summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-08 20:29:59 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-08 20:29:59 +0000
commit5f449baa69a92ea2ce4f62f5d10732e5c5dfc1ce (patch)
treee7b39a9171bfc521601b285e5a0ad63d5595f2fa /chrome/browser
parentce90764f028433b53539089a97590f47d5607e34 (diff)
downloadchromium_src-5f449baa69a92ea2ce4f62f5d10732e5c5dfc1ce.zip
chromium_src-5f449baa69a92ea2ce4f62f5d10732e5c5dfc1ce.tar.gz
chromium_src-5f449baa69a92ea2ce4f62f5d10732e5c5dfc1ce.tar.bz2
Add new chromeos specific message loop observer to map Alt-Click to
right click. BUG=chromium-os:7239 TEST=Hold Alt key while clicking (or tapping with that enabled) Context menu should appear. Ensure it works in tabs, empty part of tab strip, web content, text input areas, links. Review URL: http://codereview.chromium.org/3551019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_main_posix.cc4
-rw-r--r--chrome/browser/chromeos/browser_main_chromeos.cc53
-rw-r--r--chrome/browser/chromeos/browser_main_chromeos.h20
3 files changed, 75 insertions, 2 deletions
diff --git a/chrome/browser/browser_main_posix.cc b/chrome/browser/browser_main_posix.cc
index e6675f6..c2fc98c 100644
--- a/chrome/browser/browser_main_posix.cc
+++ b/chrome/browser/browser_main_posix.cc
@@ -219,8 +219,8 @@ void BrowserMainPartsPosix::PostMainMessageLoopStart() {
}
}
-// Mac further subclasses BrowserMainPartsPosix
-#if !defined(OS_MACOSX)
+// Mac and Chromeos further subclass BrowserMainPartsPosix.
+#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
// static
BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
const MainFunctionParams& parameters) {
diff --git a/chrome/browser/chromeos/browser_main_chromeos.cc b/chrome/browser/chromeos/browser_main_chromeos.cc
new file mode 100644
index 0000000..df4653a
--- /dev/null
+++ b/chrome/browser/chromeos/browser_main_chromeos.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2010 The Chromium 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 "chrome/browser/chromeos/browser_main_chromeos.h"
+
+#include "base/message_loop.h"
+#include "base/singleton.h"
+
+#include <gtk/gtk.h>
+
+class MessageLoopObserver : public MessageLoopForUI::Observer {
+ virtual void WillProcessEvent(GdkEvent* event) {
+ // On chromeos we want to map Alt-left click to right click.
+ // This code only changes presses and releases. We could decide to also
+ // modify drags and crossings. It doesn't seem to be a problem right now
+ // with our support for context menus (the only real need we have).
+ // There are some inconsistent states both with what we have and what
+ // we would get if we added drags. You could get a right drag without a
+ // right down for example, unless we started synthesizing events, which
+ // seems like more trouble than it's worth.
+ if ((event->type == GDK_BUTTON_PRESS ||
+ event->type == GDK_2BUTTON_PRESS ||
+ event->type == GDK_3BUTTON_PRESS ||
+ event->type == GDK_BUTTON_RELEASE) &&
+ event->button.button == 1 &&
+ event->button.state & GDK_MOD1_MASK) {
+ // Change the button to the third (right) one.
+ event->button.button = 3;
+ // Remove the Alt key and first button state.
+ event->button.state &= ~(GDK_MOD1_MASK | GDK_BUTTON1_MASK);
+ // Add the third (right) button state.
+ event->button.state |= GDK_BUTTON3_MASK;
+ }
+ }
+
+ virtual void DidProcessEvent(GdkEvent* event) {
+ }
+};
+
+void BrowserMainPartsChromeos::PostMainMessageLoopStart() {
+ static Singleton<MessageLoopObserver> observer;
+
+ BrowserMainPartsPosix::PostMainMessageLoopStart();
+ MessageLoopForUI* message_loop = MessageLoopForUI::current();
+ message_loop->AddObserver(observer.get());
+}
+
+// static
+BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
+ const MainFunctionParams& parameters) {
+ return new BrowserMainPartsChromeos(parameters);
+}
diff --git a/chrome/browser/chromeos/browser_main_chromeos.h b/chrome/browser/chromeos/browser_main_chromeos.h
new file mode 100644
index 0000000..de8deb4
--- /dev/null
+++ b/chrome/browser/chromeos/browser_main_chromeos.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_BROWSER_MAIN_CHROMEOS_H_
+#define CHROME_BROWSER_CHROMEOS_BROWSER_MAIN_CHROMEOS_H_
+
+#include "chrome/browser/browser_main_posix.h"
+
+class BrowserMainPartsChromeos : public BrowserMainPartsPosix {
+ public:
+ explicit BrowserMainPartsChromeos(const MainFunctionParams& parameters)
+ : BrowserMainPartsPosix(parameters) {}
+
+ protected:
+ virtual void PostMainMessageLoopStart();
+ DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsChromeos);
+};
+
+#endif // CHROME_BROWSER_CHROMEOS_BROWSER_MAIN_CHROMEOS_H_