]> Dogcows Code - chaz/openbox/blobdiff - openbox/keyboard.c
no more interactive mouse actions, they are evil etc. actions now "feel" much more...
[chaz/openbox] / openbox / keyboard.c
index 1f509f77ff8c5e61aa0544690053f95faea16b3d..fe13c97b4c9869ac7a756324fb7e5e5c64d42cb4 100644 (file)
@@ -12,6 +12,7 @@
 #include "keytree.h"
 #include "keyboard.h"
 #include "translate.h"
+#include "moveresize.h"
 
 #include <glib.h>
 
@@ -129,10 +130,15 @@ gboolean keyboard_bind(GList *keylist, ObAction *action)
 }
 
 void keyboard_interactive_grab(guint state, ObClient *client,
-                               ObFrameContext context, ObAction *action)
+                               ObAction *action)
 {
     ObInteractiveState *s;
 
+    g_assert(action->data.any.interactive);
+
+    if (moveresize_in_progress)
+        moveresize_end(FALSE);
+
     if (!interactive_states) {
         if (!grab_keyboard(TRUE))
             return;
@@ -147,14 +153,11 @@ void keyboard_interactive_grab(guint state, ObClient *client,
     s->state = state;
     s->client = client;
     s->action = action;
-    s->context = context;
 
     interactive_states = g_slist_append(interactive_states, s);
 }
 
-gboolean keyboard_process_interactive_grab(const XEvent *e,
-                                           ObClient **client,
-                                           ObFrameContext *context)
+gboolean keyboard_process_interactive_grab(const XEvent *e)
 {
     GSList *it, *next;
     gboolean handled = FALSE;
@@ -166,9 +169,6 @@ gboolean keyboard_process_interactive_grab(const XEvent *e,
 
         next = g_slist_next(it);
         
-        *client = s->client;
-        *context = s->context;
-
         if ((e->type == KeyRelease && 
              !(s->state & e->xkey.state)))
             done = TRUE;
@@ -179,19 +179,18 @@ gboolean keyboard_process_interactive_grab(const XEvent *e,
                 cancel = done = TRUE;
         }
         if (done) {
-            g_assert(s->action->data.any.interactive);
-
-            s->action->data.inter.cancel = cancel;
-            s->action->data.inter.final = TRUE;
-
-            s->action->func(&s->action->data);
-
-            grab_keyboard(FALSE);
-            grab_pointer(FALSE, OB_CURSOR_NONE);
-            keyboard_reset_chains();
+            action_run_interactive(s->action, s->client,
+                                   e->xkey.state, cancel, TRUE);
 
             g_free(s);
+
             interactive_states = g_slist_delete_link(interactive_states, it);
+            if (!interactive_states) {
+                grab_keyboard(FALSE);
+                grab_pointer(FALSE, OB_CURSOR_NONE);
+                keyboard_reset_chains();
+            }
+
             handled = TRUE;
         }
     }
@@ -218,7 +217,8 @@ void keyboard_event(ObClient *client, const XEvent *e)
         p = curpos->first_child;
     while (p) {
         if (p->key == e->xkey.keycode &&
-            p->state == e->xkey.state) {
+            p->state == e->xkey.state)
+        {
             if (p->first_child != NULL) { /* part of a chain */
                 ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
                 /* 5 second timeout for chains */
@@ -229,32 +229,10 @@ void keyboard_event(ObClient *client, const XEvent *e)
                 grab_keys(TRUE);
             } else {
                 GSList *it;
-                for (it = p->actions; it; it = it->next) {
-                    ObAction *act = it->data;
-                    if (act->func != NULL) {
-                        act->data.any.c = client;
-
-                        if (act->func == action_moveresize) {
-                            screen_pointer_pos(&act->data.moveresize.x,
-                                               &act->data.moveresize.y);
-                        }
-
-                        if (act->data.any.interactive) {
-                            act->data.inter.cancel = FALSE;
-                            act->data.inter.final = FALSE;
-                            keyboard_interactive_grab(e->xkey.state, client,
-                                                      0, act);
-                        }
-
-                        if (act->func == action_showmenu) {
-                            act->data.showmenu.x = e->xkey.x_root;
-                            act->data.showmenu.y = e->xkey.y_root;
-                        }
-
-                        act->data.any.c = client;
-                        act->func(&act->data);
-                    }
-                }
+
+                for (it = p->actions; it; it = it->next)
+                    action_run_key(it->data, client, e->xkey.state,
+                                   e->xkey.x_root, e->xkey.y_root);
 
                 keyboard_reset_chains();
             }
This page took 0.024915 seconds and 4 git commands to generate.