Commit graph

925 commits

Author SHA1 Message Date
Martin Gräßlin
f72e4a4d6f Add a Client::EventQueue
The EventQueue is a wrapper for wl_event_queue. The usage is for the
case that the connection is in a different thread.

The EventQueue needs to be added to the Registry before Registry::create
is invoked. This ensures that the Registry gets added to the EventQueue
and all objects created by the Registry (and further down the tree)
will be added to the same EventQueue.

The auto-tests which already used a wl_event_queue are transited to the
EventQueue class. That's also the reason why there is no dedicated
unit test: the new code is sufficiently tested by the existing tests.
2014-09-23 11:55:07 +02:00
Martin Gräßlin
53b9b5b9b2 Add ::destroy to Client::Keyboard and Client::Pointer
This makes the API more consistent and allows to properly cleanup
Keyboard and Pointer if the connection dies. Like with Shell and
ShellSurface signals are emitted from Seat when the interface is
going to be released or destroyed. These are connected to the
methods of the created Pointer and Keyboard.
2014-09-22 13:12:08 +02:00
Martin Gräßlin
6ea3abc56d Add test case for Seat::destroy 2014-09-22 12:02:57 +02:00
Martin Gräßlin
ff9c6ea23d Add test case for operator cast in Client::Seat 2014-09-22 11:56:48 +02:00
Martin Gräßlin
d267cdca02 Add test case for operator cast in Client::Shell
One test also adjusted to get the operator cast in ShellSurface under
coverage.
2014-09-22 11:41:34 +02:00
Martin Gräßlin
bf1168db23 Add test case for ShellSurface::destroy 2014-09-22 11:33:13 +02:00
Martin Gräßlin
44a51fef8b Add test case for Surface::destroy 2014-09-22 11:14:05 +02:00
Martin Gräßlin
610e8ce484 Add test case for Registry::destroy 2014-09-22 11:08:14 +02:00
Martin Gräßlin
ca3b8b0cec Add test case for operator cast in Compositor 2014-09-22 11:03:46 +02:00
Martin Gräßlin
ebac7d3c03 Verify that Pointer isValid in the autotest 2014-09-22 11:02:16 +02:00
Martin Gräßlin
ba9270a887 Pass parent to Client::Keyboard in TestWaylandSeat
This ensures that the Keyboard doesn't leak in the test.
2014-09-22 11:00:02 +02:00
Martin Gräßlin
acb08e276d Add unit test for Client::Compositor::destroy 2014-09-22 10:24:21 +02:00
Martin Gräßlin
6f2d49e680 ShmPool returns QWeakPointer<Buffer> instead of Buffer*
The Buffers are exclusively hold by ShmPool. The user of a Buffer is not
supposed to delete it as a no longer used Buffer should be reused by the
ShmPool.

To make it obvious that the ownership of the pointer is not passed to the
user the return type is changed to QWeakPointer. This also allows the
ShmPool to destroy Buffers as needed.
2014-09-22 09:54:10 +02:00
Martin Gräßlin
aa26a42432 Do not include wayland-client-protocol.h in test_shm_pool.cpp
This should fix the build on CI system.
2014-09-22 09:01:24 +02:00
Martin Gräßlin
6394b6cd8c Add unit test for ShmPool
The unit test found a few problems which are now addressed
* getBuffer did not check the format when reusing a buffer
* creatBuffer used the wrong method on QSize to check whether it is empty
* destroy didn't call destroy on the Buffer. This is now added by moving
  the Buffer::Private in a dedicated header which can also be included
  from the ShmPool
