]> icculus.org git repositories - dana/openbox.git/blob - openbox/action.h
Actions say what kind of filter they would like by default (one window or all)
[dana/openbox.git] / openbox / action.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    action.h for the Openbox window manager
4    Copyright (c) 2007-2011   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 #include "obt/keyboard.h"
23
24 #include <glib.h>
25 #include <X11/Xlib.h>
26
27 struct _ObActionList;
28
29 typedef struct _ObActionDefinition   ObActionDefinition;
30 typedef struct _ObAction             ObAction;
31 typedef struct _ObActionData         ObActionData;
32
33 typedef void     (*ObActionDataFreeFunc)(gpointer options);
34 typedef gboolean (*ObActionRunFunc)(ObActionData *data,
35                                     gpointer options);
36 typedef gpointer (*ObActionDataSetupFunc)(GHashTable *config);
37 typedef void     (*ObActionShutdownFunc)(void);
38
39 /* functions for interactive actions */
40 /* return TRUE if the action is going to be interactive, or false to change
41    your mind and make it not */
42 typedef gboolean (*ObActionIPreFunc)(guint initial_state, gpointer options);
43 typedef void     (*ObActionIPostFunc)(gpointer options);
44 typedef gboolean (*ObActionIInputFunc)(guint initial_state,
45                                        XEvent *e,
46                                        ObtIC *ic,
47                                        gpointer options,
48                                        gboolean *used);
49 typedef void     (*ObActionICancelFunc)(gpointer options);
50 typedef gpointer (*ObActionIDataSetupFunc)(GHashTable *config,
51                                            ObActionIPreFunc *pre,
52                                            ObActionIInputFunc *input,
53                                            ObActionICancelFunc *cancel,
54                                            ObActionIPostFunc *post);
55
56 /*! The default filter an action would like if no filter is provided by the
57   user */
58 typedef enum {
59     OB_ACTION_DEFAULT_FILTER_EMPTY,
60     OB_ACTION_DEFAULT_FILTER_SINGLE,
61     OB_ACTION_DEFAULT_FILTER_ALL,
62     OB_NUM_ACTION_DEFAULT_FILTERS
63 } ObActionDefaultFilter;
64
65 struct _ObActionData {
66     ObUserAction uact;
67     guint state;
68     gint x;
69     gint y;
70     gint button;
71
72     struct _ObClient *client;
73     ObFrameContext context;
74 };
75
76 void action_startup(gboolean reconfigure);
77 void action_shutdown(gboolean reconfigure);
78
79 /*! Use this if the actions created from this name may be interactive */
80 gboolean action_register_i(const gchar *name,
81                            ObActionDefaultFilter def_filter,
82                            ObActionIDataSetupFunc setup,
83                            ObActionDataFreeFunc free,
84                            ObActionRunFunc run);
85
86 gboolean action_register(const gchar *name,
87                          ObActionDefaultFilter def_filter,
88                          ObActionDataSetupFunc setup,
89                          ObActionDataFreeFunc free,
90                          ObActionRunFunc run);
91
92 gboolean action_set_shutdown(const gchar *name,
93                              ObActionShutdownFunc shutdown);
94
95 gboolean action_is_interactive(ObAction *act);
96
97 /*! Create a new ObAction structure.
98   @name The name of the action.
99   @keys The names of the options passed to the action.
100   @values The values of the options passed to the action, paired with the
101     keys.  These are ObActionListValue objects.
102 */
103 ObAction* action_new(const gchar *name, GHashTable *config);
104
105 void action_ref(ObAction *act);
106 void action_unref(ObAction *act);
107
108 /*! Runs a list of actions.
109  @return TRUE if an interactive action was started, FALSE otherwise.
110 */
111 gboolean action_run_acts(struct _ObActionList *acts,
112                          ObUserAction uact,
113                          guint state,
114                          gint x,
115                          gint y,
116                          gint button,
117                          ObFrameContext con,
118                          struct _ObClient *client);
119
120 gboolean action_interactive_act_running(void);
121 void action_interactive_cancel_act(void);
122
123 gboolean action_interactive_input_event(XEvent *e);
124
125 /*! Function for actions to call when they are moving a client around */
126 void action_client_move(ObActionData *data, gboolean start);