Changeset View
Changeset View
Standalone View
Standalone View
composite.cpp
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Line(s) | 158 | { | |||
---|---|---|---|---|---|
185 | } | 185 | } | ||
186 | } | 186 | } | ||
187 | 187 | | |||
188 | extern int screen_number; // main.cpp | 188 | extern int screen_number; // main.cpp | ||
189 | extern bool is_multihead; | 189 | extern bool is_multihead; | ||
190 | 190 | | |||
191 | void Compositor::slotCompositingOptionsInitialized() | 191 | void Compositor::slotCompositingOptionsInitialized() | ||
192 | { | 192 | { | ||
193 | claimCompositorSelection(); | 193 | setupX11Support(); | ||
194 | 194 | | |||
195 | // There might still be a deleted around, needs to be cleared before creating the scene (BUG 333275) | 195 | // There might still be a deleted around, needs to be cleared before creating the scene (BUG 333275) | ||
196 | if (Workspace::self()) { | 196 | if (Workspace::self()) { | ||
197 | while (!Workspace::self()->deletedList().isEmpty()) { | 197 | while (!Workspace::self()->deletedList().isEmpty()) { | ||
198 | Workspace::self()->deletedList().first()->discard(); | 198 | Workspace::self()->deletedList().first()->discard(); | ||
199 | } | 199 | } | ||
200 | } | 200 | } | ||
201 | 201 | | |||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 284 | if (Workspace::self()) { | |||
285 | startupWithWorkspace(); | 285 | startupWithWorkspace(); | ||
286 | } else { | 286 | } else { | ||
287 | connect(kwinApp(), &Application::workspaceCreated, this, &Compositor::startupWithWorkspace); | 287 | connect(kwinApp(), &Application::workspaceCreated, this, &Compositor::startupWithWorkspace); | ||
288 | } | 288 | } | ||
289 | } | 289 | } | ||
290 | 290 | | |||
291 | void Compositor::claimCompositorSelection() | 291 | void Compositor::claimCompositorSelection() | ||
292 | { | 292 | { | ||
293 | if (!cm_selection && kwinApp()->x11Connection()) { | 293 | if (!cm_selection) { | ||
294 | char selection_name[ 100 ]; | 294 | char selection_name[ 100 ]; | ||
295 | sprintf(selection_name, "_NET_WM_CM_S%d", Application::x11ScreenNumber()); | 295 | sprintf(selection_name, "_NET_WM_CM_S%d", Application::x11ScreenNumber()); | ||
296 | cm_selection = new CompositorSelectionOwner(selection_name); | 296 | cm_selection = new CompositorSelectionOwner(selection_name); | ||
297 | connect(cm_selection, SIGNAL(lostOwnership()), SLOT(finish())); | 297 | connect(cm_selection, SIGNAL(lostOwnership()), SLOT(finish())); | ||
298 | } | 298 | } | ||
299 | 299 | | |||
300 | if (!cm_selection) // no X11 yet | 300 | if (!cm_selection) // no X11 yet | ||
301 | return; | 301 | return; | ||
302 | 302 | | |||
303 | if (!cm_selection->owning) { | 303 | if (!cm_selection->owning) { | ||
304 | cm_selection->claim(true); // force claiming | 304 | cm_selection->claim(true); // force claiming | ||
305 | cm_selection->owning = true; | 305 | cm_selection->owning = true; | ||
306 | } | 306 | } | ||
307 | } | 307 | } | ||
308 | 308 | | |||
309 | void Compositor::setupX11Support() | ||||
310 | { | ||||
311 | auto c = kwinApp()->x11Connection(); | ||||
312 | if (!c) { | ||||
313 | delete cm_selection; | ||||
314 | cm_selection = nullptr; | ||||
315 | return; | ||||
316 | } | ||||
317 | claimCompositorSelection(); | ||||
318 | xcb_composite_redirect_subwindows(c, kwinApp()->x11RootWindow(), XCB_COMPOSITE_REDIRECT_MANUAL); | ||||
319 | } | ||||
320 | | ||||
309 | void Compositor::startupWithWorkspace() | 321 | void Compositor::startupWithWorkspace() | ||
310 | { | 322 | { | ||
311 | if (!m_starting) { | 323 | if (!m_starting) { | ||
312 | return; | 324 | return; | ||
313 | } | 325 | } | ||
326 | connect(kwinApp(), &Application::x11ConnectionChanged, this, &Compositor::setupX11Support, Qt::UniqueConnection); | ||||
314 | Workspace::self()->markXStackingOrderAsDirty(); | 327 | Workspace::self()->markXStackingOrderAsDirty(); | ||
315 | Q_ASSERT(m_scene); | 328 | Q_ASSERT(m_scene); | ||
316 | connect(workspace(), &Workspace::destroyed, this, [this] { compositeTimer.stop(); }); | 329 | connect(workspace(), &Workspace::destroyed, this, [this] { compositeTimer.stop(); }); | ||
317 | claimCompositorSelection(); | 330 | setupX11Support(); | ||
318 | m_xrrRefreshRate = KWin::currentRefreshRate(); | 331 | m_xrrRefreshRate = KWin::currentRefreshRate(); | ||
319 | fpsInterval = options->maxFpsInterval(); | 332 | fpsInterval = options->maxFpsInterval(); | ||
320 | if (m_scene->syncsToVBlank()) { // if we do vsync, set the fps to the next multiple of the vblank rate | 333 | if (m_scene->syncsToVBlank()) { // if we do vsync, set the fps to the next multiple of the vblank rate | ||
321 | vBlankInterval = milliToNano(1000) / m_xrrRefreshRate; | 334 | vBlankInterval = milliToNano(1000) / m_xrrRefreshRate; | ||
322 | fpsInterval = qMax((fpsInterval / vBlankInterval) * vBlankInterval, vBlankInterval); | 335 | fpsInterval = qMax((fpsInterval / vBlankInterval) * vBlankInterval, vBlankInterval); | ||
323 | } else | 336 | } else | ||
324 | vBlankInterval = milliToNano(1); // no sync - DO NOT set "0", would cause div-by-zero segfaults. | 337 | vBlankInterval = milliToNano(1); // no sync - DO NOT set "0", would cause div-by-zero segfaults. | ||
325 | m_timeSinceLastVBlank = fpsInterval - (options->vBlankTime() + 1); // means "start now" - we don't have even a slight idea when the first vsync will occur | 338 | m_timeSinceLastVBlank = fpsInterval - (options->vBlankTime() + 1); // means "start now" - we don't have even a slight idea when the first vsync will occur | ||
326 | scheduleRepaint(); | 339 | scheduleRepaint(); | ||
327 | xcb_composite_redirect_subwindows(connection(), rootWindow(), XCB_COMPOSITE_REDIRECT_MANUAL); | | |||
328 | new EffectsHandlerImpl(this, m_scene); // sets also the 'effects' pointer | 340 | new EffectsHandlerImpl(this, m_scene); // sets also the 'effects' pointer | ||
329 | connect(Workspace::self(), &Workspace::deletedRemoved, m_scene, &Scene::windowDeleted); | 341 | connect(Workspace::self(), &Workspace::deletedRemoved, m_scene, &Scene::windowDeleted); | ||
330 | connect(effects, SIGNAL(screenGeometryChanged(QSize)), SLOT(addRepaintFull())); | 342 | connect(effects, SIGNAL(screenGeometryChanged(QSize)), SLOT(addRepaintFull())); | ||
331 | addRepaintFull(); | 343 | addRepaintFull(); | ||
332 | foreach (Client * c, Workspace::self()->clientList()) { | 344 | foreach (Client * c, Workspace::self()->clientList()) { | ||
333 | c->setupCompositing(); | 345 | c->setupCompositing(); | ||
334 | c->getShadow(); | 346 | c->getShadow(); | ||
335 | } | 347 | } | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 390 | if (Workspace::self()) { | |||
387 | foreach (Client * c, Workspace::self()->clientList()) | 399 | foreach (Client * c, Workspace::self()->clientList()) | ||
388 | c->finishCompositing(); | 400 | c->finishCompositing(); | ||
389 | foreach (Client * c, Workspace::self()->desktopList()) | 401 | foreach (Client * c, Workspace::self()->desktopList()) | ||
390 | c->finishCompositing(); | 402 | c->finishCompositing(); | ||
391 | foreach (Unmanaged * c, Workspace::self()->unmanagedList()) | 403 | foreach (Unmanaged * c, Workspace::self()->unmanagedList()) | ||
392 | c->finishCompositing(); | 404 | c->finishCompositing(); | ||
393 | foreach (Deleted * c, Workspace::self()->deletedList()) | 405 | foreach (Deleted * c, Workspace::self()->deletedList()) | ||
394 | c->finishCompositing(); | 406 | c->finishCompositing(); | ||
395 | xcb_composite_unredirect_subwindows(connection(), rootWindow(), XCB_COMPOSITE_REDIRECT_MANUAL); | 407 | if (auto c = kwinApp()->x11Connection()) { | ||
408 | xcb_composite_unredirect_subwindows(c, kwinApp()->x11RootWindow(), XCB_COMPOSITE_REDIRECT_MANUAL); | ||||
409 | } | ||||
396 | } | 410 | } | ||
397 | if (waylandServer()) { | 411 | if (waylandServer()) { | ||
398 | foreach (ShellClient *c, waylandServer()->clients()) { | 412 | foreach (ShellClient *c, waylandServer()->clients()) { | ||
399 | m_scene->windowClosed(c, nullptr); | 413 | m_scene->windowClosed(c, nullptr); | ||
400 | } | 414 | } | ||
401 | foreach (ShellClient *c, waylandServer()->internalClients()) { | 415 | foreach (ShellClient *c, waylandServer()->internalClients()) { | ||
402 | m_scene->windowClosed(c, nullptr); | 416 | m_scene->windowClosed(c, nullptr); | ||
403 | } | 417 | } | ||
▲ Show 20 Lines • Show All 817 Lines • Show Last 20 Lines |