| 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/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
| 6 | 6 |
| 7 #include <X11/extensions/shape.h> | 7 #include <X11/extensions/shape.h> |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
| 10 #include <X11/Xregion.h> | 10 #include <X11/Xregion.h> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "ui/views/ime/input_method.h" | 42 #include "ui/views/ime/input_method.h" |
| 43 #include "ui/views/linux_ui/linux_ui.h" | 43 #include "ui/views/linux_ui/linux_ui.h" |
| 44 #include "ui/views/views_delegate.h" | 44 #include "ui/views/views_delegate.h" |
| 45 #include "ui/views/views_switches.h" | 45 #include "ui/views/views_switches.h" |
| 46 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" | 46 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" |
| 47 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" | 47 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" |
| 48 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 48 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 49 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_observer_x11.h" | 49 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_observer_x11.h" |
| 50 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | 50 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
| 51 #include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h" | 51 #include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h" |
| 52 #include "ui/views/widget/desktop_aura/x11_pointer_grab.h" |
| 52 #include "ui/views/widget/desktop_aura/x11_window_event_filter.h" | 53 #include "ui/views/widget/desktop_aura/x11_window_event_filter.h" |
| 53 #include "ui/wm/core/compound_event_filter.h" | 54 #include "ui/wm/core/compound_event_filter.h" |
| 54 #include "ui/wm/core/window_util.h" | 55 #include "ui/wm/core/window_util.h" |
| 55 | 56 |
| 56 DECLARE_WINDOW_PROPERTY_TYPE(views::DesktopWindowTreeHostX11*); | 57 DECLARE_WINDOW_PROPERTY_TYPE(views::DesktopWindowTreeHostX11*); |
| 57 | 58 |
| 58 namespace views { | 59 namespace views { |
| 59 | 60 |
| 60 DesktopWindowTreeHostX11* DesktopWindowTreeHostX11::g_current_capture = | 61 DesktopWindowTreeHostX11* DesktopWindowTreeHostX11::g_current_capture = |
| 61 NULL; | 62 NULL; |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 return; | 947 return; |
| 947 | 948 |
| 948 // Grabbing the mouse is asynchronous. However, we synchronously start | 949 // Grabbing the mouse is asynchronous. However, we synchronously start |
| 949 // forwarding all mouse events received by Chrome to the | 950 // forwarding all mouse events received by Chrome to the |
| 950 // aura::WindowEventDispatcher which has capture. This makes capture | 951 // aura::WindowEventDispatcher which has capture. This makes capture |
| 951 // synchronous for all intents and purposes if either: | 952 // synchronous for all intents and purposes if either: |
| 952 // - |g_current_capture|'s X window has capture. | 953 // - |g_current_capture|'s X window has capture. |
| 953 // OR | 954 // OR |
| 954 // - The topmost window underneath the mouse is managed by Chrome. | 955 // - The topmost window underneath the mouse is managed by Chrome. |
| 955 DesktopWindowTreeHostX11* old_capturer = g_current_capture; | 956 DesktopWindowTreeHostX11* old_capturer = g_current_capture; |
| 957 |
| 958 // Update |g_current_capture| prior to calling OnHostLostWindowCapture() to |
| 959 // avoid releasing pointer grab. |
| 956 g_current_capture = this; | 960 g_current_capture = this; |
| 957 if (old_capturer) | 961 if (old_capturer) |
| 958 old_capturer->OnHostLostWindowCapture(); | 962 old_capturer->OnHostLostWindowCapture(); |
| 959 | 963 |
| 960 unsigned int event_mask = PointerMotionMask | ButtonReleaseMask | | 964 GrabPointer(xwindow_, true, None); |
| 961 ButtonPressMask; | |
| 962 XGrabPointer(xdisplay_, xwindow_, True, event_mask, GrabModeAsync, | |
| 963 GrabModeAsync, None, None, CurrentTime); | |
| 964 } | 965 } |
| 965 | 966 |
| 966 void DesktopWindowTreeHostX11::ReleaseCapture() { | 967 void DesktopWindowTreeHostX11::ReleaseCapture() { |
| 967 if (g_current_capture == this) { | 968 if (g_current_capture == this) { |
| 968 // Release mouse grab asynchronously. A window managed by Chrome is likely | 969 // Release mouse grab asynchronously. A window managed by Chrome is likely |
| 969 // the topmost window underneath the mouse so the capture release being | 970 // the topmost window underneath the mouse so the capture release being |
| 970 // asynchronous is likely inconsequential. | 971 // asynchronous is likely inconsequential. |
| 971 g_current_capture = NULL; | 972 g_current_capture = NULL; |
| 972 XUngrabPointer(xdisplay_, CurrentTime); | 973 UngrabPointer(); |
| 973 | 974 |
| 974 OnHostLostWindowCapture(); | 975 OnHostLostWindowCapture(); |
| 975 } | 976 } |
| 976 } | 977 } |
| 977 | 978 |
| 978 void DesktopWindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { | 979 void DesktopWindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { |
| 979 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); | 980 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); |
| 980 } | 981 } |
| 981 | 982 |
| 982 void DesktopWindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) { | 983 void DesktopWindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) { |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 if (linux_ui) { | 1931 if (linux_ui) { |
| 1931 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1932 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
| 1932 if (native_theme) | 1933 if (native_theme) |
| 1933 return native_theme; | 1934 return native_theme; |
| 1934 } | 1935 } |
| 1935 | 1936 |
| 1936 return ui::NativeTheme::instance(); | 1937 return ui::NativeTheme::instance(); |
| 1937 } | 1938 } |
| 1938 | 1939 |
| 1939 } // namespace views | 1940 } // namespace views |
| OLD | NEW |