change some of the hooks, and add all the hooks to the code so that they run
authorDana Jansens <danakj@orodu.net>
Sat, 1 Mar 2008 04:34:28 +0000 (23:34 -0500)
committerDana Jansens <danakj@orodu.net>
Sat, 1 Mar 2008 04:40:02 +0000 (23:40 -0500)
openbox/client.c
openbox/focus.c
openbox/hooks.c
openbox/hooks.h
openbox/screen.c

index bf1d4f9..7c23e8e 100644 (file)
@@ -33,6 +33,7 @@
 #include "focus.h"
 #include "stacking.h"
 #include "openbox.h"
+#include "hooks.h"
 #include "group.h"
 #include "config.h"
 #include "menuframe.h"
@@ -560,6 +561,8 @@ void client_manage(Window window, ObPrompt *prompt)
 
     ob_debug("Managed window 0x%lx plate 0x%x (%s)",
              window, self->frame->window, self->class);
+
+    hooks_run(OB_HOOK_WIN_NEW, self);
 }
 
 
@@ -635,6 +638,8 @@ void client_unmanage(ObClient *self)
     if (!self->prompt)
         XChangeSaveSet(obt_display, self->window, SetModeDelete);
 
+    hooks_run(OB_HOOK_WIN_CLOSE, self);
+
     /* update the focus lists */
     focus_order_remove(self);
     if (client_focused(self)) {
@@ -2519,6 +2524,8 @@ gboolean client_show(ObClient *self)
            desktop!
         */
         client_change_wm_state(self);
+
+        hooks_run(OB_HOOK_WIN_VISIBLE, self);
     }
     return show;
 }
@@ -2557,6 +2564,8 @@ gboolean client_hide(ObClient *self)
            desktop!
         */
         client_change_wm_state(self);
+
+        hooks_run(OB_HOOK_WIN_INVISIBLE, self);
     }
     return hide;
 }
@@ -3152,6 +3161,8 @@ static void client_iconify_recursive(ObClient *self,
             frame_begin_iconify_animation(self->frame, iconic);
         /* do this after starting the animation so it doesn't flash */
         client_showhide(self);
+
+        hooks_run((iconic ? OB_HOOK_WIN_ICONIC : OB_HOOK_WIN_UNICONIC), self);
     }
 
     /* iconify all direct transients, and deiconify all transients
@@ -3239,6 +3250,8 @@ void client_maximize(ObClient *self, gboolean max, gint dir)
 
     client_setup_decor_and_functions(self, FALSE);
     client_move_resize(self, x, y, w, h);
+
+    hooks_run((max ? OB_HOOK_WIN_MAX : OB_HOOK_WIN_UNMAX), self);
 }
 
 void client_shade(ObClient *self, gboolean shade)
@@ -3252,6 +3265,8 @@ void client_shade(ObClient *self, gboolean shade)
     client_change_wm_state(self); /* the window is being hidden/shown */
     /* resize the frame to just the titlebar */
     frame_adjust_area(self->frame, FALSE, TRUE, FALSE);
+
+    hooks_run((shade ? OB_HOOK_WIN_SHADE : OB_HOOK_WIN_UNSHADE), self);
 }
 
 static void client_ping_event(ObClient *self, gboolean dead)
@@ -3453,6 +3468,9 @@ static void client_set_desktop_recursive(ObClient *self,
             /* the new desktop's geometry may be different, so we may need to
                resize, for example if we are maximized */
             client_reconfigure(self, FALSE);
+
+        if (old != self->desktop)
+            hooks_run(OB_HOOK_WIN_DESK_CHANGE, self);
     }
 
     /* move all transients */
@@ -3855,6 +3873,9 @@ void client_set_undecorated(ObClient *self, gboolean undecorated)
         self->undecorated = undecorated;
         client_setup_decor_and_functions(self, TRUE);
         client_change_state(self); /* reflect this in the state hints */
+
+        hooks_run((undecorated ?
+                   OB_HOOK_WIN_UNDECORATED : OB_HOOK_WIN_DECORATED), self);
     }
 }
 
index 7c15891..5eb27bc 100644 (file)
@@ -27,6 +27,7 @@
 #include "focus_cycle.h"
 #include "screen.h"
 #include "keyboard.h"
+#include "hooks.h"
 #include "focus.h"
 #include "stacking.h"
 #include "obt/prop.h"
