]> Dogcows Code - chaz/tint2/blobdiff - src/tint.c
fixed icon on 64 bit system by benjaminfranzke
[chaz/tint2] / src / tint.c
index 94ec86ce6eb9c24e92346085d47f94b6aceb2527..dc90b02220b5e220211383b7dcfb2b9a8a989e44 100644 (file)
@@ -53,6 +53,7 @@ void init ()
        signal(SIGINT, signal_handler);
        signal(SIGTERM, signal_handler);
        signal(SIGHUP, signal_handler);
+       signal(SIGCLD, SIG_IGN);                // don't have to wait() after fork()
 
    // set global data
    memset(&server, 0, sizeof(Server_global));
@@ -140,7 +141,7 @@ void event_button_press (XEvent *e)
        if (!panel) return;
 
        if (wm_menu) {
-               if ((e->xbutton.x < panel->area.paddingxlr) || (e->xbutton.x > panel->area.width-panel->area.paddingxlr) || (e->xbutton.y < panel->area.paddingy) || (e->xbutton.y > panel->area.paddingy+panel->g_taskbar.height)) {
+               if ((panel_horizontal && (e->xbutton.x < panel->area.paddingxlr || e->xbutton.x > panel->area.width-panel->area.paddingxlr || e->xbutton.y < panel->area.paddingy || e->xbutton.y > panel->area.paddingy+panel->g_taskbar.height)) || (!panel_horizontal && (e->xbutton.y < panel->area.paddingxlr || e->xbutton.y > panel->area.height-panel->area.paddingxlr || e->xbutton.x < panel->area.paddingy || e->xbutton.x > panel->area.paddingy+panel->g_taskbar.width))) {
                        // forward the click to the desktop window (thanks conky)
                        XUngrabPointer(server.dsp, e->xbutton.time);
                        e->xbutton.window = server.root_win;
@@ -165,24 +166,44 @@ void event_button_press (XEvent *e)
 
    GSList *l0;
    Taskbar *tskbar;
-   int x = e->xbutton.x;
-   for (l0 = panel->area.list; l0 ; l0 = l0->next) {
-      tskbar = l0->data;
-      if (!tskbar->area.on_screen) continue;
-      if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
-         break;
-   }
-
-   if (l0) {
-      Task *tsk;
-      for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
-         tsk = l0->data;
-         if (x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
-            task_drag = tsk;
-            break;
-         }
-      }
-   }
+       if (panel_horizontal) {
+               int x = e->xbutton.x;
+               for (l0 = panel->area.list; l0 ; l0 = l0->next) {
+                       tskbar = l0->data;
+                       if (!tskbar->area.on_screen) continue;
+                       if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
+                               break;
+               }
+               if (l0) {
+                       Task *tsk;
+                       for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
+                               tsk = l0->data;
+                               if (x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
+                                       task_drag = tsk;
+                                       break;
+                               }
+                       }
+               }
+       }
+       else {
+               int y = e->xbutton.y;
+               for (l0 = panel->area.list; l0 ; l0 = l0->next) {
+                       tskbar = l0->data;
+                       if (!tskbar->area.on_screen) continue;
+                       if (y >= tskbar->area.posy && y <= (tskbar->area.posy + tskbar->area.height))
+                               break;
+               }
+               if (l0) {
+                       Task *tsk;
+                       for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
+                               tsk = l0->data;
+                               if (y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) {
+                                       task_drag = tsk;
+                                       break;
+                               }
+                       }
+               }
+       }
 
    XLowerWindow (server.dsp, panel->main_win);
 }
@@ -194,7 +215,7 @@ void event_button_release (XEvent *e)
        if (!panel) return;
 
        if (wm_menu) {
-               if ((e->xbutton.x < panel->area.paddingxlr) || (e->xbutton.x > panel->area.width-panel->area.paddingxlr) || (e->xbutton.y < panel->area.paddingy) || (e->xbutton.y > panel->area.paddingy+panel->g_taskbar.height)) {
+               if ((panel_horizontal && (e->xbutton.x < panel->area.paddingxlr || e->xbutton.x > panel->area.width-panel->area.paddingxlr || e->xbutton.y < panel->area.paddingy || e->xbutton.y > panel->area.paddingy+panel->g_taskbar.height)) || (!panel_horizontal && (e->xbutton.y < panel->area.paddingxlr || e->xbutton.y > panel->area.height-panel->area.paddingxlr || e->xbutton.x < panel->area.paddingy || e->xbutton.x > panel->area.paddingy+panel->g_taskbar.width))) {
                        // forward the click to the desktop window (thanks conky)
                        e->xbutton.window = server.root_win;
                        XSendEvent(server.dsp, e->xbutton.window, False, ButtonReleaseMask, e);
@@ -204,7 +225,7 @@ void event_button_release (XEvent *e)
 
    int action = TOGGLE_ICONIFY;
    int x = e->xbutton.x;
-   //int y = e->xbutton.y; // unused
+   int y = e->xbutton.y;
    switch (e->xbutton.button) {
       case 2:
          action = mouse_middle;
@@ -224,14 +245,28 @@ void event_button_release (XEvent *e)
    Taskbar *tskbar;
    GSList *l0;
        Clock clk = panel->clock;
-       if (clk.area.on_screen && x >= clk.area.posx && x <= (clk.area.posx + clk.area.width))
-               clock_action(e->xbutton.button);
+       if (panel_horizontal) {
+               if (clk.area.on_screen && x >= clk.area.posx && x <= (clk.area.posx + clk.area.width))
+                       clock_action(e->xbutton.button);
+               else {
+                       for (l0 = panel->area.list; l0 ; l0 = l0->next) {
+                               tskbar = l0->data;
+                               if (!tskbar->area.on_screen) continue;
+                               if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
+                                       goto suite;
+                       }
+               }
+       }
        else {
-               for (l0 = panel->area.list; l0 ; l0 = l0->next) {
-                       tskbar = l0->data;
-                       if (!tskbar->area.on_screen) continue;
-                       if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
-                               goto suite;
+               if (clk.area.on_screen && y >= clk.area.posy && y <= (clk.area.posy + clk.area.height))
+                       clock_action(e->xbutton.button);
+               else {
+                       for (l0 = panel->area.list; l0 ; l0 = l0->next) {
+                               tskbar = l0->data;
+                               if (!tskbar->area.on_screen) continue;
+                               if (y >= tskbar->area.posy && y <= (tskbar->area.posy + tskbar->area.height))
+                                       goto suite;
+                       }
                }
        }
 
@@ -256,19 +291,28 @@ suite:
    }
 
    // switch desktop
-   if (panel_mode == MULTI_DESKTOP)
+   if (panel_mode == MULTI_DESKTOP) {
       if (tskbar->desktop != server.desktop && action != CLOSE)
          set_desktop (tskbar->desktop);
+       }
 
    // action on task
    Task *tsk;
    GSList *l;
    for (l = tskbar->area.list ; l ; l = l->next) {
       tsk = l->data;
-      if (x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
-         window_action (tsk, action);
-         break;
-      }
+               if (panel_horizontal) {
+                       if (x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
+                               window_action (tsk, action);
+                               break;
+                       }
+               }
+               else {
+                       if (y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) {
+                               window_action (tsk, action);
+                               break;
+                       }
+               }
    }
 
    // to keep window below
@@ -438,11 +482,16 @@ void event_property_notify (XEvent *e)
       // Window desktop changed
       else if (at == server.atom._NET_WM_DESKTOP) {
                        int desktop = window_get_desktop (win);
+                       int active = tsk->area.is_active;
                        //printf("  Window desktop changed %d, %d\n", tsk->desktop, desktop);
                        // bug in windowmaker : send unecessary 'desktop changed' when focus changed
                        if (desktop != tsk->desktop) {
                                remove_task (tsk);
-                               add_task (win);
+                               tsk = add_task (win);
+                               if (tsk && active) {
+                                       tsk->area.is_active = 1;
+                                       task_active = tsk;
+                               }
                                panel_refresh = 1;
                        }
       }
@@ -545,18 +594,18 @@ int main (int argc, char *argv[])
    Panel *panel;
        GSList *it;
 
-   c = getopt (argc, argv, "c:");
    init ();
 
 load_config:
    i = 0;
+   c = getopt (argc, argv, "c:");
        init_config();
    if (c != -1) {
       i = config_read_file (optarg);
           c = getopt (argc, argv, "j:");
           if (c != -1) {
-                       // usage: tint2 [-c] <config_file> -j <jpeg_file> for internal use
-          printf("jpeg file %s\n", optarg);
+                       // usage: tint2 [-c] <config_file> -j <file> for internal use
+          printf("file %s\n", optarg);
              cleanup();
           exit(0);
                }
@@ -612,8 +661,13 @@ load_config:
                   break;
 
                                        case ReparentNotify:
-                                               if (e.xany.window == server.root_win) // reparented to us
+                                               if (!systray.area.on_screen)
+                                                       break;
+                                               panel = (Panel*)systray.area.panel;
+                                               if (e.xany.window == panel->main_win) // reparented to us
                                                        break;
+                                               // FIXME: 'reparent to us' badly detected => disabled
+                                               break;
                                        case UnmapNotify:
                                        case DestroyNotify:
                                                if (!systray.area.on_screen)
@@ -639,6 +693,7 @@ load_config:
 
                switch (signal_pending) {
                        case SIGUSR1:
+                               signal_pending = 0;
             goto load_config;
                        case SIGINT:
                        case SIGTERM:
This page took 0.030728 seconds and 4 git commands to generate.