]> Dogcows Code - chaz/tint2/commitdiff
*add* drag'n'drop task reordering
authorAndreas Fink <andreas.fink85@googlemail.com>
Mon, 8 Feb 2010 22:44:56 +0000 (22:44 +0000)
committerAndreas Fink <andreas.fink85@googlemail.com>
Mon, 8 Feb 2010 22:44:56 +0000 (22:44 +0000)
*fix* autohide and tooltip after SIGUSR1
*fix* send low_battery_cmd only once
*fix* update clock if time difference > 60 sec (after hibernation or supsension)
*fix* changed transient window behaviour

src/battery/battery.c
src/clock/clock.c
src/panel.c
src/panel.h
src/tint.c
src/util/window.c

index d10c10163a491f62562ac03ede1255afda805dcf..fd2ffce4bf59d74e6de728bad2e64bd638dcce59 100644 (file)
@@ -282,9 +282,8 @@ void update_battery() {
                new_percentage = (energy_now*100)/energy_full;
 
        if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) {
-               if (battery_low_cmd)
-                       if (-1 != system(battery_low_cmd))
-                               battery_low_cmd_send = 1;
+                       system(battery_low_cmd);  // return value == -1, since we've set SIGCHLD to SIGIGN
+                       battery_low_cmd_send = 1;
        }
        if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) {
                battery_low_cmd_send = 0;
index 6d4bea918486608458bc4f302cc4647c01f64406..b6eb254537f01d31b2f7e2ddb0f7779938963345 100644 (file)
@@ -66,8 +66,11 @@ void update_clocks_sec(void* arg)
 
 void update_clocks_min(void* arg)
 {
+       // remember old_sec because after suspend/hibernate the clock should be updated directly, and not
+       // on next minute change
+       time_t old_sec = time_clock.tv_sec;
        gettimeofday(&time_clock, 0);
-       if (time_clock.tv_sec % 60 == 0) {
+       if (time_clock.tv_sec % 60 == 0 || time_clock.tv_sec - old_sec > 60) {
                int i;
                if (time1_format) {
                        for (i=0 ; i < nb_panel ; i++)
index e0390c19b7ed93f17838158ac1574162e9211732..b271b23601c625277bee5db9328de63ba8ecae54 100644 (file)
@@ -50,6 +50,7 @@ int panel_layer=BOTTOM_LAYER;  // default is bottom layer
 int panel_position;
 int panel_horizontal;
 int panel_refresh;
+int task_dragged=0;
 
 int panel_autohide = 0;
 int panel_autohide_show_timeout = 0;
@@ -96,6 +97,7 @@ void init_panel()
 
        cleanup_taskbar();
        for (i=0 ; i < nb_panel ; i++) {
+               autohide_show(&panel1[i]);
                free_area(&panel1[i].area);
                if (panel1[i].temp_pmap) {
                        XFreePixmap(server.dsp, panel1[i].temp_pmap);
@@ -165,12 +167,7 @@ void init_panel()
 
                if (i >= old_nb_panel) {
                        // new panel : catch some events
-                       long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask;
-                       if (g_tooltip.enabled)
-                               event_mask |= PointerMotionMask|LeaveWindowMask;
-                       if (panel_autohide)
-                               event_mask |= LeaveWindowMask|EnterWindowMask;
-                       XSetWindowAttributes att = { .event_mask=event_mask, .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
+                       XSetWindowAttributes att = { .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
                        unsigned long mask = CWEventMask|CWColormap|CWBackPixel|CWBorderPixel;
                        p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, server.visual, mask, &att);
                }
@@ -179,6 +176,13 @@ void init_panel()
                        XMoveResizeWindow(server.dsp, p->main_win, p->posx, p->posy, p->area.width, p->area.height);
                }
 
+               long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask|ButtonMotionMask;
+               if (g_tooltip.enabled)
+                       event_mask |= PointerMotionMask|LeaveWindowMask;
+               if (panel_autohide)
+                       event_mask |= LeaveWindowMask|EnterWindowMask;
+               XChangeWindowAttributes(server.dsp, p->main_win, CWEventMask, &(XSetWindowAttributes){.event_mask=event_mask});
+
                if (!server.gc) {
                        XGCValues  gcv;
                        server.gc = XCreateGC(server.dsp, p->main_win, 0, &gcv);
index cce1d3b35c5f971b778bd9edeb897e207930c595..f51211bbca73486e9ab086c63f8be0a67dbbd555 100644 (file)
@@ -49,6 +49,7 @@ extern int panel_position;
 extern int panel_horizontal;
 
 extern int panel_refresh;
+extern int task_dragged;
 
 //panel autohide
 enum { STRUT_MINIMUM, STRUT_FOLLOW_SIZE };
index df1c58912cd94880b37ccbade2d005f738f38afe..c8521a04e584d74718fd29959eb297741133dbe9 100644 (file)
@@ -303,6 +303,60 @@ void event_button_press (XEvent *e)
        XLowerWindow (server.dsp, panel->main_win);
 }
 
+void event_button_motion_notify (XEvent *e)
+{
+       Panel * panel = get_panel(e->xany.window);
+       if(!panel || !task_drag)
+               return;
+       // Find the taskbar on the event's location
+       Taskbar * event_taskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y);
+       if(event_taskbar == NULL)
+               return;
+
+       // Find the task on the event's location
+       Task * event_task = click_task(panel, e->xbutton.x, e->xbutton.y);
+
+       // If the event takes place on the same taskbar as the task being dragged
+       if(event_taskbar == task_drag->area.parent)     {
+               // Swap the task_drag with the task on the event's location (if they differ)
+               if(event_task && event_task != task_drag) {
+                       GSList * drag_iter = g_slist_find(event_taskbar->area.list, task_drag);
+                       GSList * task_iter = g_slist_find(event_taskbar->area.list, event_task);
+                       if(drag_iter && task_iter) {
+                               gpointer temp = task_iter->data;
+                               task_iter->data = drag_iter->data;
+                               drag_iter->data = temp;
+                               event_taskbar->area.resize = 1;
+                               panel_refresh = 1;
+                               task_dragged = 1;
+                       }
+               }
+       }
+       else { // The event is on another taskbar than the task being dragged
+               if(task_drag->desktop == ALLDESKTOP || panel_mode != MULTI_DESKTOP)
+                       return;
+
+               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);
+               else
+                       event_taskbar->area.list = g_slist_append(event_taskbar->area.list, task_drag);
+
+               // Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify')
+               task_drag->area.parent = event_taskbar;
+               task_drag->desktop = event_taskbar->desktop;
+
+               windows_set_desktop(task_drag->win, event_taskbar->desktop);
+
+               event_taskbar->area.resize = 1;
+               drag_taskbar->area.resize = 1;
+               task_dragged = 1;
+               panel_refresh = 1;
+       }
+}
 
 void event_button_release (XEvent *e)
 {
@@ -353,26 +407,19 @@ void event_button_release (XEvent *e)
                return;
        }
 
-       // drag and drop task
-       if (task_drag) {
-               if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) {
-                       if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) {
-                               windows_set_desktop(task_drag->win, tskbar->desktop);
-                               if (tskbar->desktop == server.desktop)
-                                       set_active(task_drag->win);
-                               task_drag = 0;
-                       }
-                       return;
-               }
-               else task_drag = 0;
-       }
-
        // switch desktop
        if (panel_mode == MULTI_DESKTOP) {
                if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT)
                        set_desktop (tskbar->desktop);
        }
 
+       // drag and drop task
+       if (task_dragged) {
+               task_drag = 0;
+               task_dragged = 0;
+               return;
+       }
+
        // action on task
        window_action( click_task(panel, e->xbutton.x, e->xbutton.y), action);
 
@@ -739,6 +786,10 @@ int main (int argc, char *argv[])
                                                break;
 
                                        case MotionNotify: {
+                                               unsigned int button_mask = Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask;
+                                               if (e.xmotion.state & button_mask)
+                                                       event_button_motion_notify (&e);
+                                               
                                                if (!g_tooltip.enabled) break;
                                                Panel* panel = get_panel(e.xmotion.window);
                                                Area* area = click_area(panel, e.xmotion.x, e.xmotion.y);
index 06ab09359054e334aaedd5b100482a4e7d0072b0..f4ef6a04ac306277e46d6561a7cda780c150ef02 100644 (file)
@@ -86,12 +86,10 @@ int window_is_hidden (Window win)
                        XFree(at);
                        return 1;
                }
-               if (at[i] == server.atom._NET_WM_STATE_MODAL) {
-                       // do not add modal windows if the transient window is already in the taskbar
-                       if ( XGetTransientForHint(server.dsp, win, &window) && task_get_tasks(window) ) {
-                               XFree(at);
-                               return 1;
-                       }
+               // do not add transient_for windows if the transient window is already in the taskbar
+               if ( XGetTransientForHint(server.dsp, win, &window) && task_get_tasks(window) ) {
+                       XFree(at);
+                       return 1;
                }
        }
        XFree(at);
This page took 0.033672 seconds and 4 git commands to generate.