make mouse use the new action stuff
[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 "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 enum {
34     OB_ACTION_DONE,
35     OB_ACTION_CANCELLED,
36     OB_ACTION_INTERACTING,
37     OB_NUM_ACTIONS_INTERACTIVE_STATES
38 } ObActionsInteractiveState;
39
40 typedef gpointer (*ObActionsDataSetupFunc)(ObParseInst *i,
41                                            xmlDocPtr doc, xmlNodePtr node);
42 typedef void     (*ObActionsDataFreeFunc)(gpointer options);
43 typedef void     (*ObActionsRunFunc)(ObActionsData *data,
44                                      gpointer options);
45
46 /*
47   The theory goes:
48
49   06:10 (@dana) hm i think there are 3 types of actions
50   06:10 (@dana) global actions, window actions, and selector actions
51   06:11 (@dana) eg show menu/exit, raise/focus, and cycling/directional/expose
52 */
53
54 typedef enum {
55     OB_ACTION_TYPE_GLOBAL,
56     OB_ACTION_TYPE_CLIENT,
57     OB_ACTION_TYPE_SELECTOR
58 } ObActionsType;
59
60 /* These structures are all castable as eachother */
61
62 struct _ObActionsAnyData {
63     ObUserAction uact;
64     Time time;
65     guint state;
66     guint button;
67     gint x;
68     gint y;
69 };
70
71 struct _ObActionsGlobalData {
72     ObActionsType type;
73     ObActionsAnyData any;
74 };
75
76 struct _ObActionsClientData {
77     ObActionsType type;
78     ObActionsAnyData any;
79
80     struct _ObClient *c;
81     ObFrameContext context;
82 };
83
84 struct _ObActionsSelectorData {
85     ObActionsType type;
86     ObActionsAnyData any;
87
88     ObActionsInteractiveState interactive;
89     GSList *actions;
90 };
91
92 struct _ObActionsData {
93     ObActionsType type;
94
95     union {
96         ObActionsAnyData      any;
97         ObActionsGlobalData   global;
98         ObActionsClientData   client;
99         ObActionsSelectorData selector;
100     };
101 };
102
103 void actions_startup(gboolean reconfigure);
104 void actions_shutdown(gboolean reconfigure);
105
106 gboolean actions_register(const gchar *name,
107                           ObActionsType type,
108                           ObActionsDataSetupFunc setup,
109                           ObActionsDataFreeFunc free,
110                           ObActionsRunFunc run);
111
112 ObActionsAct* actions_parse(ObParseInst *i,
113                             xmlDocPtr doc,
114                             xmlNodePtr node);
115 ObActionsAct* actions_parse_string(const gchar *name);
116
117 void actions_act_ref(ObActionsAct *act);
118 void actions_act_unref(ObActionsAct *act);
119
120 /*! Pass in a GSList of ObActionsAct's to be run */
121 void actions_run_acts(GSList *acts,
122                       ObUserAction uact,
123                       Time time,
124                       guint state,
125                       guint button,
126                       gint x,
127                       gint y,
128                       ObFrameContext con,
129                       struct _ObClient *client,
130                       ObActionsInteractiveState interactive);