Skip to content

Commit

Permalink
Use xdo to feed escape keycodes into the focused window prior to
Browse files Browse the repository at this point in the history
attempting mouse and keyboard grabs.

A frequent barrier to the screensaver starting is a modal window,
application popup menu or cinnamon popup being left open when
the user steps away from their computer. This will have the effect
of cancelling or closing these if they exist.

It sends two keystrokes in the event of a popup menu being raised
by a modal dialog (the first will cancel the popup, the second
the dialog).

note: cinnamon popups could be addressed differently (expo/overview
modes already are), but this wasn't possible with application
popups.

Ref: #93
  • Loading branch information
mtwebster committed Jul 10, 2022
1 parent 081fd33 commit 290092b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Depends:
python3-gi-cairo,
python3-setproctitle,
python3-xapp (>= 1.0.1),
python3-xdo,
python3-xlib,
${misc:Depends},
${python3:Depends},
Expand Down
2 changes: 2 additions & 0 deletions src/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def set_active(self, active, msg=None):
if active:
if not status.Active:
self.cinnamon_client.exit_expo_and_overview()
utils.maybe_cancel_ui_grab()
if self.grab_helper.grab_root(False):
if not self.stage:
Gio.Application.get_default().hold()
Expand Down Expand Up @@ -372,6 +373,7 @@ def stage_refreshed(self):
if status.Debug:
print("manager: stage refresh complete")

utils.maybe_cancel_ui_grab()
self.grab_stage()

if status.Locked:
Expand Down
10 changes: 10 additions & 0 deletions src/util/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import grp
import subprocess
import xapp.os
import xdo

import config
import status
Expand Down Expand Up @@ -148,3 +149,12 @@ def clear_clipboards(widget):

def do_quit():
Gtk.main_quit()


# Most popup-menu-type actors and widgets can be closed via the escape key, making sure there's
# no active grab when the screensaver starts.
xdo = xdo.xdo()

def maybe_cancel_ui_grab():
xdo.send_keysequence_window("Escape")
xdo.send_keysequence_window("Escape")

0 comments on commit 290092b

Please sign in to comment.