2014-09-22 08:52:05 +02:00
Pier Luigi Fiorini
d8e4f5edf9 Add Review Board configuration 2014-09-21 11:33:11 +02:00
Martin Gräßlin
9ae04f2100 Extend test_wayland_surface to test frame rendered callback 2014-09-20 16:28:47 +02:00
Martin Gräßlin
c14bbe9c53 Change Client::ShmPool to return Client::Buffer* instead of wl_buffer* 2014-09-20 15:11:40 +02:00
Martin Gräßlin
e33c005118 Add support for Formats to Buffer and ShmPool
So far only ARGB32 and RGB32 are supported. The format is an optional
argument to all the createBuffer and getBuffer calls with a default
for ARGB32.
2014-09-19 14:53:03 +02:00
Martin Gräßlin
2bef3d08ef Check maximum supported version in Client::Registry
Ensure that we do not connect to a version which our client library
does not support. If we would allow higher versions we would run the
risk that the wayland library calls into not existing callbacks.
2014-09-19 10:54:09 +02:00
Martin Gräßlin
4d77c197a9 Add convenient create methods to Registry
These methods allow to create the Interface objects and set them up
directly.
2014-09-19 10:42:44 +02:00
Martin Gräßlin
4d70ace4df Add a Registry::create overload taking the ConnectionThread object
This means we don't need to pass the wl_display* around.
2014-09-19 09:52:50 +02:00
Martin Gräßlin
cdd2ab9b78 Do not install Server library
It's not yet used by KWin, so we don't need to expose it yet.
This gives us more time to fine tune the API.
2014-09-19 09:46:55 +02:00
Martin Gräßlin
e448b84a82 Add d-pointer to Server::SurfaceInterface
It also adds a
static SurfaceInterface *get(wl_resource*)
to SurfaceInterface which can find the SurfaceInterface for the
given wl_resource. This is needed for ShellSurfaceInterface which
can no longer just cast the wayland user data.
2014-09-19 07:06:31 +02:00
Martin Gräßlin
98ce3ec2b9 Add d-pointer to Server::ShellSurfaceInterface 2014-09-18 19:25:11 +02:00
Martin Gräßlin
b2f6704560 Add d-pointer to Server::ShellInterface 2014-09-18 18:51:35 +02:00
Martin Gräßlin
c2f89128d5 Add d-pointer to Server::KeyboardInterface 2014-09-18 17:14:50 +02:00
Martin Gräßlin
8eb325ee69 Add d-pointer to Server::PointerInterface 2014-09-18 16:58:23 +02:00
Martin Gräßlin
4b3f8ccc8d Add d-pointer to Server::SeatInterface 2014-09-18 16:35:28 +02:00
Martin Gräßlin
5a0ad8c648 Add d-pointer to Server::OutputInterface 2014-09-18 16:00:21 +02:00
Martin Gräßlin
2bee5b0e2b Add d-pointer to Server::Display 2014-09-18 15:40:22 +02:00
Martin Gräßlin
6fbb8462d4 Add d-pointer to Server::CompositorInterface 2014-09-18 15:31:01 +02:00
Martin Gräßlin
7de67ceb61 Add d-pointer to Server::BufferInterface 2014-09-18 15:21:25 +02:00
Martin Gräßlin
f2628cf831 s/kwin/kwayland in test names 2014-09-17 16:22:34 +02:00
Martin Gräßlin
9b8e9c2e89 Drop KWIN_ from include guards 2014-09-17 16:20:56 +02:00
Martin Gräßlin
677e8b66a7 Use namespace KWayland::Client instead of KWin::WaylandServer
It's no longer part of KWin.
2014-09-17 16:17:26 +02:00
Martin Gräßlin
a8c7c16c94 Use namespace KWayland::Server instead of KWin::WaylandServer
It's no longer part of KWin.
2014-09-17 16:10:38 +02:00
Martin Gräßlin
3c87cea7a8 Change to LGPLv2+
I'm the only copyright holder of the code in this repository, thus
I can change from GPL to LGPL!
2014-09-17 15:57:56 +02:00
Martin Gräßlin
8fee17fc79 Install library and headers 2014-09-17 15:47:42 +02:00
Martin Gräßlin
5e54a86d5e Generate export headers and use it in our headers
Auto tests are adjusted to link against the library instead of compiling
the source files.
2014-09-17 15:10:43 +02:00
Martin Gräßlin
e763d9acc0 Add a build system
Framework style build system which generates two libraries:
* KF5WaylandClient
* KF5WaylandServer

