X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmouse.c;h=2e8507c347784011916350573a336a0f5cd9ec3f;hb=c34915ae8d49f61426912ef332e8097be516bdd3;hp=2624ecb930ab7b5458bcb9c9721d93e44a063b36;hpb=e1fd32bcf5a07d8b9ab774d0f690112dec29cc8e;p=chaz%2Fopenbox diff --git a/openbox/mouse.c b/openbox/mouse.c index 2624ecb9..2e8507c3 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" @@ -14,9 +15,13 @@ typedef struct { guint state; guint button; - GSList *actions[NUM_MOUSEACTION]; /* lists of Action pointers */ + GSList *actions[OB_MOUSE_NUM_ACTIONS]; /* lists of Action pointers */ } ObMouseBinding; +#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 +42,7 @@ void mouse_grab_for_client(ObClient *client, gboolean grab) win = client->frame->window; mode = GrabModeAsync; mask = ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; - } else if (i == OB_FRAME_CONTEXT_CLIENT) { + } else if (CLIENT_CONTEXT(i, client)) { win = client->frame->plate; mode = GrabModeSync; /* this is handled in event */ mask = ButtonPressMask; /* can't catch more than this with Sync @@ -70,7 +75,7 @@ static void clearall() int j; ObMouseBinding *b = it->data; - for (j = 0; j < NUM_MOUSEACTION; ++j) { + for (j = 0; j < OB_MOUSE_NUM_ACTIONS; ++j) { GSList *it; for (it = b->actions[j]; it; it = it->next) { action_free(it->data); @@ -83,9 +88,9 @@ static void clearall() } } -static void fire_button(ObMouseAction a, ObFrameContext context, - ObClient *c, guint state, - guint button, int x, int y) +static gboolean fire_button(ObMouseAction a, ObFrameContext context, + ObClient *c, guint state, + guint button, int x, int y) { GSList *it; ObMouseBinding *b; @@ -96,7 +101,7 @@ static void fire_button(ObMouseAction a, ObFrameContext context, break; } /* if not bound, then nothing to do! */ - if (it == NULL) return; + if (it == NULL) return FALSE; for (it = b->actions[a]; it; it = it->next) { ObAction *act = it->data; @@ -131,11 +136,12 @@ static void fire_button(ObMouseAction a, ObFrameContext context, act->func(&act->data); } } + return TRUE; } -static void fire_motion(ObMouseAction a, ObFrameContext context, ObClient *c, - guint state, guint button, int x_root, int y_root, - guint32 corner) +static gboolean fire_motion(ObMouseAction a, ObFrameContext context, + ObClient *c, guint state, guint button, + int x_root, int y_root, guint32 corner) { GSList *it; ObMouseBinding *b; @@ -146,7 +152,7 @@ static void fire_motion(ObMouseAction a, ObFrameContext context, ObClient *c, break; } /* if not bound, then nothing to do! */ - if (it == NULL) return; + if (it == NULL) return FALSE; for (it = b->actions[a]; it; it = it->next) { ObAction *act = it->data; @@ -170,6 +176,7 @@ static void fire_motion(ObMouseAction a, ObFrameContext context, ObClient *c, act->func(&act->data); } } + return TRUE; } static guint32 pick_corner(int x, int y, int cx, int cy, int cw, int ch) @@ -196,7 +203,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; @@ -204,12 +211,12 @@ void mouse_event(ObClient *client, ObFrameContext context, XEvent *e) button = e->xbutton.button; state = e->xbutton.state; - fire_button(MouseAction_Press, context, + fire_button(OB_MOUSE_ACTION_PRESS, context, client, e->xbutton.state, e->xbutton.button, e->xbutton.x_root, e->xbutton.y_root); - if (context == OB_FRAME_CONTEXT_CLIENT) { + if (CLIENT_CONTEXT(context, client)) { /* Replay the event, so it goes to the client*/ XAllowEvents(ob_display, ReplayPointer, event_lasttime); /* Fall through to the release case! */ @@ -222,45 +229,49 @@ 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; state = 0; ltime = e->xbutton.time; } - fire_button(MouseAction_Release, context, + fire_button(OB_MOUSE_ACTION_RELEASE, context, client, e->xbutton.state, e->xbutton.button, e->xbutton.x_root, e->xbutton.y_root); if (click) - fire_button(MouseAction_Click, context, + fire_button(OB_MOUSE_ACTION_CLICK, context, client, e->xbutton.state, e->xbutton.button, e->xbutton.x_root, e->xbutton.y_root); if (dclick) - fire_button(MouseAction_DClick, context, + fire_button(OB_MOUSE_ACTION_DOUBLE_CLICK, context, client, e->xbutton.state, e->xbutton.button, e->xbutton.x_root, @@ -302,7 +313,7 @@ void mouse_event(ObClient *client, ObFrameContext context, XEvent *e) client->area.height + client->frame->size.top + client->frame->size.bottom); - fire_motion(MouseAction_Motion, context, + fire_motion(OB_MOUSE_ACTION_MOTION, context, client, state, button, px, py, corner); button = 0; state = 0;