Example #1
0
BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym)
{
	XF_MODIFIER_KEYS mod = { 0 };

	xk_keyboard_get_modifier_keys(xfc, &mod);

	if (!xf_keyboard_execute_action_script(xfc, &mod, keysym))
	{
		return TRUE;
	}

	if(xfc->fullscreen_toggle)
	{
            if (keysym == XK_Return)
            {
                    if (mod.Ctrl && mod.Alt)
                    {
                            /* Ctrl-Alt-Enter: toggle full screen */
                            xf_toggle_fullscreen(xfc);
                            return TRUE;
                    }
            }
	}

	if ((keysym == XK_c) || (keysym == XK_C))
	{
		if (mod.Ctrl && mod.Alt)
		{
			/* Ctrl-Alt-C: toggle control */
			xf_toggle_control(xfc);
			return TRUE;
		}
	}

	if (keysym == XK_period)
	{
		if (mod.Ctrl && mod.Alt)
		{
			/* Zoom In (scale larger) */

			double s = xfc->settings->ScalingFactor;

			s += 0.1;

			if (s > 2.0)
				s = 2.0;
			
			xfc->settings->ScalingFactor = s;
			
			xfc->currentWidth = xfc->originalWidth * s;
			xfc->currentHeight = xfc->originalHeight * s;
			
			xf_transform_window(xfc);
			
			{
				ResizeWindowEventArgs e;
				
				EventArgsInit(&e, "xfreerdp");
				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);
			return TRUE;
		}
	}
	
	if (keysym == XK_comma)
	{
		if (mod.Ctrl && mod.Alt)
		{
			/* Zoom Out (scale smaller) */

			double s = xfc->settings->ScalingFactor;

			s -= 0.1;

			if (s < 0.5)
				s = 0.5;
			
			xfc->settings->ScalingFactor = s;
			
			xfc->currentWidth = xfc->originalWidth * s;
			xfc->currentHeight = xfc->originalHeight * s;
			
			xf_transform_window(xfc);
			
			{
				ResizeWindowEventArgs e;
				
				EventArgsInit(&e, "xfreerdp");
				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);
			return TRUE;
		}
	}
	
	if (keysym == XK_KP_4)
	{
		if (mod.Ctrl && mod.Alt)
		{
			
			{
				PanningChangeEventArgs e;
				
				EventArgsInit(&e, "xfreerdp");
				e.XPan = -5;
				e.YPan = 0;
				PubSub_OnPanningChange(((rdpContext*) xfc)->pubSub, xfc, &e);
			}
			
			return TRUE;
		}
	}
	
	if (keysym == XK_KP_6)
	{
		if (mod.Ctrl && mod.Alt)
		{
			
			{
				PanningChangeEventArgs e;
				
				EventArgsInit(&e, "xfreerdp");
				e.XPan = 5;
				e.YPan = 0;
				PubSub_OnPanningChange(((rdpContext*) xfc)->pubSub, xfc, &e);
			}
			return TRUE;
		}
	}
	
	if (keysym == XK_KP_8)
	{
		if (mod.Ctrl && mod.Alt)
		{
			{
				PanningChangeEventArgs e;
				
				EventArgsInit(&e, "xfreerdp");
				e.XPan = 0;
				e.YPan = -5;
				PubSub_OnPanningChange(((rdpContext*) xfc)->pubSub, xfc, &e);
			}
			return TRUE;
		}
	}
	
	if (keysym == XK_KP_2)
	{
		if (mod.Ctrl && mod.Alt)
		{
			{
				PanningChangeEventArgs e;
				
				EventArgsInit(&e, "xfreerdp");
				e.XPan = 0;
				e.YPan = 5;
				PubSub_OnPanningChange(((rdpContext*) xfc)->pubSub, xfc, &e);
			}
			return TRUE;
		}
	}
	
	return FALSE;
}
Example #2
0
BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym)
{
	XF_MODIFIER_KEYS mod = { 0 };

	xk_keyboard_get_modifier_keys(xfc, &mod);

	if (!xf_keyboard_execute_action_script(xfc, &mod, keysym))
	{
		return TRUE;
	}

	if(!xfc->remote_app && xfc->fullscreen_toggle)
	{
		if (keysym == XK_Return)
		{
			WLog_DBG(TAG,  "X keycode 0x%x, Ctrl: %d, Alt: %d", keysym, mod.Ctrl, mod.Alt);
			if (mod.Ctrl && mod.Alt)
			{
				/* Ctrl-Alt-Enter: toggle full screen */
				xf_toggle_fullscreen(xfc);
				return TRUE;
			}
		}
	}

	if (!xfc->remote_app)
	{
		if ((keysym == XK_Tab) || (keysym == XK_Left) || (keysym == XK_Right))
		{
			WLog_DBG(TAG,  "X keycode 0x%x, Ctrl: %d, Alt: %d", keysym, mod.Ctrl, mod.Alt);
			if (mod.Ctrl && mod.Alt)
			{
				/* Works in either full screen or windowed.
				 * If in fullscreen or cursor inside window - need to do
				 * "double" ctrl-alt-* key press and release...
				 * 1st ctrl-alt-[tab-left-right] releases from x11 key binding
				 * 2nd ctrl-alt-[tab-left-right] executes OS system key binding
				 * Note: If windowed and cursor is not in freerdp window, ie.,
				 * on tile bar, this doesnt apply and ctrl-alt-[tab-left-right]
				 * key press will work as OS system key binding.
				 */
				XUngrabKeyboard(xfc->display, CurrentTime);
				return TRUE;
			}
		}
	}

	if ((keysym == XK_c) || (keysym == XK_C))
	{
		if (mod.Ctrl && mod.Alt)
		{
			/* Ctrl-Alt-C: toggle control */
			xf_toggle_control(xfc);
			return TRUE;
		}
	}

#if 0 /* set to 1 to enable multi touch gesture simulation via keyboard */
#ifdef WITH_XRENDER
	if (!xfc->remote_app && xfc->settings->MultiTouchGestures)
	{
		if (mod.Ctrl && mod.Alt)
		{
			int pdx = 0;
			int pdy = 0;
			int zdx = 0;
			int zdy = 0;

			switch(keysym)
			{
				case XK_0:	/* Ctrl-Alt-0: Reset scaling and panning */
					xfc->scaledWidth = xfc->sessionWidth;
					xfc->scaledHeight = xfc->sessionHeight;
					xfc->offset_x = 0;
					xfc->offset_y = 0;
					if (!xfc->fullscreen && (xfc->sessionWidth != xfc->window->width ||
						 xfc->sessionHeight != xfc->window->height))
					{
						xf_ResizeDesktopWindow(xfc, xfc->window, xfc->sessionWidth, xfc->sessionHeight);
					}
					xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight);
					return TRUE;

				case XK_1:	/* Ctrl-Alt-1: Zoom in */
					zdx = zdy = 10;
					break;

				case XK_2:	/* Ctrl-Alt-2: Zoom out */
					zdx = zdy = -10;
					break;

				case XK_3:	/* Ctrl-Alt-3: Pan left */
					pdx = -10;
					break;

				case XK_4:	/* Ctrl-Alt-4: Pan right */
					pdx = 10;
					break;

				case XK_5:	/* Ctrl-Alt-5: Pan up */
					pdy = -10;
					break;

				case XK_6:	/* Ctrl-Alt-6: Pan up */
					pdy = 10;
					break;
			}

			if (pdx != 0 || pdy != 0)
			{
				PanningChangeEventArgs e;
				EventArgsInit(&e, "xfreerdp");
				e.dx = pdx;
				e.dy = pdy;
				PubSub_OnPanningChange(((rdpContext*) xfc)->pubSub, xfc, &e);
				return TRUE;
			}

			if (zdx != 0 || zdy != 0)
			{
				ZoomingChangeEventArgs e;
				EventArgsInit(&e, "xfreerdp");
				e.dx = zdx;
				e.dy = zdy;
				PubSub_OnZoomingChange(((rdpContext*) xfc)->pubSub, xfc, &e);
				return TRUE;
			}
		}
	}
