| 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/Xatom.h> | 7 #include <X11/Xatom.h> |
| 8 #include <X11/Xregion.h> | 8 #include <X11/Xregion.h> |
| 9 #include <X11/Xutil.h> | 9 #include <X11/Xutil.h> |
| 10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ui/aura/client/cursor_client.h" | 21 #include "ui/aura/client/cursor_client.h" |
| 22 #include "ui/aura/client/focus_client.h" | 22 #include "ui/aura/client/focus_client.h" |
| 23 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 24 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
| 25 #include "ui/aura/window_property.h" | 25 #include "ui/aura/window_property.h" |
| 26 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" | 26 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" |
| 27 #include "ui/base/hit_test.h" | 27 #include "ui/base/hit_test.h" |
| 28 #include "ui/base/ime/input_method.h" | 28 #include "ui/base/ime/input_method.h" |
| 29 #include "ui/base/x/x11_util.h" | 29 #include "ui/base/x/x11_util.h" |
| 30 #include "ui/base/x/x11_util_internal.h" | 30 #include "ui/base/x/x11_util_internal.h" |
| 31 #include "ui/display/display.h" |
| 32 #include "ui/display/screen.h" |
| 31 #include "ui/events/devices/x11/device_data_manager_x11.h" | 33 #include "ui/events/devices/x11/device_data_manager_x11.h" |
| 32 #include "ui/events/devices/x11/device_list_cache_x11.h" | 34 #include "ui/events/devices/x11/device_list_cache_x11.h" |
| 33 #include "ui/events/devices/x11/touch_factory_x11.h" | 35 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 34 #include "ui/events/event_utils.h" | 36 #include "ui/events/event_utils.h" |
| 35 #include "ui/events/platform/platform_event_source.h" | 37 #include "ui/events/platform/platform_event_source.h" |
| 36 #include "ui/events/platform/x11/x11_event_source.h" | 38 #include "ui/events/platform/x11/x11_event_source.h" |
| 37 #include "ui/gfx/display.h" | |
| 38 #include "ui/gfx/geometry/insets.h" | 39 #include "ui/gfx/geometry/insets.h" |
| 39 #include "ui/gfx/geometry/size_conversions.h" | 40 #include "ui/gfx/geometry/size_conversions.h" |
| 40 #include "ui/gfx/image/image_skia.h" | 41 #include "ui/gfx/image/image_skia.h" |
| 41 #include "ui/gfx/image/image_skia_rep.h" | 42 #include "ui/gfx/image/image_skia_rep.h" |
| 42 #include "ui/gfx/path.h" | 43 #include "ui/gfx/path.h" |
| 43 #include "ui/gfx/path_x11.h" | 44 #include "ui/gfx/path_x11.h" |
| 44 #include "ui/gfx/screen.h" | |
| 45 #include "ui/native_theme/native_theme.h" | 45 #include "ui/native_theme/native_theme.h" |
| 46 #include "ui/native_theme/native_theme_aura.h" | 46 #include "ui/native_theme/native_theme_aura.h" |
| 47 #include "ui/views/corewm/tooltip_aura.h" | 47 #include "ui/views/corewm/tooltip_aura.h" |
| 48 #include "ui/views/linux_ui/linux_ui.h" | 48 #include "ui/views/linux_ui/linux_ui.h" |
| 49 #include "ui/views/views_delegate.h" | 49 #include "ui/views/views_delegate.h" |
| 50 #include "ui/views/views_switches.h" | 50 #include "ui/views/views_switches.h" |
| 51 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" | 51 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" |
| 52 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" | 52 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" |
| 53 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 53 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 54 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_observer_x11.h" | 54 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_observer_x11.h" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 if (unmaximize_and_remaximize) | 815 if (unmaximize_and_remaximize) |
| 816 Maximize(); | 816 Maximize(); |
| 817 | 817 |
| 818 // Try to guess the size we will have after the switch to/from fullscreen: | 818 // Try to guess the size we will have after the switch to/from fullscreen: |
| 819 // - (may) avoid transient states | 819 // - (may) avoid transient states |
| 820 // - works around Flash content which expects to have the size updated | 820 // - works around Flash content which expects to have the size updated |
| 821 // synchronously. | 821 // synchronously. |
| 822 // See https://crbug.com/361408 | 822 // See https://crbug.com/361408 |
| 823 if (fullscreen) { | 823 if (fullscreen) { |
| 824 restored_bounds_in_pixels_ = bounds_in_pixels_; | 824 restored_bounds_in_pixels_ = bounds_in_pixels_; |
| 825 const gfx::Display display = | 825 const display::Display display = |
| 826 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); | 826 display::Screen::GetScreen()->GetDisplayNearestWindow(window()); |
| 827 bounds_in_pixels_ = ToPixelRect(display.bounds()); | 827 bounds_in_pixels_ = ToPixelRect(display.bounds()); |
| 828 } else { | 828 } else { |
| 829 bounds_in_pixels_ = restored_bounds_in_pixels_; | 829 bounds_in_pixels_ = restored_bounds_in_pixels_; |
| 830 } | 830 } |
| 831 OnHostMoved(bounds_in_pixels_.origin()); | 831 OnHostMoved(bounds_in_pixels_.origin()); |
| 832 OnHostResized(bounds_in_pixels_.size()); | 832 OnHostResized(bounds_in_pixels_.size()); |
| 833 | 833 |
| 834 if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN") == fullscreen) { | 834 if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN") == fullscreen) { |
| 835 Relayout(); | 835 Relayout(); |
| 836 ResetWindowRegion(); | 836 ResetWindowRegion(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 } | 934 } |
| 935 | 935 |
| 936 void DesktopWindowTreeHostX11::SizeConstraintsChanged() { | 936 void DesktopWindowTreeHostX11::SizeConstraintsChanged() { |
| 937 UpdateMinAndMaxSize(); | 937 UpdateMinAndMaxSize(); |
| 938 } | 938 } |
| 939 | 939 |
| 940 //////////////////////////////////////////////////////////////////////////////// | 940 //////////////////////////////////////////////////////////////////////////////// |
| 941 // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation: | 941 // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation: |
| 942 | 942 |
| 943 gfx::Transform DesktopWindowTreeHostX11::GetRootTransform() const { | 943 gfx::Transform DesktopWindowTreeHostX11::GetRootTransform() const { |
| 944 gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); | 944 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 945 if (window_mapped_) { | 945 if (window_mapped_) { |
| 946 aura::Window* win = const_cast<aura::Window*>(window()); | 946 aura::Window* win = const_cast<aura::Window*>(window()); |
| 947 display = gfx::Screen::GetScreen()->GetDisplayNearestWindow(win); | 947 display = display::Screen::GetScreen()->GetDisplayNearestWindow(win); |
| 948 } | 948 } |
| 949 | 949 |
| 950 float scale = display.device_scale_factor(); | 950 float scale = display.device_scale_factor(); |
| 951 gfx::Transform transform; | 951 gfx::Transform transform; |
| 952 transform.Scale(scale, scale); | 952 transform.Scale(scale, scale); |
| 953 return transform; | 953 return transform; |
| 954 } | 954 } |
| 955 | 955 |
| 956 ui::EventSource* DesktopWindowTreeHostX11::GetEventSource() { | 956 ui::EventSource* DesktopWindowTreeHostX11::GetEventSource() { |
| 957 return this; | 957 return this; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 : NULL; | 1289 : NULL; |
| 1290 if (window_icon) { | 1290 if (window_icon) { |
| 1291 SetWindowIcons(gfx::ImageSkia(), *window_icon); | 1291 SetWindowIcons(gfx::ImageSkia(), *window_icon); |
| 1292 } | 1292 } |
| 1293 CreateCompositor(); | 1293 CreateCompositor(); |
| 1294 OnAcceleratedWidgetAvailable(); | 1294 OnAcceleratedWidgetAvailable(); |
| 1295 } | 1295 } |
| 1296 | 1296 |
| 1297 gfx::Size DesktopWindowTreeHostX11::AdjustSize( | 1297 gfx::Size DesktopWindowTreeHostX11::AdjustSize( |
| 1298 const gfx::Size& requested_size_in_pixels) { | 1298 const gfx::Size& requested_size_in_pixels) { |
| 1299 std::vector<gfx::Display> displays = | 1299 std::vector<display::Display> displays = |
| 1300 gfx::Screen::GetScreen()->GetAllDisplays(); | 1300 display::Screen::GetScreen()->GetAllDisplays(); |
| 1301 // Compare against all monitor sizes. The window manager can move the window | 1301 // Compare against all monitor sizes. The window manager can move the window |
| 1302 // to whichever monitor it wants. | 1302 // to whichever monitor it wants. |
| 1303 for (size_t i = 0; i < displays.size(); ++i) { | 1303 for (size_t i = 0; i < displays.size(); ++i) { |
| 1304 if (requested_size_in_pixels == displays[i].GetSizeInPixel()) { | 1304 if (requested_size_in_pixels == displays[i].GetSizeInPixel()) { |
| 1305 return gfx::Size(requested_size_in_pixels.width() - 1, | 1305 return gfx::Size(requested_size_in_pixels.width() - 1, |
| 1306 requested_size_in_pixels.height() - 1); | 1306 requested_size_in_pixels.height() - 1); |
| 1307 } | 1307 } |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 // Do not request a 0x0 window size. It causes an XError. | 1310 // Do not request a 0x0 window size. It causes an XError. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 } | 1561 } |
| 1562 | 1562 |
| 1563 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { | 1563 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { |
| 1564 GetInputMethod()->DispatchKeyEvent(event); | 1564 GetInputMethod()->DispatchKeyEvent(event); |
| 1565 } | 1565 } |
| 1566 | 1566 |
| 1567 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( | 1567 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( |
| 1568 ui::LocatedEvent* located_event, | 1568 ui::LocatedEvent* located_event, |
| 1569 DesktopWindowTreeHostX11* host) { | 1569 DesktopWindowTreeHostX11* host) { |
| 1570 DCHECK_NE(this, host); | 1570 DCHECK_NE(this, host); |
| 1571 const gfx::Display display_src = | 1571 const display::Display display_src = |
| 1572 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); | 1572 display::Screen::GetScreen()->GetDisplayNearestWindow(window()); |
| 1573 const gfx::Display display_dest = | 1573 const display::Display display_dest = |
| 1574 gfx::Screen::GetScreen()->GetDisplayNearestWindow(host->window()); | 1574 display::Screen::GetScreen()->GetDisplayNearestWindow(host->window()); |
| 1575 DCHECK_EQ(display_src.device_scale_factor(), | 1575 DCHECK_EQ(display_src.device_scale_factor(), |
| 1576 display_dest.device_scale_factor()); | 1576 display_dest.device_scale_factor()); |
| 1577 gfx::Vector2d offset = GetLocationOnNativeScreen() - | 1577 gfx::Vector2d offset = GetLocationOnNativeScreen() - |
| 1578 host->GetLocationOnNativeScreen(); | 1578 host->GetLocationOnNativeScreen(); |
| 1579 gfx::PointF location_in_pixel_in_host = | 1579 gfx::PointF location_in_pixel_in_host = |
| 1580 located_event->location_f() + gfx::Vector2dF(offset); | 1580 located_event->location_f() + gfx::Vector2dF(offset); |
| 1581 located_event->set_location_f(location_in_pixel_in_host); | 1581 located_event->set_location_f(location_in_pixel_in_host); |
| 1582 } | 1582 } |
| 1583 | 1583 |
| 1584 void DesktopWindowTreeHostX11::ResetWindowRegion() { | 1584 void DesktopWindowTreeHostX11::ResetWindowRegion() { |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2062 if (linux_ui) { | 2062 if (linux_ui) { |
| 2063 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2063 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
| 2064 if (native_theme) | 2064 if (native_theme) |
| 2065 return native_theme; | 2065 return native_theme; |
| 2066 } | 2066 } |
| 2067 | 2067 |
| 2068 return ui::NativeThemeAura::instance(); | 2068 return ui::NativeThemeAura::instance(); |
| 2069 } | 2069 } |
| 2070 | 2070 |
| 2071 } // namespace views | 2071 } // namespace views |
| OLD | NEW |