7#include "kwindowshadow_p_x11.h"
9#include <private/qtx11extras_p.h>
11static const QByteArray s_atomName = QByteArrayLiteral(
"_KDE_NET_WM_SHADOW");
13bool KWindowShadowTilePrivateX11::create()
15 xcb_connection_t *connection = QX11Info::connection();
16 xcb_window_t rootWindow = QX11Info::appRootWindow();
18 const uint16_t width = uint16_t(image.width());
19 const uint16_t height = uint16_t(image.height());
20 const uint8_t depth = uint8_t(image.depth());
22 pixmap = xcb_generate_id(connection);
23 gc = xcb_generate_id(connection);
25 xcb_create_pixmap(connection, depth, pixmap, rootWindow, width, height);
26 xcb_create_gc(connection, gc, pixmap, 0,
nullptr);
28 xcb_put_image(connection,
29 XCB_IMAGE_FORMAT_Z_PIXMAP,
44void KWindowShadowTilePrivateX11::destroy()
46 xcb_connection_t *connection = QX11Info::connection();
48 xcb_free_pixmap(connection, pixmap);
49 xcb_free_gc(connection, gc);
51 pixmap = XCB_PIXMAP_NONE;
55KWindowShadowTilePrivateX11 *KWindowShadowTilePrivateX11::get(
const KWindowShadowTile *tile)
57 KWindowShadowTilePrivate *d = KWindowShadowTilePrivate::get(tile);
58 return static_cast<KWindowShadowTilePrivateX11 *
>(d);
61static xcb_atom_t lookupAtom(
const QByteArray &atomName)
63 xcb_connection_t *connection = QX11Info::connection();
68 xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom_unchecked(connection,
72 xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, atomCookie,
nullptr);
78 xcb_atom_t atom = reply->atom;
86 const auto d = KWindowShadowTilePrivateX11::get(tile.
data());
90bool KWindowShadowPrivateX11::create()
92 xcb_connection_t *connection = QX11Info::connection();
94 const xcb_atom_t atom = lookupAtom(s_atomName);
95 if (atom == XCB_ATOM_NONE) {
107 data[i++] = nativeHandleForTile(topTile);
109 data[i++] = nativeHandleForTile(getOrCreateEmptyTile());
113 data[i++] = nativeHandleForTile(topRightTile);
115 data[i++] = nativeHandleForTile(getOrCreateEmptyTile());
119 data[i++] = nativeHandleForTile(rightTile);
121 data[i++] = nativeHandleForTile(getOrCreateEmptyTile());
124 if (bottomRightTile) {
125 data[i++] = nativeHandleForTile(bottomRightTile);
127 data[i++] = nativeHandleForTile(getOrCreateEmptyTile());
131 data[i++] = nativeHandleForTile(bottomTile);
133 data[i++] = nativeHandleForTile(getOrCreateEmptyTile());
136 if (bottomLeftTile) {
137 data[i++] = nativeHandleForTile(bottomLeftTile);
139 data[i++] = nativeHandleForTile(getOrCreateEmptyTile());
143 data[i++] = nativeHandleForTile(leftTile);
145 data[i++] = nativeHandleForTile(getOrCreateEmptyTile());
149 data[i++] = nativeHandleForTile(topLeftTile);
151 data[i++] = nativeHandleForTile(getOrCreateEmptyTile());
154 if (topLeftTile || topTile || topRightTile) {
155 data[i++] = uint32_t(padding.top());
160 if (topRightTile || rightTile || bottomRightTile) {
161 data[i++] = uint32_t(padding.right());
166 if (bottomRightTile || bottomTile || bottomLeftTile) {
167 data[i++] = uint32_t(padding.bottom());
172 if (bottomLeftTile || leftTile || topLeftTile) {
173 data[i++] = uint32_t(padding.left());
178 xcb_change_property(connection, XCB_PROP_MODE_REPLACE,
window->
winId(), atom, XCB_ATOM_CARDINAL, 32, data.size(), data.constData());
179 xcb_flush(connection);
184void KWindowShadowPrivateX11::destroy()
196 xcb_connection_t *connection = QX11Info::connection();
198 const xcb_atom_t atom = lookupAtom(s_atomName);
199 if (atom == XCB_ATOM_NONE) {
203 xcb_delete_property(connection,
window->
winId(), atom);
213 emptyTile->setImage(image);
The KWindowShadowTile class provides a platform-indendent shadow tile representation.
const char * constData() const const
qsizetype size() const const
QSharedPointer< T > create(Args &&... args)
virtual QPlatformSurface * surfaceHandle() const const=0