}
+int tint2_handles_click(Panel* panel, XButtonEvent* e)
+{
+ Task* task = click_task(panel, e->x, e->y);
+ if (task) {
+ if( (e->button == 1)
+ || (e->button == 2 && mouse_middle != 0)
+ || (e->button == 3 && mouse_right != 0)
+ || (e->button == 4 && mouse_scroll_up != 0)
+ || (e->button == 5 && mouse_scroll_down !=0) )
+ {
+ return 1;
+ }
+ else
+ return 0;
+ }
+ // no task clicked --> check if taskbar clicked
+ Taskbar *tskbar = click_taskbar(panel, e->x, e->y);
+ if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP)
+ return 1;
+ if (click_clock(panel, e->x, e->y)) {
+ if ( (e->button == 1 && clock_lclick_command) || (e->button == 2 && clock_rclick_command) )
+ return 1;
+ else
+ return 0;
+ }
+ return 0;
+}
+
+
+void forward_click(XEvent* e)
+{
+ // forward the click to the desktop window (thanks conky)
+ XUngrabPointer(server.dsp, e->xbutton.time);
+ e->xbutton.window = server.root_win;
+ // icewm doesn't open under the mouse.
+ // and xfce doesn't open at all.
+ e->xbutton.x = e->xbutton.x_root;
+ e->xbutton.y = e->xbutton.y_root;
+ //printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
+ //XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
+ XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e);
+}
+
+
void event_button_press (XEvent *e)
{
Panel *panel = get_panel(e->xany.window);
if (!panel) return;
- task_drag = click_task(panel, e->xbutton.x, e->xbutton.y);
- if (wm_menu && !task_drag && !click_clock(panel, e->xbutton.x, e->xbutton.y) && (e->xbutton.button != 1) ) {
- // forward the click to the desktop window (thanks conky)
- XUngrabPointer(server.dsp, e->xbutton.time);
- e->xbutton.window = server.root_win;
- // icewm doesn't open under the mouse.
- // and xfce doesn't open at all.
- e->xbutton.x = e->xbutton.x_root;
- e->xbutton.y = e->xbutton.y_root;
- //printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
- //XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
- XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e);
+ if (wm_menu && !tint2_handles_click(panel, &e->xbutton) ) {
+ forward_click(e);
return;
}
+ task_drag = click_task(panel, e->xbutton.x, e->xbutton.y);
XLowerWindow (server.dsp, panel->main_win);
}
Panel *panel = get_panel(e->xany.window);
if (!panel) return;
+ if (wm_menu && !tint2_handles_click(panel, &e->xbutton)) {
+ forward_click(e);
+ task_drag = 0;
+ return;
+ }
+
int action = TOGGLE_ICONIFY;
switch (e->xbutton.button) {
case 2:
int x11_fd, i;
Panel *panel;
GSList *it;
- GSList* timer_iter;
- struct timer* timer;
+ const struct timespec* timeout;
init (argc, argv);
}
// thanks to AngryLlama for the timer
- // Create a File Description Set containing x11_fd, and every timer_fd
+ // Create a File Description Set containing x11_fd
FD_ZERO (&fdset);
FD_SET (x11_fd, &fdset);
- int max_fd = x11_fd;
- timer_iter = timer_list;
- while (timer_iter) {
- timer = timer_iter->data;
- max_fd = timer->id > max_fd ? timer->id : max_fd;
- FD_SET(timer->id, &fdset);
- timer_iter = timer_iter->next;
- }
+ update_next_timeout();
+ if (next_timeout.tv_sec >= 0 && next_timeout.tv_nsec >= 0)
+ timeout = &next_timeout;
+ else
+ timeout = 0;
// Wait for X Event or a Timer
- if (pselect(max_fd+1, &fdset, 0, 0, 0, &empty_mask) > 0) {
- // we need to iterate over the whole timer list, since fd_set can only be checked with the
- // brute force method FD_ISSET for every possible timer
- timer_iter = timer_list;
- while (timer_iter) {
- timer = timer_iter->data;
- if (FD_ISSET(timer->id, &fdset)) {
- uint64_t dummy;
- if ( -1 != read(timer->id, &dummy, sizeof(uint64_t)) )
- timer->_callback();
- }
- timer_iter = timer_iter->next;
- }
-
+ if (pselect(x11_fd+1, &fdset, 0, 0, timeout, &empty_mask) > 0) {
while (XPending (server.dsp)) {
XNextEvent(server.dsp, &e);
}
}
+ callback_timeout_expired();
+
switch (signal_pending) {
case SIGUSR1: // reload config file
signal_pending = 0;