examples icon indicating copy to clipboard operation
examples copied to clipboard

On KDE X11, main window sometimes loses focus when switching or closing menu items

Open nyanpasu64 opened this issue 4 years ago • 4 comments

I'm running this repo, latest main d385acefcc2405ddb863f79e3ccdb4479891008c, with updated dependencies plus nativeshell updated to https://github.com/nativeshell/nativeshell/commit/790b609bd79d229848bce423b708dba389e0a639.

Are you overwhelmed with bug reports or not?

Instructions:

This issue is easier to spot if you switch KDE's color scheme from "Breeze Light/Dark" to "Breeze", so focused title bars are dark and unfocused title bars are light.

  • cargo build --release
  • watch -n0.1 ./target/release/nativeshell_examples
    • This bug only appears randomly, so watch makes testing easier by automatically respawning the app after I close it. (I'm sure you can use a bash loop too, but I don't remember the syntax, and I use fish which has a different syntax.)
    • I didn't test cargo run --release or debug.
  • Click on the "Menu & MenuBar" tab.
  • Expand the purple menu.
  • (Optionally) move your mouse rapidly left and right across the menu entries, optionally moving it onto the white space around the menu bar.
  • Close the menu by clicking on the window.

Results:

Usually the window will maintain focus when you wiggle your mouse, and when you click on the window. Close the window and try again.

On some program runs, the title bar will flash the "inactive" color when you wiggle your mouse. (On the Breeze color theme, it turns from dark to light). If you click outside of the menu bar, on the rest of the app window body, will close the menu but leave the app defocused until you click a second time!

~~If your second click is on selectable text (in this case, "lib/pages/menu.dart")~~ or even if your second click is not on selectable text, it fails to refocus the app and you need a third click to do so.

Desktop environments:

Could reproduce:

  • KDE Xorg (has KWin title bars)

Could not reproduce:

  • GNOME Xorg (has GTK3 client-side decoration title bars) (10-20 failed tries)
  • Weston Wayland (has GTK3 client-side decoration title bars) (15-ish tries). It was difficult to test because my cursor kept lagging, and the nativeshell window popped up on a different location on each run.
  • KDE Wayland (title bars look like KWin, probably drawn by KWin) (20-ish failed tries)
    • Menus had invisible text, and closing the window produced GTK3 drawing errors.
  • GNOME Wayland (has GTK3 client-side decoration title bars) (20-ish failed tries)
    • I could not start GNOME Wayland through SDDM or XDG_SESSION_TYPE=wayland dbus-run-session gnome-session; it locked up. I ended up running mutter --wayland & gnome-terminal (not gnome-session since it would error out) and going from there.

Videos:

Bug on KWin X11:

https://user-images.githubusercontent.com/913957/123012627-72787d00-d377-11eb-89ae-da3a92071fb0.mp4

Flutter version:

Flutter 2.3.0-17.0.pre.434 • channel master • https://github.com/flutter/flutter.git Framework • revision b79dd40bad (50 minutes ago) • 2021-06-22 18:51:04 -0400 Engine • revision 2536a34859 Tools • Dart 2.14.0 (build 2.14.0-233.0.dev)

System info:

Operating System: Arch Linux KDE Plasma Version: 5.22.1 KDE Frameworks Version: 5.83.0 Qt Version: 5.15.2 Kernel Version: 5.12.11-zen1-1-zen (64-bit) Graphics Platform: X11 Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor Memory: 15.6 GiB of RAM Graphics Processor: NVIDIA GeForce GT 730/PCIe/SSE2

nyanpasu64 avatar Jun 22 '21 23:06 nyanpasu64

I tried this with KDE/Plasma 5.22.2/X11 with high contrast theme but so far I'm unable to rperoduce this. Which Gtk version do you have installed?

knopp avatar Jun 23 '21 09:06 knopp

Arch package version 1:3.24.29-2, aka GTK+ 3.24.29. The bug occurs with both the Arch package, and my self-built packages with debug symbols.

I haven't tried the bug in other user accounts though.

nyanpasu64 avatar Jun 23 '21 11:06 nyanpasu64

No luck reproducing this. As far as I can tell Gtk sets proper window type atom (i.e. _NET_WM_WINDOW_TYPE_DROPDOWN_MENU) and it's Kwin responsibility not to unfocus parent window for child that is a menu. So it seems like this might be a kwin bug, but possibly fixed in 5.22.2 since I can't reproduce it.

knopp avatar Jun 23 '21 13:06 knopp

Reproduced on KWin 5.22.2. Shrug, that's weird. It's not the biggest bug though.

nyanpasu64 avatar Jun 25 '21 06:06 nyanpasu64