From 856ef50f992efb2b5c0ff87051b84fb26883b04b Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Fri, 3 May 2013 19:04:47 -0400 Subject: [PATCH] xfreerdp-client: window resize + scaling --- client/X11/xf_event.c | 21 ++++++++++++++++++++ client/X11/xf_interface.c | 41 ++++++++++++++++----------------------- client/X11/xf_interface.h | 4 ++++ 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index ae1dbdf02..c15eda875 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -524,6 +524,24 @@ static BOOL xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, BOOL app) rdpWindow* window; rdpRail* rail = ((rdpContext*) xfi->context)->rail; + { + double scale; + + + if(xfi->width != event->xconfigure.width) + { + printf("resize detected: x: %dx%d xfi:%dx%d orig: %dx%d\n", + event->xconfigure.width, event->xconfigure.height, + xfi->width, xfi->height, + xfi->orig_width, xfi->orig_height); + + scale = (double)event->xconfigure.width / (double) xfi->orig_width; + + printf("\tscale:%.2f\n", scale); + xfi->scale = scale; + } + } + window = window_list_get_by_extra_id(rail->list, (void*) event->xconfigure.window); if (window != NULL) @@ -541,6 +559,9 @@ static BOOL xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, BOOL app) RootWindowOfScreen(xfi->screen), 0, 0, &xfw->left, &xfw->top, &childWindow); + + + xfw->width = event->xconfigure.width; xfw->height = event->xconfigure.height; xfw->right = xfw->left + xfw->width - 1; diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 4764e4f46..ce0a214dd 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -159,6 +159,11 @@ double percent_to_scale(double p) } */ +void xf_set_scale(double scale) +{ + +} + void xf_context_new(freerdp* instance, rdpContext* context) { context->channels = freerdp_channels_new(); @@ -255,41 +260,19 @@ void xf_sw_end_paint(rdpContext* context) //scale { - int w2, h2; - int x2, y2; - double percent; - double scale; XTransform transform; - percent = 0.5; - - scale = percent_to_scale(percent); - - w2 = (int)(w * percent); - h2 = (int)(h * percent); - - x2 = (int)(x * percent); - y2 = (int)(y * percent); - - if(w2 == 0) - w2++; - if(h2 == 0) - h2++; - - - - transform.matrix[0][0] = XDoubleToFixed(1); transform.matrix[0][1] = XDoubleToFixed(0); transform.matrix[0][2] = XDoubleToFixed(0); transform.matrix[1][0] = XDoubleToFixed(0); transform.matrix[1][1] = XDoubleToFixed(1); - transform.matrix[1][2] = XDoubleToFixed(1); + transform.matrix[1][2] = XDoubleToFixed(0); transform.matrix[2][0] = XDoubleToFixed(0); transform.matrix[2][1] = XDoubleToFixed(0); - transform.matrix[2][2] = XDoubleToFixed(0.5); + transform.matrix[2][2] = XDoubleToFixed(xfi->scale); @@ -691,6 +674,16 @@ void xf_create_window(xfInfo* xfi) XSetWMProtocols(xfi->display, xfi->window->handle, &(xfi->WM_DELETE_WINDOW), 1); xfi->drawable = xfi->window->handle; + + + xfi->scale = 1.0; + xfi->orig_width = xfi->width; + xfi->orig_height = xfi->height; + //allow resizing from half to double + xf_SetWindowMinMaxInfo(xfi, xfi->window, + 0, 0, 0, 0, //these aren't used + xfi->width * 0.5, xfi->height * 0.5, xfi->width * 2, xfi->height * 2); + } else { diff --git a/client/X11/xf_interface.h b/client/X11/xf_interface.h index d287f39b3..eebb88379 100644 --- a/client/X11/xf_interface.h +++ b/client/X11/xf_interface.h @@ -126,6 +126,10 @@ struct xf_info BOOL UseXThreads; int XInputOpcode; + int orig_width; + int orig_height; + + double scale; HGDI_DC hdc; BYTE* primary_buffer;