diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 4b291813a..9155d0861 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -31,6 +31,7 @@ extern Window EphyrPreExistingHostWin; extern Bool EphyrWantGrayScale; +extern Bool ephyr_glamor; extern Bool kdHasPointer; extern Bool kdHasKbd; @@ -223,6 +224,7 @@ ddxProcessArgument (int argc, char **argv, int i) } else if (!strcmp (argv[i], "-glamor")) { + ephyr_glamor = TRUE; ephyrFuncs.initAccel = ephyr_glamor_init; ephyrFuncs.enableAccel = ephyr_glamor_enable; ephyrFuncs.disableAccel = ephyr_glamor_disable; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index a854c881d..c7c792984 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -97,6 +97,7 @@ struct EphyrHostXVars Display *dpy; int screen; Visual *visual; + XVisualInfo *visual_info; Window winroot; GC gc; int depth; @@ -125,10 +126,14 @@ extern int monitorResolution; char *ephyrResName = NULL; int ephyrResNameFromCmd = 0; char *ephyrTitle = NULL; +Bool ephyr_glamor = FALSE; static void hostx_set_fullscreen_hint(void); +static void +ephyr_glamor_get_visual(void); + /* X Error traps */ static int trapped_error_code = 0; @@ -364,8 +369,11 @@ hostx_init (void) HostX.winroot = RootWindow(HostX.dpy, HostX.screen); HostX.gc = XCreateGC(HostX.dpy, HostX.winroot, 0, NULL); HostX.depth = DefaultDepth(HostX.dpy, HostX.screen); - HostX.visual = DefaultVisual(HostX.dpy, HostX.screen); - + if (ephyr_glamor) { + ephyr_glamor_get_visual(); + } else { + HostX.visual = DefaultVisual(HostX.dpy, HostX.screen); + } class_hint = XAllocClassHint(); for (index = 0 ; index < HostX.n_screens ; index++) @@ -1448,22 +1456,18 @@ hostx_has_glx (void) #endif /* XF86DRI */ -void -ephyr_glamor_host_create_context(EphyrScreenInfo ephyr_screen) +static void +ephyr_glamor_get_visual(void) { - Display *dpy = hostx_get_display(); + Display *dpy = HostX.dpy; int attribs[] = {GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None}; XVisualInfo *visual_info; - GLXContext ctx; - struct EphyrHostScreen *host_screen; int event_base = 0, error_base = 0; - host_screen = host_screen_from_screen_info(ephyr_screen); - if (!glXQueryExtension (dpy, &event_base, &error_base)) errx(1, "Couldn't find GLX extension\n"); @@ -1471,12 +1475,23 @@ ephyr_glamor_host_create_context(EphyrScreenInfo ephyr_screen) if (visual_info == NULL) errx(1, "Couldn't get RGB visual\n"); - ctx = glXCreateContext(dpy, visual_info, NULL, True); + HostX.visual_info = visual_info; + HostX.visual = visual_info->visual; +} + +void +ephyr_glamor_host_create_context(EphyrScreenInfo ephyr_screen) +{ + Display *dpy = HostX.dpy; + GLXContext ctx; + struct EphyrHostScreen *host_screen; + + host_screen = host_screen_from_screen_info(ephyr_screen); + + ctx = glXCreateContext(dpy, HostX.visual_info, NULL, True); if (ctx == NULL) errx(1, "glXCreateContext failed\n"); if (!glXMakeCurrent(dpy, host_screen->win, ctx)) errx(1, "glXMakeCurrent failed\n"); - - XFree(visual_info); }