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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 Maximize(); | 813 Maximize(); |
814 | 814 |
815 // Try to guess the size we will have after the switch to/from fullscreen: | 815 // Try to guess the size we will have after the switch to/from fullscreen: |
816 // - (may) avoid transient states | 816 // - (may) avoid transient states |
817 // - works around Flash content which expects to have the size updated | 817 // - works around Flash content which expects to have the size updated |
818 // synchronously. | 818 // synchronously. |
819 // See https://crbug.com/361408 | 819 // See https://crbug.com/361408 |
820 if (fullscreen) { | 820 if (fullscreen) { |
821 restored_bounds_in_pixels_ = bounds_in_pixels_; | 821 restored_bounds_in_pixels_ = bounds_in_pixels_; |
822 const gfx::Display display = | 822 const gfx::Display display = |
823 gfx::Screen::GetScreenFor(NULL)->GetDisplayNearestWindow(window()); | 823 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); |
824 bounds_in_pixels_ = ToPixelRect(display.bounds()); | 824 bounds_in_pixels_ = ToPixelRect(display.bounds()); |
825 } else { | 825 } else { |
826 bounds_in_pixels_ = restored_bounds_in_pixels_; | 826 bounds_in_pixels_ = restored_bounds_in_pixels_; |
827 } | 827 } |
828 OnHostMoved(bounds_in_pixels_.origin()); | 828 OnHostMoved(bounds_in_pixels_.origin()); |
829 OnHostResized(bounds_in_pixels_.size()); | 829 OnHostResized(bounds_in_pixels_.size()); |
830 | 830 |
831 if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN") == fullscreen) { | 831 if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN") == fullscreen) { |
832 Relayout(); | 832 Relayout(); |
833 ResetWindowRegion(); | 833 ResetWindowRegion(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 } | 931 } |
932 | 932 |
933 void DesktopWindowTreeHostX11::SizeConstraintsChanged() { | 933 void DesktopWindowTreeHostX11::SizeConstraintsChanged() { |
934 UpdateMinAndMaxSize(); | 934 UpdateMinAndMaxSize(); |
935 } | 935 } |
936 | 936 |
937 //////////////////////////////////////////////////////////////////////////////// | 937 //////////////////////////////////////////////////////////////////////////////// |
938 // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation: | 938 // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation: |
939 | 939 |
940 gfx::Transform DesktopWindowTreeHostX11::GetRootTransform() const { | 940 gfx::Transform DesktopWindowTreeHostX11::GetRootTransform() const { |
941 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 941 gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
942 if (window_mapped_) { | 942 if (window_mapped_) { |
943 aura::Window* win = const_cast<aura::Window*>(window()); | 943 aura::Window* win = const_cast<aura::Window*>(window()); |
944 display = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(win); | 944 display = gfx::Screen::GetScreen()->GetDisplayNearestWindow(win); |
945 } | 945 } |
946 | 946 |
947 float scale = display.device_scale_factor(); | 947 float scale = display.device_scale_factor(); |
948 gfx::Transform transform; | 948 gfx::Transform transform; |
949 transform.Scale(scale, scale); | 949 transform.Scale(scale, scale); |
950 return transform; | 950 return transform; |
951 } | 951 } |
952 | 952 |
953 ui::EventSource* DesktopWindowTreeHostX11::GetEventSource() { | 953 ui::EventSource* DesktopWindowTreeHostX11::GetEventSource() { |
954 return this; | 954 return this; |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 if (window_icon) { | 1280 if (window_icon) { |
1281 SetWindowIcons(gfx::ImageSkia(), *window_icon); | 1281 SetWindowIcons(gfx::ImageSkia(), *window_icon); |
1282 } | 1282 } |
1283 CreateCompositor(); | 1283 CreateCompositor(); |
1284 OnAcceleratedWidgetAvailable(); | 1284 OnAcceleratedWidgetAvailable(); |
1285 } | 1285 } |
1286 | 1286 |
1287 gfx::Size DesktopWindowTreeHostX11::AdjustSize( | 1287 gfx::Size DesktopWindowTreeHostX11::AdjustSize( |
1288 const gfx::Size& requested_size_in_pixels) { | 1288 const gfx::Size& requested_size_in_pixels) { |
1289 std::vector<gfx::Display> displays = | 1289 std::vector<gfx::Display> displays = |
1290 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)->GetAllDisplays(); | 1290 gfx::Screen::GetScreen()->GetAllDisplays(); |
1291 // Compare against all monitor sizes. The window manager can move the window | 1291 // Compare against all monitor sizes. The window manager can move the window |
1292 // to whichever monitor it wants. | 1292 // to whichever monitor it wants. |
1293 for (size_t i = 0; i < displays.size(); ++i) { | 1293 for (size_t i = 0; i < displays.size(); ++i) { |
1294 if (requested_size_in_pixels == displays[i].GetSizeInPixel()) { | 1294 if (requested_size_in_pixels == displays[i].GetSizeInPixel()) { |
1295 return gfx::Size(requested_size_in_pixels.width() - 1, | 1295 return gfx::Size(requested_size_in_pixels.width() - 1, |
1296 requested_size_in_pixels.height() - 1); | 1296 requested_size_in_pixels.height() - 1); |
1297 } | 1297 } |
1298 } | 1298 } |
1299 | 1299 |
1300 // Do not request a 0x0 window size. It causes an XError. | 1300 // Do not request a 0x0 window size. It causes an XError. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 | 1526 |
1527 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { | 1527 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { |
1528 GetInputMethod()->DispatchKeyEvent(event); | 1528 GetInputMethod()->DispatchKeyEvent(event); |
1529 } | 1529 } |
1530 | 1530 |
1531 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( | 1531 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( |
1532 ui::LocatedEvent* located_event, | 1532 ui::LocatedEvent* located_event, |
1533 DesktopWindowTreeHostX11* host) { | 1533 DesktopWindowTreeHostX11* host) { |
1534 DCHECK_NE(this, host); | 1534 DCHECK_NE(this, host); |
1535 const gfx::Display display_src = | 1535 const gfx::Display display_src = |
1536 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); | 1536 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); |
1537 const gfx::Display display_dest = | 1537 const gfx::Display display_dest = |
1538 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); | 1538 gfx::Screen::GetScreen()->GetDisplayNearestWindow(host->window()); |
1539 DCHECK_EQ(display_src.device_scale_factor(), | 1539 DCHECK_EQ(display_src.device_scale_factor(), |
1540 display_dest.device_scale_factor()); | 1540 display_dest.device_scale_factor()); |
1541 gfx::Vector2d offset = GetLocationOnNativeScreen() - | 1541 gfx::Vector2d offset = GetLocationOnNativeScreen() - |
1542 host->GetLocationOnNativeScreen(); | 1542 host->GetLocationOnNativeScreen(); |
1543 gfx::PointF location_in_pixel_in_host = | 1543 gfx::PointF location_in_pixel_in_host = |
1544 located_event->location_f() + gfx::Vector2dF(offset); | 1544 located_event->location_f() + gfx::Vector2dF(offset); |
1545 located_event->set_location_f(location_in_pixel_in_host); | 1545 located_event->set_location_f(location_in_pixel_in_host); |
1546 } | 1546 } |
1547 | 1547 |
1548 void DesktopWindowTreeHostX11::ResetWindowRegion() { | 1548 void DesktopWindowTreeHostX11::ResetWindowRegion() { |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 if (linux_ui) { | 2035 if (linux_ui) { |
2036 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2036 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2037 if (native_theme) | 2037 if (native_theme) |
2038 return native_theme; | 2038 return native_theme; |
2039 } | 2039 } |
2040 | 2040 |
2041 return ui::NativeThemeAura::instance(); | 2041 return ui::NativeThemeAura::instance(); |
2042 } | 2042 } |
2043 | 2043 |
2044 } // namespace views | 2044 } // namespace views |
OLD | NEW |