-
Notifications
You must be signed in to change notification settings - Fork 11
/
send-raw.cr
20 lines (20 loc) · 827 Bytes
/
send-raw.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# SendRaw, Keys
class Cmd::X11::Keyboard::SendRaw < Cmd::Base
def self.min_args; 1 end
def self.max_args; 1 end
def run(thread, args)
txt = args[0]
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
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
key_map_hotkey_up.code = hotkey.keycode
thread.runner.display.x_do.keys_raw [key_map_hotkey_up], pressed: false, delay: 0
end
thread.runner.display.x_do.type txt
thread.runner.display.x_do.set_active_modifiers active_modifiers
end
end
end