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 "compositor.h"
9 #include "connection_thread.h"
10 #include "datadevicemanager.h"
11 #include "dpms.h"
12 #include "event_queue.h"
13 #include "fakeinput.h"
14 #include "fullscreen_shell.h"
15 #include "idle.h"
16 #include "idleinhibit.h"
17 #include "keystate.h"
18 #include "remote_access.h"
19 #include "logging.h"
20 #include "outputconfiguration.h"
21 #include "outputmanagement.h"
22 #include "outputdevice.h"
23 #include "output.h"
24 #include "plasmashell.h"
25 #include "plasmavirtualdesktop.h"
26 #include "plasmawindowmanagement.h"
27 #include "pointerconstraints.h"
28 #include "pointergestures.h"
29 #include "seat.h"
30 #include "shadow.h"
31 #include "blur.h"
32 #include "contrast.h"
33 #include "relativepointer.h"
34 #include "server_decoration.h"
35 #include "slide.h"
36 #include "shell.h"
37 #include "shm_pool.h"
38 #include "subcompositor.h"
39 #include "textinput_p.h"
40 #include "xdgshell.h"
41 #include "xdgshell_p.h"
42 #include "wayland_pointer_p.h"
43 #include "xdgforeign_v2.h"
44 #include "appmenu.h"
45 #include "server_decoration_palette.h"
46 #include "xdgoutput.h"
47 #include "xdgdecoration.h"
48 // Qt
49 #include <QDebug>
50 // wayland
51 #include <wayland-client-protocol.h>
52 #include <wayland-fullscreen-shell-client-protocol.h>
53 #include <wayland-plasma-shell-client-protocol.h>
54 #include <wayland-plasma-virtual-desktop-client-protocol.h>
55 #include <wayland-plasma-window-management-client-protocol.h>
56 #include <wayland-idle-client-protocol.h>
57 #include <wayland-idle-inhibit-unstable-v1-client-protocol.h>
58 #include <wayland-remote-access-client-protocol.h>
59 #include <wayland-fake-input-client-protocol.h>
60 #include <wayland-shadow-client-protocol.h>
61 #include <wayland-output-management-client-protocol.h>
62 #include <wayland-org_kde_kwin_outputdevice-client-protocol.h>
63 #include <wayland-blur-client-protocol.h>
64 #include <wayland-contrast-client-protocol.h>
65 #include <wayland-slide-client-protocol.h>
66 #include <wayland-dpms-client-protocol.h>
67 #include <wayland-server-decoration-client-protocol.h>
68 #include <wayland-text-input-v0-client-protocol.h>
69 #include <wayland-text-input-v2-client-protocol.h>
70 #include "../compat/wayland-xdg-shell-v5-client-protocol.h"
71 #include <wayland-xdg-shell-v6-client-protocol.h>
72 #include <wayland-xdg-shell-client-protocol.h>
73 #include <wayland-relativepointer-unstable-v1-client-protocol.h>
74 #include <wayland-pointer-gestures-unstable-v1-client-protocol.h>
75 #include <wayland-pointer-constraints-unstable-v1-client-protocol.h>
76 #include <wayland-xdg-foreign-unstable-v2-client-protocol.h>
77 #include <wayland-appmenu-client-protocol.h>
78 #include <wayland-server-decoration-palette-client-protocol.h>
79 #include <wayland-xdg-output-unstable-v1-client-protocol.h>
80 #include <wayland-xdg-decoration-unstable-v1-client-protocol.h>
81 #include <wayland-keystate-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 
101 namespace {
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 static const QMap<Registry::Interface, SuppertedInterfaceData> s_interfaces = {
111  4,
112  QByteArrayLiteral("wl_compositor"),
113  &wl_compositor_interface,
116  }},
118  3,
119  QByteArrayLiteral("wl_data_device_manager"),
120  &wl_data_device_manager_interface,
123  }},
125  3,
126  QByteArrayLiteral("wl_output"),
127  &wl_output_interface,
130  }},
132  1,
133  QByteArrayLiteral("wl_shm"),
134  &wl_shm_interface,
137  }},
139  5,
140  QByteArrayLiteral("wl_seat"),
141  &wl_seat_interface,
144  }},
146  1,
147  QByteArrayLiteral("wl_shell"),
148  &wl_shell_interface,
151  }},
153  1,
154  QByteArrayLiteral("wl_subcompositor"),
155  &wl_subcompositor_interface,
158  }},
160  6,
161  QByteArrayLiteral("org_kde_plasma_shell"),
162  &org_kde_plasma_shell_interface,
165  }},
167  2,
168  QByteArrayLiteral("org_kde_plasma_virtual_desktop_management"),
169  &org_kde_plasma_virtual_desktop_management_interface,
172  }},
174  13,
175  QByteArrayLiteral("org_kde_plasma_window_management"),
176  &org_kde_plasma_window_management_interface,
179  }},
181  1,
182  QByteArrayLiteral("org_kde_kwin_idle"),
183  &org_kde_kwin_idle_interface,
186  }},
188  1,
189  QByteArrayLiteral("org_kde_kwin_remote_access_manager"),
190  &org_kde_kwin_remote_access_manager_interface,
193  }},
195  4,
196  QByteArrayLiteral("org_kde_kwin_fake_input"),
197  &org_kde_kwin_fake_input_interface,
200  }},
202  2,
203  QByteArrayLiteral("org_kde_kwin_outputmanagement"),
204  &org_kde_kwin_outputmanagement_interface,
205  &Registry::outputManagementAnnounced,
207  }},
209  2,
210  QByteArrayLiteral("org_kde_kwin_outputdevice"),
211  &org_kde_kwin_outputdevice_interface,
214  }},
216  2,
217  QByteArrayLiteral("org_kde_kwin_shadow_manager"),
218  &org_kde_kwin_shadow_manager_interface,
221  }},
223  1,
224  QByteArrayLiteral("org_kde_kwin_blur_manager"),
225  &org_kde_kwin_blur_manager_interface,
228  }},
230  1,
231  QByteArrayLiteral("org_kde_kwin_contrast_manager"),
232  &org_kde_kwin_contrast_manager_interface,
235  }},
237  1,
238  QByteArrayLiteral("org_kde_kwin_slide_manager"),
239  &org_kde_kwin_slide_manager_interface,
242  }},
244  1,
245  QByteArrayLiteral("_wl_fullscreen_shell"),
246  &_wl_fullscreen_shell_interface,
249  }},
251  1,
252  QByteArrayLiteral("org_kde_kwin_dpms_manager"),
253  &org_kde_kwin_dpms_manager_interface,
256  }},
258  1,
259  QByteArrayLiteral("org_kde_kwin_server_decoration_manager"),
260  &org_kde_kwin_server_decoration_manager_interface,
263  }},
265  1,
266  QByteArrayLiteral("wl_text_input_manager"),
267  &wl_text_input_manager_interface,
270  }},
272  1,
273  QByteArrayLiteral("zwp_text_input_manager_v2"),
274  &zwp_text_input_manager_v2_interface,
277  }},
279  1,
280  QByteArrayLiteral("xdg_shell"),
281  &zxdg_shell_v5_interface,
284  }},
286  1,
287  QByteArrayLiteral("zwp_relative_pointer_manager_v1"),
288  &zwp_relative_pointer_manager_v1_interface,
291  }},
293  1,
294  QByteArrayLiteral("zwp_pointer_gestures_v1"),
295  &zwp_pointer_gestures_v1_interface,
298  }},
300  1,
301  QByteArrayLiteral("zwp_pointer_constraints_v1"),
302  &zwp_pointer_constraints_v1_interface,
305  }},
307  1,
308  QByteArrayLiteral("zxdg_exporter_v2"),
309  &zxdg_exporter_v2_interface,
312  }},
314  1,
315  QByteArrayLiteral("zxdg_importer_v2"),
316  &zxdg_importer_v2_interface,
319  }},
321  1,
322  QByteArrayLiteral("zxdg_shell_v6"),
323  &zxdg_shell_v6_interface,
326  }},
328  1,
329  QByteArrayLiteral("zwp_idle_inhibit_manager_v1"),
330  &zwp_idle_inhibit_manager_v1_interface,
333  }},
334  {Registry::Interface::AppMenu, {
335  1,
336  QByteArrayLiteral("org_kde_kwin_appmenu_manager"),
337  &org_kde_kwin_appmenu_manager_interface,
340  }},
342  1,
343  QByteArrayLiteral("org_kde_kwin_server_decoration_palette_manager"),
344  &org_kde_kwin_server_decoration_palette_manager_interface,
347  }},
348  {Registry::Interface::XdgOutputUnstableV1, {
349  2,
350  QByteArrayLiteral("zxdg_output_manager_v1"),
351  &zxdg_output_manager_v1_interface,
354  }},
356  1,
357  QByteArrayLiteral("xdg_wm_base"),
358  &xdg_wm_base_interface,
361  }},
363  1,
364  QByteArrayLiteral("zxdg_decoration_manager_v1"),
365  &zxdg_decoration_manager_v1_interface,
368  }},
370  1,
371  QByteArrayLiteral("org_kde_kwin_keystate"),
372  &org_kde_kwin_keystate_interface,
373  &Registry::keystateAnnounced,
374  &Registry::keystateRemoved
375  }}
376 };
377 
378 static quint32 maxVersion(const Registry::Interface &interface)
379 {
380  auto it = s_interfaces.find(interface);
381  if (it != s_interfaces.end()) {
382  return it.value().maxVersion;
383  }
384  return 0;
385 }
386 }
387 
388 class Q_DECL_HIDDEN Registry::Private
389 {
390 public:
391  Private(Registry *q);
392  void setup();
393  bool hasInterface(Interface interface) const;
394  AnnouncedInterface interface(Interface interface) const;
395  QVector<AnnouncedInterface> interfaces(Interface interface) const;
396  Interface interfaceForName(quint32 name) const;
397  template <typename T>
398  T *bind(Interface interface, uint32_t name, uint32_t version) const;
399  template <class T, typename WL>
400  T *create(quint32 name, quint32 version, QObject *parent, WL *(Registry::*bindMethod)(uint32_t, uint32_t) const);
401 
402  WaylandPointer<wl_registry, wl_registry_destroy> registry;
403  static const struct wl_callback_listener s_callbackListener;
404  WaylandPointer<wl_callback, wl_callback_destroy> callback;
405  EventQueue *queue = nullptr;
406 
407 private:
408  void handleAnnounce(uint32_t name, const char *interface, uint32_t version);
409  void handleRemove(uint32_t name);
410  void handleGlobalSync();
411  static void globalAnnounce(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version);
412  static void globalRemove(void *data, struct wl_registry *registry, uint32_t name);
413  static void globalSync(void *data, struct wl_callback *callback, uint32_t serial);
414 
415  Registry *q;
416  struct InterfaceData {
417  Interface interface;
418  uint32_t name;
419  uint32_t version;
420  };
421  QList<InterfaceData> m_interfaces;
422  static const struct wl_registry_listener s_registryListener;
423 };
424 
425 Registry::Private::Private(Registry *q)
426  : q(q)
427 {
428 }
429 
430 void Registry::Private::setup()
431 {
432  wl_registry_add_listener(registry, &s_registryListener, this);
433  wl_callback_add_listener(callback, &s_callbackListener, this);
434 }
435 
436 Registry::Registry(QObject *parent)
437  : QObject(parent)
438  , d(new Private(this))
439 {
440 }
441 
442 Registry::~Registry()
443 {
444  release();
445 }
446 
447 void Registry::release()
448 {
449  d->registry.release();
450  d->callback.release();
451 }
452 
453 void Registry::destroy()
454 {
455  emit registryDestroyed();
456  d->registry.destroy();
457  d->callback.destroy();
458 }
459 
460 void Registry::create(wl_display *display)
461 {
462  Q_ASSERT(display);
463  Q_ASSERT(!isValid());
464  d->registry.setup(wl_display_get_registry(display));
465  d->callback.setup(wl_display_sync(display));
466  if (d->queue) {
467  d->queue->addProxy(d->registry);
468  d->queue->addProxy(d->callback);
469  }
470 }
471 
472 void Registry::create(ConnectionThread *connection)
473 {
474  create(connection->display());
475  connect(connection, &ConnectionThread::connectionDied, this, &Registry::destroy);
476 }
477 
478 void Registry::setup()
479 {
480  Q_ASSERT(isValid());
481  d->setup();
482 }
483 
484 void Registry::setEventQueue(EventQueue *queue)
485 {
486  d->queue = queue;
487  if (!queue) {
488  return;
489  }
490  if (d->registry) {
491  d->queue->addProxy(d->registry);
492  }
493  if (d->callback) {
494  d->queue->addProxy(d->callback);
495  }
496 }
497 
498 EventQueue *Registry::eventQueue()
499 {
500  return d->queue;
501 }
502 
503 #ifndef K_DOXYGEN
504 const struct wl_registry_listener Registry::Private::s_registryListener = {
505  globalAnnounce,
506  globalRemove
507 };
508 
509 const struct wl_callback_listener Registry::Private::s_callbackListener = {
510  globalSync
511 };
512 #endif
513 
514 void Registry::Private::globalAnnounce(void *data, wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
515 {
516  auto r = reinterpret_cast<Registry::Private*>(data);
517  Q_ASSERT(registry == r->registry);
518  r->handleAnnounce(name, interface, version);
519 }
520 
521 void Registry::Private::globalRemove(void *data, wl_registry *registry, uint32_t name)
522 {
523  auto r = reinterpret_cast<Registry::Private*>(data);
524  Q_ASSERT(registry == r->registry);
525  r->handleRemove(name);
526 }
527 
528 void Registry::Private::globalSync(void* data, wl_callback* callback, uint32_t serial)
529 {
530  Q_UNUSED(serial)
531  auto r = reinterpret_cast<Registry::Private*>(data);
532  Q_ASSERT(r->callback == callback);
533  r->handleGlobalSync();
534  r->callback.release();
535 }
536 
537 void Registry::Private::handleGlobalSync()
538 {
539  emit q->interfacesAnnounced();
540 }
541 
542 namespace {
543 static Registry::Interface nameToInterface(const char *interface)
544 {
545  for (auto it = s_interfaces.constBegin(); it != s_interfaces.constEnd(); ++it) {
546  if (qstrcmp(interface, it.value().name) == 0) {
547  return it.key();
548  }
549  }
550  return Registry::Interface::Unknown;
551 }
552 }
553 
554 void Registry::Private::handleAnnounce(uint32_t name, const char *interface, uint32_t version)
555 {
556  Interface i = nameToInterface(interface);
557  emit q->interfaceAnnounced(QByteArray(interface), name, version);
558  if (i == Interface::Unknown) {
559  qCDebug(KWAYLAND_CLIENT) << "Unknown interface announced: " << interface << "/" << name << "/" << version;
560  return;
561  }
562  qCDebug(KWAYLAND_CLIENT) << "Wayland Interface: " << interface << "/" << name << "/" << version;
563  m_interfaces.append({i, name, version});
564  auto it = s_interfaces.constFind(i);
565  if (it != s_interfaces.end()) {
566  emit (q->*it.value().announcedSignal)(name, version);
567  }
568 }
569 
570 void Registry::Private::handleRemove(uint32_t name)
571 {
572  auto it = std::find_if(m_interfaces.begin(), m_interfaces.end(),
573  [name](const InterfaceData &data) {
574  return data.name == name;
575  }
576  );
577  if (it != m_interfaces.end()) {
578  InterfaceData data = *(it);
579  m_interfaces.erase(it);
580  auto sit = s_interfaces.find(data.interface);
581  if (sit != s_interfaces.end()) {
582  emit (q->*sit.value().removedSignal)(data.name);
583  }
584  }
585  emit q->interfaceRemoved(name);
586 }
587 
588 bool Registry::Private::hasInterface(Registry::Interface interface) const
589 {
590  auto it = std::find_if(m_interfaces.constBegin(), m_interfaces.constEnd(),
591  [interface](const InterfaceData &data) {
592  return data.interface == interface;
593  }
594  );
595  return it != m_interfaces.constEnd();
596 }
597 
598 QVector<Registry::AnnouncedInterface> Registry::Private::interfaces(Interface interface) const
599 {
601  for (auto it = m_interfaces.constBegin(); it != m_interfaces.constEnd(); ++it) {
602  const auto &data = *it;
603  if (data.interface == interface) {
604  retVal << AnnouncedInterface{data.name, data.version};
605  }
606  }
607  return retVal;
608 }
609 
610 Registry::AnnouncedInterface Registry::Private::interface(Interface interface) const
611 {
612  const auto all = interfaces(interface);
613  if (!all.isEmpty()) {
614  return all.last();
615  }
616  return AnnouncedInterface{0, 0};
617 }
618 
619 Registry::Interface Registry::Private::interfaceForName(quint32 name) const
620 {
621  auto it = std::find_if(m_interfaces.constBegin(), m_interfaces.constEnd(),
622  [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 #define BIND2(__NAME__, __INAME__, __WL__) \
647 __WL__ *Registry::bind##__NAME__(uint32_t name, uint32_t version) const \
648 { \
649  return d->bind<__WL__>(Interface::__INAME__, name, qMin(maxVersion(Interface::__INAME__), version)); \
650 }
651 
652 #define BIND(__NAME__, __WL__) BIND2(__NAME__, __NAME__, __WL__)
653 
654 BIND(Compositor, wl_compositor)
655 BIND(Output, wl_output)
656 BIND(Seat, wl_seat)
657 BIND(Shell, wl_shell)
658 BIND(Shm, wl_shm)
659 BIND(SubCompositor, wl_subcompositor)
660 BIND(FullscreenShell, _wl_fullscreen_shell)
661 BIND(DataDeviceManager, wl_data_device_manager)
662 BIND(PlasmaShell, org_kde_plasma_shell)
663 BIND(PlasmaVirtualDesktopManagement, org_kde_plasma_virtual_desktop_management)
664 BIND(PlasmaWindowManagement, org_kde_plasma_window_management)
665 BIND(Idle, org_kde_kwin_idle)
666 BIND(RemoteAccessManager, org_kde_kwin_remote_access_manager)
667 BIND(FakeInput, org_kde_kwin_fake_input)
668 BIND(OutputManagement, org_kde_kwin_outputmanagement)
669 BIND(OutputDevice, org_kde_kwin_outputdevice)
670 BIND(ServerSideDecorationManager, org_kde_kwin_server_decoration_manager)
671 BIND(TextInputManagerUnstableV0, wl_text_input_manager)
672 BIND(TextInputManagerUnstableV2, zwp_text_input_manager_v2)
673 BIND(XdgShellUnstableV5, xdg_shell)
674 BIND(XdgShellUnstableV6, zxdg_shell_v6)
675 BIND(XdgShellStable, xdg_wm_base)
676 BIND(RelativePointerManagerUnstableV1, zwp_relative_pointer_manager_v1)
677 BIND(PointerGesturesUnstableV1, zwp_pointer_gestures_v1)
678 BIND(PointerConstraintsUnstableV1, zwp_pointer_constraints_v1)
679 BIND(XdgExporterUnstableV2, zxdg_exporter_v2)
680 BIND(XdgImporterUnstableV2, zxdg_importer_v2)
681 BIND(IdleInhibitManagerUnstableV1, zwp_idle_inhibit_manager_v1)
682 BIND(Keystate, org_kde_kwin_keystate)
683 BIND2(ShadowManager, Shadow, org_kde_kwin_shadow_manager)
684 BIND2(BlurManager, Blur, org_kde_kwin_blur_manager)
685 BIND2(ContrastManager, Contrast, org_kde_kwin_contrast_manager)
686 BIND2(SlideManager, Slide, org_kde_kwin_slide_manager)
687 BIND2(DpmsManager, Dpms, org_kde_kwin_dpms_manager)
688 BIND2(AppMenuManager, AppMenu, org_kde_kwin_appmenu_manager)
689 BIND2(ServerSideDecorationPaletteManager, ServerSideDecorationPalette, org_kde_kwin_server_decoration_palette_manager)
690 BIND(XdgOutputUnstableV1, zxdg_output_manager_v1)
691 BIND(XdgDecorationUnstableV1, zxdg_decoration_manager_v1)
692 
693 #undef BIND
694 #undef BIND2
695 
696 template <class T, typename WL>
697 T *Registry::Private::create(quint32 name, quint32 version, QObject *parent, WL *(Registry::*bindMethod)(uint32_t, uint32_t) const)
698 {
699  T *t = new T(parent);
700  t->setEventQueue(queue);
701  t->setup((q->*bindMethod)(name, version));
702  QObject::connect(q, &Registry::interfaceRemoved, t,
703  [t, name] (quint32 removed) {
704  if (name == removed) {
705  emit t->removed();
706  }
707  }
708  );
709  QObject::connect(q, &Registry::registryDestroyed, t, &T::destroy);
710  return t;
711 }
712 
713 #define CREATE2(__NAME__, __BINDNAME__) \
714 __NAME__ *Registry::create##__NAME__(quint32 name, quint32 version, QObject *parent) \
715 { \
716  return d->create<__NAME__>(name, version, parent, &Registry::bind##__BINDNAME__); \
717 }
718 
719 #define CREATE(__NAME__) CREATE2(__NAME__, __NAME__)
720 
721 CREATE(Compositor)
722 CREATE(Seat)
723 CREATE(Shell)
724 CREATE(SubCompositor)
725 CREATE(FullscreenShell)
726 CREATE(Output)
727 CREATE(DataDeviceManager)
728 CREATE(PlasmaShell)
731 CREATE(Idle)
732 CREATE(RemoteAccessManager)
733 CREATE(FakeInput)
734 CREATE(OutputManagement)
735 CREATE(OutputDevice)
736 CREATE(ShadowManager)
737 CREATE(BlurManager)
738 CREATE(ContrastManager)
739 CREATE(SlideManager)
740 CREATE(DpmsManager)
742 CREATE2(ShmPool, Shm)
743 CREATE(AppMenuManager)
744 CREATE(Keystate)
746 
747 #undef CREATE
748 #undef CREATE2
749 
750 XdgExporter *Registry::createXdgExporter(quint32 name, quint32 version, QObject *parent)
751 {
752  //only V1 supported for now
753  return d->create<XdgExporterUnstableV2>(name, version, parent, &Registry::bindXdgExporterUnstableV2);
754 }
755 
756 XdgImporter *Registry::createXdgImporter(quint32 name, quint32 version, QObject *parent)
757 {
758  //only V1 supported for now
759  return d->create<XdgImporterUnstableV2>(name, version, parent, &Registry::bindXdgImporterUnstableV2);
760 }
761 
762 TextInputManager *Registry::createTextInputManager(quint32 name, quint32 version, QObject *parent)
763 {
764  switch (d->interfaceForName(name)) {
765  case Interface::TextInputManagerUnstableV0:
766  return d->create<TextInputManagerUnstableV0>(name, version, parent, &Registry::bindTextInputManagerUnstableV0);
767  case Interface::TextInputManagerUnstableV2:
768  return d->create<TextInputManagerUnstableV2>(name, version, parent, &Registry::bindTextInputManagerUnstableV2);
769  default:
770  return nullptr;
771  }
772 }
773 
774 XdgShell *Registry::createXdgShell(quint32 name, quint32 version, QObject *parent)
775 {
776  switch (d->interfaceForName(name)) {
777  case Interface::XdgShellUnstableV5:
778  return d->create<XdgShellUnstableV5>(name, version, parent, &Registry::bindXdgShellUnstableV5);
779  case Interface::XdgShellUnstableV6:
780  return d->create<XdgShellUnstableV6>(name, version, parent, &Registry::bindXdgShellUnstableV6);
781  case Interface::XdgShellStable:
782  return d->create<XdgShellStable>(name, version, parent, &Registry::bindXdgShellStable);
783  default:
784  return nullptr;
785  }
786 }
787 
788 RelativePointerManager *Registry::createRelativePointerManager(quint32 name, quint32 version, QObject *parent)
789 {
790  switch (d->interfaceForName(name)) {
791  case Interface::RelativePointerManagerUnstableV1:
792  return d->create<RelativePointerManager>(name, version, parent, &Registry::bindRelativePointerManagerUnstableV1);
793  default:
794  return nullptr;
795  }
796 }
797 
798 PointerGestures *Registry::createPointerGestures(quint32 name, quint32 version, QObject *parent)
799 {
800  switch (d->interfaceForName(name)) {
801  case Interface::PointerGesturesUnstableV1:
802  return d->create<PointerGestures>(name, version, parent, &Registry::bindPointerGesturesUnstableV1);
803  default:
804  return nullptr;
805  }
806 }
807 
808 PointerConstraints *Registry::createPointerConstraints(quint32 name, quint32 version, QObject *parent)
809 {
810  switch (d->interfaceForName(name)) {
811  case Interface::PointerConstraintsUnstableV1:
812  return d->create<PointerConstraints>(name, version, parent, &Registry::bindPointerConstraintsUnstableV1);
813  default:
814  return nullptr;
815  }
816 }
817 
818 IdleInhibitManager *Registry::createIdleInhibitManager(quint32 name, quint32 version, QObject *parent)
819 {
820  switch (d->interfaceForName(name)) {
821  case Interface::IdleInhibitManagerUnstableV1:
822  return d->create<IdleInhibitManager>(name, version, parent, &Registry::bindIdleInhibitManagerUnstableV1);
823  default:
824  return nullptr;
825  }
826 }
827 
828 XdgOutputManager *Registry::createXdgOutputManager(quint32 name, quint32 version, QObject *parent)
829 {
830  switch(d->interfaceForName(name)) {
831  case Interface::XdgOutputUnstableV1:
832  return d->create<XdgOutputManager>(name, version, parent, &Registry::bindXdgOutputUnstableV1);
833  default:
834  return nullptr;
835  }
836 }
837 
838 XdgDecorationManager *Registry::createXdgDecorationManager(quint32 name, quint32 version, QObject *parent)
839 {
840  switch(d->interfaceForName(name)) {
841  case Interface::XdgDecorationUnstableV1:
842  return d->create<XdgDecorationManager>(name, version, parent, &Registry::bindXdgDecorationUnstableV1);
843  default:
844  return nullptr;
845  }
846 }
847 
848 namespace {
849 static const wl_interface *wlInterface(Registry::Interface interface)
850 {
851  auto it = s_interfaces.find(interface);
852  if (it != s_interfaces.end()) {
853  return it.value().interface;
854  }
855  return nullptr;
856 }
857 }
858 
859 template <typename T>
860 T *Registry::Private::bind(Registry::Interface interface, uint32_t name, uint32_t version) const
861 {
862  auto it = std::find_if(m_interfaces.constBegin(), m_interfaces.constEnd(), [=](const InterfaceData &data) {
863  return data.interface == interface && data.name == name && data.version >= version;
864  });
865  if (it == m_interfaces.constEnd()) {
866  qCDebug(KWAYLAND_CLIENT) << "Don't have interface " << int(interface) << "with name " << name << "and minimum version" << version;
867  return nullptr;
868  }
869  auto t = reinterpret_cast<T*>(wl_registry_bind(registry, name, wlInterface(interface), version));
870  if (queue) {
871  queue->addProxy(t);
872  }
873  return t;
874 }
875 
876 bool Registry::isValid() const
877 {
878  return d->registry.isValid();
879 }
880 
881 wl_registry *Registry::registry()
882 {
883  return d->registry;
884 }
885 
886 Registry::operator wl_registry*() const
887 {
888  return d->registry;
889 }
890 
891 Registry::operator wl_registry*()
892 {
893  return d->registry;
894 }
895 
896 }
897 }
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:135
Wrapper for the zxdg_exporter_v2 interface.
Definition: xdgforeign.h:53
Wrapper for the zxdg_exporter_v2 interface.
Definition: xdgforeign_v2.h:54
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:128
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_plasma_virtual_desktop_management 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:154
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:116
Wrapper for the zxdg_importer_v2 interface.
Definition: xdgforeign_v2.h:94
Manager class for the TextInputManager interfaces.
Definition: textinput.h:417
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:55
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:50
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_server_decoration_palette_manager.
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:52
Wrapper for the org_kde_kwin_remote_access_manager interface.
Definition: remote_access.h:48
Refers to the wl_output interface.
Refers to the wl_data_device_manager interface.
Wrapper for the wl_output interface.
Definition: output.h:55
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:51
Refers to zxdg_shell_v6 (unstable version 6),.
Wrapper for the org_kde_kwin_shadow interface.
Definition: shadow.h:151
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:153
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:50
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:137
refers to zxdg_decoration_manager_v1,
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:55
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 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:49
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
This class is a factory for Dpms instances.
Definition: dpms.h:49
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:53
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:247
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 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:251
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:55
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 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:35
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:58
Wrapper for the wl_data_device_manager interface.
Wrapper for the zwp_idle_inhibit_manager_v1 interface.
Definition: idleinhibit.h:49
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.
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:131
Refers to the wl_seat interface.
Wrapper for the org_kde_kwin_shadow_manager interface.
Definition: shadow.h:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 22:48:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.