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

Side by Side 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, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/base/accelerators/accelerator_gtk.h"
6
7 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
8 #include "ui/base/keycodes/keyboard_codes_posix.h"
9
10 namespace ui {
11
12 AcceleratorGtk::AcceleratorGtk() : gdk_key_code_(0) {
13 }
14
15 AcceleratorGtk::AcceleratorGtk(guint key_code, GdkModifierType modifier_type) {
16 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.
17 gdk_key_code_ = key_code;
18 modifiers_ = modifier_type;
19 }
20
21 AcceleratorGtk::AcceleratorGtk(KeyboardCode key_code,
22 bool shift_pressed,
23 bool ctrl_pressed,
24 bool alt_pressed)
25 : gdk_key_code_(0) {
26 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.
27 modifiers_ = 0;
28 if (shift_pressed)
29 modifiers_ |= GDK_SHIFT_MASK;
30 if (ctrl_pressed)
31 modifiers_ |= GDK_CONTROL_MASK;
32 if (alt_pressed)
33 modifiers_ |= GDK_MOD1_MASK;
34 }
35
36 AcceleratorGtk::~AcceleratorGtk() {
37 }
38
39 guint AcceleratorGtk::GetGdkKeyCode() const {
40 if (gdk_key_code_ > 0)
41 return gdk_key_code_;
42
43 // The second parameter is false because accelerator keys are expressed in
44 // terms of the non-shift-modified key.
45 return GdkKeyCodeForWindowsKeyCode(key_code_, false);
46 }
47
48 GdkModifierType AcceleratorGtk::GetGdkModifierType() const {
49 return static_cast<GdkModifierType>(modifiers_);
50 }
51
52 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698