Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KWin
Commits
775dd4e1
Commit
775dd4e1
authored
May 05, 2020
by
Vlad Zahorodnii
Browse files
xdg-shell: Drop support for v5
It's been deprecated for quite a while and all major toolkits already support xdg_wm_base.
parent
8715e441
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/wayland/CMakeLists.txt
View file @
775dd4e1
set
(
SERVER_LIB_SRCS
../compat/wayland-xdg-shell-v5-protocol.c
abstract_data_source.cpp
appmenu_interface.cpp
blur_interface.cpp
...
...
@@ -65,8 +64,6 @@ set(SERVER_LIB_SRCS
xdgoutput_interface.cpp
xdgshell_interface.cpp
xdgshell_stable_interface.cpp
xdgshell_v5_interface.cpp
xdgshell_v5_interface.cpp
xdgshell_v6_interface.cpp
)
...
...
src/wayland/autotests/client/CMakeLists.txt
View file @
775dd4e1
...
...
@@ -331,18 +331,6 @@ target_link_libraries( testSelection Qt5::Test Qt5::Gui KF5::WaylandClient Plasm
add_test
(
NAME kwayland-testSelection COMMAND testSelection
)
ecm_mark_as_test
(
testSelection
)
########################################################
# Test XdgShellV5
########################################################
set
(
testXdgShellV5_SRCS
test_xdg_shell.cpp
test_xdg_shell_v5.cpp
)
add_executable
(
testXdgShellV5
${
testXdgShellV5_SRCS
}
)
target_link_libraries
(
testXdgShellV5 Qt5::Test Qt5::Gui Plasma::KWaylandServer KF5::WaylandClient Wayland::Client
)
add_test
(
NAME kwayland-testXdgShellV5 COMMAND testXdgShellV5
)
ecm_mark_as_test
(
testXdgShellV5
)
########################################################
# Test XdgForeign
########################################################
...
...
src/wayland/autotests/client/test_wayland_registry.cpp
View file @
775dd4e1
...
...
@@ -52,7 +52,6 @@
#include
<wayland-relativepointer-unstable-v1-client-protocol.h>
#include
<wayland-pointer-gestures-unstable-v1-client-protocol.h>
#include
<wayland-pointer-constraints-unstable-v1-client-protocol.h>
#include
"../../src/compat/wayland-xdg-shell-v5-client-protocol.h"
class
TestWaylandRegistry
:
public
QObject
{
...
...
@@ -74,7 +73,6 @@ private Q_SLOTS:
void
testBindContrastManager
();
void
testBindSlideManager
();
void
testBindDpmsManager
();
void
testBindXdgShellUnstableV5
();
void
testBindRelativePointerManagerUnstableV1
();
void
testBindPointerGesturesUnstableV1
();
void
testBindPointerConstraintsUnstableV1
();
...
...
@@ -99,7 +97,6 @@ private:
KWaylandServer
::
ServerSideDecorationManagerInterface
*
m_serverSideDecorationManager
;
KWaylandServer
::
TextInputManagerInterface
*
m_textInputManagerV0
;
KWaylandServer
::
TextInputManagerInterface
*
m_textInputManagerV2
;
KWaylandServer
::
XdgShellInterface
*
m_xdgShellUnstableV5
;
KWaylandServer
::
RelativePointerManagerInterface
*
m_relativePointerV1
;
KWaylandServer
::
PointerGesturesInterface
*
m_pointerGesturesV1
;
KWaylandServer
::
PointerConstraintsInterface
*
m_pointerConstraintsV1
;
...
...
@@ -124,7 +121,6 @@ TestWaylandRegistry::TestWaylandRegistry(QObject *parent)
,
m_serverSideDecorationManager
(
nullptr
)
,
m_textInputManagerV0
(
nullptr
)
,
m_textInputManagerV2
(
nullptr
)
,
m_xdgShellUnstableV5
(
nullptr
)
,
m_relativePointerV1
(
nullptr
)
,
m_pointerGesturesV1
(
nullptr
)
,
m_pointerConstraintsV1
(
nullptr
)
...
...
@@ -168,9 +164,6 @@ void TestWaylandRegistry::init()
m_textInputManagerV2
=
m_display
->
createTextInputManager
(
KWaylandServer
::
TextInputInterfaceVersion
::
UnstableV2
);
QCOMPARE
(
m_textInputManagerV2
->
interfaceVersion
(),
KWaylandServer
::
TextInputInterfaceVersion
::
UnstableV2
);
m_textInputManagerV2
->
create
();
m_xdgShellUnstableV5
=
m_display
->
createXdgShell
(
KWaylandServer
::
XdgShellInterfaceVersion
::
UnstableV5
);
m_xdgShellUnstableV5
->
create
();
QCOMPARE
(
m_xdgShellUnstableV5
->
interfaceVersion
(),
KWaylandServer
::
XdgShellInterfaceVersion
::
UnstableV5
);
m_relativePointerV1
=
m_display
->
createRelativePointerManager
(
KWaylandServer
::
RelativePointerInterfaceVersion
::
UnstableV1
);
m_relativePointerV1
->
create
();
QCOMPARE
(
m_relativePointerV1
->
interfaceVersion
(),
KWaylandServer
::
RelativePointerInterfaceVersion
::
UnstableV1
);
...
...
@@ -300,11 +293,6 @@ void TestWaylandRegistry::testBindDpmsManager()
TEST_BIND
(
KWayland
::
Client
::
Registry
::
Interface
::
Dpms
,
SIGNAL
(
dpmsAnnounced
(
quint32
,
quint32
)),
bindDpmsManager
,
org_kde_kwin_dpms_manager_destroy
)
}
void
TestWaylandRegistry
::
testBindXdgShellUnstableV5
()
{
TEST_BIND
(
KWayland
::
Client
::
Registry
::
Interface
::
XdgShellUnstableV5
,
SIGNAL
(
xdgShellUnstableV5Announced
(
quint32
,
quint32
)),
bindXdgShellUnstableV5
,
zxdg_shell_v5_destroy
)
}
void
TestWaylandRegistry
::
testBindRelativePointerManagerUnstableV1
()
{
TEST_BIND
(
KWayland
::
Client
::
Registry
::
Interface
::
RelativePointerManagerUnstableV1
,
SIGNAL
(
relativePointerManagerUnstableV1Announced
(
quint32
,
quint32
)),
bindRelativePointerManagerUnstableV1
,
zwp_relative_pointer_manager_v1_destroy
)
...
...
src/wayland/autotests/client/test_xdg_shell_v5.cpp
deleted
100644 → 0
View file @
8715e441
/*
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2017 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include
"test_xdg_shell.h"
class
XdgShellTestV5
:
public
XdgShellTest
{
Q_OBJECT
public:
XdgShellTestV5
()
:
XdgShellTest
(
KWaylandServer
::
XdgShellInterfaceVersion
::
UnstableV5
)
{}
private
Q_SLOTS
:
void
testPopup
();
};
void
XdgShellTestV5
::
testPopup
()
{
// this test verifies that the creation of popups works correctly
SURFACE
QSignalSpy
surfaceCreatedSpy
(
m_compositorInterface
,
&
CompositorInterface
::
surfaceCreated
);
QVERIFY
(
surfaceCreatedSpy
.
isValid
());
QSignalSpy
xdgPopupSpy
(
m_xdgShellInterface
,
&
XdgShellInterface
::
popupCreated
);
//check as well as the compat signal, the new signal is also fired
QSignalSpy
xdgPopupSpyNew
(
m_xdgShellInterface
,
&
XdgShellInterface
::
xdgPopupCreated
);
QVERIFY
(
xdgPopupSpy
.
isValid
());
QScopedPointer
<
Surface
>
popupSurface
(
m_compositor
->
createSurface
());
QVERIFY
(
surfaceCreatedSpy
.
wait
());
// TODO: proper serial
QScopedPointer
<
XdgShellPopup
>
xdgPopup
(
m_xdgShell
->
createPopup
(
popupSurface
.
data
(),
surface
.
data
(),
m_seat
,
120
,
QPoint
(
10
,
20
)));
QVERIFY
(
xdgPopupSpy
.
wait
());
QCOMPARE
(
xdgPopupSpy
.
count
(),
1
);
QCOMPARE
(
xdgPopupSpyNew
.
count
(),
1
);
QCOMPARE
(
xdgPopupSpy
.
first
().
at
(
1
).
value
<
SeatInterface
*>
(),
m_seatInterface
);
QCOMPARE
(
xdgPopupSpy
.
first
().
at
(
2
).
value
<
quint32
>
(),
120u
);
auto
serverXdgPopup
=
xdgPopupSpy
.
first
().
first
().
value
<
XdgShellPopupInterface
*>
();
QVERIFY
(
serverXdgPopup
);
QCOMPARE
(
serverXdgPopup
->
surface
(),
surfaceCreatedSpy
.
first
().
first
().
value
<
SurfaceInterface
*>
());
QCOMPARE
(
serverXdgPopup
->
transientFor
().
data
(),
serverXdgSurface
->
surface
());
QCOMPARE
(
serverXdgPopup
->
transientOffset
(),
QPoint
(
10
,
20
));
// now also a popup for the popup
QScopedPointer
<
Surface
>
popup2Surface
(
m_compositor
->
createSurface
());
QScopedPointer
<
XdgShellPopup
>
xdgPopup2
(
m_xdgShell
->
createPopup
(
popup2Surface
.
data
(),
popupSurface
.
data
(),
m_seat
,
121
,
QPoint
(
5
,
7
)));
QVERIFY
(
xdgPopupSpy
.
wait
());
QCOMPARE
(
xdgPopupSpy
.
count
(),
2
);
QCOMPARE
(
xdgPopupSpy
.
last
().
at
(
1
).
value
<
SeatInterface
*>
(),
m_seatInterface
);
QCOMPARE
(
xdgPopupSpy
.
last
().
at
(
2
).
value
<
quint32
>
(),
121u
);
auto
serverXdgPopup2
=
xdgPopupSpy
.
last
().
first
().
value
<
XdgShellPopupInterface
*>
();
QVERIFY
(
serverXdgPopup2
);
QCOMPARE
(
serverXdgPopup2
->
surface
(),
surfaceCreatedSpy
.
last
().
first
().
value
<
SurfaceInterface
*>
());
QCOMPARE
(
serverXdgPopup2
->
transientFor
().
data
(),
serverXdgPopup
->
surface
());
QCOMPARE
(
serverXdgPopup2
->
transientOffset
(),
QPoint
(
5
,
7
));
QSignalSpy
popup2DoneSpy
(
xdgPopup2
.
data
(),
&
XdgShellPopup
::
popupDone
);
QVERIFY
(
popup2DoneSpy
.
isValid
());
serverXdgPopup2
->
popupDone
();
QVERIFY
(
popup2DoneSpy
.
wait
());
// TODO: test that this sends also the done to all parents
}
QTEST_GUILESS_MAIN
(
XdgShellTestV5
)
#include
"test_xdg_shell_v5.moc"
src/wayland/display.cpp
View file @
775dd4e1
...
...
@@ -42,7 +42,6 @@
#include
"xdgforeign_interface.h"
#include
"xdgoutput_interface.h"
#include
"xdgshell_stable_interface_p.h"
#include
"xdgshell_v5_interface_p.h"
#include
"xdgshell_v6_interface_p.h"
#include
"xdgdecoration_interface.h"
#include
"eglstream_controller_interface.h"
...
...
@@ -387,8 +386,7 @@ XdgShellInterface *Display::createXdgShell(const XdgShellInterfaceVersion &versi
XdgShellInterface
*
x
=
nullptr
;
switch
(
version
)
{
case
XdgShellInterfaceVersion
::
UnstableV5
:
x
=
new
XdgShellV5Interface
(
this
,
parent
);
break
;
return
nullptr
;
case
XdgShellInterfaceVersion
::
UnstableV6
:
x
=
new
XdgShellV6Interface
(
this
,
parent
);
break
;
...
...
src/wayland/server/xdgshell_v5_interface.cpp
deleted
100644 → 0
View file @
8715e441
/*
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include
"xdgshell_v5_interface_p.h"
#include
"xdgshell_interface_p.h"
#include
"generic_shell_surface_p.h"
#include
"display.h"
#include
"global_p.h"
#include
"resource_p.h"
#include
"output_interface.h"
#include
"seat_interface.h"
#include
"surface_interface.h"
#include
"../compat/wayland-xdg-shell-v5-server-protocol.h"
namespace
KWaylandServer
{
class
XdgShellV5Interface
::
Private
:
public
XdgShellInterface
::
Private
{
public:
Private
(
XdgShellV5Interface
*
q
,
Display
*
d
);
QVector
<
XdgSurfaceV5Interface
*>
surfaces
;
private:
void
createSurface
(
wl_client
*
client
,
uint32_t
version
,
uint32_t
id
,
SurfaceInterface
*
surface
,
wl_resource
*
parentResource
);
void
createPopup
(
wl_client
*
client
,
uint32_t
version
,
uint32_t
id
,
SurfaceInterface
*
surface
,
SurfaceInterface
*
parent
,
SeatInterface
*
seat
,
quint32
serial
,
const
QPoint
&
pos
,
wl_resource
*
parentResource
);
void
bind
(
wl_client
*
client
,
uint32_t
version
,
uint32_t
id
)
override
;
quint32
ping
(
XdgShellSurfaceInterface
*
surface
)
override
;
static
void
unbind
(
wl_resource
*
resource
);
static
Private
*
cast
(
wl_resource
*
r
)
{
return
reinterpret_cast
<
Private
*>
(
wl_resource_get_user_data
(
r
));
}
QHash
<
wl_client
*
,
wl_resource
*>
resources
;
static
void
destroyCallback
(
wl_client
*
client
,
wl_resource
*
resource
);
static
void
useUnstableVersionCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
int32_t
version
);
static
void
getXdgSurfaceCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
uint32_t
id
,
wl_resource
*
surface
);
static
void
getXdgPopupCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
uint32_t
id
,
wl_resource
*
surface
,
wl_resource
*
parent
,
wl_resource
*
seat
,
uint32_t
serial
,
int32_t
x
,
int32_t
y
);
static
void
pongCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
uint32_t
serial
);
XdgShellV5Interface
*
q
;
static
const
struct
zxdg_shell_v5_interface
s_interface
;
static
const
quint32
s_version
;
};
class
XdgPopupV5Interface
::
Private
:
public
XdgShellPopupInterface
::
Private
{
public:
Private
(
XdgPopupV5Interface
*
q
,
XdgShellV5Interface
*
c
,
SurfaceInterface
*
surface
,
wl_resource
*
parentResource
);
~
Private
();
QRect
windowGeometry
()
const
override
;
void
commit
()
override
;
void
popupDone
()
override
;
XdgPopupV5Interface
*
q_func
()
{
return
reinterpret_cast
<
XdgPopupV5Interface
*>
(
q
);
}
private:
static
const
struct
zxdg_popup_v5_interface
s_interface
;
};
const
quint32
XdgShellV5Interface
::
Private
::
s_version
=
1
;
#ifndef K_DOXYGEN
const
struct
zxdg_shell_v5_interface
XdgShellV5Interface
::
Private
::
s_interface
=
{
destroyCallback
,
useUnstableVersionCallback
,
getXdgSurfaceCallback
,
getXdgPopupCallback
,
pongCallback
};
#endif
void
XdgShellV5Interface
::
Private
::
destroyCallback
(
wl_client
*
client
,
wl_resource
*
resource
)
{
Q_UNUSED
(
client
)
// TODO: send protocol error if there are still surfaces mapped
wl_resource_destroy
(
resource
);
}
void
XdgShellV5Interface
::
Private
::
useUnstableVersionCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
int32_t
version
)
{
Q_UNUSED
(
client
)
Q_UNUSED
(
resource
)
Q_UNUSED
(
version
)
// TODO: implement
}
void
XdgShellV5Interface
::
Private
::
getXdgSurfaceCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
uint32_t
id
,
wl_resource
*
surface
)
{
auto
s
=
cast
(
resource
);
s
->
createSurface
(
client
,
wl_resource_get_version
(
resource
),
id
,
SurfaceInterface
::
get
(
surface
),
resource
);
}
void
XdgShellV5Interface
::
Private
::
createSurface
(
wl_client
*
client
,
uint32_t
version
,
uint32_t
id
,
SurfaceInterface
*
surface
,
wl_resource
*
parentResource
)
{
auto
it
=
std
::
find_if
(
surfaces
.
constBegin
(),
surfaces
.
constEnd
(),
[
surface
](
XdgSurfaceV5Interface
*
s
)
{
return
surface
==
s
->
surface
();
}
);
if
(
it
!=
surfaces
.
constEnd
())
{
wl_resource_post_error
(
surface
->
resource
(),
ZXDG_SHELL_V5_ERROR_ROLE
,
"ShellSurface already created"
);
return
;
}
XdgSurfaceV5Interface
*
shellSurface
=
new
XdgSurfaceV5Interface
(
q
,
surface
,
parentResource
);
surfaces
<<
shellSurface
;
QObject
::
connect
(
shellSurface
,
&
XdgSurfaceV5Interface
::
destroyed
,
q
,
[
this
,
shellSurface
]
{
surfaces
.
removeAll
(
shellSurface
);
}
);
shellSurface
->
d
->
create
(
display
->
getConnection
(
client
),
version
,
id
);
emit
q
->
surfaceCreated
(
shellSurface
);
}
void
XdgShellV5Interface
::
Private
::
getXdgPopupCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
uint32_t
id
,
wl_resource
*
surface
,
wl_resource
*
parent
,
wl_resource
*
seat
,
uint32_t
serial
,
int32_t
x
,
int32_t
y
)
{
auto
s
=
cast
(
resource
);
s
->
createPopup
(
client
,
wl_resource_get_version
(
resource
),
id
,
SurfaceInterface
::
get
(
surface
),
SurfaceInterface
::
get
(
parent
),
SeatInterface
::
get
(
seat
),
serial
,
QPoint
(
x
,
y
),
resource
);
}
void
XdgShellV5Interface
::
Private
::
createPopup
(
wl_client
*
client
,
uint32_t
version
,
uint32_t
id
,
SurfaceInterface
*
surface
,
SurfaceInterface
*
parent
,
SeatInterface
*
seat
,
quint32
serial
,
const
QPoint
&
pos
,
wl_resource
*
parentResource
)
{
XdgPopupV5Interface
*
popupSurface
=
new
XdgPopupV5Interface
(
q
,
surface
,
parentResource
);
auto
d
=
popupSurface
->
d_func
();
d
->
parent
=
QPointer
<
SurfaceInterface
>
(
parent
);
d
->
anchorRect
=
QRect
(
pos
,
QSize
(
0
,
0
));
//default open like a normal popup
d
->
anchorEdge
=
Qt
::
BottomEdge
;
d
->
gravity
=
Qt
::
TopEdge
;
d
->
create
(
display
->
getConnection
(
client
),
version
,
id
);
//compat
emit
q
->
popupCreated
(
popupSurface
,
seat
,
serial
);
//new system
emit
q
->
xdgPopupCreated
(
popupSurface
);
emit
popupSurface
->
grabRequested
(
seat
,
serial
);
}
void
XdgShellV5Interface
::
Private
::
pongCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
uint32_t
serial
)
{
Q_UNUSED
(
client
)
auto
s
=
cast
(
resource
);
auto
timerIt
=
s
->
pingTimers
.
find
(
serial
);
if
(
timerIt
!=
s
->
pingTimers
.
end
()
&&
timerIt
.
value
()
->
isActive
())
{
delete
timerIt
.
value
();
s
->
pingTimers
.
erase
(
timerIt
);
emit
s
->
q
->
pongReceived
(
serial
);
}
}
XdgShellV5Interface
::
Private
::
Private
(
XdgShellV5Interface
*
q
,
Display
*
d
)
:
XdgShellInterface
::
Private
(
XdgShellInterfaceVersion
::
UnstableV5
,
q
,
d
,
&
zxdg_shell_v5_interface
,
s_version
)
,
q
(
q
)
{
}
void
XdgShellV5Interface
::
Private
::
bind
(
wl_client
*
client
,
uint32_t
version
,
uint32_t
id
)
{
auto
c
=
display
->
getConnection
(
client
);
auto
resource
=
c
->
createResource
(
&
zxdg_shell_v5_interface
,
qMin
(
version
,
s_version
),
id
);
if
(
!
resource
)
{
wl_client_post_no_memory
(
client
);
return
;
}
resources
[
client
]
=
resource
;
wl_resource_set_implementation
(
resource
,
&
s_interface
,
this
,
unbind
);
}
void
XdgShellV5Interface
::
Private
::
unbind
(
wl_resource
*
resource
)
{
auto
s
=
cast
(
resource
);
auto
client
=
wl_resource_get_client
(
resource
);
s
->
resources
.
remove
(
client
);
}
XdgSurfaceV5Interface
*
XdgShellV5Interface
::
getSurface
(
wl_resource
*
resource
)
{
if
(
!
resource
)
{
return
nullptr
;
}
Q_D
();
auto
it
=
std
::
find_if
(
d
->
surfaces
.
constBegin
(),
d
->
surfaces
.
constEnd
(),
[
resource
]
(
XdgSurfaceV5Interface
*
surface
)
{
return
surface
->
resource
()
==
resource
;
}
);
if
(
it
!=
d
->
surfaces
.
constEnd
())
{
return
*
it
;
}
return
nullptr
;
}
quint32
XdgShellV5Interface
::
Private
::
ping
(
XdgShellSurfaceInterface
*
surface
)
{
auto
client
=
surface
->
client
()
->
client
();
//from here we can get the resource bound to our global.
auto
clientXdgShellResource
=
resources
.
value
(
client
);
if
(
!
clientXdgShellResource
)
{
return
0
;
}
const
quint32
pingSerial
=
display
->
nextSerial
();
zxdg_shell_v5_send_ping
(
clientXdgShellResource
,
pingSerial
);
setupTimer
(
pingSerial
);
return
pingSerial
;
}
XdgShellV5Interface
::
Private
*
XdgShellV5Interface
::
d_func
()
const
{
return
reinterpret_cast
<
Private
*>
(
d
.
data
());
}
class
XdgSurfaceV5Interface
::
Private
:
public
XdgShellSurfaceInterface
::
Private
{
public:
Private
(
XdgSurfaceV5Interface
*
q
,
XdgShellV5Interface
*
c
,
SurfaceInterface
*
surface
,
wl_resource
*
parentResource
);
~
Private
();
QRect
windowGeometry
()
const
override
;
QSize
minimumSize
()
const
override
;
QSize
maximumSize
()
const
override
;
void
close
()
override
;
void
commit
()
override
;
quint32
configure
(
States
states
,
const
QSize
&
size
)
override
;
XdgSurfaceV5Interface
*
q_func
()
{
return
reinterpret_cast
<
XdgSurfaceV5Interface
*>
(
q
);
}
private:
static
void
setParentCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
wl_resource
*
parent
);
static
void
showWindowMenuCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
wl_resource
*
seat
,
uint32_t
serial
,
int32_t
x
,
int32_t
y
);
static
void
ackConfigureCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
uint32_t
serial
);
static
void
setWindowGeometryCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
height
);
static
void
setMaximizedCallback
(
wl_client
*
client
,
wl_resource
*
resource
);
static
void
unsetMaximizedCallback
(
wl_client
*
client
,
wl_resource
*
resource
);
static
void
setFullscreenCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
wl_resource
*
output
);
static
void
unsetFullscreenCallback
(
wl_client
*
client
,
wl_resource
*
resource
);
static
void
setMinimizedCallback
(
wl_client
*
client
,
wl_resource
*
resource
);
static
const
struct
zxdg_surface_v5_interface
s_interface
;
struct
ShellSurfaceState
{
QRect
windowGeometry
;
bool
windowGeometryIsSet
=
false
;
};
ShellSurfaceState
m_currentState
;
ShellSurfaceState
m_pendingState
;
};
namespace
{
template
<
>
Qt
::
Edges
edgesToQtEdges
(
zxdg_surface_v5_resize_edge
edges
)
{
Qt
::
Edges
qtEdges
;
switch
(
edges
)
{
case
ZXDG_SURFACE_V5_RESIZE_EDGE_TOP
:
qtEdges
=
Qt
::
TopEdge
;
break
;
case
ZXDG_SURFACE_V5_RESIZE_EDGE_BOTTOM
:
qtEdges
=
Qt
::
BottomEdge
;
break
;
case
ZXDG_SURFACE_V5_RESIZE_EDGE_LEFT
:
qtEdges
=
Qt
::
LeftEdge
;
break
;
case
ZXDG_SURFACE_V5_RESIZE_EDGE_TOP_LEFT
:
qtEdges
=
Qt
::
TopEdge
|
Qt
::
LeftEdge
;
break
;
case
ZXDG_SURFACE_V5_RESIZE_EDGE_BOTTOM_LEFT
:
qtEdges
=
Qt
::
BottomEdge
|
Qt
::
LeftEdge
;
break
;
case
ZXDG_SURFACE_V5_RESIZE_EDGE_RIGHT
:
qtEdges
=
Qt
::
RightEdge
;
break
;
case
ZXDG_SURFACE_V5_RESIZE_EDGE_TOP_RIGHT
:
qtEdges
=
Qt
::
TopEdge
|
Qt
::
RightEdge
;
break
;
case
ZXDG_SURFACE_V5_RESIZE_EDGE_BOTTOM_RIGHT
:
qtEdges
=
Qt
::
BottomEdge
|
Qt
::
RightEdge
;
break
;
case
ZXDG_SURFACE_V5_RESIZE_EDGE_NONE
:
break
;
default:
Q_UNREACHABLE
();
break
;
}
return
qtEdges
;
}
}
#ifndef K_DOXYGEN
const
struct
zxdg_surface_v5_interface
XdgSurfaceV5Interface
::
Private
::
s_interface
=
{
resourceDestroyedCallback
,
setParentCallback
,
setTitleCallback
,
setAppIdCallback
,
showWindowMenuCallback
,
moveCallback
,
resizeCallback
<
zxdg_surface_v5_resize_edge
>
,
ackConfigureCallback
,
setWindowGeometryCallback
,
setMaximizedCallback
,
unsetMaximizedCallback
,
setFullscreenCallback
,
unsetFullscreenCallback
,
setMinimizedCallback
};
#endif
void
XdgSurfaceV5Interface
::
Private
::
setParentCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
wl_resource
*
parent
)
{
auto
s
=
cast
<
Private
>
(
resource
);
Q_ASSERT
(
client
==
*
s
->
client
);
auto
parentSurface
=
static_cast
<
XdgShellV5Interface
*>
(
s
->
q
->
global
())
->
getSurface
(
parent
);
if
(
s
->
parent
.
data
()
!=
parentSurface
)
{
s
->
parent
=
QPointer
<
XdgSurfaceV5Interface
>
(
parentSurface
);
emit
s
->
q_func
()
->
transientForChanged
();
}
}
void
XdgSurfaceV5Interface
::
Private
::
showWindowMenuCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
wl_resource
*
seat
,
uint32_t
serial
,
int32_t
x
,
int32_t
y
)
{
auto
s
=
cast
<
Private
>
(
resource
);
Q_ASSERT
(
client
==
*
s
->
client
);
emit
s
->
q_func
()
->
windowMenuRequested
(
SeatInterface
::
get
(
seat
),
serial
,
QPoint
(
x
,
y
));
}
void
XdgSurfaceV5Interface
::
Private
::
ackConfigureCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
uint32_t
serial
)
{
auto
s
=
cast
<
Private
>
(
resource
);
Q_ASSERT
(
client
==
*
s
->
client
);
if
(
!
s
->
configureSerials
.
contains
(
serial
))
{
// TODO: send error?
return
;
}
while
(
!
s
->
configureSerials
.
isEmpty
())
{
quint32
i
=
s
->
configureSerials
.
takeFirst
();
emit
s
->
q_func
()
->
configureAcknowledged
(
i
);
if
(
i
==
serial
)
{
break
;
}
}
}
void
XdgSurfaceV5Interface
::
Private
::
setWindowGeometryCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
height
)
{
if
(
width
<
0
||
height
<
0
)
{
wl_resource_post_error
(
resource
,
-
1
,
"Tried to set invalid xdg-surface geometry"
);
return
;
}
auto
s
=
cast
<
Private
>
(
resource
);
Q_ASSERT
(
client
==
*
s
->
client
);
s
->
m_pendingState
.
windowGeometry
=
QRect
(
x
,
y
,
width
,
height
);
s
->
m_pendingState
.
windowGeometryIsSet
=
true
;
}
void
XdgSurfaceV5Interface
::
Private
::
setMaximizedCallback
(
wl_client
*
client
,
wl_resource
*
resource
)
{
auto
s
=
cast
<
Private
>
(
resource
);
Q_ASSERT
(
client
==
*
s
->
client
);
s
->
q_func
()
->
maximizedChanged
(
true
);
}
void
XdgSurfaceV5Interface
::
Private
::
unsetMaximizedCallback
(
wl_client
*
client
,
wl_resource
*
resource
)
{
auto
s
=
cast
<
Private
>
(
resource
);
Q_ASSERT
(
client
==
*
s
->
client
);
s
->
q_func
()
->
maximizedChanged
(
false
);
}
void
XdgSurfaceV5Interface
::
Private
::
setFullscreenCallback
(
wl_client
*
client
,
wl_resource
*
resource
,
wl_resource
*
output
)
{
auto
s
=
cast
<
Private
>
(
resource
);
Q_ASSERT
(
client
==
*
s
->
client
);
OutputInterface
*
o
=
nullptr
;
if
(
output
)
{
o
=
OutputInterface
::
get
(
output
);
}
s
->
q_func
()
->
fullscreenChanged
(
true
,
o
);
}
void
XdgSurfaceV5Interface
::
Private
::
unsetFullscreenCallback
(
wl_client
*
client
,
wl_resource
*
resource
)
{
auto
s
=
cast
<
Private
>
(
resource
);
Q_ASSERT
(
client
==
*
s
->
client
);
s
->
q_func
()
->
fullscreenChanged
(
false
,
nullptr
);
}