]> Dogcows Code - chaz/tint2/commitdiff
fixed segfault with multi-monitor
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Thu, 22 Oct 2009 17:55:23 +0000 (17:55 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Thu, 22 Oct 2009 17:55:23 +0000 (17:55 +0000)
src/panel.c

index 0bd2c4cc8e30efd8f9bd86bbab3668ad011c7a16..e6d747f05fa277e66609b0720af94c4c04e5c78a 100644 (file)
@@ -74,6 +74,10 @@ void init_panel()
        cleanup_taskbar();
        for (i=0 ; i < nb_panel ; i++) {
                free_area(&panel1[i].area);
+               if (panel1[i].temp_pmap) {
+                       XFreePixmap(server.dsp, panel1[i].temp_pmap);
+                       panel1[i].temp_pmap = 0;
+               }
        }
 
        // alloc panels (one monitor or all monitors)
@@ -82,26 +86,29 @@ void init_panel()
                nb_panel = 1;
        else
                nb_panel = server.nb_monitor;
-       fprintf(stderr, "tint2 : nb monitor %d, nb desktop %d\n", nb_panel, server.nb_desktop);
 
-/*     if (nb_panel < old_nb_panel) {
+       if (nb_panel < old_nb_panel) {
                // freed old panels
                for (i=nb_panel ; i < old_nb_panel ; i++) {
+                       if (panel1[i].main_win)
+                               XDestroyWindow(server.dsp, panel1[i].main_win);
                }
-       }*/
-
-       if (nb_panel != old_nb_panel)
                new_panel = realloc(panel1, nb_panel * sizeof(Panel));
+       }
+       else if (nb_panel > old_nb_panel) {
+               new_panel = realloc(panel1, nb_panel * sizeof(Panel));
+               // init new panel
+               for (i=old_nb_panel ; i < nb_panel ; i++) {
+                       memcpy(&new_panel[i], &panel_config, sizeof(Panel));
+               }
+       }
        else
                new_panel = panel1;
 
+       fprintf(stderr, "tint2 : nb monitor %d, nb desktop %d\n", nb_panel, server.nb_desktop);
        for (i=0 ; i < nb_panel ; i++) {
                p = &new_panel[i];
 
-               if (i >= old_nb_panel) {
-                       // new panel
-                       memcpy(p, &panel_config, sizeof(Panel));
-               }
                p->monitor = i;
                p->area.parent = p;
                p->area.panel = p;
@@ -138,7 +145,7 @@ void init_panel()
 
                if (i >= old_nb_panel) {
                        // new panel
-                       printf("new panel %d, %d, %d, %d\n", p->posx, p->posy, p->area.width, p->area.height);
+                       printf("new panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
 
                        // Catch some events
                        long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask;
@@ -154,7 +161,7 @@ void init_panel()
                }
                else {
                        // old panel
-                       printf("old panel %d, %d, %d, %d\n", p->posx, p->posy, p->area.width, p->area.height);
+                       printf("old panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
                        XMoveResizeWindow(server.dsp, p->main_win, p->posx, p->posy, p->area.width, p->area.height);
                        set_panel_background(p);
                }
@@ -162,6 +169,7 @@ void init_panel()
 
        panel1 = new_panel;
        panel_refresh = 1;
+       refresh_systray = 1;
        init_taskbar();
        visible_object();
        task_refresh_tasklist();
This page took 0.023357 seconds and 4 git commands to generate.