|
17 | 17 | #include <xcb/xcb.h> |
18 | 18 | #include <xcb/xcb_ewmh.h> |
19 | 19 | #include <xcb/xcb_icccm.h> |
| 20 | +#include <xcb/shape.h> |
20 | 21 |
|
21 | 22 | DS_BEGIN_NAMESPACE |
22 | 23 |
|
@@ -316,6 +317,38 @@ void LayerShellEmulation::onScopeChanged() |
316 | 317 | qCDebug(layershell) << "Set WM_CLASS for window" << m_window->winId() << " wm_class:" << wmClassData; |
317 | 318 | } |
318 | 319 |
|
| 320 | +void LayerShellEmulation::onInputRegionChanged() |
| 321 | +{ |
| 322 | + auto *x11Application = qGuiApp->nativeInterface<QNativeInterface::QX11Application>(); |
| 323 | + if (!x11Application || !m_window->winId() || !m_dlayerShellWindow) { |
| 324 | + return; |
| 325 | + } |
| 326 | + |
| 327 | + if (m_dlayerShellWindow->inputRegion().isNull()) { |
| 328 | + xcb_shape_mask(x11Application->connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, m_window->winId(), 0, 0, XCB_NONE); |
| 329 | + xcb_flush(x11Application->connection()); |
| 330 | + return; |
| 331 | + } |
| 332 | + |
| 333 | + QRegion region = m_dlayerShellWindow->inputRegion(); |
| 334 | + qreal scaleFactor = qGuiApp->devicePixelRatio(); |
| 335 | + |
| 336 | + QVector<xcb_rectangle_t> rects; |
| 337 | + for (const QRect &r : region) { |
| 338 | + xcb_rectangle_t rect; |
| 339 | + rect.x = r.x() * scaleFactor; |
| 340 | + rect.y = r.y() * scaleFactor; |
| 341 | + rect.width = r.width() * scaleFactor; |
| 342 | + rect.height = r.height() * scaleFactor; |
| 343 | + rects.append(rect); |
| 344 | + } |
| 345 | + |
| 346 | + xcb_shape_rectangles(x11Application->connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, |
| 347 | + XCB_CLIP_ORDERING_UNSORTED, m_window->winId(), 0, 0, |
| 348 | + rects.size(), rects.data()); |
| 349 | + xcb_flush(x11Application->connection()); |
| 350 | +} |
| 351 | + |
319 | 352 | // void X11Emulation::onKeyboardInteractivityChanged() |
320 | 353 | // { |
321 | 354 | // // kwin no implentation on wayland |
|
0 commit comments