From c9c0fbae74a30b50afba01dd3296ded24f657aa6 Mon Sep 17 00:00:00 2001 From: meck Date: Tue, 9 Jun 2020 17:42:28 +0200 Subject: [PATCH] Scale strut according to GDK_SCALE on hidpi --- src/Graphics/UI/EWMHStrut.hs | 16 ++++++++++++++++ src/Graphics/UI/GIGtkStrut.hs | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Graphics/UI/EWMHStrut.hs b/src/Graphics/UI/EWMHStrut.hs index a2f36a1..9d9c1d0 100644 --- a/src/Graphics/UI/EWMHStrut.hs +++ b/src/Graphics/UI/EWMHStrut.hs @@ -42,6 +42,22 @@ zeroStrutSettings = EWMHStrutSettings , _bottom_end_x = 0 } +scaleStrutSettings :: Int32 -> EWMHStrutSettings -> EWMHStrutSettings +scaleStrutSettings scaleFactor st = st + { _left = _left st * scaleFactor + , _right = _right st * scaleFactor + , _top = _top st * scaleFactor + , _bottom = _bottom st * scaleFactor + , _left_start_y = _left_start_y st * scaleFactor + , _left_end_y = _left_end_y st * scaleFactor + , _right_start_y = _right_start_y st * scaleFactor + , _right_end_y = _right_end_y st * scaleFactor + , _top_start_x = _top_start_x st * scaleFactor + , _top_end_x = _top_end_x st * scaleFactor + , _bottom_start_x = _bottom_start_x st * scaleFactor + , _bottom_end_x = _bottom_end_x st * scaleFactor + } + strutSettingsToPtr :: MonadIO m => EWMHStrutSettings -> m (Ptr CULong) strutSettingsToPtr EWMHStrutSettings { _left = left diff --git a/src/Graphics/UI/GIGtkStrut.hs b/src/Graphics/UI/GIGtkStrut.hs index 7e0cf4c..0875c02 100644 --- a/src/Graphics/UI/GIGtkStrut.hs +++ b/src/Graphics/UI/GIGtkStrut.hs @@ -80,6 +80,7 @@ setupStrutWindow StrutConfig geometry <- Gdk.newZeroGeometry monitorGeometry <- Gdk.monitorGetGeometry monitor + monitorScaleFactor <- Gdk.monitorGetScaleFactor monitor monitorWidth <- Gdk.getRectangleWidth monitorGeometry monitorHeight <- Gdk.getRectangleHeight monitorGeometry monitorX <- Gdk.getRectangleX monitorGeometry @@ -156,7 +157,8 @@ setupStrutWindow StrutConfig setStrutProperties = void $ runMaybeT $ do gdkWindow <- MaybeT $ Gtk.widgetGetWindow window - lift $ setStrut gdkWindow ewmhSettings + lift $ setStrut gdkWindow $ + scaleStrutSettings monitorScaleFactor ewmhSettings void $ Gtk.onWidgetRealize window setStrutProperties