mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-12 17:46:04 +01:00
7bc494880f
- Add new CefContextMenuHandler, CefContextMenuParams and CefMenuModel classes. - Add cef_strings.grd and related infrastructure for supporting translation of CEF strings. - Generate include/cef_pack_resources.h and include/cef_pack_strings.h files at build time that include all IDs used by CEF pack files. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@595 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
|
// reserved. Use of this source code is governed by a BSD-style license that can
|
|
// be found in the LICENSE file.
|
|
|
|
#include "libcef/browser/menu_creator_runner_gtk.h"
|
|
#include "libcef/browser/browser_host_impl.h"
|
|
|
|
#include "content/public/browser/render_widget_host_view.h"
|
|
#include "content/public/browser/web_contents_view.h"
|
|
#include "ui/gfx/point.h"
|
|
|
|
namespace {
|
|
|
|
class CefMenuDelegate : public MenuGtk::Delegate {
|
|
public:
|
|
CefMenuDelegate() {}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
|
CefMenuCreatorRunnerWin::CefMenuCreatorRunnerWin() {
|
|
}
|
|
|
|
bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) {
|
|
if (!menu_delegate_.get())
|
|
menu_delegate_.reset(new CefMenuDelegate);
|
|
|
|
// Create a menu based on the model.
|
|
menu_.reset(new MenuGtk(menu_delegate_.get(), manager->model()));
|
|
|
|
gfx::Rect bounds;
|
|
manager->browser()->GetWebContents()->GetView()->GetContainerBounds(&bounds);
|
|
gfx::Point point = bounds.origin();
|
|
point.Offset(manager->params().x, manager->params().y);
|
|
|
|
content::RenderWidgetHostView* view =
|
|
manager->browser()->GetWebContents()->GetRenderWidgetHostView();
|
|
GdkEventButton* event = view->GetLastMouseDown();
|
|
uint32_t triggering_event_time = event ? event->time : GDK_CURRENT_TIME;
|
|
|
|
// Show the menu. Execution will continue asynchronously.
|
|
menu_->PopupAsContext(point, triggering_event_time);
|
|
|
|
return true;
|
|
}
|