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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 OnHostResized(bounds.size()); | 914 OnHostResized(bounds.size()); |
915 ResetWindowRegion(); | 915 ResetWindowRegion(); |
916 } | 916 } |
917 } | 917 } |
918 | 918 |
919 gfx::Point DesktopWindowTreeHostX11::GetLocationOnNativeScreen() const { | 919 gfx::Point DesktopWindowTreeHostX11::GetLocationOnNativeScreen() const { |
920 return bounds_.origin(); | 920 return bounds_.origin(); |
921 } | 921 } |
922 | 922 |
923 void DesktopWindowTreeHostX11::SetCapture() { | 923 void DesktopWindowTreeHostX11::SetCapture() { |
| 924 if (HasCapture()) |
| 925 return; |
| 926 |
924 // Grabbing the mouse is asynchronous. However, we synchronously start | 927 // Grabbing the mouse is asynchronous. However, we synchronously start |
925 // forwarding all mouse events received by Chrome to the | 928 // forwarding all mouse events received by Chrome to the |
926 // aura::WindowEventDispatcher which has capture. This makes capture | 929 // aura::WindowEventDispatcher which has capture. This makes capture |
927 // synchronous for all intents and purposes if either: | 930 // synchronous for all intents and purposes if either: |
928 // - |g_current_capture|'s X window has capture. | 931 // - |g_current_capture|'s X window has capture. |
929 // OR | 932 // OR |
930 // - The topmost window underneath the mouse is managed by Chrome. | 933 // - The topmost window underneath the mouse is managed by Chrome. |
931 if (g_current_capture) | 934 DesktopWindowTreeHostX11* old_capturer = g_current_capture; |
932 g_current_capture->OnHostLostWindowCapture(); | |
933 g_current_capture = this; | 935 g_current_capture = this; |
| 936 if (old_capturer) |
| 937 old_capturer->OnHostLostWindowCapture(); |
934 | 938 |
935 unsigned int event_mask = PointerMotionMask | ButtonReleaseMask | | 939 unsigned int event_mask = PointerMotionMask | ButtonReleaseMask | |
936 ButtonPressMask; | 940 ButtonPressMask; |
937 XGrabPointer(xdisplay_, xwindow_, True, event_mask, GrabModeAsync, | 941 XGrabPointer(xdisplay_, xwindow_, True, event_mask, GrabModeAsync, |
938 GrabModeAsync, None, None, CurrentTime); | 942 GrabModeAsync, None, None, CurrentTime); |
939 } | 943 } |
940 | 944 |
941 void DesktopWindowTreeHostX11::ReleaseCapture() { | 945 void DesktopWindowTreeHostX11::ReleaseCapture() { |
942 if (g_current_capture == this) { | 946 if (g_current_capture == this) { |
943 // Release mouse grab asynchronously. A window managed by Chrome is likely | 947 // Release mouse grab asynchronously. A window managed by Chrome is likely |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 if (linux_ui) { | 1907 if (linux_ui) { |
1904 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1908 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
1905 if (native_theme) | 1909 if (native_theme) |
1906 return native_theme; | 1910 return native_theme; |
1907 } | 1911 } |
1908 | 1912 |
1909 return ui::NativeTheme::instance(); | 1913 return ui::NativeTheme::instance(); |
1910 } | 1914 } |
1911 | 1915 |
1912 } // namespace views | 1916 } // namespace views |
OLD | NEW |