autotests are adjusted to compile again. They need to be changed to
use the libraries once the export header gets generated.
2014-09-17 14:35:33 +02:00
Martin Gräßlin
2dbf5e95cf Import server autotests 2014-09-17 13:25:46 +02:00
Martin Gräßlin
bc93c5c6a8 Move all files to autotests/server 2014-09-17 13:24:51 +02:00
Martin Gräßlin
3c89460dd9 Import client autotests 2014-09-17 13:23:48 +02:00
Martin Gräßlin
faa80cefb7 Move all files to autotests/client 2014-09-17 13:23:06 +02:00
Martin Gräßlin
37c5318375 Move all files to src/server 2014-09-17 13:20:55 +02:00
Martin Gräßlin
00802824d7 [autotests/wayland_client] Make TestWaylandShell more robust 2014-09-03 21:31:10 +02:00
Martin Gräßlin
08def82e13 [autotests/wayland_client] Improve TestWaylandShell
Uses our own Wayland server instead of starting Weston and adds
tests for the interface removed signals.
2014-09-03 21:13:25 +02:00
Martin Gräßlin
7003d80173 [kwin_wayland] Add assert in Display::setRunning
Making the impossible condition an assert instead of a return.
2014-09-03 20:04:31 +02:00
Martin Gräßlin
2ccaa4342a [kwin_wayland] Fix Display::outputs
Should return a const-ref not a const copy.
2014-09-03 20:03:13 +02:00
Martin Gräßlin
1574c47d27 [kwin_wayland] Test that Seat gets destroyed when Display terminates 2014-09-03 20:02:42 +02:00
Martin Gräßlin
d080ce7356 [kwin_wayland] Test adding/removing Outputs in TestWaylandServerDisplay 2014-09-03 20:01:54 +02:00
Martin Gräßlin
b51fb1f8b9 [kwin_wayland] define WL_SEAT_NAME_SINCE_VERSION if not defined
Apparently not yet in wayland server library on build.kde.org.
2014-09-02 11:11:26 +02:00
Martin Gräßlin
70dacba26f [kwin_wayland] Add SeatInterface to server module
So far the Seat interface is provided together with pointer and
keyboard. As always touch is not yet implemented. The pointer interface
is still lacking the set cursor callback. Keyboard on the other hand is
complete.

Both Keyboard and Pointer have the concept of a focused surface and only
to the bound interface belonging to the same client as the focused
surface events are sent.

The change comes with a set of new auto tests also verifying the client
side which wasn't possible before as we couldn't fake events.
2014-09-02 10:55:33 +02:00
Martin Gräßlin
3c7a59ba9e [kwin_wayland] Add SeatInterface to server module
So far the Seat interface is provided together with pointer and
keyboard. As always touch is not yet implemented. The pointer interface
is still lacking the set cursor callback. Keyboard on the other hand is
complete.

Both Keyboard and Pointer have the concept of a focused surface and only
to the bound interface belonging to the same client as the focused
surface events are sent.

The change comes with a set of new auto tests also verifying the client
side which wasn't possible before as we couldn't fake events.
2014-09-02 10:55:33 +02:00
Martin Gräßlin
9d780deeb2 [kwin_wayland] Add SeatInterface to server module
So far the Seat interface is provided together with pointer and
keyboard. As always touch is not yet implemented. The pointer interface
is still lacking the set cursor callback. Keyboard on the other hand is
complete.

Both Keyboard and Pointer have the concept of a focused surface and only
to the bound interface belonging to the same client as the focused
surface events are sent.

The change comes with a set of new auto tests also verifying the client
side which wasn't possible before as we couldn't fake events.
2014-09-02 10:55:33 +02:00
Martin Gräßlin
49f0d19710 [kwin_wayland] Add Shell and ShellSurface to server module
ShellSurfaceInterface is not yet completely implemented. Several parts
are still TODO, e.g. move/resize is missing, setting to maximized is
missing and also flags for fullscreen are missing.

The surface test is extended as far as possible.
2014-09-02 10:55:33 +02:00
Martin Gräßlin
71b125e967 [kwin_wayland] Add Shell and ShellSurface to server module
ShellSurfaceInterface is not yet completely implemented. Several parts
are still TODO, e.g. move/resize is missing, setting to maximized is
missing and also flags for fullscreen are missing.

