gtk: Implement popup menu.
This commit is contained in:
parent
a941c20af4
commit
6939e325df
2 changed files with 25 additions and 1 deletions
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
#include "browser/api/atom_api_menu_gtk.h"
|
#include "browser/api/atom_api_menu_gtk.h"
|
||||||
|
|
||||||
|
#include "browser/native_window.h"
|
||||||
|
#include "content/public/browser/render_widget_host_view.h"
|
||||||
|
#include "ui/gfx/point.h"
|
||||||
|
#include "ui/gfx/screen.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
@ -16,6 +21,21 @@ MenuGtk::~MenuGtk() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuGtk::Popup(NativeWindow* native_window) {
|
void MenuGtk::Popup(NativeWindow* native_window) {
|
||||||
|
uint32_t triggering_event_time;
|
||||||
|
gfx::Point point;
|
||||||
|
|
||||||
|
GdkEventButton* event = native_window->GetWebContents()->
|
||||||
|
GetRenderWidgetHostView()->GetLastMouseDown();
|
||||||
|
if (event) {
|
||||||
|
triggering_event_time = event->time;
|
||||||
|
point = gfx::Point(event->x_root, event->y_root);
|
||||||
|
} else {
|
||||||
|
triggering_event_time = GDK_CURRENT_TIME;
|
||||||
|
point = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
menu_gtk_.reset(new ::MenuGtk(this, model_.get()));
|
||||||
|
menu_gtk_->PopupAsContext(point, triggering_event_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
#define ATOM_BROWSER_API_ATOM_API_MENU_GTK_H_
|
#define ATOM_BROWSER_API_ATOM_API_MENU_GTK_H_
|
||||||
|
|
||||||
#include "browser/api/atom_api_menu.h"
|
#include "browser/api/atom_api_menu.h"
|
||||||
|
#include "browser/ui/gtk/menu_gtk.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
class MenuGtk : public Menu {
|
class MenuGtk : public Menu,
|
||||||
|
public ::MenuGtk::Delegate {
|
||||||
public:
|
public:
|
||||||
explicit MenuGtk(v8::Handle<v8::Object> wrapper);
|
explicit MenuGtk(v8::Handle<v8::Object> wrapper);
|
||||||
virtual ~MenuGtk();
|
virtual ~MenuGtk();
|
||||||
|
@ -20,6 +22,8 @@ class MenuGtk : public Menu {
|
||||||
virtual void Popup(NativeWindow* window) OVERRIDE;
|
virtual void Popup(NativeWindow* window) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
scoped_ptr<::MenuGtk> menu_gtk_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MenuGtk);
|
DISALLOW_COPY_AND_ASSIGN(MenuGtk);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue