| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef APP_MENUS_ACCELERATOR_GTK_H_ | 5 #ifndef APP_MENUS_ACCELERATOR_GTK_H_ |
| 6 #define APP_MENUS_ACCELERATOR_GTK_H_ | 6 #define APP_MENUS_ACCELERATOR_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gdk/gdk.h> | 9 #include <gdk/gdk.h> |
| 10 | 10 |
| 11 #include "app/keyboard_code_conversion_gtk.h" | |
| 12 #include "app/keyboard_codes_posix.h" | |
| 13 #include "app/menus/accelerator.h" | 11 #include "app/menus/accelerator.h" |
| 12 #include "base/keyboard_code_conversion_gtk.h" |
| 13 #include "base/keyboard_codes_posix.h" |
| 14 | 14 |
| 15 namespace menus { | 15 namespace menus { |
| 16 | 16 |
| 17 class AcceleratorGtk : public Accelerator { | 17 class AcceleratorGtk : public Accelerator { |
| 18 public: | 18 public: |
| 19 AcceleratorGtk(app::KeyboardCode key_code, | 19 AcceleratorGtk(base::KeyboardCode key_code, |
| 20 bool shift_pressed, bool ctrl_pressed, bool alt_pressed) | 20 bool shift_pressed, bool ctrl_pressed, bool alt_pressed) |
| 21 : gdk_keyval_(0) { | 21 : gdk_keyval_(0) { |
| 22 key_code_ = key_code; | 22 key_code_ = key_code; |
| 23 modifiers_ = 0; | 23 modifiers_ = 0; |
| 24 if (shift_pressed) | 24 if (shift_pressed) |
| 25 modifiers_ |= GDK_SHIFT_MASK; | 25 modifiers_ |= GDK_SHIFT_MASK; |
| 26 if (ctrl_pressed) | 26 if (ctrl_pressed) |
| 27 modifiers_ |= GDK_CONTROL_MASK; | 27 modifiers_ |= GDK_CONTROL_MASK; |
| 28 if (alt_pressed) | 28 if (alt_pressed) |
| 29 modifiers_ |= GDK_MOD1_MASK; | 29 modifiers_ |= GDK_MOD1_MASK; |
| 30 } | 30 } |
| 31 | 31 |
| 32 AcceleratorGtk(guint keyval, GdkModifierType modifier_type) { | 32 AcceleratorGtk(guint keyval, GdkModifierType modifier_type) { |
| 33 key_code_ = app::WindowsKeyCodeForGdkKeyCode(keyval); | 33 key_code_ = base::WindowsKeyCodeForGdkKeyCode(keyval); |
| 34 gdk_keyval_ = keyval; | 34 gdk_keyval_ = keyval; |
| 35 modifiers_ = modifier_type; | 35 modifiers_ = modifier_type; |
| 36 } | 36 } |
| 37 | 37 |
| 38 AcceleratorGtk() : gdk_keyval_(0) { } | 38 AcceleratorGtk() : gdk_keyval_(0) { } |
| 39 virtual ~AcceleratorGtk() { } | 39 virtual ~AcceleratorGtk() { } |
| 40 | 40 |
| 41 guint GetGdkKeyCode() const { | 41 guint GetGdkKeyCode() const { |
| 42 return gdk_keyval_ > 0 ? | 42 return gdk_keyval_ > 0 ? |
| 43 // The second parameter is false because accelerator keys are | 43 // The second parameter is false because accelerator keys are |
| 44 // expressed in terms of the non-shift-modified key. | 44 // expressed in terms of the non-shift-modified key. |
| 45 gdk_keyval_ : app::GdkKeyCodeForWindowsKeyCode(key_code_, false); | 45 gdk_keyval_ : base::GdkKeyCodeForWindowsKeyCode(key_code_, false); |
| 46 } | 46 } |
| 47 | 47 |
| 48 GdkModifierType gdk_modifier_type() { | 48 GdkModifierType gdk_modifier_type() { |
| 49 return static_cast<GdkModifierType>(modifiers()); | 49 return static_cast<GdkModifierType>(modifiers()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 // The GDK keycode. | 53 // The GDK keycode. |
| 54 guint gdk_keyval_; | 54 guint gdk_keyval_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 } // namespace menus | 57 } // namespace menus |
| 58 | 58 |
| 59 #endif // APP_MENUS_ACCELERATOR_GTK_H_ | 59 #endif // APP_MENUS_ACCELERATOR_GTK_H_ |
| OLD | NEW |