diff --git a/src/run/display/x11.cr b/src/run/display/x11.cr index 5aa7cf9..d9ea441 100644 --- a/src/run/display/x11.cr +++ b/src/run/display/x11.cr @@ -293,7 +293,7 @@ module Run _key_event.type = type _key_event.keycode = keycode _key_event.state = state - if keycode <= 9 # mouse button + if type >= 4 # mouse button. keycode will be 1-9 # pretend that keysym = keycode @key_handler.not_nil!.call(_key_event, keycode.to_u64, nil) else diff --git a/tests.ahk b/tests.ahk index e152b67..89d9fe5 100755 --- a/tests.ahk +++ b/tests.ahk @@ -3,7 +3,7 @@ ; Right now, only commands that can be easily tested in 1-2 lines are tested. ;;;;;;;;;;;;;;;;;;;;;; -N_TESTS = 48 +N_TESTS = 50 GoSub, run_tests if tests_run != %N_TESTS% @@ -633,6 +633,28 @@ runwait, xdotool key shift+s expect = hotkey shift_s lowercase,hotkey_shift_s_success,1 gosub assert +; esc and xbutton2 share the same keycode: +goto l_after_esc_hotkey + hotkey_esc: + hotkey_esc_success = 1 + return +l_after_esc_hotkey: +hotkey, esc, hotkey_esc +runwait, xdotool key Escape +expect = hotkey esc,hotkey_esc_success,1 +gosub assert +hotkey, esc, off +goto l_after_xbutton2_hotkey + hotkey_xbutton2: + hotkey_xbutton2_success = 1 + return +l_after_xbutton2_hotkey: +hotkey, xbutton2, hotkey_xbutton2 +runwait, xdotool click 9 +expect = hotkey xbutton2,hotkey_xbutton2_success,1 +gosub assert +hotkey, xbutton2, off + Send, {LButton} sleep 20 expect = send {lbutton},gui_button_clicked_success,1