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

Side by Side Diff: views/event_gtk.cc

Issue 235025: Use windows keycodes under linux (and all non-windows platforms). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « views/event.h ('k') | views/focus/accelerator_handler_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "views/event.h" 5 #include "views/event.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 8
9 #include "base/keyboard_code_conversion_gtk.h"
10
9 namespace views { 11 namespace views {
10 12
11 // TODO(jcampan): the same physical key can send different keyvals (ex: a or A). 13 // TODO(jcampan): the same physical key can send different keyvals (ex: a or A).
12 // In order for accelerators to work, we need to normalize that. The right 14 // In order for accelerators to work, we need to normalize that. The right
13 // solution should probably to get the key-code out of the keystate. 15 // solution should probably to get the key-code out of the keystate.
14 KeyEvent::KeyEvent(GdkEventKey* event, bool make_lower_case) 16 KeyEvent::KeyEvent(GdkEventKey* event)
15 : Event(event->type == GDK_KEY_PRESS ? 17 : Event(event->type == GDK_KEY_PRESS ?
16 Event::ET_KEY_PRESSED : Event::ET_KEY_RELEASED, 18 Event::ET_KEY_PRESSED : Event::ET_KEY_RELEASED,
17 GetFlagsFromGdkState(event->state)), 19 GetFlagsFromGdkState(event->state)),
18 // TODO(erg): All these values are iffy. 20 // TODO(erg): All these values are iffy.
19 character_(make_lower_case ? gdk_keyval_to_lower(event->keyval) : 21 character_(base::WindowsKeyCodeForGdkKeyCode(event->keyval)),
20 event->keyval),
21 repeat_count_(0), 22 repeat_count_(0),
22 message_flags_(0) { 23 message_flags_(0) {
23 } 24 }
24 25
25 int Event::GetFlagsFromGdkState(int state) { 26 int Event::GetFlagsFromGdkState(int state) {
26 int flags = 0; 27 int flags = 0;
27 if (state & GDK_CONTROL_MASK) 28 if (state & GDK_CONTROL_MASK)
28 flags |= Event::EF_CONTROL_DOWN; 29 flags |= Event::EF_CONTROL_DOWN;
29 if (state & GDK_SHIFT_MASK) 30 if (state & GDK_SHIFT_MASK)
30 flags |= Event::EF_SHIFT_DOWN; 31 flags |= Event::EF_SHIFT_DOWN;
31 if (state & GDK_MOD1_MASK) 32 if (state & GDK_MOD1_MASK)
32 flags |= Event::EF_ALT_DOWN; 33 flags |= Event::EF_ALT_DOWN;
33 if (state & GDK_BUTTON1_MASK) 34 if (state & GDK_BUTTON1_MASK)
34 flags |= Event::EF_LEFT_BUTTON_DOWN; 35 flags |= Event::EF_LEFT_BUTTON_DOWN;
35 if (state & GDK_BUTTON2_MASK) 36 if (state & GDK_BUTTON2_MASK)
36 flags |= Event::EF_MIDDLE_BUTTON_DOWN; 37 flags |= Event::EF_MIDDLE_BUTTON_DOWN;
37 if (state & GDK_BUTTON3_MASK) 38 if (state & GDK_BUTTON3_MASK)
38 flags |= Event::EF_RIGHT_BUTTON_DOWN; 39 flags |= Event::EF_RIGHT_BUTTON_DOWN;
39 return flags; 40 return flags;
40 } 41 }
41 42
42 } // namespace views 43 } // namespace views
OLDNEW
« no previous file with comments | « views/event.h ('k') | views/focus/accelerator_handler_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698