]> Dogcows Code - chaz/tint2/blobdiff - src/taskbar/task.c
fixed decorated window with compiz
[chaz/tint2] / src / taskbar / task.c
index f0b9924caff8e1f440505439f1ff9a48368dc99b..1bac2f6aba95b68e4441dc0e41ece377f9871ff2 100644 (file)
@@ -60,20 +60,27 @@ void add_task (Window win)
    XSelectInput (server.dsp, new_tsk->win, PropertyChangeMask|StructureNotifyMask);
    
    if (desktop == 0xFFFFFFFF) {
-      if (new_tsk->title) XFree (new_tsk->title);
-      if (new_tsk->icon_data) XFree (new_tsk->icon_data);
+      if (new_tsk->title) {
+         free (new_tsk->title);
+         new_tsk->title = 0;
+      }
+      if (new_tsk->icon_data) {
+         free (new_tsk->icon_data);
+         new_tsk->icon_data = 0;
+      }
       free(new_tsk);
       fprintf(stderr, "task on all desktop : ignored\n");
       return;
    }
-   
+      
+   //printf("add_task %d  %s\n", index(desktop, monitor), new_tsk->title);
    Taskbar *tskbar;
-   tskbar = g_slist_nth_data(panel.area.list, index(desktop, monitor));      
+   tskbar = &panel.taskbar[index(desktop, monitor)];     
    new_tsk->area.parent = tskbar;
    tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk);
 
-   if (resize_tasks (tskbar)) 
-      redraw (&tskbar->area);
+   if (resize_tasks (tskbar))
+      set_redraw (&tskbar->area);
 }
 
 
@@ -85,10 +92,17 @@ void remove_task (Task *tsk)
    tskbar = (Taskbar*)tsk->area.parent;
    tskbar->area.list = g_slist_remove(tskbar->area.list, tsk);
    resize_tasks (tskbar);
-   redraw (&tskbar->area);
+   set_redraw (&tskbar->area);
+   //printf("remove_task %d  %s\n", index(tskbar->desktop, tskbar->monitor), tsk->title);
 
-   if (tsk->title) XFree (tsk->title);
-   if (tsk->icon_data) XFree (tsk->icon_data);
+   if (tsk->title) {
+      free (tsk->title);
+      tsk->title = 0;
+   }
+   if (tsk->icon_data) {
+      free (tsk->icon_data);
+      tsk->icon_data = 0;
+   }
    XFreePixmap (server.dsp, tsk->area.pmap);
    XFreePixmap (server.dsp, tsk->area_active.pmap);
    free(tsk);
@@ -101,8 +115,6 @@ void get_title(Task *tsk)
 
    char *title, *name;
 
-   if (tsk->title) free(tsk->title);
-
    name = server_get_property (tsk->win, server.atom._NET_WM_VISIBLE_NAME, server.atom.UTF8_STRING, 0);
    if (!name || !strlen(name)) {
       name = server_get_property (tsk->win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 0);
@@ -116,12 +128,14 @@ void get_title(Task *tsk)
    }
 
    // add space before title
-   title = malloc(strlen(name)+1);      
+   title = malloc(strlen(name)+2);      
    if (g_task.icon) strcpy(title, " ");
    else title[0] = 0;
    strcat(title, name);
-   
    if (name) XFree (name);
+
+   if (tsk->title)
+      free(tsk->title);
    tsk->title = title;
 }
 
@@ -134,18 +148,30 @@ void get_icon (Task *tsk)
    int num;
 
    data = server_get_property (tsk->win, server.atom._NET_WM_ICON, XA_CARDINAL, &num);
-   if (!data) return;
-
-   int w, h;
-   long *tmp_data;
-   tmp_data = get_best_icon (data, get_icon_count (data, num), num, &w, &h, g_task.icon_size1);
-
-   tsk->icon_width = w;
-   tsk->icon_height = h;
-   tsk->icon_data = malloc (w * h * sizeof (long));
-   memcpy (tsk->icon_data, tmp_data, w * h * sizeof (long));
-      
-   XFree (data);
+   if (data) {
+      printf("get_icon plein\n");
+      // ARGB
+      int w, h;
+      long *tmp_data;
+      tmp_data = get_best_icon (data, get_icon_count (data, num), num, &w, &h, g_task.icon_size1);
+
+      tsk->icon_width = w;
+      tsk->icon_height = h;
+      tsk->icon_data = malloc (w * h * sizeof (long));
+      memcpy (tsk->icon_data, tmp_data, w * h * sizeof (long));
+         
+      XFree (data);
+   }
+   else {
+      //XWMHints *hints;
+      //hints = XGetWMHints(server.dsp, tkwin);
+      //if (hints != NULL) {
+      //   XFree(hints);
+      //}
+      printf("get_icon vide\n");
+      // XChangeProperty (display, windowH, XInternAtom (display, "_NET_WM_ICON", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char*) data, dataSize);
+      return;
+   }
 }
 
 
@@ -258,12 +284,22 @@ void draw_task_title (cairo_t *c, Task *tsk, int active)
 }
 
 
-int draw_foreground_task (void *obj, cairo_t *c)
+void draw_background_task (void *obj, cairo_t *c)
+{
+   Task *tsk = obj;
+
+   draw_background (&tsk->area_active, c);
+   draw_background (&tsk->area_inactive, c);
+}
+
+
+void draw_foreground_task (void *obj, cairo_t *c)
 {
    Task *tsk = obj;
    cairo_surface_t *cs;
    cairo_t *ca;
-   
+   //printf("  draw_foreground_task\n");
+
    draw_task_title (c, tsk, 0);
 
    // draw active pmap
@@ -277,11 +313,9 @@ int draw_foreground_task (void *obj, cairo_t *c)
    ca = cairo_create (cs);
 
    // redraw task
-   draw_background (&tsk->area_active, ca);
    draw_task_title (ca, tsk, 1);
    
    cairo_destroy (ca);
    cairo_surface_destroy (cs);
-   return 0;
 }
 
This page took 0.030083 seconds and 4 git commands to generate.