Commit graph

158 commits

Author SHA1 Message Date
Martin Gräßlin
1bc105e2e6 Close fd DataSourceInterface::requestData
Weston does it as well and otherwise the client blocks.
2014-11-27 11:23:37 +01:00
Martin Gräßlin
0e0933cbb1 Split SeatInterface::Private into own header file
We need to include the Private in the DataDeviceManager, thus it
needs to be in an own header.
2014-11-27 09:52:11 +01:00
Martin Gräßlin
8f2f94798d Cleanup SeatInterface after refactoring 2014-11-26 15:42:33 +01:00
Martin Gräßlin
7baf5896be Merge SeatInterface::Private::pointerForSurface and ::keyboardForSurface
templated helper method.
2014-11-26 15:34:46 +01:00
Martin Gräßlin
6504e067bc KeyboardInterface inherits Resource 2014-11-26 15:28:47 +01:00
Martin Gräßlin
99598167d7 Refactor KeyboardInterface
The KeyboardInterface gets created per wl_resource. For this all
more global information (e.g. key states) is moved into the
SeatInterface.
2014-11-26 15:00:44 +01:00
Martin Gräßlin
d7a9be72ea Get event timestamp from SeatInterface in KeyboardInterface 2014-11-26 13:04:36 +01:00
Martin Gräßlin
c6281ac64e Move pointer position into the Pointer struct in SeatInterface::Private 2014-11-26 11:57:10 +01:00
Martin Gräßlin
ce07100383 Make PointerInterface::focusedSurface public 2014-11-26 11:55:35 +01:00
Martin Gräßlin
bafb03bd3a Drop global position from PointerInterface
No longer needed, not even as a convenience wrapper.
2014-11-26 11:54:53 +01:00
Martin Gräßlin
d425515a99 Move pointer button handling from PointerInterface to SeatInterface
The button state is a seat-global state and not a per pointer state.
All pressed/released and axis events are moved to the SeatInterface
and just invoke the related method on the focused surface pointer.
2014-11-26 11:50:52 +01:00
Martin Gräßlin
a7463f6f32 Turn PointerInterface into a Resource 2014-11-26 11:03:32 +01:00
Martin Gräßlin
ef1a0a0e64 Create one PointerInterface for each pointer wl_resource
Makes PointerInterface more like other Interface classes wrapping
wl_resource. The most important change is the handling of the
focused surface. This is now kept in the SeatInterface and can also
be set if there is no PointerInterface for the client yet.

The unit tests had to be adjusted and some are also disabled as the
button events are not yet moved into SeatInterface.
2014-11-26 10:34:23 +01:00
Martin Gräßlin
961aaae8f1 [server] Add a SeatInterface::focusedPointer
This method is supposed to return the PointerInterface for the current
focused surface. At the moment it just creates the one global
PointerInterface. The existing SeatInterface::pointer method got
removed as that is actually wrong usage.
2014-11-25 16:04:07 +01:00
Martin Gräßlin
ff806d1657 Move focused pointer surface API to SeatInterface
There can only be one focused surface per Seat, thus the information
should be hold in the seat.

This only adjusts the API, the actual data is still hold in the
PointerInterface. This still needs adjustment.
2014-11-25 15:54:28 +01:00
Martin Gräßlin
41fbb0a6ee [server] Keep timestamp in SeatInterface instead of PointerInterface 2014-11-25 15:29:01 +01:00
Martin Gräßlin
12477a66fc [server] Move pointer position from PointerInterface to SeatInterface
PointerInterface should only wrap a Resource. In order to do so all
global state needs to move into the Global.
2014-11-25 14:24:52 +01:00
Martin Gräßlin
8f9a9fedb1 [server] Drop Display* from PointerInterface and KeyboardInterface
We can get it through the Global passed to PointerInterface and
KeyboardInterface. No need to pass it further around.
2014-11-25 13:58:25 +01:00
Martin Gräßlin
e6b91f5628 [server] Move PointerInterface into own .h and .cpp 2014-11-25 13:53:16 +01:00
Martin Gräßlin
80d0fb1e94 [server] Move KeyboardInterface into dedicated .h and .cpp 2014-11-25 13:39:24 +01:00
Martin Gräßlin
e05dfff919 Include(ECMMarkAsTest) in tests/
BUG: 341109
2014-11-20 16:45:32 +01:00
Martin Gräßlin
68ce470231 Add a parentResource to Resource 2014-11-20 16:40:14 +01:00
Sebastian Kügler
9e3aa9a7e3 Set physical size to something sensible -- 40x30 cm
Requested-by: Martin Gräßlin
2014-11-20 10:00:51 +01:00
Martin Gräßlin
f8bc3e6598 Drop incorrect Q_UNUSED 2014-11-19 19:07:14 +01:00
Martin Gräßlin
b243eea6cd Add createResource to ClientConnection
One place to rule all createResource calls.
2014-11-19 19:01:15 +01:00
Martin Gräßlin
fce51fb313 Add a flush to ClientConnection 2014-11-19 17:02:27 +01:00
Martin Gräßlin
14d052d9d1 Remove client credentials from ShellSurface
It's now part of ClientConnection, where it makes more sense.

