Drop Window::desktopPresenceChanged()

This signal exists as a convenience helper, but it's not always emitted
as it's advertised to work. Instead of fixing it, let's drop the signal
to simplify virtual desktop code. Its effects can be accomplished by
monitoring Window::desktopChanged() and VirtualDesktopManager::currentChanged()
signals in effects and scripts where needed.
remotes/origin/work/zzag/simplify-window-setdesktops-transients
Vlad Zahorodnii 3 years ago
parent a60c3130e3
commit b53621136d
  1. 5
      autotests/integration/virtual_desktop_test.cpp
  2. 31
      autotests/integration/xdgshellwindow_test.cpp
  3. 9
      src/effects.cpp
  4. 4
      src/effects/dialogparent/package/contents/code/main.js
  5. 4
      src/effects/frozenapp/package/contents/code/main.js
  6. 4
      src/effects/translucency/package/contents/code/main.js
  7. 14
      src/libkwineffects/kwineffects.h
  8. 1
      src/scripting/workspace_wrapper.cpp
  9. 1
      src/scripting/workspace_wrapper.h
  10. 10
      src/window.cpp
  11. 1
      src/window.h
  12. 1
      src/workspace.cpp
  13. 1
      src/workspace.h

@ -131,8 +131,6 @@ void VirtualDesktopTest::testLastDesktopRemoved()
QVERIFY(window);
QCOMPARE(window->desktop(), 2);
QSignalSpy desktopPresenceChangedSpy(window, &Window::desktopPresenceChanged);
QCOMPARE(window->desktops().count(), 1u);
QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), window->desktops().first());
@ -140,7 +138,6 @@ void VirtualDesktopTest::testLastDesktopRemoved()
VirtualDesktopManager::self()->setCount(1);
QCOMPARE(VirtualDesktopManager::self()->count(), 1u);
// now the window should be moved as well
QTRY_COMPARE(desktopPresenceChangedSpy.count(), 1);
QCOMPARE(window->desktop(), 1);
QCOMPARE(window->desktops().count(), 1u);
@ -165,7 +162,6 @@ void VirtualDesktopTest::testWindowOnMultipleDesktops()
QVERIFY(window);
QCOMPARE(window->desktop(), 3u);
QSignalSpy desktopPresenceChangedSpy(window, &Window::desktopPresenceChanged);
QCOMPARE(window->desktops().count(), 1u);
QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), window->desktops().first());
@ -243,7 +239,6 @@ void VirtualDesktopTest::testRemoveDesktopWithWindow()
QVERIFY(window);
QCOMPARE(window->desktop(), 3u);
QSignalSpy desktopPresenceChangedSpy(window, &Window::desktopPresenceChanged);
QCOMPARE(window->desktops().count(), 1u);
QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), window->desktops().first());

@ -59,7 +59,6 @@ private Q_SLOTS:
void cleanup();
void testMapUnmap();
void testDesktopPresenceChanged();
void testWindowOutputs();
void testMinimizeActiveWindow();
void testFullscreen_data();
@ -253,36 +252,6 @@ void TestXdgShellWindow::testMapUnmap()
QVERIFY(Test::waitForWindowDestroyed(window));
}
void TestXdgShellWindow::testDesktopPresenceChanged()
{
// this test verifies that the desktop presence changed signals are properly emitted
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(window->desktop(), 1);
effects->setNumberOfDesktops(4);
QSignalSpy desktopPresenceChangedClientSpy(window, &Window::desktopPresenceChanged);
QSignalSpy desktopPresenceChangedWorkspaceSpy(workspace(), &Workspace::desktopPresenceChanged);
QSignalSpy desktopPresenceChangedEffectsSpy(effects, &EffectsHandler::desktopPresenceChanged);
// let's change the desktop
workspace()->sendWindowToDesktop(window, 2, false);
QCOMPARE(window->desktop(), 2);
QCOMPARE(desktopPresenceChangedClientSpy.count(), 1);
QCOMPARE(desktopPresenceChangedWorkspaceSpy.count(), 1);
QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 1);
// verify the arguments
QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value<Window *>(), window);
QCOMPARE(desktopPresenceChangedClientSpy.first().at(1).toInt(), 1);
QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value<Window *>(), window);
QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(1).toInt(), 1);
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value<EffectWindow *>(), window->effectWindow());
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(1).toInt(), 1);
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2);
}
void TestXdgShellWindow::testWindowOutputs()
{
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());

