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

Side by Side Diff: chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.h

Issue 335923004: aura-linux: Fixes super/hyper/meta key support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | « no previous file | chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_UI_LIBGTK2UI_X11_INPUT_METHOD_CONTEXT_IMPL_GTK2_H_ 5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_X11_INPUT_METHOD_CONTEXT_IMPL_GTK2_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_X11_INPUT_METHOD_CONTEXT_IMPL_GTK2_H_ 6 #define CHROME_BROWSER_UI_LIBGTK2UI_X11_INPUT_METHOD_CONTEXT_IMPL_GTK2_H_
7 7
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/event_types.h"
9 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
10 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
11 #include "ui/base/glib/glib_integers.h" 12 #include "ui/base/glib/glib_integers.h"
12 #include "ui/base/glib/glib_signal.h" 13 #include "ui/base/glib/glib_signal.h"
13 #include "ui/base/ime/linux/linux_input_method_context.h" 14 #include "ui/base/ime/linux/linux_input_method_context.h"
14 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
15 16
17 typedef union _GdkEvent GdkEvent;
16 typedef struct _GdkDrawable GdkWindow; 18 typedef struct _GdkDrawable GdkWindow;
17 typedef struct _GtkIMContext GtkIMContext; 19 typedef struct _GtkIMContext GtkIMContext;
18 20
19 namespace libgtk2ui { 21 namespace libgtk2ui {
20 22
21 // An implementation of LinuxInputMethodContext which is based on X11 event loop 23 // An implementation of LinuxInputMethodContext which is based on X11 event loop
22 // and uses GtkIMContext(gtk-immodule) as a bridge from/to underlying IMEs. 24 // and uses GtkIMContext(gtk-immodule) as a bridge from/to underlying IMEs.
23 class X11InputMethodContextImplGtk2 : public ui::LinuxInputMethodContext { 25 class X11InputMethodContextImplGtk2 : public ui::LinuxInputMethodContext {
24 public: 26 public:
25 explicit X11InputMethodContextImplGtk2( 27 explicit X11InputMethodContextImplGtk2(
26 ui::LinuxInputMethodContextDelegate* delegate); 28 ui::LinuxInputMethodContextDelegate* delegate);
27 virtual ~X11InputMethodContextImplGtk2(); 29 virtual ~X11InputMethodContextImplGtk2();
28 30
29 // Overriden from ui::LinuxInputMethodContext 31 // Overriden from ui::LinuxInputMethodContext
30 virtual bool DispatchKeyEvent(const ui::KeyEvent& key_event) OVERRIDE; 32 virtual bool DispatchKeyEvent(const ui::KeyEvent& key_event) OVERRIDE;
31 virtual void Reset() OVERRIDE; 33 virtual void Reset() OVERRIDE;
32 virtual void OnTextInputTypeChanged(ui::TextInputType text_input_type) 34 virtual void OnTextInputTypeChanged(ui::TextInputType text_input_type)
33 OVERRIDE; 35 OVERRIDE;
34 virtual void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) OVERRIDE; 36 virtual void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) OVERRIDE;
35 37
36 private: 38 private:
39 // Resets the cache of X modifier keycodes.
40 // TODO(yukishiino): We should call this method whenever X keyboard mapping
41 // changes, for example when a user switched to another keyboard layout.
42 void ResetXModifierKeycodesCache();
43
44 // Constructs a GdkEventKey from a XKeyEvent and returns it. Otherwise,
45 // returns NULL. The returned GdkEvent must be freed by gdk_event_free.
46 GdkEvent* GdkEventFromNativeEvent(const base::NativeEvent& native_event);
47
37 // Returns true if the hardware |keycode| is assigned to a modifier key. 48 // Returns true if the hardware |keycode| is assigned to a modifier key.
38 bool IsKeycodeModifierKey(unsigned int keycode) const; 49 bool IsKeycodeModifierKey(unsigned int keycode) const;
39 50
51 // Returns true if one of |keycodes| is pressed. |keybits| is a bit vector
52 // returned by XQueryKeymap, and |num_keys| is the number of keys in
53 // |keybits|.
54 bool IsAnyOfKeycodesPressed(const std::vector<int>& keycodes,
55 const char* keybits,
56 int num_keys) const;
57
40 // GtkIMContext event handlers. They are shared among |gtk_context_simple_| 58 // GtkIMContext event handlers. They are shared among |gtk_context_simple_|
41 // and |gtk_multicontext_|. 59 // and |gtk_multicontext_|.
42 CHROMEG_CALLBACK_1(X11InputMethodContextImplGtk2, void, OnCommit, 60 CHROMEG_CALLBACK_1(X11InputMethodContextImplGtk2, void, OnCommit,
43 GtkIMContext*, gchar*); 61 GtkIMContext*, gchar*);
44 CHROMEG_CALLBACK_0(X11InputMethodContextImplGtk2, void, OnPreeditChanged, 62 CHROMEG_CALLBACK_0(X11InputMethodContextImplGtk2, void, OnPreeditChanged,
45 GtkIMContext*); 63 GtkIMContext*);
46 CHROMEG_CALLBACK_0(X11InputMethodContextImplGtk2, void, OnPreeditEnd, 64 CHROMEG_CALLBACK_0(X11InputMethodContextImplGtk2, void, OnPreeditEnd,
47 GtkIMContext*); 65 GtkIMContext*);
48 CHROMEG_CALLBACK_0(X11InputMethodContextImplGtk2, void, OnPreeditStart, 66 CHROMEG_CALLBACK_0(X11InputMethodContextImplGtk2, void, OnPreeditStart,
49 GtkIMContext*); 67 GtkIMContext*);
(...skipping 13 matching lines...) Expand all
63 81
64 // Last set client window. 82 // Last set client window.
65 GdkWindow* gdk_last_set_client_window_; 83 GdkWindow* gdk_last_set_client_window_;
66 84
67 // Last known caret bounds relative to the screen coordinates. 85 // Last known caret bounds relative to the screen coordinates.
68 gfx::Rect last_caret_bounds_; 86 gfx::Rect last_caret_bounds_;
69 87
70 // A set of hardware keycodes of modifier keys. 88 // A set of hardware keycodes of modifier keys.
71 base::hash_set<unsigned int> modifier_keycodes_; 89 base::hash_set<unsigned int> modifier_keycodes_;
72 90
91 // A list of keycodes of each modifier key.
92 std::vector<int> meta_keycodes_;
93 std::vector<int> super_keycodes_;
94 std::vector<int> hyper_keycodes_;
95
73 // The helper class to trap GTK+'s "commit" signal for direct input key 96 // The helper class to trap GTK+'s "commit" signal for direct input key
74 // events. 97 // events.
75 // 98 //
76 // gtk_im_context_filter_keypress() emits "commit" signal in order to insert 99 // gtk_im_context_filter_keypress() emits "commit" signal in order to insert
77 // a character which is not actually processed by a IME. This behavior seems, 100 // a character which is not actually processed by a IME. This behavior seems,
78 // in Javascript world, that a keydown event with keycode = VKEY_PROCESSKEY 101 // in Javascript world, that a keydown event with keycode = VKEY_PROCESSKEY
79 // (= 229) is fired. So we have to trap such "commit" signal for direct input 102 // (= 229) is fired. So we have to trap such "commit" signal for direct input
80 // key events. This class helps to trap such events. 103 // key events. This class helps to trap such events.
81 class GtkCommitSignalTrap { 104 class GtkCommitSignalTrap {
82 public: 105 public:
(...skipping 26 matching lines...) Expand all
109 132
110 FRIEND_TEST_ALL_PREFIXES(X11InputMethodContextImplGtk2FriendTest, 133 FRIEND_TEST_ALL_PREFIXES(X11InputMethodContextImplGtk2FriendTest,
111 GtkCommitSignalTrap); 134 GtkCommitSignalTrap);
112 135
113 DISALLOW_COPY_AND_ASSIGN(X11InputMethodContextImplGtk2); 136 DISALLOW_COPY_AND_ASSIGN(X11InputMethodContextImplGtk2);
114 }; 137 };
115 138
116 } // namespace libgtk2ui 139 } // namespace libgtk2ui
117 140
118 #endif // CHROME_BROWSER_UI_LIBGTK2UI_X11_INPUT_METHOD_CONTEXT_IMPL_GTK2_H_ 141 #endif // CHROME_BROWSER_UI_LIBGTK2UI_X11_INPUT_METHOD_CONTEXT_IMPL_GTK2_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698