6 #include "plasmawindowmanagement_interface.h"
9 #include "plasmavirtualdesktop_interface.h"
10 #include "resource_p.h"
11 #include "surface_interface.h"
19 #include <QtConcurrentRun>
21 #include <wayland-plasma-window-management-server-protocol.h>
22 #include <wayland-server.h>
28 class PlasmaWindowManagementInterface::Private :
public Global::Private
31 Private(PlasmaWindowManagementInterface *q, Display *d);
32 void sendShowingDesktopState();
33 void sendStackingOrderChanged();
35 ShowingDesktopState state = ShowingDesktopState::Disabled;
39 quint32 windowIdCounter = 0;
43 static void unbind(wl_resource *resource);
44 static void showDesktopCallback(wl_client *client, wl_resource *resource, uint32_t state);
45 static void getWindowCallback(wl_client *client, wl_resource *resource, uint32_t
id, uint32_t internalWindowId);
46 static void getWindowByUuidCallback(wl_client *client, wl_resource *resource, uint32_t
id,
const char *uuid);
48 void bind(wl_client *client, uint32_t version, uint32_t
id)
override;
49 void sendShowingDesktopState(wl_resource *r);
50 void sendStackingOrderChanged(wl_resource *r);
52 PlasmaWindowManagementInterface *q;
53 static const struct org_kde_plasma_window_management_interface s_interface;
54 static const quint32 s_version;
57 class PlasmaWindowInterface::Private
60 Private(PlasmaWindowManagementInterface *wm, PlasmaWindowInterface *q);
63 void createResource(wl_resource *
parent, uint32_t
id);
64 void setTitle(
const QString &title);
65 void setAppId(
const QString &appId);
66 void setPid(quint32 pid);
71 void setState(org_kde_plasma_window_management_state flag,
bool set);
75 wl_resource *resourceForParent(PlasmaWindowInterface *
parent, wl_resource *child)
const;
80 PlasmaWindowManagementInterface *wm;
82 bool unmapped =
false;
83 PlasmaWindowInterface *parentWindow =
nullptr;
89 static void unbind(wl_resource *resource);
90 static void setStateCallback(wl_client *client, wl_resource *resource, uint32_t flags, uint32_t state);
91 static void setVirtualDesktopCallback(wl_client *client, wl_resource *resource, uint32_t number);
92 static void closeCallback(wl_client *client, wl_resource *resource);
93 static void requestMoveCallback(wl_client *client, wl_resource *resource);
94 static void requestResizeCallback(wl_client *client, wl_resource *resource);
96 setMinimizedGeometryCallback(wl_client *client, wl_resource *resource, wl_resource *panel, uint32_t x, uint32_t y, uint32_t width, uint32_t height);
97 static void unsetMinimizedGeometryCallback(wl_client *client, wl_resource *resource, wl_resource *panel);
98 static void destroyCallback(wl_client *client, wl_resource *resource);
99 static void getIconCallback(wl_client *client, wl_resource *resource, int32_t fd);
100 static void requestEnterVirtualDesktopCallback(wl_client *client, wl_resource *resource,
const char *
id);
101 static void requestEnterNewVirtualDesktopCallback(wl_client *client, wl_resource *resource);
102 static void requestLeaveVirtualDesktopCallback(wl_client *client, wl_resource *resource,
const char *
id);
103 static Private *cast(wl_resource *resource)
105 return reinterpret_cast<Private *
>(wl_resource_get_user_data(resource));
108 PlasmaWindowInterface *q;
116 quint32 m_virtualDesktop = 0;
118 static const struct org_kde_plasma_window_interface s_interface;
121 const quint32 PlasmaWindowManagementInterface::Private::s_version = 11;
123 PlasmaWindowManagementInterface::Private::Private(PlasmaWindowManagementInterface *q, Display *d)
124 : Global::Private(d, &org_kde_plasma_window_management_interface, s_version)
130 const struct org_kde_plasma_window_management_interface PlasmaWindowManagementInterface::Private::s_interface = {showDesktopCallback,
132 getWindowByUuidCallback};
135 void PlasmaWindowManagementInterface::Private::sendShowingDesktopState()
137 for (wl_resource *r : resources) {
138 sendShowingDesktopState(r);
142 void PlasmaWindowManagementInterface::Private::sendShowingDesktopState(wl_resource *r)
146 case ShowingDesktopState::Enabled:
147 s = ORG_KDE_PLASMA_WINDOW_MANAGEMENT_SHOW_DESKTOP_ENABLED;
149 case ShowingDesktopState::Disabled:
150 s = ORG_KDE_PLASMA_WINDOW_MANAGEMENT_SHOW_DESKTOP_DISABLED;
156 org_kde_plasma_window_management_send_show_desktop_changed(r, s);
159 void PlasmaWindowManagementInterface::Private::sendStackingOrderChanged()
161 for (wl_resource *r : resources) {
162 sendStackingOrderChanged(r);
166 void PlasmaWindowManagementInterface::Private::sendStackingOrderChanged(wl_resource *r)
168 if (wl_resource_get_version(r) < ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STACKING_ORDER_CHANGED_SINCE_VERSION) {
173 wl_array_init(&wlIds);
174 const size_t memLength =
sizeof(uint32_t) * stackingOrder.size();
175 void *s = wl_array_add(&wlIds, memLength);
176 memcpy(s, stackingOrder.data(), memLength);
178 org_kde_plasma_window_management_send_stacking_order_changed(r, &wlIds);
180 wl_array_release(&wlIds);
183 void PlasmaWindowManagementInterface::Private::showDesktopCallback(wl_client *client, wl_resource *resource, uint32_t state)
186 ShowingDesktopState s = ShowingDesktopState::Disabled;
188 case ORG_KDE_PLASMA_WINDOW_MANAGEMENT_SHOW_DESKTOP_ENABLED:
189 s = ShowingDesktopState::Enabled;
191 case ORG_KDE_PLASMA_WINDOW_MANAGEMENT_SHOW_DESKTOP_DISABLED:
193 s = ShowingDesktopState::Disabled;
196 Q_EMIT
reinterpret_cast<Private *
>(wl_resource_get_user_data(resource))->q->requestChangeShowingDesktop(s);
199 void PlasmaWindowManagementInterface::Private::getWindowByUuidCallback(wl_client *client, wl_resource *resource, uint32_t
id,
const char *uuid)
203 qCritical() <<
"window_by_uuid is unsupported, port to KWaylandServer::PlasmaWindowManagementInterface";
205 auto p =
reinterpret_cast<Private *
>(wl_resource_get_user_data(resource));
206 PlasmaWindowInterface *
window =
new PlasmaWindowInterface(p->q, p->q);
207 window->d->unmapped =
true;
208 window->d->createResource(resource,
id);
212 void PlasmaWindowManagementInterface::Private::getWindowCallback(wl_client *client, wl_resource *resource, uint32_t
id, uint32_t internalWindowId)
215 auto p =
reinterpret_cast<Private *
>(wl_resource_get_user_data(resource));
216 auto it = std::find_if(p->windows.constBegin(), p->windows.constEnd(), [internalWindowId](PlasmaWindowInterface *window) {
217 return window->d->windowId == internalWindowId;
219 if (it == p->windows.constEnd()) {
221 PlasmaWindowInterface *
window =
new PlasmaWindowInterface(p->q, p->q);
222 window->d->unmapped =
true;
223 window->d->createResource(resource,
id);
226 (*it)->d->createResource(resource,
id);
229 PlasmaWindowManagementInterface::PlasmaWindowManagementInterface(Display *display,
QObject *parent)
230 : Global(new Private(this, display), parent)
234 PlasmaWindowManagementInterface::~PlasmaWindowManagementInterface() =
default;
236 void PlasmaWindowManagementInterface::Private::bind(wl_client *client, uint32_t version, uint32_t
id)
238 auto c = display->getConnection(client);
239 wl_resource *shell = c->createResource(&org_kde_plasma_window_management_interface, qMin(version, s_version),
id);
241 wl_client_post_no_memory(client);
244 wl_resource_set_implementation(shell, &s_interface,
this, unbind);
246 for (
auto it = windows.constBegin(); it != windows.constEnd(); ++it) {
247 org_kde_plasma_window_management_send_window(shell, (*it)->d->windowId);
249 sendStackingOrderChanged();
252 void PlasmaWindowManagementInterface::Private::unbind(wl_resource *resource)
254 auto wm =
reinterpret_cast<Private *
>(wl_resource_get_user_data(resource));
255 wm->resources.removeAll(resource);
258 void PlasmaWindowManagementInterface::setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState state)
261 if (d->state == state) {
265 d->sendShowingDesktopState();
268 PlasmaWindowManagementInterface::Private *PlasmaWindowManagementInterface::d_func()
const
270 return reinterpret_cast<Private *
>(d.data());
273 PlasmaWindowInterface *PlasmaWindowManagementInterface::createWindow(
QObject *parent)
276 PlasmaWindowInterface *
window =
new PlasmaWindowInterface(
this, parent);
278 window->d->windowId = ++d->windowIdCounter;
279 for (
auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
280 org_kde_plasma_window_management_send_window(*it,
window->d->windowId);
285 d->windows.removeAll(window);
302 d->windows.removeOne(window);
303 Q_ASSERT(!d->windows.contains(window));
307 void PlasmaWindowManagementInterface::setStackingOrder(
const QVector<quint32> &stackingOrder)
310 if (d->stackingOrder == stackingOrder) {
313 d->stackingOrder = stackingOrder;
314 d->sendStackingOrderChanged();
320 if (d->plasmaVirtualDesktopManagementInterface == manager) {
323 d->plasmaVirtualDesktopManagementInterface = manager;
329 return d->plasmaVirtualDesktopManagementInterface;
333 const struct org_kde_plasma_window_interface
PlasmaWindowInterface::Private::s_interface = {setStateCallback,
334 setVirtualDesktopCallback,
335 setMinimizedGeometryCallback,
336 unsetMinimizedGeometryCallback,
339 requestResizeCallback,
342 requestEnterVirtualDesktopCallback,
343 requestEnterNewVirtualDesktopCallback,
344 requestLeaveVirtualDesktopCallback};
347 PlasmaWindowInterface::Private::Private(PlasmaWindowManagementInterface *wm, PlasmaWindowInterface *q)
353 PlasmaWindowInterface::Private::~Private()
356 const auto c = resources;
357 for (
const auto &r : c) {
358 auto client = wl_resource_get_client(r);
359 org_kde_plasma_window_send_unmapped(r);
360 wl_resource_destroy(r);
361 wl_client_flush(client);
365 void PlasmaWindowInterface::Private::destroyCallback(wl_client *, wl_resource *r)
367 Private *p = cast(r);
368 p->resources.removeAll(r);
369 wl_resource_destroy(r);
370 if (p->unmapped && p->resources.isEmpty()) {
375 void PlasmaWindowInterface::Private::unbind(wl_resource *resource)
377 Private *p =
reinterpret_cast<Private *
>(wl_resource_get_user_data(resource));
378 p->resources.removeAll(resource);
379 if (p->unmapped && p->resources.isEmpty()) {
384 void PlasmaWindowInterface::Private::createResource(wl_resource *parent, uint32_t
id)
386 ClientConnection *c = wm->display()->getConnection(wl_resource_get_client(parent));
387 wl_resource *resource = c->createResource(&org_kde_plasma_window_interface, wl_resource_get_version(parent),
id);
391 wl_resource_set_implementation(resource, &s_interface,
this, unbind);
392 resources << resource;
394 org_kde_plasma_window_send_virtual_desktop_changed(resource, m_virtualDesktop);
395 for (
const auto &desk : plasmaVirtualDesktops) {
396 org_kde_plasma_window_send_virtual_desktop_entered(resource, desk.toUtf8().constData());
398 if (!m_appId.isEmpty()) {
399 org_kde_plasma_window_send_app_id_changed(resource, m_appId.toUtf8().constData());
402 org_kde_plasma_window_send_pid_changed(resource, m_pid);
404 if (!m_title.isEmpty()) {
405 org_kde_plasma_window_send_title_changed(resource, m_title.toUtf8().constData());
407 if (!m_appObjectPath.isEmpty() || !m_appServiceName.isEmpty()) {
408 org_kde_plasma_window_send_application_menu(resource, m_appServiceName.toUtf8().constData(), m_appObjectPath.toUtf8().constData());
410 org_kde_plasma_window_send_state_changed(resource, m_state);
411 if (!m_themedIconName.isEmpty()) {
412 org_kde_plasma_window_send_themed_icon_name_changed(resource, m_themedIconName.toUtf8().constData());
414 if (wl_resource_get_version(resource) >= ORG_KDE_PLASMA_WINDOW_ICON_CHANGED_SINCE_VERSION) {
415 org_kde_plasma_window_send_icon_changed(resource);
419 org_kde_plasma_window_send_parent_window(resource, resourceForParent(parentWindow, resource));
422 org_kde_plasma_window_send_unmapped(resource);
425 if (geometry.isValid() && wl_resource_get_version(resource) >= ORG_KDE_PLASMA_WINDOW_GEOMETRY_SINCE_VERSION) {
426 org_kde_plasma_window_send_geometry(resource, geometry.x(), geometry.y(), geometry.width(), geometry.height());
429 if (wl_resource_get_version(resource) >= ORG_KDE_PLASMA_WINDOW_INITIAL_STATE_SINCE_VERSION) {
430 org_kde_plasma_window_send_initial_state(resource);
435 void PlasmaWindowInterface::Private::setAppId(
const QString &appId)
437 if (m_appId == appId) {
442 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
443 org_kde_plasma_window_send_app_id_changed(*it, utf8.
constData());
447 void PlasmaWindowInterface::Private::setPid(quint32 pid)
453 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
454 org_kde_plasma_window_send_pid_changed(*it, pid);
458 void PlasmaWindowInterface::Private::setThemedIconName(
const QString &iconName)
460 if (m_themedIconName == iconName) {
463 m_themedIconName = iconName;
464 const QByteArray utf8 = m_themedIconName.toUtf8();
465 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
466 org_kde_plasma_window_send_themed_icon_name_changed(*it, utf8.
constData());
470 void PlasmaWindowInterface::Private::setIcon(
const QIcon &icon)
473 setThemedIconName(m_icon.name());
474 if (m_icon.name().isEmpty()) {
475 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
476 if (wl_resource_get_version(*it) >= ORG_KDE_PLASMA_WINDOW_ICON_CHANGED_SINCE_VERSION) {
477 org_kde_plasma_window_send_icon_changed(*it);
483 void PlasmaWindowInterface::Private::getIconCallback(wl_client *client, wl_resource *resource, int32_t fd)
486 Private *p = cast(resource);
488 [fd](
const QIcon &icon) {
498 void PlasmaWindowInterface::Private::requestEnterVirtualDesktopCallback(wl_client *client, wl_resource *resource,
const char *
id)
501 Private *p = cast(resource);
505 void PlasmaWindowInterface::Private::requestEnterNewVirtualDesktopCallback(wl_client *client, wl_resource *resource)
508 Private *p = cast(resource);
509 Q_EMIT p->q->enterNewPlasmaVirtualDesktopRequested();
512 void PlasmaWindowInterface::Private::requestLeaveVirtualDesktopCallback(wl_client *client, wl_resource *resource,
const char *
id)
515 Private *p = cast(resource);
519 void PlasmaWindowInterface::Private::setTitle(
const QString &title)
521 if (m_title == title) {
526 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
527 org_kde_plasma_window_send_title_changed(*it, utf8.
constData());
531 void PlasmaWindowInterface::Private::setVirtualDesktop(quint32 desktop)
533 if (m_virtualDesktop == desktop) {
536 m_virtualDesktop = desktop;
537 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
538 org_kde_plasma_window_send_virtual_desktop_changed(*it, m_virtualDesktop);
542 void PlasmaWindowInterface::Private::unmap()
545 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
546 org_kde_plasma_window_send_unmapped(*it);
548 if (resources.isEmpty()) {
553 void PlasmaWindowInterface::Private::setState(org_kde_plasma_window_management_state flag,
bool set)
555 quint32 newState = m_state;
561 if (newState == m_state) {
565 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
566 org_kde_plasma_window_send_state_changed(*it, m_state);
570 wl_resource *PlasmaWindowInterface::Private::resourceForParent(PlasmaWindowInterface *parent, wl_resource *child)
const
575 auto it = std::find_if(parent->d->resources.begin(), parent->d->resources.end(), [child](wl_resource *parentResource) {
576 return wl_resource_get_client(child) == wl_resource_get_client(parentResource);
578 if (it != parent->d->resources.end()) {
584 void PlasmaWindowInterface::Private::setParentWindow(PlasmaWindowInterface *window)
586 if (parentWindow == window) {
594 parentWindow =
nullptr;
596 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
597 org_kde_plasma_window_send_parent_window(*it,
nullptr);
601 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
602 org_kde_plasma_window_send_parent_window(*it, resourceForParent(window, *it));
606 void PlasmaWindowInterface::Private::setGeometry(
const QRect &geo)
608 if (geometry == geo) {
612 if (!geometry.isValid()) {
615 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
617 if (wl_resource_get_version(resource) < ORG_KDE_PLASMA_WINDOW_GEOMETRY_SINCE_VERSION) {
620 org_kde_plasma_window_send_geometry(resource, geometry.x(), geometry.y(), geometry.width(), geometry.height());
624 void PlasmaWindowInterface::Private::setApplicationMenuPaths(
const QString &service,
const QString &
object)
626 if (m_appServiceName == service && m_appObjectPath ==
object) {
629 m_appServiceName = service;
630 m_appObjectPath = object;
631 for (
auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
633 if (wl_resource_get_version(resource) < ORG_KDE_PLASMA_WINDOW_APPLICATION_MENU_SINCE_VERSION) {
636 org_kde_plasma_window_send_application_menu(resource, qUtf8Printable(service), qUtf8Printable(
object));
640 void PlasmaWindowInterface::Private::closeCallback(wl_client *client, wl_resource *resource)
643 Private *p = cast(resource);
644 Q_EMIT p->q->closeRequested();
647 void PlasmaWindowInterface::Private::requestMoveCallback(wl_client *client, wl_resource *resource)
650 Private *p = cast(resource);
651 Q_EMIT p->q->moveRequested();
654 void PlasmaWindowInterface::Private::requestResizeCallback(wl_client *client, wl_resource *resource)
657 Private *p = cast(resource);
658 Q_EMIT p->q->resizeRequested();
661 void PlasmaWindowInterface::Private::setVirtualDesktopCallback(wl_client *client, wl_resource *resource, uint32_t number)
664 Private *p = cast(resource);
665 Q_EMIT p->q->virtualDesktopRequested(number);
668 void PlasmaWindowInterface::Private::setStateCallback(wl_client *client, wl_resource *resource, uint32_t flags, uint32_t state)
671 Private *p = cast(resource);
672 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_ACTIVE) {
673 Q_EMIT p->q->activeRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_ACTIVE);
675 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZED) {
676 Q_EMIT p->q->minimizedRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZED);
678 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZED) {
679 Q_EMIT p->q->maximizedRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZED);
681 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREEN) {
682 Q_EMIT p->q->fullscreenRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREEN);
684 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_ABOVE) {
685 Q_EMIT p->q->keepAboveRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_ABOVE);
687 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_BELOW) {
688 Q_EMIT p->q->keepBelowRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_BELOW);
690 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_DEMANDS_ATTENTION) {
691 Q_EMIT p->q->demandsAttentionRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_DEMANDS_ATTENTION);
693 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_CLOSEABLE) {
694 Q_EMIT p->q->closeableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_CLOSEABLE);
696 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZABLE) {
697 Q_EMIT p->q->minimizeableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZABLE);
699 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZABLE) {
700 Q_EMIT p->q->maximizeableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZABLE);
702 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREENABLE) {
703 Q_EMIT p->q->fullscreenableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREENABLE);
705 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR) {
706 Q_EMIT p->q->skipTaskbarRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR);
708 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER) {
709 Q_EMIT p->q->skipSwitcherRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER);
711 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADEABLE) {
712 Q_EMIT p->q->shadeableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADEABLE);
714 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED) {
715 Q_EMIT p->q->shadedRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED);
717 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE) {
718 Q_EMIT p->q->movableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE);
720 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_RESIZABLE) {
721 Q_EMIT p->q->resizableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_RESIZABLE);
723 if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_VIRTUAL_DESKTOP_CHANGEABLE) {
724 Q_EMIT p->q->virtualDesktopChangeableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_VIRTUAL_DESKTOP_CHANGEABLE);
728 void PlasmaWindowInterface::Private::setMinimizedGeometryCallback(wl_client *client,
729 wl_resource *resource,
737 Private *p = cast(resource);
744 if (p->minimizedGeometries.value(panelSurface) ==
QRect(x, y, width, height)) {
748 p->minimizedGeometries[panelSurface] =
QRect(x, y, width, height);
749 Q_EMIT p->q->minimizedGeometriesChanged();
751 if (p->minimizedGeometries.remove(panelSurface)) {
752 Q_EMIT p->q->minimizedGeometriesChanged();
757 void PlasmaWindowInterface::Private::unsetMinimizedGeometryCallback(wl_client *client, wl_resource *resource, wl_resource *panel)
760 Private *p = cast(resource);
766 if (!p->minimizedGeometries.contains(panelSurface)) {
769 p->minimizedGeometries.remove(panelSurface);
770 Q_EMIT p->q->minimizedGeometriesChanged();
773 PlasmaWindowInterface::PlasmaWindowInterface(PlasmaWindowManagementInterface *wm,
QObject *parent)
775 , d(new Private(wm, this))
779 PlasmaWindowInterface::~PlasmaWindowInterface() =
default;
781 void PlasmaWindowInterface::setAppId(
const QString &appId)
786 void PlasmaWindowInterface::setPid(quint32 pid)
791 void PlasmaWindowInterface::setTitle(
const QString &title)
798 d->setVirtualDesktop(desktop);
803 d->wm->unmapWindow(
this);
808 return d->minimizedGeometries;
811 void PlasmaWindowInterface::setActive(
bool set)
813 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_ACTIVE, set);
816 void PlasmaWindowInterface::setFullscreen(
bool set)
818 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREEN, set);
821 void PlasmaWindowInterface::setKeepAbove(
bool set)
823 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_ABOVE, set);
826 void PlasmaWindowInterface::setKeepBelow(
bool set)
828 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_KEEP_BELOW, set);
831 void PlasmaWindowInterface::setMaximized(
bool set)
833 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZED, set);
836 void PlasmaWindowInterface::setMinimized(
bool set)
838 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZED, set);
841 void PlasmaWindowInterface::setOnAllDesktops(
bool set)
844 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_ON_ALL_DESKTOPS, set);
846 if (!d->wm->plasmaVirtualDesktopManagementInterface()) {
852 if (d->plasmaVirtualDesktops.isEmpty()) {
857 for (
auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
858 org_kde_plasma_window_send_virtual_desktop_left(*it, desk.toUtf8().constData());
861 d->plasmaVirtualDesktops.clear();
863 if (!d->plasmaVirtualDesktops.isEmpty()) {
867 for (
auto desk : d->wm->plasmaVirtualDesktopManagementInterface()->desktops()) {
868 if (desk->isActive() && !d->plasmaVirtualDesktops.contains(desk->id())) {
869 d->plasmaVirtualDesktops << desk->id();
870 for (
auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
871 org_kde_plasma_window_send_virtual_desktop_entered(*it, desk->id().toUtf8().constData());
878 void PlasmaWindowInterface::setDemandsAttention(
bool set)
880 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_DEMANDS_ATTENTION, set);
883 void PlasmaWindowInterface::setCloseable(
bool set)
885 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_CLOSEABLE, set);
888 void PlasmaWindowInterface::setFullscreenable(
bool set)
890 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREENABLE, set);
893 void PlasmaWindowInterface::setMaximizeable(
bool set)
895 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZABLE, set);
898 void PlasmaWindowInterface::setMinimizeable(
bool set)
900 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZABLE, set);
903 void PlasmaWindowInterface::setSkipTaskbar(
bool set)
905 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR, set);
908 void PlasmaWindowInterface::setSkipSwitcher(
bool skip)
910 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER, skip);
915 d->setThemedIconName(iconName);
926 if (!d->wm->plasmaVirtualDesktopManagementInterface() || d->plasmaVirtualDesktops.contains(
id)) {
930 PlasmaVirtualDesktopInterface *desktop = d->wm->plasmaVirtualDesktopManagementInterface()->desktop(
id);
936 d->plasmaVirtualDesktops << id;
943 for (
auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
944 org_kde_plasma_window_send_virtual_desktop_entered(*it,
id.toUtf8().constData());
950 if (!d->plasmaVirtualDesktops.contains(
id)) {
954 d->plasmaVirtualDesktops.removeAll(
id);
955 for (
auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
956 org_kde_plasma_window_send_virtual_desktop_left(*it,
id.toUtf8().constData());
960 if (d->plasmaVirtualDesktops.isEmpty()) {
961 setOnAllDesktops(
true);
967 return d->plasmaVirtualDesktops;
972 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADEABLE, set);
977 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED, set);
982 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE, set);
987 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_RESIZABLE, set);
992 d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_VIRTUAL_DESKTOP_CHANGEABLE, set);
997 d->setParentWindow(parentWindow);
1002 d->setGeometry(geometry);
1007 d->setApplicationMenuPaths(serviceName, objectPath);