26 xcb_connection_t *
const connection = kwinApp()->x11Connection();
28 xcb_sync_create_fence(
connection, kwinApp()->x11RootWindow(), m_fence,
false);
31 m_sync = glImportSyncEXT(GL_SYNC_X11_FENCE_EXT, m_fence, 0);
36 xcb_connection_t *
const connection = kwinApp()->x11Connection();
52 xcb_discard_reply(
connection, m_reset_cookie.sequence);
65 xcb_sync_trigger_fence(kwinApp()->x11Connection(), m_fence);
75 glWaitSync(m_sync, 0, GL_TIMEOUT_IGNORED);
81 if (m_state ==
Done) {
92 glGetSynciv(m_sync, GL_SYNC_STATUS, 1,
nullptr, &value);
94 if (value != GL_SIGNALED) {
95 qCDebug(KWIN_CORE) <<
"Waiting for X fence to finish";
98 const GLenum result = glClientWaitSync(m_sync, 0, 1000000000);
101 case GL_TIMEOUT_EXPIRED:
102 qCWarning(KWIN_CORE) <<
"Timeout while waiting for X fence";
106 qCWarning(KWIN_CORE) <<
"glClientWaitSync() failed";
117 Q_ASSERT(m_state ==
Done);
119 xcb_connection_t *
const connection = kwinApp()->x11Connection();
127 m_reset_cookie = xcb_get_input_focus(
connection);
136 free(xcb_get_input_focus_reply(kwinApp()->x11Connection(), m_reset_cookie,
nullptr));
151 const bool haveSyncObjects = glPlatform->
isGLES()
155 if (
hasGLExtension(
"GL_EXT_x11_sync_object") && haveSyncObjects) {
156 const QString useExplicitSync = qEnvironmentVariable(
"KWIN_EXPLICIT_SYNC");
158 if (useExplicitSync != QLatin1String(
"0")) {
159 qCDebug(KWIN_CORE) <<
"Initializing fences for synchronization with the X command stream";
162 qCDebug(KWIN_CORE) <<
"Explicit synchronization with the X command stream disabled by environment variable";
168X11SyncManager::X11SyncManager()
178 qDeleteAll(m_fences);
183 if (!m_currentFence) {
187 for (
int i = 0; i < std::min<int>(2, m_fences.count() - 1); i++) {
188 const int index = (m_next + i) % m_fences.count();
191 switch (fence->
state()) {
214 m_currentFence =
nullptr;
220 m_currentFence = m_fences[m_next];
221 m_next = (m_next + 1) % m_fences.count();
228 m_currentFence->
wait();
@ OperationModeX11
KWin uses only X11 for managing windows and compositing.
WorkspaceScene * scene() const
static Compositor * self()
virtual bool makeOpenGLContextCurrent()
static X11SyncManager * create()
bool hasGLVersion(int major, int minor, int release)
bool hasGLExtension(const QByteArray &extension)
KWIN_EXPORT xcb_connection_t * connection()