Fix GTK4 API issues and auto-preload gtk4-layer-shell

- Use property setter for PasswordEntry placeholder text
- Remove unsupported max-width/max-height from CSS
- Set avatar size via set_size_request()
- Auto re-exec with LD_PRELOAD for gtk4-layer-shell linking order
This commit is contained in:
nevaforget 2026-03-26 12:33:27 +01:00
parent 0ee451de9e
commit dd4ef6aa1c
3 changed files with 11 additions and 4 deletions

View File

@ -71,8 +71,10 @@ class LockscreenWindow(Gtk.ApplicationWindow):
if avatar_path:
avatar = Gtk.Picture.new_for_filename(str(avatar_path))
avatar.set_content_fit(Gtk.ContentFit.COVER)
avatar.set_size_request(128, 128)
else:
avatar = Gtk.Box()
avatar.set_size_request(128, 128)
avatar.set_halign(Gtk.Align.CENTER)
avatar.add_css_class("avatar")
self._login_box.append(avatar)
@ -84,8 +86,8 @@ class LockscreenWindow(Gtk.ApplicationWindow):
# Password entry
self._password_entry = Gtk.PasswordEntry()
self._password_entry.set_placeholder_text(self._strings.password_placeholder)
self._password_entry.set_show_peek_icon(True)
self._password_entry.set_property("placeholder-text", self._strings.password_placeholder)
self._password_entry.set_property("show-peek-icon", True)
self._password_entry.add_css_class("password-entry")
self._password_entry.connect("activate", self._on_password_submit)
self._login_box.append(self._password_entry)

View File

@ -1,9 +1,16 @@
# ABOUTME: Entry point for Moonlock — sets up GTK Application and ext-session-lock-v1.
# ABOUTME: Handles CLI invocation, session locking, and multi-monitor support.
import os
import sys
from importlib.resources import files
# gtk4-layer-shell must be loaded before libwayland-client
_LAYER_SHELL_LIB = "/usr/lib/libgtk4-layer-shell.so"
if "LD_PRELOAD" not in os.environ and os.path.exists(_LAYER_SHELL_LIB):
os.environ["LD_PRELOAD"] = _LAYER_SHELL_LIB
os.execvp(sys.executable, [sys.executable, "-m", "moonlock.main"] + sys.argv[1:])
import gi
gi.require_version("Gtk", "4.0")
gi.require_version("Gdk", "4.0")

View File

@ -20,8 +20,6 @@ window.lockscreen {
border-radius: 50%;
min-width: 128px;
min-height: 128px;
max-width: 128px;
max-height: 128px;
background-color: @theme_selected_bg_color;
border: 3px solid alpha(white, 0.3);
}