|
35 | 35 | ExtIdleNotificationV1, |
36 | 36 | ) |
37 | 37 |
|
38 | | -try: |
39 | | - from pywayland.protocol.ext_idle_notify_v1 import ( |
40 | | - ExtIdleNotifierV1, |
41 | | - ExtIdleNotificationV1, |
42 | | - ) |
43 | | -except Exception as e: |
44 | | - logging.warning("The ext_idle_notify_v1 feature is not available. Exception: %s", e) |
45 | | - logging.warning("This is likely due to an older version of Wayland.") |
46 | | - EXT_IDLE_NOTIFY_IMPORT_ERROR = True |
47 | | -else: |
48 | | - EXT_IDLE_NOTIFY_IMPORT_ERROR = False |
49 | | - |
50 | 38 | from .interface import IdleMonitorInterface |
51 | 39 | from safeeyes import utility |
52 | 40 |
|
@@ -74,6 +62,16 @@ class IdleMonitorExtIdleNotify(IdleMonitorInterface): |
74 | 62 | _idle_config: typing.Optional[IdleConfig] = None |
75 | 63 |
|
76 | 64 | def init(self) -> None: |
| 65 | + try: |
| 66 | + from pywayland.protocol.ext_idle_notify_v1 import ( |
| 67 | + ExtIdleNotifierV1, # noqa: F401 |
| 68 | + ExtIdleNotificationV1, # noqa: F401 |
| 69 | + ) |
| 70 | + except Exception as e: |
| 71 | + logging.warning("The ext_idle_notify_v1 feature is not available.") |
| 72 | + logging.warning("This is likely due to an older version of Wayland.") |
| 73 | + raise e |
| 74 | + |
77 | 75 | # we spawn one wayland client once |
78 | 76 | # when the monitor is not running, it should be quite idle |
79 | 77 | self._r_channel_started, self._w_channel_started = os.pipe() |
@@ -197,8 +195,8 @@ class ExtIdleNotifyInternal: |
197 | 195 | Split out into a separate object to simplify lifetime handling. |
198 | 196 | """ |
199 | 197 |
|
200 | | - _idle_notifier: typing.Optional[ExtIdleNotifierV1] = None |
201 | | - _notification: typing.Optional[ExtIdleNotificationV1] = None |
| 198 | + _idle_notifier: typing.Optional["ExtIdleNotifierV1"] = None |
| 199 | + _notification: typing.Optional["ExtIdleNotificationV1"] = None |
202 | 200 | _display: Display |
203 | 201 | _r_channel_stop: int |
204 | 202 | _w_channel_started: int |
@@ -323,6 +321,8 @@ def _listen(self): |
323 | 321 | self._notification.dispatcher["resumed"] = self._idle_notifier_resume_handler |
324 | 322 |
|
325 | 323 | def _global_handler(self, reg, id_num, iface_name, version) -> None: |
| 324 | + from pywayland.protocol.ext_idle_notify_v1 import ExtIdleNotifierV1 |
| 325 | + |
326 | 326 | if iface_name == "wl_seat": |
327 | 327 | self._seat = reg.bind(id_num, WlSeat, version) |
328 | 328 | if iface_name == "ext_idle_notifier_v1": |
|
0 commit comments