-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwaylandhelper.cpp
More file actions
118 lines (91 loc) · 4.22 KB
/
Copy pathwaylandhelper.cpp
File metadata and controls
118 lines (91 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "waylandhelper.h"
LayerShellQt::Window* WaylandHelper::getLayerShellWindow(QWidget *widget) {
if (!widget || !widget->windowHandle()) {
return nullptr;
}
return LayerShellQt::Window::get(widget->windowHandle());
}
void WaylandHelper::setupOverlayWindow(QWidget *widget) {
// Set basic Qt properties
widget->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
widget->setAttribute(Qt::WA_TranslucentBackground);
// Get screen size for reference
QScreen *screen = QGuiApplication::primaryScreen();
QRect screenGeometry = screen->geometry();
qDebug() << "Wayland: Screen geometry:" << screenGeometry;
// Don't set geometry yet - let layer shell handle it
// Just trigger native window creation by accessing winId()
WId wid = widget->winId();
Q_UNUSED(wid);
// Now get the window handle
QWindow *window = widget->windowHandle();
if (!window) {
qWarning() << "Wayland: Failed to get window handle";
widget->show();
return;
}
qDebug() << "Wayland: Window handle obtained";
// Get layer shell window BEFORE showing
auto layerWindow = LayerShellQt::Window::get(window);
if (!layerWindow) {
qWarning() << "Wayland: Layer shell not available! ";
widget->showFullScreen();
return;
}
qDebug() << "Wayland: Layer shell window obtained";
// Set to overlay layer (above everything including fullscreen apps)
layerWindow->setLayer(LayerShellQt::Window::LayerOverlay);
qDebug() << "Wayland: Layer set to Overlay";
// Set margins to 0 FIRST (before anchors)
layerWindow->setMargins({0, 0, 0, 0});
qDebug() << "Wayland: Margins set to 0";
// No exclusive zone (don't push other windows away, and don't be pushed)
layerWindow->setExclusiveZone(-1); // -1 means ignore exclusive zones
qDebug() << "Wayland: Exclusive zone set to -1 (ignore exclusive zones)";
// Anchor to all edges for fullscreen behavior
// When anchored to all edges with margins 0, it should cover entire screen
layerWindow->setAnchors(LayerShellQt::Window::Anchors(
LayerShellQt::Window::AnchorTop |
LayerShellQt::Window::AnchorBottom |
LayerShellQt::Window::AnchorLeft |
LayerShellQt::Window::AnchorRight
));
qDebug() << "Wayland: Anchors set to all edges";
// Set keyboard interactivity to exclusive so we stay on top and receive input
layerWindow->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityExclusive);
qDebug() << "Wayland: Keyboard interactivity set to Exclusive";
// Set scope to show on all outputs
layerWindow->setScope("glaze-overlay");
// Now show the window - layer shell will handle the sizing
widget->show();
qDebug() << "Wayland: Layer shell overlay window setup complete";
qDebug() << "Wayland: Widget geometry:" << widget->geometry();
qDebug() << "Wayland: Widget size:" << widget->size();
}
void WaylandHelper::setInputRegion(QWidget *widget, const QRegion ®ion) {
if (!widget || !widget->windowHandle()) {
return;
}
auto layerWindow = getLayerShellWindow(widget);
if (region.isEmpty()) {
// Empty region = pass-through mode (for color picker dialog)
widget->setMask(QRegion());
// Set keyboard interactivity to None for full pass-through
if (layerWindow) {
layerWindow->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityNone);
}
qDebug() << "Wayland: Input region set to empty (full pass-through)";
} else {
// Specific region receives input (toolbar or full window)
widget->setMask(region);
// Keep keyboard interactivity as Exclusive so we receive input immediately
if (layerWindow) {
layerWindow->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityExclusive);
}
qDebug() << "Wayland: Input region set to:" << region.boundingRect();
// Force Wayland surface commit by updating the window
// This is a workaround for KWin not immediately applying input region changes
widget->windowHandle()->requestUpdate();
qDebug() << "Wayland: Forced surface update";
}
}