The surface test is extended as far as possible.
2014-09-02 10:55:33 +02:00
Martin Gräßlin
0848113845 [kwin_wayland] Initial addition of the WaylandServer module
So far this new module contains:
* Display
* OutputInterface

Display manages the server socket and server event loop. In general it's
the entry point to any part of the server.

OutputInterface is the abstraction for the wl_output interface on server
side. An OutputInterface is created through the Display.

The auto tests for ConnectionThread and Output are adjusted to use the
internal server instead of starting Weston. Especially the Output test
could be extended to test much more as we have absolute control over
the server now.
2014-09-02 09:52:16 +02:00
Martin Gräßlin
70eab7e242 [kwin_wayland] Add support for shm buffers in server module
The Display provides a method to create the shm pool and a
BufferInterface class is added to the server module. It is created
from the SurfaceInterface when a buffer gets attached to the surface.
The BufferInterface can be referenced and once its unreferenced it
sends a buffer release to the client and destroys itself.

For the case that the buffer is a shm buffer the BufferInterface
provides a convenience method to turn it into a QImage.

The auto test for Surface is extended by attaching buffers to the
surface and verifying that the content is correct.
2014-09-02 09:52:16 +02:00
Martin Gräßlin
76cb898c7f [kwin_wayland] Add support for shm buffers in server module
The Display provides a method to create the shm pool and a
BufferInterface class is added to the server module. It is created
from the SurfaceInterface when a buffer gets attached to the surface.
The BufferInterface can be referenced and once its unreferenced it
sends a buffer release to the client and destroys itself.

For the case that the buffer is a shm buffer the BufferInterface
provides a convenience method to turn it into a QImage.

The auto test for Surface is extended by attaching buffers to the
surface and verifying that the content is correct.
2014-09-02 09:52:16 +02:00
Martin Gräßlin
656b740407 [kwin_wayland] Add CompositorInterface and SurfaceInterface
As far as it's currently possible to implement. CompositorInterface is
able to create a surface and emits the created SurfaceInterface. It
does not yet support regions.

The SurfaceInterface is already more complete. It keeps track of the
double buffered states and emits signals when one of the values are
changed after the committing. It supports frame callbacks and has a
hook to mark the frame as rendered.

What's still missing are the regions (as it's not implemented in
CompositorInterface) and attaching the buffer as we do not yet support
creating shm buffers and pools.

The client side test is changed to use our own server and extended to
test damage and frame callback. The test needs to be extended for scale
and transform, but that is still missing in the client side
implementation.
2014-09-02 09:52:16 +02:00
Martin Gräßlin
992d210e86 [kwin_wayland] Add CompositorInterface and SurfaceInterface
As far as it's currently possible to implement. CompositorInterface is
able to create a surface and emits the created SurfaceInterface. It
does not yet support regions.

The SurfaceInterface is already more complete. It keeps track of the
double buffered states and emits signals when one of the values are
changed after the committing. It supports frame callbacks and has a
hook to mark the frame as rendered.

What's still missing are the regions (as it's not implemented in
CompositorInterface) and attaching the buffer as we do not yet support
creating shm buffers and pools.

The client side test is changed to use our own server and extended to
test damage and frame callback. The test needs to be extended for scale
and transform, but that is still missing in the client side
implementation.
2014-09-02 09:52:16 +02:00
Martin Gräßlin
50ba61f027 [kwin_wayland] Initial addition of the WaylandServer module
So far this new module contains:
* Display
* OutputInterface

Display manages the server socket and server event loop. In general it's
the entry point to any part of the server.

OutputInterface is the abstraction for the wl_output interface on server
side. An OutputInterface is created through the Display.

The auto tests for ConnectionThread and Output are adjusted to use the
internal server instead of starting Weston. Especially the Output test
could be extended to test much more as we have absolute control over
the server now.
2014-09-02 09:52:16 +02:00
Martin Gräßlin
07bdf14dab [kwin_wayland] Initial addition of the WaylandServer module
So far this new module contains:
* Display
* OutputInterface

Display manages the server socket and server event loop. In general it's
the entry point to any part of the server.

OutputInterface is the abstraction for the wl_output interface on server
side. An OutputInterface is created through the Display.