@ -158,12 +158,6 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, WorkspaceScene *s
connect(ws, &Workspace::currentDesktopChangingCancelled, this, [this]() {
Q_EMIT desktopChangingCancelled();
});
connect(ws, &Workspace::desktopPresenceChanged, this, [this](Window *window, int old) {
if (!window->effectWindow()) {
return;
}
Q_EMIT desktopPresenceChanged(window->effectWindow(), old, window->desktop());
});
connect(ws, &Workspace::windowAdded, this, [this](Window *window) {
if (window->readyForPainting()) {
slotWindowShown(window);
@ -354,6 +348,9 @@ void EffectsHandlerImpl::setupWindowConnections(Window *window)
connect(window, &Window::decorationChanged, this, [this, window]() {
Q_EMIT windowDecorationChanged(window->effectWindow());
});
connect(window, &Window::desktopChanged, this, [this, window]() {
Q_EMIT windowDesktopsChanged(window->effectWindow());
});
}
void EffectsHandlerImpl::setupUnmanagedConnections(Unmanaged *u)

@ -138,8 +138,8 @@ var dialogParentEffect = {
effects.windowUnminimized.connect(dialogParentEffect.restartAnimation);
effects.windowModalityChanged.connect(dialogParentEffect.modalDialogChanged)
effects.desktopChanged.connect(dialogParentEffect.desktopChanged);
effects.desktopPresenceChanged.connect(dialogParentEffect.cancelAnimationInstant);
effects.desktopPresenceChanged.connect(dialogParentEffect.restartAnimation);
effects.windowDesktopsChanged.connect(dialogParentEffect.cancelAnimationInstant);
effects.windowDesktopsChanged.connect(dialogParentEffect.restartAnimation);
effects.activeFullScreenEffectChanged.connect(
dialogParentEffect.activeFullScreenEffectChanged);

@ -106,8 +106,8 @@ var frozenAppEffect = {
effects.windowUnminimized.connect(frozenAppEffect.restartAnimation);
effects.windowUnresponsiveChanged.connect(frozenAppEffect.unresponsiveChanged);
effects.desktopChanged.connect(frozenAppEffect.desktopChanged);
effects.desktopPresenceChanged.connect(frozenAppEffect.cancelAnimation);
effects.desktopPresenceChanged.connect(frozenAppEffect.restartAnimation);
effects.windowDesktopsChanged.connect(frozenAppEffect.cancelAnimation);
effects.windowDesktopsChanged.connect(frozenAppEffect.restartAnimation);
var windows = effects.stackingOrder;
for (var i = 0, length = windows.length; i < length; ++i) {

@ -206,8 +206,8 @@ var translucencyEffect = {
},
init: function () {
effect.configChanged.connect(translucencyEffect.loadConfig);
effects.desktopPresenceChanged.connect(translucencyEffect.cancelAnimations);
effects.desktopPresenceChanged.connect(translucencyEffect.startAnimation);
effects.windowDesktopsChanged.connect(translucencyEffect.cancelAnimations);
effects.windowDesktopsChanged.connect(translucencyEffect.startAnimation);
effects.windowAdded.connect(translucencyEffect.startAnimation);
effects.windowUnminimized.connect(translucencyEffect.startAnimation);
effects.windowClosed.connect(translucencyEffect.cancelAnimations);

@ -1459,15 +1459,6 @@ Q_SIGNALS:
void desktopChanging(uint currentDesktop, QPointF offset, KWin::EffectWindow *with);
void desktopChangingCancelled();
/**
* Signal emitted when a window moved to another desktop
* NOTICE that this does NOT imply that the desktop has changed
* The @param window which is moved to the new desktop
* @param oldDesktop The previous desktop of the window
* @param newDesktop The new desktop of the window
* @since 4.11.4
*/
void desktopPresenceChanged(KWin::EffectWindow *window, int oldDesktop, int newDesktop);
/**
* Emitted when the virtual desktop grid layout changes
* @param size new size
@ -1934,6 +1925,11 @@ Q_SIGNALS:
void inputPanelChanged();
/**
* This signal is emitted when a window enters or leaves a virtual desktop.
*/
void windowDesktopsChanged(KWin::EffectWindow *window);
protected:
QVector<EffectPair> loaded_effects;
// QHash< QString, EffectFactory* > effect_factories;

@ -31,7 +31,6 @@ WorkspaceWrapper::WorkspaceWrapper(QObject *parent)
{
KWin::Workspace *ws = KWin::Workspace::self();
KWin::VirtualDesktopManager *vds = KWin::VirtualDesktopManager::self();
connect(ws, &Workspace::desktopPresenceChanged, this, &WorkspaceWrapper::desktopPresenceChanged);
connect(ws, &Workspace::windowAdded, this, &WorkspaceWrapper::clientAdded);
connect(ws, &Workspace::windowRemoved, this, &WorkspaceWrapper::clientRemoved);
connect(ws, &Workspace::windowActivated, this, &WorkspaceWrapper::clientActivated);

@ -63,7 +63,6 @@ private:
Q_DISABLE_COPY(WorkspaceWrapper)
Q_SIGNALS:
void desktopPresenceChanged(KWin::Window *client, int desktop);
void clientAdded(KWin::Window *client);
void clientRemoved(KWin::Window *client);
void clientActivated(KWin::Window *client);

@ -1060,9 +1060,7 @@ void Window::setDesktops(QVector<VirtualDesktop *> desktops)
return;
}
int was_desk = Window::desktop();
const bool wasOnCurrentDesktop = isOnCurrentDesktop() && was_desk >= 0;
const bool wasOnAllDesktops = isOnAllDesktops();
m_desktops = desktops;
if (windowManagementInterface()) {
@ -1087,8 +1085,7 @@ void Window::setDesktops(QVector<VirtualDesktop *> desktops)
info->setDesktop(desktop());
}
if ((was_desk == NET::OnAllDesktops) != (desktop() == NET::OnAllDesktops)) {
// onAllDesktops changed
if (isOnAllDesktops() != wasOnAllDesktops) {
workspace()->updateOnAllDesktopsOfTransients(this);
}
@ -1113,9 +1110,6 @@ void Window::setDesktops(QVector<VirtualDesktop *> desktops)
updateWindowRules(Rules::Desktops);
Q_EMIT desktopChanged();
if (wasOnCurrentDesktop != isOnCurrentDesktop()) {
Q_EMIT desktopPresenceChanged(this, was_desk);
}
}
void Window::doSetDesktop()

@ -1494,7 +1494,6 @@ Q_SIGNALS:
* Emitted whenever the demands attention state changes.
*/
void demandsAttentionChanged();
void desktopPresenceChanged(KWin::Window *, int); // to be forwarded by Workspace
void desktopChanged();
void activitiesChanged(KWin::Window *window);
void minimizedChanged();

@ -770,7 +770,6 @@ void Workspace::updateOutputConfiguration()
void Workspace::setupWindowConnections(Window *window)
{
connect(window, &Window::desktopPresenceChanged, this, &Workspace::desktopPresenceChanged);
connect(window, &Window::minimizedChanged, this, std::bind(&Workspace::windowMinimizedChanged, this, window));
connect(window, &Window::fullScreenChanged, m_screenEdges.get(), &ScreenEdges::checkBlocking);
}

@ -573,7 +573,6 @@ Q_SIGNALS:
void geometryChanged();
// Signals required for the scripting interface
void desktopPresenceChanged(KWin::Window *, int);
void currentActivityChanged();
void currentDesktopChanged(int, KWin::Window *);
void currentDesktopChanging(uint currentDesktop, QPointF delta, KWin::Window *); // for realtime animations

Loading…
Cancel
Save