[gnome-panel/wip/muktupavels/issue-35: 5/5] widget: don't push applets outside if there is enough room




commit 4e87acc8b942c42e7479628adf11c158feba294c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Oct 21 16:39:09 2021 +0300

    widget: don't push applets outside if there is enough room
    
    Regression introduced in 9d6c76aa58ef3e9c5d6b338114b7dde6d3bbd0a6.
    
    Re-add functionality that shifts applets to the left in case center
    applets pushes right side applets outside.
    
    https://gitlab.gnome.org/GNOME/gnome-panel/-/issues/35

 gnome-panel/panel-widget.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
---
diff --git a/gnome-panel/panel-widget.c b/gnome-panel/panel-widget.c
index c90f97c45..11cc4c4d8 100644
--- a/gnome-panel/panel-widget.c
+++ b/gnome-panel/panel-widget.c
@@ -912,6 +912,39 @@ panel_widget_update_positions (PanelWidget *panel)
 
                        i = ad->position + ad->size;
                }
+
+               /* Third pass: try to push applets to the left to see if
+                * there is enough room. */
+               if (i > panel->size) {
+                       i = panel->size;
+                       for (list = g_list_last (panel->applet_list);
+                            list != NULL;
+                            list = g_list_previous (list)) {
+                               ad = list->data;
+
+                               if (ad->position + ad->size > i)
+                                       ad->position = MAX (i - ad->size, 0);
+
+                               i = ad->position;
+                       }
+               }
+
+               /* EEEEK, there's not enough room, so shift applets even
+                * at the expense of perhaps running out of room on the
+                * right if there is no free space in the middle */
+               if (i < 0) {
+                       i = 0;
+                       for (list = panel->applet_list;
+                            list != NULL;
+                            list = g_list_next (list)) {
+                               ad = list->data;
+
+                               if (ad->position < i)
+                                       ad->position = i;
+
+                               i = ad->position + ad->size;
+                       }
+               }
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]