The auto tests for ConnectionThread and Output are adjusted to use the
internal server instead of starting Weston. Especially the Output test
could be extended to test much more as we have absolute control over
the server now.
2014-09-02 09:52:16 +02:00
Martin Gräßlin
211f08446c [kwin_wayland] Keep the size in Surface
Technically the Surface itself does not have a size, it's the
ShellSurface or the size of the FullScreenShell's Output. But it
simplifies a lot if we keep track of the size in the Surface as that
way we can hide the fact which kind of Shell is used.

The user of the Surface must connect either the FullscreenShell's
Output or the ShellSurface to set the size on the Surface.
2014-09-02 09:52:16 +02:00
Martin Gräßlin
b892ae3973 [kwin_wayland] Track all created Wayland::Surface
Add static accessors to get all Surfaces and the Surface for a
wl_surface to Wayland::Surface.
2014-09-02 09:48:05 +02:00
Martin Gräßlin
db490f0d1b [kwin_wayland] Create a dedicated class for Compositor
Wraps the compositor interface.
2014-08-27 08:57:06 +02:00
Martin Gräßlin
0ab135a77c [kwin_wayland] Create a dedicated Surface class
A Surface class is split out which holds a wl_surface and supports
attaching a buffer, setting the damage and emitting a signal when the
frame callback got called.

It doesn't come with a unit test yet as it first needs the ShmPool
and Buffer properly split out to easily set it up.
2014-08-27 08:57:06 +02:00
Martin Gräßlin
c1e1d1db2b [kwin_wayland] Split out wl_shell and wl_shell_surface into dedicated classes
New classes Shell and ShellSurface are created. Both are in shell.[h|cpp]
to indicate their close relationship with the Shell having to create the
ShellSurface.

WaylandBackend is adjusted to hold a Shell* and ShellSurface* instead of
the lower level structs. This also required adjustements to the creation
of the Backend as it now doesn't set a default size any more. Thus the
backendReady signal may not be emitted before the initial configure
event arrived. This also makes it easier to support either the fullscreen
shell or wl_shell at the same time.

Of course a unit test is added for the two new classes. This needs to
be extended once we have more control over the mock Wayland server.
2014-08-27 08:57:06 +02:00
Martin Gräßlin
5e5d73ebfd [kwin_wayland] Move Wayland::Output into dedicated source files
At the same time adding an autotest for the Output, moving the listener
into the Output class and providing enums for Subpixel and Transform.

KWin now requires wl_ouput interface version 2 as that allows us to emit
the changed signal in a better way.

The unit test is not yet capable of testing everything, we need a mock
Wayland server which is more flexible.
2014-08-27 08:57:05 +02:00
Martin Gräßlin
e2f3163a3d [kwin-wayland] Add support for FullscreenShell
The FullscreenShell is a Wayland protocol provided by Weston to have
exactly one surface per output. This is exactly what KWin needs. So
in case the Wayland server we connect to provides the FullscreenShell
we prefer it over the normal Shell and mapping our surface as fullscreen.

The protocol is not yet part of wayland-client library, so the header
and source file needs to be generated. This is done during the build
process using the external tool wayland-scanner. The protocol
description is copied from the Westion 1.5 sources.

REVIEW: 119839
2014-08-27 08:55:40 +02:00
Martin Gräßlin
65c66e731b [autotests/wayland_client] Add --use-pixman and remove --no-config
Needed for running the weston on the ci-system.
2014-08-21 13:46:13 +02:00
Martin Gräßlin
5488fb512e [kwin_wayland] Add a Wayland::Registry class
The Wayland::Registry class wraps wl_registry handling. It keeps track
of the interfaces in the registry and emits signals whenever a known
interface gets announced or removed. So far it only tracks the interfaces
which are used and needed by KWin.
2014-08-18 14:05:35 +02:00
Martin Gräßlin
5b95cab34e [kwin-wayland] Create dedicated thread for wayland connection
The Wayland event queue is moved into a dedicated thread and a
new class is created for just creating the connection and listening
for events. The WaylandBackend creates the thread and uses an event
queue for the main thread.

REVIEW: 119761
2014-08-18 08:51:24 +02:00