KWayland

appmenu.cpp
1 /*
2  SPDX-FileCopyrightText: 2017 David Edmundson <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #include "appmenu.h"
7 #include "event_queue.h"
8 #include "surface.h"
9 #include "wayland_pointer_p.h"
10 
11 #include <wayland-appmenu-client-protocol.h>
12 
13 namespace KWayland
14 {
15 namespace Client
16 {
17 
18 class AppMenuManager::Private
19 {
20 public:
21  Private() = default;
22 
23  void setup(org_kde_kwin_appmenu_manager *arg);
24 
25  WaylandPointer<org_kde_kwin_appmenu_manager, org_kde_kwin_appmenu_manager_destroy> appmenumanager;
26  EventQueue *queue = nullptr;
27 };
28 
30  : QObject(parent)
31  , d(new Private)
32 {
33 }
34 
35 void AppMenuManager::Private::setup(org_kde_kwin_appmenu_manager *arg)
36 {
37  Q_ASSERT(arg);
38  Q_ASSERT(!appmenumanager);
39  appmenumanager.setup(arg);
40 }
41 
42 AppMenuManager::~AppMenuManager()
43 {
44  release();
45 }
46 
47 void AppMenuManager::setup(org_kde_kwin_appmenu_manager *appmenumanager)
48 {
49  d->setup(appmenumanager);
50 }
51 
53 {
54  d->appmenumanager.release();
55 }
56 
58 {
59  d->appmenumanager.destroy();
60 }
61 
62 AppMenuManager::operator org_kde_kwin_appmenu_manager*() {
63  return d->appmenumanager;
64 }
65 
66 AppMenuManager::operator org_kde_kwin_appmenu_manager*() const {
67  return d->appmenumanager;
68 }
69 
71 {
72  return d->appmenumanager.isValid();
73 }
74 
76 {
77  d->queue = queue;
78 }
79 
81 {
82  return d->queue;
83 }
84 
85 AppMenu *AppMenuManager::create(Surface *surface, QObject *parent)
86 {
87  Q_ASSERT(isValid());
88  auto p = new AppMenu(parent);
89  auto w = org_kde_kwin_appmenu_manager_create(d->appmenumanager, *surface);
90  if (d->queue) {
91  d->queue->addProxy(w);
92  }
93  p->setup(w);
94  return p;
95 }
96 
97 class AppMenu::Private
98 {
99 public:
100  void setup(org_kde_kwin_appmenu *arg);
101 
102  WaylandPointer<org_kde_kwin_appmenu, org_kde_kwin_appmenu_release> appmenu;
103 };
104 
105 AppMenu::AppMenu(QObject *parent)
106  : QObject(parent)
107  , d(new Private)
108 {
109 }
110 
111 void AppMenu::Private::setup(org_kde_kwin_appmenu *arg)
112 {
113  Q_ASSERT(arg);
114  Q_ASSERT(!appmenu);
115  appmenu.setup(arg);
116 }
117 
118 AppMenu::~AppMenu()
119 {
120  release();
121 }
122 
123 void AppMenu::setup(org_kde_kwin_appmenu *appmenu)
124 {
125  d->setup(appmenu);
126 }
127 
129 {
130  d->appmenu.release();
131 }
132 
134 {
135  d->appmenu.destroy();
136 }
137 
138 AppMenu::operator org_kde_kwin_appmenu*() {
139  return d->appmenu;
140 }
141 
142 AppMenu::operator org_kde_kwin_appmenu*() const {
143  return d->appmenu;
144 }
145 
146 bool AppMenu::isValid() const
147 {
148  return d->appmenu.isValid();
149 }
150 
151 void AppMenu::setAddress(const QString &serviceName, const QString &objectPath)
152 {
153  Q_ASSERT(isValid());
154  org_kde_kwin_appmenu_set_address(d->appmenu, serviceName.toLatin1(), objectPath.toLatin1());
155 }
156 
157 
158 }
159 }
160 
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:55
void release()
Releases the org_kde_kwin_appmenu_manager interface.
Definition: appmenu.cpp:52
Wrapper for the wl_surface interface.
Definition: surface.h:44
void setup(org_kde_kwin_appmenu *appmenu)
Setup this Appmenu to manage the appmenu.
Definition: appmenu.cpp:123
QObject(QObject *parent)
QByteArray toLatin1() const const
void setup(org_kde_kwin_appmenu_manager *appmenumanager)
Setup this AppMenuManager to manage the appmenumanager.
Definition: appmenu.cpp:47
void setEventQueue(EventQueue *queue)
Sets the queue to use for creating objects with this AppMenuManager.
Definition: appmenu.cpp:75
bool isValid() const
Definition: appmenu.cpp:146
void destroy()
Destroys the data held by this AppMenuManager.
Definition: appmenu.cpp:57
AppMenuManager(QObject *parent=nullptr)
Creates a new AppMenuManager.
Definition: appmenu.cpp:29
QObject * parent() const const
void destroy()
Destroys the data held by this Appmenu.
Definition: appmenu.cpp:133
void setAddress(const QString &serviceName, const QString &objectPath)
Sets the appmenu address.
Definition: appmenu.cpp:151
void release()
Releases the org_kde_kwin_appmenu interface.
Definition: appmenu.cpp:128
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 13 2020 22:50:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.