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

KDE's Doxygen guidelines are available online.