Keep track of the currently targetted client for user events in event.c/h
authorDana Jansens <danakj@orodu.net>
Fri, 29 Jul 2011 19:58:35 +0000 (15:58 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 16 Oct 2011 22:55:14 +0000 (18:55 -0400)
openbox/event.c
openbox/event.h

index 8a39ecdb44d9ea8ee49620bdd4476186c7382f8c..9fbc3fe6b69e6818ca727f94139dfa5734754908 100644 (file)
@@ -116,6 +116,7 @@ static guint focus_delay_timeout_id = 0;
 static ObClient *focus_delay_timeout_client = NULL;
 static guint unfocus_delay_timeout_id = 0;
 static ObClient *unfocus_delay_timeout_client = NULL;
+static ObClient *current_target = NULL;
 
 #ifdef USE_SM
 static gboolean ice_handler(GIOChannel *source, GIOCondition cond,
@@ -2030,6 +2031,8 @@ static void event_handle_menu(ObMenuFrame *frame, XEvent *ev)
 
 static gboolean event_handle_user_input(ObClient *client, XEvent *e)
 {
+    gboolean used = FALSE;
+
     g_assert(e->type == ButtonPress || e->type == ButtonRelease ||
              e->type == MotionNotify || e->type == KeyPress ||
              e->type == KeyRelease);
@@ -2039,32 +2042,36 @@ static gboolean event_handle_user_input(ObClient *client, XEvent *e)
             /* don't use the event if the menu used it, but if the menu
                didn't use it and it's a keypress that is bound, it will
                close the menu and be used */
-            return TRUE;
+            used = TRUE;
     }
 
     /* if the keyboard interactive action uses the event then dont
        use it for bindings. likewise is moveresize uses the event. */
-    if (action_interactive_input_event(e) || moveresize_event(e))
-        return TRUE;
+    else if (action_interactive_input_event(e) || moveresize_event(e))
+        used = TRUE;
 
-    if (moveresize_in_progress)
-        /* make further actions work on the client being
-           moved/resized */
-        client = moveresize_client;
-
-    if (e->type == ButtonPress ||
+    else if (e->type == ButtonPress ||
         e->type == ButtonRelease ||
         e->type == MotionNotify)
     {
         /* the frame may not be "visible" but they can still click on it
            in the case where it is animating before disappearing */
-        if (!client || !frame_iconify_animating(client->frame))
-            return mouse_event(client, e);
-    } else
-        return keyboard_event((focus_cycle_target ? focus_cycle_target :
-                               (client ? client : focus_client)), e);
+        if (!client || !frame_iconify_animating(client->frame)) {
+            current_target = (moveresize_in_progress ? moveresize_client :
+                              client);
+            used = mouse_event(current_target, e);
+            current_target = NULL;
+        }
+    } else {
+        current_target = (focus_cycle_target ? focus_cycle_target :
+                          (moveresize_in_progress ? moveresize_client :
+                           (client ? client :
+                            focus_client)));
+        used = keyboard_event(current_target, e);
+        current_target = NULL;
+    }
 
-    return FALSE;
+    return used;
 }
 
 static void focus_delay_dest(gpointer data)
@@ -2285,3 +2292,8 @@ void event_reset_user_time(void)
 {
     event_last_user_time = CurrentTime;
 }
+
+struct _ObClient* event_current_target(void)
+{
+    return current_target;
+}
index 4d9984e16c04ded47a499d047e9e6ba729092f3a..f105f815cfe0288b9e0e409ca20cfc472df47c10 100644 (file)
@@ -88,4 +88,8 @@ void event_update_user_time(void);
 /*! Reset the timestamp for when the user has last used the focused window. */
 void event_reset_user_time(void);
 
+/*! Returns a client that is the current target of a user input event, or NULL
+  if there is none. */
+struct _ObClient* event_current_target(void);
+
 #endif