2020-08-02 22:22:19 +00:00
/*
KWin - the KDE window manager
This file is part of the KDE project .
2016-04-11 15:24:08 +00:00
2020-08-02 22:22:19 +00:00
SPDX - FileCopyrightText : 2016 Martin Gräßlin < mgraesslin @ kde . org >
2016-04-11 15:24:08 +00:00
2020-08-02 22:22:19 +00:00
SPDX - License - Identifier : GPL - 2.0 - or - later
*/
2016-04-11 15:24:08 +00:00
# include "kwin_wayland_test.h"
2022-03-23 10:13:38 +00:00
2016-04-11 15:24:08 +00:00
# include "cursor.h"
2016-07-13 05:59:18 +00:00
# include "deleted.h"
2022-04-14 12:33:28 +00:00
# include "output.h"
2022-03-23 10:13:38 +00:00
# include "platform.h"
2016-04-11 15:24:08 +00:00
# include "screenedge.h"
# include "screens.h"
2021-08-21 17:46:51 +00:00
# include "virtualdesktops.h"
2016-04-11 15:24:08 +00:00
# include "wayland_server.h"
# include "workspace.h"
2022-04-22 17:54:31 +00:00
# include "x11window.h"
2016-04-11 15:24:08 +00:00
# include <kwineffects.h>
# include <KWayland/Client/compositor.h>
2016-06-09 08:01:05 +00:00
# include <KWayland/Client/plasmashell.h>
2016-04-11 15:24:08 +00:00
# include <KWayland/Client/surface.h>
# include <KDecoration2/Decoration>
# include <netwm.h>
# include <xcb/xcb_icccm.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral ( " wayland_test_kwin_struts-0 " ) ;
class StrutsTest : public QObject
{
Q_OBJECT
private Q_SLOTS :
void initTestCase ( ) ;
void init ( ) ;
void cleanup ( ) ;
2016-06-09 08:01:05 +00:00
void testWaylandStruts_data ( ) ;
void testWaylandStruts ( ) ;
2016-06-10 08:50:02 +00:00
void testMoveWaylandPanel ( ) ;
2016-06-28 11:12:20 +00:00
void testWaylandMobilePanel ( ) ;
2016-04-11 15:24:08 +00:00
void testX11Struts_data ( ) ;
void testX11Struts ( ) ;
2016-06-02 07:29:53 +00:00
void test363804 ( ) ;
2016-07-13 05:59:18 +00:00
void testLeftScreenSmallerBottomAligned ( ) ;
2017-07-08 06:41:16 +00:00
void testWindowMoveWithPanelBetweenScreens ( ) ;
2016-04-11 15:24:08 +00:00
private :
KWayland : : Client : : Compositor * m_compositor = nullptr ;
2016-06-09 08:01:05 +00:00
KWayland : : Client : : PlasmaShell * m_plasmaShell = nullptr ;
2016-04-11 15:24:08 +00:00
} ;
void StrutsTest : : initTestCase ( )
{
2022-04-22 17:39:12 +00:00
qRegisterMetaType < KWin : : Window * > ( ) ;
2022-03-23 10:13:38 +00:00
qRegisterMetaType < KWin : : Deleted * > ( ) ;
2020-07-07 09:32:29 +00:00
QSignalSpy applicationStartedSpy ( kwinApp ( ) , & Application : : started ) ;
QVERIFY ( applicationStartedSpy . isValid ( ) ) ;
2016-04-11 15:24:08 +00:00
kwinApp ( ) - > platform ( ) - > setInitialWindowSize ( QSize ( 1280 , 1024 ) ) ;
2020-12-09 13:06:15 +00:00
QVERIFY ( waylandServer ( ) - > init ( s_socketName ) ) ;
2019-08-26 21:16:53 +00:00
QMetaObject : : invokeMethod ( kwinApp ( ) - > platform ( ) , " setVirtualOutputs " , Qt : : DirectConnection , Q_ARG ( int , 2 ) ) ;
2016-04-11 15:24:08 +00:00
2017-08-08 17:56:24 +00:00
// set custom config which disables the Outline
KSharedConfig : : Ptr config = KSharedConfig : : openConfig ( QString ( ) , KConfig : : SimpleConfig ) ;
KConfigGroup group = config - > group ( " Outline " ) ;
group . writeEntry ( QStringLiteral ( " QmlPath " ) , QString ( " /does/not/exist.qml " ) ) ;
group . sync ( ) ;
kwinApp ( ) - > setConfig ( config ) ;
2016-04-11 15:24:08 +00:00
kwinApp ( ) - > start ( ) ;
2020-07-07 09:32:29 +00:00
QVERIFY ( applicationStartedSpy . wait ( ) ) ;
2021-08-31 07:03:05 +00:00
const auto outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
QCOMPARE ( outputs . count ( ) , 2 ) ;
QCOMPARE ( outputs [ 0 ] - > geometry ( ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( outputs [ 1 ] - > geometry ( ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
2016-04-11 15:24:08 +00:00
setenv ( " QT_QPA_PLATFORM " , " wayland " , true ) ;
2021-05-08 00:08:22 +00:00
Test : : initWaylandWorkspace ( ) ;
2016-04-11 15:24:08 +00:00
}
void StrutsTest : : init ( )
{
2016-12-03 13:31:14 +00:00
QVERIFY ( Test : : setupWaylandConnection ( Test : : AdditionalWaylandInterface : : PlasmaShell ) ) ;
2016-06-30 11:32:54 +00:00
m_compositor = Test : : waylandCompositor ( ) ;
m_plasmaShell = Test : : waylandPlasmaShell ( ) ;
2016-04-11 15:24:08 +00:00
2021-08-28 18:58:29 +00:00
workspace ( ) - > setActiveOutput ( QPoint ( 640 , 512 ) ) ;
2020-04-02 16:18:01 +00:00
Cursors : : self ( ) - > mouse ( ) - > setPos ( QPoint ( 640 , 512 ) ) ;
2022-04-23 08:33:23 +00:00
QVERIFY ( waylandServer ( ) - > windows ( ) . isEmpty ( ) ) ;
2016-04-11 15:24:08 +00:00
}
void StrutsTest : : cleanup ( )
{
2016-06-30 11:32:54 +00:00
Test : : destroyWaylandConnection ( ) ;
2016-06-09 08:01:05 +00:00
}
void StrutsTest : : testWaylandStruts_data ( )
{
QTest : : addColumn < QVector < QRect > > ( " windowGeometries " ) ;
QTest : : addColumn < QRect > ( " screen0Maximized " ) ;
QTest : : addColumn < QRect > ( " screen1Maximized " ) ;
QTest : : addColumn < QRect > ( " workArea " ) ;
2017-07-10 15:15:52 +00:00
QTest : : addColumn < QRegion > ( " restrictedMoveArea " ) ;
2016-06-09 08:01:05 +00:00
2022-03-23 10:13:38 +00:00
QTest : : newRow ( " bottom/0 " ) < < QVector < QRect > { QRect ( 0 , 992 , 1280 , 32 ) } < < QRect ( 0 , 0 , 1280 , 992 ) < < QRect ( 1280 , 0 , 1280 , 1024 ) < < QRect ( 0 , 0 , 2560 , 992 ) < < QRegion ( 0 , 992 , 1280 , 32 ) ;
QTest : : newRow ( " bottom/1 " ) < < QVector < QRect > { QRect ( 1280 , 992 , 1280 , 32 ) } < < QRect ( 0 , 0 , 1280 , 1024 ) < < QRect ( 1280 , 0 , 1280 , 992 ) < < QRect ( 0 , 0 , 2560 , 992 ) < < QRegion ( 1280 , 992 , 1280 , 32 ) ;
QTest : : newRow ( " top/0 " ) < < QVector < QRect > { QRect ( 0 , 0 , 1280 , 32 ) } < < QRect ( 0 , 32 , 1280 , 992 ) < < QRect ( 1280 , 0 , 1280 , 1024 ) < < QRect ( 0 , 32 , 2560 , 992 ) < < QRegion ( 0 , 0 , 1280 , 32 ) ;
QTest : : newRow ( " top/1 " ) < < QVector < QRect > { QRect ( 1280 , 0 , 1280 , 32 ) } < < QRect ( 0 , 0 , 1280 , 1024 ) < < QRect ( 1280 , 32 , 1280 , 992 ) < < QRect ( 0 , 32 , 2560 , 992 ) < < QRegion ( 1280 , 0 , 1280 , 32 ) ;
QTest : : newRow ( " left/0 " ) < < QVector < QRect > { QRect ( 0 , 0 , 32 , 1024 ) } < < QRect ( 32 , 0 , 1248 , 1024 ) < < QRect ( 1280 , 0 , 1280 , 1024 ) < < QRect ( 32 , 0 , 2528 , 1024 ) < < QRegion ( 0 , 0 , 32 , 1024 ) ;
QTest : : newRow ( " left/1 " ) < < QVector < QRect > { QRect ( 1280 , 0 , 32 , 1024 ) } < < QRect ( 0 , 0 , 1280 , 1024 ) < < QRect ( 1312 , 0 , 1248 , 1024 ) < < QRect ( 0 , 0 , 2560 , 1024 ) < < QRegion ( 1280 , 0 , 32 , 1024 ) ;
QTest : : newRow ( " right/0 " ) < < QVector < QRect > { QRect ( 1248 , 0 , 32 , 1024 ) } < < QRect ( 0 , 0 , 1248 , 1024 ) < < QRect ( 1280 , 0 , 1280 , 1024 ) < < QRect ( 0 , 0 , 2560 , 1024 ) < < QRegion ( 1248 , 0 , 32 , 1024 ) ;
QTest : : newRow ( " right/1 " ) < < QVector < QRect > { QRect ( 2528 , 0 , 32 , 1024 ) } < < QRect ( 0 , 0 , 1280 , 1024 ) < < QRect ( 1280 , 0 , 1248 , 1024 ) < < QRect ( 0 , 0 , 2528 , 1024 ) < < QRegion ( 2528 , 0 , 32 , 1024 ) ;
2016-06-09 08:01:05 +00:00
// same with partial panels not covering the whole area
2022-03-23 10:13:38 +00:00
QTest : : newRow ( " part bottom/0 " ) < < QVector < QRect > { QRect ( 100 , 992 , 1080 , 32 ) } < < QRect ( 0 , 0 , 1280 , 992 ) < < QRect ( 1280 , 0 , 1280 , 1024 ) < < QRect ( 0 , 0 , 2560 , 992 ) < < QRegion ( 100 , 992 , 1080 , 32 ) ;
QTest : : newRow ( " part bottom/1 " ) < < QVector < QRect > { QRect ( 1380 , 992 , 1080 , 32 ) } < < QRect ( 0 , 0 , 1280 , 1024 ) < < QRect ( 1280 , 0 , 1280 , 992 ) < < QRect ( 0 , 0 , 2560 , 992 ) < < QRegion ( 1380 , 992 , 1080 , 32 ) ;
QTest : : newRow ( " part top/0 " ) < < QVector < QRect > { QRect ( 100 , 0 , 1080 , 32 ) } < < QRect ( 0 , 32 , 1280 , 992 ) < < QRect ( 1280 , 0 , 1280 , 1024 ) < < QRect ( 0 , 32 , 2560 , 992 ) < < QRegion ( 100 , 0 , 1080 , 32 ) ;
QTest : : newRow ( " part top/1 " ) < < QVector < QRect > { QRect ( 1380 , 0 , 1080 , 32 ) } < < QRect ( 0 , 0 , 1280 , 1024 ) < < QRect ( 1280 , 32 , 1280 , 992 ) < < QRect ( 0 , 32 , 2560 , 992 ) < < QRegion ( 1380 , 0 , 1080 , 32 ) ;
QTest : : newRow ( " part left/0 " ) < < QVector < QRect > { QRect ( 0 , 100 , 32 , 824 ) } < < QRect ( 32 , 0 , 1248 , 1024 ) < < QRect ( 1280 , 0 , 1280 , 1024 ) < < QRect ( 32 , 0 , 2528 , 1024 ) < < QRegion ( 0 , 100 , 32 , 824 ) ;
QTest : : newRow ( " part left/1 " ) < < QVector < QRect > { QRect ( 1280 , 100 , 32 , 824 ) } < < QRect ( 0 , 0 , 1280 , 1024 ) < < QRect ( 1312 , 0 , 1248 , 1024 ) < < QRect ( 0 , 0 , 2560 , 1024 ) < < QRegion ( 1280 , 100 , 32 , 824 ) ;
QTest : : newRow ( " part right/0 " ) < < QVector < QRect > { QRect ( 1248 , 100 , 32 , 824 ) } < < QRect ( 0 , 0 , 1248 , 1024 ) < < QRect ( 1280 , 0 , 1280 , 1024 ) < < QRect ( 0 , 0 , 2560 , 1024 ) < < QRegion ( 1248 , 100 , 32 , 824 ) ;
QTest : : newRow ( " part right/1 " ) < < QVector < QRect > { QRect ( 2528 , 100 , 32 , 824 ) } < < QRect ( 0 , 0 , 1280 , 1024 ) < < QRect ( 1280 , 0 , 1248 , 1024 ) < < QRect ( 0 , 0 , 2528 , 1024 ) < < QRegion ( 2528 , 100 , 32 , 824 ) ;
2016-06-09 08:01:05 +00:00
// multiple panels
2017-07-10 15:15:52 +00:00
QTest : : newRow ( " two bottom panels " ) < < QVector < QRect > { QRect ( 100 , 992 , 1080 , 32 ) , QRect ( 1380 , 984 , 1080 , 40 ) } < < QRect ( 0 , 0 , 1280 , 992 ) < < QRect ( 1280 , 0 , 1280 , 984 ) < < QRect ( 0 , 0 , 2560 , 984 ) < < QRegion ( 100 , 992 , 1080 , 32 ) . united ( QRegion ( 1380 , 984 , 1080 , 40 ) ) ;
QTest : : newRow ( " two left panels " ) < < QVector < QRect > { QRect ( 0 , 10 , 32 , 390 ) , QRect ( 0 , 450 , 40 , 100 ) } < < QRect ( 40 , 0 , 1240 , 1024 ) < < QRect ( 1280 , 0 , 1280 , 1024 ) < < QRect ( 40 , 0 , 2520 , 1024 ) < < QRegion ( 0 , 10 , 32 , 390 ) . united ( QRegion ( 0 , 450 , 40 , 100 ) ) ;
2016-06-09 08:01:05 +00:00
}
void StrutsTest : : testWaylandStruts ( )
{
// this test verifies that struts on Wayland panels are handled correctly
using namespace KWayland : : Client ;
2021-08-21 17:46:51 +00:00
VirtualDesktop * desktop = VirtualDesktopManager : : self ( ) - > currentDesktop ( ) ;
2022-04-14 12:33:28 +00:00
const QVector < Output * > outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
2021-08-21 17:46:51 +00:00
2016-06-09 08:01:05 +00:00
// no, struts yet
2022-04-23 08:33:23 +00:00
QVERIFY ( waylandServer ( ) - > windows ( ) . isEmpty ( ) ) ;
2016-06-09 08:01:05 +00:00
// first screen
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
2016-06-09 08:01:05 +00:00
// second screen
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
2016-06-09 08:01:05 +00:00
// combined
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1024 ) ) ;
2021-08-21 17:46:51 +00:00
QCOMPARE ( workspace ( ) - > restrictedMoveArea ( desktop ) , QRegion ( ) ) ;
2016-06-09 08:01:05 +00:00
QFETCH ( QVector < QRect > , windowGeometries ) ;
// create the panels
2022-04-23 19:51:16 +00:00
QHash < KWayland : : Client : : Surface * , Window * > windows ;
2016-06-09 08:01:05 +00:00
for ( auto it = windowGeometries . constBegin ( ) , end = windowGeometries . constEnd ( ) ; it ! = end ; it + + ) {
const QRect windowGeometry = * it ;
2021-09-03 17:54:03 +00:00
KWayland : : Client : : Surface * surface = Test : : createSurface ( m_compositor ) ;
2021-12-09 07:47:55 +00:00
Test : : XdgToplevel * shellSurface = Test : : createXdgToplevelSurface ( surface , Test : : CreationSetup : : CreateOnly , surface ) ;
2016-06-09 08:01:05 +00:00
PlasmaShellSurface * plasmaSurface = m_plasmaShell - > createSurface ( surface , surface ) ;
plasmaSurface - > setPosition ( windowGeometry . topLeft ( ) ) ;
plasmaSurface - > setRole ( PlasmaShellSurface : : Role : : Panel ) ;
2021-05-11 05:26:51 +00:00
QSignalSpy configureRequestedSpy ( shellSurface - > xdgSurface ( ) , & Test : : XdgSurface : : configureRequested ) ;
QVERIFY ( configureRequestedSpy . isValid ( ) ) ;
2021-09-03 17:54:03 +00:00
surface - > commit ( KWayland : : Client : : Surface : : CommitFlag : : None ) ;
2021-05-11 05:26:51 +00:00
QVERIFY ( configureRequestedSpy . wait ( ) ) ;
2016-06-09 08:01:05 +00:00
// map the window
2021-05-11 05:26:51 +00:00
shellSurface - > xdgSurface ( ) - > ack_configure ( configureRequestedSpy . last ( ) . first ( ) . toUInt ( ) ) ;
2022-04-23 19:51:16 +00:00
auto window = Test : : renderAndWaitForShown ( surface , windowGeometry . size ( ) , Qt : : red , QImage : : Format_RGB32 ) ;
QVERIFY ( window ) ;
QVERIFY ( ! window - > isActive ( ) ) ;
QCOMPARE ( window - > frameGeometry ( ) , windowGeometry ) ;
QVERIFY ( window - > isDock ( ) ) ;
QVERIFY ( window - > hasStrut ( ) ) ;
windows . insert ( surface , window ) ;
2016-06-09 08:01:05 +00:00
}
// some props are independent of struts - those first
// screen 0
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
2016-06-09 08:01:05 +00:00
// screen 1
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
2016-06-09 08:01:05 +00:00
// combined
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( FullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1024 ) ) ;
2016-06-09 08:01:05 +00:00
// now verify the actual updated client areas
2021-08-25 15:12:50 +00:00
QTEST ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , " screen0Maximized " ) ;
QTEST ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , " screen0Maximized " ) ;
QTEST ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , " screen1Maximized " ) ;
QTEST ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , " screen1Maximized " ) ;
QTEST ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , " workArea " ) ;
2021-08-21 17:46:51 +00:00
QTEST ( workspace ( ) - > restrictedMoveArea ( desktop ) , " restrictedMoveArea " ) ;
2016-06-30 11:32:54 +00:00
// delete all surfaces
2022-04-23 19:51:16 +00:00
for ( auto it = windows . begin ( ) ; it ! = windows . end ( ) ; it + + ) {
2016-06-30 11:32:54 +00:00
QSignalSpy destroyedSpy ( it . value ( ) , & QObject : : destroyed ) ;
QVERIFY ( destroyedSpy . isValid ( ) ) ;
delete it . key ( ) ;
QVERIFY ( destroyedSpy . wait ( ) ) ;
}
2021-08-21 17:46:51 +00:00
QCOMPARE ( workspace ( ) - > restrictedMoveArea ( desktop ) , QRegion ( ) ) ;
2016-04-11 15:24:08 +00:00
}
2016-06-10 08:50:02 +00:00
void StrutsTest : : testMoveWaylandPanel ( )
{
2021-08-25 15:12:50 +00:00
VirtualDesktop * desktop = VirtualDesktopManager : : self ( ) - > currentDesktop ( ) ;
2022-04-14 12:33:28 +00:00
const QVector < Output * > outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
2021-08-25 15:12:50 +00:00
2016-06-10 08:50:02 +00:00
// this test verifies that repositioning a Wayland panel updates the client area
using namespace KWayland : : Client ;
const QRect windowGeometry ( 0 , 1000 , 1280 , 24 ) ;
2021-09-03 17:54:03 +00:00
QScopedPointer < KWayland : : Client : : Surface > surface ( Test : : createSurface ( ) ) ;
2021-12-09 07:47:55 +00:00
QScopedPointer < Test : : XdgToplevel > shellSurface ( Test : : createXdgToplevelSurface ( surface . data ( ) , Test : : CreationSetup : : CreateOnly ) ) ;
2016-06-10 08:50:02 +00:00
QScopedPointer < PlasmaShellSurface > plasmaSurface ( m_plasmaShell - > createSurface ( surface . data ( ) ) ) ;
plasmaSurface - > setPosition ( windowGeometry . topLeft ( ) ) ;
plasmaSurface - > setRole ( PlasmaShellSurface : : Role : : Panel ) ;
2021-05-11 05:26:51 +00:00
QSignalSpy configureRequestedSpy ( shellSurface - > xdgSurface ( ) , & Test : : XdgSurface : : configureRequested ) ;
QVERIFY ( configureRequestedSpy . isValid ( ) ) ;
2021-09-03 17:54:03 +00:00
surface - > commit ( KWayland : : Client : : Surface : : CommitFlag : : None ) ;
2021-05-11 05:26:51 +00:00
QVERIFY ( configureRequestedSpy . wait ( ) ) ;
2016-06-10 08:50:02 +00:00
// map the window
2021-05-11 05:26:51 +00:00
shellSurface - > xdgSurface ( ) - > ack_configure ( configureRequestedSpy . last ( ) . first ( ) . toUInt ( ) ) ;
2022-04-23 19:51:16 +00:00
auto window = Test : : renderAndWaitForShown ( surface . data ( ) , windowGeometry . size ( ) , Qt : : red , QImage : : Format_RGB32 ) ;
QVERIFY ( window ) ;
QVERIFY ( ! window - > isActive ( ) ) ;
QCOMPARE ( window - > frameGeometry ( ) , windowGeometry ) ;
QVERIFY ( window - > isDock ( ) ) ;
QVERIFY ( window - > hasStrut ( ) ) ;
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1000 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1000 ) ) ;
2022-03-23 10:13:38 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1000 ) ) ;
2016-06-10 08:50:02 +00:00
2022-04-23 19:51:16 +00:00
QSignalSpy frameGeometryChangedSpy ( window , & Window : : frameGeometryChanged ) ;
2020-02-05 09:28:50 +00:00
QVERIFY ( frameGeometryChangedSpy . isValid ( ) ) ;
2016-06-10 08:50:02 +00:00
plasmaSurface - > setPosition ( QPoint ( 1280 , 1000 ) ) ;
2020-02-05 09:28:50 +00:00
QVERIFY ( frameGeometryChangedSpy . wait ( ) ) ;
2022-04-23 19:51:16 +00:00
QCOMPARE ( window - > frameGeometry ( ) , QRect ( 1280 , 1000 , 1280 , 24 ) ) ;
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
2022-03-23 10:13:38 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1000 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1000 ) ) ;
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1000 ) ) ;
2016-06-10 08:50:02 +00:00
}
2016-06-28 11:12:20 +00:00
void StrutsTest : : testWaylandMobilePanel ( )
{
using namespace KWayland : : Client ;
2021-08-25 15:12:50 +00:00
VirtualDesktop * desktop = VirtualDesktopManager : : self ( ) - > currentDesktop ( ) ;
2022-04-14 12:33:28 +00:00
const QVector < Output * > outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
2021-08-25 15:12:50 +00:00
2022-03-23 10:13:38 +00:00
// First enable maxmizing policy
2016-06-28 11:12:20 +00:00
KConfigGroup group = kwinApp ( ) - > config ( ) - > group ( " Windows " ) ;
group . writeEntry ( " Placement " , " Maximizing " ) ;
group . sync ( ) ;
workspace ( ) - > slotReconfigure ( ) ;
// create first top panel
const QRect windowGeometry ( 0 , 0 , 1280 , 60 ) ;
2021-09-03 17:54:03 +00:00
QScopedPointer < KWayland : : Client : : Surface > surface ( Test : : createSurface ( ) ) ;
2021-12-09 07:47:55 +00:00
QScopedPointer < Test : : XdgToplevel > shellSurface ( Test : : createXdgToplevelSurface ( surface . data ( ) , Test : : CreationSetup : : CreateOnly ) ) ;
2016-06-28 11:12:20 +00:00
QScopedPointer < PlasmaShellSurface > plasmaSurface ( m_plasmaShell - > createSurface ( surface . data ( ) ) ) ;
plasmaSurface - > setPosition ( windowGeometry . topLeft ( ) ) ;
plasmaSurface - > setRole ( PlasmaShellSurface : : Role : : Panel ) ;
2021-05-11 05:26:51 +00:00
QSignalSpy configureRequestedSpy ( shellSurface - > xdgSurface ( ) , & Test : : XdgSurface : : configureRequested ) ;
QVERIFY ( configureRequestedSpy . isValid ( ) ) ;
2021-09-03 17:54:03 +00:00
surface - > commit ( KWayland : : Client : : Surface : : CommitFlag : : None ) ;
2021-05-11 05:26:51 +00:00
QVERIFY ( configureRequestedSpy . wait ( ) ) ;
// map the window
shellSurface - > xdgSurface ( ) - > ack_configure ( configureRequestedSpy . last ( ) . first ( ) . toUInt ( ) ) ;
2022-04-23 19:51:16 +00:00
auto window = Test : : renderAndWaitForShown ( surface . data ( ) , windowGeometry . size ( ) , Qt : : red , QImage : : Format_RGB32 ) ;
QVERIFY ( window ) ;
QVERIFY ( ! window - > isActive ( ) ) ;
QCOMPARE ( window - > frameGeometry ( ) , windowGeometry ) ;
QVERIFY ( window - > isDock ( ) ) ;
QVERIFY ( window - > hasStrut ( ) ) ;
2016-06-28 11:12:20 +00:00
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 60 , 1280 , 964 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 60 , 1280 , 964 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 60 , 2560 , 964 ) ) ;
2016-06-28 11:12:20 +00:00
// create another bottom panel
const QRect windowGeometry2 ( 0 , 874 , 1280 , 150 ) ;
2021-09-03 17:54:03 +00:00
QScopedPointer < KWayland : : Client : : Surface > surface2 ( Test : : createSurface ( ) ) ;
2021-12-09 07:47:55 +00:00
QScopedPointer < Test : : XdgToplevel > shellSurface2 ( Test : : createXdgToplevelSurface ( surface2 . data ( ) , Test : : CreationSetup : : CreateOnly ) ) ;
2016-06-28 11:12:20 +00:00
QScopedPointer < PlasmaShellSurface > plasmaSurface2 ( m_plasmaShell - > createSurface ( surface2 . data ( ) ) ) ;
plasmaSurface2 - > setPosition ( windowGeometry2 . topLeft ( ) ) ;
plasmaSurface2 - > setRole ( PlasmaShellSurface : : Role : : Panel ) ;
2021-05-11 05:26:51 +00:00
QSignalSpy configureRequestedSpy2 ( shellSurface2 - > xdgSurface ( ) , & Test : : XdgSurface : : configureRequested ) ;
QVERIFY ( configureRequestedSpy2 . isValid ( ) ) ;
2021-09-03 17:54:03 +00:00
surface2 - > commit ( KWayland : : Client : : Surface : : CommitFlag : : None ) ;
2021-05-11 05:26:51 +00:00
QVERIFY ( configureRequestedSpy2 . wait ( ) ) ;
// map the window
shellSurface2 - > xdgSurface ( ) - > ack_configure ( configureRequestedSpy2 . last ( ) . first ( ) . toUInt ( ) ) ;
2016-07-01 07:54:44 +00:00
auto c1 = Test : : renderAndWaitForShown ( surface2 . data ( ) , windowGeometry2 . size ( ) , Qt : : blue , QImage : : Format_RGB32 ) ;
2016-06-28 11:12:20 +00:00
QVERIFY ( c1 ) ;
QVERIFY ( ! c1 - > isActive ( ) ) ;
2019-09-27 10:01:10 +00:00
QCOMPARE ( c1 - > frameGeometry ( ) , windowGeometry2 ) ;
2016-06-28 11:12:20 +00:00
QVERIFY ( c1 - > isDock ( ) ) ;
QVERIFY ( c1 - > hasStrut ( ) ) ;
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 60 , 1280 , 814 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 60 , 1280 , 814 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 60 , 2560 , 814 ) ) ;
2019-08-27 15:01:14 +00:00
2022-04-23 19:51:16 +00:00
// Destroy test windows.
2019-08-27 15:01:14 +00:00
shellSurface . reset ( ) ;
2022-04-23 19:51:16 +00:00
QVERIFY ( Test : : waitForWindowDestroyed ( window ) ) ;
2019-08-27 15:01:14 +00:00
shellSurface2 . reset ( ) ;
QVERIFY ( Test : : waitForWindowDestroyed ( c1 ) ) ;
2016-06-28 11:12:20 +00:00
}
2016-04-11 15:24:08 +00:00
void StrutsTest : : testX11Struts_data ( )
{
QTest : : addColumn < QRect > ( " windowGeometry " ) ;
QTest : : addColumn < int > ( " leftStrut " ) ;
QTest : : addColumn < int > ( " rightStrut " ) ;
QTest : : addColumn < int > ( " topStrut " ) ;
QTest : : addColumn < int > ( " bottomStrut " ) ;
QTest : : addColumn < int > ( " leftStrutStart " ) ;
QTest : : addColumn < int > ( " leftStrutEnd " ) ;
QTest : : addColumn < int > ( " rightStrutStart " ) ;
QTest : : addColumn < int > ( " rightStrutEnd " ) ;
QTest : : addColumn < int > ( " topStrutStart " ) ;
QTest : : addColumn < int > ( " topStrutEnd " ) ;
QTest : : addColumn < int > ( " bottomStrutStart " ) ;
QTest : : addColumn < int > ( " bottomStrutEnd " ) ;
QTest : : addColumn < QRect > ( " screen0Maximized " ) ;
QTest : : addColumn < QRect > ( " screen1Maximized " ) ;
QTest : : addColumn < QRect > ( " workArea " ) ;
2017-07-08 06:41:16 +00:00
QTest : : addColumn < QRegion > ( " restrictedMoveArea " ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " bottom panel/no strut " ) < < QRect ( 0 , 980 , 1280 , 44 )
< < 0 < < 0 < < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
2017-07-08 06:41:16 +00:00
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " bottom panel/strut " ) < < QRect ( 0 , 980 , 1280 , 44 )
< < 0 < < 0 < < 0 < < 44
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 1279
< < QRect ( 0 , 0 , 1280 , 980 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
2017-07-08 06:41:16 +00:00
< < QRect ( 0 , 0 , 2560 , 980 )
< < QRegion ( 0 , 980 , 1279 , 44 ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " top panel/no strut " ) < < QRect ( 0 , 0 , 1280 , 44 )
2022-03-23 10:13:38 +00:00
< < 0 < < 0 < < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " top panel/strut " ) < < QRect ( 0 , 0 , 1280 , 44 )
2022-03-23 10:13:38 +00:00
< < 0 < < 0 < < 44 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 1279
< < 0 < < 0
< < QRect ( 0 , 44 , 1280 , 980 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 44 , 2560 , 980 )
< < QRegion ( 0 , 0 , 1279 , 44 ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " left panel/no strut " ) < < QRect ( 0 , 0 , 60 , 1024 )
2022-03-23 10:13:38 +00:00
< < 0 < < 0 < < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " left panel/strut " ) < < QRect ( 0 , 0 , 60 , 1024 )
2022-03-23 10:13:38 +00:00
< < 60 < < 0 < < 0 < < 0
< < 0 < < 1023
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < QRect ( 60 , 0 , 1220 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 60 , 0 , 2500 , 1024 )
< < QRegion ( 0 , 0 , 60 , 1023 ) ;
2017-07-08 06:41:16 +00:00
QTest : : newRow ( " right panel/no strut " ) < < QRect ( 1220 , 0 , 60 , 1024 )
2022-03-23 10:13:38 +00:00
< < 0 < < 0 < < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( ) ;
2017-07-08 06:41:16 +00:00
QTest : : newRow ( " right panel/strut " ) < < QRect ( 1220 , 0 , 60 , 1024 )
2022-03-23 10:13:38 +00:00
< < 0 < < 1340 < < 0 < < 0
< < 0 < < 0
< < 0 < < 1023
< < 0 < < 0
< < 0 < < 0
< < QRect ( 0 , 0 , 1220 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( 1220 , 0 , 60 , 1023 ) ;
2016-04-11 15:24:08 +00:00
// second screen
QTest : : newRow ( " bottom panel 1/no strut " ) < < QRect ( 1280 , 980 , 1280 , 44 )
2022-03-23 10:13:38 +00:00
< < 0 < < 0 < < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " bottom panel 1/strut " ) < < QRect ( 1280 , 980 , 1280 , 44 )
2022-03-23 10:13:38 +00:00
< < 0 < < 0 < < 0 < < 44
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 1280 < < 2559
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 980 )
< < QRect ( 0 , 0 , 2560 , 980 )
< < QRegion ( 1280 , 980 , 1279 , 44 ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " top panel 1/no strut " ) < < QRect ( 1280 , 0 , 1280 , 44 )
2022-03-23 10:13:38 +00:00
< < 0 < < 0 < < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " top panel 1 /strut " ) < < QRect ( 1280 , 0 , 1280 , 44 )
2022-03-23 10:13:38 +00:00
< < 0 < < 0 < < 44 < < 0
< < 0 < < 0
< < 0 < < 0
< < 1280 < < 2559
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 44 , 1280 , 980 )
< < QRect ( 0 , 44 , 2560 , 980 )
< < QRegion ( 1280 , 0 , 1279 , 44 ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " left panel 1/no strut " ) < < QRect ( 1280 , 0 , 60 , 1024 )
< < 0 < < 0 < < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
2017-07-08 06:41:16 +00:00
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " left panel 1/strut " ) < < QRect ( 1280 , 0 , 60 , 1024 )
2022-03-23 10:13:38 +00:00
< < 1340 < < 0 < < 0 < < 0
< < 0 < < 1023
< < 0 < < 0
2016-04-11 15:24:08 +00:00
< < 0 < < 0
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
2022-03-23 10:13:38 +00:00
< < QRect ( 1340 , 0 , 1220 , 1024 )
2017-07-08 06:41:16 +00:00
< < QRect ( 0 , 0 , 2560 , 1024 )
2022-03-23 10:13:38 +00:00
< < QRegion ( 1280 , 0 , 60 , 1023 ) ;
// invalid struts
QTest : : newRow ( " bottom panel/ invalid strut " ) < < QRect ( 0 , 980 , 1280 , 44 )
< < 1280 < < 0 < < 0 < < 44
< < 980 < < 1024
< < 0 < < 0
< < 0 < < 0
< < 0 < < 1279
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( 0 , 980 , 1280 , 44 ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " top panel/ invalid strut " ) < < QRect ( 0 , 0 , 1280 , 44 )
2022-03-23 10:13:38 +00:00
< < 1280 < < 0 < < 44 < < 0
< < 0 < < 44
< < 0 < < 0
< < 0 < < 1279
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( 0 , 0 , 1280 , 44 ) ;
2016-04-11 15:24:08 +00:00
QTest : : newRow ( " top panel/invalid strut 2 " ) < < QRect ( 0 , 0 , 1280 , 44 )
2022-03-23 10:13:38 +00:00
< < 0 < < 0 < < 1024 < < 0
< < 0 < < 0
< < 0 < < 0
< < 0 < < 1279
< < 0 < < 0
< < QRect ( 0 , 0 , 1280 , 1024 )
< < QRect ( 1280 , 0 , 1280 , 1024 )
< < QRect ( 0 , 0 , 2560 , 1024 )
< < QRegion ( ) ;
2016-04-11 15:24:08 +00:00
}
2016-06-02 07:29:53 +00:00
struct XcbConnectionDeleter
{
static inline void cleanup ( xcb_connection_t * pointer )
{
xcb_disconnect ( pointer ) ;
}
} ;
2016-04-11 15:24:08 +00:00
void StrutsTest : : testX11Struts ( )
{
// this test verifies that struts are applied correctly for X11 windows
2021-08-21 17:46:51 +00:00
VirtualDesktop * desktop = VirtualDesktopManager : : self ( ) - > currentDesktop ( ) ;
2022-04-14 12:33:28 +00:00
const QVector < Output * > outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
2021-08-21 17:46:51 +00:00
2016-04-11 15:24:08 +00:00
// no, struts yet
// first screen
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
2016-04-11 15:24:08 +00:00
// second screen
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
2016-04-11 15:24:08 +00:00
// combined
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1024 ) ) ;
2021-08-21 17:46:51 +00:00
QCOMPARE ( workspace ( ) - > restrictedMoveArea ( desktop ) , QRegion ( ) ) ;
2016-04-11 15:24:08 +00:00
// create an xcb window
QScopedPointer < xcb_connection_t , XcbConnectionDeleter > c ( xcb_connect ( nullptr , nullptr ) ) ;
QVERIFY ( ! xcb_connection_has_error ( c . data ( ) ) ) ;
2022-04-23 19:51:16 +00:00
xcb_window_t windowId = xcb_generate_id ( c . data ( ) ) ;
2016-04-11 15:24:08 +00:00
QFETCH ( QRect , windowGeometry ) ;
2022-04-23 19:51:16 +00:00
xcb_create_window ( c . data ( ) , XCB_COPY_FROM_PARENT , windowId , rootWindow ( ) ,
2016-04-11 15:24:08 +00:00
windowGeometry . x ( ) ,
windowGeometry . y ( ) ,
windowGeometry . width ( ) ,
windowGeometry . height ( ) ,
0 , XCB_WINDOW_CLASS_INPUT_OUTPUT , XCB_COPY_FROM_PARENT , 0 , nullptr ) ;
xcb_size_hints_t hints ;
memset ( & hints , 0 , sizeof ( hints ) ) ;
xcb_icccm_size_hints_set_position ( & hints , 1 , windowGeometry . x ( ) , windowGeometry . y ( ) ) ;
xcb_icccm_size_hints_set_size ( & hints , 1 , windowGeometry . width ( ) , windowGeometry . height ( ) ) ;
2022-04-23 19:51:16 +00:00
xcb_icccm_set_wm_normal_hints ( c . data ( ) , windowId , & hints ) ;
NETWinInfo info ( c . data ( ) , windowId , rootWindow ( ) , NET : : WMAllProperties , NET : : WM2AllProperties ) ;
2016-04-11 15:24:08 +00:00
info . setWindowType ( NET : : Dock ) ;
// set the extended strut
QFETCH ( int , leftStrut ) ;
QFETCH ( int , rightStrut ) ;
QFETCH ( int , topStrut ) ;
QFETCH ( int , bottomStrut ) ;
QFETCH ( int , leftStrutStart ) ;
QFETCH ( int , leftStrutEnd ) ;
QFETCH ( int , rightStrutStart ) ;
QFETCH ( int , rightStrutEnd ) ;
QFETCH ( int , topStrutStart ) ;
QFETCH ( int , topStrutEnd ) ;
QFETCH ( int , bottomStrutStart ) ;
QFETCH ( int , bottomStrutEnd ) ;
NETExtendedStrut strut ;
strut . left_start = leftStrutStart ;
strut . left_end = leftStrutEnd ;
strut . left_width = leftStrut ;
strut . right_start = rightStrutStart ;
strut . right_end = rightStrutEnd ;
strut . right_width = rightStrut ;
strut . top_start = topStrutStart ;
strut . top_end = topStrutEnd ;
strut . top_width = topStrut ;
strut . bottom_start = bottomStrutStart ;
strut . bottom_end = bottomStrutEnd ;
strut . bottom_width = bottomStrut ;
info . setExtendedStrut ( strut ) ;
2022-04-23 19:51:16 +00:00
xcb_map_window ( c . data ( ) , windowId ) ;
2016-04-11 15:24:08 +00:00
xcb_flush ( c . data ( ) ) ;
2022-04-23 19:51:16 +00:00
// we should get a window for it
2022-04-23 08:33:23 +00:00
QSignalSpy windowCreatedSpy ( workspace ( ) , & Workspace : : windowAdded ) ;
2016-04-11 15:24:08 +00:00
QVERIFY ( windowCreatedSpy . isValid ( ) ) ;
QVERIFY ( windowCreatedSpy . wait ( ) ) ;
2022-04-23 19:51:16 +00:00
X11Window * window = windowCreatedSpy . first ( ) . first ( ) . value < X11Window * > ( ) ;
QVERIFY ( window ) ;
QCOMPARE ( window - > window ( ) , windowId ) ;
QVERIFY ( ! window - > isDecorated ( ) ) ;
QCOMPARE ( window - > windowType ( ) , NET : : Dock ) ;
QCOMPARE ( window - > frameGeometry ( ) , windowGeometry ) ;
2016-04-11 15:24:08 +00:00
// this should have affected the client area
// some props are independent of struts - those first
// screen 0
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
2016-04-11 15:24:08 +00:00
// screen 1
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
2016-04-11 15:24:08 +00:00
// combined
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( FullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1024 ) ) ;
2016-04-11 15:24:08 +00:00
// now verify the actual updated client areas
2021-08-25 15:12:50 +00:00
QTEST ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , " screen0Maximized " ) ;
QTEST ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , " screen0Maximized " ) ;
QTEST ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , " screen1Maximized " ) ;
QTEST ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , " screen1Maximized " ) ;
QTEST ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , " workArea " ) ;
2021-08-21 17:46:51 +00:00
QTEST ( workspace ( ) - > restrictedMoveArea ( desktop ) , " restrictedMoveArea " ) ;
2016-04-11 15:24:08 +00:00
// and destroy the window again
2022-04-23 19:51:16 +00:00
xcb_unmap_window ( c . data ( ) , windowId ) ;
xcb_destroy_window ( c . data ( ) , windowId ) ;
2016-04-11 15:24:08 +00:00
xcb_flush ( c . data ( ) ) ;
c . reset ( ) ;
2022-04-23 19:51:16 +00:00
QSignalSpy windowClosedSpy ( window , & X11Window : : windowClosed ) ;
2016-04-11 15:24:08 +00:00
QVERIFY ( windowClosedSpy . isValid ( ) ) ;
QVERIFY ( windowClosedSpy . wait ( ) ) ;
// now struts should be removed again
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1280 , 1024 ) ) ;
2016-04-11 15:24:08 +00:00
// second screen
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MovementArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeFullArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( ScreenArea , outputs [ 1 ] , desktop ) , QRect ( 1280 , 0 , 1280 , 1024 ) ) ;
2016-04-11 15:24:08 +00:00
// combined
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1024 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( FullArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 2560 , 1024 ) ) ;
2021-08-21 17:46:51 +00:00
QCOMPARE ( workspace ( ) - > restrictedMoveArea ( desktop ) , QRegion ( ) ) ;
2016-04-11 15:24:08 +00:00
}
2016-06-02 07:29:53 +00:00
void StrutsTest : : test363804 ( )
{
// this test verifies the condition described in BUG 363804
// two screens in a vertical setup, aligned to right border with panel on the bottom screen
const QVector < QRect > geometries { QRect ( 0 , 0 , 1920 , 1080 ) , QRect ( 554 , 1080 , 1366 , 768 ) } ;
2018-03-19 11:05:57 +00:00
QMetaObject : : invokeMethod ( kwinApp ( ) - > platform ( ) , " setVirtualOutputs " ,
2016-06-02 07:29:53 +00:00
Qt : : DirectConnection ,
2018-03-19 11:05:57 +00:00
Q_ARG ( int , 2 ) ,
2016-06-02 07:29:53 +00:00
Q_ARG ( QVector < QRect > , geometries ) ) ;
QCOMPARE ( screens ( ) - > geometry ( ) , QRect ( 0 , 0 , 1920 , 1848 ) ) ;
2021-08-25 15:12:50 +00:00
VirtualDesktop * desktop = VirtualDesktopManager : : self ( ) - > currentDesktop ( ) ;
2022-04-14 12:33:28 +00:00
const QVector < Output * > outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
2021-08-31 07:03:05 +00:00
QCOMPARE ( outputs . count ( ) , 2 ) ;
QCOMPARE ( outputs [ 0 ] - > geometry ( ) , geometries [ 0 ] ) ;
QCOMPARE ( outputs [ 1 ] - > geometry ( ) , geometries [ 1 ] ) ;
2021-08-25 15:12:50 +00:00
2016-06-02 07:29:53 +00:00
// create an xcb window
QScopedPointer < xcb_connection_t , XcbConnectionDeleter > c ( xcb_connect ( nullptr , nullptr ) ) ;
QVERIFY ( ! xcb_connection_has_error ( c . data ( ) ) ) ;
2022-04-23 19:51:16 +00:00
xcb_window_t windowId = xcb_generate_id ( c . data ( ) ) ;
2016-06-02 07:29:53 +00:00
const QRect windowGeometry ( 554 , 1812 , 1366 , 36 ) ;
2022-04-23 19:51:16 +00:00
xcb_create_window ( c . data ( ) , XCB_COPY_FROM_PARENT , windowId , rootWindow ( ) ,
2016-06-02 07:29:53 +00:00
windowGeometry . x ( ) ,
windowGeometry . y ( ) ,
windowGeometry . width ( ) ,
windowGeometry . height ( ) ,
0 , XCB_WINDOW_CLASS_INPUT_OUTPUT , XCB_COPY_FROM_PARENT , 0 , nullptr ) ;
xcb_size_hints_t hints ;
memset ( & hints , 0 , sizeof ( hints ) ) ;
xcb_icccm_size_hints_set_position ( & hints , 1 , windowGeometry . x ( ) , windowGeometry . y ( ) ) ;
xcb_icccm_size_hints_set_size ( & hints , 1 , windowGeometry . width ( ) , windowGeometry . height ( ) ) ;
2022-04-23 19:51:16 +00:00
xcb_icccm_set_wm_normal_hints ( c . data ( ) , windowId , & hints ) ;
NETWinInfo info ( c . data ( ) , windowId , rootWindow ( ) , NET : : WMAllProperties , NET : : WM2AllProperties ) ;
2016-06-02 07:29:53 +00:00
info . setWindowType ( NET : : Dock ) ;
NETExtendedStrut strut ;
strut . left_start = 0 ;
strut . left_end = 0 ;
strut . left_width = 0 ;
strut . right_start = 0 ;
strut . right_end = 0 ;
strut . right_width = 0 ;
strut . top_start = 0 ;
strut . top_end = 0 ;
strut . top_width = 0 ;
strut . bottom_start = 554 ;
strut . bottom_end = 1919 ;
strut . bottom_width = 36 ;
info . setExtendedStrut ( strut ) ;
2022-04-23 19:51:16 +00:00
xcb_map_window ( c . data ( ) , windowId ) ;
2016-06-02 07:29:53 +00:00
xcb_flush ( c . data ( ) ) ;
2022-04-23 19:51:16 +00:00
// we should get a window for it
2022-04-23 08:33:23 +00:00
QSignalSpy windowCreatedSpy ( workspace ( ) , & Workspace : : windowAdded ) ;
2016-06-02 07:29:53 +00:00
QVERIFY ( windowCreatedSpy . isValid ( ) ) ;
QVERIFY ( windowCreatedSpy . wait ( ) ) ;
2022-04-23 19:51:16 +00:00
X11Window * window = windowCreatedSpy . first ( ) . first ( ) . value < X11Window * > ( ) ;
QVERIFY ( window ) ;
QCOMPARE ( window - > window ( ) , windowId ) ;
QVERIFY ( ! window - > isDecorated ( ) ) ;
QCOMPARE ( window - > windowType ( ) , NET : : Dock ) ;
QCOMPARE ( window - > frameGeometry ( ) , windowGeometry ) ;
2016-06-02 07:29:53 +00:00
// now verify the actual updated client areas
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , geometries . at ( 0 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , geometries . at ( 0 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , QRect ( 554 , 1080 , 1366 , 732 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , QRect ( 554 , 1080 , 1366 , 732 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 1920 , 1812 ) ) ;
2016-06-02 07:29:53 +00:00
// and destroy the window again
2022-04-23 19:51:16 +00:00
xcb_unmap_window ( c . data ( ) , windowId ) ;
xcb_destroy_window ( c . data ( ) , windowId ) ;
2016-06-02 07:29:53 +00:00
xcb_flush ( c . data ( ) ) ;
c . reset ( ) ;
2022-04-23 19:51:16 +00:00
QSignalSpy windowClosedSpy ( window , & X11Window : : windowClosed ) ;
2016-06-02 07:29:53 +00:00
QVERIFY ( windowClosedSpy . isValid ( ) ) ;
QVERIFY ( windowClosedSpy . wait ( ) ) ;
}
2016-07-13 05:59:18 +00:00
void StrutsTest : : testLeftScreenSmallerBottomAligned ( )
{
// this test verifies a two screen setup with the left screen smaller than the right and bottom aligned
// the panel is on the top of the left screen, thus not at 0/0
// what this test in addition tests is whether a window larger than the left screen is not placed into
// the dead area
const QVector < QRect > geometries { QRect ( 0 , 282 , 1366 , 768 ) , QRect ( 1366 , 0 , 1680 , 1050 ) } ;
2018-03-19 11:05:57 +00:00
QMetaObject : : invokeMethod ( kwinApp ( ) - > platform ( ) , " setVirtualOutputs " ,
2016-07-13 05:59:18 +00:00
Qt : : DirectConnection ,
2018-03-19 11:05:57 +00:00
Q_ARG ( int , 2 ) ,
2016-07-13 05:59:18 +00:00
Q_ARG ( QVector < QRect > , geometries ) ) ;
QCOMPARE ( screens ( ) - > geometry ( ) , QRect ( 0 , 0 , 3046 , 1050 ) ) ;
2022-04-14 12:33:28 +00:00
const QVector < Output * > outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
2021-08-25 15:12:50 +00:00
QCOMPARE ( outputs [ 0 ] - > geometry ( ) , geometries . at ( 0 ) ) ;
QCOMPARE ( outputs [ 1 ] - > geometry ( ) , geometries . at ( 1 ) ) ;
// the test window will be on the current desktop
VirtualDesktop * desktop = VirtualDesktopManager : : self ( ) - > currentDesktop ( ) ;
2016-07-13 05:59:18 +00:00
// create the panel
QScopedPointer < xcb_connection_t , XcbConnectionDeleter > c ( xcb_connect ( nullptr , nullptr ) ) ;
QVERIFY ( ! xcb_connection_has_error ( c . data ( ) ) ) ;
2022-04-23 19:51:16 +00:00
xcb_window_t windowId = xcb_generate_id ( c . data ( ) ) ;
2016-07-13 05:59:18 +00:00
const QRect windowGeometry ( 0 , 282 , 1366 , 24 ) ;
2022-04-23 19:51:16 +00:00
xcb_create_window ( c . data ( ) , XCB_COPY_FROM_PARENT , windowId , rootWindow ( ) ,
2016-07-13 05:59:18 +00:00
windowGeometry . x ( ) ,
windowGeometry . y ( ) ,
windowGeometry . width ( ) ,
windowGeometry . height ( ) ,
0 , XCB_WINDOW_CLASS_INPUT_OUTPUT , XCB_COPY_FROM_PARENT , 0 , nullptr ) ;
xcb_size_hints_t hints ;
memset ( & hints , 0 , sizeof ( hints ) ) ;
xcb_icccm_size_hints_set_position ( & hints , 1 , windowGeometry . x ( ) , windowGeometry . y ( ) ) ;
xcb_icccm_size_hints_set_size ( & hints , 1 , windowGeometry . width ( ) , windowGeometry . height ( ) ) ;
2022-04-23 19:51:16 +00:00
xcb_icccm_set_wm_normal_hints ( c . data ( ) , windowId , & hints ) ;
NETWinInfo info ( c . data ( ) , windowId , rootWindow ( ) , NET : : WMAllProperties , NET : : WM2AllProperties ) ;
2016-07-13 05:59:18 +00:00
info . setWindowType ( NET : : Dock ) ;
NETExtendedStrut strut ;
strut . left_start = 0 ;
strut . left_end = 0 ;
strut . left_width = 0 ;
strut . right_start = 0 ;
strut . right_end = 0 ;
strut . right_width = 0 ;
strut . top_start = 0 ;
strut . top_end = 1365 ;
strut . top_width = 306 ;
strut . bottom_start = 0 ;
strut . bottom_end = 0 ;
strut . bottom_width = 0 ;
info . setExtendedStrut ( strut ) ;
2022-04-23 19:51:16 +00:00
xcb_map_window ( c . data ( ) , windowId ) ;
2016-07-13 05:59:18 +00:00
xcb_flush ( c . data ( ) ) ;
2022-04-23 19:51:16 +00:00
// we should get a window for it
2022-04-23 08:33:23 +00:00
QSignalSpy windowCreatedSpy ( workspace ( ) , & Workspace : : windowAdded ) ;
2016-07-13 05:59:18 +00:00
QVERIFY ( windowCreatedSpy . isValid ( ) ) ;
QVERIFY ( windowCreatedSpy . wait ( ) ) ;
2022-04-23 19:51:16 +00:00
X11Window * window = windowCreatedSpy . first ( ) . first ( ) . value < X11Window * > ( ) ;
QVERIFY ( window ) ;
QCOMPARE ( window - > window ( ) , windowId ) ;
QVERIFY ( ! window - > isDecorated ( ) ) ;
QCOMPARE ( window - > windowType ( ) , NET : : Dock ) ;
QCOMPARE ( window - > frameGeometry ( ) , windowGeometry ) ;
2016-07-13 05:59:18 +00:00
// now verify the actual updated client areas
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 306 , 1366 , 744 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 306 , 1366 , 744 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , geometries . at ( 1 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , geometries . at ( 1 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 3046 , 1050 ) ) ;
2016-07-13 05:59:18 +00:00
// now create a window which is larger than screen 0
xcb_window_t w2 = xcb_generate_id ( c . data ( ) ) ;
const QRect windowGeometry2 ( 0 , 26 , 1280 , 774 ) ;
xcb_create_window ( c . data ( ) , XCB_COPY_FROM_PARENT , w2 , rootWindow ( ) ,
windowGeometry2 . x ( ) ,
windowGeometry2 . y ( ) ,
windowGeometry2 . width ( ) ,
windowGeometry2 . height ( ) ,
0 , XCB_WINDOW_CLASS_INPUT_OUTPUT , XCB_COPY_FROM_PARENT , 0 , nullptr ) ;
xcb_size_hints_t hints2 ;
memset ( & hints2 , 0 , sizeof ( hints2 ) ) ;
xcb_icccm_size_hints_set_min_size ( & hints2 , 868 , 431 ) ;
xcb_icccm_set_wm_normal_hints ( c . data ( ) , w2 , & hints2 ) ;
xcb_map_window ( c . data ( ) , w2 ) ;
xcb_flush ( c . data ( ) ) ;
QVERIFY ( windowCreatedSpy . wait ( ) ) ;
2022-04-23 19:51:16 +00:00
X11Window * window2 = windowCreatedSpy . last ( ) . first ( ) . value < X11Window * > ( ) ;
QVERIFY ( window2 ) ;
QVERIFY ( window2 ! = window ) ;
QVERIFY ( window2 - > isDecorated ( ) ) ;
QCOMPARE ( window2 - > frameGeometry ( ) , QRect ( 0 , 306 , 1366 , 744 ) ) ;
QCOMPARE ( window2 - > maximizeMode ( ) , KWin : : MaximizeFull ) ;
2016-07-13 05:59:18 +00:00
// destroy window again
2022-04-23 19:51:16 +00:00
QSignalSpy normalWindowClosedSpy ( window2 , & X11Window : : windowClosed ) ;
2016-07-13 05:59:18 +00:00
QVERIFY ( normalWindowClosedSpy . isValid ( ) ) ;
xcb_unmap_window ( c . data ( ) , w2 ) ;
xcb_destroy_window ( c . data ( ) , w2 ) ;
xcb_flush ( c . data ( ) ) ;
QVERIFY ( normalWindowClosedSpy . wait ( ) ) ;
// and destroy the window again
2022-04-23 19:51:16 +00:00
xcb_unmap_window ( c . data ( ) , windowId ) ;
xcb_destroy_window ( c . data ( ) , windowId ) ;
2016-07-13 05:59:18 +00:00
xcb_flush ( c . data ( ) ) ;
c . reset ( ) ;
2022-04-23 19:51:16 +00:00
QSignalSpy windowClosedSpy ( window , & X11Window : : windowClosed ) ;
2016-07-13 05:59:18 +00:00
QVERIFY ( windowClosedSpy . isValid ( ) ) ;
QVERIFY ( windowClosedSpy . wait ( ) ) ;
}
2017-07-08 06:41:16 +00:00
void StrutsTest : : testWindowMoveWithPanelBetweenScreens ( )
{
// this test verifies the condition of BUG
// when moving a window with decorations in a restricted way it should pass from one screen
// to the other even if there is a panel in between.
// left screen must be smaller than right screen
const QVector < QRect > geometries { QRect ( 0 , 282 , 1366 , 768 ) , QRect ( 1366 , 0 , 1680 , 1050 ) } ;
2018-03-19 11:05:57 +00:00
QMetaObject : : invokeMethod ( kwinApp ( ) - > platform ( ) , " setVirtualOutputs " ,
2017-07-08 06:41:16 +00:00
Qt : : DirectConnection ,
2018-03-19 11:05:57 +00:00
Q_ARG ( int , 2 ) ,
2017-07-08 06:41:16 +00:00
Q_ARG ( QVector < QRect > , geometries ) ) ;
QCOMPARE ( screens ( ) - > geometry ( ) , QRect ( 0 , 0 , 3046 , 1050 ) ) ;
2022-04-14 12:33:28 +00:00
const QVector < Output * > outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
2021-08-25 15:12:50 +00:00
QCOMPARE ( outputs [ 0 ] - > geometry ( ) , geometries . at ( 0 ) ) ;
QCOMPARE ( outputs [ 1 ] - > geometry ( ) , geometries . at ( 1 ) ) ;
// all windows will be placed on the current desktop
VirtualDesktop * desktop = VirtualDesktopManager : : self ( ) - > currentDesktop ( ) ;
2017-07-08 06:41:16 +00:00
// create the panel on the right screen, left edge
QScopedPointer < xcb_connection_t , XcbConnectionDeleter > c ( xcb_connect ( nullptr , nullptr ) ) ;
QVERIFY ( ! xcb_connection_has_error ( c . data ( ) ) ) ;
2022-04-23 19:51:16 +00:00
xcb_window_t windowId = xcb_generate_id ( c . data ( ) ) ;
2017-07-08 06:41:16 +00:00
const QRect windowGeometry ( 1366 , 0 , 24 , 1050 ) ;
2022-04-23 19:51:16 +00:00
xcb_create_window ( c . data ( ) , XCB_COPY_FROM_PARENT , windowId , rootWindow ( ) ,
2017-07-08 06:41:16 +00:00
windowGeometry . x ( ) ,
windowGeometry . y ( ) ,
windowGeometry . width ( ) ,
windowGeometry . height ( ) ,
0 , XCB_WINDOW_CLASS_INPUT_OUTPUT , XCB_COPY_FROM_PARENT , 0 , nullptr ) ;
xcb_size_hints_t hints ;
memset ( & hints , 0 , sizeof ( hints ) ) ;
xcb_icccm_size_hints_set_position ( & hints , 1 , windowGeometry . x ( ) , windowGeometry . y ( ) ) ;
xcb_icccm_size_hints_set_size ( & hints , 1 , windowGeometry . width ( ) , windowGeometry . height ( ) ) ;
2022-04-23 19:51:16 +00:00
xcb_icccm_set_wm_normal_hints ( c . data ( ) , windowId , & hints ) ;
NETWinInfo info ( c . data ( ) , windowId , rootWindow ( ) , NET : : WMAllProperties , NET : : WM2AllProperties ) ;
2017-07-08 06:41:16 +00:00
info . setWindowType ( NET : : Dock ) ;
NETExtendedStrut strut ;
strut . left_start = 0 ;
strut . left_end = 1050 ;
2022-03-23 10:13:38 +00:00
strut . left_width = 1366 + 24 ;
2017-07-08 06:41:16 +00:00
strut . right_start = 0 ;
strut . right_end = 0 ;
strut . right_width = 0 ;
strut . top_start = 0 ;
strut . top_end = 0 ;
strut . top_width = 0 ;
strut . bottom_start = 0 ;
strut . bottom_end = 0 ;
strut . bottom_width = 0 ;
info . setExtendedStrut ( strut ) ;
2022-04-23 19:51:16 +00:00
xcb_map_window ( c . data ( ) , windowId ) ;
2017-07-08 06:41:16 +00:00
xcb_flush ( c . data ( ) ) ;
2022-04-23 19:51:16 +00:00
// we should get a window for it
2022-04-23 08:33:23 +00:00
QSignalSpy windowCreatedSpy ( workspace ( ) , & Workspace : : windowAdded ) ;
2017-07-08 06:41:16 +00:00
QVERIFY ( windowCreatedSpy . isValid ( ) ) ;
QVERIFY ( windowCreatedSpy . wait ( ) ) ;
2022-04-23 19:51:16 +00:00
X11Window * window = windowCreatedSpy . first ( ) . first ( ) . value < X11Window * > ( ) ;
QVERIFY ( window ) ;
QCOMPARE ( window - > window ( ) , windowId ) ;
QVERIFY ( ! window - > isDecorated ( ) ) ;
QCOMPARE ( window - > windowType ( ) , NET : : Dock ) ;
QCOMPARE ( window - > frameGeometry ( ) , windowGeometry ) ;
2017-07-08 06:41:16 +00:00
// now verify the actual updated client areas
2021-08-25 15:12:50 +00:00
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 282 , 1366 , 768 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 282 , 1366 , 768 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( PlacementArea , outputs [ 1 ] , desktop ) , QRect ( 1390 , 0 , 1656 , 1050 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( MaximizeArea , outputs [ 1 ] , desktop ) , QRect ( 1390 , 0 , 1656 , 1050 ) ) ;
QCOMPARE ( workspace ( ) - > clientArea ( WorkArea , outputs [ 0 ] , desktop ) , QRect ( 0 , 0 , 3046 , 1050 ) ) ;
2021-08-21 17:46:51 +00:00
QCOMPARE ( workspace ( ) - > restrictedMoveArea ( desktop ) , QRegion ( 1366 , 0 , 24 , 1050 ) ) ;
2017-07-08 06:41:16 +00:00
// create another window and try to move it
xcb_window_t w2 = xcb_generate_id ( c . data ( ) ) ;
const QRect windowGeometry2 ( 1500 , 400 , 200 , 300 ) ;
xcb_create_window ( c . data ( ) , XCB_COPY_FROM_PARENT , w2 , rootWindow ( ) ,
windowGeometry2 . x ( ) ,
windowGeometry2 . y ( ) ,
windowGeometry2 . width ( ) ,
windowGeometry2 . height ( ) ,
0 , XCB_WINDOW_CLASS_INPUT_OUTPUT , XCB_COPY_FROM_PARENT , 0 , nullptr ) ;
xcb_size_hints_t hints2 ;
memset ( & hints2 , 0 , sizeof ( hints2 ) ) ;
xcb_icccm_size_hints_set_position ( & hints2 , 1 , windowGeometry2 . x ( ) , windowGeometry2 . y ( ) ) ;
xcb_icccm_size_hints_set_min_size ( & hints2 , 200 , 300 ) ;
xcb_icccm_set_wm_normal_hints ( c . data ( ) , w2 , & hints2 ) ;
xcb_map_window ( c . data ( ) , w2 ) ;
xcb_flush ( c . data ( ) ) ;
QVERIFY ( windowCreatedSpy . wait ( ) ) ;
2022-04-23 19:51:16 +00:00
X11Window * window2 = windowCreatedSpy . last ( ) . first ( ) . value < X11Window * > ( ) ;
QVERIFY ( window2 ) ;
QVERIFY ( window2 ! = window ) ;
QVERIFY ( window2 - > isDecorated ( ) ) ;
QCOMPARE ( window2 - > clientSize ( ) , QSize ( 200 , 300 ) ) ;
QCOMPARE ( window2 - > pos ( ) , QPoint ( 1500 , 400 ) ) ;
const QRect origGeo = window2 - > frameGeometry ( ) ;
2020-04-02 16:18:01 +00:00
Cursors : : self ( ) - > mouse ( ) - > setPos ( origGeo . center ( ) ) ;
2022-04-23 19:51:16 +00:00
workspace ( ) - > performWindowOperation ( window2 , Options : : MoveOp ) ;
QTRY_COMPARE ( workspace ( ) - > moveResizeWindow ( ) , window2 ) ;
QVERIFY ( window2 - > isInteractiveMove ( ) ) ;
2017-07-08 06:41:16 +00:00
// move to next screen - step is 8 pixel, so 800 pixel
for ( int i = 0 ; i < 100 ; i + + ) {
2022-04-23 19:51:16 +00:00
window2 - > keyPressEvent ( Qt : : Key_Left ) ;
2017-08-09 15:54:42 +00:00
QTest : : qWait ( 50 ) ;
2017-07-08 06:41:16 +00:00
}
2022-04-23 19:51:16 +00:00
window2 - > keyPressEvent ( Qt : : Key_Enter ) ;
QCOMPARE ( window2 - > isInteractiveMove ( ) , false ) ;
2022-04-23 08:33:23 +00:00
QVERIFY ( workspace ( ) - > moveResizeWindow ( ) = = nullptr ) ;
2022-04-23 19:51:16 +00:00
QCOMPARE ( window2 - > frameGeometry ( ) , QRect ( origGeo . translated ( - 800 , 0 ) ) ) ;
2017-07-08 06:41:16 +00:00
}
2016-04-11 15:24:08 +00:00
}
WAYLANDTEST_MAIN ( KWin : : StrutsTest )
# include "struts_test.moc"