gio icon indicating copy to clipboard operation
gio copied to clipboard

Enhance focus handling in X11 by updating stage status

Open olablt opened this issue 2 years ago • 1 comments

app: improve focus event handling for X11 environment

This commit enhances the application's response to focus gain and loss events under the X11 environment. Specifically, when the application window gains focus, it now triggers a StageEvent with the 'StageRunning' state. Conversely, when the window loses focus, it transitions to the 'StageInactive' state. This change ensures more intuitive application behavior in response to user focus changes.

Discussion on Slack regarding future enhancements: https://gophers.slack.com/archives/CM87SNCGM/p1709048436843239

olablt avatar Feb 28 '24 10:02 olablt

I have signed off on the commit and updated the commit message according to the guidelines provided.

Regarding the implementation details, could you provide some advice on how to trigger a pointer.Leave event when the pointer is at the edge and the window loses focus? Any insights or references would be greatly appreciated.

olablt avatar Feb 29 '24 05:02 olablt

The merging of https://todo.sr.ht/~eliasnaur/gio/555 replaces StageEvent with Config.Focused. Sorry for the conflict.

Regarding the implementation details, could you provide some advice on how to trigger a pointer.Leave event when the pointer is at the edge and the window loses focus? Any insights or references would be greatly appreciated.

I believe you'll have to change app.Window to tell its io/input.Router that focus is lost, thereby triggering a (synthetic) pointer.Leave. There is already code to translate a window focus to a widget focus: https://git.sr.ht/~eliasnaur/gio/tree/main/item/app/window.go#L634.

eliasnaur avatar Mar 06 '24 21:03 eliasnaur