diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index fa9861330..731c727b5 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -118,8 +118,8 @@ void xf_transform_window(xfContext* xfc) if(ret == 0) size_hints = XAllocSizeHints(); - w = (xfc->originalWidth * xfc->scale) + xfc->offset_x; - h = (xfc->originalHeight * xfc->scale) + xfc->offset_y; + w = (xfc->originalWidth * xfc->settings->ScalingFactor) + xfc->offset_x; + h = (xfc->originalHeight * xfc->settings->ScalingFactor) + xfc->offset_y; if(w < 1) w = 1; @@ -164,17 +164,17 @@ void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h, BOOL scal transform.matrix[2][0] = XDoubleToFixed(0); transform.matrix[2][1] = XDoubleToFixed(0); - transform.matrix[2][2] = XDoubleToFixed(xfc->scale); + transform.matrix[2][2] = XDoubleToFixed(xfc->settings->ScalingFactor); if( (w != 0) && (h != 0) ) { if(scale == TRUE) { - xr.x = x * xfc->scale; - xr.y = y * xfc->scale; - xr.width = (w+1) * xfc->scale; - xr.height = (h+1) * xfc->scale; + xr.x = x * xfc->settings->ScalingFactor; + xr.y = y * xfc->settings->ScalingFactor; + xr.width = (w+1) * xfc->settings->ScalingFactor; + xr.height = (h+1) * xfc->settings->ScalingFactor; } else { @@ -230,7 +230,7 @@ void xf_sw_end_paint(rdpContext* context) XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image, x, y, x, y, w, h); - if ( (xfc->scale != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) + if ( (xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) { xf_draw_screen_scaled(xfc, x, y, w, h, TRUE); } @@ -265,7 +265,7 @@ void xf_sw_end_paint(rdpContext* context) //combine xfc->primary with xfc->image XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image, x, y, x, y, w, h); - if ( (xfc->scale != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) + if ( (xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) { xf_draw_screen_scaled(xfc, x, y, w, h, TRUE); } @@ -352,7 +352,7 @@ void xf_hw_end_paint(rdpContext* context) xf_lock_x11(xfc, FALSE); - if ( (xfc->scale != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) + if ( (xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) { xf_draw_screen_scaled(xfc, x, y, w, h, TRUE); } @@ -384,7 +384,7 @@ void xf_hw_end_paint(rdpContext* context) w = cinvalid[i].w; h = cinvalid[i].h; - if ( (xfc->scale != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) + if ( (xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) { xf_draw_screen_scaled(xfc, x, y, w, h, TRUE); } @@ -913,7 +913,7 @@ BOOL xf_post_connect(freerdp* instance) xfc->originalHeight = settings->DesktopHeight; xfc->currentWidth = xfc->originalWidth; xfc->currentHeight = xfc->originalWidth; - xfc->scale = 1.0; + xfc->settings->ScalingFactor = 1.0; xfc->offset_x = 0; xfc->offset_y = 0; @@ -1618,6 +1618,8 @@ void xf_ParamChangeEventHandler(rdpContext* context, ParamChangeEventArgs* e) { case FreeRDP_ScalingFactor: + printf("scaling factor changed to: %.2f\n", xfc->settings->ScalingFactor); + xfc->currentWidth = xfc->originalWidth * xfc->settings->ScalingFactor; xfc->currentHeight = xfc->originalHeight * xfc->settings->ScalingFactor; @@ -1697,7 +1699,7 @@ int xfreerdp_client_stop(rdpContext* context) double freerdp_client_get_scale(rdpContext* context) { xfContext* xfc = (xfContext*) context; - return xfc->scale; + return xfc->settings->ScalingFactor; } @@ -1706,17 +1708,17 @@ void freerdp_client_set_scale(rdpContext* context, double newScale) ResizeWindowEventArgs e; xfContext* xfc = (xfContext*) context; - xfc->scale = newScale; + xfc->settings->ScalingFactor = newScale; - xfc->currentWidth = xfc->originalWidth * xfc->scale; - xfc->currentHeight = xfc->originalHeight * xfc->scale; + xfc->currentWidth = xfc->originalWidth * xfc->settings->ScalingFactor; + xfc->currentHeight = xfc->originalHeight * xfc->settings->ScalingFactor; xf_transform_window(xfc); - //IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); + //IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->settings->ScalingFactor, xfc->originalHeight * xfc->settings->ScalingFactor); EventArgsInit(&e, "xfreerdp"); - e.width = (int) xfc->originalWidth * xfc->scale; - e.height = (int) xfc->originalHeight * xfc->scale; + e.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor; + e.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor; PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &e); xf_draw_screen_scaled(xfc, 0, 0, 0, 0, FALSE); @@ -1736,19 +1738,19 @@ void freerdp_client_reset_scale(xfContext* xfc) { ResizeWindowEventArgs e; - xfc->scale = 1.0; + xfc->settings->ScalingFactor = 1.0; xfc->offset_x = 0; xfc->offset_y = 0; xfc->currentWidth = xfc->originalWidth; xfc->currentHeight = xfc->originalHeight; - XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); - //IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); + XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->settings->ScalingFactor, xfc->originalHeight * xfc->settings->ScalingFactor); + //IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->settings->ScalingFactor, xfc->originalHeight * xfc->settings->ScalingFactor); EventArgsInit(&e, "xfreerdp"); - e.width = (int) xfc->originalWidth * xfc->scale; - e.height = (int) xfc->originalHeight * xfc->scale; + e.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor; + e.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor; PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &e); xf_draw_screen_scaled(xfc, 0, 0, 0, 0, FALSE); diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index a32f2ba54..17b9eb73b 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -97,7 +97,7 @@ static BOOL xf_event_Expose(xfContext* xfc, XEvent* event, BOOL app) if (!app) { - if ((xfc->scale != 1.0) || (xfc->offset_x) || (xfc->offset_y)) + if ((xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y)) { xf_draw_screen_scaled(xfc, x - xfc->offset_x, y - xfc->offset_y, w, h, FALSE); @@ -160,10 +160,10 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window win } /* Take scaling in to consideration */ - if ( (xfc->scale != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) + if ( (xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) { - x = (int)((x - xfc->offset_x) * (1.0 / xfc->scale) ); - y = (int)((y - xfc->offset_y) * (1.0 / xfc->scale) ); + x = (int)((x - xfc->offset_x) * (1.0 / xfc->settings->ScalingFactor) ); + y = (int)((y - xfc->offset_y) * (1.0 / xfc->settings->ScalingFactor) ); } input->MouseEvent(input, PTR_FLAGS_MOVE, x, y); @@ -262,13 +262,13 @@ BOOL xf_generic_ButtonPress(xfContext* xfc, int x, int y, int button, Window win } - if ((xfc->scale != 1.0) || (xfc->offset_x) + if ((xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y)) { x = (int) ((x - xfc->offset_x) - * (1.0 / xfc->scale)); + * (1.0 / xfc->settings->ScalingFactor)); y = (int) ((y - xfc->offset_y) - * (1.0 / xfc->scale)); + * (1.0 / xfc->settings->ScalingFactor)); } if (extended) @@ -349,10 +349,10 @@ BOOL xf_generic_ButtonRelease(xfContext* xfc, int x, int y, int button, Window w } - if ((xfc->scale != 1.0) || (xfc->offset_x) || (xfc->offset_y)) + if ((xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y)) { - x = (int) ((x - xfc->offset_x) * (1.0 / xfc->scale)); - y = (int) ((y - xfc->offset_y) * (1.0 / xfc->scale)); + x = (int) ((x - xfc->offset_x) * (1.0 / xfc->settings->ScalingFactor)); + y = (int) ((y - xfc->offset_y) * (1.0 / xfc->settings->ScalingFactor)); } if (extended) @@ -552,7 +552,7 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app) if (xfc->width != event->xconfigure.width) { - xfc->scale = (double) event->xconfigure.width / (double) xfc->originalWidth; + xfc->settings->ScalingFactor = (double) event->xconfigure.width / (double) xfc->originalWidth; xfc->currentWidth = event->xconfigure.width; xfc->currentHeight = event->xconfigure.width; diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index ed498ac47..336e42546 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -443,10 +443,10 @@ void xf_input_detect_pinch(xfContext* xfc) if (z_vector > ZOOM_THRESHOLD) { - xfc->scale -= 0.05; + xfc->settings->ScalingFactor -= 0.05; - if (xfc->scale < 0.8) - xfc->scale = 0.8; + if (xfc->settings->ScalingFactor < 0.8) + xfc->settings->ScalingFactor = 0.8; /* xfi->currentWidth = xfi->originalWidth * xfi->scale; xfi->currentHeight = xfi->originalHeight * xfi->scale; @@ -456,12 +456,12 @@ void xf_input_detect_pinch(xfContext* xfc) xf_draw_screen_scaled(xfi, 0, 0, 0, 0, FALSE); */ - //XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); + //XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->settings->ScalingFactor, xfc->originalHeight * xfc->settings->ScalingFactor); EventArgsInit(&e, "xfreerdp"); - e.width = (int) xfc->originalWidth * xfc->scale; - e.height = (int) xfc->originalHeight * xfc->scale; + e.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor; + e.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor; xf_transform_window(xfc); PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &e); @@ -475,10 +475,10 @@ void xf_input_detect_pinch(xfContext* xfc) if (z_vector < -ZOOM_THRESHOLD) { - xfc->scale += 0.05; + xfc->settings->ScalingFactor += 0.05; - if (xfc->scale > 1.2) - xfc->scale = 1.2; + if (xfc->settings->ScalingFactor > 1.2) + xfc->settings->ScalingFactor = 1.2; /* xfi->currentWidth = xfi->originalWidth * xfi->scale; xfi->currentHeight = xfi->originalHeight * xfi->scale; @@ -488,12 +488,12 @@ void xf_input_detect_pinch(xfContext* xfc) xf_draw_screen_scaled(xfi, 0, 0, 0, 0, FALSE); */ - if (xfc->scale > 1.5) - xfc->scale = 1.5; + if (xfc->settings->ScalingFactor > 1.5) + xfc->settings->ScalingFactor = 1.5; EventArgsInit(&e, "xfreerdp"); - e.width = (int) xfc->originalWidth * xfc->scale; - e.height = (int) xfc->originalHeight * xfc->scale; + e.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor; + e.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor; xf_transform_window(xfc); PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &e); diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index 7ca912cdd..5bb127983 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -226,12 +226,12 @@ BOOL xf_kbd_handle_special_keys(xfContext* xfc, KeySym keysym) XK_Control_R))) { //Zoom in (scale larger) - double s = xfc->scale; + double s = xfc->settings->ScalingFactor; s += 0.1; if (s > 2.0) s = 2.0; - xfc->scale = s; + xfc->settings->ScalingFactor = s; xfc->currentWidth = xfc->originalWidth * s; xfc->currentHeight = xfc->originalHeight * s; @@ -243,8 +243,8 @@ BOOL xf_kbd_handle_special_keys(xfContext* xfc, KeySym keysym) ResizeWindowEventArgs e; EventArgsInit(&e, "xfreerdp"); - e.width = (int) xfc->originalWidth * xfc->scale; - e.height = (int) xfc->originalHeight * xfc->scale; + e.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor; + e.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor; PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &e); } xf_draw_screen_scaled(xfc, 0, 0, 0, 0, FALSE); @@ -261,12 +261,12 @@ BOOL xf_kbd_handle_special_keys(xfContext* xfc, KeySym keysym) XK_Control_R))) { //Zoom out (scale smaller) - double s = xfc->scale; + double s = xfc->settings->ScalingFactor; s -= 0.1; if (s < 0.5) s = 0.5; - xfc->scale = s; + xfc->settings->ScalingFactor = s; xfc->currentWidth = xfc->originalWidth * s; xfc->currentHeight = xfc->originalHeight * s; @@ -278,8 +278,8 @@ BOOL xf_kbd_handle_special_keys(xfContext* xfc, KeySym keysym) ResizeWindowEventArgs e; EventArgsInit(&e, "xfreerdp"); - e.width = (int) xfc->originalWidth * xfc->scale; - e.height = (int) xfc->originalHeight * xfc->scale; + e.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor; + e.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor; PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &e); } diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 78399b235..a7a3cd5ff 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -106,7 +106,7 @@ struct xf_context UINT16 frame_x2; UINT16 frame_y2; - double scale; + //double scale; int originalWidth; int originalHeight; int currentWidth; diff --git a/libfreerdp/common/settings.c b/libfreerdp/common/settings.c index e99066b15..7e12b1400 100644 --- a/libfreerdp/common/settings.c +++ b/libfreerdp/common/settings.c @@ -2319,7 +2319,8 @@ int freerdp_set_param_double(rdpSettings* settings, int id, double param) EventArgsInit(&e, "freerdp"); e.id = id; - PubSub_OnParamChange(context->pubSub, context->instance, &e); + //PubSub_OnParamChange(context->pubSub, context->instance, &e); + PubSub_OnParamChange(context->pubSub, context, &e); return 0; } diff --git a/winpr/libwinpr/utils/collections/PubSub.c b/winpr/libwinpr/utils/collections/PubSub.c index 160a0ddf0..1236d6858 100644 --- a/winpr/libwinpr/utils/collections/PubSub.c +++ b/winpr/libwinpr/utils/collections/PubSub.c @@ -167,6 +167,9 @@ int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, wEvent event = PubSub_FindEventType(pubSub, EventName); + if (pubSub->synchronized) + PubSub_Unlock(pubSub); + if (event) { status = 0; @@ -181,9 +184,6 @@ int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, wEvent } } - if (pubSub->synchronized) - PubSub_Unlock(pubSub); - return status; }