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