Commit 28ed0ced authored by Ben Cooksley's avatar Ben Cooksley
Browse files

Merge kwayland-server into kwin.

Ref T15459
parents ef7d51f0 411679ea
Pipeline #166807 passed with stage
in 15 minutes and 20 seconds
set(SERVER_LIB_SRCS
abstract_data_source.cpp
abstract_drop_handler.cpp
appmenu_interface.cpp
blur_interface.cpp
clientbuffer.cpp
clientbufferintegration.cpp
clientconnection.cpp
compositor_interface.cpp
contrast_interface.cpp
datacontroldevice_v1_interface.cpp
datacontroldevicemanager_v1_interface.cpp
datacontroloffer_v1_interface.cpp
datacontrolsource_v1_interface.cpp
datadevice_interface.cpp
datadevicemanager_interface.cpp
dataoffer_interface.cpp
datasource_interface.cpp
display.cpp
dpms_interface.cpp
drmclientbuffer.cpp
drmleasedevice_v1_interface.cpp
fakeinput_interface.cpp
filtered_display.cpp
idle_interface.cpp
idleinhibit_v1_interface.cpp
inputmethod_v1_interface.cpp
keyboard_interface.cpp
keyboard_shortcuts_inhibit_v1_interface.cpp
keystate_interface.cpp
layershell_v1_interface.cpp
linuxdmabufv1clientbuffer.cpp
output_interface.cpp
outputdevice_v2_interface.cpp
outputconfiguration_v2_interface.cpp
outputmanagement_v2_interface.cpp
outputchangeset_v2.cpp
plasmashell_interface.cpp
plasmavirtualdesktop_interface.cpp
plasmawindowmanagement_interface.cpp
pointer_interface.cpp
pointerconstraints_v1_interface.cpp
pointergestures_v1_interface.cpp
primaryoutput_v1_interface.cpp
primaryselectiondevice_v1_interface.cpp
primaryselectiondevicemanager_v1_interface.cpp
primaryselectionoffer_v1_interface.cpp
primaryselectionsource_v1_interface.cpp
region_interface.cpp
relativepointer_v1_interface.cpp
screencast_v1_interface.cpp
seat_interface.cpp
server_decoration_interface.cpp
server_decoration_palette_interface.cpp
shadow_interface.cpp
shmclientbuffer.cpp
slide_interface.cpp
subcompositor_interface.cpp
surface_interface.cpp
surfacerole.cpp
tablet_v2_interface.cpp
textinput.cpp
textinput_v2_interface.cpp
textinput_v3_interface.cpp
touch_interface.cpp
viewporter_interface.cpp
xdgactivation_v1_interface.cpp
xdgdecoration_v1_interface.cpp
xdgforeign_v2_interface.cpp
xdgoutput_v1_interface.cpp
xdgshell_interface.cpp
)
ecm_qt_declare_logging_category(SERVER_LIB_SRCS
HEADER logging.h
IDENTIFIER KWAYLAND_SERVER
CATEGORY_NAME kwayland-server
DEFAULT_SEVERITY Critical
DESCRIPTION "KWayland Server Library"
EXPORT KWAYLANDSERVER
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${Wayland_DATADIR}/wayland.xml
BASENAME wayland
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-device-v2.xml
BASENAME kde-output-device-v2
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml
BASENAME kde-primary-output-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-management-v2.xml
BASENAME kde-output-management-v2
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/plasma-shell.xml
BASENAME plasma-shell
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/plasma-virtual-desktop.xml
BASENAME org-kde-plasma-virtual-desktop
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/plasma-window-management.xml
BASENAME plasma-window-management
)
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/surface-extension.xml
BASENAME qt-surface-extension
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/idle.xml
BASENAME idle
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/fake-input.xml
BASENAME fake-input
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/shadow.xml
BASENAME shadow
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/dpms.xml
BASENAME dpms
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/blur.xml
BASENAME blur
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/contrast.xml
BASENAME contrast
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml
BASENAME relative-pointer-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/slide.xml
BASENAME slide
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/server-decoration.xml
BASENAME server-decoration
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v1.xml
BASENAME text-input-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/text-input-unstable-v2.xml
BASENAME text-input-unstable-v2
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v3.xml
BASENAME text-input-unstable-v3
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml
BASENAME pointer-gestures-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
BASENAME pointer-constraints-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml
BASENAME xdg-foreign-unstable-v2
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
BASENAME idle-inhibit-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/appmenu.xml
BASENAME appmenu
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/server-decoration-palette.xml
BASENAME server-decoration-palette
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-output/xdg-output-unstable-v1.xml
BASENAME xdg-output-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml
BASENAME xdg-shell
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
BASENAME xdg-decoration-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/keystate.xml
BASENAME keystate
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
BASENAME linux-dmabuf-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/tablet/tablet-unstable-v2.xml
BASENAME tablet-unstable-v2
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PROJECT_SOURCE_DIR}/src/protocols/wlr-data-control-unstable-v1.xml
BASENAME wlr-data-control-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PROJECT_SOURCE_DIR}/src/protocols/wlr-layer-shell-unstable-v1.xml
BASENAME wlr-layer-shell-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml
BASENAME keyboard-shortcuts-inhibit-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/stable/viewporter/viewporter.xml
BASENAME viewporter
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/primary-selection/primary-selection-unstable-v1.xml
BASENAME wp-primary-selection-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml
BASENAME zkde-screencast-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml
BASENAME input-method-unstable-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/staging/xdg-activation/xdg-activation-v1.xml
BASENAME xdg-activation-v1
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/staging/drm-lease/drm-lease-v1.xml
BASENAME drm-lease-v1
)
add_library(KWaylandServer ${SERVER_LIB_SRCS})
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
target_sources(KWaylandServer PRIVATE utils/executable_path_proc.cpp)
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
target_sources(KWaylandServer PRIVATE utils/executable_path_sysctl.cpp)
else()
message(FATAL_ERROR "Unsupported platform ${CMAKE_SYSTEM_NAME}")
endif()
add_library(Plasma::KWaylandServer ALIAS KWaylandServer)
ecm_generate_export_header(KWaylandServer
BASE_NAME
KWaylandServer
EXPORT_FILE_NAME
KWaylandServer/kwaylandserver_export.h
GROUP_BASE_NAME KF
VERSION ${PROJECT_VERSION}
)
target_include_directories(KWaylandServer INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR}>")
target_link_libraries(KWaylandServer
PUBLIC
Qt::Gui
Wayland::Server
PRIVATE
EGL::EGL
Qt::Concurrent
)
target_compile_definitions(KWaylandServer PRIVATE
MESA_EGL_NO_X11_HEADERS
EGL_NO_X11
EGL_NO_PLATFORM_SPECIFIC_TYPES
)
set_target_properties(KWaylandServer PROPERTIES VERSION ${KWAYLANDSERVER_VERSION}
SOVERSION ${KWAYLANDSERVER_SOVERSION}
)
install(TARGETS KWaylandServer EXPORT KWaylandServerTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
set(SERVER_LIB_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/KWaylandServer/kwaylandserver_export.h
abstract_data_source.h
abstract_drop_handler.h
appmenu_interface.h
blur_interface.h
clientbuffer.h
clientbufferintegration.h
clientconnection.h
compositor_interface.h
contrast_interface.h
datacontroldevice_v1_interface.h
datacontroldevicemanager_v1_interface.h
datacontroloffer_v1_interface.h
datacontrolsource_v1_interface.h
datadevice_interface.h
datadevicemanager_interface.h
dataoffer_interface.h
datasource_interface.h
display.h
dpms_interface.h
drmclientbuffer.h
drmleasedevice_v1_interface.h
fakeinput_interface.h
filtered_display.h
idle_interface.h
idleinhibit_v1_interface.h
inputmethod_v1_interface.h
keyboard_interface.h
keyboard_shortcuts_inhibit_v1_interface.h
keystate_interface.h
layershell_v1_interface.h
linuxdmabufv1clientbuffer.h
output_interface.h
outputchangeset_v2.h
outputconfiguration_v2_interface.h
outputdevice_v2_interface.h
outputmanagement_v2_interface.h
plasmashell_interface.h
plasmavirtualdesktop_interface.h
plasmawindowmanagement_interface.h
pointer_interface.h
pointerconstraints_v1_interface.h
pointergestures_v1_interface.h
primaryoutput_v1_interface.h
primaryselectiondevice_v1_interface.h
primaryselectiondevicemanager_v1_interface.h
primaryselectionoffer_v1_interface.h
primaryselectionsource_v1_interface.h
relativepointer_v1_interface.h
screencast_v1_interface.h
seat_interface.h
server_decoration_interface.h
server_decoration_palette_interface.h
shadow_interface.h
shmclientbuffer.h
slide_interface.h
subcompositor_interface.h
surface_interface.h
tablet_v2_interface.h
textinput.h
textinput_v2_interface.h
textinput_v3_interface.h
touch_interface.h
utils.h
viewporter_interface.h
xdgactivation_v1_interface.h
xdgdecoration_v1_interface.h
xdgforeign_v2_interface.h
xdgoutput_v1_interface.h
xdgshell_interface.h
)
install(FILES
${SERVER_LIB_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/KWaylandServer COMPONENT Devel
)
# make available to ecm_add_qch in parent folder
set(KWaylandServer_APIDOX_SRCS ${SERVER_LIB_HEADERS} PARENT_SCOPE)
set(KWaylandServer_APIDOX_BUILD_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
# History
We started out with one method of generting classes. We then ported to a new approach of using QtWaylandScanner to reduce a lot of boiler plate.
New classes should use the new approach.
# New Approach
A public facing PIMPL class which should inherit from QObject.
A private class that should inherit from QtWaylandServer::interface_name which is auto-generated. This will manage individual resources, handle callbacks and QString conversions.
Class Names should map to the interface name in UpperCamelCase.
Where a V1 exists in the interface name, this should be mirrored in the file and class name.
An implementation should handle all versions of a given interface, but not different interfaces which represent different versions.
(i.e zxdg_output_manager_v1 versions 1 2 and 3 would be wrapped in one class XdgOutputManagerV1Interface. A zxdg_output_manager_v2 protocol would be exposed as a new public class XdgOutputManagerV2Interface)
# Implementations
There are 3 modes of operation happening within the exported classes of KWaylandServer
The generated classes can behave in all these modes, it is up to our implementation to use the correct methods.
## Globals
e.g BlurManager
This represents an object listed by the Display class.
Use the interface_name::(wl_display*, int version) constructor within the private class to create an instance.
## Server-managed multicasting resources
e.g XdgOutput
This is where one QObject represents multiple Resources.
Use the method
```cpp
QtWaylandServer::interface_name::add(client, id, version)
```
to create a a new Resource instance managed by this object.
Use the event method with the wl_resource* overload to send events.
```cpp
for (auto resource : resourceMap())
{
send_some_method(resource->handle, arg1, arg2);
}
```
methods to send requests to all clients.
## Client-owned Resources:
e.g BlurInterface
This is where one instance of our public class represents a single resource. Typically the lifespan of the exported class matches our resource.
In the private class use the QtWaylandServer::interface_name(wl_resource*) constructor to create a wrapper bound to a specific resource.
Use
```cpp
send_some_method(arg1, args2)
```
methods of the privateClass to send events to the resource set in the constructor
## Other hooks
`_bind_resource` is called whenever a resource is bound. This exists for all generated classes in all the operating modes
`_destroy_resource` is a hook called whenever a resource has been unbound.
Note one should not call wl_resource_destroy in this hook.
## Resource destructors
destructors (tagged with type="destructor" in the XML) are not handled specially in QtWayland it is up to the class implementation to implement the event handler and call
```cpp
wl_resource_destroy(resource->handle)
```
in the relevant method
/*
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "abstract_data_source.h"
using namespace KWaylandServer;
AbstractDataSource::AbstractDataSource(QObject *parent)
: QObject(parent)
{
}
/*
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include "clientconnection.h"
#include "datadevicemanager_interface.h"
#include <KWaylandServer/kwaylandserver_export.h>
struct wl_client;
namespace KWaylandServer
{
/**
* @brief The AbstractDataSource class abstracts the data that
* can be transferred to another client.
*
* It loosely maps to DataDeviceInterface
*/
// Anything related to selections are pure virtual, content relating
// to drag and drop has a default implementation
class KWAYLANDSERVER_EXPORT AbstractDataSource : public QObject
{
Q_OBJECT
public:
virtual bool isAccepted() const
{
return false;
}
virtual void accept(const QString &mimeType)
{
Q_UNUSED(mimeType);
};
virtual void requestData(const QString &mimeType, qint32 fd) = 0;
virtual void cancel() = 0;
virtual QStringList mimeTypes() const = 0;
/**
* @returns The Drag and Drop actions supported by this DataSourceInterface.
*/
virtual DataDeviceManagerInterface::DnDActions supportedDragAndDropActions() const
{
return {};
};
/**
* The user performed the drop action during a drag and drop operation.
*/
virtual void dropPerformed(){};
/**
* The drop destination finished interoperating with this data source.
*/
virtual void dndFinished(){};
/**
* This event indicates the @p action selected by the compositor after matching the
* source/destination side actions. Only one action (or none) will be offered here.
*/
virtual void dndAction(DataDeviceManagerInterface::DnDAction action)
{
Q_UNUSED(action);
};
/**
* Called when a user stops clicking but it is not accepted by a client.
*/
virtual void dndCancelled()
{
}
virtual wl_client *client() const
{
return nullptr;
};
Q_SIGNALS:
void aboutToBeDestroyed();
void mimeTypeOffered(const QString &);
void supportedDragAndDropActionsChanged();
protected:
explicit AbstractDataSource(QObject *parent = nullptr);
};
}
/*
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "abstract_drop_handler.h"
namespace KWaylandServer
{
AbstractDropHandler::AbstractDropHandler(QObject *parent)
: QObject(parent)
{
}
}
/*
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include <KWaylandServer/kwaylandserver_export.h>
#include <QObject>