Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noc_file_dialog: Specify timestamp to focus dialog for GTK #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mborgerson
Copy link

@mborgerson mborgerson commented Mar 25, 2020

GNOME has a "focus stealing prevention" feature that will open new windows in the background to prevent the keyboard focus from being stolen from a user, and show an "<Application> is ready" notification.

This feature currently impacts file dialog creation resulting in the dialog being confusingly spawned in the background on every creation after the first with the GTK implementation.

This patch adds a call to gtk_window_present_with_time() with the current time, enforcing that the dialog always makes it to the top of the window stacking order and receives focus.

I believe this is the simplest/best way to handle this for my application of responding to a button click without convenient access to this necessary event token/timestamp, but I welcome someone with more experience with GTK to weigh in here with a better solution. Note that I've not tested with Wayland.

Some information about the issue/feature:

Tagging other, similar projects I came across while searching for solutions which might be interested in this:

GNOME has a "focus stealing prevention" feature that will open new
windows in the background to prevent the keyboard focus from being
stolen from a user, and show an "<Application> is ready" notification.

This feature currently impacts file dialog creation resulting in the
dialog being confusingly spawned in the background on every creation
after the first.

This patch adds a call to gtk_window_present_with_time() with the
current time, enforcing that the dialog always makes it to the top of
the window stacking order and receives focus.
@thp
Copy link

thp commented Nov 29, 2020

If anybody tries to reproduce this issue:
This bug seems to happen only on X11, not on Wayland, but the fix presented here indeed fixes the issue for me.

@guillaumechereau
Copy link
Owner

Hello, it seems that this pull requests removed the:

#ifndef NOC_INCLUDE_NOC_FILE_DIALOG_H

Because of that it doesn't compile properly anymore.

@mborgerson
Copy link
Author

Hello, it seems that this pull requests removed the:

#ifndef NOC_INCLUDE_NOC_FILE_DIALOG_H

Because of that it doesn't compile properly anymore.

Looking at the diff I do not see such a change. Have you pulled the code cleanly?

@guillaumechereau
Copy link
Owner

You are right. I was checking with some local changes I think. Let me check again...

@guillaumechereau
Copy link
Owner

I got this error at compilation time:

./noc_file_dialog.h:141:9: error: ‘GDK_IS_X11_DISPLAY’ was not declared in this scope; did you mean ‘GDK_IS_DISPLAY’?
  141 |     if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {

I haven't checked the code for a long time. I also got a few warnings from the original code. I'll try to have a look that that first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants