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