]> icculus.org git repositories - dana/openbox.git/blob - openbox/actions.h
Make it possible for an action name to choose whether it is interactive or not based...
[dana/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/parse.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
39 /* functions for interactive actions */
40 typedef void     (*ObActionsIPreFunc)(gpointer options);
41 typedef void     (*ObActionsIPostFunc)(gpointer options);
42 typedef gboolean (*ObActionsIInputFunc)(guint initial_state,
43                                                   XEvent *e,
44                                                   gpointer options,
45                                                   gboolean *used);
46 typedef void     (*ObActionsICancelFunc)(gpointer options);
47 typedef gpointer (*ObActionsIDataSetupFunc)(xmlNodePtr node,
48                                             ObActionsIPreFunc *pre,
49                                             ObActionsIInputFunc *input,
50                                             ObActionsICancelFunc *cancel,
51                                             ObActionsIPostFunc *post);
52
53 struct _ObActionsData {
54     ObUserAction uact;
55     guint state;
56     gint x;
57     gint y;
58     gint button;
59
60     struct _ObClient *client;
61     ObFrameContext context;
62 };
63
64 void actions_startup(gboolean reconfigure);
65 void actions_shutdown(gboolean reconfigure);
66
67 /*! Use this if the actions created from this name may be interactive */
68 gboolean actions_register_i(const gchar *name,
69                             ObActionsIDataSetupFunc setup,
70                             ObActionsDataFreeFunc free,
71                             ObActionsRunFunc run);
72
73 gboolean actions_register(const gchar *name,
74                           ObActionsDataSetupFunc setup,
75                           ObActionsDataFreeFunc free,
76                           ObActionsRunFunc run);
77
78 ObActionsAct* actions_parse(xmlNodePtr node);
79 ObActionsAct* actions_parse_string(const gchar *name);
80
81 gboolean actions_act_is_interactive(ObActionsAct *act);
82
83 void actions_act_ref(ObActionsAct *act);
84 void actions_act_unref(ObActionsAct *act);
85
86 /*! When this is true, an XAllowEvents with ReplayPointer will be called
87   if an action is going to maybe try moving windows around on screen (or
88   map/unmap windows)
89 */
90 void actions_set_need_pointer_replay_before_move(gboolean replay);
91 /*! Returns if a ReplayPointer is still needed.  If it was called while running
92   actions then this will be false */
93 gboolean actions_get_need_pointer_replay_before_move(void);
94
95 /*! Pass in a GSList of ObActionsAct's to be run. */
96 void actions_run_acts(GSList *acts,
97                       ObUserAction uact,
98                       guint state,
99                       gint x,
100                       gint y,
101                       gint button,
102                       ObFrameContext con,
103                       struct _ObClient *client);
104
105 gboolean actions_interactive_act_running(void);
106 void actions_interactive_cancel_act(void);
107
108 gboolean actions_interactive_input_event(XEvent *e);
109
110 /*! Function for actions to call when they are moving a client around */
111 void actions_client_move(ObActionsData *data, gboolean start);