Compare commits

..
2 Commits
Author SHA1 Message Date
Boria138 34c053c758 feat: add labwc support to the system keyboard
Code check / Check code (push) Failing after 7m11s
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2026-11-21 21:51:44 +05:00
Boria138 eebb274b9c fix: populate the Budgie tray menu before it opens
Code check / Check code (push) Successful in 6m58s
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2026-11-21 21:21:24 +05:00
10 changed files with 233 additions and 66 deletions

No files matched your search

+22 -45
View File
@@ -1,17 +1,19 @@
name: Build native binaries on Debian 11
name: Build vk_gpu_info on Debian 11
on:
workflow_dispatch:
push:
branches:
- main
- scripts
paths:
- 'build-aux/src/**'
- 'build-aux/src/vk_gpu_info.c'
- 'build-aux/src/wine_gpu_names.h'
- '.gitea/workflows/build-vk-gpu-info-debian.yml'
jobs:
build-debian11:
name: Build native binaries on Debian 11
name: Build vk_gpu_info on Debian 11
runs-on: ubuntu-latest
container:
image: debian:11
@@ -20,13 +22,8 @@ jobs:
steps:
- name: Install dependencies
run: |
set -- build-essential cmake pkg-config libvulkan-dev libwayland-dev libx11-dev git curl wget nodejs npm
if ! (apt-get update -o APT::Update::Error-Mode=any && apt-get install -y "$@"); then
echo 'APT failed; retrying with security.debian.org for bullseye-security.'
sed -i '/^[[:space:]]*deb .* bullseye-security /s|http://deb.debian.org/debian-security|http://security.debian.org/debian-security|' /etc/apt/sources.list &&
apt-get update -o APT::Update::Error-Mode=any &&
apt-get install -y "$@"
fi
apt-get update
apt-get install -y build-essential pkg-config libvulkan-dev git curl wget nodejs npm
- name: Set up Node.js
uses: https://git.linux-gaming.ru/actions/setup-node@v2
@@ -35,46 +32,26 @@ jobs:
- name: Checkout code
uses: https://git.linux-gaming.ru/actions/checkout@v3
with:
ref: ${{ gitea.ref }}
token: ${{ secrets.GITEA_TOKEN }}
- name: Build SDL3 for linking
- name: Compile vk_gpu_info
run: |
# SDL 3.2.10 is not available in Debian 11. Only the backends are shipped.
sdl_commit=877399b2b2cf21e67554ed9046410f268ce1d1b2
curl --fail --location --max-time 120 \
"https://codeload.github.com/libsdl-org/SDL/tar.gz/${sdl_commit}" -o /tmp/sdl3.tar.gz
mkdir -p /tmp/sdl3-src
tar -xzf /tmp/sdl3.tar.gz -C /tmp/sdl3-src --strip-components=1
cmake -S /tmp/sdl3-src -B /tmp/sdl3-build \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/sdl3 \
-DCMAKE_INSTALL_LIBDIR=lib -DSDL_UNIX_CONSOLE_BUILD=ON \
-DSDL_SHARED=ON -DSDL_STATIC=OFF -DSDL_TEST_LIBRARY=OFF
cmake --build /tmp/sdl3-build --parallel "$(nproc)"
cmake --install /tmp/sdl3-build
- name: Compile native binaries
run: |
export PKG_CONFIG_PATH="/tmp/sdl3/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
mkdir -p build-aux/bin build-aux/lib
gcc -std=c99 -o build-aux/bin/vk_gpu_info build-aux/src/vk_gpu_info.c -lvulkan
gcc -shared -fPIC -Wl,-z,defs -o build-aux/lib/libportprotonqt_gamepad.so \
build-aux/src/gamepad_backend.c $(pkg-config --cflags --libs sdl3)
gcc -shared -fPIC -Wl,-z,defs -o build-aux/lib/libportprotonqt_keyboard.so \
build-aux/src/keyboard_backend.c $(pkg-config --cflags --libs wayland-client x11)
mkdir -p build-aux/bin
gcc -o build-aux/bin/vk_gpu_info build-aux/src/vk_gpu_info.c -lvulkan
- name: Test vk_gpu_info execution
run: |
test -x build-aux/bin/vk_gpu_info
timeout 10s build-aux/bin/vk_gpu_info || echo "Vulkan smoke test failed; CI may lack a Vulkan device."
# Check if the executable was created
if [ -f "build-aux/bin/vk_gpu_info" ]; then
echo "vk_gpu_info executable created successfully"
# Try to run it (may fail if no Vulkan devices present, but that's OK for build test)
timeout 10s build-aux/bin/vk_gpu_info || echo "vk_gpu_info ran but may have failed due to lack of Vulkan hardware (expected in CI)"
else
echo "ERROR: vk_gpu_info executable was not created"
exit 1
fi
- name: Upload native binaries
- name: Upload vk_gpu_info binary
uses: https://git.linux-gaming.ru/actions/gitea-upload-artifact@v4
with:
name: native-binaries-debian11
path: |
build-aux/bin/vk_gpu_info
build-aux/lib/libportprotonqt_gamepad.so
build-aux/lib/libportprotonqt_keyboard.so
if-no-files-found: error
name: vk_gpu_info-debian11-binary
path: build-aux/bin/vk_gpu_info
+1
View File
@@ -46,6 +46,7 @@
### Fixed
- Исправлено неполное меню PortProtonQt в системном трее Budgie
- Обложки заполняют отведённую область без растягивания
- Исправлена загрузка оценок времени прохождения с HowLongToBeat в карточках игр
- При нажатии вниз на D-pad с верхней панели библиотеки фокус переходит на первую карточку верхнего ряда, а не перескакивает на нижние ряды
+2
View File
@@ -1032,6 +1032,8 @@ class MainWindow(
self._on_only_installed_changed(current_filter[1])
return
self.games = games
if self.tray_manager is not None:
self.tray_manager.refresh_tray_menu()
focus_first_card = not self.game_library_manager.games and not getattr(
self, "_preserve_library_focus_after_load", False
)
+22 -7
View File
@@ -137,16 +137,20 @@ class IBusLayout(X11Layout):
class CosmicLayout:
use_cosmic_protocol = True
def __init__(self) -> None:
self.display = self.layout = None
self.group = None
# Labwc sends the keymap first and may defer the group until a modifier event.
self.group = None if self.use_cosmic_protocol else 0
self.error = None
self.callbacks, self.proxies = [], []
self.keyboard = self.manager = self.tracker = None
self.lib = load_library()
self._configure_library()
self.group_interface = self._interface('zcosmic_keyboard_layout_v1')
self.manager_interface = self._interface('zcosmic_keyboard_layout_manager_v1')
if self.use_cosmic_protocol:
self.group_interface = self._interface('zcosmic_keyboard_layout_v1')
self.manager_interface = self._interface('zcosmic_keyboard_layout_manager_v1')
try:
self.display = self.lib.portproton_keyboard_wayland_connect(None)
if not self.display:
@@ -158,7 +162,7 @@ class CosmicLayout:
for _ in range(4):
self._check(self.lib.wl_display_roundtrip(self.display))
if self.layout is None or self.group is None:
raise RuntimeError('COSMIC keyboard layout protocol or keymap unavailable')
raise RuntimeError('Wayland keyboard layout or keymap unavailable')
except Exception:
self.close()
raise
@@ -216,7 +220,8 @@ class CosmicLayout:
self.seat = self._new(self.registry, (0, self._interface('wl_seat')),
C.c_uint32(name), interface, C.c_uint32(1), C.c_void_p())
self._listen(self.seat, [(self._capabilities, [C.c_uint32])])
elif interface == b'zcosmic_keyboard_layout_manager_v1' and self.manager is None:
elif (self.use_cosmic_protocol and interface == b'zcosmic_keyboard_layout_manager_v1'
and self.manager is None):
self.manager = self._new(self.registry, (0, self.manager_interface),
C.c_uint32(name), interface, C.c_uint32(1), C.c_void_p())
self._track()
@@ -225,12 +230,14 @@ class CosmicLayout:
if capabilities & 2 and self.keyboard is None:
self.keyboard = self._new(self.seat, (1, self._interface('wl_keyboard')), C.c_void_p())
u, p = C.c_uint32, C.c_void_p
modifiers = (lambda *args: None) if self.use_cosmic_protocol else (
lambda serial, depressed, latched, locked, group: self._group(group))
self._listen(self.keyboard, [
(self._keymap, [u, C.c_int, u]),
(lambda *args: None, [u, p, p]),
(lambda *args: None, [u, p]),
(lambda *args: None, [u, u, u, u]),
(lambda *args: None, [u, u, u, u, u])])
(modifiers, [u, u, u, u, u])])
self._track()
elif not capabilities & 2 and self.keyboard is not None:
self.error = RuntimeError('COSMIC: keyboard disconnected')
@@ -289,6 +296,11 @@ class CosmicLayout:
self.display = None
class LabwcLayout(CosmicLayout):
# Labwc broadcasts wl_keyboard group changes even without keyboard focus.
use_cosmic_protocol = False
SOURCE_SCHEMA = 'org.gnome.desktop.input-sources'
BINDINGS_SCHEMA = 'org.gnome.desktop.wm.keybindings'
SHORTCUT_MODIFIERS = {
@@ -385,6 +397,8 @@ def compositor(environment: Any) -> Any:
if name in desktop), None)
if name is not None:
return name
if environment.get("WAYLAND_DISPLAY") and (environment.get("LABWC_PID") or "labwc" in desktop):
return "labwc"
return 'wayland' if environment.get('WAYLAND_DISPLAY') else None
@@ -635,7 +649,8 @@ def detect_layout() -> object:
logger.warning('IBus layout detection unavailable: %s', error)
return X11Layout()
adapter = {'cosmic': CosmicLayout, 'niri': NiriLayout, 'sway': SwayLayout,
'hyprland': HyprlandLayout, 'umbriel': UmbrielLayout, 'mango': MangoLayout}.get(name)
'hyprland': HyprlandLayout, 'umbriel': UmbrielLayout, 'mango': MangoLayout,
'labwc': LabwcLayout}.get(name)
if adapter is None:
raise RuntimeError('No keyboard layout adapter for this compositor')
return adapter()
+32 -3
View File
@@ -42,6 +42,7 @@ class SystemInputWorker(QThread):
self.stopping = Event()
self.enabled = Event()
self.modifiers: set[int] = set()
self.pending_super = False
self.caps_lock = False
self.layout: Any = None
self.manual_layout = False
@@ -109,10 +110,13 @@ class SystemInputWorker(QThread):
self.warning.emit(f'{error}. Manual US/RU labels; external layout changes are not tracked.')
def _execute(self, device: UInput, action: str, codes: tuple[int, ...]) -> None:
from portprotonqt.system_keyboard.detection import CinnamonLayout, GSettingsLayout, KDELayout, X11Layout, is_x11_session
from portprotonqt.system_keyboard.detection import CinnamonLayout, GSettingsLayout, KDELayout, LabwcLayout, X11Layout, is_x11_session
import os
if action in {'tap', 'caps', 'language', 'modifiers'} and not self.enabled.is_set():
return
if isinstance(self.layout, LabwcLayout) and action == 'modifiers':
self._set_labwc_modifiers(device, codes)
return
if action == 'modifiers':
modifier_only = ((self.modifiers == {ecodes.KEY_LEFTMETA}
and not is_x11_session(os.environ))
@@ -126,6 +130,7 @@ class SystemInputWorker(QThread):
self.send_keys(device, chord)
self._set_modifiers(device, codes)
elif action == 'release':
self.pending_super = False
self._set_modifiers(device, ())
elif action == 'caps':
if isinstance(self.layout, X11Layout) and is_x11_session(os.environ):
@@ -133,6 +138,7 @@ class SystemInputWorker(QThread):
else:
self.send_keys(device, (ecodes.KEY_CAPSLOCK,))
elif action == 'language':
self.pending_super = False
self._set_modifiers(device, ())
if (type(self.layout) is X11Layout
and 'gnome' in os.environ.get('XDG_CURRENT_DESKTOP', '').lower().split(':')):
@@ -154,10 +160,32 @@ class SystemInputWorker(QThread):
self.send_keys(device, (ecodes.KEY_KBD_LAYOUT_NEXT,))
elif action == 'tap':
try:
if self.pending_super:
self.pending_super = False
self._set_modifiers(device, (ecodes.KEY_LEFTMETA,))
self.send_keys(device, tuple(code for code in codes if code not in self.modifiers))
finally:
self._set_modifiers(device, ())
def _set_labwc_modifiers(self, device: UInput, codes: tuple[int, ...]) -> None:
requested = set(codes)
super_key = {ecodes.KEY_LEFTMETA}
if self.pending_super and not requested:
# Send both edges after the click; labwc cancels release bindings on pointer presses.
self.pending_super = False
self.send_keys(device, (ecodes.KEY_LEFTMETA,))
return
self.pending_super = requested == super_key and not self.modifiers
if self.pending_super:
return
shift_keys = {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT}
if (len(self.modifiers) == 2 and ecodes.KEY_LEFTALT in self.modifiers
and self.modifiers & shift_keys and self.modifiers - requested):
# XKB already switched when the chord was pressed; do not replay it.
requested.difference_update(self.modifiers)
self._set_modifiers(device, (ecodes.KEY_LEFTALT,))
self._set_modifiers(device, tuple(requested))
def _set_modifiers(self, device: UInput, codes: tuple[int, ...]) -> None:
requested = set(codes)
for code in sorted(self.modifiers - requested, reverse=True):
@@ -193,9 +221,10 @@ class SystemInputWorker(QThread):
name = current[0] if isinstance(current, tuple) else getattr(self.layout, 'language', 'System')
if hasattr(self.layout, 'layout_identifier'):
name = self.layout.layout_identifier()
active = self.modifiers | ({ecodes.KEY_LEFTMETA} if self.pending_super else set())
self.state_changed.emit({'labels': labels, 'caps': caps,
'shift': bool(self.modifiers & {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT}),
'modifiers': tuple(sorted(self.modifiers)), 'layout': name})
'shift': bool(active & {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT}),
'modifiers': tuple(sorted(active)), 'layout': name})
except Exception as error:
logger.warning("Cannot update system keyboard labels: %s", error)
self.warning.emit(str(error))
+10
View File
@@ -14,6 +14,7 @@ from evdev import ecodes
from PySide6.QtCore import QEvent, QObject, QPoint, QPointF, QSocketNotifier, Qt, QTimer
from PySide6.QtGui import QCloseEvent, QIcon, QMouseEvent, QImage, QRegion
from PySide6.QtWidgets import QApplication, QFrame, QLabel, QPushButton, QSizePolicy, QWidget
from shiboken6 import isValid
from portprotonqt.config import gamepad_config, ui_config
from portprotonqt.input_manager.constants import GamepadType
@@ -583,6 +584,8 @@ class WaylandWindow(QObject):
if not width or not height or width * height > MAX_SURFACE_PIXELS:
raise ValueError('Invalid Wayland layer-surface dimensions')
self._request(self.layer, (6, None), (C.c_uint32(serial),))
if self.configured and (width, height) == (self.window.width(), self.window.height()):
return
self.window.resize(width, height)
self.window._position_keyboard()
self.configured = self.dirty = True
@@ -742,6 +745,13 @@ class WaylandWindow(QObject):
self.window.keyboard.stop_backspace_repeat()
def _mouse_event(self, kind: QEvent.Type) -> None:
pressed = self.pressed_widget
if pressed is not None and (not isValid(pressed) or not self.window.isAncestorOf(pressed)):
self.pressed_widget = None
self.window.keyboard.stop_backspace_repeat()
self.dirty = True
if kind == QEvent.Type.MouseButtonRelease and self.pressed_widget is None:
return
point = self.position.toPoint()
target = self.pressed_widget or self.window.childAt(point) or self.window.keyboard
if isinstance(target, QPushButton) and self.window.keyboard.selected_button is not target:
+2 -9
View File
@@ -83,15 +83,8 @@ class TrayManager:
self.pause_game_action.setEnabled(False)
self.pause_game_action.triggered.connect(self.toggle_game_pause)
self.tray_menu.addAction(self.pause_game_action)
self.tray_menu.addAction(self.stop_game_action)
self.tray_menu.addSeparator()
self.tray_menu.addSeparator()
exit_action = QAction(_("Exit"), self.main_window)
exit_action.triggered.connect(self.force_exit)
self.tray_menu.addAction(exit_action)
# Some D-Bus tray hosts read the menu without opening the local QMenu.
self.refresh_tray_menu()
self.tray_menu.aboutToShow.connect(self.refresh_tray_menu)
self.tray_icon.setContextMenu(self.tray_menu)
self.tray_icon.show()
+2
View File
@@ -476,6 +476,7 @@ def test_failed_protondb_completion_preserves_library_scroll(
main.stackedWidget = SimpleNamespace(currentIndex=lambda: 0)
main.getColorPalette_from_pixmap = MagicMock()
main.game_library_manager = manager
main.tray_manager = MagicMock()
main._get_portproton_desktop_files = lambda: set()
monkeypatch.setattr(portproton_api, "get_user_conf_setting", lambda _key: None)
monkeypatch.setattr(api, "load_protondb_status", lambda _appid: None)
@@ -503,6 +504,7 @@ def test_failed_protondb_completion_preserves_library_scroll(
QApplication.processEvents()
QApplication.processEvents()
main.tray_manager.refresh_tray_menu.assert_called_once_with()
assert scrollbar.value() == previous_value
assert not manager._focus_first_card_after_update
+25
View File
@@ -370,6 +370,31 @@ def test_shutdown_waits_for_compatibility_analysis() -> None:
assert window.compatibility_workers == []
def test_tray_exports_complete_menu_before_first_open(monkeypatch: MonkeyPatch) -> None:
_application = QApplication.instance() or QApplication([])
from portprotonqt import tray_manager as tray_module
icon = MagicMock()
theme = MagicMock()
theme.get_icon.return_value = None
monkeypatch.setattr(tray_module, "QSystemTrayIcon", lambda _parent: icon)
monkeypatch.setattr(tray_module, "ThemeManager", lambda: theme)
monkeypatch.setattr(tray_module.ui_config, "get_theme", lambda: "standart")
monkeypatch.setattr(tray_module.display_config, "get_tray_menu_mode", lambda: "detailed")
window = cast(Any, QWidget())
window.games = []
def check_export(menu: QMenu) -> None:
labels = [action.text() for action in menu.actions() if not action.isSeparator()]
assert labels == [tray_module._(text) for text in (
"Pause Game", "Stop Game", "No recent games", "Exit",
)]
icon.setContextMenu.side_effect = check_export
manager = TrayManager(window)
icon.setContextMenu.assert_called_once_with(manager.tray_menu)
def test_minimal_tray_contains_game_actions() -> None:
_application = QApplication.instance() or QApplication([])
manager = TrayManager.__new__(TrayManager)
+115 -2
View File
@@ -297,6 +297,41 @@ def test_modifiers_send_real_press_and_release_events(
assert not worker.modifiers
@pytest.mark.parametrize('action, codes, events', [
('modifiers', (), [(ecodes.KEY_LEFTMETA, 1), (ecodes.KEY_LEFTMETA, 0)]),
('tap', (ecodes.KEY_E,), [(ecodes.KEY_LEFTMETA, 1), (ecodes.KEY_E, 1),
(ecodes.KEY_E, 0), (ecodes.KEY_LEFTMETA, 0)]),
('release', (), []),
])
def test_labwc_super_sends_one_chord_after_click(action: str, codes: tuple[int, ...], events: list) -> None:
worker = SystemInputWorker()
worker.layout = detection.LabwcLayout.__new__(detection.LabwcLayout)
worker.enabled.set()
device = MagicMock()
worker._execute(device, 'modifiers', (ecodes.KEY_LEFTMETA,))
device.write.assert_not_called()
worker._execute(device, action, codes)
assert [call.args for call in device.write.call_args_list] == [
(ecodes.EV_KEY, key, value) for key, value in events
]
assert not worker.modifiers and not worker.pending_super
def test_labwc_alt_shift_releases_both_without_replaying() -> None:
worker = SystemInputWorker()
worker.layout = detection.LabwcLayout.__new__(detection.LabwcLayout)
worker.enabled.set()
device = MagicMock()
worker._execute(device, 'modifiers', (ecodes.KEY_LEFTALT,))
worker._execute(device, 'modifiers', (ecodes.KEY_LEFTALT, ecodes.KEY_LEFTSHIFT))
worker._execute(device, 'modifiers', (ecodes.KEY_LEFTALT,))
assert [call.args for call in device.write.call_args_list] == [
(ecodes.EV_KEY, ecodes.KEY_LEFTALT, 1), (ecodes.EV_KEY, ecodes.KEY_LEFTSHIFT, 1),
(ecodes.EV_KEY, ecodes.KEY_LEFTSHIFT, 0), (ecodes.EV_KEY, ecodes.KEY_LEFTALT, 0),
]
assert not worker.modifiers
def test_alt_shift_replay_preserves_remaining_alt(application: QApplication) -> None:
worker = SystemInputWorker()
worker.enabled.set()
@@ -727,14 +762,37 @@ def test_wayland_protocol_metadata_is_native(application: QApplication) -> None:
window._interface('not_a_protocol')
@pytest.mark.parametrize('desktop', ['labwc', 'wayfire', 'Qtile', 'river', 'unknown'])
def test_budgie_wayland_uses_labwc_layout(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv('XDG_CURRENT_DESKTOP', 'Budgie')
monkeypatch.setenv('WAYLAND_DISPLAY', 'wayland-test')
monkeypatch.setenv('LABWC_PID', '123')
adapter = MagicMock()
monkeypatch.setattr(detection, 'LabwcLayout', adapter)
assert detection.detect_layout() is adapter.return_value
def test_labwc_updates_group_from_keyboard_modifiers() -> None:
layout = detection.LabwcLayout.__new__(detection.LabwcLayout)
fake = cast(Any, layout)
fake.keyboard = fake.manager = None
fake.seat = 1
fake._interface = MagicMock()
fake._new = MagicMock(return_value=2)
fake._listen = MagicMock()
layout._capabilities(2)
modifiers, _ = fake._listen.call_args.args[1][-1]
modifiers(0, 0, 0, 0, 2)
assert layout.group == 2
@pytest.mark.parametrize('desktop', ['wayfire', 'Qtile', 'river', 'unknown'])
def test_generic_wayland_uses_manual_labels_without_xwayland(
monkeypatch: pytest.MonkeyPatch, desktop: str,
) -> None:
monkeypatch.setenv('XDG_CURRENT_DESKTOP', desktop)
monkeypatch.setenv('WAYLAND_DISPLAY', 'wayland-test')
for variable in ('HYPRLAND_INSTANCE_SIGNATURE', 'SWAYSOCK', 'NIRI_SOCKET',
'UMBRIEL_SOCKET', 'MANGO_INSTANCE_SIGNATURE'):
'UMBRIEL_SOCKET', 'MANGO_INSTANCE_SIGNATURE', 'LABWC_PID'):
monkeypatch.delenv(variable, raising=False)
x11 = MagicMock()
monkeypatch.setattr(detection, 'X11Layout', x11)
@@ -984,6 +1042,26 @@ def test_kde_selection_uses_native_backend(monkeypatch: pytest.MonkeyPatch) -> N
assert detection.detect_layout() is factory.return_value
def test_wayland_repeated_configure_does_not_rebuild_keyboard() -> None:
native: Any = system_window.WaylandWindow.__new__(system_window.WaylandWindow)
native.layer = 1
native._request = MagicMock()
native.window = MagicMock()
native.window.width.return_value = 1280
native.window.height.return_value = 720
native.configured = False
native._configured(1, 1280, 720)
native.dirty = False
native._configured(2, 1280, 720)
native.window._position_keyboard.assert_called_once_with()
assert native._request.call_count == 2
assert not native.dirty
native._configured(3, 1920, 1080)
native.window.resize.assert_called_with(1920, 1080)
assert native.window._position_keyboard.call_count == 2
assert native.dirty
def test_wayland_mouse_moves_selection_and_shows_pressed_state(
keyboard_window: SystemKeyboardWindow, application: QApplication,
) -> None:
@@ -1012,6 +1090,41 @@ def test_wayland_mouse_moves_selection_and_shows_pressed_state(
assert keyboard_window.worker.commands.get_nowait() == ('tap', (ecodes.KEY_Q,))
@pytest.mark.parametrize('deleted', [False, True])
def test_wayland_release_after_keyboard_rebuild(
keyboard_window: SystemKeyboardWindow, application: QApplication, deleted: bool,
) -> None:
from PySide6.QtCore import QEvent, QPointF
from shiboken6 import isValid
keyboard_window.ready = True
keyboard_window.show_keyboard()
application.processEvents()
keyboard = keyboard_window.keyboard
target = keyboard.buttons['q']
native: Any = system_window.WaylandWindow.__new__(system_window.WaylandWindow)
native.window = keyboard_window
native.pressed_widget = None
native.position = QPointF(target.mapTo(keyboard_window, target.rect().center()))
native._mouse_event(QEvent.Type.MouseButtonPress)
keyboard.update_keyboard()
if deleted:
QApplication.sendPostedEvents(target, QEvent.Type.DeferredDelete)
assert isValid(target) is not deleted
native._mouse_event(QEvent.Type.MouseButtonRelease)
assert native.pressed_widget is None
assert keyboard_window.worker.commands.empty()
application.processEvents()
replacement = keyboard.buttons['q']
native.position = QPointF(replacement.mapTo(keyboard_window, replacement.rect().center()))
assert keyboard_window.childAt(native.position.toPoint()) is replacement
native._mouse_event(QEvent.Type.MouseButtonPress)
native._mouse_event(QEvent.Type.MouseButtonRelease)
assert keyboard_window.worker.commands.get_nowait() == ('tap', (ecodes.KEY_Q,))
@pytest.mark.parametrize('failed', [False, True])
def test_kde_dbus_connection_is_retained_and_closed(
monkeypatch: pytest.MonkeyPatch, tmp_path: Any, failed: bool,