+/* TRUE when we have a grab on the pointer and need to replay the pointer event
+ to send it to other applications */
+static gboolean replay_pointer_needed;
+
+ObFrameContext mouse_button_frame_context(ObFrameContext context,
+ guint button,
+ guint state)
+{
+ GSList *it;
+ ObFrameContext x = context;
+
+ for (it = bound_contexts[context]; it; it = g_slist_next(it)) {
+ ObMouseBinding *b = it->data;
+
+ if (b->button == button && b->state == state)
+ return context;
+ }
+
+ switch (context) {
+ case OB_FRAME_CONTEXT_NONE:
+ case OB_FRAME_CONTEXT_DESKTOP:
+ case OB_FRAME_CONTEXT_CLIENT:
+ case OB_FRAME_CONTEXT_TITLEBAR:
+ case OB_FRAME_CONTEXT_FRAME:
+ case OB_FRAME_CONTEXT_MOVE_RESIZE:
+ case OB_FRAME_CONTEXT_LEFT:
+ case OB_FRAME_CONTEXT_RIGHT:
+ break;
+ case OB_FRAME_CONTEXT_ROOT:
+ x = OB_FRAME_CONTEXT_DESKTOP;
+ break;
+ case OB_FRAME_CONTEXT_BOTTOM:
+ case OB_FRAME_CONTEXT_BLCORNER:
+ case OB_FRAME_CONTEXT_BRCORNER:
+ x = OB_FRAME_CONTEXT_BOTTOM;
+ break;
+ case OB_FRAME_CONTEXT_TLCORNER:
+ case OB_FRAME_CONTEXT_TRCORNER:
+ case OB_FRAME_CONTEXT_TOP:
+ case OB_FRAME_CONTEXT_MAXIMIZE:
+ case OB_FRAME_CONTEXT_ALLDESKTOPS:
+ case OB_FRAME_CONTEXT_SHADE:
+ case OB_FRAME_CONTEXT_ICONIFY:
+ case OB_FRAME_CONTEXT_ICON:
+ case OB_FRAME_CONTEXT_CLOSE:
+ x = OB_FRAME_CONTEXT_TITLEBAR;
+ break;
+ case OB_FRAME_NUM_CONTEXTS:
+ g_assert_not_reached();
+ }
+
+ /* allow for multiple levels of fall-through */
+ if (x != context)
+ return mouse_button_frame_context(x, button, state);
+ else
+ return x;
+}