#ifndef NO_MULTIMON
#include <X11/extensions/Xinerama.h>
#endif
-#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
#include "vmware.h"
#include "debug.h"
Bool canUseVMwareCtrlTopologySet;
// TRUE if VMwareCtrl extension supports topology set
Bool canUseRandR12; // TRUE if RandR extension >= 1.2 available
+
+ Bool canUseResolutionKMS; // TRUE if backing off for resolutionKMS
} ResolutionInfoX11Type;
static Bool ResolutionCanSet(void);
static Bool TopologyCanSet(void);
static Bool SelectResolution(uint32 width, uint32 height);
+static int ResolutionX11ErrorHandler(Display *d, XErrorEvent *e);
/*
* X11 back-end initializer. Records caller's X11 display, then determines
* which capabilities are available.
*
- * @param[in] handle User's X11 display
+ * @param[in] handle (ResolutionInfoX11Type is used as backend specific handle)
* @return TRUE on success, FALSE on failure.
*/
Bool
ResolutionBackendInit(InitHandle handle)
{
- ResolutionInfoX11Type *resInfoX = &resolutionInfoX11;
+ ResolutionInfoX11Type *resInfoX = (ResolutionInfoX11Type *)handle;
ResolutionInfoType *resInfo = &resolutionInfo;
int dummy1;
int dummy2;
- memset(resInfoX, 0, sizeof *resInfoX);
+ if (resInfoX->canUseResolutionKMS == TRUE) {
+ resInfo->canSetResolution = FALSE;
+ resInfo->canSetTopology = FALSE;
+ return TRUE;
+ }
- resInfoX->display = handle;
+ XSetErrorHandler(ResolutionX11ErrorHandler);
+ resInfoX->display = XOpenDisplay(NULL);
if (resInfoX->display == NULL) {
+ g_error("%s: Invalid display detected.\n", __func__);
resInfo->canSetResolution = FALSE;
resInfo->canSetTopology = FALSE;
return TRUE;
}
- resInfoX->display = handle;
resInfoX->rootWindow = DefaultRootWindow(resInfoX->display);
resInfoX->canUseVMwareCtrl = VMwareCtrl_QueryVersion(resInfoX->display, &dummy1,
&dummy2);
void
ResolutionBackendCleanup(void)
{
+ ResolutionInfoX11Type *resInfoX = &resolutionInfoX11;
+ if (resInfoX->display) {
+ XCloseDisplay(resInfoX->display);
+ }
return;
}
g_debug("Setting guest resolution to: %dx%d (requested: %d, %d)\n",
xrrSizes[bestFitIndex].width, xrrSizes[bestFitIndex].height, width, height);
rc = XRRSetScreenConfig(resInfoX->display, xrrConfig, resInfoX->rootWindow,
- bestFitIndex, xrrCurRotation, GDK_CURRENT_TIME);
+ bestFitIndex, xrrCurRotation, CurrentTime);
g_debug("XRRSetScreenConfig returned %d (result: %dx%d)\n", rc,
xrrSizes[bestFitIndex].width, xrrSizes[bestFitIndex].height);
} else {
/**
- * Obtain a "handle", which for X11, is a display pointer.
+ * Obtain a "handle".
*
* @note We will have to move this out of the resolution plugin soon, I am
- * just landing this here now for convenience as I port resolution set over
+ * just landing this here now for convenience as I port resolution set over
* to the new service architecture.
*
- * @return X server display
+ * @return ResolutionInfoX11Type as backend specific handle
*/
InitHandle
ResolutionToolkitInit(ToolsAppCtx *ctx) // IN: For config database access
{
- int argc = 1;
- char *argv[] = {"", NULL};
- GtkWidget *wnd;
- Display *display;
+ ResolutionInfoX11Type *resInfoX = &resolutionInfoX11;
int fd;
+ memset(resInfoX, 0, sizeof *resInfoX);
+
fd = resolutionCheckForKMS(ctx);
if (fd >= 0) {
resolutionDRMClose(fd);
g_message("%s: Backing off for resolutionKMS.\n", __func__);
- return (InitHandle) 0;
+ resInfoX->canUseResolutionKMS = TRUE;
}
-
- XSetErrorHandler(ResolutionX11ErrorHandler);
- gtk_init(&argc, (char ***) &argv);
- wnd = gtk_invisible_new();
-#ifndef GTK3
- display = GDK_WINDOW_XDISPLAY(wnd->window);
-#else
- display = GDK_WINDOW_XDISPLAY(gtk_widget_get_window(wnd));
-#endif
- if (!display)
- g_error("%s: Invalid display detected.\n", __func__);
-
- return (InitHandle) display;
+ return (InitHandle) resInfoX;
}