#include "openbox.h"
#include "config.h"
-#include "xerror.h"
#include "actions.h"
#include "event.h"
#include "client.h"
-#include "prop.h"
#include "grab.h"
#include "frame.h"
#include "translate.h"
#include "mouse.h"
#include "gettext.h"
+#include "obt/display.h"
#include <glib.h>
mouse_grab_for_client(it->data, grab);
}
-void mouse_unbind_all()
+void mouse_unbind_all(void)
{
gint i;
GSList *it;
-
+
for(i = 0; i < OB_FRAME_NUM_CONTEXTS; ++i) {
for (it = bound_contexts[i]; it; it = g_slist_next(it)) {
ObMouseBinding *b = it->data;
gint j;
for (j = 0; j < OB_NUM_MOUSE_ACTIONS; ++j) {
- GSList *it;
+ GSList *jt;
- for (it = b->actions[j]; it; it = g_slist_next(it))
- actions_act_unref(it->data);
+ for (jt = b->actions[j]; jt; jt = g_slist_next(jt))
+ actions_act_unref(jt->data);
g_slist_free(b->actions[j]);
}
g_free(b);
button = e->xbutton.button;
state = e->xbutton.state;
+ /* 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, so have the action system perform the
+ ReplayPointer for us if that is the case. */
+ if (CLIENT_CONTEXT(context, client))
+ actions_set_need_pointer_replay_before_move(TRUE);
+ else
+ actions_set_need_pointer_replay_before_move(FALSE);
+
fire_binding(OB_MOUSE_ACTION_PRESS, context,
client, e->xbutton.state,
e->xbutton.button,
if (grab_on_pointer())
button = 0;
- 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
+ /* replay the pointer event if it hasn't been replayed yet (i.e. no
+ windows were moved) */
+ if (actions_get_need_pointer_replay_before_move())
+ XAllowEvents(obt_display, ReplayPointer, event_curtime);
+
+ /* 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))
break;
case ButtonRelease:
Window wjunk;
guint ujunk, b, w, h;
/* this can cause errors to occur when the window closes */
- xerror_set_ignore(TRUE);
- junk1 = XGetGeometry(ob_display, e->xbutton.window,
+ obt_display_ignore_errors(TRUE);
+ junk1 = XGetGeometry(obt_display, e->xbutton.window,
&wjunk, &junk1, &junk2, &w, &h, &b, &ujunk);
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(FALSE);
if (junk1) {
if (e->xbutton.x >= (signed)-b &&
e->xbutton.y >= (signed)-b &&