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

Side by Side Diff: ui/events/x/events_x.cc

Issue 243143002: linux-aura: Supports Compose key with XIM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disabled EF_IME_FABRICATED_KEY flag on CrOS. Created 6 years, 7 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 | « ui/events/event_constants.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 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 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 "ui/events/event_constants.h" 5 #include "ui/events/event_constants.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string.h> 8 #include <string.h>
9 #include <X11/extensions/XInput.h> 9 #include <X11/extensions/XInput.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (state & Button1Mask) 142 if (state & Button1Mask)
143 flags |= ui::EF_LEFT_MOUSE_BUTTON; 143 flags |= ui::EF_LEFT_MOUSE_BUTTON;
144 if (state & Button2Mask) 144 if (state & Button2Mask)
145 flags |= ui::EF_MIDDLE_MOUSE_BUTTON; 145 flags |= ui::EF_MIDDLE_MOUSE_BUTTON;
146 if (state & Button3Mask) 146 if (state & Button3Mask)
147 flags |= ui::EF_RIGHT_MOUSE_BUTTON; 147 flags |= ui::EF_RIGHT_MOUSE_BUTTON;
148 return flags; 148 return flags;
149 } 149 }
150 150
151 int GetEventFlagsFromXKeyEvent(XEvent* xevent) { 151 int GetEventFlagsFromXKeyEvent(XEvent* xevent) {
152 DCHECK(xevent->type == KeyPress || xevent->type == KeyRelease);
153
154 #if defined(OS_CHROMEOS)
155 const int ime_fabricated_flag = 0;
156 #else
157 // XIM fabricates key events for the character compositions by XK_Multi_key.
158 // For example, when a user hits XK_Multi_key, XK_apostrophe, and XK_e in
159 // order to input "é", then XIM generates a key event with keycode=0 and
160 // state=0 for the composition, and the sequence of X11 key events will be
161 // XK_Multi_key, XK_apostrophe, **NoSymbol**, and XK_e.
162 //
163 // We have to send these fabricated key events to XIM so it can correctly
164 // handle the character compositions.
165 const bool fabricated_by_xim =
166 xevent->xkey.keycode == 0 && xevent->xkey.state == 0;
167 const int ime_fabricated_flag =
168 fabricated_by_xim ? ui::EF_IME_FABRICATED_KEY : 0;
169 #endif
170
152 return GetEventFlagsFromXState(xevent->xkey.state) | 171 return GetEventFlagsFromXState(xevent->xkey.state) |
153 (IsKeypadKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_NUMPAD_KEY : 0); 172 (IsKeypadKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_NUMPAD_KEY : 0) |
173 ime_fabricated_flag;
154 } 174 }
155 175
156 // Get the event flag for the button in XButtonEvent. During a ButtonPress 176 // Get the event flag for the button in XButtonEvent. During a ButtonPress
157 // event, |state| in XButtonEvent does not include the button that has just been 177 // event, |state| in XButtonEvent does not include the button that has just been
158 // pressed. Instead |state| contains flags for the buttons (if any) that had 178 // pressed. Instead |state| contains flags for the buttons (if any) that had
159 // already been pressed before the current button, and |button| stores the most 179 // already been pressed before the current button, and |button| stores the most
160 // current pressed button. So, if you press down left mouse button, and while 180 // current pressed button. So, if you press down left mouse button, and while
161 // pressing it down, press down the right mouse button, then for the latter 181 // pressing it down, press down the right mouse button, then for the latter
162 // event, |state| would have Button1Mask set but not Button3Mask, and |button| 182 // event, |state| would have Button1Mask set but not Button3Mask, and |button|
163 // would be 3. 183 // would be 3.
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 DeviceDataManager::GetInstance()->GetGestureTimes( 690 DeviceDataManager::GetInstance()->GetGestureTimes(
671 native_event, start_time, end_time); 691 native_event, start_time, end_time);
672 return true; 692 return true;
673 } 693 }
674 694
675 bool IsTouchpadEvent(const base::NativeEvent& event) { 695 bool IsTouchpadEvent(const base::NativeEvent& event) {
676 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event); 696 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event);
677 } 697 }
678 698
679 } // namespace ui 699 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event_constants.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698