This allowed to make Resource::Private::create non-virtual.
2014-11-19 16:57:12 +01:00
Martin Gräßlin
c71cf3999c Resource holds a ClientConnection instead of a wl_client 2014-11-19 16:53:56 +01:00
Martin Gräßlin
b770cbb140 Expose all ClientConnections in Display 2014-11-17 18:15:50 +01:00
Martin Gräßlin
4a7af2c665 Add test condition in test_display.cpp 2014-11-17 16:21:54 +01:00
Martin Gräßlin
8f11a2b0e5 Adding a new ClientConnection class for wrapping wl_client
The ClientConnection is managed by Display. Whenever one tries to
get a ClientConnection for a wl_client* and it doesn't exist yet a
new one will be created and a clientConnected signal will be emitted.
Also there is a clientDisconnected signal.

ClientConnection provides access to pid, uid and gid. The idea is
to extend it to provide access to all the resources created for the
client.
2014-11-17 16:01:18 +01:00
Martin Gräßlin
8685a0e972 Create wl_resource in Resource::Private instead of subclasses
Required information is passed through the ctor of Private.
::create is still virtual as ShellSurfaceInterface is retrieving
client information. This can be fixed once we have a better wl_client
encapsulation class.
2014-11-14 15:33:21 +01:00
Martin Gräßlin
57de2df55e Track all created Resources in Resource::Private
Also provide static method to map a wl_resource to the Resource
sub class.
2014-11-14 15:13:06 +01:00
Martin Gräßlin
cee32f902a Move static unbind method from derived classes to Resource::Private
All classes had exactly the same implementation, so it's a good idea
to share the implementation.
2014-11-14 11:01:54 +01:00
Martin Gräßlin
0fb42d102e Move q-ptr to Resource::Private
In the derived classes a q_func() is added which casts the q-ptr
back to the Resource derived class.
2014-11-14 10:55:06 +01:00
Martin Gräßlin
de62216357 Add cast from wl_resource to Private to Resource::Private
Replaces the custom implementation in each of the derived classes.
2014-11-14 10:20:43 +01:00
Martin Gräßlin
53a4455c47 [server] Introduce a base class Resource
The Resource base class is supposed to be used by all interface
classes which get created for a wl_resource.

Most interface classes are adjusted, but there are some exceptions:
* BufferInterface: is different as the wl_resource is already created
* PointerInterface and KeyboardInterface: those two need changes, the
  implementation differs from all other interface implementations.
2014-11-14 09:45:02 +01:00
Martin Gräßlin
2eb75bdac9 Global::Private can create the wl_global
Version and interface get passed to the ctor allowing Global::Private
to implement ::create instead of providing a pure virtual method.
Also the static bind method is added to the Global::Private which
delegates into a pure virtual method.
2014-11-13 18:43:18 +01:00
Martin Gräßlin
22197da94b Add a base class for all server interfaces of a wl_global
New base class KWayland::Server::Global which all Interface classes
for a wl_global inherit. Furthermore there is a shared base class
for all the Private classes of that type.
2014-11-13 15:10:35 +01:00
Martin Gräßlin
dd50148187 [server] Interface method returning wl_resource* is called ::resource
Simplifies using the library as all Interfaces have the same methods.
Note: there are interfaces not providing the wl_resource* method.
2014-11-13 13:05:01 +01:00
Martin Gräßlin
c81271a3b4 Fix shared memory access in BufferInterface
The BufferInterface used nested calls of wl_shm_buffer_begin_access
and allowed multiple different BufferInterfaces to be in a block
between wl_shm_buffer_begin_access and wl_shm_buffer_end_access.
But this is not allowed: nesting is only possible if it accesses
the same buffer!

