KWayland

registry.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2018 David Edmundson <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 #include "registry.h"
8 #include "appmenu.h"
9 #include "blur.h"
10 #include "compositor.h"
11 #include "connection_thread.h"
12 #include "contrast.h"
13 #include "datadevicemanager.h"
14 #include "dpms.h"
15 #include "event_queue.h"
16 #include "fakeinput.h"
17 #include "fullscreen_shell.h"
18 #include "idle.h"
19 #include "idleinhibit.h"
20 #include "keystate.h"
21 #include "logging.h"
22 #include "output.h"
23 #include "outputconfiguration.h"
24 #include "outputdevice.h"
25 #include "outputmanagement.h"
26 #include "plasmashell.h"
27 #include "plasmavirtualdesktop.h"
28 #include "plasmawindowmanagement.h"
29 #include "pointerconstraints.h"
30 #include "pointergestures.h"
31 #include "relativepointer.h"
32 #include "remote_access.h"
33 #include "seat.h"
34 #include "server_decoration.h"
35 #include "server_decoration_palette.h"
36 #include "shadow.h"
37 #include "shell.h"
38 #include "shm_pool.h"
39 #include "slide.h"
40 #include "subcompositor.h"
41 #include "textinput_p.h"
42 #include "wayland_pointer_p.h"
43 #include "xdgdecoration.h"
44 #include "xdgforeign_v2.h"
45 #include "xdgoutput.h"
46 #include "xdgshell.h"
47 #include "xdgshell_p.h"
48 // Qt
49 #include <QDebug>
50 // wayland
51 #include "../compat/wayland-xdg-shell-v5-client-protocol.h"
52 #include <wayland-appmenu-client-protocol.h>
53 #include <wayland-blur-client-protocol.h>
54 #include <wayland-client-protocol.h>
55 #include <wayland-contrast-client-protocol.h>
56 #include <wayland-dpms-client-protocol.h>
57 #include <wayland-fake-input-client-protocol.h>
58 #include <wayland-fullscreen-shell-client-protocol.h>
59 #include <wayland-idle-client-protocol.h>
60 #include <wayland-idle-inhibit-unstable-v1-client-protocol.h>
61 #include <wayland-keystate-client-protocol.h>
62 #include <wayland-org_kde_kwin_outputdevice-client-protocol.h>
63 #include <wayland-output-management-client-protocol.h>
64 #include <wayland-plasma-shell-client-protocol.h>
65 #include <wayland-plasma-virtual-desktop-client-protocol.h>
66 #include <wayland-plasma-window-management-client-protocol.h>
67 #include <wayland-pointer-constraints-unstable-v1-client-protocol.h>
68 #include <wayland-pointer-gestures-unstable-v1-client-protocol.h>
69 #include <wayland-relativepointer-unstable-v1-client-protocol.h>
70 #include <wayland-remote-access-client-protocol.h>
71 #include <wayland-server-decoration-client-protocol.h>
72 #include <wayland-server-decoration-palette-client-protocol.h>
73 #include <wayland-shadow-client-protocol.h>
74 #include <wayland-slide-client-protocol.h>
75 #include <wayland-text-input-v0-client-protocol.h>
76 #include <wayland-text-input-v2-client-protocol.h>
77 #include <wayland-xdg-decoration-unstable-v1-client-protocol.h>
78 #include <wayland-xdg-foreign-unstable-v2-client-protocol.h>
79 #include <wayland-xdg-output-unstable-v1-client-protocol.h>
80 #include <wayland-xdg-shell-client-protocol.h>
81 #include <wayland-xdg-shell-v6-client-protocol.h>
82 
83 /*****
84  * How to add another interface:
85  * * define a new enum value in Registry::Interface
86  * * define the bind<InterfaceName> method
87  * * define the create<InterfaceName> method
88  * * define the <interfaceName>Announced signal
89  * * define the <interfaceName>Removed signal
90  * * add a block to s_interfaces
91  * * add the BIND macro for the new bind<InterfaceName>
92  * * add the CREATE macro for the new create<InterfaceName>
93  * * extend registry unit test to verify that it works
94  ****/
95 
96 namespace KWayland
97 {
98 namespace Client
99 {
100 namespace
101 {
102 struct SuppertedInterfaceData {
103  quint32 maxVersion;
104  QByteArray name;
105  const wl_interface *interface;
106  void (Registry::*announcedSignal)(quint32, quint32);
107  void (Registry::*removedSignal)(quint32);
108 };
109 // clang-format off
110 static const QMap<Registry::Interface, SuppertedInterfaceData> s_interfaces = {
112  4,
113  QByteArrayLiteral("wl_compositor"),
114  &wl_compositor_interface,
117  }},
119  3,
120  QByteArrayLiteral("wl_data_device_manager"),
121  &wl_data_device_manager_interface,
124  }},
126  3,
127  QByteArrayLiteral("wl_output"),
128  &wl_output_interface,
131  }},
133  1,
134  QByteArrayLiteral("wl_shm"),
135  &wl_shm_interface,
138  }},
140  5,
141  QByteArrayLiteral("wl_seat"),
142  &wl_seat_interface,
145  }},
147  1,
148  QByteArrayLiteral("wl_shell"),
149  &wl_shell_interface,
152  }},
154  1,
155  QByteArrayLiteral("wl_subcompositor"),
156  &wl_subcompositor_interface,
159  }},
161  6,
162  QByteArrayLiteral("org_kde_plasma_shell"),
163  &org_kde_plasma_shell_interface,
166  }},
168  2,
169  QByteArrayLiteral("org_kde_plasma_virtual_desktop_management"),
170  &org_kde_plasma_virtual_desktop_management_interface,
173  }},
175  15,
176  QByteArrayLiteral("org_kde_plasma_window_management"),
177  &org_kde_plasma_window_management_interface,
180  }},
182  1,
183  QByteArrayLiteral("org_kde_kwin_idle"),
184  &org_kde_kwin_idle_interface,
187  }},
189  1,
190  QByteArrayLiteral("org_kde_kwin_remote_access_manager"),
191  &org_kde_kwin_remote_access_manager_interface,
194  }},
196  4,
197  QByteArrayLiteral("org_kde_kwin_fake_input"),
198  &org_kde_kwin_fake_input_interface,
201  }},
203  4,
204  QByteArrayLiteral("org_kde_kwin_outputmanagement"),
205  &org_kde_kwin_outputmanagement_interface,
206  &Registry::outputManagementAnnounced,
208  }},
210  4,
211  QByteArrayLiteral("org_kde_kwin_outputdevice"),
212  &org_kde_kwin_outputdevice_interface,
215  }},
217  2,
218  QByteArrayLiteral("org_kde_kwin_shadow_manager"),
219  &org_kde_kwin_shadow_manager_interface,
222  }},
224  1,
225  QByteArrayLiteral("org_kde_kwin_blur_manager"),
226  &org_kde_kwin_blur_manager_interface,
229  }},
231  2,
232  QByteArrayLiteral("org_kde_kwin_contrast_manager"),
233  &org_kde_kwin_contrast_manager_interface,
236  }},
238  1,
239  QByteArrayLiteral("org_kde_kwin_slide_manager"),
240  &org_kde_kwin_slide_manager_interface,
243  }},
245  1,
246  QByteArrayLiteral("_wl_fullscreen_shell"),
247  &_wl_fullscreen_shell_interface,
250  }},
252  1,
253  QByteArrayLiteral("org_kde_kwin_dpms_manager"),
254  &org_kde_kwin_dpms_manager_interface,
257  }},
259  1,
260  QByteArrayLiteral("org_kde_kwin_server_decoration_manager"),
261  &org_kde_kwin_server_decoration_manager_interface,
264  }},
266  1,
267  QByteArrayLiteral("wl_text_input_manager"),
268  &wl_text_input_manager_interface,
271  }},
273  1,
274  QByteArrayLiteral("zwp_text_input_manager_v2"),
275  &zwp_text_input_manager_v2_interface,
278  }},
280  1,
281  QByteArrayLiteral("xdg_shell"),
282  &zxdg_shell_v5_interface,
285  }},
287  1,
288  QByteArrayLiteral("zwp_relative_pointer_manager_v1"),
289  &zwp_relative_pointer_manager_v1_interface,
292  }},
294  1,
295  QByteArrayLiteral("zwp_pointer_gestures_v1"),
296  &zwp_pointer_gestures_v1_interface,
299  }},
301  1,
302  QByteArrayLiteral("zwp_pointer_constraints_v1"),
303  &zwp_pointer_constraints_v1_interface,
306  }},
308  1,
309  QByteArrayLiteral("zxdg_exporter_v2"),
310  &zxdg_exporter_v2_interface,
313  }},
315  1,
316  QByteArrayLiteral("zxdg_importer_v2"),
317  &zxdg_importer_v2_interface,
320  }},
322  1,
323  QByteArrayLiteral("zxdg_shell_v6"),
324  &zxdg_shell_v6_interface,
327  }},
329  1,
330  QByteArrayLiteral("zwp_idle_inhibit_manager_v1"),
331  &zwp_idle_inhibit_manager_v1_interface,
334  }},
336  1,
337  QByteArrayLiteral("org_kde_kwin_appmenu_manager"),
338  &org_kde_kwin_appmenu_manager_interface,
341  }},
343  1,
344  QByteArrayLiteral("org_kde_kwin_server_decoration_palette_manager"),
345  &org_kde_kwin_server_decoration_palette_manager_interface,
348  }},
350  2,
351  QByteArrayLiteral("zxdg_output_manager_v1"),
352  &zxdg_output_manager_v1_interface,
355  }},
357  1,
358  QByteArrayLiteral("xdg_wm_base"),
359  &xdg_wm_base_interface,
362  }},
364  1,
365  QByteArrayLiteral("zxdg_decoration_manager_v1"),
366  &zxdg_decoration_manager_v1_interface,
369  }},
371  1,
372  QByteArrayLiteral("org_kde_kwin_keystate"),
373  &org_kde_kwin_keystate_interface,
376  }},
378  1,
379  QByteArrayLiteral("org_kde_plasma_activation_feedback"),
380  &org_kde_plasma_activation_feedback_interface,
383  }},
384 };
385 // clang-format on
386 
387 static quint32 maxVersion(const Registry::Interface &interface)
388 {
389  auto it = s_interfaces.find(interface);
390  if (it != s_interfaces.end()) {
391  return it.value().maxVersion;
392  }
393  return 0;
394 }
395 }
396 
397 class Q_DECL_HIDDEN Registry::Private
398 {
399 public:
400  Private(Registry *q);
401  void setup();
402  bool hasInterface(Interface interface) const;
403  AnnouncedInterface interface(Interface interface) const;
404  QVector<AnnouncedInterface> interfaces(Interface interface) const;
405  Interface interfaceForName(quint32 name) const;
406  template<typename T>
407  T *bind(Interface interface, uint32_t name, uint32_t version) const;
408  template<class T, typename WL>
409  T *create(quint32 name, quint32 version, QObject *parent, WL *(Registry::*bindMethod)(uint32_t, uint32_t) const);
410 
411  WaylandPointer<wl_registry, wl_registry_destroy> registry;
412  static const struct wl_callback_listener s_callbackListener;
413  WaylandPointer<wl_callback, wl_callback_destroy> callback;
414  EventQueue *queue = nullptr;
415 
416 private:
417  void handleAnnounce(uint32_t name, const char *interface, uint32_t version);
418  void handleRemove(uint32_t name);
419  void handleGlobalSync();
420  static void globalAnnounce(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version);
421  static void globalRemove(void *data, struct wl_registry *registry, uint32_t name);
422  static void globalSync(void *data, struct wl_callback *callback, uint32_t serial);
423 
424  Registry *q;
425  struct InterfaceData {
426  Interface interface;
427  uint32_t name;
428  uint32_t version;
429  };
430  QList<InterfaceData> m_interfaces;
431  static const struct wl_registry_listener s_registryListener;
432 };
433 
434 Registry::Private::Private(Registry *q)
435  : q(q)
436 {
437 }
438 
439 void Registry::Private::setup()
440 {
441  wl_registry_add_listener(registry, &s_registryListener, this);
442  wl_callback_add_listener(callback, &s_callbackListener, this);
443 }
444 
445 Registry::Registry(QObject *parent)
446  : QObject(parent)
447  , d(new Private(this))
448 {
449 }
450 
451 Registry::~Registry()
452 {
453  release();
454 }
455 
456 void Registry::release()
457 {
458  d->registry.release();
459  d->callback.release();
460 }
461 
462 void Registry::destroy()
463 {
464  Q_EMIT registryDestroyed();
465  d->registry.destroy();
466  d->callback.destroy();
467 }
468 
469 void Registry::create(wl_display *display)
470 {
471  Q_ASSERT(display);
472  Q_ASSERT(!isValid());
473  d->registry.setup(wl_display_get_registry(display));
474  d->callback.setup(wl_display_sync(display));
475  if (d->queue) {
476  d->queue->addProxy(d->registry);
477  d->queue->addProxy(d->callback);
478  }
479 }
480 
481 void Registry::create(ConnectionThread *connection)
482 {
483  create(connection->display());
484  connect(connection, &ConnectionThread::connectionDied, this, &Registry::destroy);
485 }
486 
487 void Registry::setup()
488 {
489  Q_ASSERT(isValid());
490  d->setup();
491 }
492 
493 void Registry::setEventQueue(EventQueue *queue)
494 {
495  d->queue = queue;
496  if (!queue) {
497  return;
498  }
499  if (d->registry) {
500  d->queue->addProxy(d->registry);
501  }
502  if (d->callback) {
503  d->queue->addProxy(d->callback);
504  }
505 }
506 
507 EventQueue *Registry::eventQueue()
508 {
509  return d->queue;
510 }
511 
512 #ifndef K_DOXYGEN
513 const struct wl_registry_listener Registry::Private::s_registryListener = {globalAnnounce, globalRemove};
514 
515 const struct wl_callback_listener Registry::Private::s_callbackListener = {globalSync};
516 #endif
517 
518 void Registry::Private::globalAnnounce(void *data, wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
519 {
520  auto r = reinterpret_cast<Registry::Private *>(data);
521  Q_ASSERT(registry == r->registry);
522  r->handleAnnounce(name, interface, version);
523 }
524 
525 void Registry::Private::globalRemove(void *data, wl_registry *registry, uint32_t name)
526 {
527  auto r = reinterpret_cast<Registry::Private *>(data);
528  Q_ASSERT(registry == r->registry);
529  r->handleRemove(name);
530 }
531 
532 void Registry::Private::globalSync(void *data, wl_callback *callback, uint32_t serial)
533 {
534  Q_UNUSED(serial)
535  auto r = reinterpret_cast<Registry::Private *>(data);
536  Q_ASSERT(r->callback == callback);
537  r->handleGlobalSync();
538  r->callback.release();
539 }
540 
541 void Registry::Private::handleGlobalSync()
542 {
543  Q_EMIT q->interfacesAnnounced();
544 }
545 
546 namespace
547 {
548 static Registry::Interface nameToInterface(const char *interface)
549 {
550  for (auto it = s_interfaces.constBegin(); it != s_interfaces.constEnd(); ++it) {
551  if (qstrcmp(interface, it.value().name) == 0) {
552  return it.key();
553  }
554  }
555  return Registry::Interface::Unknown;
556 }
557 }
558 
559 void Registry::Private::handleAnnounce(uint32_t name, const char *interface, uint32_t version)
560 {
561  Interface i = nameToInterface(interface);
562  Q_EMIT q->interfaceAnnounced(QByteArray(interface), name, version);
563  if (i == Interface::Unknown) {
564  qCDebug(KWAYLAND_CLIENT) << "Unknown interface announced: " << interface << "/" << name << "/" << version;
565  return;
566  }
567  qCDebug(KWAYLAND_CLIENT) << "Wayland Interface: " << interface << "/" << name << "/" << version;
568  m_interfaces.append({i, name, version});
569  auto it = s_interfaces.constFind(i);
570  if (it != s_interfaces.end()) {
571  Q_EMIT(q->*it.value().announcedSignal)(name, version);
572  }
573 }
574 
575 void Registry::Private::handleRemove(uint32_t name)
576 {
577  auto it = std::find_if(m_interfaces.begin(), m_interfaces.end(), [name](const InterfaceData &data) {
578  return data.name == name;
579  });
580  if (it != m_interfaces.end()) {
581  InterfaceData data = *(it);
582  m_interfaces.erase(it);
583  auto sit = s_interfaces.find(data.interface);
584  if (sit != s_interfaces.end()) {
585  Q_EMIT(q->*sit.value().removedSignal)(data.name);
586  }
587  }
588  Q_EMIT q->interfaceRemoved(name);
589 }
590 
591 bool Registry::Private::hasInterface(Registry::Interface interface) const
592 {
593  auto it = std::find_if(m_interfaces.constBegin(), m_interfaces.constEnd(), [interface](const InterfaceData &data) {
594  return data.interface == interface;
595  });
596  return it != m_interfaces.constEnd();
597 }
598 
599 QVector<Registry::AnnouncedInterface> Registry::Private::interfaces(Interface interface) const
600 {
602  for (auto it = m_interfaces.constBegin(); it != m_interfaces.constEnd(); ++it) {
603  const auto &data = *it;
604  if (data.interface == interface) {
605  retVal << AnnouncedInterface{data.name, data.version};
606  }
607  }
608  return retVal;
609 }
610 
611 Registry::AnnouncedInterface Registry::Private::interface(Interface interface) const
612 {
613  const auto all = interfaces(interface);
614  if (!all.isEmpty()) {
615  return all.last();
616  }
617  return AnnouncedInterface{0, 0};
618 }
619 
620 Registry::Interface Registry::Private::interfaceForName(quint32 name) const
621 {
622  auto it = std::find_if(m_interfaces.constBegin(), m_interfaces.constEnd(), [name](const InterfaceData &data) {
623  return data.name == name;
624  });
625  if (it == m_interfaces.constEnd()) {
626  return Interface::Unknown;
627  }
628  return (*it).interface;
629 }
630 
631 bool Registry::hasInterface(Registry::Interface interface) const
632 {
633  return d->hasInterface(interface);
634 }
635 
636 QVector<Registry::AnnouncedInterface> Registry::interfaces(Interface interface) const
637 {
638  return d->interfaces(interface);
639 }
640 
641 Registry::AnnouncedInterface Registry::interface(Interface interface) const
642 {
643  return d->interface(interface);
644 }
645 
646 // clang-format off
647 #define BIND2(__NAME__, __INAME__, __WL__) \
648 __WL__ *Registry::bind##__NAME__(uint32_t name, uint32_t version) const \
649 { \
650  return d->bind<__WL__>(Interface::__INAME__, name, qMin(maxVersion(Interface::__INAME__), version)); \
651 }
652 
653 #define BIND(__NAME__, __WL__) BIND2(__NAME__, __NAME__, __WL__)
654 // clang-format on
655 
656 BIND(Compositor, wl_compositor)
657 BIND(Output, wl_output)
658 BIND(Seat, wl_seat)
659 BIND(Shell, wl_shell)
660 BIND(Shm, wl_shm)
661 BIND(SubCompositor, wl_subcompositor)
662 BIND(FullscreenShell, _wl_fullscreen_shell)
663 BIND(DataDeviceManager, wl_data_device_manager)
664 BIND(PlasmaShell, org_kde_plasma_shell)
665 BIND(PlasmaActivationFeedback, org_kde_plasma_activation_feedback)
666 BIND(PlasmaVirtualDesktopManagement, org_kde_plasma_virtual_desktop_management)
667 BIND(PlasmaWindowManagement, org_kde_plasma_window_management)
668 BIND(Idle, org_kde_kwin_idle)
669 BIND(RemoteAccessManager, org_kde_kwin_remote_access_manager)
670 BIND(FakeInput, org_kde_kwin_fake_input)
671 BIND(OutputManagement, org_kde_kwin_outputmanagement)
672 BIND(OutputDevice, org_kde_kwin_outputdevice)
673 BIND(ServerSideDecorationManager, org_kde_kwin_server_decoration_manager)
674 BIND(TextInputManagerUnstableV0, wl_text_input_manager)
675 BIND(TextInputManagerUnstableV2, zwp_text_input_manager_v2)
676 BIND(XdgShellUnstableV5, xdg_shell)
677 BIND(XdgShellUnstableV6, zxdg_shell_v6)
678 BIND(XdgShellStable, xdg_wm_base)
679 BIND(RelativePointerManagerUnstableV1, zwp_relative_pointer_manager_v1)
680 BIND(PointerGesturesUnstableV1, zwp_pointer_gestures_v1)
681 BIND(PointerConstraintsUnstableV1, zwp_pointer_constraints_v1)
682 BIND(XdgExporterUnstableV2, zxdg_exporter_v2)
683 BIND(XdgImporterUnstableV2, zxdg_importer_v2)
684 BIND(IdleInhibitManagerUnstableV1, zwp_idle_inhibit_manager_v1)
685 BIND(Keystate, org_kde_kwin_keystate)
686 BIND2(ShadowManager, Shadow, org_kde_kwin_shadow_manager)
687 BIND2(BlurManager, Blur, org_kde_kwin_blur_manager)
688 BIND2(ContrastManager, Contrast, org_kde_kwin_contrast_manager)
689 BIND2(SlideManager, Slide, org_kde_kwin_slide_manager)
690 BIND2(DpmsManager, Dpms, org_kde_kwin_dpms_manager)
691 BIND2(AppMenuManager, AppMenu, org_kde_kwin_appmenu_manager)
692 BIND2(ServerSideDecorationPaletteManager, ServerSideDecorationPalette, org_kde_kwin_server_decoration_palette_manager)
693 BIND(XdgOutputUnstableV1, zxdg_output_manager_v1)
694 BIND(XdgDecorationUnstableV1, zxdg_decoration_manager_v1)
695 
696 #undef BIND
697 #undef BIND2
698 
699 template<class T, typename WL>
700 T *Registry::Private::create(quint32 name, quint32 version, QObject *parent, WL *(Registry::*bindMethod)(uint32_t, uint32_t) const)
701 {
702  T *t = new T(parent);
703  t->setEventQueue(queue);
704  t->setup((q->*bindMethod)(name, version));
705  QObject::connect(q, &Registry::interfaceRemoved, t, [t, name](quint32 removed) {
706  if (name == removed) {
707  Q_EMIT t->removed();
708  }
709  });
710  QObject::connect(q, &Registry::registryDestroyed, t, &T::destroy);
711  return t;
712 }
713 
714 // clang-format off
715 #define CREATE2(__NAME__, __BINDNAME__) \
716 __NAME__ *Registry::create##__NAME__(quint32 name, quint32 version, QObject *parent) \
717 { \
718  return d->create<__NAME__>(name, version, parent, &Registry::bind##__BINDNAME__); \
719 }
720 
721 #define CREATE(__NAME__) CREATE2(__NAME__, __NAME__)
722 // clang-format on
723 
724 CREATE(Compositor)
725 CREATE(Seat)
726 CREATE(Shell)
727 CREATE(SubCompositor)
728 CREATE(FullscreenShell)
729 CREATE(Output)
730 CREATE(DataDeviceManager)
731 CREATE(PlasmaShell)
735 CREATE(Idle)
736 CREATE(RemoteAccessManager)
737 CREATE(FakeInput)
738 CREATE(OutputManagement)
739 CREATE(OutputDevice)
740 CREATE(ShadowManager)
741 CREATE(BlurManager)
742 CREATE(ContrastManager)
743 CREATE(SlideManager)
744 CREATE(DpmsManager)
746 CREATE2(ShmPool, Shm)
747 CREATE(AppMenuManager)
748 CREATE(Keystate)
750 
751 #undef CREATE
752 #undef CREATE2
753 
754 XdgExporter *Registry::createXdgExporter(quint32 name, quint32 version, QObject *parent)
755 {
756  // only V1 supported for now
757  return d->create<XdgExporterUnstableV2>(name, version, parent, &Registry::bindXdgExporterUnstableV2);
758 }
759 
760 XdgImporter *Registry::createXdgImporter(quint32 name, quint32 version, QObject *parent)
761 {
762  // only V1 supported for now
763  return d->create<XdgImporterUnstableV2>(name, version, parent, &Registry::bindXdgImporterUnstableV2);
764 }
765 
766 TextInputManager *Registry::createTextInputManager(quint32 name, quint32 version, QObject *parent)
767 {
768  switch (d->interfaceForName(name)) {
769  case Interface::TextInputManagerUnstableV0:
770  return d->create<TextInputManagerUnstableV0>(name, version, parent, &Registry::bindTextInputManagerUnstableV0);
771  case Interface::TextInputManagerUnstableV2:
772  return d->create<TextInputManagerUnstableV2>(name, version, parent, &Registry::bindTextInputManagerUnstableV2);
773  default:
774  return nullptr;
775  }
776 }
777 
778 XdgShell *Registry::createXdgShell(quint32 name, quint32 version, QObject *parent)
779 {
780  switch (d->interfaceForName(name)) {
781  case Interface::XdgShellUnstableV5:
782  return d->create<XdgShellUnstableV5>(name, version, parent, &Registry::bindXdgShellUnstableV5);
783  case Interface::XdgShellUnstableV6:
784  return d->create<XdgShellUnstableV6>(name, version, parent, &Registry::bindXdgShellUnstableV6);
785  case Interface::XdgShellStable:
786  return d->create<XdgShellStable>(name, version, parent, &Registry::bindXdgShellStable);
787  default:
788  return nullptr;
789  }
790 }
791 
792 RelativePointerManager *Registry::createRelativePointerManager(quint32 name, quint32 version, QObject *parent)
793 {
794  switch (d->interfaceForName(name)) {
795  case Interface::RelativePointerManagerUnstableV1:
796  return d->create<RelativePointerManager>(name, version, parent, &Registry::bindRelativePointerManagerUnstableV1);
797  default:
798  return nullptr;
799  }
800 }
801 
802 PointerGestures *Registry::createPointerGestures(quint32 name, quint32 version, QObject *parent)
803 {
804  switch (d->interfaceForName(name)) {
805  case Interface::PointerGesturesUnstableV1:
806  return d->create<PointerGestures>(name, version, parent, &Registry::bindPointerGesturesUnstableV1);
807  default:
808  return nullptr;
809  }
810 }
811 
812 PointerConstraints *Registry::createPointerConstraints(quint32 name, quint32 version, QObject *parent)
813 {
814  switch (d->interfaceForName(name)) {
815  case Interface::PointerConstraintsUnstableV1:
816  return d->create<PointerConstraints>(name, version, parent, &Registry::bindPointerConstraintsUnstableV1);
817  default:
818  return nullptr;
819  }
820 }
821 
822 IdleInhibitManager *Registry::createIdleInhibitManager(quint32 name, quint32 version, QObject *parent)
823 {
824  switch (d->interfaceForName(name)) {
825  case Interface::IdleInhibitManagerUnstableV1:
826  return d->create<IdleInhibitManager>(name, version, parent, &Registry::bindIdleInhibitManagerUnstableV1);
827  default:
828  return nullptr;
829  }
830 }
831 
832 XdgOutputManager *Registry::createXdgOutputManager(quint32 name, quint32 version, QObject *parent)
833 {
834  switch (d->interfaceForName(name)) {
835  case Interface::XdgOutputUnstableV1:
836  return d->create<XdgOutputManager>(name, version, parent, &Registry::bindXdgOutputUnstableV1);
837  default:
838  return nullptr;
839  }
840 }
841 
842 XdgDecorationManager *Registry::createXdgDecorationManager(quint32 name, quint32 version, QObject *parent)
843 {
844  switch (d->interfaceForName(name)) {
845  case Interface::XdgDecorationUnstableV1:
846  return d->create<XdgDecorationManager>(name, version, parent, &Registry::bindXdgDecorationUnstableV1);
847  default:
848  return nullptr;
849  }
850 }
851 
852 namespace
853 {
854 static const wl_interface *wlInterface(Registry::Interface interface)
855 {
856  auto it = s_interfaces.find(interface);
857  if (it != s_interfaces.end()) {
858  return it.value().interface;
859  }
860  return nullptr;
861 }
862 }
863 
864 template<typename T>
865 T *Registry::Private::bind(Registry::Interface interface, uint32_t name, uint32_t version) const
866 {
867  auto it = std::find_if(m_interfaces.constBegin(), m_interfaces.constEnd(), [=](const InterfaceData &data) {
868  return data.interface == interface && data.name == name && data.version >= version;
869  });
870  if (it == m_interfaces.constEnd()) {
871  qCDebug(KWAYLAND_CLIENT) << "Don't have interface " << int(interface) << "with name " << name << "and minimum version" << version;
872  return nullptr;
873  }
874  auto t = reinterpret_cast<T *>(wl_registry_bind(registry, name, wlInterface(interface), version));
875  if (queue) {
876  queue->addProxy(t);
877  }
878  return t;
879 }
880 
881 bool Registry::isValid() const
882 {
883  return d->registry.isValid();
884 }
885 
886 wl_registry *Registry::registry()
887 {
888  return d->registry;
889 }
890 
891 Registry::operator wl_registry *() const
892 {
893  return d->registry;
894 }
895 
896 Registry::operator wl_registry *()
897 {
898  return d->registry;
899 }
900 
901 }
902 }
void idleInhibitManagerUnstableV1Announced(quint32 name, quint32 version)
Emitted whenever a zwp_idle_inhibit_manager_v1 interface gets announced.
Wrapper for the org_kde_kwin_blur interface.
Definition: blur.h:132
Wrapper for the zxdg_exporter_v2 interface.
Definition: xdgforeign.h:52
Wrapper for the zxdg_exporter_v2 interface.
Definition: xdgforeign_v2.h:51
void textInputManagerUnstableV2Removed(quint32 name)
Emitted whenever a zwp_text_input_manager_v2 interface gets removed.
Refers to org_kde_kwin_fake_input interface.
Wrapper for the org_kde_kwin_contrast interface.
Definition: contrast.h:130
void serverSideDecorationPaletteManagerRemoved(quint32 name)
Emitted whenever a org_kde_kwin_server_decoration_palette_manager gets removed.
Wrapper for the org_kde_kwin_server_decoration_palette_manager interface.
Refers to org_kde_kwin_server_decoration_palette_manager.
Refers to org_kde_plasma_virtual_desktop_management interface.
Refers to org_kde_plasma_activation_feedback interface,.
void compositorRemoved(quint32 name)
Emitted whenever a wl_compositor interface gets removed.
void seatRemoved(quint32 name)
Emitted whenever a wl_seat interface gets removed.
void outputManagementRemoved(quint32 name)
Emitted whenever a org_kde_kwin_outputmanagement interface gets removed.
void relativePointerManagerUnstableV1Announced(quint32 name, quint32 version)
Emitted whenever a zwp_relative_pointer_manager_v1 interface gets announced.
void xdgShellStableAnnounced(quint32 name, quint32 version)
Emitted whenever a xdg_wm_base (stable xdg shell) interface gets announced.
Wrapper for the _wl_fullscreen_shell interface.
Wrapper for the xdg_shell interface.
Definition: xdgshell.h:155
void outputAnnounced(quint32 name, quint32 version)
Emitted whenever a wl_output interface gets announced.
void relativePointerManagerUnstableV1Removed(quint32 name)
Emitted whenever a zwp_relative_pointer_manager_v1 interface gets removed.
void outputDeviceRemoved(quint32 name)
Emitted whenever a org_kde_kwin_outputdevice interface gets removed.
void plasmaVirtualDesktopManagementAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_plasma_virtual_desktop_management interface gets announced.
Wrapper for the zwp_pointer_constraints_v1 interface.
QAction * create(StandardAction id, const QObject *recvr, Func slot, QObject *parent)
Wrapper class for wl_shm interface.
Definition: shm_pool.h:115
Wrapper for the zxdg_importer_v2 interface.
Definition: xdgforeign_v2.h:91
Manager class for the TextInputManager interfaces.
Definition: textinput.h:415
Refers to the _wl_fullscreen_shell interface.
QMap::const_iterator constBegin() const const
void plasmaVirtualDesktopManagementRemoved(quint32 name)
Emitted whenever a org_kde_plasma_virtual_desktop_management interface gets removed.
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
void pointerGesturesUnstableV1Announced(quint32 name, quint32 version)
Emitted whenever a zwp_pointer_gestures_v1 interface gets announced.
Wrapper for the wl_compositor interface.
Definition: compositor.h:49
void importerUnstableV2Removed(quint32 name)
Emitted whenever a zxdg_importer_v2 interface gets removed.
void blurAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_blur_manager interface gets announced.
void dpmsRemoved(quint32 name)
Emitted whenever a org_kde_kwin_dpms_manager interface gets removed.
refers to org_kde_kwin_blur_manager interface
Refers to org_kde_kwin_remote_access_manager interface.
QMap::const_iterator constFind(const Key &key) const const
void compositorAnnounced(quint32 name, quint32 version)
Emitted whenever a wl_compositor interface gets announced.
void xdgShellUnstableV6Removed(quint32 name)
Emitted whenever an xdg_shell (unstable version 5) interface gets removed.
void subCompositorRemoved(quint32 name)
Emitted whenever a wl_subcompositor interface gets removed.
void shadowAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_shadow_manager interface gets announced.
Wrapper for the wl_seat interface.
Definition: seat.h:51
Wrapper for the org_kde_kwin_remote_access_manager interface.
Definition: remote_access.h:47
Refers to the wl_output interface.
Refers to the wl_data_device_manager interface.
Wrapper for the wl_output interface.
Definition: output.h:54
void importerUnstableV2Announced(quint32 name, quint32 version)
Emitted whenever a zxdg_importer_v2 interface gets announced.
void shmRemoved(quint32 name)
Emitted whenever a wl_shm interface gets removed.
void slideAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_slide_manager interface gets announced.
void xdgDecorationAnnounced(quint32 name, quint32 version)
Emitted whenever a zxdg_decoration_manager_v1 interface gets announced.
Wrapper for the org_kde_plasma_virtual_desktop_management interface.
Wrapper for the zxdg_decoration_manager_v1 interface.
Definition: xdgdecoration.h:50
Refers to zxdg_shell_v6 (unstable version 6)
Wrapper for the org_kde_kwin_shadow interface.
Definition: shadow.h:149
Refers to org_kde_kwin_dpms_manager interface.
void exporterUnstableV2Removed(quint32 name)
Emitted whenever a zxdg_exporter_v2 interface gets removed.
Refers to zwp_idle_inhibit_manager_v1 (unstable version 1)
Refers to org_kde_kwin_server_decoration_manager.
Refers to org_kde_plasma_shell interface.
Wrapper for the zxdg_importer_v2 interface.
Definition: xdgforeign.h:152
void idleInhibitManagerUnstableV1Removed(quint32 name)
Emitted whenever a zwp_idle_inhibit_manager_v1 interface gets removed.
void textInputManagerUnstableV0Removed(quint32 name)
Emitted whenever a wl_text_input_manager interface gets removed.
void xdgShellUnstableV5Removed(quint32 name)
Emitted whenever an xdg_shell (unstable version 5) interface gets removed.
void idleAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_idle interface gets announced.
Wrapper for the org_kde_kwin_fake_input interface.
Definition: fakeinput.h:47
void outputRemoved(quint32 name)
Emitted whenever a wl_output interface gets removed.
void pointerConstraintsUnstableV1Announced(quint32 name, quint32 version)
Emitted whenever a zwp_pointer_constraints_v1 interface gets announced.
Interface
The well-known interfaces this Registry supports.
Definition: registry.h:138
void plasmaWindowManagementAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_plasma_window_management interface gets announced.
Wrapper for the zxdg_output_manager_v1 interface.
Definition: xdgoutput.h:54
Creates and manages the connection to a Wayland server.
void appMenuRemoved(quint32 name)
Emitted whenever a org_kde_kwin_appmenu_manager gets removed.
void fakeInputAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_fake_input interface gets announced.
void xdgShellUnstableV5Announced(quint32 name, quint32 version)
Emitted whenever a xdg_shell (unstable version 5) interface gets announced.
void keystateRemoved(quint32 name)
Emitted whenever a org_kde_kwin_keystate gets removed.
void serverSideDecorationManagerAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_server_decoration_manager interface gets announced.
Wrapper for the org_kde_kwin_appmenu_manager interface.
Definition: appmenu.h:48
void outputDeviceAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_outputdevice interface gets announced.
Refers to org_kde_kwin_shadow_manager interface.
void fullscreenShellAnnounced(quint32 name, quint32 version)
Emitted whenever a _wl_fullscreen_shell interface gets announced.
Refers to org_kde_kwin_idle_interface interface.
Refers to the wl_data_device_manager interface.
QMap::const_iterator constEnd() const const
Wrapper for the zwp_pointer_gestures_v1 interface.
Wrapper for the org_kde_plasma_shell interface.
Definition: plasmashell.h:51
Refers to org_kde_kwin_appmenu.
This class is a factory for Dpms instances.
Definition: dpms.h:48
void keystateAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_keystate interface gets announced.
Refers to the wl_shm interface.
void shellAnnounced(quint32 name, quint32 version)
Emitted whenever a wl_shell interface gets announced.
Refers to xdg_shell (unstable version 5)
Wrapper for the org_kde_kwin_idle interface.
Definition: idle.h:52
QMap::iterator end()
Refers to the wl_shell interface.
void shadowRemoved(quint32 name)
Emitted whenever a org_kde_kwin_shadow_manager interface gets removed.
void remoteAccessManagerAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_remote_access_manager interface gets announced.
Representation of one announced interface.
Definition: registry.h:249
void idleRemoved(quint32 name)
Emitted whenever a org_kde_kwin_idle interface gets removed.
void slideRemoved(quint32 name)
Emitted whenever a org_kde_kwin_slide_manager interface gets removed.
void textInputManagerUnstableV2Announced(quint32 name, quint32 version)
Emitted whenever a zwp_text_input_manager_v2 interface gets announced.
void shellRemoved(quint32 name)
Emitted whenever a wl_shell interface gets removed.
Wrapper for the zwp_relative_pointer_manager_v1 interface.
void dataDeviceManagerRemoved(quint32 name)
Emitted whenever a wl_data_device_manager interface gets removed.
Wrapper for the org_kde_kwin_server_decoration_manager interface.
void xdgOutputAnnounced(quint32 name, quint32 version)
Emitted whenever a zxdg_output_v1 interface gets announced.
void xdgShellStableRemoved(quint32 name)
Emitted whenever an xdg_wm_base (stable xdgshell) interface gets removed.
Wrapper for the org_kde_plasma_window_management interface.
void plasmaActivationFeedbackAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_plasma_activation_feedback interface gets announced.
void fakeInputRemoved(quint32 name)
Emitted whenever a org_kde_kwin_fake_input interface gets removed.
Refers to the wl_compositor interface.
quint32 name
The name of the announced interface.
Definition: registry.h:253
void xdgOutputRemoved(quint32 name)
Emitted whenever a zxdg_output_v1 gets removed.
void contrastAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_contrast_manager interface gets announced.
void blurRemoved(quint32 name)
Emitted whenever a org_kde_kwin_blur_manager interface gets removed.
void pointerGesturesUnstableV1Removed(quint32 name)
Emitted whenever a zwp_pointer_gestures_v1 interface gets removed.
void fullscreenShellRemoved(quint32 name)
Emitted whenever a _wl_fullscreen_shell interface gets removed.
refers to org_kde_kwin_slide_manager
Wrapper for the org_kde_kwin_slide_manager interface.
Definition: slide.h:54
void remoteAccessManagerRemoved(quint32 name)
Emitted whenever a org_kde_kwin_remote_access_manager interface gets removed.
Refers to the wl_subcompositor interface;.
Refers to the org_kde_kwin_outputdevice interface.
void subCompositorAnnounced(quint32 name, quint32 version)
Emitted whenever a wl_subcompositor interface gets announced.
void serverSideDecorationManagerRemoved(quint32 name)
Emitted whenever a org_kde_kwin_server_decoration_manager interface gets removed. ...
void plasmaShellAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_plasma_shell interface gets announced.
void dataDeviceManagerAnnounced(quint32 name, quint32 version)
Emitted whenever a wl_data_device_manager interface gets announced.
void pointerConstraintsUnstableV1Removed(quint32 name)
Emitted whenever a zwp_pointer_constraints_v1 interface gets removed.
void plasmaShellRemoved(quint32 name)
Emitted whenever a org_kde_plasma_shell interface gets removed.
void serverSideDecorationPaletteManagerAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_server_decoration_palette_manager interface gets announced.
Wrapper for the org_kde_kwin_outputmanagement interface.
refers to org_kde_kwin_contrast_manager interface
void seatAnnounced(quint32 name, quint32 version)
Emitted whenever a wl_seat interface gets announced.
void plasmaActivationFeedbackRemoved(quint32 name)
Emitted whenever a org_kde_plasma_activation_feedback interface gets removed.
void appMenuAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_appmenu_manager interface gets announced.
void xdgShellUnstableV6Announced(quint32 name, quint32 version)
Emitted whenever a zxdg_shell_v6 (unstable version 6) interface gets announced.
void textInputManagerUnstableV0Announced(quint32 name, quint32 version)
Emitted whenever a wl_text_input_manager interface gets announced.
Wrapper for the wl_subcompositor interface.
Definition: subcompositor.h:34
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
Wrapper for the org_kde_kwin_outputdevice interface.
Definition: outputdevice.h:57
Wrapper for the wl_data_device_manager interface.
Wrapper for the zwp_idle_inhibit_manager_v1 interface.
Definition: idleinhibit.h:48
void xdgDecorationRemoved(quint32 name)
Emitted whenever a zxdg_decoration_manager_v1 gets removed.
void exporterUnstableV2Announced(quint32 name, quint32 version)
Emitted whenever a zxdg_exporter_v2 interface gets announced.
void shmAnnounced(quint32 name, quint32 version)
Emitted whenever a wl_shm interface gets announced.
QMap::iterator find(const Key &key)
void contrastRemoved(quint32 name)
Emitted whenever a org_kde_kwin_contrast_manager interface gets removed.
void plasmaWindowManagementRemoved(quint32 name)
Emitted whenever a org_kde_plasma_window_management interface gets removed.
void dpmsAnnounced(quint32 name, quint32 version)
Emitted whenever a org_kde_kwin_dpms_manager interface gets announced.
Q_EMITQ_EMIT
wl_display * display()
The display this ConnectionThread is connected to.
Refers to org_kde_plasma_window_management interface.
Wrapper for the wl_shell interface.
Definition: shell.h:55
Power management for monitors.
Definition: dpms.h:130
Refers to the wl_seat interface.
Wrapper for the org_kde_kwin_shadow_manager interface.
Definition: shadow.h:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Sep 23 2021 22:51:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.