From 80719ab5a7ffcaaaa06b7608523e0ebeab540ad1 Mon Sep 17 00:00:00 2001 From: Daniel Johnson Date: Sun, 3 Sep 2023 13:21:28 -0400 Subject: [PATCH] Enable the 'break' keystroke to stop a running game. GTK calls it break, but it's ctrl-pause on my keyboard. This is useful when a game won't go of the mouse, but the keyboard can be used. Deus Ex: Human Revolution does this; this keystroke will let me kill it and get control again. --- lutris/game_actions.py | 8 ++++++-- lutris/gui/views/base.py | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lutris/game_actions.py b/lutris/game_actions.py index 86a93366c..3c6f978f7 100644 --- a/lutris/game_actions.py +++ b/lutris/game_actions.py @@ -40,6 +40,10 @@ class GameActions: def is_game_running(self): return self.game and self.game.is_db_stored and bool(self.application.get_running_game_by_id(self.game.id)) + @property + def is_game_removable(self): + return self.game and (self.game.is_installed or self.game.is_db_stored) + def on_game_state_changed(self, game): """Handler called when the game has changed state""" if self.game and game.id == self.game.get_safe_id(): @@ -129,7 +133,7 @@ class GameActions: and steam_shortcut.shortcut_exists(self.game) and not steam_shortcut.is_steam_game(self.game) ), - "remove": self.game.is_installed or self.game.is_db_stored, + "remove": self.is_game_removable, "view": True, "hide": self.game.is_installed and not self.game.is_hidden, "unhide": self.game.is_hidden, @@ -149,7 +153,7 @@ class GameActions: return None - def on_game_stop(self, _caller): + def on_game_stop(self, *_args): """Stops the game""" game = self.get_running_game() if game: diff --git a/lutris/gui/views/base.py b/lutris/gui/views/base.py index 89d564741..44c5073c9 100644 --- a/lutris/gui/views/base.py +++ b/lutris/gui/views/base.py @@ -79,5 +79,11 @@ class GameView: game_id = self.get_selected_game_id() if game_id: game_actions = self.get_game_actions(game_id) - if game_actions: + if game_actions and game_actions.is_game_removable: game_actions.on_remove_game(self) + elif key == Gdk.KEY_Break: + game_id = self.get_selected_game_id() + if game_id: + game_actions = self.get_game_actions(game_id) + if game_actions and game_actions.is_game_running: + game_actions.on_game_stop(self)