6 #include "obt/display.h"
10 static GSList *hooks[OB_NUM_HOOKS];
11 static const gchar *names[OB_NUM_HOOKS];
15 struct _ObClient *client;
19 ObHookQueue run_queue[QUEUE_SIZE];
22 void hooks_startup(gboolean reconfig)
26 for (i = 0; i < OB_NUM_HOOKS; ++i)
31 names[OB_HOOK_WIN_NEW] = "WindowNew";
32 names[OB_HOOK_WIN_CLOSE] = "WindowClosed";
33 names[OB_HOOK_WIN_VISIBLE] = "WindowVisible";
34 names[OB_HOOK_WIN_INVISIBLE] = "WindowInvisible";
35 names[OB_HOOK_WIN_ICONIC] = "WindowIconified";
36 names[OB_HOOK_WIN_UNICONIC] = "WindowUniconified";
37 names[OB_HOOK_WIN_MAX] = "WindowMaximized";
38 names[OB_HOOK_WIN_UNMAX] = "WindowUnmaximized";
39 names[OB_HOOK_WIN_SHADE] = "WindowShaded";
40 names[OB_HOOK_WIN_UNSHADE] = "WindowUnshaded";
41 names[OB_HOOK_WIN_FOCUS] = "WindowFocused";
42 names[OB_HOOK_WIN_UNFOCUS] = "WindowUnfocused";
43 names[OB_HOOK_WIN_DESK_CHANGE] = "WindowOnNewDesktop";
44 names[OB_HOOK_WIN_DECORATED] = "WindowDecorated";
45 names[OB_HOOK_WIN_UNDECORATED] = "WindowUndecorated";
46 names[OB_HOOK_SCREEN_DESK_CHANGE] = "DesktopChanged";
49 void hooks_shutdown(gboolean reconfig)
53 for (i = 0; i < OB_NUM_HOOKS; ++i)
55 actions_act_unref(hooks[i]->data);
56 hooks[i] = g_slist_delete_link(hooks[i], hooks[i]);
60 ObHook hooks_hook_from_name(const gchar *n)
64 for (i = 1; i < OB_NUM_HOOKS; ++i)
65 if (!g_ascii_strcasecmp(n, names[i]))
67 return OB_HOOK_INVALID;
70 void hooks_queue(ObHook hook, struct _ObClient *client)
74 g_assert(hook < OB_NUM_HOOKS && hook > OB_HOOK_INVALID);
76 //ob_debug("Queing hook %s for client 0x%x", names[hook],
77 // (client ? client->window : 0));
78 q = &run_queue[queue_size++];
82 if (queue_size == QUEUE_SIZE)
87 void hooks_run(ObHook hook, struct _ObClient *c)
93 void hooks_add(ObHook hook, struct _ObActionsAct *act)
95 g_assert(hook < OB_NUM_HOOKS && hook > OB_HOOK_INVALID);
97 /* append so they are executed in the same order as they appear in the
99 hooks[hook] = g_slist_append(hooks[hook], act);
102 void hooks_run_queue(void)
106 for (i = 0; i < queue_size; ++i) {
107 const ObHookQueue *q = &run_queue[i];
109 //ob_debug("Running hook %s for client 0x%x", names[q->hook],
110 // (q->client ? q->client->window : 0));
111 actions_run_acts(hooks[q->hook],
114 OB_FRAME_CONTEXT_NONE,