mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-06 19:14:57 +11:00
all: refactor windows code out of core
There are still some links from core to window but its now separate enough to fix PanelWindow in qml tooling.
This commit is contained in:
parent
1adad9e822
commit
4e48c6eefb
45 changed files with 1171 additions and 1142 deletions
|
|
@ -1,9 +1,8 @@
|
|||
function (qs_test name)
|
||||
add_executable(${name} ${ARGN})
|
||||
target_link_libraries(${name} PRIVATE ${QT_DEPS} Qt6::Test quickshell-core)
|
||||
target_link_libraries(${name} PRIVATE ${QT_DEPS} Qt6::Test quickshell-core quickshell-window)
|
||||
add_test(NAME ${name} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" COMMAND $<TARGET_FILE:${name}>)
|
||||
endfunction()
|
||||
|
||||
qs_test(popupwindow popupwindow.cpp)
|
||||
qs_test(transformwatcher transformwatcher.cpp)
|
||||
qs_test(ringbuffer ringbuf.cpp)
|
||||
|
|
|
|||
|
|
@ -1,180 +0,0 @@
|
|||
#include "popupwindow.hpp"
|
||||
|
||||
#include <qquickwindow.h>
|
||||
#include <qsignalspy.h>
|
||||
#include <qtest.h>
|
||||
#include <qtestcase.h>
|
||||
#include <qwindow.h>
|
||||
|
||||
#include "../popupwindow.hpp"
|
||||
#include "../proxywindow.hpp"
|
||||
|
||||
void TestPopupWindow::initiallyVisible() { // NOLINT
|
||||
auto parent = ProxyWindowBase();
|
||||
auto popup = ProxyPopupWindow();
|
||||
|
||||
popup.setParentWindow(&parent);
|
||||
popup.setVisible(true);
|
||||
|
||||
parent.reload();
|
||||
popup.reload();
|
||||
|
||||
QVERIFY(popup.isVisible());
|
||||
QVERIFY(popup.backingWindow()->isVisible());
|
||||
QCOMPARE(popup.backingWindow()->transientParent(), parent.backingWindow());
|
||||
}
|
||||
|
||||
void TestPopupWindow::reloadReparent() { // NOLINT
|
||||
// first generation
|
||||
auto parent = ProxyWindowBase();
|
||||
auto popup = ProxyPopupWindow();
|
||||
|
||||
auto* win2 = new QQuickWindow();
|
||||
win2->setVisible(true);
|
||||
|
||||
parent.setVisible(true);
|
||||
popup.setParentWindow(&parent);
|
||||
popup.setVisible(true);
|
||||
|
||||
parent.reload();
|
||||
popup.reload();
|
||||
|
||||
// second generation
|
||||
auto newParent = ProxyWindowBase();
|
||||
auto newPopup = ProxyPopupWindow();
|
||||
|
||||
newPopup.setParentWindow(&newParent);
|
||||
newPopup.setVisible(true);
|
||||
|
||||
auto* oldWindow = popup.backingWindow();
|
||||
auto* oldTransientParent = oldWindow->transientParent();
|
||||
|
||||
auto spy = QSignalSpy(oldWindow, &QWindow::visibleChanged);
|
||||
|
||||
newParent.reload(&parent);
|
||||
newPopup.reload(&popup);
|
||||
|
||||
QVERIFY(newPopup.isVisible());
|
||||
QVERIFY(newPopup.backingWindow()->isVisible());
|
||||
QCOMPARE(newPopup.backingWindow()->transientParent(), oldTransientParent);
|
||||
QCOMPARE(newPopup.backingWindow()->transientParent(), newParent.backingWindow());
|
||||
QCOMPARE(spy.length(), 0);
|
||||
}
|
||||
|
||||
void TestPopupWindow::reloadUnparent() { // NOLINT
|
||||
// first generation
|
||||
auto parent = ProxyWindowBase();
|
||||
auto popup = ProxyPopupWindow();
|
||||
|
||||
popup.setParentWindow(&parent);
|
||||
popup.setVisible(true);
|
||||
|
||||
parent.reload();
|
||||
popup.reload();
|
||||
|
||||
// second generation
|
||||
auto newPopup = ProxyPopupWindow();
|
||||
|
||||
// parent not set
|
||||
newPopup.setVisible(true);
|
||||
newPopup.reload(&popup);
|
||||
|
||||
QVERIFY(!newPopup.isVisible());
|
||||
QVERIFY(!newPopup.backingWindow()->isVisible());
|
||||
QCOMPARE(newPopup.backingWindow()->transientParent(), nullptr);
|
||||
}
|
||||
|
||||
void TestPopupWindow::invisibleWithoutParent() { // NOLINT
|
||||
auto popup = ProxyPopupWindow();
|
||||
|
||||
popup.setVisible(true);
|
||||
popup.reload();
|
||||
|
||||
QVERIFY(!popup.isVisible());
|
||||
}
|
||||
|
||||
void TestPopupWindow::moveWithParent() { // NOLINT
|
||||
auto parent = ProxyWindowBase();
|
||||
auto popup = ProxyPopupWindow();
|
||||
|
||||
popup.setParentWindow(&parent);
|
||||
popup.setRelativeX(10);
|
||||
popup.setRelativeY(10);
|
||||
popup.setVisible(true);
|
||||
|
||||
parent.reload();
|
||||
popup.reload();
|
||||
|
||||
QCOMPARE(popup.x(), parent.x() + 10);
|
||||
QCOMPARE(popup.y(), parent.y() + 10);
|
||||
|
||||
parent.backingWindow()->setX(10);
|
||||
parent.backingWindow()->setY(10);
|
||||
|
||||
QCOMPARE(popup.x(), parent.x() + 10);
|
||||
QCOMPARE(popup.y(), parent.y() + 10);
|
||||
}
|
||||
|
||||
void TestPopupWindow::attachParentLate() { // NOLINT
|
||||
auto parent = ProxyWindowBase();
|
||||
auto popup = ProxyPopupWindow();
|
||||
|
||||
popup.setVisible(true);
|
||||
|
||||
parent.reload();
|
||||
popup.reload();
|
||||
|
||||
QVERIFY(!popup.isVisible());
|
||||
|
||||
popup.setParentWindow(&parent);
|
||||
QVERIFY(popup.isVisible());
|
||||
QVERIFY(popup.backingWindow()->isVisible());
|
||||
QCOMPARE(popup.backingWindow()->transientParent(), parent.backingWindow());
|
||||
}
|
||||
|
||||
void TestPopupWindow::reparentLate() { // NOLINT
|
||||
auto parent = ProxyWindowBase();
|
||||
auto popup = ProxyPopupWindow();
|
||||
|
||||
popup.setParentWindow(&parent);
|
||||
popup.setVisible(true);
|
||||
|
||||
parent.reload();
|
||||
popup.reload();
|
||||
|
||||
QCOMPARE(popup.x(), parent.x());
|
||||
QCOMPARE(popup.y(), parent.y());
|
||||
|
||||
auto parent2 = ProxyWindowBase();
|
||||
parent2.reload();
|
||||
|
||||
parent2.backingWindow()->setX(10);
|
||||
parent2.backingWindow()->setY(10);
|
||||
|
||||
popup.setParentWindow(&parent2);
|
||||
QVERIFY(popup.isVisible());
|
||||
QVERIFY(popup.backingWindow()->isVisible());
|
||||
QCOMPARE(popup.backingWindow()->transientParent(), parent2.backingWindow());
|
||||
QCOMPARE(popup.x(), parent2.x());
|
||||
QCOMPARE(popup.y(), parent2.y());
|
||||
}
|
||||
|
||||
void TestPopupWindow::xMigrationFix() { // NOLINT
|
||||
auto parent = ProxyWindowBase();
|
||||
auto popup = ProxyPopupWindow();
|
||||
|
||||
popup.setParentWindow(&parent);
|
||||
popup.setVisible(true);
|
||||
|
||||
parent.reload();
|
||||
popup.reload();
|
||||
|
||||
QCOMPARE(popup.x(), parent.x());
|
||||
|
||||
popup.setVisible(false);
|
||||
popup.setVisible(true);
|
||||
|
||||
QCOMPARE(popup.x(), parent.x());
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestPopupWindow);
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class TestPopupWindow: public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
private slots:
|
||||
void initiallyVisible();
|
||||
void reloadReparent();
|
||||
void reloadUnparent();
|
||||
void invisibleWithoutParent();
|
||||
void moveWithParent();
|
||||
void attachParentLate();
|
||||
void reparentLate();
|
||||
void xMigrationFix();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue