| 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/aura/root_window_host_linux.h" | 5 #include "ui/aura/root_window_host_linux.h" |
| 6 | 6 |
| 7 #include <X11/cursorfont.h> | 7 #include <X11/cursorfont.h> |
| 8 #include <X11/extensions/Xfixes.h> | 8 #include <X11/extensions/Xfixes.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 #include <X11/extensions/Xrandr.h> | 10 #include <X11/extensions/Xrandr.h> |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 bool origin_changed = bounds_.origin() != bounds.origin(); | 480 bool origin_changed = bounds_.origin() != bounds.origin(); |
| 481 bounds_ = bounds; | 481 bounds_ = bounds; |
| 482 // Always update barrier and mouse location because |bounds_| might | 482 // Always update barrier and mouse location because |bounds_| might |
| 483 // have already been updated in |SetBounds|. | 483 // have already been updated in |SetBounds|. |
| 484 if (pointer_barriers_.get()) { | 484 if (pointer_barriers_.get()) { |
| 485 UnConfineCursor(); | 485 UnConfineCursor(); |
| 486 RootWindow* root = delegate_->AsRootWindow(); | 486 RootWindow* root = delegate_->AsRootWindow(); |
| 487 client::ScreenPositionClient* client = | 487 client::ScreenPositionClient* client = |
| 488 client::GetScreenPositionClient(root); | 488 client::GetScreenPositionClient(root); |
| 489 if (client) { | 489 if (client) { |
| 490 gfx::Point p = gfx::Screen::GetCursorScreenPoint(); | 490 gfx::Point p = gfx::Screen::GetScreenFor(root)-> |
| 491 GetCursorScreenPoint(); |
| 491 client->ConvertPointFromScreen(root, &p); | 492 client->ConvertPointFromScreen(root, &p); |
| 492 if (root->ContainsPoint(p)) { | 493 if (root->ContainsPoint(p)) { |
| 493 root->ConvertPointToNativeScreen(&p); | 494 root->ConvertPointToNativeScreen(&p); |
| 494 XWarpPointer( | 495 XWarpPointer( |
| 495 xdisplay_, None, x_root_window_, 0, 0, 0, 0, p.x(), p.y()); | 496 xdisplay_, None, x_root_window_, 0, 0, 0, 0, p.x(), p.y()); |
| 496 } | 497 } |
| 497 } | 498 } |
| 498 ConfineCursorToRootWindow(); | 499 ConfineCursorToRootWindow(); |
| 499 } | 500 } |
| 500 if (size_changed) | 501 if (size_changed) |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 } | 737 } |
| 737 | 738 |
| 738 gfx::Rect RootWindowHostLinux::GetBounds() const { | 739 gfx::Rect RootWindowHostLinux::GetBounds() const { |
| 739 return bounds_; | 740 return bounds_; |
| 740 } | 741 } |
| 741 | 742 |
| 742 void RootWindowHostLinux::SetBounds(const gfx::Rect& bounds) { | 743 void RootWindowHostLinux::SetBounds(const gfx::Rect& bounds) { |
| 743 // Even if the host window's size doesn't change, aura's root window | 744 // Even if the host window's size doesn't change, aura's root window |
| 744 // size, which is in DIP, changes when the scale changes. | 745 // size, which is in DIP, changes when the scale changes. |
| 745 float current_scale = delegate_->GetDeviceScaleFactor(); | 746 float current_scale = delegate_->GetDeviceScaleFactor(); |
| 746 float new_scale = gfx::Screen::GetDisplayNearestWindow( | 747 float new_scale = gfx::Screen::GetScreenFor(delegate_->AsRootWindow())-> |
| 747 delegate_->AsRootWindow()).device_scale_factor(); | 748 GetDisplayNearestWindow(delegate_->AsRootWindow()).device_scale_factor(); |
| 748 bool origin_changed = bounds_.origin() != bounds.origin(); | 749 bool origin_changed = bounds_.origin() != bounds.origin(); |
| 749 bool size_changed = bounds_.size() != bounds.size(); | 750 bool size_changed = bounds_.size() != bounds.size(); |
| 750 XWindowChanges changes = {0}; | 751 XWindowChanges changes = {0}; |
| 751 unsigned value_mask = 0; | 752 unsigned value_mask = 0; |
| 752 | 753 |
| 753 if (size_changed) { | 754 if (size_changed) { |
| 754 changes.width = bounds.width(); | 755 changes.width = bounds.width(); |
| 755 changes.height = bounds.height(); | 756 changes.height = bounds.height(); |
| 756 value_mask = CWHeight | CWWidth; | 757 value_mask = CWHeight | CWWidth; |
| 757 } | 758 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 return new RootWindowHostLinux(bounds); | 1011 return new RootWindowHostLinux(bounds); |
| 1011 } | 1012 } |
| 1012 | 1013 |
| 1013 // static | 1014 // static |
| 1014 gfx::Size RootWindowHost::GetNativeScreenSize() { | 1015 gfx::Size RootWindowHost::GetNativeScreenSize() { |
| 1015 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 1016 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
| 1016 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 1017 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
| 1017 } | 1018 } |
| 1018 | 1019 |
| 1019 } // namespace aura | 1020 } // namespace aura |
| OLD | NEW |