23#include <qwayland-server-plasma-window-management.h>
27static const quint32 s_version = 16;
28static const quint32 s_activationVersion = 1;
65 QtWaylandServer::org_kde_plasma_window_management::Resource *
wmResource =
nullptr;
72 void setIcon(
const QIcon &icon);
74 void setState(org_kde_plasma_window_management_state flag,
bool set);
124 : QtWaylandServer::org_kde_plasma_window_management(*display, s_version)
131 const auto clientResources = resourceMap();
132 for (
auto resource : clientResources) {
142 s = QtWaylandServer::org_kde_plasma_window_management::show_desktop_enabled;
145 s = QtWaylandServer::org_kde_plasma_window_management::show_desktop_disabled;
151 send_show_desktop_changed(r, s);
156 const auto clientResources = resourceMap();
157 for (
auto resource : clientResources) {
164 if (wl_resource_get_version(r) < ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STACKING_ORDER_CHANGED_SINCE_VERSION) {
168 send_stacking_order_changed(r, QByteArray::fromRawData(
reinterpret_cast<const char *
>(
stackingOrder.constData()),
sizeof(uint32_t) *
stackingOrder.size()));
173 const auto clientResources = resourceMap();
174 for (
auto resource : clientResources) {
181 if (wl_resource_get_version(r) < ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STACKING_ORDER_UUID_CHANGED_SINCE_VERSION) {
188 uuids += QLatin1Char(
';');
192 uuids.remove(uuids.length() - 1, 1);
194 send_stacking_order_uuid_changed(r, uuids);
199 for (
const auto window : std::as_const(
windows)) {
200 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_MANAGEMENT_WINDOW_WITH_UUID_SINCE_VERSION) {
201 send_window_with_uuid(resource->handle, window->d->windowId, window->d->uuid);
203 send_window(resource->handle, window->d->windowId);
214 case ORG_KDE_PLASMA_WINDOW_MANAGEMENT_SHOW_DESKTOP_ENABLED:
217 case ORG_KDE_PLASMA_WINDOW_MANAGEMENT_SHOW_DESKTOP_DISABLED:
227 for (
const auto window : std::as_const(
windows)) {
228 if (window->d->windowId == internal_window_id) {
229 auto windowResource = window->d->add(resource->client(), id, resource->version());
231 window->d->sendInitialState(windowResource);
236 auto windowResource = window.d->add(resource->client(),
id, resource->version());
237 window.d->sendInitialState(windowResource);
242 const QString &internal_window_uuid)
245 return window->d->uuid == internal_window_uuid;
247 if (it ==
windows.constEnd()) {
248 qCWarning(KWIN_CORE) <<
"Could not find window with uuid" << internal_window_uuid;
251 auto windowResource = window.d->add(resource->client(),
id, resource->version());
252 window.d->sendInitialState(windowResource);
255 auto windowResource = (*it)->d->add(resource->client(),
id, resource->version());
257 (*it)->d->sendInitialState(windowResource);
270 if (d->state == state) {
274 d->sendShowingDesktopState();
281 window->d->uuid = uuid.toString();
282 window->d->windowId = ++d->windowIdCounter;
284 const auto clientResources = d->resourceMap();
285 for (
auto resource : clientResources) {
286 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_MANAGEMENT_WINDOW_WITH_UUID_SINCE_VERSION) {
287 d->send_window_with_uuid(resource->handle, window->d->windowId, window->d->uuid);
289 d->send_window(resource->handle, window->d->windowId);
292 d->windows << window;
293 connect(window, &QObject::destroyed,
this, [
this, window] {
294 d->windows.removeAll(window);
306 if (d->stackingOrder == stackingOrder) {
309 d->stackingOrder = stackingOrder;
310 d->sendStackingOrderChanged();
315 if (d->stackingOrderUuids == stackingOrderUuids) {
318 d->stackingOrderUuids = stackingOrderUuids;
319 d->sendStackingOrderUuidsChanged();
324 if (d->plasmaVirtualDesktopManagementInterface == manager) {
327 d->plasmaVirtualDesktopManagementInterface = manager;
332 return d->plasmaVirtualDesktopManagementInterface;
337 : QtWaylandServer::org_kde_plasma_window()
355 wl_resource_destroy(resource->handle);
361 send_virtual_desktop_entered(resource->handle, desk);
364 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_ACTIVITY_ENTERED_SINCE_VERSION) {
365 send_activity_entered(resource->handle, activity);
369 send_app_id_changed(resource->handle, truncate(
m_appId));
372 send_pid_changed(resource->handle,
m_pid);
375 send_title_changed(resource->handle, truncate(
m_title));
380 send_state_changed(resource->handle,
m_state);
383 }
else if (!
m_icon.isNull()) {
384 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_ICON_CHANGED_SINCE_VERSION) {
385 send_icon_changed(resource->handle);
391 if (
geometry.isValid() && resource->version() >= ORG_KDE_PLASMA_WINDOW_GEOMETRY_SINCE_VERSION) {
395 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_INITIAL_STATE_SINCE_VERSION) {
396 send_initial_state(resource->handle);
399 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_RESOURCE_NAME_CHANGED_SINCE_VERSION) {
412 const auto clientResources = resourceMap();
414 for (
auto resource : clientResources) {
415 send_app_id_changed(resource->handle, truncate(
m_appId));
425 const auto clientResources = resourceMap();
427 for (
auto resource : clientResources) {
428 send_pid_changed(resource->handle, pid);
438 const auto clientResources = resourceMap();
440 for (
auto resource : clientResources) {
450 const auto clientResources = resourceMap();
451 for (
auto resource : clientResources) {
452 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_ICON_CHANGED_SINCE_VERSION) {
453 send_icon_changed(resource->handle);
465 const auto clientResources = resourceMap();
466 for (
auto resource : clientResources) {
467 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_RESOURCE_NAME_CHANGED_SINCE_VERSION) {
468 send_resource_name_changed(resource->handle, resourceName);
475 QThreadPool::globalInstance()->start([fd, icon =
m_icon]() {
477 file.open(fd, QIODevice::WriteOnly, QFileDevice::AutoCloseHandle);
478 QDataStream ds(&file);
520 const auto clientResources = resourceMap();
522 for (
auto resource : clientResources) {
523 send_title_changed(resource->handle, truncate(
m_title));
533 const auto clientResources = resourceMap();
535 for (
auto resource : clientResources) {
536 send_unmapped(resource->handle);
552 const auto clientResources = resourceMap();
554 for (
auto resource : clientResources) {
555 send_state_changed(resource->handle,
m_state);
565 const auto parentResource = parent->d->resourceMap();
567 for (
auto resource : parentResource) {
569 return resource->handle;
587 const auto clientResources = resourceMap();
588 for (
auto resource : clientResources) {
589 send_parent_window(resource->handle,
nullptr);
593 const auto clientResources = resourceMap();
594 for (
auto resource : clientResources) {
609 const auto clientResources = resourceMap();
610 for (
auto resource : clientResources) {
611 if (resource->version() < ORG_KDE_PLASMA_WINDOW_GEOMETRY_SINCE_VERSION) {
625 const auto clientResources = resourceMap();
626 for (
auto resource : clientResources) {
627 if (resource->version() < ORG_KDE_PLASMA_WINDOW_APPLICATION_MENU_SINCE_VERSION) {
630 send_application_menu(resource->handle, service,
object);
656 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_ACTIVE) {
657 Q_EMIT
q->
activeRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_ACTIVE);
659 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZED) {
662 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZED) {
665 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREEN) {
668 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_ABOVE) {
671 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_BELOW) {
674 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_DEMANDS_ATTENTION) {
677 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_CLOSEABLE) {
680 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZABLE) {
683 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZABLE) {
686 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREENABLE) {
689 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR) {
692 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER) {
695 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADEABLE) {
698 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED) {
699 Q_EMIT
q->
shadedRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED);
701 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE) {
702 Q_EMIT
q->
movableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE);
704 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_RESIZABLE) {
707 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_VIRTUAL_DESKTOP_CHANGEABLE) {
731 QObject::connect(panelSurface, &QObject::destroyed,
q, [
this, panelSurface]() {
733 Q_EMIT q->minimizedGeometriesChanged();
782 return d->minimizedGeometries;
787 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_ACTIVE, set);
792 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREEN, set);
797 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_ABOVE, set);
802 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_BELOW, set);
807 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZED, set);
812 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZED, set);
818 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_ON_ALL_DESKTOPS, set);
820 if (!d->wm->plasmaVirtualDesktopManagementInterface()) {
823 const auto clientResources = d->resourceMap();
826 if (d->plasmaVirtualDesktops.isEmpty()) {
831 for (
auto resource : clientResources) {
832 d->send_virtual_desktop_left(resource->handle, desk);
835 d->plasmaVirtualDesktops.clear();
837 if (!d->plasmaVirtualDesktops.isEmpty()) {
841 const auto desktops = d->wm->plasmaVirtualDesktopManagementInterface()->desktops();
842 for (
const auto desktop : desktops) {
843 if (desktop->isActive() && !d->plasmaVirtualDesktops.contains(desktop->id())) {
844 d->plasmaVirtualDesktops << desktop->id();
845 for (
auto resource : clientResources) {
846 d->send_virtual_desktop_entered(resource->handle, desktop->id());
855 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_DEMANDS_ATTENTION, set);
860 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_CLOSEABLE, set);
865 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREENABLE, set);
870 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZABLE, set);
875 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZABLE, set);
880 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR, set);
885 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER, skip);
895 d->setResourceName(resourceName);
901 if (!d->wm->plasmaVirtualDesktopManagementInterface() || d->plasmaVirtualDesktops.contains(
id)) {
911 d->plasmaVirtualDesktops << id;
914 connect(desktop, &QObject::destroyed,
this, [
this,
id]() {
918 const auto clientResources = d->resourceMap();
919 for (
auto resource : clientResources) {
920 d->send_virtual_desktop_entered(resource->handle,
id);
926 if (!d->plasmaVirtualDesktops.contains(
id)) {
930 d->plasmaVirtualDesktops.removeAll(
id);
931 const auto clientResources = d->resourceMap();
932 for (
auto resource : clientResources) {
933 d->send_virtual_desktop_left(resource->handle,
id);
937 if (d->plasmaVirtualDesktops.isEmpty()) {
944 return d->plasmaVirtualDesktops;
949 if (d->plasmaActivities.contains(
id)) {
953 d->plasmaActivities << id;
955 const auto clientResources = d->resourceMap();
956 for (
auto resource : clientResources) {
957 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_ACTIVITY_ENTERED_SINCE_VERSION) {
958 d->send_activity_entered(resource->handle,
id);
965 if (!d->plasmaActivities.removeOne(
id)) {
969 const auto clientResources = d->resourceMap();
970 for (
auto resource : clientResources) {
971 if (resource->version() >= ORG_KDE_PLASMA_WINDOW_ACTIVITY_LEFT_SINCE_VERSION) {
972 d->send_activity_left(resource->handle,
id);
979 return d->plasmaActivities;
984 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADEABLE, set);
989 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED, set);
994 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE, set);
999 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_RESIZABLE, set);
1004 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_VIRTUAL_DESKTOP_CHANGEABLE, set);
1009 d->setParentWindow(parentWindow);
1014 d->setGeometry(geometry);
1019 d->setApplicationMenuPaths(serviceName, objectPath);
1045 : QtWaylandServer::org_kde_plasma_activation()
1054 : QtWaylandServer::org_kde_plasma_activation_feedback(*display, s_activationVersion)
1060 wl_resource_destroy(resource->handle);
1076 const auto resources = d->resourceMap();
1077 for (
auto resource : resources) {
1078 auto activationResource = activation->d->add(resource->client(), resource->version());
1079 d->send_activation(resource->handle, activationResource->handle);
1081 activation->sendAppId(appid);
1085PlasmaWindowActivationInterface::PlasmaWindowActivationInterface()
1092 const auto clientResources = d->resourceMap();
1093 for (
auto resource : clientResources) {
1094 d->send_finished(resource->handle);
1100 const auto clientResources = d->resourceMap();
1101 for (
auto resource : clientResources) {
1102 d->send_app_id(resource->handle, appid);
1108#include "moc_plasmawindowmanagement.cpp"
Class holding the Wayland server display loop.
static OutputInterface * get(wl_resource *native)
Wrapper for the org_kde_plasma_virtual_desktop_management interface.
~PlasmaWindowActivationFeedbackInterface() override
std::unique_ptr< PlasmaWindowActivationInterface > createActivation(const QString &app_id)
PlasmaWindowActivationFeedbackInterface(Display *display, QObject *parent=nullptr)
PlasmaWindowActivationFeedbackInterfacePrivate(Display *display)
void org_kde_plasma_activation_feedback_destroy(Resource *resource) override
~PlasmaWindowActivationInterface()
void sendAppId(const QString &id)
PlasmaWindowActivationInterface *const q
PlasmaWindowActivationInterfacePrivate(PlasmaWindowActivationInterface *q)
void shadeableRequested(bool set)
void shadedRequested(bool set)
void sendToOutput(KWin::OutputInterface *output)
void leavePlasmaActivityRequested(const QString &activity)
void keepAboveRequested(bool set)
void keepBelowRequested(bool set)
void setApplicationMenuPaths(const QString &serviceName, const QString &objectPath)
QStringList plasmaActivities() const
void maximizedRequested(bool set)
quint32 internalId() const
void setGeometry(const QRect &geometry)
void movableRequested(bool set)
QRect minimizedGeometriesChanged()
void resizableRequested(bool set)
void setResizable(bool set)
void minimizedRequested(bool set)
void setKeepBelow(bool set)
void activeRequested(bool set)
void enterNewPlasmaVirtualDesktopRequested()
void virtualDesktopChangeableRequested(bool set)
void fullscreenRequested(bool set)
void leavePlasmaVirtualDesktopRequested(const QString &desktop)
void setKeepAbove(bool set)
void skipSwitcherRequested(bool set)
void setSkipSwitcher(bool skip)
void removePlasmaVirtualDesktop(const QString &id)
void setMovable(bool set)
void setMinimized(bool set)
void setCloseable(bool set)
void setTitle(const QString &title)
QStringList plasmaVirtualDesktops() const
void fullscreenableRequested(bool set)
void setIcon(const QIcon &icon)
void addPlasmaVirtualDesktop(const QString &id)
void setFullscreenable(bool set)
~PlasmaWindowInterface() override
void setMaximized(bool set)
void setResourceName(const QString &resourceName)
void enterPlasmaActivityRequested(const QString &activity)
void skipTaskbarRequested(bool set)
QHash< SurfaceInterface *, QRect > minimizedGeometries() const
void minimizeableRequested(bool set)
void setMinimizeable(bool set)
void setVirtualDesktopChangeable(bool set)
void removePlasmaActivity(const QString &id)
void setDemandsAttention(bool set)
void setSkipTaskbar(bool skip)
void maximizeableRequested(bool set)
void closeableRequested(bool set)
void enterPlasmaVirtualDesktopRequested(const QString &desktop)
void setShadeable(bool set)
void setOnAllDesktops(bool set)
void addPlasmaActivity(const QString &id)
void setMaximizeable(bool set)
void setAppId(const QString &appId)
void demandsAttentionRequested(bool set)
void setFullscreen(bool set)
void setParentWindow(PlasmaWindowInterface *parentWindow)
QtWaylandServer::org_kde_plasma_window_management::Resource * wmResource
void org_kde_plasma_window_request_leave_activity(Resource *resource, const QString &id) override
void org_kde_plasma_window_request_move(Resource *resource) override
QHash< SurfaceInterface *, QRect > minimizedGeometries
void org_kde_plasma_window_get_icon(Resource *resource, int32_t fd) override
PlasmaWindowInterface * q
void org_kde_plasma_window_unset_minimized_geometry(Resource *resource, wl_resource *panel) override
void setParentWindow(PlasmaWindowInterface *parent)
~PlasmaWindowInterfacePrivate()
void setThemedIconName(const QString &iconName)
QMetaObject::Connection parentWindowDestroyConnection
void org_kde_plasma_window_set_virtual_desktop(Resource *resource, uint32_t number) override
PlasmaWindowInterface * parentWindow
QStringList plasmaVirtualDesktops
void setIcon(const QIcon &icon)
void setAppId(const QString &appId)
void org_kde_plasma_window_request_enter_activity(Resource *resource, const QString &id) override
void org_kde_plasma_window_set_minimized_geometry(Resource *resource, wl_resource *panel, uint32_t x, uint32_t y, uint32_t width, uint32_t height) override
void org_kde_plasma_window_set_state(Resource *resource, uint32_t flags, uint32_t state) override
void setTitle(const QString &title)
PlasmaWindowManagementInterface * wm
QStringList plasmaActivities
void org_kde_plasma_window_destroy(Resource *resource) override
void setResourceName(const QString &resourceName)
void setApplicationMenuPaths(const QString &service, const QString &object)
void org_kde_plasma_window_request_resize(Resource *resource) override
void org_kde_plasma_window_request_enter_virtual_desktop(Resource *resource, const QString &id) override
void org_kde_plasma_window_request_leave_virtual_desktop(Resource *resource, const QString &id) override
void org_kde_plasma_window_close(Resource *resource) override
void sendInitialState(Resource *resource)
void setState(org_kde_plasma_window_management_state flag, bool set)
Resource * org_kde_plasma_window_allocate() override
PlasmaWindowInterfacePrivate(PlasmaWindowManagementInterface *wm, PlasmaWindowInterface *q)
wl_resource * resourceForParent(PlasmaWindowInterface *parent, Resource *child) const
void setGeometry(const QRect &geometry)
void org_kde_plasma_window_send_to_output(Resource *resource, struct wl_resource *output) override
void org_kde_plasma_window_request_enter_new_virtual_desktop(Resource *resource) override
void setShowingDesktopState(ShowingDesktopState state)
void setStackingOrder(const QList< quint32 > &stackingOrder)
void setStackingOrderUuids(const QList< QString > &stackingOrderUuids)
~PlasmaWindowManagementInterface() override
PlasmaVirtualDesktopManagementInterface * plasmaVirtualDesktopManagementInterface() const
PlasmaWindowManagementInterface(Display *display, QObject *parent=nullptr)
PlasmaWindowInterface * createWindow(QObject *parent, const QUuid &uuid)
void requestChangeShowingDesktop(ShowingDesktopState requestedState)
void setPlasmaVirtualDesktopManagementInterface(PlasmaVirtualDesktopManagementInterface *manager)
QList< PlasmaWindowInterface * > windows() const
void sendShowingDesktopState()
PlasmaWindowManagementInterface * q
void org_kde_plasma_window_management_show_desktop(Resource *resource, uint32_t state) override
void org_kde_plasma_window_management_get_window_by_uuid(Resource *resource, uint32_t id, const QString &internal_window_uuid) override
PlasmaWindowManagementInterface::ShowingDesktopState state
void org_kde_plasma_window_management_get_window(Resource *resource, uint32_t id, uint32_t internal_window_id) override
QList< PlasmaWindowInterface * > windows
QList< QString > stackingOrderUuids
void sendStackingOrderChanged()
QPointer< PlasmaVirtualDesktopManagementInterface > plasmaVirtualDesktopManagementInterface
void org_kde_plasma_window_management_bind_resource(Resource *resource) override
QList< quint32 > stackingOrder
void sendStackingOrderUuidsChanged()
PlasmaWindowManagementInterfacePrivate(PlasmaWindowManagementInterface *_q, Display *display)
Resource representing a wl_surface.
static SurfaceInterface * get(wl_resource *native)