From 8794fe548a0b7ec29b346748f8899face6b06f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Mon, 7 Aug 2017 06:57:37 +0200 Subject: [PATCH] Guard every remaining access to rootInfo Summary: For a future XFree KWin. Only remaining not guarded usages are in Workspace::init, but that one needs to be refactored anyway for becoming X free. Test Plan: Compiles Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D7173 --- geometry.cpp | 26 +++++++++++++++----------- layers.cpp | 6 ++++++ workspace.cpp | 8 ++++++-- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/geometry.cpp b/geometry.cpp index bd1ec657cb..b32b0e3a76 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -70,10 +70,12 @@ extern bool is_multihead; void Workspace::desktopResized() { QRect geom = screens()->geometry(); - NETSize desktop_geometry; - desktop_geometry.width = geom.width(); - desktop_geometry.height = geom.height(); - rootInfo()->setDesktopGeometry(desktop_geometry); + if (rootInfo()) { + NETSize desktop_geometry; + desktop_geometry.width = geom.width(); + desktop_geometry.height = geom.height(); + rootInfo()->setDesktopGeometry(desktop_geometry); + } updateClientArea(); saveOldScreenSizes(); // after updateClientArea(), so that one still uses the previous one @@ -309,13 +311,15 @@ void Workspace::updateClientArea(bool force) oldrestrictedmovearea = restrictedmovearea; restrictedmovearea = new_rmoveareas; screenarea = new_sareas; - NETRect r; - for (int i = 1; i <= numberOfDesktops; i++) { - r.pos.x = workarea[ i ].x(); - r.pos.y = workarea[ i ].y(); - r.size.width = workarea[ i ].width(); - r.size.height = workarea[ i ].height(); - rootInfo()->setWorkArea(i, r); + if (rootInfo()) { + NETRect r; + for (int i = 1; i <= numberOfDesktops; i++) { + r.pos.x = workarea[ i ].x(); + r.pos.y = workarea[ i ].y(); + r.size.width = workarea[ i ].width(); + r.size.height = workarea[ i ].height(); + rootInfo()->setWorkArea(i, r); + } } for (auto it = m_allClients.constBegin(); diff --git a/layers.cpp b/layers.cpp index 1734d0cb6c..28db06785a 100644 --- a/layers.cpp +++ b/layers.cpp @@ -151,6 +151,9 @@ void Workspace::updateStackingOrder(bool propagate_new_clients) */ void Workspace::stackScreenEdgesUnderOverrideRedirect() { + if (!rootInfo()) { + return; + } Xcb::restackWindows(QVector() << rootInfo()->supportWindow() << ScreenEdges::self()->windows()); } @@ -160,6 +163,9 @@ void Workspace::stackScreenEdgesUnderOverrideRedirect() */ void Workspace::propagateClients(bool propagate_new_clients) { + if (!rootInfo()) { + return; + } // restack the windows according to the stacking order // supportWindow > electric borders > clients > hidden clients QVector newWindowStack; diff --git a/workspace.cpp b/workspace.cpp index e83f159cd4..4c2d5f7551 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -948,7 +948,9 @@ void Workspace::updateClientVisibilityOnDesktopChange(uint oldDesktop, uint newD } } // Now propagate the change, after hiding, before showing - rootInfo()->setCurrentDesktop(VirtualDesktopManager::self()->current()); + if (rootInfo()) { + rootInfo()->setCurrentDesktop(VirtualDesktopManager::self()->current()); + } if (movingClient && !movingClient->isOnDesktop(newDesktop)) { movingClient->setDesktop(newDesktop); @@ -1246,7 +1248,9 @@ void Workspace::sendClientToScreen(AbstractClient* c, int screen) void Workspace::sendPingToWindow(xcb_window_t window, xcb_timestamp_t timestamp) { - rootInfo()->sendPing(window, timestamp); + if (rootInfo()) { + rootInfo()->sendPing(window, timestamp); + } } /**