Fix move command parsing.
[fvwm.git] / fvwm / ewmh_conf.c
blob9e547d28a70753dde13db44dd979be5a1a4adddc
1 /* -*-c-*- */
2 /* Copyright (C) 2001 Olivier Chapuis */
3 /* This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #include "config.h"
20 #include <stdio.h>
22 #include <X11/Xlib.h>
23 #include <X11/Xmd.h>
25 #include "libs/fvwmlib.h"
26 #include "libs/Parse.h"
27 #include "libs/Strings.h"
28 #include "fvwm.h"
29 #include "cursor.h"
30 #include "functions.h"
31 #include "misc.h"
32 #include "screen.h"
33 #include "update.h"
34 #include "stack.h"
35 #include "style.h"
36 #include "externs.h"
37 #include "icons.h"
38 #include "ewmh.h"
39 #include "ewmh_intern.h"
40 #include "move_resize.h"
43 * CMDS
46 static
47 void set_state_workaround(void)
49 FvwmWindow *t;
51 for (t = Scr.FvwmRoot.next; t != NULL; t = t->next)
53 if ((t->Desk != Scr.CurrentDesk) &&
54 (!is_window_sticky_across_desks(t) &&
55 !IS_ICON_UNMAPPED(t)))
57 if (Scr.bo.do_enable_ewmh_iconic_state_workaround)
59 SetMapStateProp(t, NormalState);
61 else
63 SetMapStateProp(t, IconicState);
69 Bool EWMH_BugOpts(char *opt, Bool toggle)
71 Bool save_isw = Scr.bo.do_enable_ewmh_iconic_state_workaround;
73 if (StrEquals(opt,"EWMHIconicStateWorkaround"))
75 switch (toggle)
77 case -1:
78 Scr.bo.do_enable_ewmh_iconic_state_workaround ^= 1;
79 break;
80 case 0:
81 case 1:
82 Scr.bo.do_enable_ewmh_iconic_state_workaround = toggle;
83 break;
84 default:
85 Scr.bo.do_enable_ewmh_iconic_state_workaround = 0;
86 break;
88 if (save_isw != Scr.bo.do_enable_ewmh_iconic_state_workaround)
90 set_state_workaround();
92 return True;
95 return False;
98 void CMD_EwmhNumberOfDesktops(F_CMD_ARGS)
100 int val[2];
101 int num;
103 num = GetIntegerArguments(action, NULL, val, 2);
104 if ((num != 1 && num != 2) || val[0] < 1 ||
105 (num == 2 && val[1] < val[0] && val[1] != 0))
107 fvwm_msg(ERR,"EwmhNumberOfDesktops",
108 "Bad arguments to EwmhNumberOfDesktops");
109 return;
112 if (num == 2 && ewmhc.MaxDesktops != val[1])
114 ewmhc.MaxDesktops = val[1];
115 num = 3;
117 else if (num == 1 && ewmhc.MaxDesktops != 0)
119 ewmhc.MaxDesktops = 0;
120 num = 3;
123 if (ewmhc.NumberOfDesktops != val[0])
125 ewmhc.NumberOfDesktops = val[0];
126 num = 3;
129 if (num == 3)
131 ewmhc.NeedsToCheckDesk = True;
132 EWMH_SetNumberOfDesktops();
136 void CMD_EwmhBaseStruts(F_CMD_ARGS)
138 int val[4];
140 if (GetIntegerArguments(action, NULL, val, 4) != 4 ||
141 val[0] < 0 || val[1] < 0 || val[2] < 0 || val[3] < 0)
143 fvwm_msg(ERR,"CMD_EwmhBaseStruts",
144 "EwmhBaseStruts needs four positive arguments");
145 return;
148 if (ewmhc.BaseStrut.left != val[0] ||
149 ewmhc.BaseStrut.right != val[1] ||
150 ewmhc.BaseStrut.top != val[2] ||
151 ewmhc.BaseStrut.bottom != val[3])
153 ewmhc.BaseStrut.left = val[0];
154 ewmhc.BaseStrut.right = val[1];
155 ewmhc.BaseStrut.top = val[2];
156 ewmhc.BaseStrut.bottom = val[3];
157 ewmh_ComputeAndSetWorkArea();
158 ewmh_HandleDynamicWorkArea();
162 * Styles
165 Bool EWMH_CMD_Style(char *token, window_style *ptmpstyle, int on)
167 int found = False;
169 if (StrEquals(token, "EWMHDonateIcon"))
171 found = True;
172 S_SET_DO_EWMH_DONATE_ICON(SCF(*ptmpstyle), on);
173 S_SET_DO_EWMH_DONATE_ICON(SCM(*ptmpstyle), 1);
174 S_SET_DO_EWMH_DONATE_ICON(SCC(*ptmpstyle), 1);
176 else if (StrEquals(token, "EWMHDonateMiniIcon"))
178 found = True;
179 S_SET_DO_EWMH_DONATE_MINI_ICON(SCF(*ptmpstyle), on);
180 S_SET_DO_EWMH_DONATE_MINI_ICON(SCM(*ptmpstyle), 1);
181 S_SET_DO_EWMH_DONATE_MINI_ICON(SCC(*ptmpstyle), 1);
183 else if (StrEquals(token, "EWMHDontDonateIcon"))
185 found = True;
186 S_SET_DO_EWMH_DONATE_ICON(SCF(*ptmpstyle), !on);
187 S_SET_DO_EWMH_DONATE_ICON(SCM(*ptmpstyle), 1);
188 S_SET_DO_EWMH_DONATE_ICON(SCC(*ptmpstyle), 1);
190 else if (StrEquals(token, "EWMHDontDonateMiniIcon"))
192 found = True;
193 S_SET_DO_EWMH_DONATE_MINI_ICON(SCF(*ptmpstyle), !on);
194 S_SET_DO_EWMH_DONATE_MINI_ICON(SCM(*ptmpstyle), 1);
195 S_SET_DO_EWMH_DONATE_MINI_ICON(SCC(*ptmpstyle), 1);
197 else if (StrEquals(token, "EWMHMaximizeIgnoreWorkingArea"))
199 found = True;
200 S_SET_EWMH_MAXIMIZE_MODE(
201 SCF(*ptmpstyle), EWMH_IGNORE_WORKING_AREA);
202 S_SET_EWMH_MAXIMIZE_MODE(
203 SCM(*ptmpstyle), EWMH_WORKING_AREA_MASK);
204 S_SET_EWMH_MAXIMIZE_MODE(
205 SCC(*ptmpstyle), EWMH_WORKING_AREA_MASK);
207 else if (StrEquals(token, "EWMHMaximizeUseWorkingArea"))
209 found = True;
210 S_SET_EWMH_MAXIMIZE_MODE(
211 SCF(*ptmpstyle), EWMH_USE_WORKING_AREA);
212 S_SET_EWMH_MAXIMIZE_MODE(
213 SCM(*ptmpstyle), EWMH_WORKING_AREA_MASK);
214 S_SET_EWMH_MAXIMIZE_MODE(
215 SCC(*ptmpstyle), EWMH_WORKING_AREA_MASK);
217 else if (StrEquals(token, "EWMHMaximizeUseDynamicWorkingArea"))
219 found = True;
220 S_SET_EWMH_MAXIMIZE_MODE(
221 SCF(*ptmpstyle), EWMH_USE_DYNAMIC_WORKING_AREA);
222 S_SET_EWMH_MAXIMIZE_MODE(
223 SCM(*ptmpstyle), EWMH_WORKING_AREA_MASK);
224 S_SET_EWMH_MAXIMIZE_MODE(
225 SCC(*ptmpstyle), EWMH_WORKING_AREA_MASK);
227 else if (StrEquals(token, "EWMHMiniIconOverride"))
229 found = True;
230 S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCF(*ptmpstyle), on);
231 S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCM(*ptmpstyle), 1);
232 S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCC(*ptmpstyle), 1);
234 else if (StrEquals(token, "EWMHNoMiniIconOverride"))
236 found = True;
237 S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCF(*ptmpstyle), !on);
238 S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCM(*ptmpstyle), 1);
239 S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCC(*ptmpstyle), 1);
241 else if (StrEquals(token, "EWMHPlacementIgnoreWorkingArea"))
243 found = True;
244 ptmpstyle->flags.ewmh_placement_mode =
245 EWMH_IGNORE_WORKING_AREA;
246 ptmpstyle->flag_mask.ewmh_placement_mode =
247 EWMH_WORKING_AREA_MASK;
248 ptmpstyle->change_mask.ewmh_placement_mode =
249 EWMH_WORKING_AREA_MASK;
251 else if (StrEquals(token, "EWMHPlacementUseWorkingArea"))
253 found = True;
254 ptmpstyle->flags.ewmh_placement_mode = EWMH_USE_WORKING_AREA;
255 ptmpstyle->flag_mask.ewmh_placement_mode =
256 EWMH_WORKING_AREA_MASK;
257 ptmpstyle->change_mask.ewmh_placement_mode =
258 EWMH_WORKING_AREA_MASK;
260 else if (StrEquals(token, "EWMHPlacementUseDynamicWorkingArea"))
262 found = True;
263 ptmpstyle->flags.ewmh_placement_mode =
264 EWMH_USE_DYNAMIC_WORKING_AREA;
265 ptmpstyle->flag_mask.ewmh_placement_mode =
266 EWMH_WORKING_AREA_MASK;
267 ptmpstyle->change_mask.ewmh_placement_mode =
268 EWMH_WORKING_AREA_MASK;
270 else if (StrEquals(token, "EWMHUseStackingOrderHints"))
272 found = True;
273 S_SET_DO_EWMH_USE_STACKING_HINTS(SCF(*ptmpstyle), on);
274 S_SET_DO_EWMH_USE_STACKING_HINTS(SCM(*ptmpstyle), 1);
275 S_SET_DO_EWMH_USE_STACKING_HINTS(SCC(*ptmpstyle), 1);
277 else if (StrEquals(token, "EWMHIgnoreStackingOrderHints"))
279 found = True;
280 S_SET_DO_EWMH_USE_STACKING_HINTS(SCF(*ptmpstyle), !on);
281 S_SET_DO_EWMH_USE_STACKING_HINTS(SCM(*ptmpstyle), 1);
282 S_SET_DO_EWMH_USE_STACKING_HINTS(SCC(*ptmpstyle), 1);
284 else if (StrEquals(token, "EWMHUseStateHints"))
286 found = True;
287 S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCF(*ptmpstyle), !on);
288 S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCM(*ptmpstyle), 1);
289 S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCC(*ptmpstyle), 1);
291 else if (StrEquals(token, "EWMHIgnoreStateHints"))
293 found = True;
294 S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCF(*ptmpstyle), on);
295 S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCM(*ptmpstyle), 1);
296 S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCC(*ptmpstyle), 1);
298 else if (StrEquals(token, "EWMHUseStrutHints"))
300 found = True;
301 S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCF(*ptmpstyle), !on);
302 S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCM(*ptmpstyle), 1);
303 S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCC(*ptmpstyle), 1);
305 else if (StrEquals(token, "EWMHIgnoreStrutHints"))
307 found = True;
308 S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCF(*ptmpstyle), on);
309 S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCM(*ptmpstyle), 1);
310 S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCC(*ptmpstyle), 1);
312 else if (StrEquals(token, "EWMHIgnoreWindowType"))
314 found = True;
315 S_SET_DO_EWMH_IGNORE_WINDOW_TYPE(SCF(*ptmpstyle), on);
316 S_SET_DO_EWMH_IGNORE_WINDOW_TYPE(SCM(*ptmpstyle), 1);
317 S_SET_DO_EWMH_IGNORE_WINDOW_TYPE(SCC(*ptmpstyle), 1);
319 return found;