Handle mouse events outside device screen
Mouse events position were unsigned (so negative values could not be
handled properly).
To avoid issues with negative values, mouse events outside the device
screen were ignored (commit a7fe9ad779).
But as a consequence, drag&drop were "broken" if the "drop" occurred
outside the device screen.
Instead, use signed 32-bits to store the position, and forward events
outside the device screen.
Fixes <https://github.com/Genymobile/scrcpy/issues/357>.
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
#include "log.h"
|
||||
|
||||
static void write_position(Uint8 *buf, const struct position *position) {
|
||||
buffer_write16be(&buf[0], position->point.x);
|
||||
buffer_write16be(&buf[2], position->point.y);
|
||||
buffer_write16be(&buf[4], position->screen_size.width);
|
||||
buffer_write16be(&buf[6], position->screen_size.height);
|
||||
buffer_write32be(&buf[0], position->point.x);
|
||||
buffer_write32be(&buf[4], position->point.y);
|
||||
buffer_write16be(&buf[8], position->screen_size.width);
|
||||
buffer_write16be(&buf[10], position->screen_size.height);
|
||||
}
|
||||
|
||||
int control_event_serialize(const struct control_event *event, unsigned char *buf) {
|
||||
@@ -37,12 +37,12 @@ int control_event_serialize(const struct control_event *event, unsigned char *bu
|
||||
buf[1] = event->mouse_event.action;
|
||||
buffer_write32be(&buf[2], event->mouse_event.buttons);
|
||||
write_position(&buf[6], &event->mouse_event.position);
|
||||
return 14;
|
||||
return 18;
|
||||
case CONTROL_EVENT_TYPE_SCROLL:
|
||||
write_position(&buf[1], &event->scroll_event.position);
|
||||
buffer_write32be(&buf[9], (Uint32) event->scroll_event.hscroll);
|
||||
buffer_write32be(&buf[13], (Uint32) event->scroll_event.vscroll);
|
||||
return 17;
|
||||
buffer_write32be(&buf[13], (Uint32) event->scroll_event.hscroll);
|
||||
buffer_write32be(&buf[17], (Uint32) event->scroll_event.vscroll);
|
||||
return 21;
|
||||
case CONTROL_EVENT_TYPE_COMMAND:
|
||||
buf[1] = event->command_event.action;
|
||||
return 2;
|
||||
|
||||
Reference in New Issue
Block a user