OLD | NEW |
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/aura/window_tree_host_x11.h" | 5 #include "ui/aura/window_tree_host_x11.h" |
6 | 6 |
7 #include <strings.h> | 7 #include <strings.h> |
8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
10 #include <X11/extensions/Xrandr.h> | 10 #include <X11/extensions/Xrandr.h> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event; | 66 target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event; |
67 return target; | 67 return target; |
68 } | 68 } |
69 | 69 |
70 void SelectXInput2EventsForRootWindow(XDisplay* display, ::Window root_window) { | 70 void SelectXInput2EventsForRootWindow(XDisplay* display, ::Window root_window) { |
71 CHECK(ui::IsXInput2Available()); | 71 CHECK(ui::IsXInput2Available()); |
72 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {}; | 72 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {}; |
73 memset(mask, 0, sizeof(mask)); | 73 memset(mask, 0, sizeof(mask)); |
74 | 74 |
75 XISetMask(mask, XI_HierarchyChanged); | 75 XISetMask(mask, XI_HierarchyChanged); |
76 XISetMask(mask, XI_KeyPress); | |
77 XISetMask(mask, XI_KeyRelease); | |
78 | 76 |
79 XIEventMask evmask; | 77 XIEventMask evmask; |
80 evmask.deviceid = XIAllDevices; | 78 evmask.deviceid = XIAllDevices; |
81 evmask.mask_len = sizeof(mask); | 79 evmask.mask_len = sizeof(mask); |
82 evmask.mask = mask; | 80 evmask.mask = mask; |
83 XISelectEvents(display, root_window, &evmask, 1); | 81 XISelectEvents(display, root_window, &evmask, 1); |
84 | 82 |
85 #if defined(OS_CHROMEOS) | 83 #if defined(OS_CHROMEOS) |
86 if (base::SysInfo::IsRunningOnChromeOS()) { | 84 if (base::SysInfo::IsRunningOnChromeOS()) { |
87 // It is necessary to listen for touch events on the root window for proper | 85 // It is necessary to listen for touch events on the root window for proper |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 return ui::POST_DISPATCH_STOP_PROPAGATION; | 408 return ui::POST_DISPATCH_STOP_PROPAGATION; |
411 } | 409 } |
412 | 410 |
413 switch (xev->type) { | 411 switch (xev->type) { |
414 case Expose: { | 412 case Expose: { |
415 gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y, | 413 gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y, |
416 xev->xexpose.width, xev->xexpose.height); | 414 xev->xexpose.width, xev->xexpose.height); |
417 compositor()->ScheduleRedrawRect(damage_rect); | 415 compositor()->ScheduleRedrawRect(damage_rect); |
418 break; | 416 break; |
419 } | 417 } |
420 | |
421 case FocusOut: | 418 case FocusOut: |
422 if (xev->xfocus.mode != NotifyGrab) | 419 if (xev->xfocus.mode != NotifyGrab) |
423 OnHostLostWindowCapture(); | 420 OnHostLostWindowCapture(); |
424 break; | 421 break; |
425 case ConfigureNotify: { | 422 case ConfigureNotify: { |
426 DCHECK_EQ(xwindow_, xev->xconfigure.event); | 423 DCHECK_EQ(xwindow_, xev->xconfigure.event); |
427 DCHECK_EQ(xwindow_, xev->xconfigure.window); | 424 DCHECK_EQ(xwindow_, xev->xconfigure.window); |
428 // It's possible that the X window may be resized by some other means | 425 // It's possible that the X window may be resized by some other means |
429 // than from within aura (e.g. the X window manager can change the | 426 // than from within aura (e.g. the X window manager can change the |
430 // size). Make sure the root window size is maintained properly. | 427 // size). Make sure the root window size is maintained properly. |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 TranslateAndDispatchLocatedEvent(&mouseev); | 682 TranslateAndDispatchLocatedEvent(&mouseev); |
686 break; | 683 break; |
687 } | 684 } |
688 case ui::ET_SCROLL_FLING_START: | 685 case ui::ET_SCROLL_FLING_START: |
689 case ui::ET_SCROLL_FLING_CANCEL: | 686 case ui::ET_SCROLL_FLING_CANCEL: |
690 case ui::ET_SCROLL: { | 687 case ui::ET_SCROLL: { |
691 ui::ScrollEvent scrollev(xev); | 688 ui::ScrollEvent scrollev(xev); |
692 SendEventToProcessor(&scrollev); | 689 SendEventToProcessor(&scrollev); |
693 break; | 690 break; |
694 } | 691 } |
| 692 case ui::ET_KEY_PRESSED: |
| 693 case ui::ET_KEY_RELEASED: { |
| 694 ui::KeyEvent key_event(xev, false); |
| 695 SendEventToProcessor(&key_event); |
| 696 break; |
| 697 } |
695 case ui::ET_UMA_DATA: | 698 case ui::ET_UMA_DATA: |
696 break; | 699 break; |
697 case ui::ET_UNKNOWN: | 700 case ui::ET_UNKNOWN: |
698 break; | 701 break; |
699 default: | 702 default: |
700 NOTREACHED(); | 703 NOTREACHED(); |
701 } | 704 } |
702 | 705 |
703 // If we coalesced an event we need to free its cookie. | 706 // If we coalesced an event we need to free its cookie. |
704 if (num_coalesced > 0) | 707 if (num_coalesced > 0) |
(...skipping 23 matching lines...) Expand all Loading... |
728 } | 731 } |
729 | 732 |
730 namespace test { | 733 namespace test { |
731 | 734 |
732 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 735 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
733 default_override_redirect = override_redirect; | 736 default_override_redirect = override_redirect; |
734 } | 737 } |
735 | 738 |
736 } // namespace test | 739 } // namespace test |
737 } // namespace aura | 740 } // namespace aura |
OLD | NEW |