From c3efeccbd6965a26047184ef41bcdf56eb3f4765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 14 May 2013 19:26:01 -0400 Subject: [PATCH] xfreerdp: partial cleanup of multitouch code --- channels/rdpei/client/rdpei_main.c | 94 +++++++++++------------------- channels/rdpei/client/rdpei_main.h | 7 +-- client/X11/xf_event.c | 15 +---- client/X11/xf_input.c | 7 +-- include/freerdp/client/rdpei.h | 8 +-- 5 files changed, 40 insertions(+), 91 deletions(-) diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 562951bed..1147fa816 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -117,8 +117,10 @@ int rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId, status = callback->channel->Write(callback->channel, Stream_Length(s), Stream_Buffer(s), NULL); +#ifdef WITH_DEBUG_RDPEI printf("rdpei_send_pdu: eventId: %d (%s) length: %d status: %d\n", eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength, status); +#endif return status; } @@ -172,8 +174,10 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) int index; RDPINPUT_CONTACT_DATA* contact; +#ifdef WITH_DEBUG_RDPEI printf("contactCount: %d\n", frame->contactCount); printf("frameOffset: 0x%08X\n", (UINT32) frame->frameOffset); +#endif rdpei_write_2byte_unsigned(s, frame->contactCount); /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */ rdpei_write_8byte_unsigned(s, frame->frameOffset); /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */ @@ -184,6 +188,7 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) { contact = &frame->contacts[index]; +#ifdef WITH_DEBUG_RDPEI printf("contact[%d].contactId: %d\n", index, contact->contactId); printf("contact[%d].fieldsPresent: %d\n", index, contact->fieldsPresent); printf("contact[%d].x: %d\n", index, contact->x); @@ -191,6 +196,7 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) printf("contact[%d].contactFlags: 0x%04X", index, contact->contactFlags); rdpei_print_contact_flags(contact->contactFlags); printf("\n"); +#endif Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */ @@ -243,7 +249,7 @@ int rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, RDPINPUT_TOUCH_ Stream_Seek(s, RDPINPUT_HEADER_LENGTH); rdpei_write_4byte_unsigned(s, frame->frameOffset); /* FOUR_BYTE_UNSIGNED_INTEGER */ - rdpei_write_2byte_unsigned(s, frame->contactCount); /* TWO_BYTE_UNSIGNED_INTEGER */ + rdpei_write_2byte_unsigned(s, 1); /* TWO_BYTE_UNSIGNED_INTEGER */ rdpei_write_touch_frame(s, frame); @@ -289,8 +295,10 @@ int rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) Stream_Read_UINT16(s, eventId); /* eventId (2 bytes) */ Stream_Read_UINT32(s, pduLength); /* pduLength (4 bytes) */ +#ifdef WITH_DEBUG_RDPEI printf("rdpei_recv_pdu: eventId: %d (%s) length: %d\n", eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength); +#endif switch (eventId) { @@ -407,32 +415,22 @@ int rdpei_get_version(RdpeiClientContext* context) return rdpei->version; } -int rdpei_begin_frame(RdpeiClientContext* context) -{ - RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; - - rdpei->frame.contactCount = 0; - rdpei->frame.frameOffset = 0; - - return 1; -} - -int rdpei_end_frame(RdpeiClientContext* context) +int rdpei_send_frame(RdpeiClientContext* context) { + UINT64 currentTime; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; RDPEI_CHANNEL_CALLBACK* callback = rdpei->listener_callback->channel_callback; - //if (rdpei->frame.contactCount < 8) - // return 0; + currentTime = GetTickCount64(); if (!rdpei->previousFrameTime && !rdpei->currentFrameTime) { - rdpei->currentFrameTime = (UINT64) GetTickCount64(); + rdpei->currentFrameTime = currentTime; rdpei->frame.frameOffset = 0; } else { - rdpei->currentFrameTime = (UINT64) GetTickCount64(); + rdpei->currentFrameTime = currentTime; rdpei->frame.frameOffset = rdpei->currentFrameTime - rdpei->previousFrameTime; } @@ -453,12 +451,14 @@ int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contac rdpei->frame.contactCount++; } + rdpei_send_frame(context); + return 1; } -int rdpei_contact_begin(RdpeiClientContext* context, int externalId, int x, int y) +int rdpei_contact_begin(RdpeiClientContext* context, int externalId) { - int i, j; + int i; int contactId = -1; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; @@ -470,21 +470,13 @@ int rdpei_contact_begin(RdpeiClientContext* context, int externalId, int x, int { rdpei->contactPoints[i].flags = 1; rdpei->contactPoints[i].contactId = i; - rdpei->contactPoints[i].touchDownX = x; - rdpei->contactPoints[i].touchDownX = y; - for (j = 0; j < MAX_EXTERNAL_IDS; j++) + if (!rdpei->contactPoints[i].externalId) { - if (!rdpei->contactPoints[i].externalIds[j]) - { - rdpei->contactPoints[i].externalIds[j] = externalId; - rdpei->contactPoints[i].externalIdCount++; - break; - } + rdpei->contactPoints[i].externalId = externalId; + contactId = rdpei->contactPoints[i].contactId; + break; } - - contactId = rdpei->contactPoints[i].contactId; - break; } } @@ -493,7 +485,7 @@ int rdpei_contact_begin(RdpeiClientContext* context, int externalId, int x, int int rdpei_contact_update(RdpeiClientContext* context, int externalId) { - int i, j; + int i; int contactId = -1; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; @@ -502,17 +494,11 @@ int rdpei_contact_update(RdpeiClientContext* context, int externalId) if (!rdpei->contactPoints[i].flags) continue; - for (j = 0; j < MAX_EXTERNAL_IDS; j++) + if (rdpei->contactPoints[i].externalId == externalId) { - if (rdpei->contactPoints[i].externalIds[j] == externalId) - { - contactId = rdpei->contactPoints[i].contactId; - break; - } - } - - if (contactId != -1) + contactId = rdpei->contactPoints[i].contactId; break; + } } return contactId; @@ -520,7 +506,7 @@ int rdpei_contact_update(RdpeiClientContext* context, int externalId) int rdpei_contact_end(RdpeiClientContext* context, int externalId) { - int i, j; + int i; int contactId = -1; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; @@ -529,26 +515,14 @@ int rdpei_contact_end(RdpeiClientContext* context, int externalId) if (!rdpei->contactPoints[i].flags) continue; - for (j = 0; j < MAX_EXTERNAL_IDS; j++) + if (rdpei->contactPoints[i].externalId == externalId) { - if (rdpei->contactPoints[i].externalIds[j] == externalId) - { - contactId = rdpei->contactPoints[i].contactId; - rdpei->contactPoints[i].externalIds[j] = 0; - rdpei->contactPoints[i].externalIdCount--; - - if (rdpei->contactPoints[i].externalIdCount < 1) - { - rdpei->contactPoints[i].flags = 0; - rdpei->contactPoints[i].contactId = 0; - } - - break; - } - } - - if (contactId != -1) + contactId = rdpei->contactPoints[i].contactId; + rdpei->contactPoints[i].externalId = 0; + rdpei->contactPoints[i].flags = 0; + rdpei->contactPoints[i].contactId = 0; break; + } } return contactId; @@ -592,8 +566,6 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) context->handle = (void*) rdpei; context->GetVersion = rdpei_get_version; - context->BeginFrame = rdpei_begin_frame; - context->EndFrame = rdpei_end_frame; context->AddContact = rdpei_add_contact; context->ContactBegin = rdpei_contact_begin; diff --git a/channels/rdpei/client/rdpei_main.h b/channels/rdpei/client/rdpei_main.h index 8e532bd00..8c0137ce4 100644 --- a/channels/rdpei/client/rdpei_main.h +++ b/channels/rdpei/client/rdpei_main.h @@ -51,16 +51,11 @@ #define EVENTID_RESUME_TOUCH 0x0005 #define EVENTID_DISMISS_HOVERING_CONTACT 0x0006 -#define MAX_EXTERNAL_IDS 32 - struct _RDPINPUT_CONTACT_POINT { UINT32 flags; UINT32 contactId; - int touchDownX; - int touchDownY; - int externalIdCount; - int externalIds[MAX_EXTERNAL_IDS]; + int externalId; }; typedef struct _RDPINPUT_CONTACT_POINT RDPINPUT_CONTACT_POINT; diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 5af5c232e..95b7a423d 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -132,13 +132,10 @@ static BOOL xf_event_VisibilityNotify(xfInfo* xfi, XEvent* event, BOOL app) static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app) { - rdpInput* input; int x, y; + rdpInput* input; Window childWindow; - if (xfi->settings->MultiTouchInput) - return TRUE; - input = xfi->instance->input; x = event->xmotion.x; y = event->xmotion.y; @@ -184,13 +181,10 @@ static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app) { int x, y; int flags; - Window childWindow; BOOL wheel; BOOL extended; rdpInput* input; - - if (xfi->settings->MultiTouchInput) - return TRUE; + Window childWindow; input = xfi->instance->input; @@ -297,12 +291,9 @@ static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app) { int x, y; int flags; - Window childWindow; BOOL extended; rdpInput* input; - - if (xfi->settings->MultiTouchInput) - return TRUE; + Window childWindow; input = xfi->instance->input; diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index d34fee12d..23bb97fb6 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -338,9 +338,6 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) y = (int) event->event_y; ZeroMemory(&contact, sizeof(RDPINPUT_CONTACT_DATA)); - //if ((x < 0) || (y < 0)) - // return 0; - contact.fieldsPresent = 0; contact.x = x; contact.y = y; @@ -348,7 +345,7 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) if (flags & CONTACT_FLAG_DOWN) { - contact.contactId = rdpei->ContactBegin(rdpei, touchId, x, y); + contact.contactId = rdpei->ContactBegin(rdpei, touchId); contact.contactFlags |= CONTACT_FLAG_INRANGE; contact.contactFlags |= CONTACT_FLAG_INCONTACT; } @@ -363,9 +360,7 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) contact.contactId = rdpei->ContactEnd(rdpei, touchId); } - rdpei->BeginFrame(rdpei); rdpei->AddContact(rdpei, &contact); - rdpei->EndFrame(rdpei); return 0; } diff --git a/include/freerdp/client/rdpei.h b/include/freerdp/client/rdpei.h index 37ed03ead..a38c940dc 100644 --- a/include/freerdp/client/rdpei.h +++ b/include/freerdp/client/rdpei.h @@ -64,11 +64,9 @@ typedef struct _RDPINPUT_TOUCH_FRAME RDPINPUT_TOUCH_FRAME; typedef struct _rdpei_client_context RdpeiClientContext; typedef int (*pcRdpeiGetVersion)(RdpeiClientContext* context); -typedef int (*pcRdpeiBeginFrame)(RdpeiClientContext* context); -typedef int (*pcRdpeiEndFrame)(RdpeiClientContext* context); typedef int (*pcRdpeiAddContact)(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact); -typedef int (*pcRdpeiContactBegin)(RdpeiClientContext* context, int externalId, int x, int y); +typedef int (*pcRdpeiContactBegin)(RdpeiClientContext* context, int externalId); typedef int (*pcRdpeiContactUpdate)(RdpeiClientContext* context, int externalId); typedef int (*pcRdpeiContactEnd)(RdpeiClientContext* context, int externalId); @@ -78,10 +76,8 @@ struct _rdpei_client_context void* custom; pcRdpeiGetVersion GetVersion; - pcRdpeiBeginFrame BeginFrame; - pcRdpeiEndFrame EndFrame; - pcRdpeiAddContact AddContact; + pcRdpeiAddContact AddContact; pcRdpeiContactBegin ContactBegin; pcRdpeiContactUpdate ContactUpdate; pcRdpeiContactEnd ContactEnd;