Closed twitham1 closed 1 year ago
Hi Tim, do you have a setup where i can reproduce the problem you"re trying to fix? The reason is that i only recently changed mask depth from 1 to display depth exactly because icon background was garbled on ubuntu/mate. So I studied gtk code which did that thing with mask depth which was the only thing that worked. Or the other way round, you might want to test the patch on ubuntu to see if it gets correct results.
Interesting, I see that change now on August 10. I thought I had black or random background since I first used an icon in May, but maybe I am wrong and it broke in August. I couldn't get transparent until I changed the mask depth back to 1.
So MATE behaves opposite? I'm running XFCE on Ubuntu 20.04 and my guts.depth is 24. It seems really strange for 1 bit depth to not work for mask, since the pixels are simply on or off.
I wonder if it depends on how the icon is generated? I'm using Prima to auto-generate the mask bits of the region I draw. I even wrote out the pixmap and mask to files to prove they were individually correct.
Perhaps I could write a small test program.
Not only a test program, but also see if your setup is x11 or wayland. Yesterday I tested icons on latest ubuntu and wasted several hours trying to figure our how come xterm and gvim display proper icons while a test program shows a generic icon. Apparently wayland has no way of setting a program icon at all and apps use some hacky binding between their class and separately installed images.
If you will be able to produce a test program I can try it on my setup, where I remember it was finally working after changing from 1 bit to 24.
that's how it looks on my ubuntu/mate 22.04 - firefox and gvim have a proper icon, while xterm has a broken one. If I change depth to 1, my icons get broken exactly the same way as xterm's
Wow, that's amazing. I always thought the very definition of mask was 1 bit! Maybe newer system wants partially transparent application icon? I'm still on x11. Haven't got to wayland yet.
https://raw.githubusercontent.com/twitham1/LPDB/dev/bin/icontest
depth 1: vs guts.depth=24:
xterm:
I wonder if in my case something is not translated to 24 bit in the prima_put_ximage(image_cache.icon) line. Is that where the 1 bit prima icon mask gets changed to 24 bits?
Hey, guess what? guts.idepth (32) works for me! Could it be used instead? If it works in your cases?
- and = XCreatePixmap( DISP, guts. root, i-> w, i-> h, guts.depth);
+ /* 1 and guts.idepth works for me, but guts.depth works for others */
+ and = XCreatePixmap( DISP, guts. root, i-> w, i-> h, guts.idepth);
+ warn("in window.c: depth=%d, idepth=%d", guts.depth, guts.idepth);
in window.c: depth=24, idepth=32 at /usr/local/lib/x86_64-linux-gnu/perl/5.30.0/Prima/Classes.pm line 264.
Hmm no, that doesn't work for me - 32 bit (or idepth) masks result in empty image being shown. 24 or guts.depth works fine, still. I tried to experiment around and the only useful thing I found that the mask gets treated as a 1-bit mask even though it is 24-bit, i e no alpha channel.
It would be interesting to test on your system how it shows f ex gvim/gtk icon that works fine on my system apparently by using non-1-bit depth mask pixmaps (Or some other icons with transparency, f.ex. firefox/thunderbird/whatever?). I also know that xterm uses 1-bpp pixmaps and it shows garbled on my system ( so yours is more correct in that regard about 1-bpp masks).
(wasting some hours reading about Wayland)
I assume XWM gets our icon from Xwayland since our random Prima app doesn't have any icon lines in /usr/share/applications/*.desktop pointing to /usr/share/pixmaps. You're right, this method is way different! Maybe this is sort of a bug in XWM.
I see how these .desktop metadata files are better in some ways as other apps (launchers, menus, search) can look there to know about applications in advance, including their icons. Maybe we could drop our icons in there and write a .desktop file that would work. To go full native wayland, seems like Prima would need an option to use all GTK calls rather than X11, which I assume would be a ton of work!
Meanwhile back here on old Xorg, non-rectangle application icons work, I haven't found any that don't. But it is possible my XFCE is also using those .desktop files to find the icons for modern apps rather than using the old X11 WM hints.
One of these days I should upgrade my other box to Ubuntu 22.04 then I could experiment.
I don't like Wayland but that's apparently the way of the future. If Prima to support Wayland natively I would not use gtk since there are lots of subtle undercurrent problems ( f ex threads ), plus I can cut many corners when implementing some stuff. However, if Prima detects wayland it can do some wayland-specific stuff. I just think that the icons are not shown is not as much a Prima problem but XWayland<->Wayland problem, where XWayland either doesn't know how or has no ability to respect SetWMHints that contains an icon. I'm not even sure there's a possibility to make a dynamic icon in Wayland, with this *.desktop idiocy. Anyway, wayland is too immature, so I'd hide behind XWayland but would implement some Wayland-specific stuff that doesn't work otherwise, f ex icons - if I would find out how
Ok, so if 1 bit icon mask worked in X11 for 3 decades and only breaks with wayland, then perhaps we should stick with 1 bit? Or as you say, conditional: wayland ? 24 : 1.
Ideally owners of the wayland compositor's XWM or WMM should fix their bug of not understanding the simple 1 bit mask from Xwayland. I think they get the icon from wm hints since it works with the hacked 24 bit depth, without needing the silly .desktop hacks.
Xwayland should be around basically forever to support all X clients. So I agree there is not much reason to go native. If it matures enough to be worthwhile someday, there are several toolkits to choose from.
Right, its not quite the way you put it, and i dont want to be pedantic about it, but id like to sum it up if the issue will be referenced again.
Hi Tim,
I just found out that there's a parallel (or a more modern) standard from window icons, NET_WM_ICON, and I tried to set that icon as well. I also tried that on xfce setup, looks okay. Could you check it out and see if that fix works for you?
/dk
Yes, this works! I discovered that xprop can even show this icon.
I saw your comment about rectangle so I tweaked my icontest to try random ratios. Square and portrait always work but landscape sometimes swaps left and right side like this
This might be a WM bug or icon limitation. We can simply use square icons. With this new icon, we can close this since the hint mask is apparently no longer used.
I think I fixed that now
Yes, you fixed even that! All my random shape and size icons work now.
Thank you for your patience and work in getting the window icon upgraded!
This lets the icon mask give the expected transparent background rather than black or random.
The key was switching the mask to a 1 bit depth, an idea I got from studying prima_create_icon_pixmaps in image.c. This passes make test for me and yields the correct application icon for my bin/lpgallery.