KWayland

slide.cpp
1 /*
2  SPDX-FileCopyrightText: 2015 Marco Martin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #include "slide.h"
7 #include "event_queue.h"
8 #include "surface.h"
9 #include "wayland_pointer_p.h"
10 
11 #include <wayland-slide-client-protocol.h>
12 
13 namespace KWayland
14 {
15 namespace Client
16 {
17 class Q_DECL_HIDDEN SlideManager::Private
18 {
19 public:
20  Private() = default;
21 
22  WaylandPointer<org_kde_kwin_slide_manager, org_kde_kwin_slide_manager_destroy> slidemanager;
23  EventQueue *queue = nullptr;
24 };
25 
27  : QObject(parent)
28  , d(new Private)
29 {
30 }
31 
32 SlideManager::~SlideManager()
33 {
34  release();
35 }
36 
37 void SlideManager::setup(org_kde_kwin_slide_manager *slidemanager)
38 {
39  Q_ASSERT(slidemanager);
40  Q_ASSERT(!d->slidemanager);
41  d->slidemanager.setup(slidemanager);
42 }
43 
45 {
46  d->slidemanager.release();
47 }
48 
50 {
51  d->slidemanager.destroy();
52 }
53 
55 {
56  d->queue = queue;
57 }
58 
60 {
61  return d->queue;
62 }
63 
64 SlideManager::operator org_kde_kwin_slide_manager *()
65 {
66  return d->slidemanager;
67 }
68 
69 SlideManager::operator org_kde_kwin_slide_manager *() const
70 {
71  return d->slidemanager;
72 }
73 
75 {
76  return d->slidemanager.isValid();
77 }
78 
79 Slide *SlideManager::createSlide(Surface *surface, QObject *parent)
80 {
81  Q_ASSERT(isValid());
82  Slide *s = new Slide(parent);
83  auto w = org_kde_kwin_slide_manager_create(d->slidemanager, *surface);
84  if (d->queue) {
85  d->queue->addProxy(w);
86  }
87  s->setup(w);
88  return s;
89 }
90 
91 void SlideManager::removeSlide(Surface *surface)
92 {
93  org_kde_kwin_slide_manager_unset(d->slidemanager, *surface);
94 }
95 
96 class Slide::Private
97 {
98 public:
99  Private() = default;
100 
101  WaylandPointer<org_kde_kwin_slide, org_kde_kwin_slide_release> slide;
102 };
103 
104 Slide::Slide(QObject *parent)
105  : QObject(parent)
106  , d(new Private)
107 {
108 }
109 
110 Slide::~Slide()
111 {
112  release();
113 }
114 
115 void Slide::setup(org_kde_kwin_slide *slide)
116 {
117  Q_ASSERT(slide);
118  Q_ASSERT(!d->slide);
119  d->slide.setup(slide);
120 }
121 
123 {
124  d->slide.release();
125 }
126 
128 {
129  d->slide.destroy();
130 }
131 
132 Slide::operator org_kde_kwin_slide *()
133 {
134  return d->slide;
135 }
136 
137 Slide::operator org_kde_kwin_slide *() const
138 {
139  return d->slide;
140 }
141 
142 bool Slide::isValid() const
143 {
144  return d->slide.isValid();
145 }
146 
147 void Slide::commit()
148 {
149  Q_ASSERT(isValid());
150  org_kde_kwin_slide_commit(d->slide);
151 }
152 
154 {
155  org_kde_kwin_slide_set_location(d->slide, location);
156 }
157 
158 void Slide::setOffset(qint32 offset)
159 {
160  org_kde_kwin_slide_set_offset(d->slide, offset);
161 }
162 
163 }
164 }
SlideManager(QObject *parent=nullptr)
Creates a new SlideManager.
Definition: slide.cpp:26
void destroy()
Destroys the data held by this SlideManager.
Definition: slide.cpp:49
Wrapper for the wl_surface interface.
Definition: surface.h:43
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
bool isValid() const
Definition: slide.cpp:142
void setLocation(Slide::Location location)
Set the location of the screen to slide the window from.
Definition: slide.cpp:153
void release()
Releases the org_kde_kwin_slide interface.
Definition: slide.cpp:122
void destroy()
Destroys the data held by this Slide.
Definition: slide.cpp:127
void setOffset(qint32 offset)
Set the offset from the screen edge to make the window slide from.
Definition: slide.cpp:158
void setup(org_kde_kwin_slide_manager *slidemanager)
Setup this SlideManager to manage the slidemanager.
Definition: slide.cpp:37
EventQueue * eventQueue()
Definition: slide.cpp:59
void setup(org_kde_kwin_slide *slide)
Setup this Slide to manage the slide.
Definition: slide.cpp:115
QObject * parent() const const
void setEventQueue(EventQueue *queue)
Sets the queue to use for creating objects with this SlideManager.
Definition: slide.cpp:54
void release()
Releases the org_kde_kwin_slide_manager interface.
Definition: slide.cpp:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 03:56:22 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.