From cfd3407f69e6178757e32416b6e72406a55ceb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 22 Aug 2011 21:22:05 -0400 Subject: [PATCH] xfreerdp: fix drawing of maximized RAIL windows --- client/X11/xf_event.c | 30 +++++++++++++++--------------- client/X11/xf_rail.c | 17 +++++++---------- client/X11/xf_window.c | 33 ++++++++++++++++++++++++++++++--- client/X11/xf_window.h | 6 ++++-- client/X11/xfreerdp.c | 2 +- libfreerdp-rail/rail.c | 24 ++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 31 deletions(-) diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index fd7a1ca04..26e749e4a 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -93,15 +93,14 @@ boolean xf_event_Expose(xfInfo* xfi, XEvent* event, boolean app) xfw = (xfWindow*) window->extra; XPutImage(xfi->display, xfi->primary, xfw->gc, xfi->image, - window->windowOffsetX, window->windowOffsetY, - window->windowOffsetX, window->windowOffsetY, - window->windowWidth, window->windowHeight); + xfw->left, xfw->top, xfw->left, xfw->top, xfw->width, xfw->height); XCopyArea(xfi->display, xfi->primary, xfw->handle, xfw->gc, - window->windowOffsetX, window->windowOffsetY, - window->windowWidth, window->windowHeight, 0, 0); + xfw->left, xfw->top, xfw->width, xfw->height, 0, 0); XFlush(xfi->display); + + xfw = (xfWindow*) window->extra; } } @@ -178,7 +177,7 @@ boolean xf_event_ButtonPress(xfInfo* xfi, XEvent* event, boolean app) case 5: wheel = True; - flags = PTR_FLAGS_WHEEL | 0x0088; + flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088; break; default: @@ -198,13 +197,15 @@ boolean xf_event_ButtonPress(xfInfo* xfi, XEvent* event, boolean app) { if (app) { + xfWindow* xfw; rdpWindow* window; window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xbutton.window); if (window != NULL) { - x += window->windowOffsetX; - y += window->windowOffsetY; + xfw = (xfWindow*) window->extra; + x += xfw->left; + y += xfw->top; } } @@ -256,13 +257,15 @@ boolean xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, boolean app) { if (app) { + xfWindow* xfw; 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; + xfw = (xfWindow*) window->extra; + x += xfw->left; + y += xfw->top; } } @@ -406,13 +409,10 @@ boolean xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, boolean app) xfw = (xfWindow*) window->extra; XPutImage(xfi->display, xfi->primary, xfw->gc, xfi->image, - window->windowOffsetX, window->windowOffsetY, - window->windowOffsetX, window->windowOffsetY, - window->windowWidth, window->windowHeight); + xfw->left, xfw->top, xfw->left, xfw->top, xfw->width, xfw->height); XCopyArea(xfi->display, xfi->primary, xfw->handle, xfw->gc, - window->windowOffsetX, window->windowOffsetY, - window->windowWidth, window->windowHeight, 0, 0); + xfw->left, xfw->top, xfw->width, xfw->height, 0, 0); XFlush(xfi->display); } diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c index 4a933468b..1cb34a1d0 100644 --- a/client/X11/xf_rail.c +++ b/client/X11/xf_rail.c @@ -41,10 +41,10 @@ void xf_rail_paint(xfInfo* xfi, rdpRail* rail, uint32 ileft, uint32 itop, uint32 window = window_list_get_next(rail->list); xfw = (xfWindow*) window->extra; - wleft = window->windowOffsetX; - wtop = window->windowOffsetY; - wright = window->windowOffsetX + window->windowWidth - 1; - wbottom = window->windowOffsetY + window->windowHeight - 1; + wleft = xfw->left; + wtop = xfw->top; + wright = xfw->right; + wbottom = xfw->bottom; intersect = ((iright > wleft) && (ileft < wright) && (ibottom > wtop) && (itop < wbottom)) ? True : False; @@ -63,8 +63,7 @@ void xf_rail_paint(xfInfo* xfi, rdpRail* rail, uint32 ileft, uint32 itop, uint32 XCopyArea(xfi->display, xfi->primary, xfw->handle, xfw->gc, uleft, utop, uwidth, uheight, - uleft - window->windowOffsetX, - utop - window->windowOffsetY); + uleft - xfw->left, utop - xfw->top); } } @@ -79,8 +78,7 @@ void xf_rail_CreateWindow(rdpRail* rail, rdpWindow* window) xfi = (xfInfo*) rail->extra; xfw = xf_CreateWindow((xfInfo*) rail->extra, - window->windowOffsetX + xfi->workArea.x, - window->windowOffsetY + xfi->workArea.y, + window->windowOffsetX, window->windowOffsetY, window->windowWidth, window->windowHeight, window->windowId); @@ -99,8 +97,7 @@ void xf_rail_MoveWindow(rdpRail* rail, rdpWindow* window) xfw = (xfWindow*) window->extra; xf_MoveWindow((xfInfo*) rail->extra, xfw, - window->windowOffsetX + xfi->workArea.x, - window->windowOffsetY + xfi->workArea.y, + window->windowOffsetX, window->windowOffsetY, window->windowWidth, window->windowHeight); } diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 057e6c1db..c43942d0f 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -206,6 +206,20 @@ xfWindow* desktop_create(xfInfo* xfi, char* name) return window; } +void xf_fix_window_coordinates(int* x, int* y, int* width, int* height) +{ + if (*x < 0) + { + *width += *x; + *x = 0; + } + if (*y < 0) + { + *height += *y; + *y = 0; + } +} + char rail_window_class[] = "RAIL:00000000"; xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, uint32 id) @@ -214,6 +228,15 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, uint window = (xfWindow*) xzalloc(sizeof(xfWindow)); + if ((width * height) < 1) + return NULL; + + xf_fix_window_coordinates(&x, &y, &width, &height); + + window->left = x; + window->top = y; + window->right = x + width - 1; + window->bottom = y + height - 1; window->width = width; window->height = height; @@ -285,6 +308,8 @@ void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int h if ((width * height) < 1) return; + xf_fix_window_coordinates(&x, &y, &width, &height); + size_hints = XAllocSizeHints(); if (size_hints) @@ -298,7 +323,7 @@ void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int h if (window->width == width && window->height == height) XMoveWindow(xfi->display, window->handle, x, y); - else if (window->x == x && window->y == y) + else if (window->left == x && window->top == y) XResizeWindow(xfi->display, window->handle, width, height); else XMoveResizeWindow(xfi->display, window->handle, x, y, width, height); @@ -308,8 +333,10 @@ void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int h XFreePixmap(xfi->display, window->surface); window->surface = surface; - window->x = x; - window->y = y; + window->left = x; + window->top = y; + window->right = x + width - 1; + window->bottom = y + height - 1; window->width = width; window->height = height; } diff --git a/client/X11/xf_window.h b/client/X11/xf_window.h index e6df94b25..0f050982c 100644 --- a/client/X11/xf_window.h +++ b/client/X11/xf_window.h @@ -31,8 +31,10 @@ typedef struct xf_window xfWindow; struct xf_window { GC gc; - int x; - int y; + int left; + int top; + int right; + int bottom; int width; int height; Window handle; diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index 9d5506474..8a1ec3841 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -205,7 +205,7 @@ boolean xf_pre_connect(freerdp* instance) if (settings->workarea) { settings->monitors[n].x = screen_info[n].x_org; - settings->monitors[n].y = screen_info[n].y_org; + settings->monitors[n].y = xfi->workArea.y; settings->monitors[n].width = screen_info[n].width; settings->monitors[n].height = xfi->workArea.height; } diff --git a/libfreerdp-rail/rail.c b/libfreerdp-rail/rail.c index d15a57e28..bfb34cffc 100644 --- a/libfreerdp-rail/rail.c +++ b/libfreerdp-rail/rail.c @@ -82,6 +82,27 @@ static void rail_WindowCachedIcon(rdpUpdate* update, WINDOW_ORDER_INFO* orderInf printf("rail_WindowCachedIcon\n"); } +static void rail_NotifyIconCreate(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notify_icon_state) +{ + rdpRail* rail; + rail = (rdpRail*) update->rail; + printf("NotifyIconCreate\n"); +} + +static void rail_NotifyIconUpdate(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notify_icon_state) +{ + rdpRail* rail; + rail = (rdpRail*) update->rail; + printf("NotifyIconUpdate\n"); +} + +static void rail_NotifyIconDelete(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo) +{ + rdpRail* rail; + rail = (rdpRail*) update->rail; + printf("NotifyIconDelete\n"); +} + void rail_register_update_callbacks(rdpRail* rail, rdpUpdate* update) { update->WindowCreate = rail_WindowCreate; @@ -89,6 +110,9 @@ void rail_register_update_callbacks(rdpRail* rail, rdpUpdate* update) update->WindowDelete = rail_WindowDelete; update->WindowIcon = rail_WindowIcon; update->WindowCachedIcon = rail_WindowCachedIcon; + update->NotifyIconCreate = rail_NotifyIconCreate; + update->NotifyIconUpdate = rail_NotifyIconUpdate; + update->NotifyIconDelete = rail_NotifyIconDelete; } rdpRail* rail_new(rdpSettings* settings)