Пример #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->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;
}
Пример #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->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;
}