OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/libgtk2ui/gtk2_event_loop.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_event_loop.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 #include <X11/X.h> | 10 #include <X11/X.h> |
11 | 11 |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "ui/events/platform/x11/x11_event_source.h" | |
13 #include "ui/gfx/x/x11_types.h" | 14 #include "ui/gfx/x/x11_types.h" |
14 | 15 |
15 namespace libgtk2ui { | 16 namespace libgtk2ui { |
16 | 17 |
17 // static | 18 // static |
18 Gtk2EventLoop* Gtk2EventLoop::GetInstance() { | 19 Gtk2EventLoop* Gtk2EventLoop::GetInstance() { |
19 return Singleton<Gtk2EventLoop>::get(); | 20 return Singleton<Gtk2EventLoop>::get(); |
20 } | 21 } |
21 | 22 |
22 Gtk2EventLoop::Gtk2EventLoop() { | 23 Gtk2EventLoop::Gtk2EventLoop() { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 gdk_event_key.type == GDK_KEY_PRESS ? KeyPress : KeyRelease; | 64 gdk_event_key.type == GDK_KEY_PRESS ? KeyPress : KeyRelease; |
64 x_event.xkey.send_event = gdk_event_key.send_event; | 65 x_event.xkey.send_event = gdk_event_key.send_event; |
65 x_event.xkey.display = gfx::GetXDisplay(); | 66 x_event.xkey.display = gfx::GetXDisplay(); |
66 x_event.xkey.window = GDK_WINDOW_XID(gdk_event_key.window); | 67 x_event.xkey.window = GDK_WINDOW_XID(gdk_event_key.window); |
67 x_event.xkey.root = DefaultRootWindow(x_event.xkey.display); | 68 x_event.xkey.root = DefaultRootWindow(x_event.xkey.display); |
68 x_event.xkey.time = gdk_event_key.time; | 69 x_event.xkey.time = gdk_event_key.time; |
69 x_event.xkey.state = gdk_event_key.state; | 70 x_event.xkey.state = gdk_event_key.state; |
70 x_event.xkey.keycode = gdk_event_key.hardware_keycode; | 71 x_event.xkey.keycode = gdk_event_key.hardware_keycode; |
71 x_event.xkey.same_screen = true; | 72 x_event.xkey.same_screen = true; |
72 | 73 |
73 XPutBackEvent(x_event.xkey.display, &x_event); | 74 // We want to process the gtk2 event; mapped to an X11 event immediately |
75 // otherwise if we put it back on the queue we may get items out of order. | |
76 if (ui::X11EventSource* x11_source = ui::X11EventSource::GetInstance()) | |
77 x11_source->DispatchEventNow(&x_event); | |
78 else | |
79 XPutBackEvent(x_event.xkey.display, &x_event); | |
sadrul
2015/09/02 17:18:52
Can we send this key-event directly to the InputMe
| |
74 } | 80 } |
75 | 81 |
76 } // namespace libgtk2ui | 82 } // namespace libgtk2ui |
OLD | NEW |