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

Tray Icons Disappearing on i3bar #745

Closed
i3bot opened this issue Jul 3, 2012 · 19 comments
Closed

Tray Icons Disappearing on i3bar #745

i3bot opened this issue Jul 3, 2012 · 19 comments
Assignees
Labels

Comments

@i3bot
Copy link

i3bot commented Jul 3, 2012

[Originally reported by Bruno BRAGA <bruno.braga@…>]
(I am experiencing this annoying behaviour for some icons in the tray bar. They sometimes disappear out of nowhere, sometimes after coming back from suspend, or when I reload the i3 config (by hitting Mod+Shift+R).

It always happens with checkgmail/xchat icons, but intermittently with Skype as well.

I tried to check the logs, but there was nothing there. Even though the icons are gone, the applications are still running.

More details of this are discussed in the mailing list:
http://infra.in.zekjur.net/archives/i3-discuss/2012-June/000745.html

From the logs, it looks like the problem from the mailing list:

[src/xcb.c:445] ERROR: Window 022002d7 violates the XEMBED protocol, _XEMBED_INFO not set

(complete log is attached).

@stapelberg
Copy link
Member

Checkgmail is a bad example, as it uses Gtk2::TrayIcon, which doesn’t actually use Gtk despite the name. It uses the "eggtrayicon" library, which apparently fails to implement the spec properly and doesn’t deal with tray managers coming and going. You can verify this using stalonetray instead of i3bar for example (I also xtraced it and read the code).

I could reproduce the problem with xchat, too, though. Not sure if it’s the same problem throughout all your applications, so feel free to follow-up.

@stapelberg
Copy link
Member

This should be fixed with commit 8a3574f. Feel free to re-open in case you got other test cases with which it still doesn’t work.

@i3bot
Copy link
Author

i3bot commented Jul 11, 2012

[Original comment by Bruno BRAGA <bruno.braga@…>]

Michael,

Thanks for the input. This corrected issues for Skype and Xchat. And, as you predicted, checkgmail is still failing.

I can survive with that by simply restarting the application every time (exec-always).

Cheers,

@i3bot
Copy link
Author

i3bot commented Jul 18, 2012

[Original comment by lkraav <leho@…>]

Also experiencing this, following. I'm running 4.2 stable, I wonder how well the patch applies on top of it (-> Gentoo). I guess I can always clone the whole repo, too..

@i3bot
Copy link
Author

i3bot commented Sep 14, 2012

[Original comment by lkraav]

I'm running now with 8a3574f applied. But still every time I connect my HDMI plug and i3 runs through its udev reaction stuff, Skype and wpa_gui icons disappear 100% of the time. I usually do in-place restart, that makes all the icons come back. I'd vote for reopening this.

@stapelberg
Copy link
Member

Replying to comment 5 by lkraav:

I'm running now with 8a3574f applied. But still every time I connect my HDMI plug and i3 runs through its udev reaction stuff, Skype and wpa_gui icons disappear 100% of the time. I usually do in-place restart, that makes all the icons come back. I'd vote for reopening this.
Please run the latest git next version (22922a9 as of now) instead of just applying some particular commit. Does the problem persist? Also, is it only Skype and wpa_gui? Are other tray icons unaffected?

@i3bot
Copy link
Author

i3bot commented Sep 21, 2012

[Original comment by lkraav <leho@…>]

That patch seemed to be independent enough to try. Either way, I'm now on 4.3. Problem still exists. Only thing I'm seeing in .xsession-errors is:

[i3bar/src/xcb.c:596] ERROR: PropertyNotify received for unknown window 05200e4d 
[i3bar/src/xcb.c:596] ERROR: PropertyNotify received for unknown window 024001f4 
[i3bar/src/xcb.c:596] ERROR: PropertyNotify received for unknown window 0121a2fb 
[i3bar/src/xcb.c:596] ERROR: PropertyNotify received for unknown window 05200eb7 
[i3bar/src/xcb.c:596] ERROR: PropertyNotify received for unknown window 024001ff 
[i3bar/src/xcb.c:596] ERROR: PropertyNotify received for unknown window 0121a378 
[i3bar/src/xcb.c:596] ERROR: PropertyNotify received for unknown window 05200ebf 
[i3bar/src/xcb.c:596] ERROR: PropertyNotify received for unknown window 02400205 
[i3bar/src/xcb.c:596] ERROR: PropertyNotify received for unknown window 0121a385

Tray moves to my external monitor and loses some icons. Now I'm also seeing that even when restarting i3, Skype icon comes back, but wpa_gui icon stays missing. wpa_gui is running.

leho     12873  0.0  0.1  29752  6800 ?        S    Sep13   0:25 wpa_gui

@i3bot
Copy link
Author

i3bot commented Sep 21, 2012

[Original comment by lkraav <leho@…>]

Replying to comment 7 by lkraav <leho@…>:

Tray moves to my external monitor and loses some icons. Now I'm also seeing that even when restarting i3, Skype icon comes back, but wpa_gui icon stays missing. wpa_gui is running.

Common denominator is both of these are Qt-based apps.

@i3bot
Copy link
Author

i3bot commented Sep 30, 2012

[Original comment by lkraav <leho@…>]

Hi Michael

Can you shoot an update on if you have any idea on what's going on here or is further information needed?

@stapelberg
Copy link
Member

Replying to comment 9 by lkraav <leho@…>:

Hi Michael

Can you shoot an update on if you have any idea on what's going on here or is further information needed?
I haven’t looked into it yet.

@i3bot
Copy link
Author

i3bot commented Jan 1, 2013

[Original comment by angus@…]

I am having this problem, running i3 4.4 on my netbook.

If I start VLC or Skype, they put icons in the i3bar tray. When the xrandr outputs change (e.g if I plug in an external monitor, or if I use xrandr to change resolution or something), the applications keep running normally but their tray icons disappear. Restarting i3 with mod+shift+R makes the icons appear again.

@i3bot
Copy link
Author

i3bot commented Jan 2, 2013

[Original comment by angus@…]

Looks like a Qt bug, actually. VLC and Skype both use Qt.

When the xrandr outputs change, i3bar kicks all the tray clients, expecting them to start the system tray protocol again. But it seems that Qt doesn't behave correctly.

@i3bot
Copy link
Author

i3bot commented Jan 2, 2013

[Original comment by lkraav <leho@…>]

This is still an issue on qt-4.8.4

@i3bot
Copy link
Author

i3bot commented Jan 2, 2013

[Original comment by angus@…]

It looks like maybe Qt doesn't try to add system tray icons to the tray again unless it sees the previous tray window has been destroyed. (I'm looking at http://qt.gitorious.org/qt/qt/blobs/4.8/src/gui/util/qsystemtrayicon_x11.cpp near line 129.)

I don't have much experience with X11 or the system tray, so I don't really know what I'm doing, but I tried to make i3bar destroy and recreate the tray window every time the outputs are reconfigured. Here is a quick not-very-well-tested patch that seems to only sometimes work. I might investigate more later, but if not, hopefully at least people can understand what I was trying to do.

diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c
index 3a8d8b9..cc1470f 100644
--- a/i3bar/src/xcb.c
+++ b/i3bar/src/xcb.c
@…;
 /* This is needed for integration with libi3 */
 xcb_connection_t *conn;

+/* The window which holds the system tray atom selection */
+xcb_window_t selwin = XCB_NONE;
+
 /* The font we'll use */
 static i3Font font;

@…) {
     xcb_intern_atom_reply_t *tray_reply;
     tray_cookie = xcb_intern_atom(xcb_connection, 0, strlen(atomname), atomname);

+    /* If we already have a tray, destroy it first */
+    if (selwin != XCB_NONE) {
+        i3_output *o_walk;
+        SLIST_FOREACH(o_walk, outputs, slist) {
+            kick_tray_clients(o_walk);
+        }
+        xcb_destroy_window(xcb_connection, selwin);
+    }
+
     /* tray support: we need a window to own the selection */
-    xcb_window_t selwin = xcb_generate_id(xcb_connection);
+    selwin = xcb_generate_id(xcb_connection);
     uint32_t selmask = XCB_CW_OVERRIDE_REDIRECT;
     uint32_t selval[] = { 1 };
     xcb_create_window(xcb_connection,
@…) {
 void reconfig_windows(void) {
     uint32_t mask;
     uint32_t values[5];
-    static bool tray_configured = false;

     i3_output *walk;
     SLIST_FOREACH(walk, outputs, slist) {
@…) {
                 (!config.hide_on_modifier && xcb_request_failed(map_cookie, "Could not map window"))) {
                 exit(EXIT_FAILURE);
             }
-
-            if (!tray_configured &&
-                (!config.tray_output ||
-                 strcasecmp("none", config.tray_output) != 0)) {
-                init_tray();
-                tray_configured = true;
-            }
         } else {
             /* We already have a bar, so we just reconfigure it */
             mask = XCB_CONFIG_WINDOW_X |
@…) {
             }
         }
     }