This resulted in an abort when we accessed two BufferInterfaces
at the same time. The added test case aborts in the previous
version.

The fix now changes the semantic of the method. The BufferInterface
doesn't hold the QImage any more, but creates a new one every time
::data is invoked. The QImage is created with a custom cleanup
function which calls to wl_shm_buffer_end_access. It ensures that
we don't call into wl_shm_buffer_begin_access as long as there is
a valid QImage for any other BufferInterface still around and
instead returns a null QImage.

Thus a user of a BufferInterface::data should destroy the returned
QImage as soon as it's no longer needed or create a deep copy if
it needs to be kept around.
2014-11-13 08:30:51 +01:00
Martin Gräßlin
6c406df725 Adding a test application for paste
Counter part for the copyClient test app: the pasteClient test app
creates and maps a shell surface and waits for selection announce,
initiates the copy/paste mechanismn and prints out what got pasted.
After success it closes itself.
2014-11-12 14:05:46 +01:00
Martin Gräßlin
3f10218d77 Adding a test application for copy
The test application copyClient creates a ShellSurface, maps it as
fullscreen, renders a green buffer and when it gets pointer focus it
sets "foo" in mimetype "text/plain" into the selection.
2014-11-12 13:17:26 +01:00
Martin Gräßlin
5cd92ba7e2 Adding a test application supporting output to a QWidget
This test application "testRenderingServer" is able to start a
Wayland server and uses a QWidget to render the "scene". It manages
ShellSurfaces and renders them on the QWidget in a very static way.
Furthermore input events (key, pointer, wheel) are forwarded to the
top most Surface.

This test server is able to support kwin_wayland as a client, but
weston's test application in latest release fail due to missing
xdg_shell support.
2014-11-10 14:56:17 +01:00
Martin Gräßlin
ce7a6edaea Overloads taking Qt::MouseButton added to Server::SeatInterface
Qt::MouseButton is mapped to the linux buttons. The mapping does
not match the mapping used in QtWayland module [1] as that seems
to be incorrect to me. E.g. Qt::BackButton is not mapped to BTN_BACK.

[1] qtwayland/src/client/qwaylandinputdevice.cpp
2014-11-10 14:51:09 +01:00
Martin Gräßlin
3fa065a2bd Remove destroy listener on BufferInterface in dtor
One needs to use wl_list_remove for the listeners one creates.
2014-11-07 19:09:36 +01:00
Martin Gräßlin
34af4b1cf8 Fix check whether there is already a ShellSurface for a given Surface
Incorrect logic prevented that more than one ShellSurface could be
created.
2014-11-07 17:07:48 +01:00
Martin Gräßlin
bf4c5ef26b Test server extended to start Xwayland server
Proof-of-concept code illustrating how to start a Wayland server
before creating the QGuiApplication and also starting an Xwayland
server before creating the QGuiApplication. Thus the QGuiApplication
is able to connect to the Xwayland server started in the same
application.
2014-11-07 11:48:32 +01:00
Martin Gräßlin
9d5d8d0871 Display can start the server before QCoreApplication is created
Event dispatching in Display requires a QSocketNotifier which
requires the QCoreApplication to be created. This requirement renders
it impossible to create the server before the QCoreApplication is
created. But there are use cases which need this:

Let's assume we want to integrate a wayland server into an existing
X11 dependent application which uses QApplication and enforces the
xcb plugin. This means said application requires that an X Server is
up and running before the QApplication is created. If we want said
application to connect to an Xwayland server we need to be able to
create the Wayland server AND the Xwayland server before creating
the QApplication.

The solution is to only create the socket notifier if the
QCoreApplication exists. For the case that it doesn't exist an
additional method is added which needs to be called once the
QCoreApplication got created. In addition a manual event dispatch
method is added which allows to block for events when we don't
have a QSocketNotifier set up yet.
2014-11-07 11:41:37 +01:00
Martin Gräßlin
376a2ffac9 Add a simple testServer binary 2014-11-07 09:08:29 +01:00