Bug 501829 - Permanent focus stealing with non-sense Gtk4 code
Summary: Permanent focus stealing with non-sense Gtk4 code
Status: REOPENED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 6.3.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-21 13:53 UTC by postix
Modified: 2025-04-19 11:24 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description postix 2025-03-21 13:53:57 UTC
SUMMARY

I've stumbled over the following two issues by accident:

If a Gtk4 popovermenu is set visible in the _closed_ event, it will re-open and steal the focus: 
You can basically no longer click anything else.

However, if you click fast and often enough onto the "x" button in the titlebar of the sample app, you can make it close eventually.

You can also click into into another app, e.g. Konsole, until eventually Konsole will gain focus. The main window will hide behind Konsole, but the popover keeps staying on top of all windows.

The code of course makes no sense, but I wanted to report it nonetheless. 


STEPS TO REPRODUCE

Here's a minimal  reproducer:

```
import gi
gi.require_version("Gtk", "4.0")

from gi.repository import Gtk
from gi.repository import GLib

def on_closed(popover):
    print("popover closed")
    popover.set_visible(True)

def on_activate(app):
    win = Gtk.ApplicationWindow(application=app)

    popovermenu = Gtk.PopoverMenu()
    popovermenu.connect("closed", on_closed)
    popovermenu.set_size_request(100, 100)

    win.set_child(popovermenu)
    win.present()

    popovermenu.popup()


app = Gtk.Application(application_id='org.gtk.Example')
app.connect('activate', on_activate)
app.run(None)
```

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20250318
KDE Plasma Version: 6.3.3
KDE Frameworks Version: 6.12.0
Qt Version: 6.8.2
Kernel Version: 6.13.6-1-default (64-bit)
Comment 1 postix 2025-04-13 11:56:09 UTC
Fixed by the same commit as for #501828
Comment 2 postix 2025-04-19 11:24:09 UTC
Actually it's not fixed yet. Question: Is this behavior of automatic focus grabbing on re-showing the closed surface intended or something, which needs to be solved?

 Is this maybe "fixed" in 6.4 already?