10 static gboolean error;
17 static void endofline();
18 static int mparsewrap();
19 static void gotfield();
20 static void addbinding();
23 field [A-Za-z0-9][-A-Za-z0-9]*
28 ^{white}#.*\n lineno++;
36 static void gotfield()
39 context = g_strdup(mparsetext);
40 else if (event == NULL)
41 event = g_strdup(mparsetext);
42 else if (button == NULL)
43 button = g_strdup(mparsetext);
44 else if (action == NULL)
45 action = g_strdup(mparsetext);
50 static void endofline()
52 if (!error && context && event && button && action)
54 else if (error || context || event || button || action)
55 g_warning("Parser error in '%s' on line %d", path, lineno);
58 g_free(context); g_free(event); g_free(button); g_free(action);
59 context = event = button = action = NULL;
64 static void addbinding()
69 if (!g_ascii_strcasecmp(event, "press"))
70 mact = MouseAction_Press;
71 else if (!g_ascii_strcasecmp(event, "release"))
72 mact = MouseAction_Release;
73 else if (!g_ascii_strcasecmp(event, "click"))
74 mact = MouseAction_Click;
75 else if (!g_ascii_strcasecmp(event, "doubleclick"))
76 mact = MouseAction_DClick;
77 else if (!g_ascii_strcasecmp(event, "drag"))
78 mact = MouseAction_Motion;
80 g_warning("Invalid event '%s' in '%s' on line %d", event, path,
85 a = action_from_string(action);
87 if (mact == MouseAction_Motion) {
88 if (a && !(a->func == action_move || a->func == action_resize)) {
92 /* the below types cannot be used with !motion events, or at all with
94 } else if (a && (a->func == action_move || a->func == action_resize ||
95 a->func == action_execute || a->func == action_desktop ||
96 a->func == action_move_relative_horz ||
97 a->func == action_move_relative_vert ||
98 a->func == action_resize_relative_horz ||
99 a->func == action_resize_relative_vert)) {
104 g_warning("Invalid action '%s' in '%s' on line %d", action, path,
109 if (!mbind(button, context, mact, a)) {
111 g_warning("Unable to add binding '%s %s %s %s'",
112 context, event, button, action);
117 static int mparsewrap()
119 g_free(context); g_free(event); g_free(button); g_free(action);
125 path = g_build_filename(g_get_home_dir(), ".openbox", "mouserc", NULL);
126 if ((mparsein = fopen(path, "r")) == NULL) {
128 path = g_build_filename(RCDIR, "mouserc", NULL);
129 if ((mparsein = fopen(path, "r")) == NULL) {
130 g_warning("No mouserc file found!");
138 context = event = button = action = NULL;