+
+    if (!config.tray_output || strcasecmp("none", config.tray_output) != 0) {
+        init_tray();
+    }
 }

 /*

@stapelberg
Copy link
Member

After a few hours of debugging, I think that i3bar should send a faked DestroyNotify (makes Qt pick up the tray changes) followed by a MANAGER ClientMessage (makes GTK pick up the tray after the DestroyNotify).

Find attached a patch which does that. It works for me with nm-applet and VLC.

Please tell me how it works for you, then I’ll merge it.

@i3bot
Copy link
Author

i3bot commented Jan 2, 2013

[Original comment by lkraav <leho@…>]

Nice job @….

@stapelberg
Copy link
Member

Thanks for the feedback.

By the way, since I have just looked into this:

Java (starting with OpenJDK ≥ 7) correctly realizes that the tray manager has gone away and passes that on via its API. This means it will send a PropertyChangeEvent with which the programmer can notice that the tray icons have been deleted and should be re-added.

It seems like JDownloader and others don’t do that and therefore have a somewhat buggy system tray behavior. If someone wants to fix it and bring that fix upstream, I’d welcome that.

Here is my proof of concept:

import java.awt.AWTException;
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

class MiniTray {
    public static void main(String[] args) {
        final SystemTray systemTray = SystemTray.getSystemTray();

        Image i = Toolkit.getDefaultToolkit().getImage(
                "/usr/share/icons/xmonad.png");
        final TrayIcon trayIcon = new TrayIcon(i, "Tray Demo", null);

        PropertyChangeListener pcl;
        pcl = new PropertyChangeListener() {
            @…   
            public void propertyChange(PropertyChangeEvent pce) {
                TrayIcon[] tia = (TrayIcon[]) pce.getNewValue();
                if (tia != null && tia.length == 0) {
                    try {               
                        systemTray.add(trayIcon);
                    } catch (AWTException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();    
                    }                   
                }               
            }           
        };      
        systemTray.addPropertyChangeListener("trayIcons", pcl);

        try {   
            systemTray.add(trayIcon);
        } catch (AWTException e) {
            System.err.println("could not add");
        }       

        while (true) {
            try {       
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }           
        }       
    }   
}

@stapelberg
Copy link
Member

This ticket was fixed in commit http://c.i3wm.org/e9503a1f:

i3bar: fake DestroyNotify and send MANAGER ClientMessages to fix tray restarts

fixes #745

@i3bot
Copy link
Author

i3bot commented Jan 2, 2013

[Original comment by angus@…]

Seems to work for me too. Thanks.

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

No branches or pull requests

2 participants