Implement Menu.closePopup on Windows/Linux
This commit is contained in:
parent
0a5ccdccb4
commit
91d1af053f
2 changed files with 10 additions and 11 deletions
|
@ -49,11 +49,12 @@ void MenuViews::PopupAt(
|
|||
atom::UnresponsiveSuppressor suppressor;
|
||||
|
||||
// Show the menu.
|
||||
menu_runner_.reset(new MenuRunner(
|
||||
model(),
|
||||
flags,
|
||||
base::Bind(&MenuViews::OnMenuClosed, weak_factory_.GetWeakPtr())));
|
||||
ignore_result(menu_runner_->RunMenuAt(
|
||||
int32_t window_id = window->ID();
|
||||
auto close_callback = base::Bind(
|
||||
&MenuViews::ClosePopupAt, weak_factory_.GetWeakPtr(), window_id);
|
||||
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
|
||||
model(), flags, close_callback));
|
||||
ignore_result(menu_runners_[window_id]->RunMenuAt(
|
||||
static_cast<NativeWindowViews*>(window->window())->widget(),
|
||||
NULL,
|
||||
gfx::Rect(location, gfx::Size()),
|
||||
|
@ -61,10 +62,6 @@ void MenuViews::PopupAt(
|
|||
ui::MENU_SOURCE_MOUSE));
|
||||
}
|
||||
|
||||
void MenuViews::OnMenuClosed() {
|
||||
menu_runner_.reset();
|
||||
}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* Menu::New(mate::Arguments* args) {
|
||||
return new MenuViews(args->isolate(), args->GetThis());
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "atom/browser/api/atom_api_menu.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "ui/display/screen.h"
|
||||
|
@ -21,10 +23,10 @@ class MenuViews : public Menu {
|
|||
protected:
|
||||
void PopupAt(
|
||||
Window* window, int x, int y, int positioning_item, bool async) override;
|
||||
void OnMenuClosed();
|
||||
void ClosePopupAt(int32_t window_id);
|
||||
|
||||
private:
|
||||
std::unique_ptr<views::MenuRunner> menu_runner_;
|
||||
std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
|
||||
base::WeakPtrFactory<MenuViews> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MenuViews);
|
||||
|
|
Loading…
Reference in a new issue