Skip to content

Commit

Permalink
Layer shell support
Browse files Browse the repository at this point in the history
This is almost completely working under Wayland.  To test, use a
compositor that supports Layer Shell, such as KWin.  KWin can be spawned
nested inside an X11 window, such as what Qubes OS provides.

There are two known limitations:

1. The window is too short.
2. The configuration options that control where the app menu appears do
   not work.
  • Loading branch information
DemiMarie committed Dec 1, 2024
1 parent 9d665ee commit a7ad8d3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include:
checks:pylint:
stage: checks
before_script:
- sudo dnf install -y python3-gobject gtk3 xorg-x11-server-Xvfb python3-mypy
- sudo dnf install -y python3-gobject gtk3 xorg-x11-server-Xvfb python3-mypy gtk-layer-shell
- pip3 install --quiet -r ci/requirements.txt
- git clone https://github.com/QubesOS/qubes-core-admin-client ~/core-admin-client
script:
Expand All @@ -23,7 +23,7 @@ checks:tests:
before_script: &before-script
- "PATH=$PATH:$HOME/.local/bin"
- sudo dnf install -y python3-gobject gtk3 python3-pytest python3-pytest-asyncio
python3-coverage xorg-x11-server-Xvfb python3-inotify sequoia-sqv
python3-coverage xorg-x11-server-Xvfb python3-inotify sequoia-sqv gtk-layer-shell
- pip3 install --quiet -r ci/requirements.txt
- git clone https://github.com/QubesOS/qubes-core-admin-client ~/core-admin-client
- git clone https://github.com/QubesOS/qubes-desktop-linux-manager ~/desktop-linux-manager
Expand Down
3 changes: 2 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Build-Depends:
qubes-desktop-linux-manager,
python3-gi,
gobject-introspection,
gir1.2-gtk-3.0
gir1.2-gtk-3.0,
gir1.2-gtklayershell-0.1,
Standards-Version: 3.9.5
Homepage: https://www.qubes-os.org/
X-Python3-Version: >= 3.5
Expand Down
30 changes: 25 additions & 5 deletions qubes_menu/appmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GLib, Gio
gi.require_version('GtkLayerShell', '0.1')
from gi.repository import Gtk, Gdk, GLib, Gio, GtkLayerShell

import gbulb
gbulb.install()
Expand Down Expand Up @@ -208,12 +209,23 @@ def do_activate(self, *args, **kwargs):
if not self.start_in_background:
self.main_window.show_all()
self.initialize_state()
# set size if too big
current_width = self.main_window.get_allocated_width()
current_height = self.main_window.get_allocated_height()
max_height = self.main_window.get_screen().get_height() * 0.9
# set size if too big
max_height = int(self.main_window.get_screen().get_height() * 0.9)
assert max_height > 0
if current_height > max_height:
self.main_window.resize(self.main_window.get_allocated_width(),
int(max_height))
self.main_window.resize(current_height, max_height)
if GtkLayerShell.is_supported():
# The default for layer shell is no keyboard input.
# Explicitly request that the compositor use the normal
# rules for keyboard input as if this was a normal window.
GtkLayerShell.set_keyboard_mode(self.main_window,
GtkLayerShell.KeyboardMode.ON_DEMAND)
# Work around https://github.com/wmww/gtk-layer-shell/issues/167
# by explicitly setting the window size.
self.main_window.set_size_request(current_width,
min(current_height, max_height))

# grab a focus on the initially selected page so that keyboard
# navigation works
Expand Down Expand Up @@ -341,6 +353,14 @@ def perform_setup(self):
'domain-feature-delete:' + feature,
self._update_settings)

if GtkLayerShell.is_supported():
GtkLayerShell.init_for_window(self.main_window)
GtkLayerShell.auto_exclusive_zone_enable(self.main_window)
GtkLayerShell.set_anchor(self.main_window, GtkLayerShell.Edge.LEFT,
True)
GtkLayerShell.set_anchor(self.main_window, GtkLayerShell.Edge.TOP,
True)

def load_style(self, *_args):
"""Load appropriate CSS stylesheet and associated properties."""
light_ref = (importlib.resources.files('qubes_menu') /
Expand Down
1 change: 1 addition & 0 deletions rpm_spec/qubes-desktop-linux-menu.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ BuildRequires: gettext
Requires: python%{python3_pkgversion}-setuptools
Requires: python%{python3_pkgversion}-gbulb
Requires: gtk3
Requires: gtk-layer-shell
Requires: python%{python3_pkgversion}-qubesadmin >= 4.1.8
Requires: qubes-artwork >= 4.1.5
Requires: qubes-desktop-linux-manager
Expand Down

0 comments on commit a7ad8d3

Please sign in to comment.