File indexing completed on 2024-12-22 05:09:24

0001 /*
0002     SPDX-FileCopyrightText: 2015 Marco Martin <notmart@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 #include "slide.h"
0007 #include "event_queue.h"
0008 #include "surface.h"
0009 #include "wayland_pointer_p.h"
0010 
0011 #include <wayland-slide-client-protocol.h>
0012 
0013 namespace KWayland
0014 {
0015 namespace Client
0016 {
0017 class Q_DECL_HIDDEN SlideManager::Private
0018 {
0019 public:
0020     Private() = default;
0021 
0022     WaylandPointer<org_kde_kwin_slide_manager, org_kde_kwin_slide_manager_destroy> slidemanager;
0023     EventQueue *queue = nullptr;
0024 };
0025 
0026 SlideManager::SlideManager(QObject *parent)
0027     : QObject(parent)
0028     , d(new Private)
0029 {
0030 }
0031 
0032 SlideManager::~SlideManager()
0033 {
0034     release();
0035 }
0036 
0037 void SlideManager::setup(org_kde_kwin_slide_manager *slidemanager)
0038 {
0039     Q_ASSERT(slidemanager);
0040     Q_ASSERT(!d->slidemanager);
0041     d->slidemanager.setup(slidemanager);
0042 }
0043 
0044 void SlideManager::release()
0045 {
0046     d->slidemanager.release();
0047 }
0048 
0049 void SlideManager::destroy()
0050 {
0051     d->slidemanager.destroy();
0052 }
0053 
0054 void SlideManager::setEventQueue(EventQueue *queue)
0055 {
0056     d->queue = queue;
0057 }
0058 
0059 EventQueue *SlideManager::eventQueue()
0060 {
0061     return d->queue;
0062 }
0063 
0064 SlideManager::operator org_kde_kwin_slide_manager *()
0065 {
0066     return d->slidemanager;
0067 }
0068 
0069 SlideManager::operator org_kde_kwin_slide_manager *() const
0070 {
0071     return d->slidemanager;
0072 }
0073 
0074 bool SlideManager::isValid() const
0075 {
0076     return d->slidemanager.isValid();
0077 }
0078 
0079 Slide *SlideManager::createSlide(Surface *surface, QObject *parent)
0080 {
0081     Q_ASSERT(isValid());
0082     Slide *s = new Slide(parent);
0083     auto w = org_kde_kwin_slide_manager_create(d->slidemanager, *surface);
0084     if (d->queue) {
0085         d->queue->addProxy(w);
0086     }
0087     s->setup(w);
0088     return s;
0089 }
0090 
0091 void SlideManager::removeSlide(Surface *surface)
0092 {
0093     org_kde_kwin_slide_manager_unset(d->slidemanager, *surface);
0094 }
0095 
0096 class Slide::Private
0097 {
0098 public:
0099     Private() = default;
0100 
0101     WaylandPointer<org_kde_kwin_slide, org_kde_kwin_slide_release> slide;
0102 };
0103 
0104 Slide::Slide(QObject *parent)
0105     : QObject(parent)
0106     , d(new Private)
0107 {
0108 }
0109 
0110 Slide::~Slide()
0111 {
0112     release();
0113 }
0114 
0115 void Slide::setup(org_kde_kwin_slide *slide)
0116 {
0117     Q_ASSERT(slide);
0118     Q_ASSERT(!d->slide);
0119     d->slide.setup(slide);
0120 }
0121 
0122 void Slide::release()
0123 {
0124     d->slide.release();
0125 }
0126 
0127 void Slide::destroy()
0128 {
0129     d->slide.destroy();
0130 }
0131 
0132 Slide::operator org_kde_kwin_slide *()
0133 {
0134     return d->slide;
0135 }
0136 
0137 Slide::operator org_kde_kwin_slide *() const
0138 {
0139     return d->slide;
0140 }
0141 
0142 bool Slide::isValid() const
0143 {
0144     return d->slide.isValid();
0145 }
0146 
0147 void Slide::commit()
0148 {
0149     Q_ASSERT(isValid());
0150     org_kde_kwin_slide_commit(d->slide);
0151 }
0152 
0153 void Slide::setLocation(Slide::Location location)
0154 {
0155     org_kde_kwin_slide_set_location(d->slide, location);
0156 }
0157 
0158 void Slide::setOffset(qint32 offset)
0159 {
0160     org_kde_kwin_slide_set_offset(d->slide, offset);
0161 }
0162 
0163 }
0164 }
0165 
0166 #include "moc_slide.cpp"