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

Corrupted tray icons after restarting of Awesome #1720

Open
aminought opened this issue Apr 12, 2017 · 38 comments
Open

Corrupted tray icons after restarting of Awesome #1720

aminought opened this issue Apr 12, 2017 · 38 comments

Comments

@aminought
Copy link

Output of awesome --version:

awesome v4.1 (Technologic)
• Compiled against Lua 5.1.5 (running with Lua 5.1)
• D-Bus support: ✔
• execinfo support: ✔
• xcb-randr version: 1.4
• LGI version: 0.9.0

How to reproduce the issue:

  1. Start Telegram or Dropbox.
    screenshot from 2017-04-12 20-37-21
  2. Restart Awesome.

Actual result:

screenshot from 2017-04-12 20-38-23

Expected result:

screenshot from 2017-04-12 20-37-21

@psychon
Copy link
Member

psychon commented Apr 12, 2017

I know that this isn't helping anyone, but I'll still mention it: Awesome only places the tray icons, it does not draw them.

Start Telegram or Dropbox.

As far as I know, Dropbox uses Qt. Does Telegram do, too? What is creating the third icon, which apparently does not have this problem?

@aminought
Copy link
Author

Yes, Telegram uses Qt too. The third app is Slack, I don't know what toolkit it uses. Okey, I get it, but what I don't understand is how other window managers and desktop environments properly shows its tray icons?

@aminought
Copy link
Author

aminought commented Apr 13, 2017

It somehow depends on a tray width. Awesome shows tray icons normally if I set tray.forced_width.

@sw9
Copy link

sw9 commented Apr 25, 2017

I believe the reason for the corrupted tray icons is that awesome wm doesn't support or advertise support for alpha channels for tray icons. Qt checks for this, and when it isn't supported, it tries to grab the background behind the icons and do the compositing itself. And I guess when restarting awesome, it grabs the background too early or something to that effect.

@psychon
Copy link
Member

psychon commented Apr 25, 2017

@sw9 Yup, that's correct. However, the systray spec (I guess) means to have systray icons in a flickering manner: You first clear the background (this can be done without actually knowing what the background is) and then draw your icon ontop. This kind of drawing is sadly incompatible with anything modern. I guess Gtk works around its drawing model here while Qt tries to force things in the other direction...

And no, I don't want to turn awesome into a compositing manager. Not even for the systray.

@spheenik
Copy link

spheenik commented Jun 1, 2017

Well then, wouldn't the smart way to fix this be to somehow delay QT grabbing stuff?

@Konfekt
Copy link

Konfekt commented Jun 5, 2018

@spheenik Yes, now I understand why I had to add a sleep 3s before every (QT) application (such as copyq) before autostarting it.

@AGCaesar
Copy link

AGCaesar commented Sep 25, 2018

I had the same problem, installed https://github.com/TomaszGasior/gtk3-mushrooms and now it works great :)

@kopr12
Copy link

kopr12 commented Oct 23, 2018

It somehow depends on a tray width. Awesome shows tray icons normally if I set tray.forced_width.

This helped in my case as well.

@thfr
Copy link

thfr commented Nov 29, 2018

For tracking purposes:

@anjannath
Copy link

It somehow depends on a tray width. Awesome shows tray icons normally if I set tray.forced_width.

This helped in my case as well.

Did not help in my case, i use NetworkManager and the applet nm-applet, in the tray it shows both connected and disconnected icons overlapped on each other, have the same issue with other systray icons, viz. riot, mattermost, slack all of these icons are not rendered properly.

@thfr
Copy link

thfr commented Feb 22, 2019

According to https://gitlab.gnome.org/GNOME/gtk/commit/e3a1593a0984cc0156ec1892a46af8f256a64878 this bug should be fixed with GTK 3.24.3 .

@arielnmz
Copy link

Can someone explain why if this is related to GTK rather than Awesome, it does not happen with XFCE, Gnome, KDE, etc?

@anjannath
Copy link

anjannath commented Mar 14, 2019 via email

@arielnmz
Copy link

Hmmm... seems that setting a forced width helps a bit
https://awesomewm.org/doc/api/classes/wibox.widget.systray.html#wibox.widget.systray.forced_width 
This is how it looks right after restarting awesome 

image

And this happens if you hide → unhide the wibar 

image

The background seems to leak through. setting the background to a solid color (e.g "#ff0000"), "alpha" or anything, actually, doesn't help at all...

@psychon
Copy link
Member

psychon commented Mar 15, 2019

Can someone explain why if this is related to GTK rather than Awesome, it does not happen with XFCE, Gnome, KDE, etc?

If you want me to guess:

AwesomeWM is not a a WM+compositing manager, but only a WM. Thus, we do how tray icons where always done. With the invention of compositing and the compositing X11 extension, the systray specification was changed so that one can also use compositing for systray icons. With that, systray icons can just do "this is a transparent background" instead of having the traditional thing of getting the real background and drawing ontop of that. Now, changes in toolkits could break the "traditional systray icon stuff" and DE users would not notice.

The big guess here is now that Gnome, KDE (these two I'm pretty sure about), and XFCE (dunno about this one) use this "compositing stuff" while AwesomeWM does not.

Does this answer your question?

Systray icon spec: https://standards.freedesktop.org/systemtray-spec/systemtray-spec-latest.html
_NET_SYSTEM_TRAY_VISUAL is the relevant property for compositioning:

If this property is set to a visual with an alpha channel, the tray manager must use the Composite extension to composite the icon against the background using PictOpOver.

@anjannath
Copy link

anjannath commented Mar 15, 2019 via email

@arielnmz
Copy link

arielnmz commented Mar 15, 2019 via email

@psychon
Copy link
Member

psychon commented Mar 15, 2019

So in principle if we use a composite manage like compton with awesome, that should fix the problem?

In theory, that would be possible. In practice, it is not, because the spec does not allow things like "I previously did not support transparency, but now I suddenly do" (= compositing manager was just started). Thus, AwesomeWM always has to announce "I do not support tray icon transparency". And if the spec would allow that, no one would implement it correctly anyway, because no one would test this code...

@arielnmz
Copy link

What would it take to change the spec to fix this? What are XFCE, MATE, Gnome, etc., doing right, then? I might take a look into this but could someone put me up to speed in this matter?

@anjannath
Copy link

anjannath commented Mar 15, 2019 via email

@psychon
Copy link
Member

psychon commented Mar 15, 2019

What would it take to change the spec to fix this?

A time machine to change the spec before it is finalised (and some good arguments to convince people that the added complexity is worth it). I doubt a lot that the powers that be are interested in changes to the spec. And I doubt more that toolkits authors would update their code due to changes to the spec. Everyone rather focuses on wayland.

(GTK 4 even dropped support for tray icons, didn't they?)

What are XFCE, MATE, Gnome, etc., doing right, then?

They have built-in compositing managers and so there is no problem in saying "transparency support is available", because that support cannot suddenly go away due to pkill xcompmgr.


Anyway, to come back to something a bit more productive than time machines: Which version of stuff still has problems? I thought the regressions in GTK where fixed quickly and Qt does some drawing through the RENDER extension these days to make transparency work properly (git says: since version v5.12.0-alpha1~397).

@arielnmz
Copy link

I doubt a lot that the powers that be are interested in changes to the spec.

I doubt this issue would mean an entire rewrite of the spec, but I'd have to take a look though... I'm no expert but I also don't think that forking the project and adding a quick fix just for the people that are interested in it would have to have the attention of the "powers that be". I want to be clear: I'm not asking for anyone to do it, I just want to know if hacking it a bit would at least be possible.

They have built-in compositing managers and so there is no problem in saying "transparency support is available", because that support cannot suddenly go away due to pkill xcompmgr.

True but what'd be problem of making a little switch that lets people compile or start awesome with the "I have transparency support" flag always on, expecting users have a compositing manager e.g. compton? Why do icons still work when switching off window compositing (at least with XFCE)?

@psychon
Copy link
Member

psychon commented Mar 16, 2019

Why do icons still work when switching off window compositing (at least with XFCE)?

Oh, wow. I'm stupid. One cannot change the "supports transparency"-flag of an already-running systray. However, one can just get rid of the systray and set up a new one:
https://git.xfce.org/xfce/xfce4-panel/tree/plugins/systray/systray.c?id=5ceb4057a2e4c6136b7884ad649dd95f1c71aabf#n475

@psychon
Copy link
Member

psychon commented Mar 17, 2019

Here's some real transparency in a systray icon (running with compton). Note that we just get whatever-is-behind-the-wibar as background here and not the wibar's content.

diff --git a/awesomerc.lua b/awesomerc.lua
index fa584b8a8..9f9e31b73 100644
--- a/awesomerc.lua
+++ b/awesomerc.lua
@@ -216,15 +216,16 @@ awful.screen.connect_for_each_screen(function(s)
 
     -- @DOC_SETUP_WIDGETS@
     -- Add widgets to the wibox
+    s.mywibox.height = 30
     s.mywibox:setup {
         layout = wibox.layout.align.horizontal,
         { -- Left widgets
             layout = wibox.layout.fixed.horizontal,
             mylauncher,
-            s.mytaglist,
+            --s.mytaglist,
             s.mypromptbox,
         },
-        s.mytasklist, -- Middle widget
+        nil, --s.mytasklist, -- Middle widget
         { -- Right widgets
             layout = wibox.layout.fixed.horizontal,
             mykeyboardlayout,
@@ -233,6 +234,12 @@ awful.screen.connect_for_each_screen(function(s)
             s.mylayoutbox,
         },
     }
+    s.mywibox:set_bg(beautiful.bg_normal .. '80')
+    s.mywibox.ontop = true
+    gears.timer.start_new(1, function()
+        awesome.systray(s.mywibox.drawin, 0, 0, 20, false, '#ff0000', false, 0)
+        return true
+    end)
 end)
 -- }}}
 
diff --git a/common/atoms.list b/common/atoms.list
index 9cf41336e..2061fb743 100644
--- a/common/atoms.list
+++ b/common/atoms.list
@@ -57,6 +57,7 @@ ESETROOT_PMAP_ID
 WM_STATE
 _NET_WM_WINDOW_OPACITY
 _NET_SYSTEM_TRAY_ORIENTATION
+_NET_SYSTEM_TRAY_VISUAL
 WM_CHANGE_STATE
 WM_WINDOW_ROLE
 WM_CLIENT_LEADER
diff --git a/systray.c b/systray.c
index c3919ee3b..beca7b23f 100644
--- a/systray.c
+++ b/systray.c
@@ -44,15 +44,16 @@ systray_init(void)
 
     globalconf.systray.window = xcb_generate_id(globalconf.connection);
     globalconf.systray.background_pixel = xscreen->black_pixel;
-    xcb_create_window(globalconf.connection, xscreen->root_depth,
+    xcb_create_window(globalconf.connection, globalconf.default_depth,
                       globalconf.systray.window,
                       xscreen->root,
                       -1, -1, 1, 1, 0,
-                      XCB_COPY_FROM_PARENT, xscreen->root_visual,
-                      XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, (const uint32_t [])
-                      { xscreen->black_pixel, XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT });
+                      XCB_COPY_FROM_PARENT, globalconf.visual->visual_id,
+                      XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP, (const uint32_t [])
+                      { xscreen->black_pixel, xscreen->black_pixel, XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, globalconf.default_cmap });
     xwindow_set_class_instance(globalconf.systray.window);
     xwindow_set_name_static(globalconf.systray.window, "Awesome systray window");
