}
+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 timespec_subtract(struct timespec* result, struct timespec* x, struct timespec* y);
+/** Implementation notes for timeouts: The timeouts are kept in a GSList sorted by their
+ * expiration time.
+ * That means that update_next_timeout() only have to consider the first timeout in the list,
+ * and callback_timeout_expired() only have to consider the timeouts as long as the expiration time
+ * is in the past to the current time.
+ * As time measurement we use clock_gettime(CLOCK_MONOTONIC) because this refers to a timer, which
+ * reference point lies somewhere in the past and cannot be changed, but just queried.
+**/
+
const struct timeout* add_timeout(int value_msec, int interval_msec, void (*_callback)())
{
struct timeout* t = malloc(sizeof(struct timeout));
// it's time for the callback function
t->_callback();
if (g_slist_find(timeout_list, t)) {
- // if _callback() calls stop_timeout(t) the timeout 't' does not exist anymore
+ // if _callback() calls stop_timeout(t) the timeout 't' was freed and is not in the timeout_list
timeout_list = g_slist_remove(timeout_list, t);
if (t->interval_msec > 0)
add_timeout_intern(t->interval_msec, t->interval_msec, t->_callback, t);
void stop_timeout(const struct timeout* t)
{
+ // if not in the list, it was deleted in callback_timeout_expired
if (g_slist_find(timeout_list, t)) {
timeout_list = g_slist_remove(timeout_list, t);
free((void*)t);