Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Unified Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc

Issue 659883002: Enable hidpi on Linux, refactor a bit on Windows to share Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: constants Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index a6f120943f57de515556c227b84f04f8f253b208..b3692b62e11573c3c59f9df62a65dddd5e01ff19 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -31,12 +31,16 @@
#include "ui/events/x/device_list_cache_x.h"
#include "ui/events/x/touch_factory_x11.h"
#include "ui/gfx/display.h"
+#include "ui/gfx/dpi.h"
+#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/path.h"
#include "ui/gfx/path_x11.h"
+#include "ui/gfx/point.h"
#include "ui/gfx/screen.h"
+#include "ui/gfx/size.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/corewm/tooltip_aura.h"
#include "ui/views/ime/input_method.h"
@@ -385,7 +389,7 @@ bool DesktopWindowTreeHostX11::IsVisible() const {
}
void DesktopWindowTreeHostX11::SetSize(const gfx::Size& requested_size) {
- gfx::Size size = AdjustSize(requested_size);
+ gfx::Size size = AdjustSize(gfx::DIPToScreenSize(requested_size));
bool size_changed = bounds_.size() != size;
XResizeWindow(xdisplay_, xwindow_, size.width(), size.height());
bounds_.set_size(size);
@@ -399,9 +403,11 @@ void DesktopWindowTreeHostX11::StackAtTop() {
XRaiseWindow(xdisplay_, xwindow_);
}
-void DesktopWindowTreeHostX11::CenterWindow(const gfx::Size& size) {
+void DesktopWindowTreeHostX11::CenterWindow(const gfx::Size& size_dip) {
gfx::Rect parent_bounds = GetWorkAreaBoundsInScreen();
+ gfx::Size size = gfx::DIPToScreenSize(size_dip);
+
// If |window_|'s transient parent bounds are big enough to contain |size|,
// use them instead.
if (wm::GetTransientParent(content_window_)) {
@@ -444,7 +450,7 @@ void DesktopWindowTreeHostX11::GetWindowPlacement(
}
gfx::Rect DesktopWindowTreeHostX11::GetWindowBoundsInScreen() const {
- return bounds_;
+ return gfx::ScreenToDIPRect(bounds_);
}
gfx::Rect DesktopWindowTreeHostX11::GetClientAreaBoundsInScreen() const {
@@ -456,7 +462,7 @@ gfx::Rect DesktopWindowTreeHostX11::GetClientAreaBoundsInScreen() const {
// Attempts to calculate the rect by asking the NonClientFrameView what it
// thought its GetBoundsForClientView() were broke combobox drop down
// placement.
- return bounds_;
+ return gfx::ScreenToDIPRect(bounds_);
}
gfx::Rect DesktopWindowTreeHostX11::GetRestoredBounds() const {
@@ -465,7 +471,7 @@ gfx::Rect DesktopWindowTreeHostX11::GetRestoredBounds() const {
// or restoring bounds, we can record the current bounds before we request
// maximization, and clear it when we detect a state change.
if (!restored_bounds_.IsEmpty())
- return restored_bounds_;
+ return gfx::ScreenToDIPRect(restored_bounds_);
return GetWindowBoundsInScreen();
}
@@ -488,7 +494,7 @@ gfx::Rect DesktopWindowTreeHostX11::GetWorkAreaBoundsInScreen() const {
return gfx::Rect(0, 0, 10, 10);
}
- return gfx::Rect(x, y, width, height);
+ return gfx::ScreenToDIPRect(gfx::Rect(x, y, width, height));
}
void DesktopWindowTreeHostX11::SetShape(gfx::NativeRegion native_region) {
@@ -1086,12 +1092,14 @@ void DesktopWindowTreeHostX11::InitX11Window(
}
}
- bounds_ = gfx::Rect(params.bounds.origin(),
- AdjustSize(params.bounds.size()));
+ gfx::Point origin_screen = gfx::DIPToScreenPoint(params.bounds.origin());
+ gfx::Size size_screen = gfx::DIPToScreenSize(params.bounds.size());
+ bounds_ = gfx::Rect(origin_screen,
+ AdjustSize(size_screen));
xwindow_ = XCreateWindow(
xdisplay_, x_root_window_,
- bounds_.x(), bounds_.y(),
- bounds_.width(), bounds_.height(),
+ origin_screen.x(), origin_screen.y(),
+ size_screen.width(), size_screen.height(),
0, // border width
depth,
InputOutput,
@@ -1409,6 +1417,7 @@ void DesktopWindowTreeHostX11::SetUseNativeFrame(bool use_native_frame) {
}
void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) {
+ event->set_location(gfx::ScreenToDIPPoint(event->location()));
// In Windows, the native events sent to chrome are separated into client
// and non-client versions of events, which we record on our LocatedEvent
// structures. On X11, we emulate the concept of non-client. Before we pass
@@ -1427,8 +1436,8 @@ void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) {
// WindowTreeHost that hosts ash.
if (content_window_ && content_window_->delegate()) {
int flags = event->flags();
- int hit_test_code =
- content_window_->delegate()->GetNonClientComponent(event->location());
+ int hit_test_code = content_window_->delegate()->GetNonClientComponent(
+ gfx::ScreenToDIPPoint(event->location()));
if (hit_test_code != HTCLIENT && hit_test_code != HTNOWHERE)
flags |= ui::EF_IS_NON_CLIENT;
event->set_flags(flags);
@@ -1440,11 +1449,13 @@ void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) {
FlashFrame(false);
if (!g_current_capture || g_current_capture == this) {
+ event->set_location(gfx::DIPToScreenPoint(event->location()));
SendEventToProcessor(event);
} else {
// Another DesktopWindowTreeHostX11 has installed itself as
// capture. Translate the event's location and dispatch to the other.
event->ConvertLocationToTarget(window(), g_current_capture->window());
+ event->set_location(gfx::DIPToScreenPoint(event->location()));
g_current_capture->SendEventToProcessor(event);
}
}

Powered by Google App Engine
This is Rietveld 408576698