From 75e96010a30545454b75aa6e0d47f801ffbe934c Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sun, 11 Aug 2019 22:15:38 +0200 Subject: [PATCH] Move common code out of if/else Summary: Less duplication is better. Reviewers: #kwin, romangg Reviewed By: #kwin, romangg Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D23101 --- useractions.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/useractions.cpp b/useractions.cpp index ddfa816cfa..eb52d7c19e 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -152,18 +152,15 @@ void UserActionsMenu::show(const QRect &pos, AbstractClient *client) int x = pos.left(); int y = pos.bottom(); const bool needsPopup = kwinApp()->shouldUseWaylandForCompositing(); + m_client->blockActivityUpdates(true); + if (y == pos.top()) { - m_client->blockActivityUpdates(true); if (needsPopup) { m_menu->popup(QPoint(x, y)); } else { m_menu->exec(QPoint(x, y)); } - if (m_client) { - m_client->blockActivityUpdates(false); - } } else { - m_client->blockActivityUpdates(true); QRect area = ws->clientArea(ScreenArea, QPoint(x, y), VirtualDesktopManager::self()->current()); menuAboutToShow(); // needed for sizeHint() to be correct :-/ int popupHeight = m_menu->sizeHint().height(); @@ -180,9 +177,9 @@ void UserActionsMenu::show(const QRect &pos, AbstractClient *client) m_menu->exec(QPoint(x, pos.top() - popupHeight)); } } - if (m_client) { - m_client->blockActivityUpdates(false); - } + } + if (m_client) { + m_client->blockActivityUpdates(false); } }