xfreerdp: fix mouse input inside application windows

This commit is contained in:
Marc-André Moreau 2011-08-17 16:45:09 -04:00
parent dc6d3f022b
commit 257f3ac55b
7 changed files with 53 additions and 4 deletions

View File

@ -138,7 +138,14 @@ boolean xf_event_ButtonPress(xfInfo* xfi, XEvent* event, boolean app)
{
if (app)
{
rdpWindow* window;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xany.window);
if (window != NULL)
{
x += window->windowOffsetX;
y += window->windowOffsetY;
}
}
input->MouseEvent(input, flags, x, y);
@ -150,24 +157,33 @@ boolean xf_event_ButtonPress(xfInfo* xfi, XEvent* event, boolean app)
boolean xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, boolean app)
{
uint16 x, y;
uint16 flags;
rdpInput* input;
input = xfi->instance->input;
x = 0;
y = 0;
flags = 0;
switch (event->xbutton.button)
{
case 1:
x = event->xmotion.x;
y = event->xmotion.y;
flags = PTR_FLAGS_BUTTON1;
break;
case 2:
x = event->xmotion.x;
y = event->xmotion.y;
flags = PTR_FLAGS_BUTTON3;
break;
case 3:
x = event->xmotion.x;
y = event->xmotion.y;
flags = PTR_FLAGS_BUTTON2;
break;
@ -180,10 +196,17 @@ boolean xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, boolean app)
{
if (app)
{
rdpWindow* window;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xany.window);
if (window != NULL)
{
x += window->windowOffsetX;
y += window->windowOffsetY;
}
}
input->MouseEvent(input, flags, event->xbutton.x, event->xbutton.y);
input->MouseEvent(input, flags, x, y);
}
return True;

View File

@ -53,6 +53,7 @@ void xf_rail_CreateWindow(rdpRail* rail, rdpWindow* window)
window->windowWidth, window->windowHeight, "RAIL");
window->extra = (void*) xfw;
window->extraId = (void*) xfw->handle;
}
void xf_rail_register_callbacks(xfInfo* xfi, rdpRail* rail)

View File

@ -323,9 +323,10 @@ boolean xf_post_connect(freerdp* instance)
instance->update->BeginPaint = xf_begin_paint;
instance->update->EndPaint = xf_end_paint;
instance->update->rail = (void*) rail_new();
rail_register_update_callbacks((rdpRail*) instance->update->rail, instance->update);
xf_rail_register_callbacks(xfi, (rdpRail*) instance->update->rail);
xfi->rail = rail_new();
instance->update->rail = (void*) xfi->rail;
rail_register_update_callbacks(xfi->rail, instance->update);
xf_rail_register_callbacks(xfi, xfi->rail);
freerdp_chanman_post_connect(GET_CHANMAN(instance), instance);

View File

@ -72,6 +72,7 @@ struct xf_info
xfWorkArea workArea;
int current_desktop;
boolean remote_app;
rdpRail* rail;
GC gc_mono;
GC gc_default;

View File

@ -33,6 +33,7 @@ typedef struct rdp_window rdpWindow;
struct rdp_window
{
void* extra;
void* extraId;
rdpWindow* prev;
rdpWindow* next;
uint32 windowId;

View File

@ -42,6 +42,8 @@ FREERDP_API void window_list_rewind(rdpWindowList* list);
FREERDP_API boolean window_list_has_next(rdpWindowList* list);
FREERDP_API rdpWindow* window_list_get_next(rdpWindowList* list);
rdpWindow* window_list_get_by_extra_id(rdpWindowList* list, void* extraId);
FREERDP_API void window_list_create(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state);
FREERDP_API void window_list_update(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state);
FREERDP_API void window_list_delete(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo);

View File

@ -51,6 +51,26 @@ rdpWindow* window_list_get_next(rdpWindowList* list)
return next;
}
rdpWindow* window_list_get_by_extra_id(rdpWindowList* list, void* extraId)
{
rdpWindow* window;
window = list->head;
if (window == NULL)
return NULL;
while (window->next != NULL)
{
if (window->extraId == extraId)
return window;
window = window->next;
}
return NULL;
}
rdpWindow* window_list_get_by_id(rdpWindowList* list, uint32 windowId)
{
rdpWindow* window;