Changeset View
Changeset View
Standalone View
Standalone View
src/client/registry.cpp
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | Copyright 2014 Martin Gräßlin <mgraesslin@kde.org> | 2 | Copyright 2014 Martin Gräßlin <mgraesslin@kde.org> | ||
3 | Copyright 2018 David Edmundson <davidedmundson@kde.org> | ||||
3 | 4 | | |||
4 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either | ||
7 | version 2.1 of the License, or (at your option) version 3, or any | 8 | version 2.1 of the License, or (at your option) version 3, or any | ||
8 | later version accepted by the membership of KDE e.V. (or its | 9 | later version accepted by the membership of KDE e.V. (or its | ||
9 | successor approved by the membership of KDE e.V.), which shall | 10 | successor approved by the membership of KDE e.V.), which shall | ||
10 | act as a proxy defined in Section 6 of version 3 of the license. | 11 | act as a proxy defined in Section 6 of version 3 of the license. | ||
Show All 40 Lines | |||||
51 | #include "textinput_p.h" | 52 | #include "textinput_p.h" | ||
52 | #include "xdgshell.h" | 53 | #include "xdgshell.h" | ||
53 | #include "xdgshell_p.h" | 54 | #include "xdgshell_p.h" | ||
54 | #include "wayland_pointer_p.h" | 55 | #include "wayland_pointer_p.h" | ||
55 | #include "xdgforeign_v2.h" | 56 | #include "xdgforeign_v2.h" | ||
56 | #include "appmenu.h" | 57 | #include "appmenu.h" | ||
57 | #include "server_decoration_palette.h" | 58 | #include "server_decoration_palette.h" | ||
58 | #include "xdgoutput.h" | 59 | #include "xdgoutput.h" | ||
60 | #include "xdgdecoration.h" | ||||
59 | // Qt | 61 | // Qt | ||
60 | #include <QDebug> | 62 | #include <QDebug> | ||
61 | // wayland | 63 | // wayland | ||
62 | #include <wayland-client-protocol.h> | 64 | #include <wayland-client-protocol.h> | ||
63 | #include <wayland-fullscreen-shell-client-protocol.h> | 65 | #include <wayland-fullscreen-shell-client-protocol.h> | ||
64 | #include <wayland-plasma-shell-client-protocol.h> | 66 | #include <wayland-plasma-shell-client-protocol.h> | ||
65 | #include <wayland-plasma-virtual-desktop-client-protocol.h> | 67 | #include <wayland-plasma-virtual-desktop-client-protocol.h> | ||
66 | #include <wayland-plasma-window-management-client-protocol.h> | 68 | #include <wayland-plasma-window-management-client-protocol.h> | ||
Show All 16 Lines | |||||
83 | #include <wayland-xdg-shell-client-protocol.h> | 85 | #include <wayland-xdg-shell-client-protocol.h> | ||
84 | #include <wayland-relativepointer-unstable-v1-client-protocol.h> | 86 | #include <wayland-relativepointer-unstable-v1-client-protocol.h> | ||
85 | #include <wayland-pointer-gestures-unstable-v1-client-protocol.h> | 87 | #include <wayland-pointer-gestures-unstable-v1-client-protocol.h> | ||
86 | #include <wayland-pointer-constraints-unstable-v1-client-protocol.h> | 88 | #include <wayland-pointer-constraints-unstable-v1-client-protocol.h> | ||
87 | #include <wayland-xdg-foreign-unstable-v2-client-protocol.h> | 89 | #include <wayland-xdg-foreign-unstable-v2-client-protocol.h> | ||
88 | #include <wayland-appmenu-client-protocol.h> | 90 | #include <wayland-appmenu-client-protocol.h> | ||
89 | #include <wayland-server-decoration-palette-client-protocol.h> | 91 | #include <wayland-server-decoration-palette-client-protocol.h> | ||
90 | #include <wayland-xdg-output-unstable-v1-client-protocol.h> | 92 | #include <wayland-xdg-output-unstable-v1-client-protocol.h> | ||
93 | #include <wayland-xdg-decoration-unstable-v1-client-protocol.h> | ||||
91 | 94 | | |||
92 | /***** | 95 | /***** | ||
93 | * How to add another interface: | 96 | * How to add another interface: | ||
94 | * * define a new enum value in Registry::Interface | 97 | * * define a new enum value in Registry::Interface | ||
95 | * * define the bind<InterfaceName> method | 98 | * * define the bind<InterfaceName> method | ||
96 | * * define the create<InterfaceName> method | 99 | * * define the create<InterfaceName> method | ||
97 | * * define the <interfaceName>Announced signal | 100 | * * define the <interfaceName>Announced signal | ||
98 | * * define the <interfaceName>Removed signal | 101 | * * define the <interfaceName>Removed signal | ||
▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Line(s) | 360 | {Registry::Interface::XdgOutputUnstableV1, { | |||
362 | &Registry::xdgOutputRemoved | 365 | &Registry::xdgOutputRemoved | ||
363 | }}, | 366 | }}, | ||
364 | {Registry::Interface::XdgShellStable, { | 367 | {Registry::Interface::XdgShellStable, { | ||
365 | 1, | 368 | 1, | ||
366 | QByteArrayLiteral("xdg_wm_base"), | 369 | QByteArrayLiteral("xdg_wm_base"), | ||
367 | &xdg_wm_base_interface, | 370 | &xdg_wm_base_interface, | ||
368 | &Registry::xdgShellStableAnnounced, | 371 | &Registry::xdgShellStableAnnounced, | ||
369 | &Registry::xdgShellStableRemoved | 372 | &Registry::xdgShellStableRemoved | ||
373 | }}, | ||||
374 | {Registry::Interface::XdgDecorationUnstableV1, { | ||||
375 | 1, | ||||
376 | QByteArrayLiteral("zxdg_decoration_manager_v1"), | ||||
377 | &zxdg_decoration_manager_v1_interface, | ||||
378 | &Registry::xdgDecorationAnnounced, | ||||
379 | &Registry::xdgDecorationRemoved | ||||
370 | }} | 380 | }} | ||
371 | }; | 381 | }; | ||
372 | 382 | | |||
373 | static quint32 maxVersion(const Registry::Interface &interface) | 383 | static quint32 maxVersion(const Registry::Interface &interface) | ||
374 | { | 384 | { | ||
375 | auto it = s_interfaces.find(interface); | 385 | auto it = s_interfaces.find(interface); | ||
376 | if (it != s_interfaces.end()) { | 386 | if (it != s_interfaces.end()) { | ||
377 | return it.value().maxVersion; | 387 | return it.value().maxVersion; | ||
▲ Show 20 Lines • Show All 299 Lines • ▼ Show 20 Line(s) | |||||
677 | BIND2(ShadowManager, Shadow, org_kde_kwin_shadow_manager) | 687 | BIND2(ShadowManager, Shadow, org_kde_kwin_shadow_manager) | ||
678 | BIND2(BlurManager, Blur, org_kde_kwin_blur_manager) | 688 | BIND2(BlurManager, Blur, org_kde_kwin_blur_manager) | ||
679 | BIND2(ContrastManager, Contrast, org_kde_kwin_contrast_manager) | 689 | BIND2(ContrastManager, Contrast, org_kde_kwin_contrast_manager) | ||
680 | BIND2(SlideManager, Slide, org_kde_kwin_slide_manager) | 690 | BIND2(SlideManager, Slide, org_kde_kwin_slide_manager) | ||
681 | BIND2(DpmsManager, Dpms, org_kde_kwin_dpms_manager) | 691 | BIND2(DpmsManager, Dpms, org_kde_kwin_dpms_manager) | ||
682 | BIND2(AppMenuManager, AppMenu, org_kde_kwin_appmenu_manager) | 692 | BIND2(AppMenuManager, AppMenu, org_kde_kwin_appmenu_manager) | ||
683 | BIND2(ServerSideDecorationPaletteManager, ServerSideDecorationPalette, org_kde_kwin_server_decoration_palette_manager) | 693 | BIND2(ServerSideDecorationPaletteManager, ServerSideDecorationPalette, org_kde_kwin_server_decoration_palette_manager) | ||
684 | BIND(XdgOutputUnstableV1, zxdg_output_manager_v1) | 694 | BIND(XdgOutputUnstableV1, zxdg_output_manager_v1) | ||
695 | BIND(XdgDecorationUnstableV1, zxdg_decoration_manager_v1) | ||||
685 | 696 | | |||
686 | #undef BIND | 697 | #undef BIND | ||
687 | #undef BIND2 | 698 | #undef BIND2 | ||
688 | 699 | | |||
689 | template <class T, typename WL> | 700 | template <class T, typename WL> | ||
690 | T *Registry::Private::create(quint32 name, quint32 version, QObject *parent, WL *(Registry::*bindMethod)(uint32_t, uint32_t) const) | 701 | T *Registry::Private::create(quint32 name, quint32 version, QObject *parent, WL *(Registry::*bindMethod)(uint32_t, uint32_t) const) | ||
691 | { | 702 | { | ||
692 | T *t = new T(parent); | 703 | T *t = new T(parent); | ||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 832 | { | |||
822 | switch(d->interfaceForName(name)) { | 833 | switch(d->interfaceForName(name)) { | ||
823 | case Interface::XdgOutputUnstableV1: | 834 | case Interface::XdgOutputUnstableV1: | ||
824 | return d->create<XdgOutputManager>(name, version, parent, &Registry::bindXdgOutputUnstableV1); | 835 | return d->create<XdgOutputManager>(name, version, parent, &Registry::bindXdgOutputUnstableV1); | ||
825 | default: | 836 | default: | ||
826 | return nullptr; | 837 | return nullptr; | ||
827 | } | 838 | } | ||
828 | } | 839 | } | ||
829 | 840 | | |||
841 | XdgDecorationManager *Registry::createXdgDecorationManager(quint32 name, quint32 version, QObject *parent) | ||||
842 | { | ||||
843 | switch(d->interfaceForName(name)) { | ||||
844 | case Interface::XdgDecorationUnstableV1: | ||||
845 | return d->create<XdgDecorationManager>(name, version, parent, &Registry::bindXdgDecorationUnstableV1); | ||||
846 | default: | ||||
847 | return nullptr; | ||||
848 | } | ||||
849 | } | ||||
850 | | ||||
830 | namespace { | 851 | namespace { | ||
831 | static const wl_interface *wlInterface(Registry::Interface interface) | 852 | static const wl_interface *wlInterface(Registry::Interface interface) | ||
832 | { | 853 | { | ||
833 | auto it = s_interfaces.find(interface); | 854 | auto it = s_interfaces.find(interface); | ||
834 | if (it != s_interfaces.end()) { | 855 | if (it != s_interfaces.end()) { | ||
835 | return it.value().interface; | 856 | return it.value().interface; | ||
836 | } | 857 | } | ||
837 | return nullptr; | 858 | return nullptr; | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |