Prasad Tammana | 1 Nov 03:59 2011

Giving focus to the root window of the screen on Linux

Is there a way for an app to give focus to the root window on Linux? The only I found looking around is to set user time on the root window to be current and that's not working for me. Here is what I'm doing:


    GdkWindow* root_window = gdk_screen_get_root_window(gdk_screen_get_default());
    gdk_x11_window_set_user_time(root_window, GDK_CURRENT_TIME);

I tried a few variations of this without luck. I also tried the following and that didn't work either:

    GdkWindow* root_window = gdk_screen_get_root_window(
        gdk_screen_get_default());
    gdk_window_focus(root_window, GDK_CURRENT_TIME);


In the scenario where the only browser windows are panels, and all the panels are minimized, I'd like for Chrome to give up focus and they way I'm trying to do it is by giving focus to the root window. Is there a more direct way for an app to give up focus?

Thanks,
Prasad

--
Chromium Developers mailing list: chromium-dev <at> chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
Lambros Lambrou | 1 Nov 18:32 2011

Re: Giving focus to the root window of the screen on Linux

Quoted from here:

A convention is also required for clients that want to give up the input focus. There is no safe value set for them to set the input focus to; therefore, they should ignore input material.

Convention

Clients should not give up the input focus of their own volition. They should ignore input that they receive instead.

So, if we believe the ICCCM, then there's no simple way for an app to give up focus.  It has to ignore input instead.

Anyone else have any better ideas?
Lambros


On Mon, Oct 31, 2011 at 7:59 PM, Prasad Tammana <prasadt <at> chromium.org> wrote:
Is there a way for an app to give focus to the root window on Linux? The only I found looking around is to set user time on the root window to be current and that's not working for me. Here is what I'm doing:

    GdkWindow* root_window = gdk_screen_get_root_window(gdk_screen_get_default());
    gdk_x11_window_set_user_time(root_window, GDK_CURRENT_TIME);

I tried a few variations of this without luck. I also tried the following and that didn't work either:

    GdkWindow* root_window = gdk_screen_get_root_window(
        gdk_screen_get_default());
    gdk_window_focus(root_window, GDK_CURRENT_TIME);


In the scenario where the only browser windows are panels, and all the panels are minimized, I'd like for Chrome to give up focus and they way I'm trying to do it is by giving focus to the root window. Is there a more direct way for an app to give up focus?

Thanks,
Prasad

--
Chromium Developers mailing list: chromium-dev <at> chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

--
Chromium Developers mailing list: chromium-dev <at> chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
Tony Chang | 1 Nov 18:37 2011

Re: Giving focus to the root window of the screen on Linux

On Mon, Oct 31, 2011 at 7:59 PM, Prasad Tammana <prasadt <at> chromium.org> wrote:
In the scenario where the only browser windows are panels, and all the panels are minimized, I'd like for Chrome to give up focus and they way I'm trying to do it is by giving focus to the root window. Is there a more direct way for an app to give up focus?

Doesn't the window manager automatically handle focus for you? That is, if the last chrome window is a panel and you call gtk_window_iconify() on it, the window manager should automatically shift focus to the previous app selected.

I suspect when you say, "all the panels are minimized", you mean that you're changing the appearance of the panels, but not actually calling gtk_window_iconify(). This is going to be hard to get right. If you look at the code for gdk_window_focus[1], you'll see that it sends _NET_ACTIVE_WINDOW to the window, but it's up to the window manager whether to honor that or not.  I suspect metactiy/compiz is ignoring the request because it doesn't make sense.

Also, I suspect this won't work correctly with focus follows mouse if the window is still under the mouse cursor after "minimizing".  The window will probably re-get focus as soon as you move your mouse.

--
Chromium Developers mailing list: chromium-dev <at> chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Gmane