awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.39k stars 597 forks source link

Corrupted tray icons after restarting of Awesome #1720

Open aminought opened 7 years ago

aminought commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

sw9 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

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

Konfekt commented 6 years ago

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

AGCaesar commented 6 years ago

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

kopr12 commented 6 years ago

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 commented 5 years ago

For tracking purposes:

anjannath commented 5 years ago

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 commented 5 years ago

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

arielnmz commented 5 years ago

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

anjannath commented 5 years ago

TBH i have seen this bug in i3 also, i guess it depends on the tray, for me nm-applet tray icon misbehaves in both i3 and awesome.

On Fri, Mar 15, 2019, 03:36 Benjamín Ariel Nava Martínez < notifications@github.com> wrote:

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

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/awesomeWM/awesome/issues/1720#issuecomment-473083842, or mute the thread https://github.com/notifications/unsubscribe-auth/AIeV7uEvj1vQucWm_y0Yg_vjPE0JjLAHks5vWsfogaJpZM4M7m0S .

arielnmz commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

On Fri, Mar 15, 2019, 12:51 Uli Schlachter notifications@github.com wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/awesomeWM/awesome/issues/1720#issuecomment-473184118, or mute the thread https://github.com/notifications/unsubscribe-auth/AIeV7jaco7oxWYD44279aPJzdvNugaigks5vW0oJgaJpZM4M7m0S .

arielnmz commented 5 years ago

Nope, I'm using compton, actually

01:25, 15 de marzo de 2019, Anjan Nath notifications@github.com:So in principle if we use a composite manage like compton with awesome, that should fix the problem?

On Fri, Mar 15, 2019, 12:51 Uli Schlachter notifications@github.com wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/awesomeWM/awesome/issues/1720#issuecomment-473184118, or mute the thread https://github.com/notifications/unsubscribe-auth/AIeV7jaco7oxWYD44279aPJzdvNugaigks5vW0oJgaJpZM4M7m0S .

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.

-- Sent from Yandex.Mail for mobile

psychon commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

+1

On Sat, Mar 16, 2019, 00:03 Benjamín Ariel Nava Martínez < notifications@github.com> wrote:

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?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/awesomeWM/awesome/issues/1720#issuecomment-473397357, or mute the thread https://github.com/notifications/unsubscribe-auth/AIeV7uuu9qEQZ_F_ET8qyNWpa70mE2vzks5vW-dcgaJpZM4M7m0S .

psychon commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

Yes: i3

h1nk commented 5 years ago

As already noted by others in this issue i3 has the same problem too: https://github.com/i3/i3/issues/3335#issuecomment-408155406

Kukunin commented 5 years ago

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 commented 5 years ago

Can you post the versions you use? Thanks!

Am 10. November 2019 10:13:32 MEZ schrieb Sergey Kukunin notifications@github.com:

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

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/awesomeWM/awesome/issues/1720#issuecomment-552176887

Kukunin commented 5 years ago

I have Manjaro (based on Archlinux):

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 commented 5 years ago

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 commented 5 years ago

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 commented 3 years ago

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

cluxter commented 1 year ago

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.