@@ -19,18 +19,34 @@ FocusGrab::~FocusGrab() {
1919bool FocusGrab::isActive () const { return this ->active ; }
2020
2121void FocusGrab::addWindow (QWindow* window) {
22+ auto tryAddWayland = [this ](QWaylandWindow* waylandWindow) {
23+ if (waylandWindow->surface ()) {
24+ this ->addWaylandWindow (waylandWindow);
25+ this ->sync ();
26+ } else {
27+ QObject::connect (
28+ waylandWindow,
29+ &QWaylandWindow::surfaceCreated,
30+ this ,
31+ [this , waylandWindow]() {
32+ this ->addWaylandWindow (waylandWindow);
33+ this ->sync ();
34+ }
35+ );
36+ }
37+ };
38+
2239 if (auto * waylandWindow = dynamic_cast <QWaylandWindow*>(window->handle ())) {
23- this -> addWaylandWindow (waylandWindow);
40+ tryAddWayland (waylandWindow);
2441 } else {
25- QObject::connect (window, &QWindow::visibleChanged, this , [this , window]() {
42+ QObject::connect (window, &QWindow::visibleChanged, this , [this , window, tryAddWayland ]() {
2643 if (window->isVisible ()) {
2744 if (window->handle () == nullptr ) {
2845 window->create ();
2946 }
3047
3148 auto * waylandWindow = dynamic_cast <QWaylandWindow*>(window->handle ());
32- this ->addWaylandWindow (waylandWindow);
33- this ->sync ();
49+ tryAddWayland (waylandWindow);
3450 }
3551 });
3652 }
@@ -53,6 +69,8 @@ void FocusGrab::addWaylandWindow(QWaylandWindow* window) {
5369}
5470
5571void FocusGrab::sync () {
72+ if (this ->transactionActive ) return ;
73+
5674 if (this ->commitRequired ) {
5775 this ->commit ();
5876 this ->commitRequired = false ;
@@ -70,6 +88,13 @@ void FocusGrab::sync() {
7088 }
7189}
7290
91+ void FocusGrab::startTransaction () { this ->transactionActive = true ; }
92+
93+ void FocusGrab::completeTransaction () {
94+ this ->transactionActive = false ;
95+ this ->sync ();
96+ }
97+
7398void FocusGrab::hyprland_focus_grab_v1_cleared () {
7499 this ->active = false ;
75100 emit this ->cleared ();
0 commit comments