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

Side by Side Diff: app/event_synthesis_gtk.cc

Issue 3165064: Move the keyboard files from base/ to app/. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: latest merge Created 10 years, 4 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
« no previous file with comments | « app/event_synthesis_gtk.h ('k') | app/keyboard_code_conversion.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/event_synthesis_gtk.h" 5 #include "app/event_synthesis_gtk.h"
6 6
7 #include "base/keyboard_code_conversion_gtk.h" 7 #include "app/keyboard_code_conversion_gtk.h"
8 8
9 namespace base { 9 namespace app {
10 10
11 GdkEvent* SynthesizeKeyEvent(GdkWindow* window, 11 GdkEvent* SynthesizeKeyEvent(GdkWindow* window,
12 bool press, guint gdk_key, guint state) { 12 bool press, guint gdk_key, guint state) {
13 GdkEvent* event = gdk_event_new(press ? GDK_KEY_PRESS : GDK_KEY_RELEASE); 13 GdkEvent* event = gdk_event_new(press ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
14 14
15 event->key.type = press ? GDK_KEY_PRESS : GDK_KEY_RELEASE; 15 event->key.type = press ? GDK_KEY_PRESS : GDK_KEY_RELEASE;
16 event->key.window = window; 16 event->key.window = window;
17 if (window) 17 if (window)
18 g_object_ref(window); 18 g_object_ref(window);
19 event->key.send_event = false; 19 event->key.send_event = false;
(...skipping 12 matching lines...) Expand all
32 event->key.keyval, &keys, &n_keys)) { 32 event->key.keyval, &keys, &n_keys)) {
33 event->key.hardware_keycode = keys[0].keycode; 33 event->key.hardware_keycode = keys[0].keycode;
34 event->key.group = keys[0].group; 34 event->key.group = keys[0].group;
35 g_free(keys); 35 g_free(keys);
36 } 36 }
37 37
38 return event; 38 return event;
39 } 39 }
40 40
41 void SynthesizeKeyPressEvents(GdkWindow* window, 41 void SynthesizeKeyPressEvents(GdkWindow* window,
42 base::KeyboardCode key, 42 app::KeyboardCode key,
43 bool control, bool shift, bool alt, 43 bool control, bool shift, bool alt,
44 std::vector<GdkEvent*>* events) { 44 std::vector<GdkEvent*>* events) {
45 if (control) 45 if (control)
46 events->push_back( 46 events->push_back(
47 SynthesizeKeyEvent(window, true, GDK_Control_L, 0)); 47 SynthesizeKeyEvent(window, true, GDK_Control_L, 0));
48 48
49 if (shift) { 49 if (shift) {
50 events->push_back(SynthesizeKeyEvent(window, true, GDK_Shift_L, 50 events->push_back(SynthesizeKeyEvent(window, true, GDK_Shift_L,
51 control ? GDK_CONTROL_MASK : 0)); 51 control ? GDK_CONTROL_MASK : 0));
52 } 52 }
53 53
54 if (alt) { 54 if (alt) {
55 guint state = (control ? GDK_CONTROL_MASK : 0) | 55 guint state = (control ? GDK_CONTROL_MASK : 0) |
56 (shift ? GDK_SHIFT_MASK : 0); 56 (shift ? GDK_SHIFT_MASK : 0);
57 events->push_back( 57 events->push_back(
58 SynthesizeKeyEvent(window, true, GDK_Alt_L, state)); 58 SynthesizeKeyEvent(window, true, GDK_Alt_L, state));
59 } 59 }
60 60
61 // TODO(estade): handle other state flags besides control, shift, alt? 61 // TODO(estade): handle other state flags besides control, shift, alt?
62 // For example caps lock. 62 // For example caps lock.
63 guint state = (control ? GDK_CONTROL_MASK : 0) | 63 guint state = (control ? GDK_CONTROL_MASK : 0) |
64 (shift ? GDK_SHIFT_MASK : 0) | 64 (shift ? GDK_SHIFT_MASK : 0) |
65 (alt ? GDK_MOD1_MASK : 0); 65 (alt ? GDK_MOD1_MASK : 0);
66 66
67 guint gdk_key = base::GdkKeyCodeForWindowsKeyCode(key, shift); 67 guint gdk_key = GdkKeyCodeForWindowsKeyCode(key, shift);
68 events->push_back(SynthesizeKeyEvent(window, true, gdk_key, state)); 68 events->push_back(SynthesizeKeyEvent(window, true, gdk_key, state));
69 events->push_back(SynthesizeKeyEvent(window, false, gdk_key, state)); 69 events->push_back(SynthesizeKeyEvent(window, false, gdk_key, state));
70 70
71 if (alt) { 71 if (alt) {
72 guint state = (control ? GDK_CONTROL_MASK : 0) | 72 guint state = (control ? GDK_CONTROL_MASK : 0) |
73 (shift ? GDK_SHIFT_MASK : 0) | GDK_MOD1_MASK; 73 (shift ? GDK_SHIFT_MASK : 0) | GDK_MOD1_MASK;
74 events->push_back( 74 events->push_back(
75 SynthesizeKeyEvent(window, false, GDK_Alt_L, state)); 75 SynthesizeKeyEvent(window, false, GDK_Alt_L, state));
76 } 76 }
77 77
78 if (shift) { 78 if (shift) {
79 events->push_back( 79 events->push_back(
80 SynthesizeKeyEvent(window, false, GDK_Shift_L, 80 SynthesizeKeyEvent(window, false, GDK_Shift_L,
81 (control ? GDK_CONTROL_MASK : 0) | GDK_SHIFT_MASK)); 81 (control ? GDK_CONTROL_MASK : 0) | GDK_SHIFT_MASK));
82 } 82 }
83 83
84 if (control) { 84 if (control) {
85 events->push_back( 85 events->push_back(
86 SynthesizeKeyEvent(window, false, GDK_Control_L, GDK_CONTROL_MASK)); 86 SynthesizeKeyEvent(window, false, GDK_Control_L, GDK_CONTROL_MASK));
87 } 87 }
88 } 88 }
89 89
90 } // namespace base 90 } // namespace app
OLDNEW
« no previous file with comments | « app/event_synthesis_gtk.h ('k') | app/keyboard_code_conversion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698