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

KDE's Doxygen guidelines are available online.