Skip to content

Commit

Permalink
fix grabbing modifier hotkeys that sendRAW a key
Browse files Browse the repository at this point in the history
like previously done with Send for #50, now SendRaw where this also applies
  • Loading branch information
phil294 committed Jul 29, 2023
1 parent 27bac77 commit 3b9a7e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/cmd/x11/keyboard/send-raw.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ class Cmd::X11::Keyboard::SendRaw < Cmd::Base
def self.max_args; 1 end
def run(thread, args)
txt = args[0]
hotkey = thread.hotkey
thread.runner.display.pause do # to prevent hotkey from triggering other hotkey or itself
active_modifiers = thread.runner.display.x_do.active_modifiers
thread.runner.display.x_do.clear_active_modifiers active_modifiers
# TODO: duplicate code as in send.cr
if hotkey && ! hotkey.no_grab
active_modifiers.reject! do |mod|
# We don't want to restore a modifier down below if it came from the hotkey itself.
# This would essentially undo the grabbing.
mod.code == hotkey.keycode
end
end
if (hotkey = thread.hotkey) && hotkey.key_name.size == 1 && txt.includes?(hotkey.key_name)
# TODO: duplicate code as in send.cr
key_map_hotkey_up = XDo::LibXDo::Charcodemap.new
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/x11/keyboard/send.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class Cmd::X11::Keyboard::Send < Cmd::Base
thread.runner.display.x_do.clear_active_modifiers active_modifiers
if hotkey && ! hotkey.no_grab
active_modifiers.reject! do |mod|
# We don't want to restore a modifier if it came from the hotkey itself. This would
# essentially undo the grabbing.
# We don't want to restore a modifier down below if it came from the hotkey itself.
# This would essentially undo the grabbing.
mod.code == hotkey.keycode
end
end
Expand Down

0 comments on commit 3b9a7e6

Please sign in to comment.