From 6354a7561c4a44a61f5370b93b0bc256fadfcf43 Mon Sep 17 00:00:00 2001 From: Norbert Federa Date: Tue, 14 Apr 2015 13:07:19 +0200 Subject: [PATCH] xfreerdp: rename xf_context's width height vars Since several contributers in the past repeatedly made the error to treat xfc->width and xfc->height as equal with the x11 window width and heigth I've renamed these variables to sessionWidth and sessionHeight. --- client/X11/xf_client.c | 54 ++++++++++++++++++++++++------------------------ client/X11/xf_event.c | 18 ++++++++-------- client/X11/xf_keyboard.c | 12 +++++------ client/X11/xf_window.c | 8 +++---- client/X11/xfreerdp.h | 4 ++-- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index dfc2a03..c2f2c88 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -128,14 +128,14 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h) return; } - if (xfc->width <= 0 || xfc->height <= 0) + if (xfc->sessionWidth <= 0 || xfc->sessionHeight <= 0) { WLog_ERR(TAG, "the window dimensions are invalid"); return; } - xScalingFactor = xfc->width / (double)xfc->scaledWidth; - yScalingFactor = xfc->height / (double)xfc->scaledHeight; + xScalingFactor = xfc->sessionWidth / (double)xfc->scaledWidth; + yScalingFactor = xfc->sessionHeight / (double)xfc->scaledHeight; XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, 0); @@ -195,8 +195,8 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h) BOOL xf_picture_transform_required(xfContext* xfc) { if (xfc->offset_x || xfc->offset_y || - xfc->scaledWidth != xfc->width || - xfc->scaledHeight != xfc->height) + xfc->scaledWidth != xfc->sessionWidth || + xfc->scaledHeight != xfc->sessionHeight) { return TRUE; } @@ -232,7 +232,7 @@ static void xf_desktop_resize(rdpContext* context) { BOOL same = (xfc->primary == xfc->drawing) ? TRUE : FALSE; XFreePixmap(xfc->display, xfc->primary); - xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, xfc->width, xfc->height, xfc->depth); + xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, xfc->sessionWidth, xfc->sessionHeight, xfc->depth); if (same) xfc->drawing = xfc->primary; } @@ -240,8 +240,8 @@ static void xf_desktop_resize(rdpContext* context) #ifdef WITH_XRENDER if (!xfc->settings->SmartSizing) { - xfc->scaledWidth = xfc->width; - xfc->scaledHeight = xfc->height; + xfc->scaledWidth = xfc->sessionWidth; + xfc->scaledHeight = xfc->sessionHeight; } #endif @@ -343,10 +343,10 @@ void xf_sw_desktop_resize(rdpContext* context) xf_lock_x11(xfc, TRUE); - xfc->width = context->settings->DesktopWidth; - xfc->height = context->settings->DesktopHeight; + xfc->sessionWidth = context->settings->DesktopWidth; + xfc->sessionHeight = context->settings->DesktopHeight; - gdi_resize(gdi, xfc->width, xfc->height); + gdi_resize(gdi, xfc->sessionWidth, xfc->sessionHeight); if (xfc->image) { @@ -447,8 +447,8 @@ void xf_hw_desktop_resize(rdpContext* context) xf_lock_x11(xfc, TRUE); - xfc->width = settings->DesktopWidth; - xfc->height = settings->DesktopHeight; + xfc->sessionWidth = settings->DesktopWidth; + xfc->sessionHeight = settings->DesktopHeight; xf_desktop_resize(context); @@ -505,8 +505,8 @@ BOOL xf_create_window(xfContext* xfc) xf_detect_monitors(xfc); - width = xfc->width; - height = xfc->height; + width = xfc->sessionWidth; + height = xfc->sessionHeight; if (!xfc->hdc) xfc->hdc = gdi_CreateDC(CLRBUF_32BPP, xfc->bpp); @@ -581,7 +581,7 @@ BOOL xf_create_window(xfContext* xfc) xfc->unobscured = (xevent.xvisibility.state == VisibilityUnobscured); /* Disallow resize now that any initial fullscreen window operation is complete */ - xf_SetWindowSizeHints(xfc, xfc->window, FALSE, xfc->width, xfc->height); + xf_SetWindowSizeHints(xfc, xfc->window, FALSE, xfc->sessionWidth, xfc->sessionHeight); XSetWMProtocols(xfc->display, xfc->window->handle, &(xfc->WM_DELETE_WINDOW), 1); xfc->drawable = xfc->window->handle; @@ -600,7 +600,7 @@ BOOL xf_create_window(xfContext* xfc) assert(!xfc->gc); xfc->gc = XCreateGC(xfc->display, xfc->drawable, GCGraphicsExposures, &gcv); assert(!xfc->primary); - xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, xfc->width, xfc->height, xfc->depth); + xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, xfc->sessionWidth, xfc->sessionHeight, xfc->depth); xfc->drawing = xfc->primary; assert(!xfc->bitmap_mono); xfc->bitmap_mono = XCreatePixmap(xfc->display, xfc->drawable, 8, 8, 1); @@ -609,12 +609,12 @@ BOOL xf_create_window(xfContext* xfc) XSetFunction(xfc->display, xfc->gc, GXcopy); XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, BlackPixelOfScreen(xfc->screen)); - XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, xfc->width, xfc->height); + XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, xfc->sessionWidth, xfc->sessionHeight); XFlush(xfc->display); assert(!xfc->image); xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, - (char*) xfc->primary_buffer, xfc->width, xfc->height, xfc->scanline_pad, 0); + (char*) xfc->primary_buffer, xfc->sessionWidth, xfc->sessionHeight, xfc->scanline_pad, 0); return TRUE; } @@ -693,9 +693,9 @@ void xf_toggle_fullscreen(xfContext* xfc) xfc->fullscreen = (xfc->fullscreen) ? FALSE : TRUE; xfc->decorations = (xfc->fullscreen) ? FALSE : settings->Decorations; - xf_SetWindowSizeHints(xfc, xfc->window, TRUE, xfc->width, xfc->height); + xf_SetWindowSizeHints(xfc, xfc->window, TRUE, xfc->sessionWidth, xfc->sessionHeight); xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen); - xf_SetWindowSizeHints(xfc, xfc->window, FALSE, xfc->width, xfc->height); + xf_SetWindowSizeHints(xfc, xfc->window, FALSE, xfc->sessionWidth, xfc->sessionHeight); EventArgsInit(&e, "xfreerdp"); e.state = xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0; @@ -1074,12 +1074,12 @@ BOOL xf_post_connect(freerdp* instance) xf_gdi_register_update_callbacks(update); } - xfc->width = settings->DesktopWidth; - xfc->height = settings->DesktopHeight; + xfc->sessionWidth = settings->DesktopWidth; + xfc->sessionHeight = settings->DesktopHeight; #ifdef WITH_XRENDER - xfc->scaledWidth = xfc->width; - xfc->scaledHeight = xfc->height; + xfc->scaledWidth = xfc->sessionWidth; + xfc->scaledHeight = xfc->sessionHeight; xfc->offset_x = 0; xfc->offset_y = 0; #endif @@ -1557,7 +1557,7 @@ static void xf_ZoomingChangeEventHandler(rdpContext* context, ZoomingChangeEvent xfc->scaledWidth = w; xfc->scaledHeight = h; - xf_draw_screen(xfc, 0, 0, xfc->width, xfc->height); + xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight); } static void xf_PanningChangeEventHandler(rdpContext* context, PanningChangeEventArgs* e) @@ -1570,7 +1570,7 @@ static void xf_PanningChangeEventHandler(rdpContext* context, PanningChangeEvent xfc->offset_x += e->dx; xfc->offset_y += e->dy; - xf_draw_screen(xfc, 0, 0, xfc->width, xfc->height); + xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight); } #endif diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 742ddc7..448cac2 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -185,8 +185,8 @@ void xf_event_adjust_coordinates(xfContext* xfc, int* x, int *y) #ifdef WITH_XRENDER if (xf_picture_transform_required(xfc)) { - double xScalingFactor = xfc->width / (double)xfc->scaledWidth; - double yScalingFactor = xfc->height / (double)xfc->scaledHeight; + double xScalingFactor = xfc->sessionWidth / (double)xfc->scaledWidth; + double yScalingFactor = xfc->sessionHeight / (double)xfc->scaledHeight; *x = (int)((*x - xfc->offset_x) * xScalingFactor); *y = (int)((*y - xfc->offset_y) * yScalingFactor); } @@ -204,8 +204,8 @@ static BOOL xf_event_Expose(xfContext* xfc, XEvent* event, BOOL app) { x = 0; y = 0; - w = xfc->width; - h = xfc->height; + w = xfc->sessionWidth; + h = xfc->sessionHeight; } else { @@ -657,12 +657,12 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app) xfc->scaledWidth = xfc->window->width; xfc->scaledHeight = xfc->window->height; } - xf_draw_screen(xfc, 0, 0, xfc->width, xfc->height); + xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight); } else { - xfc->scaledWidth = xfc->width; - xfc->scaledHeight = xfc->height; + xfc->scaledWidth = xfc->sessionWidth; + xfc->scaledHeight = xfc->sessionHeight; } #endif } @@ -718,8 +718,8 @@ static BOOL xf_event_MapNotify(xfContext* xfc, XEvent* event, BOOL app) { rect.left = 0; rect.top = 0; - rect.right = xfc->width; - rect.bottom = xfc->height; + rect.right = xfc->sessionWidth; + rect.bottom = xfc->sessionHeight; update->SuppressOutput((rdpContext*) xfc, 1, &rect); } diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index f9eed58..38b319f 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -490,16 +490,16 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym) switch(keysym) { case XK_0: /* Ctrl-Alt-0: Reset scaling and panning */ - xfc->scaledWidth = xfc->width; - xfc->scaledHeight = xfc->height; + xfc->scaledWidth = xfc->sessionWidth; + xfc->scaledHeight = xfc->sessionHeight; xfc->offset_x = 0; xfc->offset_y = 0; - if (!xfc->fullscreen && (xfc->width != xfc->window->width || - xfc->height != xfc->window->height)) + if (!xfc->fullscreen && (xfc->sessionWidth != xfc->window->width || + xfc->sessionHeight != xfc->window->height)) { - xf_ResizeDesktopWindow(xfc, xfc->window, xfc->width, xfc->height); + xf_ResizeDesktopWindow(xfc, xfc->window, xfc->sessionWidth, xfc->sessionHeight); } - xf_draw_screen(xfc, 0, 0, xfc->width, xfc->height); + xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight); return TRUE; case XK_1: /* Ctrl-Alt-1: Zoom in */ diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index e89b944..fb9b269 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -189,7 +189,7 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) 1); } - window->fullscreen = TRUE; + window->fullscreen = fullscreen; } /* http://tronche.com/gui/x/xlib/window-information/XGetWindowProperty.html */ @@ -399,7 +399,7 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig * changes can work in window managers that might disallow otherwise. * We will set back afterwards. */ - xf_SetWindowSizeHints(xfc, window, TRUE, xfc->width, xfc->height); + xf_SetWindowSizeHints(xfc, window, TRUE, xfc->sessionWidth, xfc->sessionHeight); input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | @@ -482,8 +482,8 @@ void xf_SetWindowSizeHints(xfContext* xfc, xfWindow *window, BOOL can_resize, in if (can_resize) { size_hints->width_inc = size_hints->height_inc = 1; - size_hints->max_width = xfc->width + 1; - size_hints->max_height = xfc->height + 1; + size_hints->max_width = xfc->sessionWidth + 1; + size_hints->max_height = xfc->sessionHeight + 1; } XSetWMNormalHints(xfc->display, window->handle, size_hints); diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 50397de..e5a571c 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -92,8 +92,8 @@ struct xf_context int bpp; int xfds; int depth; - int width; - int height; + int sessionWidth; + int sessionHeight; int srcBpp; GC gc_mono; BOOL invert; -- 2.7.4