}
static void fire_button(MouseAction a, Context context, Client *c, guint state,
- guint button)
+ guint button, int x, int y)
{
GSList *it;
MouseBinding *b;
g_assert(!(b->action[a]->func == action_move ||
b->action[a]->func == action_resize));
+ if (b->action[a]->func == action_showmenu) {
+ b->action[a]->data.showmenu.x = x;
+ b->action[a]->data.showmenu.y = y;
+ }
+
b->action[a]->func(&b->action[a]->data);
}
}
static guint button = 0, state = 0, lbutton = 0;
static gboolean drag = FALSE, drag_used = FALSE;
static Corner corner = Corner_TopLeft;
+ static Client *drag_client = NULL;
+ static Context drag_context = Context_None;
gboolean click = FALSE;
gboolean dclick = FALSE;
Context context;
break;
case Event_X_ButtonPress:
+ context = frame_context(e->data.x.client,
+ e->data.x.e->xbutton.window);
+
if (!button) {
if (e->data.x.client != NULL) {
cx = e->data.x.client->frame->area.x;
}
button = e->data.x.e->xbutton.button;
state = e->data.x.e->xbutton.state;
+ drag_context = context;
+ drag_client = e->data.x.client;
}
- context = frame_context(e->data.x.client->frame,
- e->data.x.e->xbutton.window);
fire_button(MouseAction_Press, context,
e->data.x.client, e->data.x.e->xbutton.state,
- e->data.x.e->xbutton.button);
+ e->data.x.e->xbutton.button,
+ e->data.x.e->xbutton.x_root, e->data.x.e->xbutton.y_root);
if (context == Context_Client) {
/* Replay the event, so it goes to the client*/
break;
case Event_X_ButtonRelease:
- context = frame_context(e->data.x.client->frame,
+ context = frame_context(e->data.x.client,
e->data.x.e->xbutton.window);
if (e->data.x.e->xbutton.button == button) {
/* end drags */
if (drag_used) {
- fire_motion(MouseAction_Motion, context,
- e->data.x.client, state, button,
+ fire_motion(MouseAction_Motion, drag_context,
+ drag_client, state, button,
cx, cy, cw, ch, dx, dy, TRUE, corner);
drag = drag_used = FALSE;
+ drag_context = Context_None;
+ drag_client = NULL;
lbutton = 0;
} else {
}
fire_button(MouseAction_Release, context,
e->data.x.client, e->data.x.e->xbutton.state,
- e->data.x.e->xbutton.button);
+ e->data.x.e->xbutton.button,
+ e->data.x.e->xbutton.x_root, e->data.x.e->xbutton.y_root);
if (click)
fire_button(MouseAction_Click, context,
e->data.x.client, e->data.x.e->xbutton.state,
- e->data.x.e->xbutton.button);
+ e->data.x.e->xbutton.button,
+ e->data.x.e->xbutton.x_root,
+ e->data.x.e->xbutton.y_root);
if (dclick)
fire_button(MouseAction_DClick, context,
e->data.x.client, e->data.x.e->xbutton.state,
- e->data.x.e->xbutton.button);
+ e->data.x.e->xbutton.button,
+ e->data.x.e->xbutton.x_root,
+ e->data.x.e->xbutton.y_root);
break;
case Event_X_MotionNotify:
dx = e->data.x.e->xmotion.x_root - px;
dy = e->data.x.e->xmotion.y_root - py;
if (!drag &&
- (ABS(dx) >= threshold || ABS(dy) >= threshold))
+ (ABS(dx) >= threshold || ABS(dy) >= threshold)) {
drag = TRUE;
+ }
if (drag) {
- context = frame_context(e->data.x.client->frame,
- e->data.x.e->xbutton.window);
- drag_used = fire_motion(MouseAction_Motion, context,
- e->data.x.client,
+ drag_used = fire_motion(MouseAction_Motion, drag_context,
+ drag_client,
state, button, cx, cy, cw, ch, dx, dy,
FALSE, corner);
}