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 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 return; | 945 return; |
946 | 946 |
947 // Grabbing the mouse is asynchronous. However, we synchronously start | 947 // Grabbing the mouse is asynchronous. However, we synchronously start |
948 // forwarding all mouse events received by Chrome to the | 948 // forwarding all mouse events received by Chrome to the |
949 // aura::WindowEventDispatcher which has capture. This makes capture | 949 // aura::WindowEventDispatcher which has capture. This makes capture |
950 // synchronous for all intents and purposes if either: | 950 // synchronous for all intents and purposes if either: |
951 // - |g_current_capture|'s X window has capture. | 951 // - |g_current_capture|'s X window has capture. |
952 // OR | 952 // OR |
953 // - The topmost window underneath the mouse is managed by Chrome. | 953 // - The topmost window underneath the mouse is managed by Chrome. |
954 DesktopWindowTreeHostX11* old_capturer = g_current_capture; | 954 DesktopWindowTreeHostX11* old_capturer = g_current_capture; |
| 955 |
| 956 // Update |g_current_capture| prior to calling OnHostLostWindowCapture() to |
| 957 // avoid releasing pointer grab. |
955 g_current_capture = this; | 958 g_current_capture = this; |
956 if (old_capturer) | 959 if (old_capturer) |
957 old_capturer->OnHostLostWindowCapture(); | 960 old_capturer->OnHostLostWindowCapture(); |
958 | 961 |
959 unsigned int event_mask = PointerMotionMask | ButtonReleaseMask | | 962 ui::GrabPointer(xwindow_, true, None); |
960 ButtonPressMask; | |
961 XGrabPointer(xdisplay_, xwindow_, True, event_mask, GrabModeAsync, | |
962 GrabModeAsync, None, None, CurrentTime); | |
963 } | 963 } |
964 | 964 |
965 void DesktopWindowTreeHostX11::ReleaseCapture() { | 965 void DesktopWindowTreeHostX11::ReleaseCapture() { |
966 if (g_current_capture == this) { | 966 if (g_current_capture == this) { |
967 // Release mouse grab asynchronously. A window managed by Chrome is likely | 967 // Release mouse grab asynchronously. A window managed by Chrome is likely |
968 // the topmost window underneath the mouse so the capture release being | 968 // the topmost window underneath the mouse so the capture release being |
969 // asynchronous is likely inconsequential. | 969 // asynchronous is likely inconsequential. |
970 g_current_capture = NULL; | 970 g_current_capture = NULL; |
971 XUngrabPointer(xdisplay_, CurrentTime); | 971 ui::UngrabPointer(); |
972 | 972 |
973 OnHostLostWindowCapture(); | 973 OnHostLostWindowCapture(); |
974 } | 974 } |
975 } | 975 } |
976 | 976 |
977 void DesktopWindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { | 977 void DesktopWindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { |
978 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); | 978 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); |
979 } | 979 } |
980 | 980 |
981 void DesktopWindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) { | 981 void DesktopWindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) { |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1928 if (linux_ui) { | 1928 if (linux_ui) { |
1929 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1929 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
1930 if (native_theme) | 1930 if (native_theme) |
1931 return native_theme; | 1931 return native_theme; |
1932 } | 1932 } |
1933 | 1933 |
1934 return ui::NativeTheme::instance(); | 1934 return ui::NativeTheme::instance(); |
1935 } | 1935 } |
1936 | 1936 |
1937 } // namespace views | 1937 } // namespace views |
OLD | NEW |