]> Dogcows Code - chaz/openbox/blob - openbox/hooks.c
change some of the hooks, and add all the hooks to the code so that they run
[chaz/openbox] / openbox / hooks.c
1 #include "hooks.h"
2 #include "actions.h"
3
4 #include <glib.h>
5
6 static GSList *hooks[OB_NUM_HOOKS];
7
8 void hooks_startup(gboolean reconfig)
9 {
10 gint i;
11
12 for (i = 0; i < OB_NUM_HOOKS; ++i)
13 hooks[i] = NULL;
14 }
15
16 void hooks_shutdown(gboolean reconfig)
17 {
18 gint i;
19
20 for (i = 0; i < OB_NUM_HOOKS; ++i)
21 while (hooks[i]) {
22 actions_act_unref(hooks[i]->data);
23 hooks[i] = g_slist_delete_link(hooks[i], hooks[i]);
24 }
25 }
26
27 ObHook hooks_hook_from_name(const gchar *n)
28 {
29 if (!g_ascii_strcasecmp(n, "WindowNew"))
30 return OB_HOOK_WIN_NEW;
31 if (!g_ascii_strcasecmp(n, "WindowClosed"))
32 return OB_HOOK_WIN_CLOSE;
33 if (!g_ascii_strcasecmp(n, "WindowVisible"))
34 return OB_HOOK_WIN_VISIBLE;
35 if (!g_ascii_strcasecmp(n, "WindowInvisible"))
36 return OB_HOOK_WIN_INVISIBLE;
37 if (!g_ascii_strcasecmp(n, "WindowIconified"))
38 return OB_HOOK_WIN_ICONIC;
39 if (!g_ascii_strcasecmp(n, "WindowUniconified"))
40 return OB_HOOK_WIN_UNICONIC;
41 if (!g_ascii_strcasecmp(n, "WindowMaximized"))
42 return OB_HOOK_WIN_MAX;
43 if (!g_ascii_strcasecmp(n, "WindowUnmaximized"))
44 return OB_HOOK_WIN_UNMAX;
45 if (!g_ascii_strcasecmp(n, "WindowShaded"))
46 return OB_HOOK_WIN_SHADE;
47 if (!g_ascii_strcasecmp(n, "WindowUnshaded"))
48 return OB_HOOK_WIN_UNSHADE;
49 if (!g_ascii_strcasecmp(n, "WindowFocused"))
50 return OB_HOOK_WIN_FOCUS;
51 if (!g_ascii_strcasecmp(n, "WindowUnfocused"))
52 return OB_HOOK_WIN_UNFOCUS;
53 if (!g_ascii_strcasecmp(n, "WindowOnNewDesktop"))
54 return OB_HOOK_WIN_DESK_CHANGE;
55 if (!g_ascii_strcasecmp(n, "WindowDecorated"))
56 return OB_HOOK_WIN_DECORATED;
57 if (!g_ascii_strcasecmp(n, "WindowUndecorated"))
58 return OB_HOOK_WIN_UNDECORATED;
59 if (!g_ascii_strcasecmp(n, "DesktopChanged"))
60 return OB_HOOK_SCREEN_DESK_CHANGE;
61 return OB_HOOK_INVALID;
62 }
63
64 void hooks_run(ObHook hook, struct _ObClient *c)
65 {
66 GSList *it;
67
68 g_assert(hook < OB_NUM_HOOKS);
69
70 actions_run_acts(hooks[hook],
71 OB_USER_ACTION_HOOK,
72 0, -1, -1, 0,
73 OB_FRAME_CONTEXT_NONE,
74 c);
75 }
76
77 void hooks_add(ObHook hook, struct _ObActionsAct *act)
78 {
79 g_assert(hook < OB_NUM_HOOKS);
80
81 /* append so they are executed in the same order as they appear in the
82 config file */
83 hooks[hook] = g_slist_append(hooks[hook], act);
84 }
This page took 0.034619 seconds and 4 git commands to generate.