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 | | |||
27 | #include <KWindowShadow> | ||||
28 | | ||||
26 | #include <QObject> | 29 | #include <QObject> | ||
27 | #include <QPointer> | 30 | #include <QPointer> | ||
28 | #include <QMap> | 31 | #include <QMap> | ||
29 | #include <QMargins> | 32 | #include <QMargins> | ||
30 | 33 | #include <QSet> | |||
31 | #if BREEZE_HAVE_X11 | | |||
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 | 34 | | |||
47 | namespace Breeze | 35 | namespace Breeze | ||
48 | { | 36 | { | ||
49 | 37 | | |||
50 | //* forward declaration | 38 | //* forward declaration | ||
51 | class Helper; | 39 | class Helper; | ||
52 | 40 | | |||
53 | struct ShadowParams | 41 | struct ShadowParams | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 78 | { | |||
126 | /** is public because it is also needed for mdi windows */ | 114 | /** is public because it is also needed for mdi windows */ | ||
127 | TileSet shadowTiles(); | 115 | TileSet shadowTiles(); | ||
128 | 116 | | |||
129 | protected Q_SLOTS: | 117 | protected Q_SLOTS: | ||
130 | 118 | | |||
131 | //* unregister widget | 119 | //* unregister widget | ||
132 | void objectDeleted( QObject* ); | 120 | void objectDeleted( QObject* ); | ||
133 | 121 | | |||
134 | //* initializes the Wayland specific parts | | |||
135 | void initializeWayland(); | | |||
136 | | ||||
137 | protected: | 122 | protected: | ||
138 | 123 | | |||
139 | //* true if widget is a menu | 124 | //* true if widget is a menu | ||
140 | bool isMenu( QWidget* ) const; | 125 | bool isMenu( QWidget* ) const; | ||
141 | 126 | | |||
142 | //* true if widget is a tooltip | 127 | //* true if widget is a tooltip | ||
143 | bool isToolTip( QWidget* ) const; | 128 | bool isToolTip( QWidget* ) const; | ||
144 | 129 | | |||
145 | //* dock widget | 130 | //* dock widget | ||
146 | bool isDockWidget( QWidget* ) const; | 131 | bool isDockWidget( QWidget* ) const; | ||
147 | 132 | | |||
148 | //* toolbar | 133 | //* toolbar | ||
149 | bool isToolBar( QWidget* ) const; | 134 | bool isToolBar( QWidget* ) const; | ||
150 | 135 | | |||
151 | //* accept widget | 136 | //* accept widget | ||
152 | bool acceptWidget( QWidget* ) const; | 137 | bool acceptWidget( QWidget* ) const; | ||
153 | 138 | | |||
154 | // create pixmap handles from tileset | 139 | // create shared shadow tiles from tileset | ||
155 | const QVector<quint32>& createPixmapHandles(); | 140 | const QVector<KWindowShadowTile::Ptr>& createShadowTiles(); | ||
156 | 141 | | |||
157 | // create pixmap handle from pixmap | 142 | // create shadow tile from pixmap | ||
158 | quint32 createPixmap( const QPixmap& ); | 143 | KWindowShadowTile::Ptr createTile( const QPixmap& ); | ||
159 | 144 | | |||
160 | //* installs shadow on given widget in a platform independent way | 145 | //* installs shadow on given widget in a platform independent way | ||
161 | bool installShadows( QWidget * ); | 146 | void installShadows( QWidget * ); | ||
162 | 147 | | |||
163 | //* uninstalls shadow on given widget in a platform independent way | 148 | //* uninstalls shadow on given widget in a platform independent way | ||
164 | void uninstallShadows( QWidget * ) const; | 149 | 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 | 150 | | |||
182 | //* gets the shadow margins for the given widget | 151 | //* gets the shadow margins for the given widget | ||
183 | QMargins shadowMargins( QWidget* ) const; | 152 | QMargins shadowMargins( QWidget* ) const; | ||
184 | 153 | | |||
185 | private: | 154 | private: | ||
186 | 155 | | |||
187 | //* helper | 156 | //* helper | ||
188 | Helper& _helper; | 157 | Helper& _helper; | ||
189 | 158 | | |||
190 | //* registered widgets | 159 | //* registered widgets | ||
191 | QMap<QWidget*, WId> _widgets; | 160 | QSet<QWidget*> _widgets; | ||
161 | | ||||
162 | //* managed shadows | ||||
163 | QMap<QWidget*, KWindowShadow*> _shadows; | ||||
192 | 164 | | |||
193 | //* tileset | 165 | //* tileset | ||
194 | TileSet _shadowTiles; | 166 | TileSet _shadowTiles; | ||
195 | 167 | | |||
196 | //* number of pixmaps | 168 | //* number of tiles | ||
197 | enum { numPixmaps = 8 }; | 169 | enum { numTiles = 8 }; | ||
198 | | ||||
199 | //* pixmaps | | |||
200 | QVector<quint32> _pixmaps; | | |||
201 | | ||||
202 | #if BREEZE_HAVE_X11 | | |||
203 | | ||||
204 | //* graphical context | | |||
205 | xcb_gcontext_t _gc = 0; | | |||
206 | | ||||
207 | //* shadow atom | | |||
208 | xcb_atom_t _atom = 0; | | |||
209 | 170 | | |||
210 | #endif | 171 | //* shared shadow tiles | ||
211 | 172 | QVector<KWindowShadowTile::Ptr> _tiles; | |||
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 | 173 | | |||
224 | }; | 174 | }; | ||
225 | 175 | | |||
226 | } | 176 | } | ||
227 | 177 | | |||
228 | #endif | 178 | #endif |