KWayland

fullscreen_shell.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #include "fullscreen_shell.h"
7 #include "surface.h"
8 #include "output.h"
9 #include "wayland_pointer_p.h"
10 
11 #include <QDebug>
12 // wayland
13 #include <wayland-fullscreen-shell-client-protocol.h>
14 #include <wayland-client-protocol.h>
15 
16 namespace KWayland
17 {
18 namespace Client
19 {
20 
21 class Q_DECL_HIDDEN FullscreenShell::Private
22 {
23 public:
24  Private(FullscreenShell *q);
25  void setup(_wl_fullscreen_shell *shell);
26 
27  WaylandPointer<_wl_fullscreen_shell, _wl_fullscreen_shell_release> shell;
28  EventQueue *queue = nullptr;
29  bool capabilityArbitraryModes = false;
30  bool capabilityCursorPlane = false;
31 
32 private:
33  void handleCapabilities(uint32_t capability);
34  static void capabilitiesAnnounce(void *data, struct _wl_fullscreen_shell *shell, uint32_t capability);
35  static _wl_fullscreen_shell_listener s_fullscreenShellListener;
36  FullscreenShell *q;
37 };
38 
39 _wl_fullscreen_shell_listener FullscreenShell::Private::s_fullscreenShellListener = {
40  FullscreenShell::Private::capabilitiesAnnounce
41 };
42 
43 FullscreenShell::Private::Private(FullscreenShell *q)
44  : q(q)
45 {
46 }
47 
48 void FullscreenShell::Private::setup(_wl_fullscreen_shell *s)
49 {
50  Q_ASSERT(!shell);
51  Q_ASSERT(s);
52  shell.setup(s);
53  _wl_fullscreen_shell_add_listener(shell, &s_fullscreenShellListener, this);
54 }
55 
56 void FullscreenShell::Private::capabilitiesAnnounce(void *data, _wl_fullscreen_shell *shell, uint32_t capability)
57 {
58  auto s = reinterpret_cast<FullscreenShell::Private*>(data);
59  Q_ASSERT(shell == s->shell);
60  s->handleCapabilities(capability);
61 }
62 
63 void FullscreenShell::Private::handleCapabilities(uint32_t capability)
64 {
65  if (capability & _WL_FULLSCREEN_SHELL_CAPABILITY_ARBITRARY_MODES) {
66  capabilityArbitraryModes = true;
67  emit q->capabilityArbitraryModesChanged(capabilityArbitraryModes);
68  }
69  if (capability & _WL_FULLSCREEN_SHELL_CAPABILITY_CURSOR_PLANE) {
70  capabilityCursorPlane = true;
71  emit q->capabilityCursorPlaneChanged(capabilityCursorPlane);
72  }
73 }
74 
75 FullscreenShell::FullscreenShell(QObject *parent)
76  : QObject(parent)
77  , d(new Private(this))
78 {
79 }
80 
81 FullscreenShell::~FullscreenShell()
82 {
83  release();
84 }
85 
86 void FullscreenShell::release()
87 {
88  d->shell.release();
89 }
90 
91 void FullscreenShell::destroy()
92 {
93  d->shell.destroy();
94 }
95 
96 void FullscreenShell::setup(_wl_fullscreen_shell *shell)
97 {
98  d->setup(shell);
99 }
100 
101 EventQueue *FullscreenShell::eventQueue() const
102 {
103  return d->queue;
104 }
105 
106 void FullscreenShell::setEventQueue(EventQueue *queue)
107 {
108  d->queue = queue;
109 }
110 
111 void FullscreenShell::present(wl_surface *surface, wl_output *output)
112 {
113  Q_ASSERT(d->shell);
114  _wl_fullscreen_shell_present_surface(d->shell, surface, _WL_FULLSCREEN_SHELL_PRESENT_METHOD_DEFAULT, output);
115 }
116 
117 void FullscreenShell::present(Surface *surface, Output *output)
118 {
119  Q_ASSERT(surface);
120  Q_ASSERT(output);
121  present(*surface, *output);
122 }
123 
124 bool FullscreenShell::isValid() const
125 {
126  return d->shell.isValid();
127 }
128 
129 bool FullscreenShell::hasCapabilityArbitraryModes() const
130 {
131  return d->capabilityArbitraryModes;
132 }
133 
134 bool FullscreenShell::hasCapabilityCursorPlane() const
135 {
136  return d->capabilityCursorPlane;
137 }
138 
139 }
140 }
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:55
Wrapper for the wl_output interface.
Definition: output.h:55
Wrapper for the wl_surface interface.
Definition: surface.h:44
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Jul 5 2020 22:50:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.