#endif /* WITH_XRENDER defined */
#endif /* pinch/zoom/pan simulation */
	return FALSE;
}
Example #3
0
BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym)
{
	XF_MODIFIER_KEYS mod = { 0 };

	xk_keyboard_get_modifier_keys(xfc, &mod);

	if (!xf_keyboard_execute_action_script(xfc, &mod, keysym))
	{
		return TRUE;
	}

	if(xfc->fullscreen_toggle)
	{
		if (keysym == XK_Return)
		{
			if (mod.Ctrl && mod.Alt)
			{
				/* Ctrl-Alt-Enter: toggle full screen */
				xf_toggle_fullscreen(xfc);
				return TRUE;
			}
		}
	}

	if ((keysym == XK_c) || (keysym == XK_C))
	{
		if (mod.Ctrl && mod.Alt)
		{
			/* Ctrl-Alt-C: toggle control */
			xf_toggle_control(xfc);
			return TRUE;
		}
	}

#if 0 /* set to 1 to enable multi touch gesture simulation via keyboard */
#ifdef WITH_XRENDER
	if (!xfc->remote_app && xfc->settings->MultiTouchGestures)
	{
		if (mod.Ctrl && mod.Alt)
		{
			int pdx = 0;
			int pdy = 0;
			int zdx = 0;
			int zdy = 0;

			switch(keysym)
			{
				case XK_0:	/* Ctrl-Alt-0: Reset scaling and panning */
					xfc->scaledWidth = xfc->sessionWidth;
					xfc->scaledHeight = xfc->sessionHeight;
					xfc->offset_x = 0;
					xfc->offset_y = 0;
					if (!xfc->fullscreen && (xfc->sessionWidth != xfc->window->width ||
						 xfc->sessionHeight != xfc->window->height))
					{
						xf_ResizeDesktopWindow(xfc, xfc->window, xfc->sessionWidth, xfc->sessionHeight);
					}
					xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight);
					return TRUE;

				case XK_1:	/* Ctrl-Alt-1: Zoom in */
					zdx = zdy = 10;
					break;

				case XK_2:	/* Ctrl-Alt-2: Zoom out */
					zdx = zdy = -10;
					break;

				case XK_3:	/* Ctrl-Alt-3: Pan left */
					pdx = -10;
					break;

				case XK_4:	/* Ctrl-Alt-4: Pan right */
					pdx = 10;
					break;

				case XK_5:	/* Ctrl-Alt-5: Pan up */
					pdy = -10;
					break;

				case XK_6:	/* Ctrl-Alt-6: Pan up */
					pdy = 10;
					break;
			}

			if (pdx != 0 || pdy != 0)
			{
				PanningChangeEventArgs e;
				EventArgsInit(&e, "xfreerdp");
				e.dx = pdx;
				e.dy = pdy;
				PubSub_OnPanningChange(((rdpContext*) xfc)->pubSub, xfc, &e);
				return TRUE;
			}

			if (zdx != 0 || zdy != 0)
			{
				ZoomingChangeEventArgs e;
				EventArgsInit(&e, "xfreerdp");
				e.dx = zdx;
				e.dy = zdy;
				PubSub_OnZoomingChange(((rdpContext*) xfc)->pubSub, xfc, &e);
				return TRUE;
			}
		}
	}
#endif /* WITH_XRENDER defined */
#endif /* pinch/zoom/pan simulation */
	return FALSE;
}