diff options
Diffstat (limited to 'chromium/ui/ozone/platform/x11/x11_screen_ozone.cc')
-rw-r--r-- | chromium/ui/ozone/platform/x11/x11_screen_ozone.cc | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/chromium/ui/ozone/platform/x11/x11_screen_ozone.cc b/chromium/ui/ozone/platform/x11/x11_screen_ozone.cc index 76aeb9e1c14..b98ae4ed908 100644 --- a/chromium/ui/ozone/platform/x11/x11_screen_ozone.cc +++ b/chromium/ui/ozone/platform/x11/x11_screen_ozone.cc @@ -10,6 +10,8 @@ #include "ui/events/platform/x11/x11_event_source.h" #include "ui/gfx/font_render_params.h" #include "ui/gfx/geometry/dip_util.h" +#include "ui/gfx/geometry/point_conversions.h" +#include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/native_widget_types.h" #include "ui/platform_window/x11/x11_topmost_window_finder.h" #include "ui/platform_window/x11/x11_window.h" @@ -29,10 +31,6 @@ float GetDeviceScaleFactor() { return device_scale_factor; } -gfx::Point PixelToDIPPoint(const gfx::Point& pixel_point) { - return gfx::ConvertPointToDIP(GetDeviceScaleFactor(), pixel_point); -} - } // namespace X11ScreenOzone::X11ScreenOzone() @@ -74,14 +72,20 @@ display::Display X11ScreenOzone::GetDisplayForAcceleratedWidget( } gfx::Point X11ScreenOzone::GetCursorScreenPoint() const { + base::Optional<gfx::Point> point_in_pixels; if (ui::X11EventSource::HasInstance()) { - base::Optional<gfx::Point> point = - ui::X11EventSource::GetInstance() - ->GetRootCursorLocationFromCurrentEvent(); - if (point) - return PixelToDIPPoint(point.value()); + point_in_pixels = ui::X11EventSource::GetInstance() + ->GetRootCursorLocationFromCurrentEvent(); + } + if (!point_in_pixels) { + // This call is expensive so we explicitly only call it when + // |point_in_pixels| is not set. We note that base::Optional::value_or() + // would cause it to be called regardless. + point_in_pixels = GetCursorLocation(); } - return PixelToDIPPoint(GetCursorLocation()); + // TODO(danakj): Should this be rounded? Or kept as a floating point? + return gfx::ToFlooredPoint( + gfx::ConvertPointToDips(*point_in_pixels, GetDeviceScaleFactor())); } gfx::AcceleratedWidget X11ScreenOzone::GetAcceleratedWidgetAtScreenPoint( @@ -107,14 +111,19 @@ display::Display X11ScreenOzone::GetDisplayNearestPoint( } display::Display X11ScreenOzone::GetDisplayMatching( - const gfx::Rect& match_rect) const { + const gfx::Rect& match_rect_in_pixels) const { + gfx::Rect match_rect = gfx::ToEnclosingRect( + gfx::ConvertRectToDips(match_rect_in_pixels, GetDeviceScaleFactor())); const display::Display* matching_display = display::FindDisplayWithBiggestIntersection( - x11_display_manager_->displays(), - gfx::ConvertRectToDIP(GetDeviceScaleFactor(), match_rect)); + x11_display_manager_->displays(), match_rect); return matching_display ? *matching_display : GetPrimaryDisplay(); } +void X11ScreenOzone::SetScreenSaverSuspended(bool suspend) { + SuspendX11ScreenSaver(suspend); +} + void X11ScreenOzone::AddObserver(display::DisplayObserver* observer) { x11_display_manager_->AddObserver(observer); } |