add an optional shutdown function which actions can register
[mikachu/openbox.git] / openbox / actions.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    actions.h for the Openbox window manager
4    Copyright (c) 2007        Dana Jansens
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "misc.h"
20 #include "frame.h"
21 #include "parser/parse.h"
22 #include <glib.h>
23 #include <X11/Xlib.h>
24
25 typedef struct _ObActionsDefinition   ObActionsDefinition;
26 typedef struct _ObActionsAct          ObActionsAct;
27 typedef struct _ObActionsData         ObActionsData;
28 typedef struct _ObActionsAnyData      ObActionsAnyData;
29 typedef struct _ObActionsGlobalData   ObActionsGlobalData;
30 typedef struct _ObActionsClientData   ObActionsClientData;
31 typedef struct _ObActionsSelectorData ObActionsSelectorData;
32
33 typedef gpointer (*ObActionsDataSetupFunc)(ObParseInst *i,
34                                            xmlDocPtr doc, xmlNodePtr node);
35 typedef void     (*ObActionsDataFreeFunc)(gpointer options);
36 typedef gboolean (*ObActionsRunFunc)(ObActionsData *data,
37                                      gpointer options);
38 typedef void     (*ObActionsShutdownFunc)(void);
39 typedef gboolean (*ObActionsInteractiveInputFunc)(guint initial_state,
40                                                   XEvent *e,
41                                                   gpointer options,
42                                                   gboolean *used);
43 typedef void     (*ObActionsInteractiveCancelFunc)(gpointer options);
44
45 struct _ObActionsData {
46     ObUserAction uact;
47     guint state;
48     gint x;
49     gint y;
50     gint button;
51
52     struct _ObClient *client;
53     ObFrameContext context;
54 };
55
56 void actions_startup(gboolean reconfigure);
57 void actions_shutdown(gboolean reconfigure);
58
59 /*! If the action is interactive, then i_input and i_cancel are not NULL.
60   Otherwise, they should both be NULL. */
61 gboolean actions_register(const gchar *name,
62                           ObActionsDataSetupFunc setup,
63                           ObActionsDataFreeFunc free,
64                           ObActionsRunFunc run,
65                           ObActionsInteractiveInputFunc i_input,
66                           ObActionsInteractiveCancelFunc i_cancel);
67
68 gboolean actions_set_shutdown(const gchar *name,
69                               ObActionsShutdownFunc shutdown);
70
71 ObActionsAct* actions_parse(ObParseInst *i,
72                             xmlDocPtr doc,
73                             xmlNodePtr node);
74
75 ObActionsAct* actions_parse_string(const gchar *name);
76
77 gboolean actions_act_is_interactive(ObActionsAct *act);
78
79 void actions_act_ref(ObActionsAct *act);
80 void actions_act_unref(ObActionsAct *act);
81
82 /*! When this is true, an XAllowEvents with ReplayPointer will be called
83   if an action is going to maybe try moving windows around on screen (or
84   map/unmap windows)
85 */
86 void actions_set_need_pointer_replay_before_move(gboolean replay);
87 /*! Returns if a ReplayPointer is still needed.  If it was called while running
88   actions then this will be false */
89 gboolean actions_get_need_pointer_replay_before_move(void);
90
91 /*! Pass in a GSList of ObActionsAct's to be run. */
92 void actions_run_acts(GSList *acts,
93                       ObUserAction uact,
94                       guint state,
95                       gint x,
96                       gint y,
97                       gint button,
98                       ObFrameContext con,
99                       struct _ObClient *client);
100
101 gboolean actions_interactive_act_running(void);
102 void actions_interactive_cancel_act(void);
103
104 gboolean actions_interactive_input_event(XEvent *e);
105
106 /*! Function for actions to call when they are moving a client around */
107 void actions_client_move(ObActionsData *data, gboolean start);