| OLD | NEW |
| 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 #include <X11/keysym.h> | 5 #include <X11/keysym.h> |
| 6 #include <X11/Xlib.h> | 6 #include <X11/Xlib.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/aura/client/screen_position_client.h" | 10 #include "ui/aura/client/screen_position_client.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 public: | 49 public: |
| 50 UIControlsX11(WindowTreeHost* host) : host_(host) { | 50 UIControlsX11(WindowTreeHost* host) : host_(host) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual bool SendKeyPress(gfx::NativeWindow window, | 53 virtual bool SendKeyPress(gfx::NativeWindow window, |
| 54 ui::KeyboardCode key, | 54 ui::KeyboardCode key, |
| 55 bool control, | 55 bool control, |
| 56 bool shift, | 56 bool shift, |
| 57 bool alt, | 57 bool alt, |
| 58 bool command) OVERRIDE { | 58 bool command) OVERRIDE { |
| 59 DCHECK(!command); // No command key on Aura |
| 59 return SendKeyPressNotifyWhenDone( | 60 return SendKeyPressNotifyWhenDone( |
| 60 window, key, control, shift, alt, command, base::Closure()); | 61 window, key, control, shift, alt, command, base::Closure()); |
| 61 } | 62 } |
| 62 virtual bool SendKeyPressNotifyWhenDone( | 63 virtual bool SendKeyPressNotifyWhenDone( |
| 63 gfx::NativeWindow window, | 64 gfx::NativeWindow window, |
| 64 ui::KeyboardCode key, | 65 ui::KeyboardCode key, |
| 65 bool control, | 66 bool control, |
| 66 bool shift, | 67 bool shift, |
| 67 bool alt, | 68 bool alt, |
| 68 bool command, | 69 bool command, |
| 69 const base::Closure& closure) OVERRIDE { | 70 const base::Closure& closure) OVERRIDE { |
| 71 DCHECK(!command); // No command key on Aura |
| 70 XEvent xevent = {0}; | 72 XEvent xevent = {0}; |
| 71 xevent.xkey.type = KeyPress; | 73 xevent.xkey.type = KeyPress; |
| 72 if (control) | 74 if (control) |
| 73 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask); | 75 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask); |
| 74 if (shift) | 76 if (shift) |
| 75 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); | 77 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); |
| 76 if (alt) | 78 if (alt) |
| 77 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); | 79 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); |
| 78 if (command) | |
| 79 SetKeycodeAndSendThenMask(&xevent, XK_Super_L, Mod4Mask); | |
| 80 xevent.xkey.keycode = | 80 xevent.xkey.keycode = |
| 81 XKeysymToKeycode(gfx::GetXDisplay(), | 81 XKeysymToKeycode(gfx::GetXDisplay(), |
| 82 ui::XKeysymForWindowsKeyCode(key, shift)); | 82 ui::XKeysymForWindowsKeyCode(key, shift)); |
| 83 host_->PostNativeEvent(&xevent); | 83 host_->PostNativeEvent(&xevent); |
| 84 | 84 |
| 85 // Send key release events. | 85 // Send key release events. |
| 86 xevent.xkey.type = KeyRelease; | 86 xevent.xkey.type = KeyRelease; |
| 87 host_->PostNativeEvent(&xevent); | 87 host_->PostNativeEvent(&xevent); |
| 88 if (alt) | 88 if (alt) |
| 89 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); | 89 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); |
| 90 if (shift) | 90 if (shift) |
| 91 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); | 91 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); |
| 92 if (control) | 92 if (control) |
| 93 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L); | 93 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L); |
| 94 if (command) | |
| 95 UnmaskAndSetKeycodeThenSend(&xevent, Mod4Mask, XK_Super_L); | |
| 96 DCHECK(!xevent.xkey.state); | 94 DCHECK(!xevent.xkey.state); |
| 97 RunClosureAfterAllPendingUIEvents(closure); | 95 RunClosureAfterAllPendingUIEvents(closure); |
| 98 return true; | 96 return true; |
| 99 } | 97 } |
| 100 | 98 |
| 101 virtual bool SendMouseMove(long screen_x, long screen_y) OVERRIDE { | 99 virtual bool SendMouseMove(long screen_x, long screen_y) OVERRIDE { |
| 102 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure()); | 100 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure()); |
| 103 } | 101 } |
| 104 virtual bool SendMouseMoveNotifyWhenDone( | 102 virtual bool SendMouseMoveNotifyWhenDone( |
| 105 long screen_x, | 103 long screen_x, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 }; | 223 }; |
| 226 | 224 |
| 227 } // namespace | 225 } // namespace |
| 228 | 226 |
| 229 UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) { | 227 UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) { |
| 230 return new UIControlsX11(host); | 228 return new UIControlsX11(host); |
| 231 } | 229 } |
| 232 | 230 |
| 233 } // namespace test | 231 } // namespace test |
| 234 } // namespace aura | 232 } // namespace aura |
| OLD | NEW |