You are not logged in.
Hi everyone! First time writing on the xfce forum but I love and use xfce (or at least some of its components) since ~20 years now
Some years ago, I developed a small plugin for xfce4-panel that shows in a label the title of the window in my i3wm session.
Yeah, I know, I use i3 instead of xfwm4. Hope this is not a problem
This plugin is extremely simple, it has no configuration and just subscribes to the i3ipc for window events and updates the label with the title of the currently focused window. The code is here: https://github.com/carmelopellegrino/xf … tle-plugin
This plugin used to work until last December, when I updated my Arch installation to xfce-panel v4.20. Specifically, the text that was left justified is now centered and truncated (via pango ellipsization) to very few characters.
Here is a visual example:
Rendering of the plugin in xfce4-panel 4.18
Rendering of the plugin in xfce4-panel 4.20
I struggled during the past months to work around this issue without any luck. I've tried several tricks, like adding the GtkLabel to a GtkBox or other container, setting expand it to expand to the maximum length, etc... Nothing worked.
Is there any breaking change in the way plugin sizes are handled in xfce4-panel 4.20? Am I missing any GTK3 special setting?
One strange thing I see is that the xfce_panel_plugin_get_size() function always returns 16, which is not the size of the panel or of the icons.
Thank you for any help and have a nice day!
Last edited by budda (2025-05-28 17:41:12)
Offline
Is there any breaking change in the way plugin sizes are handled in xfce4-panel 4.20?
Not that I recall, and no such problems have been reported to date, although something must have changed somewhere for you to get this behavior.
You can try playing with `gtk_label_set_xalign` for left alignment, and `gtk_label_set(_max)?_width_chars` for ellipsizing.
Xfce maintainer: https://gravatar.com/gaelbonithon
Offline
Hi! Yes, I have already a:
gtk_label_set_xalign(i3wmtp->title, 0.);
line in my constructor - it has no effect - and played around with gtk_label_set_width_chars, but without a proper value to set it doesn't do the proper thing, i.e. if I set a large value, like 2000, all icons on the right just go away from the screen border. If I set a smaller value, say 100, it ellipsizes to the very same short amount. gtk_label_set_max_width_chars seems to do nothing.
It may have something to do with xfce_panel_plugin_get_size() returning always 16. If I increase the number of rows in the panel preferences, my plugin shows increasingly more text.
Do you think this is worth opening a ticket on gitlab?
Offline
No, I don't think so. Does `xfce_panel_plugin_get_size` always return 16 in `i3constructor`? It's probably too early to do that, you should probably connect to the XfcePanelPlugin::size-changed signal.
Xfce maintainer: https://gravatar.com/gaelbonithon
Offline
Yes, the call to xfce_panel_plugin_get_size() was in the constructor, so I've done what you suggested:
static
gboolean size_changed(XfcePanelPlugin *plugin, gint size, i3WindowTitlePlugin *i3wmtp)
{
printf("size changed: %d\n", size);
printf("size of the panel: %d\n", xfce_panel_plugin_get_size(plugin));
return FALSE;
}
static
void i3constructor(XfcePanelPlugin* plugin) {
[...]
g_signal_connect(G_OBJECT(plugin), "size-changed", G_CALLBACK(size_changed), NULL);
}
Then I launched the panel with `PANEL_DEBUG=1 xfce4-panel -d`, getting 32 being printed out as the initial value, which is the vertical size of my horizontal bar. It always prints the vertical size of the bar, confirmed by changing either the row size or the number of rows in the panel settings. The same comes out from the second printf.
Also, in the documentation https://developer.xfce.org/xfce4-panel/ … n-get-size is written that the xfce_panel_plugin_get_size() function is supposed to return the size of the panel the plugin is embedded in, not the plugin itself.
Is there a way, either GTK-native or XFCE-specific, to get the space allocated to a plugin?
Added later 2 h 54 min 31 s:
I've found this comment in the panel-plugin source code:
https://gitlab.xfce.org/xfce/xfce4-pane … heads#L922
/* PluginExternal is a GtkBox since 4.19.0 so it must be oriented with the panel to not
* allow the remote plug to expand in the wrong direction */
could this be the change (specifically that a GtkBox is now in use) that broke the display of the label?
Offline
Is there a way, either GTK-native or XFCE-specific, to get the space allocated to a plugin?
`gtk_widget_get_allocation`
I've found this comment in the panel-plugin source code:
https://gitlab.xfce.org/xfce/xfce4-pane … heads#L922
/* PluginExternal is a GtkBox since 4.19.0 so it must be oriented with the panel to not * allow the remote plug to expand in the wrong direction */
could this be the change (specifically that a GtkBox is now in use) that broke the display of the label?
Maybe yes (not sure though), but you should be able to work it out downstream anyway. I'm curious to know what could have caused this change, but I don't have time to test your code, sorry.
Xfce maintainer: https://gravatar.com/gaelbonithon
Offline
Hi @Tamaranch,
I think I've found the reason why my plugin stopped working as usual!
Long story short: by setting the fill argument in this line https://gitlab.xfce.org/xfce/xfce4-pane … x11.c#L104 from `FALSE` to `TRUE` in the xfce4-panel's plugin-external-wrapper-x11 and recompiling, everything started working as in 4.18!
Now I'm running a self-compiled version of the package with this little change and I use many plugins:
- Whisker menu
- Launcher
- Screenshot
- CPU Graph
- System Load Monitor
- Sensor plugin
- MPD Client Plugin
- PulseAudio Plugin
- Clock
- Notification Plugin
- Clipman
- Status Tray Plugin
- Separator
- i3 Workspaces Plugin
- Docklike Taskbar
and I don't see any issue whatsoever with them.
Is there any technical reason for setting the fill argument to `FALSE` in that function call? Could I suggest to set it to `TRUE` in future releases? And how?
Thanks!
Offline
These are the default options when inserting into a box, and I'm afraid changing them will have side effects. Does using `gtk_widget_set_hexpand` in your code solve the problem by keeping the panel code as is?
Xfce maintainer: https://gravatar.com/gaelbonithon
Offline
I understand your concerns
I've just tried by calling `gtk_widget_set_hexpand(widget, TRUE)` against both the `plugin` and the `label` objects, casting them with the `GTK_WIDGET` macro:
$ git diff
diff --git a/plugin/i3wm-window-title.c b/plugin/i3wm-window-title.c
index 0a90433..a3d48f0 100644
--- a/plugin/i3wm-window-title.c
+++ b/plugin/i3wm-window-title.c
@@ -91,6 +91,8 @@ void i3constructor(XfcePanelPlugin* plugin) {
g_signal_connect(G_OBJECT(reconnect_button), "activate", G_CALLBACK(on_reconnect), i3wmtp);
gtk_container_add(GTK_CONTAINER(plugin), label);
gtk_widget_show_all(GTK_WIDGET(plugin));
+ gtk_widget_set_hexpand(GTK_WIDGET(plugin), TRUE);
+ gtk_widget_set_hexpand(GTK_WIDGET(label), TRUE);
xfce_panel_plugin_set_expand(plugin, TRUE);
}
and reinstalled the package shipping xfce4-panel that is provided by the distribution. Unfortunately, the issue came back
Added later 06 min 47 s:
Also, to ease the debug and reproducibility of the problem, I've prepared a simplified version of the plugin and uploaded it to github: https://github.com/carmelopellegrino/xfce4-label-plugin
I've there stripped any reference to i3wm and made the label a static string containing the text "Un titolo", the Italian for "A title"
Offline
I'm beginning to think that it would be reasonable to change this value to TRUE in the panel code in fact, I'm just a little surprised that the problem hasn't already arisen for another plugin using a label in the same way, but I don't have an example to hand indeed.
I'm looking at something else for now, I'll be back to tell you about it later.
Xfce maintainer: https://gravatar.com/gaelbonithon
Offline
Having the fill value set to TRUE would be ideal, at least for me Thanks for considering!
I can also add that also the windowck plugin (https://docs.xfce.org/panel-plugins/xfc … ugin/start) kind of suffers from this issue as it also can expand and ellipsize the string.
Settings:
Rendering with fill=FALSE
Rendering with fill=TRUE
Offline
I'd thought of this one too but I can't get it to expand, even with fill set to TRUE. What version of xfce4-panel and xfce4-windowck-plugin are you using?
Xfce maintainer: https://gravatar.com/gaelbonithon
Offline
I think the latest release of both:
$ xfce4-panel --version
xfce4-panel 4.20.4 (Xfce 4.20)
Copyright (c) 2004-2025
The Xfce development team. All rights reserved.
Please report bugs to <https://gitlab.xfce.org/xfce/xfce4-panel/-/issues>.
and:
$ pacman -Qi xfce4-windowck-plugin
Name : xfce4-windowck-plugin
Version : 1:0.5.2-1
Description : Xfce panel plugin for displaying window title and buttons
Architecture : x86_64
URL : https://docs.xfce.org/panel-plugins/xfce4-windowck-plugin/start
Licenses : GPL-3.0-only
Groups : None
Provides : None
Depends On : xfce4-panel libwnck3
Optional Deps : None
Required By : None
Optional For : None
Conflicts With : None
Replaces : None
Installed Size : 334.77 KiB
Packager : Evangelos Foutras <foutrelis@archlinux.org>
Build Date : Sun Dec 29 16:58:44 2024
Install Date : Wed Jan 22 05:44:22 2025
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature
You may need to restart the panel to get the plugin expand properly
Offline
That's very odd, there must be something else preventing the plugin to expand in my case. I'm going to push this fix though, I think it'll match the old behavior better.
Anyway, this isn't the first time I've encountered expand problems with external plugins, due to GtkSocket/GtkPlug: there's that old problem with tasklist when it's run as an external plugin, for example: https://gitlab.xfce.org/xfce/xfce4-panel/-/issues/176
So ultimately, it may be necessary to run the plugin as internal (modifiable for each plugin in its desktop file, or globally via the hidden option `/force-all-internal`), and then the expand problem goes away for me too.
Added later 38 min 57 s:
Fix pushed and backported to the 4.20 branch: https://gitlab.xfce.org/xfce/xfce4-pane … 57f4aba27b
Xfce maintainer: https://gravatar.com/gaelbonithon
Offline
Many thanks for the commit! Looking forward to the new release!
I didn't know about the `/force-all-internal` option, I'll give it a try while using the stock version from the distro!
Should I mark the post as solved?
Offline
Yes, go ahead.
Xfce maintainer: https://gravatar.com/gaelbonithon
Offline
[ Generated in 0.014 seconds, 7 queries executed - Memory usage: 630.15 KiB (Peak: 662.99 KiB) ]