*add* drag'n'drop task reordering

*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


git-svn-id: http://tint2.googlecode.com/svn/trunk@393 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
Andreas.Fink85 2010-02-08 22:44:56 +00:00
parent c50b931172
commit bf1dc33ca7
6 changed files with 86 additions and 30 deletions

View 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;

View 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++)

View 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);

View 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 };

View 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);

View 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);