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
58cd4825
Commit
58cd4825
authored
Jul 01, 2020
by
Vlad Zahorodnii
Browse files
Port the wl_region wrapper to the new approach
parent
c42fc80d
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/wayland/CMakeLists.txt
View file @
58cd4825
...
...
@@ -79,6 +79,11 @@ ecm_qt_declare_logging_category(SERVER_LIB_SRCS
EXPORT KWAYLAND
)
ecm_add_qtwayland_server_protocol
(
SERVER_LIB_SRCS
PROTOCOL
${
Wayland_DATADIR
}
/wayland.xml
BASENAME wayland
)
ecm_add_wayland_server_protocol
(
SERVER_LIB_SRCS
PROTOCOL
${
PLASMA_WAYLAND_PROTOCOLS_DIR
}
/output-management.xml
BASENAME output-management
...
...
src/wayland/autotests/client/test_wayland_region.cpp
View file @
58cd4825
...
...
@@ -136,7 +136,6 @@ void TestRegion::testCreate()
auto
serverRegion
=
regionCreatedSpy
.
first
().
first
().
value
<
KWaylandServer
::
RegionInterface
*>
();
QVERIFY
(
serverRegion
);
QCOMPARE
(
serverRegion
->
region
(),
QRegion
());
QCOMPARE
(
serverRegion
->
global
(),
m_compositorInterface
);
}
void
TestRegion
::
testCreateWithRegion
()
...
...
@@ -154,7 +153,6 @@ void TestRegion::testCreateWithRegion()
auto
serverRegion
=
regionCreatedSpy
.
first
().
first
().
value
<
KWaylandServer
::
RegionInterface
*>
();
QVERIFY
(
serverRegion
);
QCOMPARE
(
serverRegion
->
region
(),
QRegion
(
0
,
0
,
10
,
20
));
QVERIFY
(
serverRegion
->
parentResource
());
}
void
TestRegion
::
testCreateUniquePtr
()
...
...
@@ -282,16 +280,12 @@ void TestRegion::testDisconnect()
auto
serverRegion
=
regionCreatedSpy
.
first
().
first
().
value
<
RegionInterface
*>
();
// destroy client
QSignalSpy
clientDisconnectedSpy
(
serverRegion
->
client
(),
&
ClientConnection
::
disconnected
);
QVERIFY
(
clientDisconnectedSpy
.
isValid
());
QSignalSpy
regionDestroyedSpy
(
serverRegion
,
&
QObject
::
destroyed
);
QVERIFY
(
regionDestroyedSpy
.
isValid
());
if
(
m_connection
)
{
m_connection
->
deleteLater
();
m_connection
=
nullptr
;
}
QVERIFY
(
clientDisconnectedSpy
.
wait
());
QCOMPARE
(
clientDisconnectedSpy
.
count
(),
1
);
QCOMPARE
(
regionDestroyedSpy
.
count
(),
0
);
QVERIFY
(
regionDestroyedSpy
.
wait
());
QCOMPARE
(
regionDestroyedSpy
.
count
(),
1
);
...
...
src/wayland/compositor_interface.cpp
View file @
58cd4825
...
...
@@ -99,14 +99,13 @@ void CompositorInterface::Private::createRegionCallback(wl_client *client, wl_re
void
CompositorInterface
::
Private
::
createRegion
(
wl_client
*
client
,
wl_resource
*
resource
,
uint32_t
id
)
{
RegionInterface
*
region
=
new
R
egion
I
nterface
(
q
,
resource
);
region
->
create
(
display
->
getConnection
(
client
),
wl_resource_get_version
(
resource
),
id
);
if
(
!
region
->
r
esource
()
)
{
wl_resource
*
regionResource
=
wl_resource_create
(
client
,
&
wl_r
egion
_i
nterface
,
wl_resource_get_version
(
resource
),
id
);
if
(
!
region
R
esource
)
{
wl_resource_post_no_memory
(
resource
);
delete
region
;
return
;
}
emit
q
->
regionCreated
(
region
);
emit
q
->
regionCreated
(
new
RegionInterface
(
q
,
regionResource
)
);
}
}
src/wayland/region_interface.cpp
View file @
58cd4825
/*
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include
"region_interface.h"
#include
"resource_p.h"
#include
"compositor_interface.h"
// Wayland
#include
<
wayland-server.h
>
#include
"q
wayland-server
-wayland
.h
"
namespace
KWaylandServer
{
class
RegionInterface
::
Private
:
public
Resource
::
Private
class
RegionInterfacePrivate
:
public
QtWaylandServer
::
wl_region
{
public:
Private
(
CompositorInterface
*
compositor
,
RegionInterface
*
q
,
wl_resource
*
parentResource
);
~
Private
();
QRegion
qtRegion
;
private:
RegionInterface
*
q_func
()
{
return
reinterpret_cast
<
RegionInterface
*>
(
q
);
}
void
add
(
const
QRect
&
rect
);
void
subtract
(
const
QRect
&
rect
);
static
void
addCallback
(
wl_client
*
client
,
wl_resource
*
r
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
height
);
static
void
subtractCallback
(
wl_client
*
client
,
wl_resource
*
r
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
height
);
RegionInterfacePrivate
(
RegionInterface
*
q
,
wl_resource
*
resource
);
static
const
struct
wl_r
egion
_i
nterface
s_interface
;
}
;
R
egion
I
nterface
*
q
;
QRegion
qtRegion
;
#ifndef K_DOXYGEN
const
struct
wl_region_interfa
ce
Re
gionInterface
::
Private
::
s_interface
=
{
resourceDestroyedCallback
,
addCallback
,
subtractCallback
protected:
void
region_destroy_resour
ce
(
Re
source
*
resource
)
override
;
void
region_destroy
(
Resource
*
resource
)
override
;
void
region_add
(
Resource
*
resource
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
height
)
override
;
void
region_subtract
(
Resource
*
resource
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
height
)
override
;
};
#endif
RegionInterface
::
Private
::
Private
(
CompositorInterface
*
compositor
,
RegionInterface
*
q
,
wl_resource
*
parentResource
)
:
Resource
::
Private
(
q
,
compositor
,
parentResource
,
&
wl_region_interface
,
&
s_interface
)
RegionInterfacePrivate
::
RegionInterfacePrivate
(
RegionInterface
*
q
,
wl_resource
*
resource
)
:
QtWaylandServer
::
wl_region
(
resource
)
,
q
(
q
)
{
}
RegionInterface
::
Private
::~
Private
()
=
default
;
void
RegionInterfacePrivate
::
region_destroy_resource
(
Resource
*
)
{
delete
q
;
}
void
RegionInterface
::
Private
::
add
(
const
QRect
&
rect
)
void
RegionInterfacePrivate
::
region_destroy
(
Resource
*
resource
)
{
qtRegion
=
qtRegion
.
united
(
rect
);
Q_Q
(
RegionInterface
);
emit
q
->
regionChanged
(
qtRegion
);
wl_resource_destroy
(
resource
->
handle
);
}
void
RegionInterface
::
Private
::
subtract
(
const
QRect
&
rec
t
)
void
RegionInterfacePrivate
::
region_add
(
Resource
*
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
heigh
t
)
{
if
(
qtRegion
.
isEmpty
())
{
return
;
}
qtRegion
=
qtRegion
.
subtracted
(
rect
);
Q_Q
(
RegionInterface
);
qtRegion
+=
QRegion
(
x
,
y
,
width
,
height
);
emit
q
->
regionChanged
(
qtRegion
);
}
void
RegionInterface
::
Private
::
addCallback
(
wl_client
*
client
,
wl_r
esource
*
r
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
height
)
void
RegionInterfacePrivate
::
region_subtract
(
R
esource
*
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
height
)
{
Q_UNUSED
(
clien
t
)
cast
<
Private
>
(
r
)
->
add
(
QRect
(
x
,
y
,
width
,
height
)
);
qtRegion
-=
QRegion
(
x
,
y
,
width
,
heigh
t
)
;
emit
q
->
regionChanged
(
qtRegion
);
}
void
RegionInterface
::
Private
::
subtractCallback
(
wl_client
*
client
,
wl_resource
*
r
,
int32_t
x
,
int32_t
y
,
int32_t
width
,
int32_t
height
)
RegionInterface
::
RegionInterface
(
CompositorInterface
*
compositor
,
wl_resource
*
resource
)
:
QObject
(
compositor
)
,
d
(
new
RegionInterfacePrivate
(
this
,
resource
))
{
Q_UNUSED
(
client
)
cast
<
Private
>
(
r
)
->
subtract
(
QRect
(
x
,
y
,
width
,
height
));
}
RegionInterface
::
RegionInterface
(
CompositorInterface
*
parent
,
wl_resource
*
parentResource
)
:
Resource
(
new
Private
(
parent
,
this
,
parentResource
))
RegionInterface
::~
RegionInterface
()
{
}
RegionInterface
::~
RegionInterface
()
=
default
;
QRegion
RegionInterface
::
region
()
const
{
Q_D
();
return
d
->
qtRegion
;
}
RegionInterface
*
RegionInterface
::
get
(
wl_resource
*
native
)
{
return
Private
::
get
<
RegionInterface
>
(
native
);
}
RegionInterface
::
Private
*
RegionInterface
::
d_func
()
const
{
return
reinterpret_cast
<
Private
*>
(
d
.
data
());
if
(
auto
region
=
RegionInterfacePrivate
::
Resource
::
fromResource
(
native
))
{
return
static_cast
<
RegionInterfacePrivate
*>
(
region
->
object
())
->
q
;
}
return
nullptr
;
}
}
}
// namespace KWaylandServer
src/wayland/server/region_interface.h
View file @
58cd4825
/*
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
...
...
@@ -11,11 +12,13 @@
#include
<KWaylandServer/kwaylandserver_export.h>
#include
"
resource
.h"
struct
wl_
resource
;
namespace
KWaylandServer
{
class
CompositorInterface
;
class
RegionInterfacePrivate
;
/**
* @brief Resource for the wl_region.
...
...
@@ -25,7 +28,7 @@ class CompositorInterface;
*
* @see CompositorInterface
**/
class
KWAYLANDSERVER_EXPORT
RegionInterface
:
public
Resource
class
KWAYLANDSERVER_EXPORT
RegionInterface
:
public
QObject
{
Q_OBJECT
public:
...
...
@@ -49,10 +52,8 @@ Q_SIGNALS:
private:
friend
class
CompositorInterface
;
explicit
RegionInterface
(
CompositorInterface
*
parent
,
wl_resource
*
parentResource
);
class
Private
;
Private
*
d_func
()
const
;
explicit
RegionInterface
(
CompositorInterface
*
compositor
,
wl_resource
*
resource
);
QScopedPointer
<
RegionInterfacePrivate
>
d
;
};
}
...
...
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