Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezeshadowhelper.h
1 | #ifndef breezeshadowhelper_h | 1 | #ifndef breezeshadowhelper_h | ||
---|---|---|---|---|---|
2 | #define breezeshadowhelper_h | 2 | #define breezeshadowhelper_h | ||
3 | 3 | | |||
4 | /************************************************************************* | 4 | /************************************************************************* | ||
5 | * Copyright (C) 2014 by Hugo Pereira Da Costa <hugo.pereira@free.fr> * | 5 | * Copyright (C) 2014 by Hugo Pereira Da Costa <hugo.pereira@free.fr> * | ||
6 | * Copyright (C) 2020 by Vlad Zahorodnii <vladzzag@gmail.com> * | ||||
6 | * * | 7 | * * | ||
7 | * This program is free software; you can redistribute it and/or modify * | 8 | * This program is free software; you can redistribute it and/or modify * | ||
8 | * it under the terms of the GNU General Public License as published by * | 9 | * it under the terms of the GNU General Public License as published by * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | 10 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | 11 | * (at your option) any later version. * | ||
11 | * * | 12 | * * | ||
12 | * This program is distributed in the hope that it will be useful, * | 13 | * This program is distributed in the hope that it will be useful, * | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
15 | * GNU General Public License for more details. * | 16 | * GNU General Public License for more details. * | ||
16 | * * | 17 | * * | ||
17 | * You should have received a copy of the GNU General Public License * | 18 | * You should have received a copy of the GNU General Public License * | ||
18 | * along with this program; if not, write to the * | 19 | * along with this program; if not, write to the * | ||
19 | * Free Software Foundation, Inc., * | 20 | * Free Software Foundation, Inc., * | ||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
21 | *************************************************************************/ | 22 | *************************************************************************/ | ||
22 | 23 | | |||
23 | #include "breezetileset.h" | 24 | #include "breezetileset.h" | ||
24 | #include "config-breeze.h" | 25 | #include "config-breeze.h" | ||
25 | 26 | | |||
26 | #include <QObject> | 27 | #include <KWindowShadow> | ||
27 | #include <QPointer> | 28 | | ||
28 | #include <QMap> | 29 | #include <QMap> | ||
29 | #include <QMargins> | 30 | #include <QMargins> | ||
30 | 31 | #include <QObject> | |||
31 | #if BREEZE_HAVE_X11 | 32 | #include <QSet> | ||
32 | #include <xcb/xcb.h> | | |||
33 | #endif | | |||
34 | | ||||
35 | #if BREEZE_HAVE_KWAYLAND | | |||
36 | namespace KWayland | | |||
37 | { | | |||
38 | namespace Client | | |||
39 | { | | |||
40 | class ShadowManager; | | |||
41 | class ShmPool; | | |||
42 | class Surface; | | |||
43 | } | | |||
44 | } | | |||
45 | #endif | | |||
46 | 33 | | |||
47 | namespace Breeze | 34 | namespace Breeze | ||
48 | { | 35 | { | ||
49 | 36 | | |||
50 | //* forward declaration | 37 | //* forward declaration | ||
51 | class Helper; | 38 | class Helper; | ||
52 | 39 | | |||
53 | struct ShadowParams | 40 | struct ShadowParams | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 77 | { | |||
126 | /** is public because it is also needed for mdi windows */ | 113 | /** is public because it is also needed for mdi windows */ | ||
127 | TileSet shadowTiles(); | 114 | TileSet shadowTiles(); | ||
128 | 115 | | |||
129 | protected Q_SLOTS: | 116 | protected Q_SLOTS: | ||
130 | 117 | | |||
131 | //* unregister widget | 118 | //* unregister widget | ||
132 | void objectDeleted( QObject* ); | 119 | void objectDeleted( QObject* ); | ||
133 | 120 | | |||
134 | //* initializes the Wayland specific parts | | |||
135 | void initializeWayland(); | | |||
136 | | ||||
137 | protected: | 121 | protected: | ||
138 | 122 | | |||
139 | //* true if widget is a menu | 123 | //* true if widget is a menu | ||
140 | bool isMenu( QWidget* ) const; | 124 | bool isMenu( QWidget* ) const; | ||
141 | 125 | | |||
142 | //* true if widget is a tooltip | 126 | //* true if widget is a tooltip | ||
143 | bool isToolTip( QWidget* ) const; | 127 | bool isToolTip( QWidget* ) const; | ||
144 | 128 | | |||
145 | //* dock widget | 129 | //* dock widget | ||
146 | bool isDockWidget( QWidget* ) const; | 130 | bool isDockWidget( QWidget* ) const; | ||
147 | 131 | | |||
148 | //* toolbar | 132 | //* toolbar | ||
149 | bool isToolBar( QWidget* ) const; | 133 | bool isToolBar( QWidget* ) const; | ||
150 | 134 | | |||
151 | //* accept widget | 135 | //* accept widget | ||
152 | bool acceptWidget( QWidget* ) const; | 136 | bool acceptWidget( QWidget* ) const; | ||
153 | 137 | | |||
154 | // create pixmap handles from tileset | | |||
155 | const QVector<quint32>& createPixmapHandles(); | | |||
156 | | ||||
157 | // create pixmap handle from pixmap | | |||
158 | quint32 createPixmap( const QPixmap& ); | | |||
159 | | ||||
160 | //* installs shadow on given widget in a platform independent way | 138 | //* installs shadow on given widget in a platform independent way | ||
161 | bool installShadows( QWidget * ); | 139 | bool installShadows( QWidget * ); | ||
162 | 140 | | |||
163 | //* uninstalls shadow on given widget in a platform independent way | 141 | //* uninstalls shadow on given widget in a platform independent way | ||
164 | void uninstallShadows( QWidget * ) const; | 142 | void uninstallShadows( QWidget * ); | ||
165 | | ||||
166 | //* install shadow X11 property on given widget | | |||
167 | /** | | |||
168 | shadow atom and property specification available at | | |||
169 | https://community.kde.org/KWin/Shadow | | |||
170 | */ | | |||
171 | bool installX11Shadows( QWidget* ); | | |||
172 | | ||||
173 | //* uninstall shadow X11 property on given widget | | |||
174 | void uninstallX11Shadows( QWidget* ) const; | | |||
175 | | ||||
176 | //* install shadow on given widget for Wayland | | |||
177 | bool installWaylandShadows( QWidget * ); | | |||
178 | | ||||
179 | //* uninstall shadow on given widget for Wayland | | |||
180 | void uninstallWaylandShadows( QWidget* ) const; | | |||
181 | 143 | | |||
182 | //* gets the shadow margins for the given widget | 144 | //* gets the shadow margins for the given widget | ||
183 | QMargins shadowMargins( QWidget* ) const; | 145 | QMargins shadowMargins( QWidget* ) const; | ||
184 | 146 | | |||
147 | //* gets or creates shared kwindowsystem shadow tiles | ||||
148 | KWindowShadowTile::Ptr getOrCreateLeftTile(); | ||||
149 | KWindowShadowTile::Ptr getOrCreateTopLeftTile(); | ||||
150 | KWindowShadowTile::Ptr getOrCreateTopTile(); | ||||
151 | KWindowShadowTile::Ptr getOrCreateTopRightTile(); | ||||
152 | KWindowShadowTile::Ptr getOrCreateRightTile(); | ||||
153 | KWindowShadowTile::Ptr getOrCreateBottomRightTile(); | ||||
154 | KWindowShadowTile::Ptr getOrCreateBottomTile(); | ||||
155 | KWindowShadowTile::Ptr getOrCreateBottomLeftTile(); | ||||
156 | | ||||
185 | private: | 157 | private: | ||
186 | 158 | | |||
187 | //* helper | 159 | //* helper | ||
188 | Helper& _helper; | 160 | Helper& _helper; | ||
189 | 161 | | |||
190 | //* registered widgets | 162 | //* registered widgets | ||
191 | QMap<QWidget*, WId> _widgets; | 163 | QSet<QWidget*> _widgets; | ||
192 | | ||||
193 | //* tileset | | |||
194 | TileSet _shadowTiles; | | |||
195 | | ||||
196 | //* number of pixmaps | | |||
197 | enum { numPixmaps = 8 }; | | |||
198 | | ||||
199 | //* pixmaps | | |||
200 | QVector<quint32> _pixmaps; | | |||
201 | | ||||
202 | #if BREEZE_HAVE_X11 | | |||
203 | 164 | | |||
204 | //* graphical context | 165 | //* managed shadows | ||
205 | xcb_gcontext_t _gc = 0; | 166 | QMap<QWidget*, KWindowShadow*> _shadows; | ||
206 | 167 | | |||
207 | //* shadow atom | 168 | //* shared platform shadow tiles | ||
208 | xcb_atom_t _atom = 0; | 169 | QWeakPointer<KWindowShadowTile> _leftTile; | ||
170 | QWeakPointer<KWindowShadowTile> _topLeftTile; | ||||
171 | QWeakPointer<KWindowShadowTile> _topTile; | ||||
172 | QWeakPointer<KWindowShadowTile> _topRightTile; | ||||
173 | QWeakPointer<KWindowShadowTile> _rightTile; | ||||
174 | QWeakPointer<KWindowShadowTile> _bottomRightTile; | ||||
175 | QWeakPointer<KWindowShadowTile> _bottomTile; | ||||
176 | QWeakPointer<KWindowShadowTile> _bottomLeftTile; | ||||
209 | 177 | | |||
210 | #endif | 178 | //* tileset | ||
211 | 179 | TileSet _shadowTiles; | |||
212 | #if BREEZE_HAVE_KWAYLAND | | |||
213 | | ||||
214 | //* registered widgets to wayland surface mappings | | |||
215 | QMap<QWidget*, KWayland::Client::Surface *> _widgetSurfaces; | | |||
216 | | ||||
217 | //* The Wayland shadow manager to create Shadows for Surfaces (QWindow) | | |||
218 | QPointer<KWayland::Client::ShadowManager> _shadowManager; | | |||
219 | | ||||
220 | //* The Wayland Shared memory pool to share the shadow pixmaps with compositor | | |||
221 | QPointer<KWayland::Client::ShmPool> _shmPool; | | |||
222 | #endif | | |||
223 | 180 | | |||
224 | }; | 181 | }; | ||
225 | 182 | | |||
226 | } | 183 | } | ||
227 | 184 | | |||
228 | #endif | 185 | #endif |