mirror of https://github.com/FreeRDP/FreeRDP
xfreerdp-client: key combo for zoom in/out
This commit is contained in:
parent
05bd5e9907
commit
8af52e61df
|
@ -94,9 +94,18 @@ static BOOL xf_event_Expose(xfInfo* xfi, XEvent* event, BOOL app)
|
|||
w = event->xexpose.width;
|
||||
h = event->xexpose.height;
|
||||
|
||||
|
||||
if (!app)
|
||||
{
|
||||
XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y);
|
||||
|
||||
if(xfi->scale != 1.0)
|
||||
{
|
||||
xf_draw_screen_scaled(xfi);
|
||||
}
|
||||
else
|
||||
{
|
||||
XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -112,6 +112,37 @@ double percent_to_scale(double p)
|
|||
return s;
|
||||
}
|
||||
|
||||
void xf_draw_screen_scaled(xfInfo* xfi)
|
||||
{
|
||||
|
||||
Picture pic_prim;
|
||||
Picture pic_win;
|
||||
XRenderPictureAttributes pa;
|
||||
XRenderPictFormat* picFormat;
|
||||
XTransform transform;
|
||||
|
||||
picFormat = XRenderFindStandardFormat(xfi->display, PictStandardRGB24);
|
||||
pa.subwindow_mode = IncludeInferiors;//wtf is this?
|
||||
pic_prim = XRenderCreatePicture(xfi->display, xfi->primary, picFormat, CPSubwindowMode, &pa);
|
||||
pic_win = XRenderCreatePicture(xfi->display, xfi->window->handle, picFormat, CPSubwindowMode, &pa);
|
||||
|
||||
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(0);
|
||||
|
||||
transform.matrix[2][0] = XDoubleToFixed(0);
|
||||
transform.matrix[2][1] = XDoubleToFixed(0);
|
||||
transform.matrix[2][2] = XDoubleToFixed(xfi->scale);
|
||||
|
||||
XRenderSetPictureTransform(xfi->display, pic_prim, &transform);
|
||||
XRenderComposite(xfi->display, PictOpSrc, pic_prim, 0, pic_win, 0, 0, 0, 0, 0, 0, xfi->cur_width, xfi->cur_height);
|
||||
|
||||
}
|
||||
|
||||
//void * scaledBuf;
|
||||
//XImage* scaled_image;
|
||||
//Pixmap scaled_pixmap;
|
||||
|
@ -237,69 +268,15 @@ void xf_sw_end_paint(rdpContext* context)
|
|||
|
||||
//combine xfi->primary with xfi->image
|
||||
XPutImage(xfi->display, xfi->primary, xfi->gc, xfi->image, x, y, x, y, w, h);
|
||||
//XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y);
|
||||
|
||||
|
||||
if(1)//(rtest < 1)
|
||||
if(xfi->scale != 1.0)
|
||||
{
|
||||
Picture pic_prim;
|
||||
Picture pic_win;
|
||||
XRenderPictureAttributes pa;
|
||||
XRenderPictFormat* picFormat;
|
||||
|
||||
|
||||
picFormat = XRenderFindStandardFormat(xfi->display, PictStandardRGB24);
|
||||
pa.subwindow_mode = IncludeInferiors;//wtf is this?
|
||||
pic_prim = XRenderCreatePicture(xfi->display, xfi->primary, picFormat, CPSubwindowMode, &pa);
|
||||
pic_win = XRenderCreatePicture(xfi->display, xfi->window->handle, picFormat, CPSubwindowMode, &pa);
|
||||
|
||||
|
||||
//normal
|
||||
//XRenderComposite(xfi->display, PictOpSrc, pic_prim, pic_prim, pic_win, x, y, x, y, x, y, w, h);
|
||||
|
||||
|
||||
//scale
|
||||
{
|
||||
XTransform transform;
|
||||
|
||||
if(xfi->scale == 0 || xfi->cur_width == 0 || xfi->cur_height == 0)
|
||||
{
|
||||
printf("w: %d h: %d s: %.2f\n", xfi->cur_width, xfi->cur_height, xfi->scale);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
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(0);
|
||||
|
||||
transform.matrix[2][0] = XDoubleToFixed(0);
|
||||
transform.matrix[2][1] = XDoubleToFixed(0);
|
||||
transform.matrix[2][2] = XDoubleToFixed(xfi->scale);
|
||||
|
||||
|
||||
|
||||
XRenderSetPictureTransform(xfi->display, pic_prim, &transform);
|
||||
|
||||
//XRenderComposite(xfi->display, PictOpSrc, pic_prim, 0, pic_win, x, y, x, y, x, y, w, h);
|
||||
XRenderComposite(xfi->display, PictOpSrc, pic_prim, 0, pic_win, 0, 0, 0, 0, 0, 0, xfi->cur_width, xfi->cur_height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
rtest++;
|
||||
xf_draw_screen_scaled(xfi);
|
||||
}
|
||||
else
|
||||
{
|
||||
XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -184,6 +184,8 @@ struct xf_info
|
|||
Atom WM_DELETE_WINDOW;
|
||||
};
|
||||
|
||||
void xf_draw_screen_scaled(xfInfo* xfi);
|
||||
|
||||
void xf_create_window(xfInfo* xfi);
|
||||
void xf_toggle_fullscreen(xfInfo* xfi);
|
||||
BOOL xf_post_connect(freerdp* instance);
|
||||
|
|
|
@ -215,6 +215,45 @@ BOOL xf_kbd_handle_special_keys(xfInfo* xfi, KeySym keysym)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (keysym == XK_period)
|
||||
{
|
||||
if ((xf_kbd_key_pressed(xfi, XK_Alt_L) || xf_kbd_key_pressed(xfi, XK_Alt_R))
|
||||
&& (xf_kbd_key_pressed(xfi, XK_Control_L) || xf_kbd_key_pressed(xfi, XK_Control_R)))
|
||||
{
|
||||
//Zoom in (scale larger)
|
||||
double s = xfi->scale;
|
||||
s += 0.1;
|
||||
if(s > 1.5)
|
||||
s = 1.5;
|
||||
|
||||
xfi->scale = s;
|
||||
|
||||
XResizeWindow(xfi->display, xfi->window->handle, xfi->orig_width * s, xfi->orig_height * s);
|
||||
xf_draw_screen_scaled(xfi);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (keysym == XK_comma)
|
||||
{
|
||||
if ((xf_kbd_key_pressed(xfi, XK_Alt_L) || xf_kbd_key_pressed(xfi, XK_Alt_R))
|
||||
&& (xf_kbd_key_pressed(xfi, XK_Control_L) || xf_kbd_key_pressed(xfi, XK_Control_R)))
|
||||
{
|
||||
//Zoom out (scale smaller)
|
||||
double s = xfi->scale;
|
||||
s -= 0.1;
|
||||
if(s < 0.5)
|
||||
s = 0.5;
|
||||
|
||||
xfi->scale = s;
|
||||
|
||||
XResizeWindow(xfi->display, xfi->window->handle, xfi->orig_width * s, xfi->orig_height * s);
|
||||
xf_draw_screen_scaled(xfi);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue