| 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/root_window_host_linux.h" | 5 #include "ui/aura/root_window_host_linux.h" |
| 6 | 6 |
| 7 #include <X11/cursorfont.h> | 7 #include <X11/cursorfont.h> |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 CHECK_EQ(slave_event.valuators.mask_len, xievent->valuators.mask_len); | 71 CHECK_EQ(slave_event.valuators.mask_len, xievent->valuators.mask_len); |
| 72 CHECK_EQ(slave_event.mods.base, xievent->mods.base); | 72 CHECK_EQ(slave_event.mods.base, xievent->mods.base); |
| 73 CHECK_EQ(slave_event.mods.latched, xievent->mods.latched); | 73 CHECK_EQ(slave_event.mods.latched, xievent->mods.latched); |
| 74 CHECK_EQ(slave_event.mods.locked, xievent->mods.locked); | 74 CHECK_EQ(slave_event.mods.locked, xievent->mods.locked); |
| 75 CHECK_EQ(slave_event.mods.effective, xievent->mods.effective); | 75 CHECK_EQ(slave_event.mods.effective, xievent->mods.effective); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Returns X font cursor shape from an Aura cursor. | 79 // Returns X font cursor shape from an Aura cursor. |
| 80 int CursorShapeFromNative(gfx::NativeCursor native_cursor) { | 80 int CursorShapeFromNative(gfx::NativeCursor native_cursor) { |
| 81 switch (native_cursor) { | 81 switch (native_cursor.native_type()) { |
| 82 case aura::kCursorNull: | 82 case aura::kCursorNull: |
| 83 return XC_left_ptr; | 83 return XC_left_ptr; |
| 84 case aura::kCursorPointer: | 84 case aura::kCursorPointer: |
| 85 return XC_left_ptr; | 85 return XC_left_ptr; |
| 86 case aura::kCursorCross: | 86 case aura::kCursorCross: |
| 87 return XC_crosshair; | 87 return XC_crosshair; |
| 88 case aura::kCursorHand: | 88 case aura::kCursorHand: |
| 89 return XC_hand2; | 89 return XC_hand2; |
| 90 case aura::kCursorIBeam: | 90 case aura::kCursorIBeam: |
| 91 return XC_xterm; | 91 return XC_xterm; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 case aura::kCursorAlias: | 147 case aura::kCursorAlias: |
| 148 case aura::kCursorProgress: | 148 case aura::kCursorProgress: |
| 149 case aura::kCursorNoDrop: | 149 case aura::kCursorNoDrop: |
| 150 case aura::kCursorCopy: | 150 case aura::kCursorCopy: |
| 151 case aura::kCursorNone: | 151 case aura::kCursorNone: |
| 152 case aura::kCursorNotAllowed: | 152 case aura::kCursorNotAllowed: |
| 153 case aura::kCursorZoomIn: | 153 case aura::kCursorZoomIn: |
| 154 case aura::kCursorZoomOut: | 154 case aura::kCursorZoomOut: |
| 155 case aura::kCursorGrab: | 155 case aura::kCursorGrab: |
| 156 case aura::kCursorGrabbing: | 156 case aura::kCursorGrabbing: |
| 157 // TODO(jamescook): Need cursors for these. crbug.com/111650 |
| 158 return XC_left_ptr; |
| 157 case aura::kCursorCustom: | 159 case aura::kCursorCustom: |
| 158 // TODO(jamescook): Need cursors for these. crbug.com/111650 | 160 NOTREACHED(); |
| 159 return XC_left_ptr; | 161 return XC_left_ptr; |
| 160 } | 162 } |
| 161 NOTREACHED(); | 163 NOTREACHED(); |
| 162 return XC_left_ptr; | 164 return XC_left_ptr; |
| 163 } | 165 } |
| 164 | 166 |
| 165 // Coalesce all pending motion events that are at the top of the queue, and | 167 // Coalesce all pending motion events that are at the top of the queue, and |
| 166 // return the number eliminated, storing the last one in |last_event|. | 168 // return the number eliminated, storing the last one in |last_event|. |
| 167 int CoalescePendingXIMotionEvents(const XEvent* xev, XEvent* last_event) { | 169 int CoalescePendingXIMotionEvents(const XEvent* xev, XEvent* last_event) { |
| 168 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); | 170 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 542 } |
| 541 | 543 |
| 542 void RootWindowHostLinux::ReleaseCapture() { | 544 void RootWindowHostLinux::ReleaseCapture() { |
| 543 } | 545 } |
| 544 | 546 |
| 545 void RootWindowHostLinux::SetCursor(gfx::NativeCursor cursor) { | 547 void RootWindowHostLinux::SetCursor(gfx::NativeCursor cursor) { |
| 546 if (cursor == current_cursor_) | 548 if (cursor == current_cursor_) |
| 547 return; | 549 return; |
| 548 current_cursor_ = cursor; | 550 current_cursor_ = cursor; |
| 549 | 551 |
| 550 // Custom web cursors are handled directly. | |
| 551 if (cursor == kCursorCustom) | |
| 552 return; | |
| 553 | |
| 554 if (cursor_shown_) | 552 if (cursor_shown_) |
| 555 SetCursorInternal(cursor); | 553 SetCursorInternal(cursor); |
| 556 } | 554 } |
| 557 | 555 |
| 558 void RootWindowHostLinux::ShowCursor(bool show) { | 556 void RootWindowHostLinux::ShowCursor(bool show) { |
| 559 if (show == cursor_shown_) | 557 if (show == cursor_shown_) |
| 560 return; | 558 return; |
| 561 cursor_shown_ = show; | 559 cursor_shown_ = show; |
| 562 SetCursorInternal(show ? current_cursor_ : kCursorNone); | 560 SetCursorInternal(show ? current_cursor_ : kCursorNone); |
| 563 } | 561 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership | 637 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership |
| 640 // of WM_Sn selections (where n is a screen number). | 638 // of WM_Sn selections (where n is a screen number). |
| 641 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); | 639 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); |
| 642 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; | 640 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; |
| 643 } | 641 } |
| 644 | 642 |
| 645 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { | 643 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { |
| 646 ::Cursor xcursor = | 644 ::Cursor xcursor = |
| 647 cursor == kCursorNone ? | 645 cursor == kCursorNone ? |
| 648 invisible_cursor_ : | 646 invisible_cursor_ : |
| 647 cursor == kCursorCustom ? |
| 648 cursor.platform() : |
| 649 ui::GetXCursor(CursorShapeFromNative(cursor)); | 649 ui::GetXCursor(CursorShapeFromNative(cursor)); |
| 650 XDefineCursor(xdisplay_, xwindow_, xcursor); | 650 XDefineCursor(xdisplay_, xwindow_, xcursor); |
| 651 } | 651 } |
| 652 | 652 |
| 653 // static | 653 // static |
| 654 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { | 654 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { |
| 655 return new RootWindowHostLinux(bounds); | 655 return new RootWindowHostLinux(bounds); |
| 656 } | 656 } |
| 657 | 657 |
| 658 // static | 658 // static |
| 659 gfx::Size RootWindowHost::GetNativeScreenSize() { | 659 gfx::Size RootWindowHost::GetNativeScreenSize() { |
| 660 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); | 660 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); |
| 661 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 661 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
| 662 } | 662 } |
| 663 | 663 |
| 664 } // namespace aura | 664 } // namespace aura |
| OLD | NEW |