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

Unified Diff: ui/base/accelerators/accelerator_gtk.cc

Issue 9965049: ui/base: Clean up our AcceleratorGtk class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
Index: ui/base/accelerators/accelerator_gtk.cc
diff --git a/ui/base/accelerators/accelerator_gtk.cc b/ui/base/accelerators/accelerator_gtk.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6c09a60b48dc559c3eae6f204e3c34577d61e109
--- /dev/null
+++ b/ui/base/accelerators/accelerator_gtk.cc
@@ -0,0 +1,52 @@
+// 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 "ui/base/accelerators/accelerator_gtk.h"
+
+#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
+#include "ui/base/keycodes/keyboard_codes_posix.h"
+
+namespace ui {
+
+AcceleratorGtk::AcceleratorGtk() : gdk_key_code_(0) {
+}
+
+AcceleratorGtk::AcceleratorGtk(guint key_code, GdkModifierType modifier_type) {
+ key_code_ = WindowsKeyCodeForGdkKeyCode(key_code);
sky 2012/04/02 15:12:16 use the member initializer list for these.
tfarina 2012/04/02 20:25:16 Done.
+ gdk_key_code_ = key_code;
+ modifiers_ = modifier_type;
+}
+
+AcceleratorGtk::AcceleratorGtk(KeyboardCode key_code,
+ bool shift_pressed,
+ bool ctrl_pressed,
+ bool alt_pressed)
+ : gdk_key_code_(0) {
+ key_code_ = key_code;
sky 2012/04/02 15:12:16 use member initializer list for key_code_ and modi
tfarina 2012/04/02 20:25:16 Done.
+ modifiers_ = 0;
+ if (shift_pressed)
+ modifiers_ |= GDK_SHIFT_MASK;
+ if (ctrl_pressed)
+ modifiers_ |= GDK_CONTROL_MASK;
+ if (alt_pressed)
+ modifiers_ |= GDK_MOD1_MASK;
+}
+
+AcceleratorGtk::~AcceleratorGtk() {
+}
+
+guint AcceleratorGtk::GetGdkKeyCode() const {
+ if (gdk_key_code_ > 0)
+ return gdk_key_code_;
+
+ // The second parameter is false because accelerator keys are expressed in
+ // terms of the non-shift-modified key.
+ return GdkKeyCodeForWindowsKeyCode(key_code_, false);
+}
+
+GdkModifierType AcceleratorGtk::GetGdkModifierType() const {
+ return static_cast<GdkModifierType>(modifiers_);
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698