packages feed

gtk-scaling-image 0.1.0.0 → 0.1.0.1

raw patch · 3 files changed

+35/−9 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Changelog for gtk-scaling-image +## 0.1.0.1 - 2026-05-13++- Fix scaled image rendering on HiDPI displays.+- Normalize auto-fill icon resolution for menu and tray consumers.+- Clean up compiler warnings.+ ## 0.1.0.0  - Initial release.
gtk-scaling-image.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           gtk-scaling-image-version:        0.1.0.0+version:        0.1.0.1 synopsis:       Generic GTK image scaling helpers for haskell-gi description:    Please see the README on Github at <https://github.com/taffybar/gtk-scaling-image#readme> category:       Graphics
src/Graphics/UI/GIGtkScalingImage.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE OverloadedStrings #-}  module Graphics.UI.GIGtkScalingImage@@ -16,6 +17,7 @@   ) where +import Control.Applicative ((<|>)) import qualified Control.Concurrent.MVar as MV import Control.Monad import Control.Monad.IO.Class@@ -250,6 +252,7 @@                 Gtk.OrientationHorizontal -> contentH                 _ -> contentW             scaledFactor = max 1 scaleFactor+            sourceRequestSize = max 1 $ requestSize * scaledFactor          Gtk.widgetSetSizeRequest           drawArea@@ -258,14 +261,14 @@          old <- MV.readMVar cacheVar         srcFresh <--          if force || requestSize /= afRequestSize old-            then getPixbuf requestSize+          if force || sourceRequestSize /= afRequestSize old+            then getPixbuf sourceRequestSize             else pure Nothing -        let src = maybe (afSourcePixbuf old) Just srcFresh+        let src = srcFresh <|> afSourcePixbuf old             needsRefit =               force-                || requestSize /= afRequestSize old+                || sourceRequestSize /= afRequestSize old                 || scaledFactor /= afScaleFactor old                 || insets /= afInsets old                 || contentW /= afContentWidth old@@ -277,7 +280,7 @@               Nothing ->                 pure                   old-                    { afRequestSize = requestSize,+                    { afRequestSize = sourceRequestSize,                       afScaleFactor = scaledFactor,                       afInsets = insets,                       afContentWidth = contentW,@@ -292,7 +295,7 @@                   fitPixbufToBox scaledFactor insets allocW allocH pb                 pure                   old-                    { afRequestSize = requestSize,+                    { afRequestSize = sourceRequestSize,                       afScaleFactor = scaledFactor,                       afInsets = insets,                       afContentWidth = cw,@@ -314,8 +317,25 @@     case afScaledPixbuf st of       Nothing -> pure True       Just pb -> do-        Gdk.cairoSetSourcePixbuf ctx pb (afOffsetX st) (afOffsetY st)-        renderWithContext C.paint ctx+        let scaleFactor = fromIntegral (max 1 $ afScaleFactor st)+            -- GTK3 reports an integer widget scale on fractional Wayland+            -- outputs. The pixbuf is sized in device pixels above, so draw it+            -- through the inverse transform to keep the logical widget size.+            sourceX = afOffsetX st * scaleFactor+            sourceY = afOffsetY st * scaleFactor+        renderWithContext+          ( do+              C.save+              C.scale (1 / scaleFactor) (1 / scaleFactor)+          )+          ctx+        Gdk.cairoSetSourcePixbuf ctx pb sourceX sourceY+        renderWithContext+          ( do+              C.paint+              C.restore+          )+          ctx         pure True    pure $ recompute True