Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3263)

Unified Diff: chrome/browser/ui/gtk/event_utils.cc

Issue 10546116: gtk: Extract event functions into event_utils module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/event_utils.h ('k') | chrome/browser/ui/gtk/event_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/event_utils.cc
diff --git a/chrome/browser/ui/gtk/event_utils.cc b/chrome/browser/ui/gtk/event_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8b54f01ec4ea4cf595aec6cf19b28b7dc5e7cd8b
--- /dev/null
+++ b/chrome/browser/ui/gtk/event_utils.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 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/ui/gtk/event_utils.h"
+
+#include "base/logging.h"
+#include "chrome/browser/event_disposition.h"
+#include "ui/base/events.h"
+
+namespace event_utils {
+
+int EventFlagsFromGdkState(guint state) {
+ int flags = ui::EF_NONE;
+ flags |= (state & GDK_LOCK_MASK) ? ui::EF_CAPS_LOCK_DOWN : ui::EF_NONE;
+ flags |= (state & GDK_CONTROL_MASK) ? ui::EF_CONTROL_DOWN : ui::EF_NONE;
+ flags |= (state & GDK_SHIFT_MASK) ? ui::EF_SHIFT_DOWN : ui::EF_NONE;
+ flags |= (state & GDK_MOD1_MASK) ? ui::EF_ALT_DOWN : ui::EF_NONE;
+ flags |= (state & GDK_BUTTON1_MASK) ? ui::EF_LEFT_MOUSE_BUTTON : ui::EF_NONE;
+ flags |= (state & GDK_BUTTON2_MASK) ? ui::EF_MIDDLE_MOUSE_BUTTON
+ : ui::EF_NONE;
+ flags |= (state & GDK_BUTTON3_MASK) ? ui::EF_RIGHT_MOUSE_BUTTON : ui::EF_NONE;
+ return flags;
+}
+
+// TODO(shinyak) This function will be removed after refactoring.
+WindowOpenDisposition DispositionFromGdkState(guint state) {
+ int event_flags = EventFlagsFromGdkState(state);
+ return browser::DispositionFromEventFlags(event_flags);
+}
+
+WindowOpenDisposition DispositionForCurrentButtonPressEvent() {
+ GdkEvent* event = gtk_get_current_event();
+ if (!event) {
+ NOTREACHED();
+ return NEW_FOREGROUND_TAB;
+ }
+
+ guint state = event->button.state;
+ gdk_event_free(event);
+ return DispositionFromGdkState(state);
+}
+
+} // namespace event_utils
« no previous file with comments | « chrome/browser/ui/gtk/event_utils.h ('k') | chrome/browser/ui/gtk/event_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698