diff --git a/autotests/integration/effects/minimize_animation_test.cpp b/autotests/integration/effects/minimize_animation_test.cpp index 1dc47e6602..fb32bbe0b7 100644 --- a/autotests/integration/effects/minimize_animation_test.cpp +++ b/autotests/integration/effects/minimize_animation_test.cpp @@ -146,14 +146,14 @@ void MinimizeAnimationTest::testMinimizeUnminimize() QVERIFY(!effect->isActive()); // Start the minimize animation. - window->minimize(); + window->setMinimized(true); QVERIFY(effect->isActive()); // Eventually, the animation will be complete. QTRY_VERIFY(!effect->isActive()); // Start the unminimize animation. - window->unminimize(); + window->setMinimized(false); QVERIFY(effect->isActive()); // Eventually, the animation will be complete. diff --git a/autotests/integration/effects/scripted_effects_test.cpp b/autotests/integration/effects/scripted_effects_test.cpp index bd9d917000..9926eb3dcb 100644 --- a/autotests/integration/effects/scripted_effects_test.cpp +++ b/autotests/integration/effects/scripted_effects_test.cpp @@ -199,10 +199,10 @@ void ScriptedEffectsTest::testEffectsHandler() waitFor("stackingOrder - 1 WindowA"); // windowMinimsed - c->minimize(); + c->setMinimized(true); waitFor("windowMinimized - WindowA"); - c->unminimize(); + c->setMinimized(false); waitFor("windowUnminimized - WindowA"); surface.reset(); diff --git a/autotests/integration/idle_inhibition_test.cpp b/autotests/integration/idle_inhibition_test.cpp index 43d7977324..745babd3c6 100644 --- a/autotests/integration/idle_inhibition_test.cpp +++ b/autotests/integration/idle_inhibition_test.cpp @@ -169,11 +169,11 @@ void TestIdleInhibition::testDontInhibitWhenMinimized() QCOMPARE(input()->idleInhibitors(), QList{window}); // Minimize the window, the idle inhibitor object should not be honored. - window->minimize(); + window->setMinimized(true); QCOMPARE(input()->idleInhibitors(), QList{}); // Unminimize the window, the idle inhibitor object should be honored back again. - window->unminimize(); + window->setMinimized(false); QCOMPARE(input()->idleInhibitors(), QList{window}); // Destroy the test window. diff --git a/autotests/integration/xdgshellwindow_rules_test.cpp b/autotests/integration/xdgshellwindow_rules_test.cpp index d8addc0c20..4c0c795d12 100644 --- a/autotests/integration/xdgshellwindow_rules_test.cpp +++ b/autotests/integration/xdgshellwindow_rules_test.cpp @@ -1527,7 +1527,7 @@ void TestXdgShellWindowRules::testMinimizeApply() QVERIFY(m_window->isMinimized()); // We should still be able to unminimize the window. - m_window->unminimize(); + m_window->setMinimized(false); QVERIFY(!m_window->isMinimized()); // If we re-open the window, it should be minimized back again. @@ -1548,7 +1548,7 @@ void TestXdgShellWindowRules::testMinimizeRemember() QVERIFY(!m_window->isMinimized()); // Minimize the window. - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); // If we open the window again, it should be minimized. @@ -1569,7 +1569,7 @@ void TestXdgShellWindowRules::testMinimizeForce() QVERIFY(!m_window->isMinimized()); // Any attempt to minimize the window should fail. - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(!m_window->isMinimized()); // If we re-open the window, the minimized state should still be forced. @@ -1577,7 +1577,7 @@ void TestXdgShellWindowRules::testMinimizeForce() createTestWindow(); QVERIFY(!m_window->isMinimizable()); QVERIFY(!m_window->isMinimized()); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(!m_window->isMinimized()); destroyTestWindow(); @@ -1596,7 +1596,7 @@ void TestXdgShellWindowRules::testMinimizeApplyNow() QVERIFY(m_window->isMinimized()); // One is still able to unminimize the window. - m_window->unminimize(); + m_window->setMinimized(false); QVERIFY(!m_window->isMinimized()); // The rule should not be applied again. @@ -1616,7 +1616,7 @@ void TestXdgShellWindowRules::testMinimizeForceTemporarily() QVERIFY(!m_window->isMinimized()); // Any attempt to minimize the window should fail until the window is closed. - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(!m_window->isMinimized()); // The rule should be discarded when the window is closed. @@ -1624,7 +1624,7 @@ void TestXdgShellWindowRules::testMinimizeForceTemporarily() createTestWindow(); QVERIFY(m_window->isMinimizable()); QVERIFY(!m_window->isMinimized()); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); destroyTestWindow(); @@ -2257,7 +2257,7 @@ void TestXdgShellWindowRules::testShortcutDontAffect() createTestWindow(); QCOMPARE(m_window->shortcut(), QKeySequence()); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); // If we press the window shortcut, nothing should happen. @@ -2285,7 +2285,7 @@ void TestXdgShellWindowRules::testShortcutApply() QSignalSpy minimizedChangedSpy(m_window, &Window::minimizedChanged); quint32 timestamp = 1; QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_1})); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2299,7 +2299,7 @@ void TestXdgShellWindowRules::testShortcutApply() // One can also change the shortcut. m_window->setShortcut(QStringLiteral("Ctrl+Alt+2")); QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_2})); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2311,7 +2311,7 @@ void TestXdgShellWindowRules::testShortcutApply() QVERIFY(!m_window->isMinimized()); // The old shortcut should do nothing. - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2344,7 +2344,7 @@ void TestXdgShellWindowRules::testShortcutRemember() QSignalSpy minimizedChangedSpy(m_window, &Window::minimizedChanged); quint32 timestamp = 1; QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_1})); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2358,7 +2358,7 @@ void TestXdgShellWindowRules::testShortcutRemember() // Change the window shortcut to Ctrl+Alt+2. m_window->setShortcut(QStringLiteral("Ctrl+Alt+2")); QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_2})); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2391,7 +2391,7 @@ void TestXdgShellWindowRules::testShortcutForce() QSignalSpy minimizedChangedSpy(m_window, &Window::minimizedChanged); quint32 timestamp = 1; QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_1})); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2405,7 +2405,7 @@ void TestXdgShellWindowRules::testShortcutForce() // Any attempt to change the window shortcut should not succeed. m_window->setShortcut(QStringLiteral("Ctrl+Alt+2")); QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_1})); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2437,7 +2437,7 @@ void TestXdgShellWindowRules::testShortcutApplyNow() QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_1})); QSignalSpy minimizedChangedSpy(m_window, &Window::minimizedChanged); quint32 timestamp = 1; - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2451,7 +2451,7 @@ void TestXdgShellWindowRules::testShortcutApplyNow() // Assign a different shortcut. m_window->setShortcut(QStringLiteral("Ctrl+Alt+2")); QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_2})); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2481,7 +2481,7 @@ void TestXdgShellWindowRules::testShortcutForceTemporarily() QSignalSpy minimizedChangedSpy(m_window, &Window::minimizedChanged); quint32 timestamp = 1; QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_1})); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); @@ -2495,7 +2495,7 @@ void TestXdgShellWindowRules::testShortcutForceTemporarily() // Any attempt to change the window shortcut should not succeed. m_window->setShortcut(QStringLiteral("Ctrl+Alt+2")); QCOMPARE(m_window->shortcut(), (QKeySequence{Qt::CTRL | Qt::ALT | Qt::Key_1})); - m_window->minimize(); + m_window->setMinimized(true); QVERIFY(m_window->isMinimized()); Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++); Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++); diff --git a/autotests/integration/xdgshellwindow_test.cpp b/autotests/integration/xdgshellwindow_test.cpp index 0c3295616f..1ed97d0ec8 100644 --- a/autotests/integration/xdgshellwindow_test.cpp +++ b/autotests/integration/xdgshellwindow_test.cpp @@ -307,7 +307,7 @@ void TestXdgShellWindow::testMinimizeActiveWindow() QVERIFY(window->isMinimized()); // unminimize again - window->unminimize(); + window->setMinimized(false); QVERIFY(!window->isMinimized()); QVERIFY(!window->isActive()); QVERIFY(window->wantsInput()); @@ -905,12 +905,12 @@ void TestXdgShellWindow::testMinimizeWindowWithTransients() QVERIFY(window->hasTransient(transient, false)); // minimize the main window, the transient should be minimized as well - window->minimize(); + window->setMinimized(true); QVERIFY(window->isMinimized()); QVERIFY(transient->isMinimized()); // unminimize the main window, the transient should be unminimized as well - window->unminimize(); + window->setMinimized(false); QVERIFY(!window->isMinimized()); QVERIFY(!transient->isMinimized()); } diff --git a/src/activation.cpp b/src/activation.cpp index ee31096f83..ef02f32bdc 100644 --- a/src/activation.cpp +++ b/src/activation.cpp @@ -309,7 +309,7 @@ void Workspace::activateWindow(Window *window, bool force) } #endif if (window->isMinimized()) { - window->unminimize(); + window->setMinimized(false); } // ensure the window is really visible - could eg. be a hidden utility window, see bug #348083 diff --git a/src/decorations/decoratedclient.cpp b/src/decorations/decoratedclient.cpp index 1dc9bd5475..10d9669d88 100644 --- a/src/decorations/decoratedclient.cpp +++ b/src/decorations/decoratedclient.cpp @@ -156,10 +156,14 @@ DELEGATE(requestToggleKeepBelow, KeepBelowOp) } DELEGATE(requestContextHelp, showContextHelp) -DELEGATE(requestMinimize, minimize) #undef DELEGATE +void DecoratedClientImpl::requestMinimize() +{ + m_window->setMinimized(true); +} + void DecoratedClientImpl::requestClose() { QMetaObject::invokeMethod(m_window, &Window::closeWindow, Qt::QueuedConnection); diff --git a/src/effects.cpp b/src/effects.cpp index 10c1e259d0..371139dd24 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -2245,14 +2245,14 @@ void EffectWindowImpl::elevate(bool elevate) void EffectWindowImpl::minimize() { if (m_window->isClient()) { - m_window->minimize(); + m_window->setMinimized(true); } } void EffectWindowImpl::unminimize() { if (m_window->isClient()) { - m_window->unminimize(); + m_window->setMinimized(false); } } diff --git a/src/events.cpp b/src/events.cpp index 9913fd3674..596d704021 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -524,7 +524,7 @@ bool X11Window::mapRequestEvent(xcb_map_request_event_t *e) } // also copied in clientMessage() if (isMinimized()) { - unminimize(); + setMinimized(false); } if (isShade()) { setShade(ShadeNone); @@ -590,7 +590,7 @@ void X11Window::clientMessageEvent(xcb_client_message_event_t *e) // WM_STATE if (e->type == atoms->wm_change_state) { if (e->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC) { - minimize(); + setMinimized(true); } return; } diff --git a/src/useractions.cpp b/src/useractions.cpp index 2e618d2c67..ebc7869da3 100644 --- a/src/useractions.cpp +++ b/src/useractions.cpp @@ -1244,7 +1244,7 @@ void Workspace::performWindowOperation(Window *window, Options::WindowOperation takeActivity(window, ActivityFocus | ActivityRaise); break; case Options::MinimizeOp: - window->minimize(); + window->setMinimized(true); break; case Options::ShadeOp: window->performMouseCommand(Options::MouseShade, Cursors::self()->mouse()->pos()); diff --git a/src/window.cpp b/src/window.cpp index ae4ef9c3e8..0a0072e699 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1294,33 +1294,16 @@ bool Window::titlebarPositionUnderMouse() const void Window::setMinimized(bool set) { - set ? minimize() : unminimize(); -} - -void Window::minimize() -{ - if (!isMinimizable() || isMinimized()) { + const bool effectiveSet = rules()->checkMinimize(set); + if (m_minimized == effectiveSet) { return; } - m_minimized = true; - doMinimize(); - - updateWindowRules(Rules::Minimize); - Q_EMIT minimizedChanged(); -} - -void Window::unminimize() -{ - if (!isMinimized()) { + if (effectiveSet && !isMinimizable()) { return; } - if (rules()->checkMinimize(false)) { - return; - } - - m_minimized = false; + m_minimized = effectiveSet; doMinimize(); updateWindowRules(Rules::Minimize); @@ -2212,11 +2195,7 @@ void Window::setupWindowManagementInterface() setFullScreen(set, false); }); connect(w, &PlasmaWindowInterface::minimizedRequested, this, [this](bool set) { - if (set) { - minimize(); - } else { - unminimize(); - } + setMinimized(set); }); connect(w, &PlasmaWindowInterface::maximizedRequested, this, [this](bool set) { maximize(set ? MaximizeFull : MaximizeRestore); @@ -2418,7 +2397,7 @@ bool Window::performMouseCommand(Options::MouseCommand cmd, const QPointF &globa maximize(MaximizeRestore); break; case Options::MouseMinimize: - minimize(); + setMinimized(true); break; case Options::MouseAbove: { StackingUpdatesBlocker blocker(workspace()); @@ -4408,12 +4387,7 @@ void Window::applyWindowRules() setOnActivities(activities()); // Type maximize(requestedMaximizeMode()); - // Minimize : functions don't check, and there are two functions - if (client_rules->checkMinimize(isMinimized())) { - minimize(); - } else { - unminimize(); - } + setMinimized(isMinimized()); setShade(shadeMode()); setOriginalSkipTaskbar(skipTaskbar()); setSkipPager(skipPager()); diff --git a/src/window.h b/src/window.h index 066a5b67d2..f4652c9d00 100644 --- a/src/window.h +++ b/src/window.h @@ -974,11 +974,6 @@ public: QStringList desktopIds() const; void setMinimized(bool set); - /** - * Minimizes this window plus its transients - */ - void minimize(); - void unminimize(); bool isMinimized() const { return m_minimized; diff --git a/src/workspace.cpp b/src/workspace.cpp index fe3e659f49..4f9d07aa7e 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -2144,28 +2144,28 @@ void Workspace::updateMinimizedOfTransients(Window *window) } // but to keep them to eg. watch progress or whatever if (!(*it)->isMinimized()) { - (*it)->minimize(); + (*it)->setMinimized(true); updateMinimizedOfTransients((*it)); } } if (window->isModal()) { // if a modal dialog is minimized, minimize its mainwindow too const auto windows = window->mainWindows(); for (Window *main : std::as_const(windows)) { - main->minimize(); + main->setMinimized(true); } } } else { // else unmiminize the transients for (auto it = window->transients().constBegin(); it != window->transients().constEnd(); ++it) { if ((*it)->isMinimized()) { - (*it)->unminimize(); + (*it)->setMinimized(false); updateMinimizedOfTransients((*it)); } } if (window->isModal()) { const auto windows = window->mainWindows(); for (Window *main : std::as_const(windows)) { - main->unminimize(); + main->setMinimized(false); } } } diff --git a/src/xdgshellwindow.cpp b/src/xdgshellwindow.cpp index d0a74a27c6..377cbbebfe 100644 --- a/src/xdgshellwindow.cpp +++ b/src/xdgshellwindow.cpp @@ -1223,7 +1223,7 @@ void XdgToplevelWindow::handleUnfullscreenRequested() void XdgToplevelWindow::handleMinimizeRequested() { - minimize(); + setMinimized(true); } void XdgToplevelWindow::handleTransientForChanged()