From be6f620f91b83f753533859b849c86021ad3bd53 Mon Sep 17 00:00:00 2001 From: Charbel Assaad Date: Mon, 3 Apr 2023 17:47:57 +0300 Subject: [PATCH 1/3] add idle_notify_v1 protocol. --- wlroots/ffi_build.py | 14 ++++++++++++ wlroots/wlr_types/idle_notify_v1.py | 33 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 wlroots/wlr_types/idle_notify_v1.py diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index ff26334a..70151060 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -854,6 +854,19 @@ def has_xwayland() -> bool: struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display); """ +# types/wlr_idle_notify_v1.h +CDEF += """ +struct wlr_idle_notifier_v1; + +struct wlr_idle_notifier_v1 *wlr_idle_notifier_v1_create(struct wl_display *display); + +void wlr_idle_notifier_v1_set_inhibited(struct wlr_idle_notifier_v1 *notifier, + bool inhibited); + +void wlr_idle_notifier_v1_notify_activity(struct wlr_idle_notifier_v1 *notifier, + struct wlr_seat *seat); +""" + # types/wlr_input_device.h CDEF += """ enum wlr_button_state { @@ -2774,6 +2787,7 @@ def has_xwayland() -> bool: #include #include #include +#include #include #include #include diff --git a/wlroots/wlr_types/idle_notify_v1.py b/wlroots/wlr_types/idle_notify_v1.py new file mode 100644 index 00000000..d19b957d --- /dev/null +++ b/wlroots/wlr_types/idle_notify_v1.py @@ -0,0 +1,33 @@ +# Copyright (c) Charbel Assaad 2023 +from pywayland.server import Display + +from wlroots import lib, Ptr + +from .seat import Seat + + +class IdleNotifierV1(Ptr): + def __init__(self, display: Display) -> None: + self._ptr = lib.wlr_idle_notifier_v1_create(display._ptr) + + @property + def inhibited(self) -> bool: + return bool(self._ptr.inhibited) + + def set_inhibited(self, inhibited: bool) -> None: + """ + Inhibit idle. + + Compositors should call this function when the idle state is disabled, e.g. + because a visible client is using the idle-inhibit protocol. + """ + lib.wlr_idle_notifier_v1_set_inhibited(self._ptr, inhibited) + + def notify_activity(self, seat: Seat) -> None: + """ + Notify for user activity on a seat. + + Compositors should call this function whenever an input event is triggered + on a seat. + """ + lib.wlr_idle_notifier_v1_notify_activity(self._ptr, seat._ptr) From bc582e251c3b2ae2b0e8b94d3e7f75037f2dd4e3 Mon Sep 17 00:00:00 2001 From: Charbel Assaad Date: Fri, 7 Apr 2023 12:01:19 +0300 Subject: [PATCH 2/3] add idle_notify_v1 support to tiny. --- tiny/server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tiny/server.py b/tiny/server.py index 1defa63f..0253e995 100644 --- a/tiny/server.py +++ b/tiny/server.py @@ -17,6 +17,7 @@ from wlroots.util.log import logger from wlroots.wlr_types import ( Cursor, + idle_notify_v1, Keyboard, Output, OutputLayout, @@ -99,6 +100,9 @@ def __init__( self._cursor = cursor self._cursor_manager = cursor_manager + # idle_notify_v1 support + self.idle_notify = idle_notify_v1.IdleNotifierV1(self._display) + # the seat manages the keyboard focus information self._seat = seat self.keyboards: list[KeyboardHandler] = [] @@ -195,6 +199,7 @@ def _process_cursor_resize(self) -> None: self.grabbed_view.xdg_surface.set_size(new_width, new_height) def process_cursor_motion(self, time) -> None: + self.idle_notify.notify_activity(self._seat) if self.cursor_mode == CursorMode.MOVE: self._process_cursor_move() return @@ -226,6 +231,7 @@ def send_modifiers( self._seat.keyboard_notify_modifiers(modifiers) def send_key(self, key_event: KeyboardKeyEvent, input_device: InputDevice) -> None: + self.idle_notify.notify_activity(self._seat) keyboard = Keyboard.from_input_device(input_device) keyboard_modifier = keyboard.modifier From 0d88f68e05913ea3b8cd5dd4e77ea013e6d99bfb Mon Sep 17 00:00:00 2001 From: Charbel Assaad Date: Sat, 8 Apr 2023 08:46:08 +0300 Subject: [PATCH 3/3] fix formatting. --- wlroots/ffi_build.py | 4 ++-- wlroots/wlr_types/idle_notify_v1.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wlroots/ffi_build.py b/wlroots/ffi_build.py index 70151060..72fa8b88 100644 --- a/wlroots/ffi_build.py +++ b/wlroots/ffi_build.py @@ -861,10 +861,10 @@ def has_xwayland() -> bool: struct wlr_idle_notifier_v1 *wlr_idle_notifier_v1_create(struct wl_display *display); void wlr_idle_notifier_v1_set_inhibited(struct wlr_idle_notifier_v1 *notifier, - bool inhibited); + bool inhibited); void wlr_idle_notifier_v1_notify_activity(struct wlr_idle_notifier_v1 *notifier, - struct wlr_seat *seat); + struct wlr_seat *seat); """ # types/wlr_input_device.h diff --git a/wlroots/wlr_types/idle_notify_v1.py b/wlroots/wlr_types/idle_notify_v1.py index d19b957d..d6a520c6 100644 --- a/wlroots/wlr_types/idle_notify_v1.py +++ b/wlroots/wlr_types/idle_notify_v1.py @@ -26,7 +26,7 @@ def set_inhibited(self, inhibited: bool) -> None: def notify_activity(self, seat: Seat) -> None: """ Notify for user activity on a seat. - + Compositors should call this function whenever an input event is triggered on a seat. """