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
89dc01ad
Commit
89dc01ad
authored
May 13, 2021
by
Vlad Zahorodnii
Browse files
Add a PlasmaShellSurfaceInterface getter
This allows to simplify some compositor code.
parent
c2fc3387
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/wayland/plasmashell_interface.cpp
View file @
89dc01ad
...
...
@@ -15,14 +15,13 @@ namespace KWaylandServer
{
static
const
quint32
s_version
=
6
;
static
QList
<
PlasmaShellSurfaceInterface
*>
s_shellSurfaces
;
class
PlasmaShellInterfacePrivate
:
public
QtWaylandServer
::
org_kde_plasma_shell
{
public:
PlasmaShellInterfacePrivate
(
PlasmaShellInterface
*
q
,
Display
*
display
);
QList
<
PlasmaShellSurfaceInterface
*>
shellSurfaces
;
private:
void
org_kde_plasma_shell_get_surface
(
Resource
*
resource
,
uint32_t
id
,
struct
::
wl_resource
*
surface
)
override
;
PlasmaShellInterface
*
q
;
...
...
@@ -79,10 +78,7 @@ void PlasmaShellInterfacePrivate::org_kde_plasma_shell_get_surface(QtWaylandServ
return
;
}
auto
it
=
std
::
find_if
(
shellSurfaces
.
constBegin
(),
shellSurfaces
.
constEnd
(),
[
&
s
](
PlasmaShellSurfaceInterface
*
shellSurface
)
{
return
shellSurface
->
surface
()
==
s
;
});
if
(
it
!=
shellSurfaces
.
constEnd
())
{
if
(
PlasmaShellSurfaceInterface
::
get
(
s
))
{
wl_resource_post_error
(
resource
->
handle
,
0
,
"org_kde_plasma_shell_surface already exists"
);
return
;
}
...
...
@@ -90,10 +86,10 @@ void PlasmaShellInterfacePrivate::org_kde_plasma_shell_get_surface(QtWaylandServ
wl_resource
*
shell_resource
=
wl_resource_create
(
resource
->
client
(),
&
org_kde_plasma_surface_interface
,
resource
->
version
(),
id
);
auto
shellSurface
=
new
PlasmaShellSurfaceInterface
(
s
,
shell_resource
);
shellSurfaces
.
append
(
shellSurface
);
s_
shellSurfaces
.
append
(
shellSurface
);
QObject
::
connect
(
shellSurface
,
&
QObject
::
destroyed
,
q
,
[
this
,
shellSurface
]()
{
shellSurfaces
.
removeOne
(
shellSurface
);
QObject
::
connect
(
shellSurface
,
&
QObject
::
destroyed
,
[
shellSurface
]()
{
s_
shellSurfaces
.
removeOne
(
shellSurface
);
});
emit
q
->
surfaceCreated
(
shellSurface
);
...
...
@@ -310,4 +306,14 @@ PlasmaShellSurfaceInterface *PlasmaShellSurfaceInterface::get(wl_resource *nativ
return
nullptr
;
}
PlasmaShellSurfaceInterface
*
PlasmaShellSurfaceInterface
::
get
(
SurfaceInterface
*
surface
)
{
for
(
PlasmaShellSurfaceInterface
*
shellSurface
:
qAsConst
(
s_shellSurfaces
))
{
if
(
shellSurface
->
surface
()
==
surface
)
{
return
shellSurface
;
}
}
return
nullptr
;
}
}
src/wayland/plasmashell_interface.h
View file @
89dc01ad
...
...
@@ -153,6 +153,7 @@ public:
* @returns The PlasmaShellSurfaceInterface for the @p native resource.
*/
static
PlasmaShellSurfaceInterface
*
get
(
wl_resource
*
native
);
static
PlasmaShellSurfaceInterface
*
get
(
SurfaceInterface
*
surface
);
Q_SIGNALS:
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment