X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Fmouse.c;h=ace7bca0c59aca82b172dd5b539d5398ed1bfe12;hb=2cd1644e1040684d5f646541f65a36b01b011db2;hp=93d00784fb7232638f616795d8f7c1ce4c876dfc;hpb=6375df675f01dd1a9bc625e95d799b9cb40bcda3;p=chaz%2Fopenbox diff --git a/openbox/mouse.c b/openbox/mouse.c index 93d00784..ace7bca0 100644 --- a/openbox/mouse.c +++ b/openbox/mouse.c @@ -1,5 +1,6 @@ #include "openbox.h" #include "config.h" +#include "xerror.h" #include "action.h" #include "event.h" #include "client.h" @@ -17,9 +18,11 @@ typedef struct { GSList *actions[OB_MOUSE_NUM_ACTIONS]; /* lists of Action pointers */ } ObMouseBinding; -#define CLIENT_CONTEXT(co, cl) (co == OB_FRAME_CONTEXT_CLIENT || \ - (co == OB_FRAME_CONTEXT_ROOT && \ - cl->type == OB_CLIENT_TYPE_DESKTOP)) +#define FRAME_CONTEXT(co, cl) ((cl && cl->type != OB_CLIENT_TYPE_DESKTOP) ? \ + co == OB_FRAME_CONTEXT_FRAME : FALSE) +#define CLIENT_CONTEXT(co, cl) ((cl && cl->type == OB_CLIENT_TYPE_DESKTOP) ? \ + co == OB_FRAME_CONTEXT_DESKTOP : \ + co == OB_FRAME_CONTEXT_CLIENT) /* Array of GSList*s of PointerBinding*s. */ static GSList *bound_contexts[OB_FRAME_NUM_CONTEXTS]; @@ -37,7 +40,7 @@ void mouse_grab_for_client(ObClient *client, gboolean grab) int mode; unsigned int mask; - if (i == OB_FRAME_CONTEXT_FRAME) { + if (FRAME_CONTEXT(i, client)) { win = client->frame->window; mode = GrabModeAsync; mask = ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; @@ -50,7 +53,8 @@ void mouse_grab_for_client(ObClient *client, gboolean grab) } else continue; if (grab) - grab_button_full(b->button, b->state, win, mask, mode, None); + grab_button_full(b->button, b->state, win, mask, mode, + OB_CURSOR_NONE); else ungrab_button(b->button, b->state, win); } @@ -84,6 +88,7 @@ static void clearall() g_free(b); } g_slist_free(bound_contexts[i]); + bound_contexts[i] = NULL; } } @@ -114,21 +119,9 @@ static gboolean fire_button(ObMouseAction a, ObFrameContext context, act->data.showmenu.y = y; } - if (act->func == action_desktop_dir) - { - act->data.desktopdir.final = FALSE; - act->data.desktopdir.cancel = FALSE; - } - if (act->func == action_send_to_desktop_dir) - { - act->data.sendtodir.final = FALSE; - act->data.sendtodir.cancel = FALSE; - } - - if (config_desktop_popup && - (act->func == action_desktop_dir || - act->func == action_send_to_desktop_dir)) - { + if (act->data.any.interactive) { + act->data.inter.cancel = FALSE; + act->data.inter.final = FALSE; keyboard_interactive_grab(state, c, context, act); } @@ -202,7 +195,7 @@ void mouse_event(ObClient *client, ObFrameContext context, XEvent *e) static int px, py; gboolean click = FALSE; gboolean dclick = FALSE; - + switch (e->type) { case ButtonPress: px = e->xbutton.x_root; @@ -228,27 +221,31 @@ void mouse_event(ObClient *client, ObFrameContext context, XEvent *e) int junk1, junk2; Window wjunk; guint ujunk, b, w, h; - XGetGeometry(ob_display, e->xbutton.window, - &wjunk, &junk1, &junk2, &w, &h, &b, &ujunk); - if (e->xbutton.x >= (signed)-b && - e->xbutton.y >= (signed)-b && - e->xbutton.x < (signed)(w+b) && - e->xbutton.y < (signed)(h+b)) { - click = TRUE; - /* double clicks happen if there were 2 in a row! */ - if (lbutton == button && - lwindow == e->xbutton.window && - e->xbutton.time - config_mouse_dclicktime <= - ltime) { - dclick = TRUE; - lbutton = 0; + xerror_set_ignore(TRUE); + junk1 = XGetGeometry(ob_display, e->xbutton.window, + &wjunk, &junk1, &junk2, &w, &h, &b, &ujunk); + xerror_set_ignore(FALSE); + if (junk1) { + if (e->xbutton.x >= (signed)-b && + e->xbutton.y >= (signed)-b && + e->xbutton.x < (signed)(w+b) && + e->xbutton.y < (signed)(h+b)) { + click = TRUE; + /* double clicks happen if there were 2 in a row! */ + if (lbutton == button && + lwindow == e->xbutton.window && + e->xbutton.time - config_mouse_dclicktime <= + ltime) { + dclick = TRUE; + lbutton = 0; + } else { + lbutton = button; + lwindow = e->xbutton.window; + } } else { - lbutton = button; - lwindow = e->xbutton.window; + lbutton = 0; + lwindow = None; } - } else { - lbutton = 0; - lwindow = None; } button = 0; @@ -353,6 +350,13 @@ gboolean mouse_bind(char *buttonstr, char *contextstr, ObMouseAction mact, grab_all_clients(FALSE); + /* when there are no modifiers in the binding, then the action cannot + be interactive */ + if (!state && action->data.any.interactive) { + action->data.any.interactive = FALSE; + action->data.inter.final = TRUE; + } + /* add the binding */ b = g_new0(ObMouseBinding, 1); b->state = state; @@ -365,11 +369,11 @@ gboolean mouse_bind(char *buttonstr, char *contextstr, ObMouseAction mact, return TRUE; } -void mouse_startup() +void mouse_startup(gboolean reconfig) { } -void mouse_shutdown() +void mouse_shutdown(gboolean reconfig) { grab_all_clients(FALSE); clearall();