mirror of https://github.com/FreeRDP/FreeRDP
Implemented xfreerdp relative mouse input
This commit is contained in:
parent
b1a2efde7d
commit
db00082974
|
@ -426,6 +426,21 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window win
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL xf_generic_RawMotionNotify(xfContext* xfc, int x, int y, Window window, BOOL app)
|
||||||
|
{
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
|
||||||
|
if (app)
|
||||||
|
{
|
||||||
|
WLog_ERR(TAG, "Relative mouse input is not supported with remoate app mode!");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
freerdp_client_send_button_event(&xfc->common, TRUE, PTR_FLAGS_MOVE, x, y);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL xf_event_MotionNotify(xfContext* xfc, const XMotionEvent* event, BOOL app)
|
static BOOL xf_event_MotionNotify(xfContext* xfc, const XMotionEvent* event, BOOL app)
|
||||||
{
|
{
|
||||||
WINPR_ASSERT(xfc);
|
WINPR_ASSERT(xfc);
|
||||||
|
@ -1188,3 +1203,56 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event)
|
||||||
XSync(xfc->display, FALSE);
|
XSync(xfc->display, FALSE);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL xf_generic_RawButtonEvent(xfContext* xfc, int button, BOOL app, BOOL down)
|
||||||
|
{
|
||||||
|
UINT16 flags = 0;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (app)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAYSIZE(xfc->button_map); i++)
|
||||||
|
{
|
||||||
|
const button_map* cur = &xfc->button_map[i];
|
||||||
|
|
||||||
|
if (cur->button == button)
|
||||||
|
{
|
||||||
|
flags = cur->flags;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags != 0)
|
||||||
|
{
|
||||||
|
if (flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL))
|
||||||
|
{
|
||||||
|
if (down)
|
||||||
|
freerdp_client_send_wheel_event(&xfc->common, flags);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOOL extended = FALSE;
|
||||||
|
|
||||||
|
if (flags & (PTR_XFLAGS_BUTTON1 | PTR_XFLAGS_BUTTON2))
|
||||||
|
{
|
||||||
|
extended = TRUE;
|
||||||
|
|
||||||
|
if (down)
|
||||||
|
flags |= PTR_XFLAGS_DOWN;
|
||||||
|
}
|
||||||
|
else if (flags & (PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3))
|
||||||
|
{
|
||||||
|
if (down)
|
||||||
|
flags |= PTR_FLAGS_DOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extended)
|
||||||
|
freerdp_client_send_extended_button_event(&xfc->common, TRUE, flags, 0, 0);
|
||||||
|
else
|
||||||
|
freerdp_client_send_button_event(&xfc->common, TRUE, flags, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
|
@ -36,8 +36,9 @@ void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y);
|
||||||
void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y);
|
void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y);
|
||||||
|
|
||||||
BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window window, BOOL app);
|
BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window window, BOOL app);
|
||||||
BOOL xf_generic_ButtonPress(xfContext* xfc, int x, int y, int button, Window window, BOOL app);
|
BOOL xf_generic_RawMotionNotify(xfContext* xfc, int x, int y, Window window, BOOL app);
|
||||||
BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button, Window window, BOOL app,
|
BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button, Window window, BOOL app,
|
||||||
BOOL down);
|
BOOL down);
|
||||||
|
BOOL xf_generic_RawButtonEvent(xfContext* xfc, int button, BOOL app, BOOL down);
|
||||||
|
|
||||||
#endif /* FREERDP_CLIENT_X11_EVENT_H */
|
#endif /* FREERDP_CLIENT_X11_EVENT_H */
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
|
|
||||||
#define MIN_FINGER_DIST 5
|
#define MIN_FINGER_DIST 5
|
||||||
|
|
||||||
|
static int xf_input_event(xfContext* xfc, XIDeviceEvent* event, int evtype);
|
||||||
|
|
||||||
static const char* xf_input_get_class_string(int class)
|
static const char* xf_input_get_class_string(int class)
|
||||||
{
|
{
|
||||||
if (class == XIKeyClass)
|
if (class == XIKeyClass)
|
||||||
|
@ -68,16 +70,10 @@ static const char* xf_input_get_class_string(int class)
|
||||||
|
|
||||||
int xf_input_init(xfContext* xfc, Window window)
|
int xf_input_init(xfContext* xfc, Window window)
|
||||||
{
|
{
|
||||||
int i, j;
|
int major = XI_2_Major;
|
||||||
int nmasks = 0;
|
int minor = XI_2_Minor;
|
||||||
int ndevices = 0;
|
|
||||||
int major = 2;
|
|
||||||
int minor = 2;
|
|
||||||
XIDeviceInfo* info;
|
|
||||||
XIEventMask evmasks[64];
|
|
||||||
int opcode, event, error;
|
int opcode, event, error;
|
||||||
const rdpSettings* settings;
|
rdpSettings* settings;
|
||||||
BYTE masks[8][XIMaskLen(XI_LASTEVENT)] = { 0 };
|
|
||||||
|
|
||||||
WINPR_ASSERT(xfc);
|
WINPR_ASSERT(xfc);
|
||||||
|
|
||||||
|
@ -100,89 +96,45 @@ int xf_input_init(xfContext* xfc, Window window)
|
||||||
xfc->XInputOpcode = opcode;
|
xfc->XInputOpcode = opcode;
|
||||||
XIQueryVersion(xfc->display, &major, &minor);
|
XIQueryVersion(xfc->display, &major, &minor);
|
||||||
|
|
||||||
if (major * 1000 + minor < 2002)
|
if ((major < XI_2_Major) || ((major == XI_2_Major) && (minor < 2)))
|
||||||
{
|
{
|
||||||
WLog_WARN(TAG, "Server does not support XI 2.2");
|
WLog_WARN(TAG, "Server does not support XI 2.2");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->MultiTouchInput)
|
else
|
||||||
xfc->use_xinput = TRUE;
|
|
||||||
|
|
||||||
info = XIQueryDevice(xfc->display, XIAllDevices, &ndevices);
|
|
||||||
|
|
||||||
for (i = 0; i < ndevices; i++)
|
|
||||||
{
|
{
|
||||||
BOOL touch = FALSE;
|
XIEventMask mask;
|
||||||
XIDeviceInfo* dev = &info[i];
|
unsigned char mask_bytes[XIMaskLen(XI_LASTEVENT)] = { 0 };
|
||||||
|
|
||||||
for (j = 0; j < dev->num_classes; j++)
|
if (freerdp_settings_get_bool(settings, FreeRDP_MouseUseRelativeMove))
|
||||||
{
|
{
|
||||||
XIAnyClassInfo* class = dev->classes[j];
|
XISetMask(mask_bytes, XI_RawMotion);
|
||||||
XITouchClassInfo* t = (XITouchClassInfo*)class;
|
XISetMask(mask_bytes, XI_RawButtonPress);
|
||||||
|
XISetMask(mask_bytes, XI_RawButtonRelease);
|
||||||
if ((class->type == XITouchClass) && (t->mode == XIDirectTouch) &&
|
|
||||||
(strcmp(dev->name, "Virtual core pointer") != 0))
|
|
||||||
{
|
|
||||||
touch = TRUE;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XISetMask(mask_bytes, XI_Motion);
|
||||||
|
XISetMask(mask_bytes, XI_ButtonPress);
|
||||||
|
XISetMask(mask_bytes, XI_ButtonRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < dev->num_classes; j++)
|
if (freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures) ||
|
||||||
|
freerdp_settings_get_bool(settings, FreeRDP_MultiTouchInput))
|
||||||
{
|
{
|
||||||
XIAnyClassInfo* class = dev->classes[j];
|
XISetMask(mask_bytes, XI_TouchBegin);
|
||||||
XITouchClassInfo* t = (XITouchClassInfo*)class;
|
XISetMask(mask_bytes, XI_TouchUpdate);
|
||||||
|
XISetMask(mask_bytes, XI_TouchEnd);
|
||||||
if (xfc->common.context.settings->MultiTouchInput)
|
|
||||||
{
|
|
||||||
WLog_INFO(TAG, "%s (%d) \"%s\" id: %d", xf_input_get_class_string(class->type),
|
|
||||||
class->type, dev->name, dev->deviceid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
evmasks[nmasks].mask = masks[nmasks];
|
mask.deviceid = XIAllMasterDevices;
|
||||||
evmasks[nmasks].mask_len = sizeof(masks[0]);
|
mask.mask_len = sizeof(mask_bytes);
|
||||||
ZeroMemory(masks[nmasks], sizeof(masks[0]));
|
mask.mask = mask_bytes;
|
||||||
evmasks[nmasks].deviceid = dev->deviceid;
|
|
||||||
|
|
||||||
if ((class->type == XITouchClass) && (t->mode == XIDirectTouch) &&
|
int scr = DefaultScreen(xfc->display);
|
||||||
(strcmp(dev->name, "Virtual core pointer") != 0))
|
Window root = RootWindow(xfc->display, scr);
|
||||||
{
|
XISelectEvents(xfc->display, root, &mask, 1);
|
||||||
if (settings->MultiTouchInput)
|
|
||||||
{
|
|
||||||
WLog_INFO(TAG, "%s %s touch device (id: %d, mode: %d), supporting %d touches.",
|
|
||||||
dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent",
|
|
||||||
dev->deviceid, t->mode, t->num_touches);
|
|
||||||
}
|
|
||||||
|
|
||||||
XISetMask(masks[nmasks], XI_TouchBegin);
|
|
||||||
XISetMask(masks[nmasks], XI_TouchUpdate);
|
|
||||||
XISetMask(masks[nmasks], XI_TouchEnd);
|
|
||||||
nmasks++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xfc->use_xinput)
|
|
||||||
{
|
|
||||||
if (!touch && (class->type == XIButtonClass) &&
|
|
||||||
strcmp(dev->name, "Virtual core pointer"))
|
|
||||||
{
|
|
||||||
WLog_INFO(TAG, "%s button device (id: %d, mode: %d)", dev->name, dev->deviceid,
|
|
||||||
t->mode);
|
|
||||||
XISetMask(masks[nmasks], XI_ButtonPress);
|
|
||||||
XISetMask(masks[nmasks], XI_ButtonRelease);
|
|
||||||
XISetMask(masks[nmasks], XI_Motion);
|
|
||||||
nmasks++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
XIFreeDeviceInfo(info);
|
|
||||||
|
|
||||||
if (nmasks > 0)
|
|
||||||
{
|
|
||||||
Status xstatus = XISelectEvents(xfc->display, window, evmasks, nmasks);
|
|
||||||
if (xstatus != 0)
|
|
||||||
WLog_WARN(TAG, "XISelectEvents returned %d", xstatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -477,7 +429,7 @@ static int xf_input_handle_event_local(xfContext* xfc, const XEvent* event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
WLog_ERR(TAG, "unhandled xi type= %d", cookie.cc->evtype);
|
xf_input_event(xfc, cookie.cc->data, cookie.cc->evtype);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,26 +524,28 @@ static int xf_input_touch_remote(xfContext* xfc, XIDeviceEvent* event, int evtyp
|
||||||
y = (int)event->event_y;
|
y = (int)event->event_y;
|
||||||
xf_event_adjust_coordinates(xfc, &x, &y);
|
xf_event_adjust_coordinates(xfc, &x, &y);
|
||||||
|
|
||||||
if (evtype == XI_TouchBegin)
|
switch (evtype)
|
||||||
{
|
{
|
||||||
|
case XI_TouchBegin:
|
||||||
WLog_DBG(TAG, "TouchBegin: %d", touchId);
|
WLog_DBG(TAG, "TouchBegin: %d", touchId);
|
||||||
rdpei->TouchBegin(rdpei, touchId, x, y, &contactId);
|
rdpei->TouchBegin(rdpei, touchId, x, y, &contactId);
|
||||||
}
|
break;
|
||||||
else if (evtype == XI_TouchUpdate)
|
case XI_TouchUpdate:
|
||||||
{
|
|
||||||
WLog_DBG(TAG, "TouchUpdate: %d", touchId);
|
WLog_DBG(TAG, "TouchUpdate: %d", touchId);
|
||||||
rdpei->TouchUpdate(rdpei, touchId, x, y, &contactId);
|
rdpei->TouchUpdate(rdpei, touchId, x, y, &contactId);
|
||||||
}
|
break;
|
||||||
else if (evtype == XI_TouchEnd)
|
case XI_TouchEnd:
|
||||||
{
|
|
||||||
WLog_DBG(TAG, "TouchEnd: %d", touchId);
|
WLog_DBG(TAG, "TouchEnd: %d", touchId);
|
||||||
rdpei->TouchEnd(rdpei, touchId, x, y, &contactId);
|
rdpei->TouchEnd(rdpei, touchId, x, y, &contactId);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int xf_input_event(xfContext* xfc, XIDeviceEvent* event, int evtype)
|
int xf_input_event(xfContext* xfc, XIDeviceEvent* event, int evtype)
|
||||||
{
|
{
|
||||||
xf_input_show_cursor(xfc);
|
xf_input_show_cursor(xfc);
|
||||||
|
|
||||||
|
@ -611,6 +565,29 @@ static int xf_input_event(xfContext* xfc, XIDeviceEvent* event, int evtype)
|
||||||
xf_generic_MotionNotify(xfc, (int)event->event_x, (int)event->event_y, event->detail,
|
xf_generic_MotionNotify(xfc, (int)event->event_x, (int)event->event_y, event->detail,
|
||||||
event->event, xfc->remote_app);
|
event->event, xfc->remote_app);
|
||||||
break;
|
break;
|
||||||
|
case XI_RawButtonPress:
|
||||||
|
case XI_RawButtonRelease:
|
||||||
|
{
|
||||||
|
const XIRawEvent* ev = event;
|
||||||
|
xf_generic_RawButtonEvent(xfc, ev->detail, xfc->remote_app,
|
||||||
|
evtype == XI_RawButtonPress);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case XI_RawMotion:
|
||||||
|
{
|
||||||
|
const XIRawEvent* ev = event;
|
||||||
|
double x = 0.0;
|
||||||
|
double y = 0.0;
|
||||||
|
if (XIMaskIsSet(ev->valuators.mask, 0))
|
||||||
|
x = ev->raw_values[0];
|
||||||
|
if (XIMaskIsSet(ev->valuators.mask, 1))
|
||||||
|
y = ev->raw_values[1];
|
||||||
|
xf_generic_RawMotionNotify(xfc, (int)x, (int)y, event->event, xfc->remote_app);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WLog_INFO(TAG, "xcxx");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -630,15 +607,9 @@ static int xf_input_handle_event_remote(xfContext* xfc, const XEvent* event)
|
||||||
switch (cookie.cc->evtype)
|
switch (cookie.cc->evtype)
|
||||||
{
|
{
|
||||||
case XI_TouchBegin:
|
case XI_TouchBegin:
|
||||||
xf_input_touch_remote(xfc, cookie.cc->data, XI_TouchBegin);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case XI_TouchUpdate:
|
case XI_TouchUpdate:
|
||||||
xf_input_touch_remote(xfc, cookie.cc->data, XI_TouchUpdate);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case XI_TouchEnd:
|
case XI_TouchEnd:
|
||||||
xf_input_touch_remote(xfc, cookie.cc->data, XI_TouchEnd);
|
xf_input_touch_remote(xfc, cookie.cc->data, cookie.cc->evtype);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -673,8 +644,11 @@ int xf_input_handle_event(xfContext* xfc, const XEvent* event)
|
||||||
{
|
{
|
||||||
return xf_input_handle_event_remote(xfc, event);
|
return xf_input_handle_event_remote(xfc, event);
|
||||||
}
|
}
|
||||||
|
else if (settings->MultiTouchGestures)
|
||||||
if (settings->MultiTouchGestures)
|
{
|
||||||
|
return xf_input_handle_event_local(xfc, event);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return xf_input_handle_event_local(xfc, event);
|
return xf_input_handle_event_local(xfc, event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue