Esempio n. 1
0
void xf_keyboard_focus_in(xfContext* xfc)
{
	rdpInput* input;
	UINT32 syncFlags, state;
	Window w;
	int d, x, y;

	if (!xfc->display || !xfc->window)
		return;

	input = xfc->instance->input;
	syncFlags = xf_keyboard_get_toggle_keys_state(xfc);

	input->FocusInEvent(input, syncFlags);

	/* finish with a mouse pointer position like mstsc.exe if required */

	if (xfc->remote_app)
		return;

	if (XQueryPointer(xfc->display, xfc->window->handle, &w, &w, &d, &d, &x, &y, &state))
	{
		if (x >= 0 && x < xfc->window->width && y >= 0 && y < xfc->window->height)
		{
			xf_event_adjust_coordinates(xfc, &x, &y);
			input->MouseEvent(input, PTR_FLAGS_MOVE, x, y);
		}
	}
}
Esempio n. 2
0
BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state,
                             Window window, BOOL app)
{
	rdpInput* input;
	Window childWindow;
	input = xfc->context.input;

	if (!xfc->context.settings->MouseMotion)
	{
		if ((state & (Button1Mask | Button2Mask | Button3Mask)) == 0)
			return TRUE;
	}

	if (app)
	{
		/* make sure window exists */
		if (!xf_AppWindowFromX11Window(xfc, window))
			return TRUE;

		/* Translate to desktop coordinates */
		XTranslateCoordinates(xfc->display, window,
		                      RootWindowOfScreen(xfc->screen),
		                      x, y, &x, &y, &childWindow);
	}

	xf_event_adjust_coordinates(xfc, &x, &y);
	input->MouseEvent(input, PTR_FLAGS_MOVE, x, y);

	if (xfc->fullscreen && !app)
	{
		XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot,
		               CurrentTime);
	}

	return TRUE;
}
Esempio n. 3
0
BOOL xf_generic_ButtonRelease(xfContext* xfc, int x, int y, int button,
                              Window window, BOOL app)
{
	int flags;
	BOOL wheel;
	BOOL extended;
	rdpInput* input;
	Window childWindow;
	flags = 0;
	wheel = FALSE;
	extended = FALSE;
	input = xfc->context.input;

	switch (button)
	{
		case Button1:
		case Button2:
		case Button3:
			flags = xfc->button_map[button - BUTTON_BASE];
			break;

		case 6:
		case 8:
		case 97:
			extended = TRUE;
			flags = PTR_XFLAGS_BUTTON1;
			break;

		case 7:
		case 9:
		case 112:
			extended = TRUE;
			flags = PTR_XFLAGS_BUTTON2;
			break;

		default:
			flags = 0;
			break;
	}

	if (flags != 0)
	{
		if (app)
		{
			/* make sure window exists */
			if (!xf_AppWindowFromX11Window(xfc, window))
				return TRUE;

			/* Translate to desktop coordinates */
			XTranslateCoordinates(xfc->display, window,
			                      RootWindowOfScreen(xfc->screen),
			                      x, y, &x, &y, &childWindow);
		}

		xf_event_adjust_coordinates(xfc, &x, &y);

		if (extended)
			input->ExtendedMouseEvent(input, flags, x, y);
		else
			input->MouseEvent(input, flags, x, y);
	}

	return TRUE;
}
Esempio n. 4
0
BOOL xf_generic_ButtonPress(xfContext* xfc, int x, int y, int button,
                            Window window, BOOL app)
{
	int flags;
	BOOL wheel;
	BOOL extended;
	rdpInput* input;
	Window childWindow;
	flags = 0;
	wheel = FALSE;
	extended = FALSE;
	input = xfc->context.input;

	switch (button)
	{
		case Button1:
		case Button2:
		case Button3:
			flags = PTR_FLAGS_DOWN | xfc->button_map[button - BUTTON_BASE];
			break;

		case 4:
			wheel = TRUE;
			flags = PTR_FLAGS_WHEEL | 0x0078;
			break;

		case 5:
			wheel = TRUE;
			flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0078;
			break;

		case 8:		/* back */
		case 97:	/* Xming */
			extended = TRUE;
			flags = PTR_XFLAGS_DOWN | PTR_XFLAGS_BUTTON1;
			break;

		case 9:		/* forward */
		case 112:	/* Xming */
			extended = TRUE;
			flags = PTR_XFLAGS_DOWN | PTR_XFLAGS_BUTTON2;
			break;

		case 6:		/* wheel left */
			wheel = TRUE;
			flags = PTR_FLAGS_HWHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0078;
			break;

		case 7:		/* wheel right */
			wheel = TRUE;
			flags = PTR_FLAGS_HWHEEL | 0x0078;
			break;

		default:
			x = 0;
			y = 0;
			flags = 0;
			break;
	}

	if (flags != 0)
	{
		if (wheel)
		{
			input->MouseEvent(input, flags, 0, 0);
		}
		else
		{
			if (app)
			{
				/* make sure window exists */
				if (!xf_AppWindowFromX11Window(xfc, window))
					return TRUE;

				/* Translate to desktop coordinates */
				XTranslateCoordinates(xfc->display, window,
				                      RootWindowOfScreen(xfc->screen),
				                      x, y, &x, &y, &childWindow);
			}

			xf_event_adjust_coordinates(xfc, &x, &y);

			if (extended)
				input->ExtendedMouseEvent(input, flags, x, y);
			else
				input->MouseEvent(input, flags, x, y);
		}
	}

	return TRUE;
}