+    xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, globalconf.systray.window, _NET_SYSTEM_TRAY_VISUAL, XCB_ATOM_VISUALID, 32, 1, (uint32_t[]) { globalconf.visual->visual_id });
 
     atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", globalconf.default_screen);
     if(!atom_name)

screen

@psychon
Copy link
Member

psychon commented Mar 17, 2019

Another "Argh": xfce-panel does indeed composite the tray icons itself without any interaction with the compositing manager: https://git.xfce.org/xfce/xfce4-panel/tree/plugins/systray/systray.c?id=5ceb4057a2e4c6136b7884ad649dd95f1c71aabf#n715
This seems to be enabled somwhere around here: https://git.xfce.org/xfce/xfce4-panel/tree/plugins/systray/systray-socket.c?id=5ceb4057a2e4c6136b7884ad649dd95f1c71aabf#n151

@Kukunin
Copy link

Kukunin commented Jun 7, 2019

Just want to report my case:

my tray

I use Manjaro, AwesomeWM within XFCE. The tray is in xfce-panel (I disabled it from AwesomeWM), but still have the problems with rendering (take a look into nm-applet icon, dropbox etc).

It doesn't appear in xfwm though.

I wonder how AwesomeWM still affects on it, if assumably xfce-panel does composition for themself. Does it report that tray composition is enable or it's still the awesome's job?

@doronbehar
Copy link

Hey, I'd like to report my case as well. I've had this issue back when I used Arch Linux but I've moved to NixOS and I don't experience this issue anymore. I'm using a normal AwesomeWM installation without XFCE or Gnome. I've also experienced back then #2606 and I don't experience it anymore.

Long live reproducible builds!

@h1nk
Copy link

h1nk commented Oct 27, 2019

So are there any tl;dr work arounds or patches to apply in order to remedy this issue? I've been sick of having to see corrupted tray icons for years now.

@aminought
Copy link
Author

Yes: i3

@h1nk
Copy link

h1nk commented Nov 8, 2019

As already noted by others in this issue i3 has the same problem too: i3/i3#3335 (comment)

@Kukunin
Copy link

Kukunin commented Nov 10, 2019

I'm not sure what was changed, but for me on Archlinux, xfce4 with AwesomeWM, tray icons stopped corrupting (tray is in xfce4-panel for me). I haven't touched my config for a while.

It looks like something was fixed whether on GTK side or Xfce or AwesomeWM.

image

@danielmorlock
Copy link

danielmorlock commented Nov 10, 2019 via email

@Kukunin
Copy link

Kukunin commented Nov 10, 2019

I have Manjaro (based on Archlinux):

  • awesome wm: 4.3-1
  • xfce4-panel: 4.14.1-1.1
  • libxfce4ui: 4.14.1-2.1
  • xorg-server: 1.20.5-4.1
  • gtk2: 2.24.32-1
  • gtk3-classic: 3.24.12-1

I'm sorry, I'm not an expert so I might have not provided all related versions. I'll happily provide extra info, just tell me what.

P.S. Noticed that gtk3 is patched: https://github.com/krumelmonster/gtk3-mushrooms

@spheenik
Copy link

Just to add myself to the list -> seems fixed in current Arch (I could normally easily reproduce by just restarting Awesome once - doing so now the icons are still intact...)

@actionless
Copy link
Member

actionless commented Nov 10, 2019

i still can reproduce on the latest arch install

just make tray hide/unhide several times and background will scramble underneath Qt icons

(ie literally the problem with Dropbox background from the first post is still reproducible for me)

@mxmilkiib
Copy link

Might there be some way to automate resizing the tray when an icon is added or removed?

@cluxter
Copy link

cluxter commented Feb 6, 2023

Using NixOS 22.11 here with xfce4 and I also have the same issue than everyone else in this thread. This is quite annoying. At least I'm glad that I found the right thread about this bug.

EDIT: I found a way to solve this issue. Instead of running the default command which is nm-applet, run nm-applet --indicator. Works like a charm.

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

No branches or pull requests