10 static gboolean comment;
11 static gboolean error;
18 static void endofline();
19 static int mparsewrap();
20 static void gotfield();
21 static void addbinding();
24 field [A-Za-z0-9][-A-Za-z0-9]*[^-]
30 ^{white}# comment = TRUE;
38 static void gotfield()
42 context = g_strdup(mparsetext);
43 else if (event == NULL)
44 event = g_strdup(mparsetext);
45 else if (button == NULL)
46 button = g_strdup(mparsetext);
47 else if (action == NULL)
48 action = g_strdup(mparsetext);
54 static void endofline()
57 if (!error && context && event && button && action)
59 else if (error || context || event || button || action)
60 g_warning("Parser error in '%s' on line %d", path, lineno);
63 comment = error = FALSE;
64 g_free(context); g_free(event); g_free(button); g_free(action);
65 context = event = button = action = NULL;
70 static void addbinding()
75 if (!g_ascii_strcasecmp(event, "press"))
76 mact = MouseAction_Press;
77 else if (!g_ascii_strcasecmp(event, "release"))
78 mact = MouseAction_Release;
79 else if (!g_ascii_strcasecmp(event, "click"))
80 mact = MouseAction_Click;
81 else if (!g_ascii_strcasecmp(event, "doubleclick"))
82 mact = MouseAction_DClick;
83 else if (!g_ascii_strcasecmp(event, "drag"))
84 mact = MouseAction_Motion;
86 g_warning("Invalid event '%s' in '%s' on line %d", event, path,
91 if (!g_ascii_strcasecmp(action, "focus")) {
92 a = action_new(action_focus);
93 } else if (!g_ascii_strcasecmp(action, "unfocus")) {
94 a = action_new(action_unfocus);
95 } else if (!g_ascii_strcasecmp(action, "iconify")) {
96 a = action_new(action_iconify);
97 } else if (!g_ascii_strcasecmp(action, "raise")) {
98 a = action_new(action_raise);
99 } else if (!g_ascii_strcasecmp(action, "lower")) {
100 a = action_new(action_lower);
101 } else if (!g_ascii_strcasecmp(action, "focusraise")) {
102 a = action_new(action_focusraise);
103 } else if (!g_ascii_strcasecmp(action, "close")) {
104 a = action_new(action_close);
105 } else if (!g_ascii_strcasecmp(action, "kill")) {
106 a = action_new(action_kill);
107 } else if (!g_ascii_strcasecmp(action, "shade")) {
108 a = action_new(action_shade);
109 } else if (!g_ascii_strcasecmp(action, "unshade")) {
110 a = action_new(action_unshade);
111 } else if (!g_ascii_strcasecmp(action, "toggleshade")) {
112 a = action_new(action_toggle_shade);
113 } else if (!g_ascii_strcasecmp(action, "toggleomnipresent")) {
114 a = action_new(action_toggle_omnipresent);
115 } else if (!g_ascii_strcasecmp(action, "maximizefull")) {
116 a = action_new(action_maximize_full);
117 } else if (!g_ascii_strcasecmp(action, "unmaximizefull")) {
118 a = action_new(action_unmaximize_full);
119 } else if (!g_ascii_strcasecmp(action, "togglemaximizefull")) {
120 a = action_new(action_toggle_maximize_full);
121 } else if (!g_ascii_strcasecmp(action, "maximizehorz")) {
122 a = action_new(action_maximize_horz);
123 } else if (!g_ascii_strcasecmp(action, "unmaximizehorz")) {
124 a = action_new(action_unmaximize_horz);
125 } else if (!g_ascii_strcasecmp(action, "togglemaximizehorz")) {
126 a = action_new(action_toggle_maximize_horz);
127 } else if (!g_ascii_strcasecmp(action, "maximizevert")) {
128 a = action_new(action_maximize_vert);
129 } else if (!g_ascii_strcasecmp(action, "unmaximizevert")) {
130 a = action_new(action_unmaximize_vert);
131 } else if (!g_ascii_strcasecmp(action, "togglemaximizevert")) {
132 a = action_new(action_toggle_maximize_vert);
133 } else if (!g_ascii_strcasecmp(action, "sendtonextdesktop")) {
134 a = action_new(action_send_to_next_desktop);
135 a->data.sendtonextprev.wrap = FALSE;
136 a->data.sendtonextprev.follow = TRUE;
137 } else if (!g_ascii_strcasecmp(action, "sendtonextdesktopwrap")) {
138 a = action_new(action_send_to_next_desktop);
139 a->data.sendtonextprev.wrap = TRUE;
140 a->data.sendtonextprev.follow = TRUE;
141 } else if (!g_ascii_strcasecmp(action, "sendtopreviousdesktop")) {
142 a = action_new(action_send_to_previous_desktop);
143 a->data.sendtonextprev.wrap = FALSE;
144 a->data.sendtonextprev.follow = TRUE;
145 } else if (!g_ascii_strcasecmp(action, "sendtopreviousdesktopwrap")) {
146 a = action_new(action_send_to_previous_desktop);
147 a->data.sendtonextprev.wrap = TRUE;
148 a->data.sendtonextprev.follow = TRUE;
149 } else if (!g_ascii_strcasecmp(action, "nextdesktop")) {
150 a = action_new(action_next_desktop);
151 a->data.nextprevdesktop.wrap = FALSE;
152 } else if (!g_ascii_strcasecmp(action, "nextdesktopwrap")) {
153 a = action_new(action_next_desktop);
154 a->data.nextprevdesktop.wrap = TRUE;
155 } else if (!g_ascii_strcasecmp(action, "previousdesktop")) {
156 a = action_new(action_previous_desktop);
157 a->data.nextprevdesktop.wrap = FALSE;
158 } else if (!g_ascii_strcasecmp(action, "previousdesktopwrap")) {
159 a = action_new(action_previous_desktop);
160 a->data.nextprevdesktop.wrap = TRUE;
161 } else if (!g_ascii_strcasecmp(action, "nextdesktopcolumn")) {
162 a = action_new(action_next_desktop_column);
163 a->data.nextprevdesktop.wrap = FALSE;
164 } else if (!g_ascii_strcasecmp(action, "nextdesktopcolumnwrap")) {
165 a = action_new(action_next_desktop_column);
166 a->data.nextprevdesktop.wrap = TRUE;
167 } else if (!g_ascii_strcasecmp(action, "previousdesktopcolumn")) {
168 a = action_new(action_previous_desktop_column);
169 a->data.nextprevdesktop.wrap = FALSE;
170 } else if (!g_ascii_strcasecmp(action, "previousdesktopcolumnwrap")) {
171 a = action_new(action_previous_desktop_column);
172 a->data.nextprevdesktop.wrap = TRUE;
173 } else if (!g_ascii_strcasecmp(action, "nextdesktoprow")) {
174 a = action_new(action_next_desktop_row);
175 a->data.nextprevdesktop.wrap = FALSE;
176 } else if (!g_ascii_strcasecmp(action, "nextdesktoprowwrap")) {
177 a = action_new(action_next_desktop_row);
178 a->data.nextprevdesktop.wrap = TRUE;
179 } else if (!g_ascii_strcasecmp(action, "previousdesktoprow")) {
180 a = action_new(action_previous_desktop_row);
181 a->data.nextprevdesktop.wrap = FALSE;
182 } else if (!g_ascii_strcasecmp(action, "previousdesktoprowwrap")) {
183 a = action_new(action_previous_desktop_row);
184 a->data.nextprevdesktop.wrap = TRUE;
185 } else if (!g_ascii_strcasecmp(action, "move") &&
186 mact == MouseAction_Motion) {
187 a = action_new(action_move);
188 } else if (!g_ascii_strcasecmp(action, "resize") &&
189 mact == MouseAction_Motion) {
190 a = action_new(action_resize);
192 g_warning("Invalid action '%s' in '%s' on line %d", action, path,
197 if (!mbind(button, context, mact, a)) {
199 g_warning("Unable to add binding '%s %s %s %s'",
200 context, event, button, action);
205 static int mparsewrap()
207 g_free(context); g_free(event); g_free(button); g_free(action);
213 path = g_build_filename(g_get_home_dir(), ".openbox", "mouserc", NULL);
214 if ((mparsein = fopen(path, "r")) == NULL) {
216 path = g_build_filename(RCDIR, "mouserc", NULL);
217 if ((mparsein = fopen(path, "r")) == NULL) {
218 g_warning("No mouserc file found!");
227 context = event = button = action = NULL;