Chromium Code Reviews| 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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 g_current_capture = this; | 955 g_current_capture = this; |
| 956 if (old_capturer) | 956 if (old_capturer) |
| 957 old_capturer->OnHostLostWindowCapture(); | 957 old_capturer->OnHostLostWindowCapture(); |
| 958 | 958 |
| 959 unsigned int event_mask = PointerMotionMask | ButtonReleaseMask | | 959 unsigned int event_mask = PointerMotionMask | ButtonReleaseMask | |
| 960 ButtonPressMask; | 960 ButtonPressMask; |
| 961 XGrabPointer(xdisplay_, xwindow_, True, event_mask, GrabModeAsync, | 961 int success = |
| 962 GrabModeAsync, None, None, CurrentTime); | 962 XGrabPointer(xdisplay_, xwindow_, True, event_mask, GrabModeAsync, |
| 963 GrabModeAsync, None, None, CurrentTime); | |
| 964 if (success == AlreadyGrabbed) { | |
|
sadrul
2014/11/24 15:46:01
Can you link to some doc here? man XGrabPointer cl
pkotwicz
2014/11/24 16:07:41
The docs are not great. However man XUngrabPointer
sadrul
2014/11/27 17:48:18
Do we have example of any other clients doing simi
| |
| 965 // Try ungrabbing the pointer and regrabbing it. If the OS grabbed capture | |
| 966 // as a result of a mouse button being pressed, ungrabbing and regrabbing | |
| 967 // the pointer will succeed. | |
| 968 XUngrabPointer(xdisplay_, CurrentTime); | |
| 969 XGrabPointer(xdisplay_, xwindow_, True, event_mask, GrabModeAsync, | |
| 970 GrabModeAsync, None, None, CurrentTime); | |
| 971 } | |
| 963 } | 972 } |
| 964 | 973 |
| 965 void DesktopWindowTreeHostX11::ReleaseCapture() { | 974 void DesktopWindowTreeHostX11::ReleaseCapture() { |
| 966 if (g_current_capture == this) { | 975 if (g_current_capture == this) { |
| 967 // Release mouse grab asynchronously. A window managed by Chrome is likely | 976 // Release mouse grab asynchronously. A window managed by Chrome is likely |
| 968 // the topmost window underneath the mouse so the capture release being | 977 // the topmost window underneath the mouse so the capture release being |
| 969 // asynchronous is likely inconsequential. | 978 // asynchronous is likely inconsequential. |
| 970 g_current_capture = NULL; | 979 g_current_capture = NULL; |
| 971 XUngrabPointer(xdisplay_, CurrentTime); | 980 XUngrabPointer(xdisplay_, CurrentTime); |
| 972 | 981 |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1927 if (linux_ui) { | 1936 if (linux_ui) { |
| 1928 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1937 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
| 1929 if (native_theme) | 1938 if (native_theme) |
| 1930 return native_theme; | 1939 return native_theme; |
| 1931 } | 1940 } |
| 1932 | 1941 |
| 1933 return ui::NativeTheme::instance(); | 1942 return ui::NativeTheme::instance(); |
| 1934 } | 1943 } |
| 1935 | 1944 |
| 1936 } // namespace views | 1945 } // namespace views |
| OLD | NEW |