Repository: qtile/qtile

Issue:
[ xwayland ] Cursor display and input sketchy running Ardour
If I run Ardour from the arch repo using Qtile with wayland obvs the new session window opens with the cursor as a cross but it will not let me select any options. I can tab through to select them on the keyboard. When i get to the main window the cursor is still a cross and menus are operational but if I then exit I get dumped out of Qtile to the tty login.
I'm using qtile-git and the latest wayland python-pywlroots , python-pywalyand from the normal repos.


Discussion:
> cursor as a cross

If you run `xsetroot -cursor_name left_ptr` at startup then it will default to a left pointer.

> if I then exit I get dumped out of Qtile to the tty login

This is fixed by https://github.com/qtile/qtile/pull/3252

> it will not let me select any options

Not quite figured this one out yet...
> it will not let me select any options

I suspect this is the same issue as https://github.com/qtile/qtile/issues/3280. Does that sound right?
Yes that does indeed sound similar.
> > it will not let me select any options
> 
> I suspect this is the same issue as #3280. Does that sound right?

Yes it's similar
Is this fixed by #3508?
This should fix more of the pointer issues: https://github.com/qtile/qtile/pull/3535
Other issues mentioned above seem resolved. When Ardour is open i can select options in any pop up window now problem at all. The only one that refuses to work until it is moved is when you first start Ardour. The splash is displayed and then the initial window pop up opens which you cannot select anything in until you drag it away from the splash window as pictured below.
![2022-05-28_16-05-1653752893](https://user-images.githubusercontent.com/1571498/170832882-bd76f63a-7b64-4ed6-975b-3662d4cb8dc2.jpg)
![2022-05-28_16-05-1653752926](https://user-images.githubusercontent.com/1571498/170832883-611c9823-1df4-455b-a701-c2673dc71a3e.jpg)


Resolving patch:
diff --git a/libqtile/backend/wayland/core.py b/libqtile/backend/wayland/core.py
--- a/libqtile/backend/wayland/core.py
+++ b/libqtile/backend/wayland/core.py
@@ -772,7 +772,6 @@ def focus_window(
 
         if isinstance(win, (window.XWindow, window.XStatic)):
             if not win.surface.or_surface_wants_focus():
-                win.surface.restack(None, 0)  # XCB_STACK_MODE_ABOVE
                 return
 
         previous_surface = self.seat.keyboard_state.focused_surface
@@ -806,7 +805,6 @@ def focus_window(
 
         elif surface.is_xwayland_surface and isinstance(win.surface, xwayland.Surface):
             win.surface.activate(True)
-            win.surface.restack(None, 0)  # XCB_STACK_MODE_ABOVE
             win.ftm_handle.set_activated(True)
 
         if enter and self.seat.keyboard._ptr:  # This pointer is NULL when headless
diff --git a/libqtile/backend/wayland/window.py b/libqtile/backend/wayland/window.py
--- a/libqtile/backend/wayland/window.py
+++ b/libqtile/backend/wayland/window.py
@@ -888,6 +888,18 @@ def __init__(self, core: Core, qtile: Qtile, surface: xwayland.Surface):
         self.add_listener(surface.unmap_event, self._on_unmap)
         self.add_listener(surface.destroy_event, self._on_destroy)
 
+    @property
+    def mapped(self) -> bool:
+        return self._mapped
+
+    @mapped.setter
+    def mapped(self, mapped: bool) -> None:
+        """XWindows also need to restack in the X server's Z stack."""
+        if mapped != self._mapped:
+            if mapped:
+                self.surface.restack(None, 0)  # XCB_STACK_MODE_ABOVE
+            Window.mapped.fset(self, mapped)  # type: ignore
+
     def _on_map(self, _listener: Listener, _data: Any) -> None:
         logger.debug("Signal: xwindow map")
 
@@ -1102,6 +1114,13 @@ def place(
         for output in self._outputs | prev_outputs:
             output.damage()
 
+    def cmd_bring_to_front(self) -> None:
+        if self.mapped:
+            self.core.mapped_windows.remove(self)
+            self.core.mapped_windows.append(self)
+            self.core.stack_windows()
+            self.surface.restack(None, 0)  # XCB_STACK_MODE_ABOVE
+
     def cmd_static(
         self,
         screen: int | None = None,


Test patch: