Skip to content

Commit

Permalink
Merge pull request #5 from meck/master
Browse files Browse the repository at this point in the history
Scale strut according to GDK_SCALE on hidpi
  • Loading branch information
colonelpanic8 authored Jun 9, 2020
2 parents 84a96d5 + c9c0fba commit cc8d460
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/Graphics/UI/EWMHStrut.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/Graphics/UI/GIGtkStrut.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit cc8d460

Please sign in to comment.