Esempio n. 1
0
xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, int height, uint32 id)
{
	xfWindow* window;

	window = (xfWindow*) xzalloc(sizeof(xfWindow));

	if ((width * height) < 1)
		return NULL;

	xf_FixWindowCoordinates(xfi, &x, &y, &width, &height);

	window->left = x;
	window->top = y;
	window->right = x + width - 1;
	window->bottom = y + height - 1;
	window->width = width;
	window->height = height;

	if (window != NULL)
	{
		XGCValues gcv;
		int input_mask;
		XClassHint* class_hints;

		window->decorations = False;
		window->fullscreen = False;
		window->window = wnd;
		window->localMoveSize = False;

		window->handle = XCreateWindow(xfi->display, RootWindowOfScreen(xfi->screen),
			x, y, window->width, window->height, 0, xfi->depth, InputOutput, xfi->visual,
			CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
			CWBorderPixel, &xfi->attribs);

		xf_SetWindowDecorations(xfi, window, window->decorations);

		class_hints = XAllocClassHint();

		if (class_hints != NULL)
		{
			char* class;
			class = xmalloc(sizeof(rail_window_class));
			snprintf(class, sizeof(rail_window_class), "RAIL:%08X", id);
			class_hints->res_name = "RAIL";
			class_hints->res_class = class;
			XSetClassHint(xfi->display, window->handle, class_hints);
			XFree(class_hints);
			xfree(class);
		}
Esempio n. 2
0
int xf_AppWindowInit(xfContext* xfc, xfAppWindow* appWindow)
{
	XGCValues gcv;
	int input_mask;
	XWMHints* InputModeHint;
	XClassHint* class_hints;
	xf_FixWindowCoordinates(xfc, &appWindow->x, &appWindow->y, &appWindow->width,
	                        &appWindow->height);
	appWindow->decorations = FALSE;
	appWindow->fullscreen = FALSE;
	appWindow->local_move.state = LMS_NOT_ACTIVE;
	appWindow->is_mapped = FALSE;
	appWindow->is_transient = FALSE;
	appWindow->rail_state = 0;
	appWindow->rail_ignore_configure = FALSE;
	appWindow->handle = XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen),
	                                  appWindow->x, appWindow->y, appWindow->width, appWindow->height,
	                                  0, xfc->depth, InputOutput, xfc->visual, 0, &xfc->attribs);

	if (!appWindow->handle)
		return -1;

	ZeroMemory(&gcv, sizeof(gcv));
	appWindow->gc = XCreateGC(xfc->display, appWindow->handle, GCGraphicsExposures,
	                          &gcv);
	class_hints = XAllocClassHint();

	if (class_hints)
	{
		char* class = NULL;

		if (xfc->context.settings->WmClass)
		{
			class_hints->res_class = xfc->context.settings->WmClass;
		}
		else
		{
			class = malloc(sizeof("RAIL:00000000"));
			sprintf_s(class, sizeof("RAIL:00000000"), "RAIL:%08"PRIX32"", appWindow->windowId);
			class_hints->res_class = class;
		}

		class_hints->res_name = "RAIL";
		XSetClassHint(xfc->display, appWindow->handle, class_hints);
		XFree(class_hints);
		free(class);
	}

	/* Set the input mode hint for the WM */
	InputModeHint = XAllocWMHints();
	InputModeHint->flags = (1L << 0);
	InputModeHint->input = True;
	XSetWMHints(xfc->display, appWindow->handle, InputModeHint);
	XFree(InputModeHint);
	XSetWMProtocols(xfc->display, appWindow->handle, &(xfc->WM_DELETE_WINDOW), 1);
	input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask |
	             ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
	             PointerMotionMask | Button1MotionMask | Button2MotionMask |
	             Button3MotionMask | Button4MotionMask | Button5MotionMask |
	             ButtonMotionMask | KeymapStateMask | ExposureMask |
	             VisibilityChangeMask | StructureNotifyMask | SubstructureNotifyMask |
	             SubstructureRedirectMask | FocusChangeMask | PropertyChangeMask |
	             ColormapChangeMask | OwnerGrabButtonMask;
	XSelectInput(xfc->display, appWindow->handle, input_mask);
	xf_SetWindowDecorations(xfc, appWindow->handle, appWindow->decorations);
	xf_SetWindowStyle(xfc, appWindow, appWindow->dwStyle, appWindow->dwExStyle);
	xf_SetWindowPID(xfc, appWindow->handle, 0);
	xf_ShowWindow(xfc, appWindow, WINDOW_SHOW);
	XClearWindow(xfc->display, appWindow->handle);
	XMapWindow(xfc->display, appWindow->handle);
	/* Move doesn't seem to work until window is mapped. */
	xf_MoveWindow(xfc, appWindow, appWindow->x, appWindow->y, appWindow->width,
	              appWindow->height);
	xf_SetWindowText(xfc, appWindow, appWindow->title);
	return 1;
}