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

KDE's Doxygen guidelines are available online.