diff --git a/constants.h b/constants.h index 972feb7..7990d52 100644 --- a/constants.h +++ b/constants.h @@ -232,7 +232,8 @@ enum RDP_INPUT_DEVICE RDP_INPUT_CODEPOINT = 1, RDP_INPUT_VIRTKEY = 2, RDP_INPUT_SCANCODE = 4, - RDP_INPUT_MOUSE = 0x8001 + RDP_INPUT_MOUSE = 0x8001, + RDP_INPUT_MOUSEX = 0x8002 }; /* Device flags */ @@ -257,6 +258,8 @@ enum RDP_INPUT_DEVICE #define MOUSE_FLAG_BUTTON3 0x4000 #define MOUSE_FLAG_BUTTON4 0x0280 #define MOUSE_FLAG_BUTTON5 0x0380 +#define MOUSEX_FLAG_BUTTON1 0x0001 +#define MOUSEX_FLAG_BUTTON2 0x0002 #define MOUSE_FLAG_DOWN 0x8000 /* Raster operation masks */ diff --git a/proto.h b/proto.h index 9164e8e..e0785e3 100644 --- a/proto.h +++ b/proto.h @@ -244,7 +244,7 @@ RD_BOOL handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, R key_translation xkeymap_translate_key(uint32 keysym, unsigned int keycode, unsigned int state); void xkeymap_send_keys(uint32 keysym, unsigned int keycode, unsigned int state, uint32 ev_time, RD_BOOL pressed, uint8 nesting); -uint16 xkeymap_translate_button(unsigned int button); +uint16 xkeymap_translate_button(unsigned int button, uint16* input_type); char *get_ksname(uint32 keysym); void save_remote_modifiers(uint8 scancode); void restore_remote_modifiers(uint32 ev_time, uint8 scancode); diff --git a/xkeymap.c b/xkeymap.c index 6084e12..2ebc294 100644 --- a/xkeymap.c +++ b/xkeymap.c @@ -883,8 +883,10 @@ xkeymap_send_keys(uint32 keysym, unsigned int keycode, unsigned int state, uint3 } uint16 -xkeymap_translate_button(unsigned int button) +xkeymap_translate_button(unsigned int button, uint16* input_type) { + *input_type = RDP_INPUT_MOUSE; + switch (button) { case Button1: /* left */ @@ -897,6 +899,12 @@ xkeymap_translate_button(unsigned int button) return MOUSE_FLAG_BUTTON4; case Button5: /* wheel down */ return MOUSE_FLAG_BUTTON5; + case 8: /* button 4 */ + *input_type = RDP_INPUT_MOUSEX; + return MOUSEX_FLAG_BUTTON1; + case 9: /* button 5 */ + *input_type = RDP_INPUT_MOUSEX; + return MOUSEX_FLAG_BUTTON2; } return 0; diff --git a/xwin.c b/xwin.c index a907cc0..2994a64 100644 --- a/xwin.c +++ b/xwin.c @@ -2262,7 +2262,7 @@ xwin_toggle_fullscreen(void) static void handle_button_event(XEvent xevent, RD_BOOL down) { - uint16 button, flags = 0; + uint16 button, input_type, flags = 0; g_last_gesturetime = xevent.xbutton.time; /* Reverse the pointer button mapping, e.g. in the case of "left-handed mouse mode"; the RDP session expects to @@ -2270,7 +2270,7 @@ handle_button_event(XEvent xevent, RD_BOOL down) logical button behavior depends on the remote desktop's own mouse settings */ xevent.xbutton.button = g_pointer_log_to_phys_map[xevent.xbutton.button - 1]; - button = xkeymap_translate_button(xevent.xbutton.button); + button = xkeymap_translate_button(xevent.xbutton.button, &input_type); if (button == 0) return; @@ -2306,7 +2306,7 @@ handle_button_event(XEvent xevent, RD_BOOL down) { /* Release the mouse button outside the minimize button, to prevent the actual minimazation to happen */ - rdp_send_input(time(NULL), RDP_INPUT_MOUSE, button, 1, 1); + rdp_send_input(time(NULL), input_type, button, 1, 1); XIconifyWindow(g_display, g_wnd, DefaultScreen(g_display)); return; } @@ -2343,13 +2343,13 @@ handle_button_event(XEvent xevent, RD_BOOL down) if (xevent.xmotion.window == g_wnd) { - rdp_send_input(time(NULL), RDP_INPUT_MOUSE, + rdp_send_input(time(NULL), input_type, flags | button, xevent.xbutton.x, xevent.xbutton.y); } else { /* SeamlessRDP */ - rdp_send_input(time(NULL), RDP_INPUT_MOUSE, + rdp_send_input(time(NULL), input_type, flags | button, xevent.xbutton.x_root, xevent.xbutton.y_root); } }