From 59cea67401749cba83e454b9d0c30feb4ea25a9c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 2 Jun 2023 18:48:57 +0300 Subject: [PATCH] Avoid unnecessary Workspace::updateClientArea() Currently, when a window is added or removed, the work area will be recomputed unconditionally. But in many cases, it's unnecessary because only a small fraction of windows has a strut (in default setup, only the panel has a strut). --- src/workspace.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/workspace.cpp b/src/workspace.cpp index a43bbbfcba..87c0ba9232 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -706,7 +706,9 @@ void Workspace::addX11Window(X11Window *window) Q_ASSERT(!m_windows.contains(window)); m_windows.append(window); addToStack(window); - updateClientArea(); // This cannot be in manage(), because the window got added only now + if (window->hasStrut()) { + updateClientArea(); // This cannot be in manage(), because the window got added only now + } window->updateLayer(); if (window->isDesktop()) { raiseWindow(window); @@ -798,7 +800,9 @@ void Workspace::addWaylandWindow(Window *window) addToStack(window); updateStackingOrder(true); - updateClientArea(); + if (window->hasStrut()) { + updateClientArea(); + } if (window->wantsInput() && !window->isMinimized()) { activateWindow(window); } @@ -840,11 +844,13 @@ void Workspace::removeWindow(Window *window) window->setShortcut(QString()); // Remove from client_keys windowShortcutUpdated(window); // Needed, since this is otherwise delayed by setShortcut() and wouldn't run } + if (window->hasStrut()) { + updateClientArea(); + } Q_EMIT windowRemoved(window); updateStackingOrder(true); - updateClientArea(); updateTabbox(); } @@ -2021,8 +2027,6 @@ void Workspace::addInternalWindow(InternalWindow *window) } updateStackingOrder(true); - updateClientArea(); - Q_EMIT windowAdded(window); } @@ -2031,8 +2035,6 @@ void Workspace::removeInternalWindow(InternalWindow *window) m_windows.removeOne(window); updateStackingOrder(); - updateClientArea(); - Q_EMIT windowRemoved(window); }