mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Create 2272 release branch for CEF3.
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/2272@1993 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
72
libcef/browser/menu_creator_runner_linux.cc
Normal file
72
libcef/browser/menu_creator_runner_linux.cc
Normal file
@ -0,0 +1,72 @@
|
||||
// Copyright 2014 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_linux.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/window_x11.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "ui/aura/window.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
||||
CefMenuCreatorRunnerLinux::CefMenuCreatorRunnerLinux() {
|
||||
}
|
||||
|
||||
CefMenuCreatorRunnerLinux::~CefMenuCreatorRunnerLinux() {
|
||||
}
|
||||
|
||||
bool CefMenuCreatorRunnerLinux::RunContextMenu(CefMenuCreator* manager) {
|
||||
menu_.reset(
|
||||
new views::MenuRunner(manager->model(), views::MenuRunner::CONTEXT_MENU));
|
||||
|
||||
gfx::Point screen_point;
|
||||
|
||||
if (manager->browser()->IsWindowless()) {
|
||||
CefRefPtr<CefClient> client = manager->browser()->GetClient();
|
||||
if (!client.get())
|
||||
return false;
|
||||
|
||||
CefRefPtr<CefRenderHandler> handler = client->GetRenderHandler();
|
||||
if (!handler.get())
|
||||
return false;
|
||||
|
||||
int screenX = 0, screenY = 0;
|
||||
if (!handler->GetScreenPoint(manager->browser(),
|
||||
manager->params().x, manager->params().y,
|
||||
screenX, screenY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
screen_point = gfx::Point(screenX, screenY);
|
||||
} else {
|
||||
// We can't use aura::Window::GetBoundsInScreen on Linux because it will
|
||||
// return bounds from DesktopWindowTreeHostX11 which in our case is relative
|
||||
// to the parent window instead of the root window (screen).
|
||||
const gfx::Rect& bounds_in_screen =
|
||||
manager->browser()->window_x11()->GetBoundsInScreen();
|
||||
screen_point = gfx::Point(bounds_in_screen.x() + manager->params().x,
|
||||
bounds_in_screen.y() + manager->params().y);
|
||||
}
|
||||
|
||||
views::MenuRunner::RunResult result =
|
||||
menu_->RunMenuAt(manager->browser()->window_widget(),
|
||||
NULL, gfx::Rect(screen_point, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPRIGHT,
|
||||
ui::MENU_SOURCE_NONE);
|
||||
ALLOW_UNUSED_LOCAL(result);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefMenuCreatorRunnerLinux::CancelContextMenu() {
|
||||
if (menu_)
|
||||
menu_->Cancel();
|
||||
}
|
||||
|
||||
bool CefMenuCreatorRunnerLinux::FormatLabel(base::string16& label) {
|
||||
// Remove the accelerator indicator (&) from label strings.
|
||||
const char16 replace[] = {L'&', 0};
|
||||
return base::ReplaceChars(label, replace, base::string16(), &label);
|
||||
}
|
Reference in New Issue
Block a user