fix: draw classroom icons at the display's real pixel density
Icons went soft under UI_SCALE while the clock text beside them stayed sharp, which is visible on a 24" monitor even if it hides on a TV. new_from_file_at_scale rasterises an SVG at its *logical* size. The artwork is vector, but by the time sway scaled the session it was already a fixed raster, and the compositor enlarged that. Text never had the problem because GTK draws it at the real density. GTK 3 has no fractional scaling, so sway advertises the ceiling integer scale and scales the finished buffer down. Measured under sway: scale factor 1 at output scale 1.0, and 2 at 1.25, 1.5 and 2.0. So each icon is now rasterised at size x scale_factor physical pixels and handed to GTK as a cairo surface carrying that device scale. The icon lands at the real density; its logical size, and the whole dock layout, is unchanged. Icons redraw on notify::scale-factor as well as at realize, since the scale factor is not known until a widget is on a display and changes if UI_SCALE is changed under a running session. Browser, DVD, LIVE and all six DVD control icons go through it, in a shared module so the dock and the DVD session cannot diverge. The throbber is drawn rather than loaded and had the same flaw, so it draws on a device-scaled surface too rather than being the one soft thing left in a sharp dock. The artwork is untouched. Verified by rendering the dock under sway at 1.0, 1.25, 1.5 and 2.0 against the previous build: apparent icon size is identical at every scale (28, 35, 42, 56 px), 1.0 is unchanged pixel-for-pixel, and peak edge contrast on the Chrome icon goes from 60 to 99 at 1.25, 49 to 83 at 1.5, and 37 to 82 at 2.0 out of 255. The DVD control bar was checked the same way. Also records that Wonder Ink session-only cookies are confirmed working on the endpoint, which settles the question 0.1.34 shipped as unverified and tells us the session is in cookies rather than localStorage. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
a0f2b74d05
commit
a1a218b29f
@@ -33,10 +33,9 @@ import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gdk", "3.0")
|
||||
gi.require_version("GdkPixbuf", "2.0")
|
||||
gi.require_version("GtkLayerShell", "0.1")
|
||||
|
||||
from gi.repository import Gdk, GdkPixbuf, GLib, Gtk, GtkLayerShell
|
||||
from gi.repository import Gdk, GLib, Gtk, GtkLayerShell
|
||||
|
||||
sys.path.insert(0, "/usr/local/lib/ekklesia-classroom")
|
||||
sys.path.insert(
|
||||
@@ -49,6 +48,7 @@ import classroom_style as style # noqa: E402
|
||||
import classroom_sway as sway # noqa: E402
|
||||
import classroom_vlc as vlc # noqa: E402
|
||||
from classroom_config import SHELL_SCALE, read_device_config, scaled # noqa: E402
|
||||
from classroom_icons import ScalableIcon # noqa: E402
|
||||
|
||||
# Input shaping needs pycairo. Without it the bar still works, it just
|
||||
# takes pointer events across its whole strip instead of only where it
|
||||
@@ -141,12 +141,8 @@ window#classroom-dvd-bar {{
|
||||
|
||||
|
||||
def icon(filename, size):
|
||||
path = ICON_DIR / filename
|
||||
|
||||
if not path.exists():
|
||||
return None
|
||||
|
||||
return GdkPixbuf.Pixbuf.new_from_file_at_scale(str(path), size, size, True)
|
||||
"""A control bar icon, drawn at the display's real pixel density."""
|
||||
return ScalableIcon(filename, size, ICON_DIR)
|
||||
|
||||
|
||||
def free_port():
|
||||
@@ -324,8 +320,7 @@ class ControlBar(Gtk.Window):
|
||||
button.set_relief(Gtk.ReliefStyle.NONE)
|
||||
button.get_style_context().add_class("dock-button")
|
||||
|
||||
pixbuf = icon(filename, scaled(ICON_SIZE, scale))
|
||||
image = Gtk.Image.new_from_pixbuf(pixbuf) if pixbuf else Gtk.Image()
|
||||
image = icon(filename, scaled(ICON_SIZE, scale))
|
||||
|
||||
self.images[name] = image
|
||||
button.add(image)
|
||||
@@ -446,13 +441,7 @@ class ControlBar(Gtk.Window):
|
||||
if image is None:
|
||||
return
|
||||
|
||||
pixbuf = icon(
|
||||
"media-pause.svg" if playing else "media-play.svg",
|
||||
scaled(ICON_SIZE, self.scale),
|
||||
)
|
||||
|
||||
if pixbuf is not None:
|
||||
image.set_from_pixbuf(pixbuf)
|
||||
image.set_icon("media-pause.svg" if playing else "media-play.svg")
|
||||
|
||||
|
||||
class DvdSession:
|
||||
|
||||
Reference in New Issue
Block a user