edges should hook into number of screens changing, but for now, don't crash at reconf...
authorMikael Magnusson <mikachu@gmail.com>
Sun, 7 Apr 2013 09:59:07 +0000 (11:59 +0200)
committerMikael Magnusson <mikachu@gmail.com>
Sat, 11 Oct 2014 00:17:21 +0000 (02:17 +0200)
openbox/edges.c

index 87bac5d..1576dba 100644 (file)
@@ -11,6 +11,9 @@
 ObEdge ***edge;
 #warning put in config.c and parse configs of course
 gboolean config_edge_enabled[OB_NUM_EDGES] = {1, 1, 1, 1, 1, 1, 1, 1};
+/* this could change at runtime, we should hook into that, but for now
+ * don't crash on reconfigure/shutdown */
+static edge_monitors;
 
 #ifdef DEBUG
 #define EDGE_WIDTH 10
@@ -68,8 +71,10 @@ void edges_startup(gboolean reconfigure)
 
     xswa.override_redirect = True;
 
-    edge = g_slice_alloc(sizeof(ObEdge**) * screen_num_monitors);
-    for (m = 0; m < screen_num_monitors; m++) {
+    edge_monitors = screen_num_monitors;
+
+    edge = g_slice_alloc(sizeof(ObEdge**) * edge_monitors);
+    for (m = 0; m < edge_monitors; m++) {
         const Rect *monitor = screen_physical_area_monitor(m);
         edge[m] = g_slice_alloc(sizeof(ObEdge*) * OB_NUM_EDGES);
         for (i=0; i < OB_NUM_EDGES; i++) {
@@ -104,8 +109,11 @@ void edges_shutdown(gboolean reconfigure)
 {
     gint i, m;
 
-    for (m = 0; m < screen_num_monitors; m++) {
+    for (m = 0; m < edge_monitors; m++) {
         for (i = 0; i < OB_NUM_EDGES; i++) {
+            if (!config_edge_enabled[i])
+                continue;
+
             window_remove(edge[m][i]->win);
             stacking_remove(EDGE_AS_WINDOW(edge[m][i]));
             XDestroyWindow(obt_display, edge[m][i]->win);
@@ -113,5 +121,5 @@ void edges_shutdown(gboolean reconfigure)
         }
         g_slice_free1(sizeof(ObEdge*) * OB_NUM_EDGES, edge[m]);
     }
-    g_slice_free1(sizeof(ObEdge**) * screen_num_monitors, edge);
+    g_slice_free1(sizeof(ObEdge**) * edge_monitors, edge);
 }