]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/actions.h
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 "obt/xml.h"
22
23 #include <glib.h>
24 #include <X11/Xlib.h>
25
26 typedef struct _ObActionsDefinition   ObActionsDefinition;
27 typedef struct _ObActionsAct          ObActionsAct;
28 typedef struct _ObActionsData         ObActionsData;
29 typedef struct _ObActionsAnyData      ObActionsAnyData;
30 typedef struct _ObActionsGlobalData   ObActionsGlobalData;
31 typedef struct _ObActionsClientData   ObActionsClientData;
32 typedef struct _ObActionsSelectorData ObActionsSelectorData;
33
34 typedef void     (*ObActionsDataFreeFunc)(gpointer options);
35 typedef gboolean (*ObActionsRunFunc)(ObActionsData *data,
36                                      gpointer options);
37 typedef gpointer (*ObActionsDataSetupFunc)(xmlNodePtr node);
38 typedef void     (*ObActionsShutdownFunc)(void);
39
40 /* functions for interactive actions */
41 /* return TRUE if the action is going to be interactive, or false to change
42    your mind and make it not */
43 typedef gboolean (*ObActionsIPreFunc)(guint initial_state, gpointer options);
44 typedef void     (*ObActionsIPostFunc)(gpointer options);
45 typedef gboolean (*ObActionsIInputFunc)(guint initial_state,
46                                                   XEvent *e,
47                                                   gpointer options,
48                                                   gboolean *used);
49 typedef void     (*ObActionsICancelFunc)(gpointer options);
50 typedef gpointer (*ObActionsIDataSetupFunc)(xmlNodePtr node,
51                                             ObActionsIPreFunc *pre,
52                                             ObActionsIInputFunc *input,
53                                             ObActionsICancelFunc *cancel,
54                                             ObActionsIPostFunc *post);
55
56 struct _ObActionsData {
57     ObUserAction uact;
58     guint state;
59     gint x;
60     gint y;
61     gint button;
62
63     struct _ObClient *client;
64     ObFrameContext context;
65 };
66
67 void actions_startup(gboolean reconfigure);
68 void actions_shutdown(gboolean reconfigure);
69
70 /*! Use this if the actions created from this name may be interactive */
71 gboolean actions_register_i(const gchar *name,
72                             ObActionsIDataSetupFunc setup,
73                             ObActionsDataFreeFunc free,
74                             ObActionsRunFunc run);
75
76 gboolean actions_register(const gchar *name,
77                           ObActionsDataSetupFunc setup,
78                           ObActionsDataFreeFunc free,
79                           ObActionsRunFunc run);
80
81 gboolean actions_set_shutdown(const gchar *name,
82                               ObActionsShutdownFunc shutdown);
83
84 ObActionsAct* actions_parse(xmlNodePtr node);
85 ObActionsAct* actions_parse_string(const gchar *name);
86
87 gboolean actions_act_is_interactive(ObActionsAct *act);
88
89 void actions_act_ref(ObActionsAct *act);
90 void actions_act_unref(ObActionsAct *act);
91
92 /*! When this is true, an XAllowEvents with ReplayPointer will be called
93   if an action is going to maybe try moving windows around on screen (or
94   map/unmap windows)
95 */
96 void actions_set_need_pointer_replay_before_move(gboolean replay);
97 /*! Returns if a ReplayPointer is still needed.  If it was called while running
98   actions then this will be false */
99 gboolean actions_get_need_pointer_replay_before_move(void);
100
101 /*! Pass in a GSList of ObActionsAct's to be run. */
102 void actions_run_acts(GSList *acts,
103                       ObUserAction uact,
104                       guint state,
105                       gint x,
106                       gint y,
107                       gint button,
108                       ObFrameContext con,
109                       struct _ObClient *client);
110
111 gboolean actions_interactive_act_running(void);
112 void actions_interactive_cancel_act(void);
113
114 gboolean actions_interactive_input_event(XEvent *e);
115
116 /*! Function for actions to call when they are moving a client around */
117 void actions_client_move(ObActionsData *data, gboolean start);