Revert "Bring back "Show desktop switch popup on every monitor""
authorMikael Magnusson <mikael.magnusson@sony.com>
Fri, 5 Jul 2019 12:45:33 +0000 (14:45 +0200)
committerMikael Magnusson <mikachu@gmail.com>
Wed, 13 Apr 2022 22:43:35 +0000 (00:43 +0200)
crashes after adding monitors, debug later

This reverts commit 326d9a66caac0e99f8ec55e0f749e431c5a30ff1.

openbox/screen.c

index 5f6ea47292223bc9284f87d1afa84025b6971314..e99328cd44ddd9b46dc6f2ddc850e835b493f9fe 100644 (file)
@@ -80,7 +80,7 @@ static GSList *struts_left = NULL;
 static GSList *struts_right = NULL;
 static GSList *struts_bottom = NULL;
 
-static ObPagerPopup **desktop_popup;
+static ObPagerPopup *desktop_popup;
 static guint         desktop_popup_timer = 0;
 static gboolean      desktop_popup_perm;
 
@@ -367,25 +367,17 @@ void screen_startup(gboolean reconfig)
     guint32 d;
     gboolean namesexist = FALSE;
 
+    desktop_popup = pager_popup_new();
+    desktop_popup->popup->a_text->texture[0].data.text.font = ob_rr_theme->menu_title_font;
     desktop_popup_perm = FALSE;
+    pager_popup_height(desktop_popup, POPUP_HEIGHT);
 
     if (reconfig) {
-        guint i;
-        desktop_popup = g_new(ObPagerPopup*, screen_num_monitors);
-        for (i = 0; i < screen_num_monitors; i++) {
-            desktop_popup[i] = pager_popup_new();
-            desktop_popup[i]->popup->a_text->texture[0].data.text.font = ob_rr_theme->menu_title_font;
-            pager_popup_height(desktop_popup[i], POPUP_HEIGHT);
-
-            /* update the pager popup's width */
-            pager_popup_text_width_to_strings(desktop_popup[i],
-                                              screen_desktop_names,
-                                              screen_num_desktops);
-        }
-
+        /* update the pager popup's width */
+        pager_popup_text_width_to_strings(desktop_popup,
+                                          screen_desktop_names,
+                                          screen_num_desktops);
         return;
-    } else {
-        desktop_popup = NULL;
     }
 
     /* get the initial size */
@@ -478,12 +470,7 @@ void screen_startup(gboolean reconfig)
 
 void screen_shutdown(gboolean reconfig)
 {
-    guint i;
-
-    for (i = 0; i < screen_num_monitors; i++) {
-        pager_popup_free(desktop_popup[i]);
-    }
-    g_free(desktop_popup);
+    pager_popup_free(desktop_popup);
 
     if (reconfig)
         return;
@@ -964,37 +951,30 @@ static guint translate_row_col(guint r, guint c)
 
 static gboolean hide_desktop_popup_func(gpointer data)
 {
-    guint i;
-
+    pager_popup_hide(desktop_popup);
     desktop_popup_timer = 0;
-
-    for (i = 0; i < screen_num_monitors; i++) {
-        pager_popup_hide(desktop_popup[i]);
-    }
     return FALSE; /* don't repeat */
 }
 
 void screen_show_desktop_popup(guint d, gboolean perm)
 {
     const Rect *a;
-    guint i;
 
     /* 0 means don't show the popup */
     if (!config_desktop_popup_time) return;
 
-    for (i = 0; i < screen_num_monitors; i++) {
-        a = screen_physical_area_monitor(i);
-        pager_popup_position(desktop_popup[i], CenterGravity,
-                             a->x + a->width / 2, a->y + a->height / 2);
-        pager_popup_icon_size_multiplier(desktop_popup[i],
-                                         (screen_desktop_layout.columns /
-                                          screen_desktop_layout.rows) / 2,
-                                         (screen_desktop_layout.rows/
-                                          screen_desktop_layout.columns) / 2);
-        pager_popup_max_width(desktop_popup[i],
-                              MAX(a->width/3, POPUP_WIDTH));
-        pager_popup_show(desktop_popup[i], screen_desktop_names[d], d);
-    }
+    a = screen_physical_area_primary(FALSE);
+    pager_popup_position(desktop_popup, CenterGravity,
+                         a->x + a->width / 2, a->y + a->height / 2);
+    pager_popup_icon_size_multiplier(desktop_popup,
+                                     (screen_desktop_layout.columns /
+                                      screen_desktop_layout.rows) / 2,
+                                     (screen_desktop_layout.rows/
+                                      screen_desktop_layout.columns) / 2);
+    pager_popup_max_width(desktop_popup,
+                          MAX(a->width/3, POPUP_WIDTH));
+    pager_popup_show(desktop_popup, screen_desktop_names[d], d);
+
     if (desktop_popup_timer) g_source_remove(desktop_popup_timer);
     desktop_popup_timer = 0;
     if (!perm && !desktop_popup_perm)
@@ -1010,12 +990,8 @@ void screen_hide_desktop_popup(void)
 {
     if (desktop_popup_timer) g_source_remove(desktop_popup_timer);
     desktop_popup_timer = 0;
+    pager_popup_hide(desktop_popup);
     desktop_popup_perm = FALSE;
-    guint i;
-
-    for (i = 0; i < screen_num_monitors; i++) {
-        pager_popup_hide(desktop_popup[i]);
-    }
 }
 
 guint screen_find_desktop(guint from, ObDirection dir,
@@ -1250,11 +1226,9 @@ void screen_update_desktop_names(void)
     }
 
     /* resize the pager for these names */
-    for (i = 0; i < screen_num_monitors; i++) {
-        pager_popup_text_width_to_strings(desktop_popup[i],
-                                          screen_desktop_names,
-                                          screen_num_desktops);
-    }
+    pager_popup_text_width_to_strings(desktop_popup,
+                                      screen_desktop_names,
+                                      screen_num_desktops);
 }
 
 void screen_show_desktop(ObScreenShowDestopMode show_mode, ObClient *show_only)
@@ -1484,20 +1458,6 @@ void screen_update_areas(void)
     g_free(monitor_area);
     get_xinerama_screens(&monitor_area, &screen_num_monitors);
 
-    if (!desktop_popup) {
-        desktop_popup = g_new(ObPagerPopup*, screen_num_monitors);
-        for (i = 0; i < screen_num_monitors; i++) {
-            desktop_popup[i] = pager_popup_new();
-            pager_popup_height(desktop_popup[i], POPUP_HEIGHT);
-
-            if (screen_desktop_names)
-                /* update the pager popup's width */
-                pager_popup_text_width_to_strings(desktop_popup[i],
-                                                  screen_desktop_names,
-                                                  screen_num_desktops);
-        }
-    }
-
     /* set up the user-specified margins */
     config_margins.top_start = RECT_LEFT(monitor_area[screen_num_monitors]);
     config_margins.top_end = RECT_RIGHT(monitor_area[screen_num_monitors]);