Window::Window (Display& display, int width, int height, ::Visual* visual) : m_display (display) , m_colormap (None) , m_window (None) , m_visible (false) { XSetWindowAttributes swa; ::Display* const dpy = m_display.getXDisplay(); ::Window root = DefaultRootWindow(dpy); unsigned long mask = CWBorderPixel | CWEventMask; // If redirect is enabled, window size can't be guaranteed and it is up to // the window manager to decide whether to honor sizing requests. However, // overriding that causes window to appear as an overlay, which causes // other issues, so this is disabled by default. const bool overrideRedirect = false; if (overrideRedirect) { mask |= CWOverrideRedirect; swa.override_redirect = true; } if (visual == DE_NULL) visual = CopyFromParent; else { XVisualInfo info = XVisualInfo(); bool succ = display.getVisualInfo(XVisualIDFromVisual(visual), info); TCU_CHECK_INTERNAL(succ); root = RootWindow(dpy, info.screen); m_colormap = XCreateColormap(dpy, root, visual, AllocNone); swa.colormap = m_colormap; mask |= CWColormap; } swa.border_pixel = 0; swa.event_mask = ExposureMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask; if (width == glu::RenderConfig::DONT_CARE) width = DEFAULT_WINDOW_WIDTH; if (height == glu::RenderConfig::DONT_CARE) height = DEFAULT_WINDOW_HEIGHT; m_window = XCreateWindow(dpy, root, 0, 0, width, height, 0, CopyFromParent, InputOutput, visual, mask, &swa); TCU_CHECK(m_window); Atom deleteAtom = m_display.getDeleteAtom(); XSetWMProtocols(dpy, m_window, &deleteAtom, 1); }
Window::Window (Display& display, int width, int height, ::Visual* visual) : m_display (display) , m_colormap (None) , m_window (None) , m_visible (false) { XSetWindowAttributes swa; ::Display* dpy = m_display.getXDisplay(); ::Window root = DefaultRootWindow(dpy); unsigned long mask = CWBorderPixel | CWEventMask; if (visual == DE_NULL) visual = CopyFromParent; else { XVisualInfo info = XVisualInfo(); bool succ = display.getVisualInfo(XVisualIDFromVisual(visual), info); TCU_CHECK_INTERNAL(succ); root = RootWindow(dpy, info.screen); m_colormap = XCreateColormap(dpy, root, visual, AllocNone); swa.colormap = m_colormap; mask |= CWColormap; } swa.border_pixel = 0; swa.event_mask = ExposureMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask; mask |= CWOverrideRedirect; swa.override_redirect = true; if (width == glu::RenderConfig::DONT_CARE) width = DEFAULT_WINDOW_WIDTH; if (height == glu::RenderConfig::DONT_CARE) height = DEFAULT_WINDOW_HEIGHT; m_window = XCreateWindow(dpy, root, 0, 0, width, height, 0, CopyFromParent, InputOutput, visual, mask, &swa); TCU_CHECK(m_window); Atom deleteAtom = m_display.getDeleteAtom(); XSetWMProtocols(dpy, m_window, &deleteAtom, 1); }