keyboard: Don't reset depressed mods on config reload#2983
Open
keyboard: Don't reset depressed mods on config reload#2983
Conversation
When the config was reloaded, we were blindly resetting modifiers, despite
the fact that some might be still pressed. This patch makes it so one can
call i.e. set_option_values() from an ipc script without worrying about
modifiers being reset. This can be tested with the following ipc script,
that aims to disable wayfire-shell's toggle_menu <super> binding when there
is a fullscreen window present. Without this patch, the script makes it so
using '<super> KEY_F' to toggle a fullscreen window without releasing the
<super> modifier types the letter 'f' instead of toggling fullscreen. This
is easiest to observe with a window that accepts textual input, such as a
terminal or text editor. With this patch, the window can be freely toggled
fullscreen, without releasing <super> modifier, whilst still disabling the
wayfire-shell plugin's toggle_menu binding when a fullscreen window is
present on the focused output.
#!/usr/bin/python3
import sys
import time
from wayfire import WayfireSocket
from wayfire.extra.ipc_utils import WayfireUtils as Utils
sock = WayfireSocket()
utils = Utils(sock)
remove_menu_binding = {"wayfire-shell/toggle_menu" : "none"}
restore_menu_binding = {"wayfire-shell/toggle_menu" : "<super>"}
sock.watch(["output-gain-focus", "view-fullscreen", "view-unmapped"])
while True:
msg = sock.read_next_event()
if not "event" in msg:
continue
view_id = utils.get_focused_view_id()
if view_id is None:
continue
view_data = sock.get_view(view_id)
if view_data["fullscreen"] is True:
sock.set_option_values(remove_menu_binding)
else:
sock.set_option_values(restore_menu_binding)
2e523ff to
60ba176
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the config was reloaded, we were blindly resetting modifiers, despite the fact that some might be still pressed. This patch makes it so one can call i.e. set_option_values() from an ipc script without worrying about modifiers being reset. This can be tested with the following ipc script, that aims to disable wayfire-shell's
toggle_menu<super> binding when there is a fullscreen window present. Without this patch, the script makes it so using '<super> KEY_F' to toggle a fullscreen window without releasing the modifier types the letter 'f' instead of toggling fullscreen. This is easiest to observe with a window that accepts textual input, such as a terminal or text editor. With this patch, the window can be freely toggled fullscreen, without releasing <super> modifier, whilst still disabling the wayfire-shell plugin'stoggle_menubinding when a fullscreen window is present on the focused output.