35 m_display = XOpenDisplay(DisplayString(QX11Info::display()));
37 qCDebug(KWIN_X11STANDALONE) <<
"Failed to establish vsync monitor X11 connection";
43 const int attribs[] = {
44 GLX_RENDER_TYPE, GLX_RGBA_BIT,
45 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
50 qCDebug(KWIN_X11STANDALONE) <<
"Couldn't find any suitable FBConfig for vsync monitor";
54 XVisualInfo *visualInfo = glXGetVisualFromFBConfig(m_display, config);
59 Visual *visual = visualInfo->visual;
60 const int depth = visualInfo->depth;
63 Colormap colormap = XCreateColormap(m_display,
rootWindow, visual, AllocNone);
64 XSetWindowAttributes attributes;
65 attributes.colormap = colormap;
67 m_dummyWindow = XCreateWindow(m_display,
rootWindow, 0, 0, 1, 1, 0, depth,
68 InputOutput, visual, CWColormap, &attributes);
69 XFreeColormap(m_display, colormap);
71 qCDebug(KWIN_X11STANDALONE) <<
"Failed to create a dummy window for vsync monitor";
75 m_drawable = glXCreateWindow(m_display, config, m_dummyWindow,
nullptr);
77 qCDebug(KWIN_X11STANDALONE) <<
"Failed to create GLXWindow for dummy window";
81 m_localContext = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, 0,
true);
82 if (!m_localContext) {
83 qCDebug(KWIN_X11STANDALONE) <<
"Failed to create opengl context for vsync monitor";
111 if (!glXMakeCurrent(m_display, m_drawable, m_localContext)) {
112 qCDebug(KWIN_X11STANDALONE) <<
"Failed to make vsync monitor OpenGL context current";
116 int64_t ust, msc, sbc;
118 glXGetSyncValuesOML(m_display, m_drawable, &ust, &msc, &sbc);
119 glXWaitForMscOML(m_display, m_drawable, 0, 2, (msc + 1) % 2, &ust, &msc, &sbc);