@@ -72,6 +73,7 @@ static void push_to_top(ObClient *client)
 void focus_set_client(ObClient *client)
 {
     Window active;
+    ObClient *old;
 
     ob_debug_type(OB_DEBUG_FOCUS,
                   "focus_set_client 0x%lx", client ? client->window : 0);
@@ -87,6 +89,7 @@ void focus_set_client(ObClient *client)
     focus_cycle_stop(focus_client);
     focus_cycle_stop(client);
 
+    old = focus_client;
     focus_client = client;
 
     if (client != NULL) {
@@ -101,6 +104,9 @@ void focus_set_client(ObClient *client)
         active = client ? client->window : None;
         OBT_PROP_SET32(obt_root(ob_screen), NET_ACTIVE_WINDOW, WINDOW, active);
     }
+
+    hooks_run(OB_HOOK_WIN_UNFOCUS, old);
+    hooks_run(OB_HOOK_WIN_FOCUS, client);
 }
 
 static ObClient* focus_fallback_target(gboolean allow_refocus,
index 4cf97c0..2a346c3 100644 (file)
@@ -3,17 +3,21 @@
 
 #include <glib.h>
 
-static GSList *hooks[OB_NUM_HOOKS*2];
+static GSList *hooks[OB_NUM_HOOKS];
 
 void hooks_startup(gboolean reconfig)
 {
+    gint i;
+
+    for (i = 0; i < OB_NUM_HOOKS; ++i)
+        hooks[i] = NULL;
 }
 
 void hooks_shutdown(gboolean reconfig)
 {
     gint i;
 
-    for (i = 0; i < OB_NUM_HOOKS*2; ++i)
+    for (i = 0; i < OB_NUM_HOOKS; ++i)
         while (hooks[i]) {
             actions_act_unref(hooks[i]->data);
             hooks[i] = g_slist_delete_link(hooks[i], hooks[i]);
@@ -46,29 +50,28 @@ ObHook hooks_hook_from_name(const gchar *n)
         return OB_HOOK_WIN_FOCUS;
     if (!g_ascii_strcasecmp(n, "WindowUnfocused"))
         return OB_HOOK_WIN_UNFOCUS;
-    if (!g_ascii_strcasecmp(n, "WindowOnCurrentDesktop"))
-        return OB_HOOK_WIN_CURRENT_DESK;
-    if (!g_ascii_strcasecmp(n, "WindowOnOtherDesktop"))
-        return OB_HOOK_WIN_OTHER_DESK;
+    if (!g_ascii_strcasecmp(n, "WindowOnNewDesktop"))
+        return OB_HOOK_WIN_DESK_CHANGE;
     if (!g_ascii_strcasecmp(n, "WindowDecorated"))
         return OB_HOOK_WIN_DECORATED;
     if (!g_ascii_strcasecmp(n, "WindowUndecorated"))
         return OB_HOOK_WIN_UNDECORATED;
+    if (!g_ascii_strcasecmp(n, "DesktopChanged"))
+        return OB_HOOK_SCREEN_DESK_CHANGE;
     return OB_HOOK_INVALID;
 }
 
-void hooks_fire(ObHook hook, struct _ObClient *c)
+void hooks_run(ObHook hook, struct _ObClient *c)
 {
     GSList *it;
 
     g_assert(hook < OB_NUM_HOOKS);
 
-    for (it = hooks[hook]; it; it = g_slist_next(it))
-        actions_run_acts(it->data,
-                         OB_USER_ACTION_HOOK,
-                         0, -1, -1, 0,
-                         OB_FRAME_CONTEXT_NONE,
-                         c);
+    actions_run_acts(hooks[hook],
+                     OB_USER_ACTION_HOOK,
+                     0, -1, -1, 0,
+                     OB_FRAME_CONTEXT_NONE,
+                     c);
 }
 
 void hooks_add(ObHook hook, struct _ObActionsAct *act)
index 16ed632..442eef0 100644 (file)
@@ -20,10 +20,10 @@ typedef enum {
     OB_HOOK_WIN_UNSHADE,
     OB_HOOK_WIN_FOCUS,
     OB_HOOK_WIN_UNFOCUS,
-    OB_HOOK_WIN_CURRENT_DESK,
-    OB_HOOK_WIN_OTHER_DESK,
+    OB_HOOK_WIN_DESK_CHANGE,
     OB_HOOK_WIN_DECORATED,
     OB_HOOK_WIN_UNDECORATED,
+    OB_HOOK_SCREEN_DESK_CHANGE,
     OB_NUM_HOOKS
 } ObHook;
 
@@ -36,7 +36,7 @@ ObHook hooks_hook_from_name(const gchar *n);
   @param on TRUE if the hook is being run cuz a state was turned on, FALSE
             if a state was turned off
 */
-void hooks_fire(ObHook hook, struct _ObClient *c);
+void hooks_run(ObHook hook, struct _ObClient *c);
 
 void hooks_add(ObHook hook, struct _ObActionsAct *act);
 
index 60638a8..3432ac4 100644 (file)
@@ -31,6 +31,7 @@
 #include "event.h"
 #include "focus.h"
 #include "popup.h"
+#include "hooks.h"
 #include "render/render.h"
 #include "gettext.h"
 #include "obt/display.h"
@@ -708,6 +709,8 @@ void screen_set_desktop(guint num, gboolean dofocus)
 
     if (event_curtime != CurrentTime)
         screen_desktop_user_time = event_curtime;
+
+    hooks_run(OB_HOOK_SCREEN_DESK_CHANGE, NULL);
 }
 
 void screen_add_desktop(gboolean current)