- fire_binding(OB_MOUSE_ACTION_PRESS, context,
- client, e->xbutton.state,
- e->xbutton.button,
- e->xbutton.x_root, e->xbutton.y_root,
- e->xbutton.time);
-
- if (CLIENT_CONTEXT(context, client)) {
- /* Replay the event, so it goes to the client*/
- XAllowEvents(ob_display, ReplayPointer, event_curtime);
- /* Fall through to the release case! */
- } else
+ /* if the binding was in a client context, then we need to call
+ XAllowEvents with ReplayPointer at some point, to send the event
+ through to the client. when this happens though depends. if
+ windows are going to be moved on screen, then the click will end
+ up going somewhere wrong, set that we need it, and if nothing
+ else causes the replay pointer to be run, then we will do it
+ after all the actions are finished.
+
+ (We do it after all the actions because FocusIn interrupts
+ dragging for kdesktop, so if we send the button event now, and
+ then they get a focus event after, it breaks. Instead, wait to send
+ the button press until after the actions when possible.)
+ */
+ if (CLIENT_CONTEXT(context, client))
+ replay_pointer_needed = TRUE;
+
+ used = fire_binding(OB_MOUSE_ACTION_PRESS, context,
+ client, e->xbutton.state,
+ e->xbutton.button,
+ e->xbutton.x_root, e->xbutton.y_root) || used;
+
+ /* if the bindings grab the pointer, there won't be a ButtonRelease
+ event for us */
+ if (grab_on_pointer())
+ button = 0;
+
+ /* replay the pointer event if it hasn't been replayed yet (i.e. no
+ windows were moved) */
+ mouse_replay_pointer();
+
+ /* in the client context, we won't get a button release because of the
+ way it is grabbed, so just fake one */
+ if (!CLIENT_CONTEXT(context, client))