KWayland

server_decoration_palette.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 "server_decoration_palette.h"
7 #include "event_queue.h"
8 #include "surface.h"
9 #include "wayland_pointer_p.h"
10 
11 #include <wayland-server-decoration-palette-client-protocol.h>
12 
13 #include <QDebug>
14 
15 namespace KWayland
16 {
17 namespace Client
18 {
19 class ServerSideDecorationPaletteManager::Private
20 {
21 public:
22  Private() = default;
23 
24  void setup(org_kde_kwin_server_decoration_palette_manager *arg);
25 
26  WaylandPointer<org_kde_kwin_server_decoration_palette_manager, org_kde_kwin_server_decoration_palette_manager_destroy> serverdecomanager;
27  EventQueue *queue = nullptr;
28 };
29 
31  : QObject(parent)
32  , d(new Private)
33 {
34 }
35 
36 void ServerSideDecorationPaletteManager::Private::setup(org_kde_kwin_server_decoration_palette_manager *arg)
37 {
38  Q_ASSERT(arg);
39  Q_ASSERT(!serverdecomanager);
40  serverdecomanager.setup(arg);
41 }
42 
43 ServerSideDecorationPaletteManager::~ServerSideDecorationPaletteManager()
44 {
45  release();
46 }
47 
48 void ServerSideDecorationPaletteManager::setup(org_kde_kwin_server_decoration_palette_manager *serverdecomanager)
49 {
50  d->setup(serverdecomanager);
51 }
52 
54 {
55  d->serverdecomanager.release();
56 }
57 
59 {
60  d->serverdecomanager.destroy();
61 }
62 
63 ServerSideDecorationPaletteManager::operator org_kde_kwin_server_decoration_palette_manager *()
64 {
65  return d->serverdecomanager;
66 }
67 
68 ServerSideDecorationPaletteManager::operator org_kde_kwin_server_decoration_palette_manager *() const
69 {
70  return d->serverdecomanager;
71 }
72 
74 {
75  return d->serverdecomanager.isValid();
76 }
77 
79 {
80  d->queue = queue;
81 }
82 
84 {
85  return d->queue;
86 }
87 
88 ServerSideDecorationPalette *ServerSideDecorationPaletteManager::create(Surface *surface, QObject *parent)
89 {
90  Q_ASSERT(isValid());
91  auto p = new ServerSideDecorationPalette(parent);
92  auto w = org_kde_kwin_server_decoration_palette_manager_create(d->serverdecomanager, *surface);
93  if (d->queue) {
94  d->queue->addProxy(w);
95  }
96  p->setup(w);
97 
98  return p;
99 }
100 
101 class ServerSideDecorationPalette::Private
102 {
103 public:
104  void setup(org_kde_kwin_server_decoration_palette *arg);
105 
106  WaylandPointer<org_kde_kwin_server_decoration_palette, org_kde_kwin_server_decoration_palette_release> decoration_palette;
107 };
108 
109 ServerSideDecorationPalette::ServerSideDecorationPalette(QObject *parent)
110  : QObject(parent)
111  , d(new Private)
112 {
113 }
114 
115 void ServerSideDecorationPalette::Private::setup(org_kde_kwin_server_decoration_palette *arg)
116 {
117  Q_ASSERT(arg);
118  Q_ASSERT(!decoration_palette);
119  decoration_palette.setup(arg);
120 }
121 
122 ServerSideDecorationPalette::~ServerSideDecorationPalette()
123 {
124  release();
125 }
126 
127 void ServerSideDecorationPalette::setup(org_kde_kwin_server_decoration_palette *decoration_palette)
128 {
129  d->setup(decoration_palette);
130 }
131 
133 {
134  d->decoration_palette.release();
135 }
136 
137 void ServerSideDecorationPalette::destroy()
138 {
139  d->decoration_palette.destroy();
140 }
141 
142 ServerSideDecorationPalette::operator org_kde_kwin_server_decoration_palette *()
143 {
144  return d->decoration_palette;
145 }
146 
147 ServerSideDecorationPalette::operator org_kde_kwin_server_decoration_palette *() const
148 {
149  return d->decoration_palette;
150 }
151 
152 bool ServerSideDecorationPalette::isValid() const
153 {
154  return d->decoration_palette.isValid();
155 }
156 
157 void ServerSideDecorationPalette::setPalette(const QString &palette)
158 {
159  Q_ASSERT(isValid());
160  org_kde_kwin_server_decoration_palette_set_palette(*this, palette.toUtf8());
161 }
162 }
163 }
void setup(org_kde_kwin_server_decoration_palette_manager *serverSideDecorationPaletteManager)
Setup this ServerSideDecorationPaletteManager to manage the serverSideDecorationPaletteManager.
void destroy()
Destroys the data held by this ServerSideDecorationPaletteManager.
ServerSideDecorationPaletteManager(QObject *parent=nullptr)
Creates a new ServerSideDecorationPaletteManager.
void setEventQueue(EventQueue *queue)
Sets the queue to use for creating objects with this ServerSideDecorationPaletteManager.
virtual void release(quint64 objid)
Wrapper for the wl_surface interface.
Definition: surface.h:43
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
QByteArray toUtf8() const const
void release()
Releases the org_kde_kwin_server_decoration_palette_manager interface.
bool isValid(QStringView ifopt)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Jan 30 2023 03:56:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.