]> Dogcows Code - chaz/tint2/blobdiff - src/tint.c
*fix* warning
[chaz/tint2] / src / tint.c
index 80a7dd9488592bdef3fa91c376562e9a0af11f63..db4095985ffa2668afdf23ec237e8b55b13c1d47 100644 (file)
@@ -3,7 +3,7 @@
 * Tint2 panel
 *
 * Copyright (C) 2007 Pål Staurland (staura@gmail.com)
-* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
+* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2
@@ -42,6 +42,7 @@
 #include "panel.h"
 #include "tooltip.h"
 #include "timer.h"
+#include "xsettings-client.h"
 
 
 void signal_handler(int sig)
@@ -135,7 +136,7 @@ void init_X11()
        setlocale (LC_ALL, "");
        // config file use '.' as decimal separator
        setlocale(LC_NUMERIC, "POSIX");
-
+       
        // load default icon
        gchar *path;
        const gchar * const *data_dirs;
@@ -156,7 +157,6 @@ void init_X11()
 
 void cleanup()
 {
-       cleanup_timeout();
        cleanup_systray();
        cleanup_tooltip();
        cleanup_clock();
@@ -174,6 +174,7 @@ void cleanup()
        imlib_context_disconnect_display();
 
        cleanup_server();
+       cleanup_timeout();
        if (server.dsp) XCloseDisplay(server.dsp);
 }
 
@@ -371,8 +372,10 @@ void event_button_motion_notify (XEvent *e)
                Taskbar * drag_taskbar = (Taskbar*)task_drag->area.parent;
                drag_taskbar->area.list = g_slist_remove(drag_taskbar->area.list, task_drag);
 
-               if(event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy)
-                       event_taskbar->area.list = g_slist_prepend(event_taskbar->area.list, task_drag);
+               if(event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) {
+                       int i = (taskbarname_enabled) ? 1 : 0;
+                       event_taskbar->area.list = g_slist_insert(event_taskbar->area.list, task_drag, i);
+               }
                else
                        event_taskbar->area.list = g_slist_append(event_taskbar->area.list, task_drag);
 
@@ -479,12 +482,44 @@ void event_property_notify (XEvent *e)
        Window win = e->xproperty.window;
        Atom at = e->xproperty.atom;
 
+       if (xsettings_client)
+               xsettings_client_process_event(xsettings_client, e);
        if (win == server.root_win) {
                if (!server.got_root_win) {
                        XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
                        server.got_root_win = 1;
                }
 
+               // Change name of desktops
+               else if (at == server.atom._NET_DESKTOP_NAMES) {
+                       if (!taskbarname_enabled) return;
+                       GSList *l, *list = server_get_name_of_desktop();
+                       int j;
+                       gchar *name;
+                       Taskbar *tskbar;
+                       for (i=0 ; i < nb_panel ; i++) {
+                               for (j=0, l=list ; j < panel1[i].nb_desktop ; j++) {
+                                       if (l) {
+                                               name = g_strdup(l->data);
+                                               l = l->next;
+                                       }
+                                       else
+                                               name = g_strdup_printf("%d", j+1);
+                                       tskbar = &panel1[i].taskbar[j];
+                                       if (strcmp(name, tskbar->bar_name.name) != 0) {
+                                               g_free(tskbar->bar_name.name);
+                                               tskbar->bar_name.name = name;
+                                               tskbar->bar_name.area.resize = 1;
+                                       }
+                                       else
+                                               g_free(name);
+                               }
+                       }
+                       for (l=list ; l ; l = l->next)
+                               g_free(l->data);
+                       g_slist_free(list);
+                       panel_refresh = 1;
+               }
                // Change number of desktops
                else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
                        if (!taskbar_enabled) return;
@@ -494,9 +529,9 @@ void event_property_notify (XEvent *e)
                        for (i=0 ; i < nb_panel ; i++) {
                                init_taskbar_panel(&panel1[i]);
                                set_panel_items_order(&panel1[i]);
+                               visible_taskbar(&panel1[i]);
                                panel1[i].area.resize = 1;
                        }
-                       visible_object();
                        task_refresh_tasklist();
                        active_task();
                        panel_refresh = 1;
@@ -508,24 +543,17 @@ void event_property_notify (XEvent *e)
                        server.desktop = server_get_current_desktop ();
                        for (i=0 ; i < nb_panel ; i++) {
                                Panel *panel = &panel1[i];
-                               if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) {
-                                       // redraw both taskbar
-                                       if (server.nb_desktop > old_desktop) {
-                                               // can happen if last desktop is deleted and we've been on the last desktop
-                                               panel->taskbar[old_desktop].area.bg = panel->g_taskbar.bg;
-                                               panel->taskbar[old_desktop].area.resize = 1;
-                                       }
-                                       panel->taskbar[server.desktop].area.bg = panel->g_taskbar.bg_active;
-                                       panel->taskbar[server.desktop].area.resize = 1;
-                                       panel_refresh = 1;
-                               }
+                               set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL);
+                               set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE);
                                // check ALLDESKTOP task => resize taskbar
                                Taskbar *tskbar;
                                Task *tsk;
                                GSList *l;
                                if (server.nb_desktop > old_desktop) {
                                        tskbar = &panel->taskbar[old_desktop];
-                                       for (l = tskbar->area.list; l ; l = l->next) {
+                                       l = tskbar->area.list;
+                                       if (taskbarname_enabled) l = l->next;
+                                       for (; l ; l = l->next) {
                                                tsk = l->data;
                                                if (tsk->desktop == ALLDESKTOP) {
                                                        tsk->area.on_screen = 0;
@@ -535,7 +563,9 @@ void event_property_notify (XEvent *e)
                                        }
                                }
                                tskbar = &panel->taskbar[server.desktop];
-                               for (l = tskbar->area.list; l ; l = l->next) {
+                               l = tskbar->area.list;
+                               if (taskbarname_enabled) l = l->next;
+                               for (; l ; l = l->next) {
                                        tsk = l->data;
                                        if (tsk->desktop == ALLDESKTOP) {
                                                tsk->area.on_screen = 1;
@@ -543,9 +573,6 @@ void event_property_notify (XEvent *e)
                                        }
                                }
                        }
-                       if (panel_mode != MULTI_DESKTOP) {
-                               visible_object();
-                       }
                }
                // Window list
                else if (at == server.atom._NET_CLIENT_LIST) {
@@ -589,12 +616,13 @@ void event_property_notify (XEvent *e)
 
                // Window title changed
                if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
-                       get_title(tsk);
-                       if (g_tooltip.mapped && (g_tooltip.area == (Area*)tsk)) {
-                               tooltip_copy_text((Area*)tsk);
-                               tooltip_update();
+                       if (get_title(tsk)) {
+                               if (g_tooltip.mapped && (g_tooltip.area == (Area*)tsk)) {
+                                       tooltip_copy_text((Area*)tsk);
+                                       tooltip_update();
+                               }
+                               panel_refresh = 1;
                        }
-                       panel_refresh = 1;
                }
                // Demand attention
                else if (at == server.atom._NET_WM_STATE) {
@@ -895,7 +923,7 @@ start:
                                                                break;
                                                        }
                                                }
-                                       break;
+                                               break;
 
                                        case ClientMessage:
                                                ev = &e.xclient;
This page took 0.024994 seconds and 4 git commands to generate.