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

KDE's Doxygen guidelines are available online.