mate-desktop / mate-panel

MATE panel
https://mate-desktop.org
GNU General Public License v2.0
184 stars 118 forks source link

wayland tasklist: fit buttons to tasklist, limit button size, hide contents as necessary #1395

Closed lukefromdc closed 1 year ago

lukefromdc commented 1 year ago

Empty space between buttons removed padding in buttons similar to x11 Horizontal panel: expand buttons like in X11 until more expanded buttons won't fit When expanded buttons won't fit, resize buttons to fit contents. Almost same behavior as x11 in hiding first labels, then icons with compressed labels returning as more buttons are added.

lukefromdc commented 1 year ago

This builds on my earlier work in https://github.com/mate-desktop/mate-panel/pull/1388 which made the tasklist basically usable but still able to overflow onto the rest of the panel if enough windows (usually 20+) were open. Note that 5 windows each on 4 workspaces is enough to put 20 buttons in the tasklist unless we find a way to show them per-workspace using wlroots.

This further work allows the tasklist to behave more more like it does on x11, with one exception: we have a working window list on vertical panels with this applied and probably without it as well on wayland but not on x11. It stacks horizonal buttons one atop the other. On x11 a tasklist on a vertical panel is a tiny scaled down horizontal tasklist!

On a window list on a horizontal panel, this restores full width tasklist buttons when only a few are showing, the defined dimension is larger as it's for the whole button not just the label. This is the "never exceed" button width. In addition the internal padding around the icon has been made comparable to what we see in x11

When buttons that wide don't fit, this resizes them to the tasklist allocated width divided by the number of buttons, giving a close though not perfect fit as buttons are added or removed due to some issues with the allocated tasklist size changing with the number and width of buttons.

When there are so many buttons the internals no longer fit, this hides first the label, visually similar to behavior in x11 where the icon seems to be draw over the now greately compressed label. On Wayland, when the icon won't fit anymore with one more button, we hide the icon but restore the label, which in x11 is simply still there after the icon is hidden

As windows are closed and the number of buttons is reduced, this entire process is reversed.

Note that 50+ buttons in 700px or comparable can still overflow the panel, I have yet to find a way to fix that without emptying the buttons entirely, which would turn them invisible in themes that don't put borders on the buttons, such as Menta. I would need a way to unconditionally limit the width of the three dots only label (maybe scale it?) to allow an infinate number of buttons.

I didn't find an exposed way in the foreign toplevel code we are using to identify the workspace a window is on so we can split up the tasklist buttons by workspace like we optionally do on x11

lukefromdc commented 1 year ago

To test, build and install, and start up wayfire on another VT (or from SDDM or GDM etc.) and start adding more and more open windows, using any launcher on the panel for something that starts up fast like mate-terminal. Put a mate-terminal launcher on the panel (or on Caja's desktop where it responds more quickly) and click away while watching the buttons on the tasklist. Watch for any issues with "pushing" the other applets around, and try different panel heights.

raveit65 commented 1 year ago

Beside from boring code-formatting issues caused mostly by copy&paste, the tasklist work fine under wayfire. Tested with openning > 30 windows.

lukefromdc commented 1 year ago

I will clean the spaces issue and force-push, then save a diff file from this locally in case we want to close this on grounds of complexity to support a feature that will be used by some but may not be used a lot.

If we close this, I will open an alternate PR to remove some wasted space between buttons that can be seen only in themes drawing borders around buttons. That part is extremely simple and will provide a bit more space.

On my panel with current git master, it took a bit over 20 window buttons to start pushing applets, up from 4 or 5 with the original code. I had to factor in a case I myself have used: a netbook or other small screen with one panel and only room for two of x11's full width window buttons. I will recheck those figures with Menta and also after just removing the wasted space

This was written to support extreme numbers of buttons, though I do NOT know how many window buttons users actually need the panel to handle properly. Other thing I did was to "pretty up" the window list when small numbers of buttons are showing, with partially expanded buttons while they fit like in x11.

One thing libwnck did different: they found a way to let the icon render OVER the text when things get tight, then remove the icon when it no longer fits, at which point the window list is no longer very useful. They also found a way to let text ellipsize much smaller than we were getting.

If I can just get text to ellipsize without limit like in wnck-tasklist, I can open an alternate PR to this that does not do anything requiring looped code to iterate over all buttons. This is done in wnck-tasklist, but only to hide or show the icon. I can also look at how they got the icon to render over the severely compressed label on crowded tasklists.

It's quite likely that no matter what we do short of supporting an infinate number of no longer useful buttons (which not even this does but wnck-tasklist seems to do) someone will open enough windows to push applets, then file a bug report