! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Jumping panel resize at 1 GHz
Status:
RESOLVED: FIXED
Priority:
Very Low
Severity:
enhancement
Product:
Xfce4-cpufreq-plugin
Component:
General

Comments

Description Nick 2013-10-03 16:30:27 CEST
I noticed that if CPU(s) freq. are dropped to 1Ghz, the icon tray just displays:

[1 GHz]

but then on activity, governor pushes up Hz, so we get this:

[1.67 GHz]

OK, all well and good.  But what this does is just make the panel keep resizing:

[     ]
[        ]
[     ]
[        ]

etc.

So, looking at the code (panel-plugins/xfce4-cpufreq-utils.c)

if ((freq % div) == 0 || div == 1000)
                readable_freq = g_strdup_printf ("%d.2f %s", (freq/div), freq_unit);
        else
                readable_freq = g_strdup_printf ("%3.2f %s", ((gfloat)freq/div), freq_unit);

        g_free (freq_unit);
        return readable_freq;
}

... isn't needed.  Just:

readable_freq = g_strdup_printf ("%3.2f %s", ((gfloat)freq/div), freq_unit);

... which now gives:

[1.00 GHz]
[1.66 GHz]
[1.33 GHz]
[1.00 GHz]

and no 'panel' jumping resize.

Nick
Comment 1 Nick 2013-10-03 16:45:37 CEST
Bugger.... please ignore the:

     readable_freq = g_strdup_printf ("%d.2f %s", (freq/div), freq_unit);
                                    ^^^
that was me debugging and I forgot to remove it.  It is:

     readable_freq = g_strdup_printf ("%d %s", (freq/div), freq_unit);

Nick
Comment 2 Nick 2013-10-03 16:46:36 CEST
Bugger.... please ignore the:

     readable_freq = g_strdup_printf ("%d.2f %s", (freq/div), freq_unit);
                                         ^^^
that was me debugging and I forgot to remove it.  It is:

     readable_freq = g_strdup_printf ("%d %s", (freq/div), freq_unit);

Nick
Comment 3 Harald Judt 2013-10-07 12:03:20 CEST
Acknowledged. But while this solution may work in your case, I believe there can still be problems on other systems. What's more, that defeats the nice formatting for particular values. E.g. my thinkpad's lowest CPU freq would then be displayed as 800.00 MHz instead of 800 MHz, which wastes space and is harder to read, with no extra information gained. Maybe it would be better to calculate the max size needed and always request that. I'll look into this before the next release. Thanks for reporting.
Comment 4 Harald Judt 2014-12-19 20:07:56 CET
Created attachment 5822 
fix-panel-resizing-caused-by-freq-format-function.patch

If you are still interested in or plagued by this bug, can you please try this patch? It makes the plugin keep the max label width, only resetting it on config or panel size changes.

Unfortunately, I cannot test it for your exact problem because the cpus in my machines have no "problematic" frequencies, but the tests I did so far indicate it should fix this too.
Comment 5 Nick 2014-12-20 12:44:10 CET
Thanks for your time.

This works a lot better, but it still resizes somewhat on the change from 1GHz to 1.66GHz - i.e. the max size doesn't seem to stick.

Nick
Comment 6 Harald Judt 2014-12-20 15:11:38 CET
Ok, thanks for testing. I think we are half-way there. I believe there is one logical error in my patch that might cause the max size not to stick. The patch added a line in cpufreq_set_size():

@@ -551,6 +566,7 @@ cpufreq_set_size (XfcePanelPlugin *plugin, gint size, CpuFreqPlugin *cpufreq)
 {
 	cpuFreq->panel_size = size;
 	cpuFreq->panel_rows = xfce_panel_plugin_get_nrows (plugin);
+	cpuFreq->label_max_width = -1;
 	cpuFreq->layout_changed = TRUE;
 	cpufreq_update_icon (cpufreq);
 	cpufreq_update_plugin ();

Can you remove this line and see if that helps? If yes, then either this line is completely unnecessary or it should be added to another part, like cpufreq_set_orientation, in case the panel changes its mode (if you have time please test changing panel mode horizontal/vertical/deskbar too to verify that the patch doesn't cause any troubles or is incomplete).
Comment 7 Nick 2014-12-20 16:20:35 CET
OK, tried that - still the same, i.e. if I have the governor displayed I get (for instance):

|1GHz Ondemand|

and switching:

|1GHz Conservative|

and switch back it resizes to the same as the top line.  Also the 1GHz to 1.67GHz still resizes between them.

I dunno.  It doesn't really matter I suppose - it doing what it is suppose to do.

I also tested the panel in vertical/desktop modes, and apart from the obvious squashing up (that all applets do), it works fine.

Thanks,

Nick
Comment 8 Harald Judt 2014-12-20 18:42:50 CET
I have reproduced the problem by changing the frequency reported and altered the patch so it nearly works now. The previous patch had the right pieces, but in the wrong place.

However, the new patch has revealed other issues with the layout changes etc. so more work and much testing is needed. If I can spend enough time, I'll try to include a fix in the next release, otherwise it has to wait (again).
Comment 9 Nick 2014-12-21 11:35:21 CET
Well I can test it out for you when ready if you give me the heads up.

Nick
Comment 10 Harald Judt 2014-12-22 00:02:04 CET
Please try http://git.xfce.org/users/hjudt/xfce4-cpufreq-plugin/log/?h=fix-bug-10385.

Or if you don't know how to pull and compile from git, you can also simply apply these two patches in the following order:

http://git.xfce.org/users/hjudt/xfce4-cpufreq-plugin/patch/?id=5677fa969032ae8e6eae26ea69d4c36a39db385e
http://git.xfce.org/users/hjudt/xfce4-cpufreq-plugin/patch/?id=21a91c784c5ae99081dfff4c28ae30e092003255

These fix both your bug and small layout problems. The previous patch from this bug is obsolete.

The resizes might still occur once, but from then on the plugin size should be stable until a panel resize or orientation change occurs. This too could be fixed probably, but then I don't want to spend more time on this and I don't really see the necessity to do so; such changes usually don't happen very often.
Comment 11 Harald Judt 2014-12-22 00:02:53 CET
Comment on attachment 5822 
fix-panel-resizing-caused-by-freq-format-function.patch

Obsoleted by new patches on private git repository.
Comment 12 Harald Judt 2014-12-22 18:55:14 CET
I've pushed the changes to git master: http://git.xfce.org/panel-plugins/xfce4-cpufreq-plugin/commit/?id=5677fa969032ae8e6eae26ea69d4c36a39db385e

A new version will be released soon. Feel free to reopen if this is still an issue.
Comment 13 Nick 2014-12-22 19:04:00 CET
Will do - thanks for your hard work Harald.

Seasons greetings,

Nick
Comment 14 Nick 2014-12-26 14:16:35 CET
Hi Harald,

I just got the latest git and built it - it works perfectly now.

Thank you for your time on this.

Nick
Comment 15 Harald Judt 2014-12-26 20:04:37 CET
Thanks for your testing, glad to hear it's finally fixed now.
Comment 16 Martin Persson 2015-06-01 15:20:57 CEST
*** Bug 11953 has been marked as a duplicate of this bug. ***

Bug #10385

Reported by:
Nick
Reported on: 2013-10-03
Last modified on: 2015-06-01
Duplicates (1):

People

Assignee:
Harald Judt
CC List:
2 users

Version

Version:
unspecified

Attachments

Additional information