On Sat, 2019-06-29 at 22:26 -0400, Derek Lesho wrote:
Signed-off-by: Derek Lesho dereklesho52@Gmail.com
server/protocol.def | 2 + server/queue.c | 99 ++++++++++++++++++++++++++------------------- 2 files changed, 59 insertions(+), 42 deletions(-)
diff --git a/server/protocol.def b/server/protocol.def index 3a6a202f49..9703b49154 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -358,6 +358,8 @@ typedef union } hw; } hw_input_t;
+#define RIM_ENABLE_NATIVE_MOUSE_MOVE 0x0800 +#define RIM_ENABLE_NATIVE_MOUSE_PRESS 0x1000 typedef union { int type; diff --git a/server/queue.c b/server/queue.c index 35cfcecff5..41c26d8fa0 100644 --- a/server/queue.c +++ b/server/queue.c @@ -1599,6 +1599,9 @@ static int send_hook_ll_message( struct desktop *desktop, struct message *hardwa return 1; }
+int emulate_raw_mouse_move = 1; +int emulate_raw_mouse_press = 1;
/* queue a hardware message for a mouse event */ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, const hw_input_t *input, unsigned int origin, struct msg_queue *sender ) @@ -1666,53 +1669,59 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
if ((device = current->process->rawinput_mouse)) {
if (!(msg = alloc_hardware_message( input->mouse.info, source, time ))) return 0;
msg_data = msg->data;
if ( (emulate_raw_mouse_press && flags & ~MOUSEEVENTF_MOVE) || (emulate_raw_mouse_move && flags & MOUSEEVENTF_MOVE) )
{
if (!(msg = alloc_hardware_message( input->mouse.info, source, time ))) return 0;
msg_data = msg->data;
msg->win = device->target;
msg->msg = WM_INPUT;
msg->wparam = RIM_INPUT;
msg->lparam = 0;
msg->win = device->target;
msg->msg = WM_INPUT;
msg->wparam = RIM_INPUT;
msg->lparam = 0;
msg_data->flags = 0;
msg_data->rawinput.type = RIM_TYPEMOUSE;
msg_data->rawinput.mouse.x = x - desktop->cursor.x;
msg_data->rawinput.mouse.y = y - desktop->cursor.y;
msg_data->rawinput.mouse.button_flags = 0;
msg_data->rawinput.mouse.button_data = 0;
msg_data->flags = 0;
msg_data->rawinput.type = RIM_TYPEMOUSE;
msg_data->rawinput.mouse.x = emulate_raw_mouse_move ? x - desktop->cursor.x : 0;
msg_data->rawinput.mouse.y = emulate_raw_mouse_move ? y - desktop->cursor.y : 0;
msg_data->rawinput.mouse.button_flags = 0;
msg_data->rawinput.mouse.button_data = 0;
for (i = 1; i < ARRAY_SIZE(raw_button_flags); ++i)
{
if (flags & (1 << i))
msg_data->rawinput.mouse.button_flags |= raw_button_flags[i];
}
if (emulate_raw_mouse_press)
{
for (i = 1; i < ARRAY_SIZE(raw_button_flags); ++i)
{
if (flags & (1 << i))
msg_data->rawinput.mouse.button_flags |= raw_button_flags[i];
}
if (flags & MOUSEEVENTF_WHEEL)
{
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_WHEEL;
msg_data->rawinput.mouse.button_data = input->mouse.data;
}
if (flags & MOUSEEVENTF_HWHEEL)
{
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_HORIZONTAL_WHEEL;
msg_data->rawinput.mouse.button_data = input->mouse.data;
}
if (flags & MOUSEEVENTF_XDOWN)
{
if (input->mouse.data == XBUTTON1)
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_BUTTON_4_DOWN;
else if (input->mouse.data == XBUTTON2)
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_BUTTON_5_DOWN;
}
if (flags & MOUSEEVENTF_XUP)
{
if (input->mouse.data == XBUTTON1)
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_BUTTON_4_UP;
else if (input->mouse.data == XBUTTON2)
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_BUTTON_5_UP;
}
if (flags & MOUSEEVENTF_WHEEL)
{
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_WHEEL;
msg_data->rawinput.mouse.button_data = input->mouse.data;
}
if (flags & MOUSEEVENTF_HWHEEL)
{
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_HORIZONTAL_WHEEL;
msg_data->rawinput.mouse.button_data = input->mouse.data;
}
if (flags & MOUSEEVENTF_XDOWN)
{
if (input->mouse.data == XBUTTON1)
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_BUTTON_4_DOWN;
else if (input->mouse.data == XBUTTON2)
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_BUTTON_5_DOWN;
}
if (flags & MOUSEEVENTF_XUP)
{
if (input->mouse.data == XBUTTON1)
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_BUTTON_4_UP;
else if (input->mouse.data == XBUTTON2)
msg_data->rawinput.mouse.button_flags |= RI_MOUSE_BUTTON_5_UP;
}
}
queue_hardware_message( desktop, msg, 0 );
queue_hardware_message( desktop, msg, 0 );
} if (device->flags & RIDEV_NOLEGACY) return FALSE;
@@ -2455,6 +2464,12 @@ DECL_HANDLER(send_rawinput_message) queue_hardware_message( desktop, msg, 0 ); } break;
- case RIM_ENABLE_NATIVE_MOUSE_MOVE:
emulate_raw_mouse_move = 0;
break;
- case RIM_ENABLE_NATIVE_MOUSE_PRESS:
emulate_raw_mouse_press = 0;
default: set_error( STATUS_INVALID_PARAMETER ); }break;
Don't you think we could simplify that by using only one emulate_raw_input flag? Are there any platforms where only some of the raw input events are received?
Also the flag could probably be cleared on the first direct raw input request received instead of requiring private flag values, and an empty raw input event could be sent right after the initialization if we still want to be informed early on.