fix: destroy solaar-keyboard uinput device when no receiver is connected

When a Logitech receiver is disconnected, tear down the uinput device
so GNOME/mutter no longer detects a virtual pointer, allowing touch
mode and the on-screen keyboard to activate correctly.
This commit is contained in:
Danny Trunk 2026-03-29 14:31:06 +02:00
parent b9e0cf8235
commit bd34f4c068
2 changed files with 17 additions and 0 deletions

View File

@ -268,6 +268,20 @@ def setup_uinput():
logger.warning("cannot create uinput device: %s", e) logger.warning("cannot create uinput device: %s", e)
def teardown_uinput():
global udevice
if udevice is None:
return
try:
udevice.close()
if logger.isEnabledFor(logging.INFO):
logger.info("uinput device closed")
except Exception as e:
logger.warning("cannot close uinput device: %s", e)
finally:
udevice = None
def kbdgroup(): def kbdgroup():
if xkb_setup(): if xkb_setup():
state = XkbStateRec() state = XkbStateRec()

View File

@ -23,6 +23,7 @@ from typing import Callable
import gi import gi
import yaml import yaml
from logitech_receiver import diversion
from logitech_receiver.common import Alert from logitech_receiver.common import Alert
from solaar.i18n import _ from solaar.i18n import _
@ -130,6 +131,8 @@ def _status_changed(device, alert, reason, refresh=False):
alert = Alert.NONE alert = Alert.NONE
tray.update(device) tray.update(device)
if device.kind is None and not tray._devices_info:
diversion.teardown_uinput()
if alert & Alert.ATTENTION: if alert & Alert.ATTENTION:
tray.attention(reason) tray.attention(reason)