wf-shell icon indicating copy to clipboard operation
wf-shell copied to clipboard

High CPU usage in windowlist when it's too wide

Open lcolitti opened this issue 2 years ago • 1 comments

To Reproduce Steps to reproduce the behavior:

  1. Use wf-panel
  2. Use one panel on bottom of screen with several widgets including a window list,
  3. Create lots of windows, such that the window list width is constrained by available panel width

Expected behavior Windows icons in list get smaller and CPU usage stays low.

Actual behaviour wf-panel starts consuming 100% of one CPU. WayfireWindowList::on_draw continuously runs this code - maybe once every frame?

    /* We have changed the size/number of toplevels. On top of that, our list
     * is longer that the max size, so we need to re-layout the buttons */
    if (preferred_width > allocated_width && toplevels.size() > 0)
        set_button_width(get_target_button_width());

Wayfire version 0.7.4-2 from debian testing

Panel configuration

widgets_left = menu launchers spacing4 window-list
widgets_center = none
widgets_right = volume network battery clock
# ... configuration for 6 launchers
launchers_spacing = 0
launchers_size = 34

lcolitti avatar May 24 '23 23:05 lcolitti

I hacked this locally and it seems better, but I don't think it's completely correct:

     /* We have changed the size/number of toplevels. On top of that, our list
      * is longer that the max size, so we need to re-layout the buttons */
-    if (preferred_width > allocated_width && toplevels.size() > 0)
+    if (allocated_width != this->last_allocated_width
+            && preferred_width > allocated_width
+            && toplevels.size() > 0) {
         set_button_width(get_target_button_width());
+    }
+
+    this->last_allocated_width = allocated_width;
 }

lcolitti avatar May 25 '23 00:05 lcolitti