cvsimport
[fvwm.git] / fvwm / style.c
blobeebf4f8ba7cea2602d6957bac6b57db3ed0c9589
1 /* -*-c-*- */
2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * This module was all original code
19 * by Rob Nation
20 * Copyright 1993, Robert Nation
21 * You may use this code for any purpose, as long as the original
22 * copyright remains in the source code and all documentation
25 /* code for parsing the fvwm style command */
27 /* ---------------------------- included header files ---------------------- */
29 #include "config.h"
30 #include <stdio.h>
32 #include "libs/fvwmlib.h"
33 #include "libs/FScreen.h"
34 #include "libs/charmap.h"
35 #include "libs/modifiers.h"
36 #include "libs/ColorUtils.h"
37 #include "libs/Parse.h"
38 #include "libs/wild.h"
39 #include "fvwm.h"
40 #include "execcontext.h"
41 #include "misc.h"
42 #include "screen.h"
43 #include "update.h"
44 #include "style.h"
45 #include "colorset.h"
46 #include "ewmh.h"
47 #include "gnome.h"
48 #include "placement.h"
50 /* ---------------------------- local definitions -------------------------- */
52 #define SAFEFREE( p ) {if (p) {free(p);(p)=NULL;}}
54 /* ---------------------------- local macros ------------------------------- */
56 /* ---------------------------- imports ------------------------------------ */
58 /* ---------------------------- included code files ------------------------ */
60 /* ---------------------------- local types -------------------------------- */
62 /* ---------------------------- forward declarations ----------------------- */
64 /* ---------------------------- local variables ---------------------------- */
66 /* list of window names with attributes */
67 static window_style *all_styles = NULL;
68 static window_style *last_style_in_list = NULL;
70 /* ---------------------------- exported variables (globals) --------------- */
72 /* ---------------------------- local functions ---------------------------- */
74 static int blockor(char *dest, char *blk1, char *blk2, int length)
76 int i;
77 char result = 0;
79 for (i = 0; i < length; i++)
81 dest[i] = (blk1[i] | blk2[i]);
82 result |= dest[i];
85 return (result) ? 1 : 0;
88 static int blockand(char *dest, char *blk1, char *blk2, int length)
90 int i;
91 char result = 0;
93 for (i = 0; i < length; i++)
95 dest[i] = (blk1[i] & blk2[i]);
96 result |= dest[i];
99 return (result) ? 1 : 0;
102 static int blockunmask(char *dest, char *blk1, char *blk2, int length)
104 int i;
105 char result = (char)0xff;
107 for (i = 0; i < length; i++)
109 dest[i] = (blk1[i] & ~blk2[i]);
110 result |= dest[i];
113 return (result) ? 1 : 0;
116 static int blockissubset(char *sub, char *super, int length)
118 int i;
120 for (i = 0; i < length; i++)
122 if ((sub[i] & super[i]) != sub[i])
124 return 0;
128 return 1;
131 static int blocksintersect(char *blk1, char *blk2, int length)
133 int i;
135 for (i = 0; i < length; i++)
137 if (blk1[i] & blk2[i])
139 return 1;
143 return 0;
146 static int style_ids_are_equal(style_id_t *a, style_id_t *b)
148 if (
149 SID_GET_HAS_NAME(*a) && SID_GET_HAS_NAME(*b) &&
150 !strcmp(SID_GET_NAME(*a), SID_GET_NAME(*b)))
152 return 1;
154 if (
155 SID_GET_HAS_WINDOW_ID(*a) && SID_GET_HAS_WINDOW_ID(*b) &&
156 SID_GET_WINDOW_ID(*a) == SID_GET_WINDOW_ID(*b))
158 return 1;
161 return 0;
164 static int style_id_equals_id(window_style *s, style_id_t* id)
166 return style_ids_are_equal(&SGET_ID(*s), id);
169 static int styles_have_same_id(window_style* s, window_style* t)
171 return style_ids_are_equal(&SGET_ID(*s), &SGET_ID(*t));
174 static int fw_match_style_id(FvwmWindow *fw, style_id_t s_id)
176 if (SID_GET_HAS_NAME(s_id))
178 if (matchWildcards(SID_GET_NAME(s_id), fw->class.res_class) ==
181 return 1;
183 if (matchWildcards(SID_GET_NAME(s_id), fw->class.res_name) ==
186 return 1;
188 if (matchWildcards(SID_GET_NAME(s_id), fw->visible_name) == 1)
190 return 1;
192 if (matchWildcards(SID_GET_NAME(s_id), fw->name.name) == 1)
194 return 1;
196 if (fw->style_name != NULL &&
197 matchWildcards(SID_GET_NAME(s_id), fw->style_name) == 1)
199 return 1;
202 if (SID_GET_HAS_WINDOW_ID(s_id) &&
203 SID_GET_WINDOW_ID(s_id) == (XID)FW_W(fw))
205 return 1;
208 return 0;
211 static int one_fw_can_match_both_ids(window_style *s, window_style *t)
213 if (SGET_ID_HAS_WINDOW_ID(*s) && SGET_ID_HAS_WINDOW_ID(*t) &&
214 SGET_WINDOW_ID(*s) != SGET_WINDOW_ID(*t))
216 return 0;
219 return 1;
222 static void remove_icon_boxes_from_style(window_style *pstyle)
224 if (SHAS_ICON_BOXES(&pstyle->flags))
226 free_icon_boxes(SGET_ICON_BOXES(*pstyle));
227 pstyle->flags.has_icon_boxes = 0;
228 SSET_ICON_BOXES(*pstyle, NULL);
231 return;
234 static void copy_icon_boxes(icon_boxes **pdest, icon_boxes *src)
236 icon_boxes *last = NULL;
237 icon_boxes *temp;
239 *pdest = NULL;
240 /* copy the icon boxes */
241 for ( ; src != NULL; src = src->next)
243 temp = (icon_boxes *)safemalloc(sizeof(icon_boxes));
244 memcpy(temp, src, sizeof(icon_boxes));
245 temp->next = NULL;
246 if (last != NULL)
247 last->next = temp;
248 else
249 *pdest = temp;
250 last = temp;
254 /* Check word after IconFill to see if its "Top,Bottom,Left,Right" */
255 static int Get_TBLR(char *token, unsigned char *IconFill)
257 /* init */
258 if (StrEquals(token, "B") ||
259 StrEquals(token, "BOT")||
260 StrEquals(token, "BOTTOM"))
262 /* turn on bottom and verical */
263 *IconFill = ICONFILLBOT | ICONFILLHRZ;
265 else if (StrEquals(token, "T") ||
266 StrEquals(token, "TOP"))
268 /* turn on vertical */
269 *IconFill = ICONFILLHRZ;
271 else if (StrEquals(token, "R") ||
272 StrEquals(token, "RGT") ||
273 StrEquals(token, "RIGHT"))
275 /* turn on right bit */
276 *IconFill = ICONFILLRGT;
278 else if (StrEquals(token, "L") ||
279 StrEquals(token, "LFT") ||
280 StrEquals(token, "LEFT"))
282 *IconFill = 0;
284 else
286 /* anything else is bad */
287 return 0;
290 /* return OK */
291 return 1;
294 static void cleanup_style_defaults(window_style *style)
296 int i;
297 char *dflt;
298 char *mask;
300 mask = (char *)&(style->flag_mask);
301 dflt = (char *)&(style->flag_default);
302 for (i = 0; i < sizeof(style_flags); i++)
304 dflt[i] &= ~mask[i];
307 return;
310 /* merge_styles - For a matching style, merge window_style to window_style
312 * Returned Value:
313 * merged matching styles in callers window_style.
315 * Inputs:
316 * merged_style - style resulting from the merge
317 * add_style - the style to be added into the merge_style
318 * do_free_src_and_alloc_copy
319 * - free allocated parts of merge_style that are replaced
320 * from add_style. Create a copy of of the replaced
321 * styles in allocated memory.
323 * Note:
324 * The only trick here is that on and off flags/buttons are
325 * combined into the on flag/button. */
326 static void merge_styles(
327 window_style *merged_style, window_style *add_style,
328 Bool do_free_src_and_alloc_copy)
330 int i;
331 char *merge_flags;
332 char *add_flags;
333 char *merge_mask;
334 char *add_mask;
335 char *merge_dflt;
336 char *add_dflt;
337 char *merge_change_mask;
338 char *add_change_mask;
340 if (add_style->flag_mask.has_icon)
342 if (do_free_src_and_alloc_copy)
344 SAFEFREE(SGET_ICON_NAME(*merged_style));
345 SSET_ICON_NAME(
346 *merged_style, (SGET_ICON_NAME(*add_style)) ?
347 safestrdup(SGET_ICON_NAME(*add_style)) : NULL);
349 else
351 SSET_ICON_NAME(
352 *merged_style, SGET_ICON_NAME(*add_style));
355 if (FMiniIconsSupported && add_style->flag_mask.has_mini_icon)
357 if (do_free_src_and_alloc_copy)
359 SAFEFREE(SGET_MINI_ICON_NAME(*merged_style));
360 SSET_MINI_ICON_NAME(
361 *merged_style,
362 (SGET_MINI_ICON_NAME(*add_style)) ?
363 safestrdup(SGET_MINI_ICON_NAME(*add_style)) :
364 NULL);
366 else
368 SSET_MINI_ICON_NAME(
369 *merged_style,
370 SGET_MINI_ICON_NAME(*add_style));
373 #ifdef USEDECOR
374 if (add_style->flag_mask.has_decor)
376 if (do_free_src_and_alloc_copy)
378 SAFEFREE(SGET_DECOR_NAME(*merged_style));
379 SSET_DECOR_NAME(
380 *merged_style, (SGET_DECOR_NAME(*add_style)) ?
381 safestrdup(SGET_DECOR_NAME(*add_style)) :
382 NULL);
384 else
386 SSET_DECOR_NAME(
387 *merged_style, SGET_DECOR_NAME(*add_style));
390 #endif
391 if (S_HAS_ICON_FONT(SCF(*add_style)))
393 if (do_free_src_and_alloc_copy)
395 SAFEFREE(SGET_ICON_FONT(*merged_style));
396 SSET_ICON_FONT(
397 *merged_style, (SGET_ICON_FONT(*add_style)) ?
398 safestrdup(SGET_ICON_FONT(*add_style)) : NULL);
400 else
402 SSET_ICON_FONT(
403 *merged_style, SGET_ICON_FONT(*add_style));
406 if (S_HAS_WINDOW_FONT(SCF(*add_style)))
408 if (do_free_src_and_alloc_copy)
410 SAFEFREE(SGET_WINDOW_FONT(*merged_style));
411 SSET_WINDOW_FONT(
412 *merged_style, (SGET_WINDOW_FONT(*add_style)) ?
413 safestrdup(SGET_WINDOW_FONT(*add_style)) :
414 NULL);
416 else
418 SSET_WINDOW_FONT(
419 *merged_style, SGET_WINDOW_FONT(*add_style));
422 if (add_style->flags.use_start_on_desk)
424 SSET_START_DESK(*merged_style, SGET_START_DESK(*add_style));
425 SSET_START_PAGE_X(
426 *merged_style, SGET_START_PAGE_X(*add_style));
427 SSET_START_PAGE_Y(
428 *merged_style, SGET_START_PAGE_Y(*add_style));
430 if (add_style->flags.use_start_on_screen)
432 SSET_START_SCREEN
433 (*merged_style, SGET_START_SCREEN(*add_style));
435 if (add_style->flag_mask.has_color_fore)
437 if (do_free_src_and_alloc_copy)
439 SAFEFREE(SGET_FORE_COLOR_NAME(*merged_style));
440 SSET_FORE_COLOR_NAME(
441 *merged_style,
442 (SGET_FORE_COLOR_NAME(*add_style)) ?
443 safestrdup(SGET_FORE_COLOR_NAME(*add_style)) :
444 NULL);
446 else
448 SSET_FORE_COLOR_NAME(
449 *merged_style,
450 SGET_FORE_COLOR_NAME(*add_style));
453 if (add_style->flag_mask.has_color_back)
455 if (do_free_src_and_alloc_copy)
457 SAFEFREE(SGET_BACK_COLOR_NAME(*merged_style));
458 SSET_BACK_COLOR_NAME(
459 *merged_style,
460 (SGET_BACK_COLOR_NAME(*add_style)) ?
461 safestrdup(SGET_BACK_COLOR_NAME(*add_style)) :
462 NULL);
464 else
466 SSET_BACK_COLOR_NAME(
467 *merged_style,
468 SGET_BACK_COLOR_NAME(*add_style));
471 if (add_style->flag_mask.has_color_fore_hi)
473 if (do_free_src_and_alloc_copy)
475 SAFEFREE(SGET_FORE_COLOR_NAME_HI(*merged_style));
476 SSET_FORE_COLOR_NAME_HI(
477 *merged_style,
478 (SGET_FORE_COLOR_NAME_HI(*add_style)) ?
479 safestrdup(
480 SGET_FORE_COLOR_NAME_HI(*add_style)) :
481 NULL);
483 else
485 SSET_FORE_COLOR_NAME_HI(
486 *merged_style,
487 SGET_FORE_COLOR_NAME_HI(*add_style));
490 if (add_style->flag_mask.has_color_back_hi)
492 if (do_free_src_and_alloc_copy)
494 SAFEFREE(SGET_BACK_COLOR_NAME_HI(*merged_style));
495 SSET_BACK_COLOR_NAME_HI(
496 *merged_style,
497 (SGET_BACK_COLOR_NAME_HI(*add_style)) ?
498 safestrdup(
499 SGET_BACK_COLOR_NAME_HI(*add_style)) :
500 NULL);
502 else
504 SSET_BACK_COLOR_NAME_HI(
505 *merged_style,
506 SGET_BACK_COLOR_NAME_HI(*add_style));
509 if (add_style->flags.has_border_width)
511 SSET_BORDER_WIDTH(
512 *merged_style, SGET_BORDER_WIDTH(*add_style));
514 if (add_style->flags.has_handle_width)
516 SSET_HANDLE_WIDTH(
517 *merged_style, SGET_HANDLE_WIDTH(*add_style));
519 if (add_style->flags.has_icon_size_limits)
521 SSET_MIN_ICON_WIDTH(
522 *merged_style, SGET_MIN_ICON_WIDTH(*add_style));
523 SSET_MIN_ICON_HEIGHT(
524 *merged_style, SGET_MIN_ICON_HEIGHT(*add_style));
525 SSET_MAX_ICON_WIDTH(
526 *merged_style, SGET_MAX_ICON_WIDTH(*add_style));
527 SSET_MAX_ICON_HEIGHT(
528 *merged_style, SGET_MAX_ICON_HEIGHT(*add_style));
529 SSET_ICON_RESIZE_TYPE(
530 *merged_style, SGET_ICON_RESIZE_TYPE(*add_style));
532 if (add_style->flags.has_min_window_size)
534 SSET_MIN_WINDOW_WIDTH(
535 *merged_style, SGET_MIN_WINDOW_WIDTH(*add_style));
536 SSET_MIN_WINDOW_HEIGHT(
537 *merged_style, SGET_MIN_WINDOW_HEIGHT(*add_style));
539 if (add_style->flags.has_max_window_size)
541 SSET_MAX_WINDOW_WIDTH(
542 *merged_style, SGET_MAX_WINDOW_WIDTH(*add_style));
543 SSET_MAX_WINDOW_HEIGHT(
544 *merged_style, SGET_MAX_WINDOW_HEIGHT(*add_style));
546 if (add_style->flags.has_icon_background_relief)
548 SSET_ICON_BACKGROUND_RELIEF(
549 *merged_style,
550 SGET_ICON_BACKGROUND_RELIEF(*add_style));
552 if (add_style->flags.has_icon_background_padding)
554 SSET_ICON_BACKGROUND_PADDING(
555 *merged_style,
556 SGET_ICON_BACKGROUND_PADDING(*add_style));
558 if (add_style->flags.has_icon_title_relief)
560 SSET_ICON_TITLE_RELIEF(
561 *merged_style, SGET_ICON_TITLE_RELIEF(*add_style));
563 if (add_style->flags.has_window_shade_steps)
565 SSET_WINDOW_SHADE_STEPS(
566 *merged_style, SGET_WINDOW_SHADE_STEPS(*add_style));
568 if (add_style->flags.has_snap_attraction)
570 SSET_SNAP_PROXIMITY(
571 *merged_style, SGET_SNAP_PROXIMITY(*add_style));
572 SSET_SNAP_MODE(
573 *merged_style, SGET_SNAP_MODE(*add_style));
575 if (add_style->flags.has_snap_grid)
577 SSET_SNAP_GRID_X(
578 *merged_style, SGET_SNAP_GRID_X(*add_style));
579 SSET_SNAP_GRID_Y(
580 *merged_style, SGET_SNAP_GRID_Y(*add_style));
582 if (add_style->flags.has_edge_delay_ms_move)
584 SSET_EDGE_DELAY_MS_MOVE(
585 *merged_style, SGET_EDGE_DELAY_MS_MOVE(*add_style));
587 if (add_style->flags.has_edge_delay_ms_resize)
589 SSET_EDGE_DELAY_MS_RESIZE(
590 *merged_style, SGET_EDGE_DELAY_MS_RESIZE(*add_style));
592 if (add_style->flags.has_edge_resistance_move)
594 SSET_EDGE_RESISTANCE_MOVE(
595 *merged_style, SGET_EDGE_RESISTANCE_MOVE(*add_style));
597 if (add_style->flags.has_edge_resistance_xinerama_move)
599 SSET_EDGE_RESISTANCE_XINERAMA_MOVE(
600 *merged_style,
601 SGET_EDGE_RESISTANCE_XINERAMA_MOVE(*add_style));
604 /* Note: Only one style cmd can define a window's iconboxes, the last
605 * one encountered. */
606 if (SHAS_ICON_BOXES(&add_style->flag_mask))
608 /* If style has iconboxes */
609 /* copy it */
610 if (do_free_src_and_alloc_copy)
612 remove_icon_boxes_from_style(merged_style);
613 copy_icon_boxes(
614 &SGET_ICON_BOXES(*merged_style),
615 SGET_ICON_BOXES(*add_style));
617 else
619 SSET_ICON_BOXES(
620 *merged_style, SGET_ICON_BOXES(*add_style));
623 if (add_style->flags.use_layer)
625 SSET_LAYER(*merged_style, SGET_LAYER(*add_style));
627 if (add_style->flags.do_start_shaded)
629 SSET_STARTS_SHADED_DIR(
630 *merged_style, SGET_STARTS_SHADED_DIR(*add_style));
632 if (add_style->flags.use_colorset)
634 SSET_COLORSET(*merged_style, SGET_COLORSET(*add_style));
636 if (add_style->flags.use_colorset_hi)
638 SSET_COLORSET_HI(*merged_style, SGET_COLORSET_HI(*add_style));
640 if (add_style->flags.use_border_colorset)
642 SSET_BORDER_COLORSET(
643 *merged_style, SGET_BORDER_COLORSET(*add_style));
645 if (add_style->flags.use_border_colorset_hi)
647 SSET_BORDER_COLORSET_HI(
648 *merged_style,SGET_BORDER_COLORSET_HI(*add_style));
650 if (add_style->flags.use_icon_title_colorset)
652 SSET_ICON_TITLE_COLORSET(
653 *merged_style,SGET_ICON_TITLE_COLORSET(*add_style));
655 if (add_style->flags.use_icon_title_colorset_hi)
657 SSET_ICON_TITLE_COLORSET_HI(
658 *merged_style,SGET_ICON_TITLE_COLORSET_HI(*add_style));
660 if (add_style->flags.use_icon_background_colorset)
662 SSET_ICON_BACKGROUND_COLORSET(
663 *merged_style,SGET_ICON_BACKGROUND_COLORSET(
664 *add_style));
666 if (add_style->flags.has_placement_penalty)
668 SSET_NORMAL_PLACEMENT_PENALTY(
669 *merged_style,
670 SGET_NORMAL_PLACEMENT_PENALTY(*add_style));
671 SSET_ONTOP_PLACEMENT_PENALTY(
672 *merged_style,
673 SGET_ONTOP_PLACEMENT_PENALTY(*add_style));
674 SSET_ICON_PLACEMENT_PENALTY(
675 *merged_style, SGET_ICON_PLACEMENT_PENALTY(
676 *add_style));
677 SSET_STICKY_PLACEMENT_PENALTY(
678 *merged_style,
679 SGET_STICKY_PLACEMENT_PENALTY(*add_style));
680 SSET_BELOW_PLACEMENT_PENALTY(
681 *merged_style,
682 SGET_BELOW_PLACEMENT_PENALTY(*add_style));
683 SSET_EWMH_STRUT_PLACEMENT_PENALTY(
684 *merged_style,
685 SGET_EWMH_STRUT_PLACEMENT_PENALTY(*add_style));
687 if (add_style->flags.has_placement_percentage_penalty)
689 SSET_99_PLACEMENT_PERCENTAGE_PENALTY(
690 *merged_style,
691 SGET_99_PLACEMENT_PERCENTAGE_PENALTY(*add_style));
692 SSET_95_PLACEMENT_PERCENTAGE_PENALTY(
693 *merged_style,
694 SGET_95_PLACEMENT_PERCENTAGE_PENALTY(*add_style));
695 SSET_85_PLACEMENT_PERCENTAGE_PENALTY(
696 *merged_style,
697 SGET_85_PLACEMENT_PERCENTAGE_PENALTY(*add_style));
698 SSET_75_PLACEMENT_PERCENTAGE_PENALTY(
699 *merged_style,
700 SGET_75_PLACEMENT_PERCENTAGE_PENALTY(*add_style));
702 if (add_style->flags.has_placement_position_string)
704 SAFEFREE(SGET_PLACEMENT_POSITION_STRING(*merged_style));
705 SSET_PLACEMENT_POSITION_STRING(
706 *merged_style,
707 strdup(SGET_PLACEMENT_POSITION_STRING(*add_style)));
709 if (add_style->flags.has_initial_map_command_string)
711 SAFEFREE(SGET_INITIAL_MAP_COMMAND_STRING(*merged_style));
712 SSET_INITIAL_MAP_COMMAND_STRING(
713 *merged_style,
714 strdup(SGET_INITIAL_MAP_COMMAND_STRING(*add_style)));
716 /* merge the style flags */
718 /*** ATTENTION:
719 *** This must be the last thing that is done in this function! */
720 merge_flags = (char *)&(merged_style->flags);
721 add_flags = (char *)&(add_style->flags);
722 merge_mask = (char *)&(merged_style->flag_mask);
723 add_mask = (char *)&(add_style->flag_mask);
724 merge_dflt = (char *)&(merged_style->flag_default);
725 add_dflt = (char *)&(add_style->flag_default);
726 merge_change_mask = (char *)&(merged_style->change_mask);
727 add_change_mask = (char *)&(add_style->change_mask);
728 for (i = 0; i < sizeof(style_flags); i++)
730 char m;
732 /* overwrite set styles */
733 merge_flags[i] |= (add_flags[i] & add_mask[i]);
734 merge_flags[i] &= (add_flags[i] | ~add_mask[i]);
735 /* overwrite default values */
736 m = add_dflt[i] & ~add_mask[i] & ~merge_mask[i];
737 merge_flags[i] |= (add_flags[i] & m);
738 merge_flags[i] &= (add_flags[i] | ~m);
739 /* overwrite even weaker default values */
740 m = ~add_dflt[i] & ~add_mask[i] & ~merge_dflt[i] &
741 ~merge_mask[i];
742 merge_flags[i] |= (add_flags[i] & m);
743 merge_flags[i] &= (add_flags[i] | ~m);
744 /* other flags */
745 merge_change_mask[i] &= ~(add_mask[i]);
746 merge_change_mask[i] |= add_change_mask[i];
747 merge_mask[i] |= add_mask[i];
748 merge_dflt[i] |= add_dflt[i];
749 merge_dflt[i] &= ~merge_mask[i];
751 merged_style->has_style_changed |= add_style->has_style_changed;
753 return;
756 static void free_style(window_style *style)
758 /* Free contents of style */
759 SAFEFREE(SGET_NAME(*style));
760 SAFEFREE(SGET_BACK_COLOR_NAME(*style));
761 SAFEFREE(SGET_FORE_COLOR_NAME(*style));
762 SAFEFREE(SGET_BACK_COLOR_NAME_HI(*style));
763 SAFEFREE(SGET_FORE_COLOR_NAME_HI(*style));
764 SAFEFREE(SGET_DECOR_NAME(*style));
765 SAFEFREE(SGET_ICON_FONT(*style));
766 SAFEFREE(SGET_WINDOW_FONT(*style));
767 SAFEFREE(SGET_ICON_NAME(*style));
768 SAFEFREE(SGET_MINI_ICON_NAME(*style));
769 remove_icon_boxes_from_style(style);
770 SAFEFREE(SGET_PLACEMENT_POSITION_STRING(*style));
771 SAFEFREE(SGET_INITIAL_MAP_COMMAND_STRING(*style));
773 return;
776 /* Frees only selected members of a style; adjusts the flag_mask and
777 * change_mask appropriately. */
778 static void free_style_mask(window_style *style, style_flags *mask)
780 style_flags local_mask;
781 style_flags *pmask;
783 /* mask out all bits that are not set in the target style */
784 pmask =&local_mask;
785 blockand((char *)pmask, (char *)&style->flag_mask, (char *)mask,
786 sizeof(style_flags));
788 /* Free contents of style */
789 if (pmask->has_color_back)
791 SAFEFREE(SGET_BACK_COLOR_NAME(*style));
793 if (pmask->has_color_fore)
795 SAFEFREE(SGET_FORE_COLOR_NAME(*style));
797 if (pmask->has_color_back_hi)
799 SAFEFREE(SGET_BACK_COLOR_NAME_HI(*style));
801 if (pmask->has_color_fore_hi)
803 SAFEFREE(SGET_FORE_COLOR_NAME_HI(*style));
805 if (pmask->has_decor)
807 SAFEFREE(SGET_DECOR_NAME(*style));
809 if (pmask->common.has_icon_font)
811 SAFEFREE(SGET_ICON_FONT(*style));
813 if (pmask->common.has_window_font)
815 SAFEFREE(SGET_WINDOW_FONT(*style));
817 if (pmask->has_icon)
819 SAFEFREE(SGET_ICON_NAME(*style));
821 if (pmask->has_mini_icon)
823 SAFEFREE(SGET_MINI_ICON_NAME(*style));
825 if (pmask->has_icon_boxes)
827 remove_icon_boxes_from_style(style);
829 /* remove styles from definitiion */
830 blockunmask((char *)&style->flag_mask, (char *)&style->flag_mask,
831 (char *)pmask, sizeof(style_flags));
832 blockunmask((char *)&style->flag_default, (char *)&style->flag_default,
833 (char *)pmask, sizeof(style_flags));
834 blockunmask((char *)&style->change_mask, (char *)&style->change_mask,
835 (char *)pmask, sizeof(style_flags));
837 return;
840 static void add_style_to_list(window_style *new_style)
842 /* This used to contain logic that returned if the style didn't contain
843 * anything. I don't see why we should bother. dje.
845 * used to merge duplicate entries, but that is no longer
846 * appropriate since conflicting styles are possible, and the
847 * last match should win! */
849 if (last_style_in_list != NULL)
851 /* not first entry in list chain this entry to the list */
852 SSET_NEXT_STYLE(*last_style_in_list, new_style);
854 else
856 /* first entry in list set the list root pointer. */
857 all_styles = new_style;
859 SSET_PREV_STYLE(*new_style, last_style_in_list);
860 SSET_NEXT_STYLE(*new_style, NULL);
861 last_style_in_list = new_style;
862 Scr.flags.do_need_style_list_update = 1;
864 return;
865 } /* end function */
867 static void remove_style_from_list(window_style *style, Bool do_free_style)
869 window_style *prev;
870 window_style *next;
872 prev = SGET_PREV_STYLE(*style);
873 next = SGET_NEXT_STYLE(*style);
874 if (!prev)
876 /* first style in list */
877 all_styles = next;
879 else
881 /* not first style in list */
882 SSET_NEXT_STYLE(*prev, next);
884 if (!next)
886 /* last style in list */
887 last_style_in_list = prev;
889 else
891 SSET_PREV_STYLE(*next, prev);
893 if (do_free_style)
895 free_style(style);
896 free(style);
900 static int remove_all_of_style_from_list(style_id_t style_id)
902 window_style *nptr = all_styles;
903 window_style *next;
904 int is_changed = 0;
906 /* loop though styles */
907 while (nptr)
909 next = SGET_NEXT_STYLE(*nptr);
910 /* Check if it's to be wiped */
911 if (style_id_equals_id(nptr, &style_id))
913 remove_style_from_list(nptr, True);
914 is_changed = 1;
916 /* move on */
917 nptr = next;
920 return is_changed;
923 static int __simplify_style_list(void)
925 window_style *cur;
926 int has_modified;
928 /* Step 1:
929 * Remove styles that are completely overridden by later
930 * style definitions. At the same time...
931 * Step 2:
932 * Merge styles with the same name if there are no
933 * conflicting styles with other names set in between. */
934 for (
935 cur = last_style_in_list, has_modified = 0; cur;
936 cur = SGET_PREV_STYLE(*cur))
938 style_flags dummyflags;
939 /* incremental flags set in styles with the same name */
940 style_flags sumflags;
941 style_flags sumdflags;
942 /* incremental flags set in styles with other names */
943 style_flags interflags;
944 window_style *cmp;
946 memset(&interflags, 0, sizeof(style_flags));
947 memcpy(&sumflags, &cur->flag_mask, sizeof(style_flags));
948 memcpy(&sumdflags, &cur->flag_default, sizeof(style_flags));
949 cmp = SGET_PREV_STYLE(*cur);
950 while (cmp)
952 if (!styles_have_same_id(cur, cmp))
954 if (one_fw_can_match_both_ids(cur, cmp))
956 blockor((char *)&interflags,
957 (char *)&interflags,
958 (char *)&cmp->flag_mask,
959 sizeof(style_flags));
960 blockor((char *)&interflags,
961 (char *)&interflags,
962 (char *)&cmp->flag_default,
963 sizeof(style_flags));
965 cmp = SGET_PREV_STYLE(*cmp);
966 continue;
968 if (blockissubset(
969 (char *)&cmp->flag_mask,
970 (char *)&sumflags,
971 sizeof(style_flags)) &&
972 blockissubset(
973 (char *)&cmp->flag_default,
974 (char *)&sumdflags,
975 sizeof(style_flags)))
977 /* The style is a subset of later style
978 * definitions; nuke it */
979 window_style *tmp = SGET_PREV_STYLE(*cmp);
980 remove_style_from_list(cmp, True);
981 cmp = tmp;
982 has_modified = 1;
983 continue;
985 /* remove all styles that are overridden later from the
986 * style */
987 blockor((char *)&dummyflags,
988 (char *)&sumdflags,
989 (char *)&sumflags,
990 sizeof(style_flags));
991 free_style_mask(cmp, &dummyflags);
992 if (
993 !blocksintersect(
994 (char *)&cmp->flag_mask,
995 (char *)&interflags,
996 sizeof(style_flags)) &&
997 !blocksintersect(
998 (char *)&cmp->flag_default,
999 (char *)&interflags,
1000 sizeof(style_flags)))
1002 /* merge old style into new style */
1003 window_style *tmp = SGET_PREV_STYLE(*cmp);
1004 window_style *prev = SGET_PREV_STYLE(*cur);
1005 window_style *next = SGET_NEXT_STYLE(*cur);
1007 /* Add the style to the set */
1008 blockor((char *)&sumflags,
1009 (char *)&sumflags,
1010 (char *)&cmp->flag_mask,
1011 sizeof(style_flags));
1012 blockor((char *)&sumdflags,
1013 (char *)&sumflags,
1014 (char *)&cmp->flag_default,
1015 sizeof(style_flags));
1016 /* merge cmp into cur and delete it
1017 * afterwards */
1018 merge_styles(cmp, cur, True);
1019 free_style(cur);
1020 memcpy(cur, cmp, sizeof(window_style));
1021 /* restore fields overwritten by memcpy */
1022 SSET_PREV_STYLE(*cur, prev);
1023 SSET_NEXT_STYLE(*cur, next);
1024 /* remove the style without freeing the
1025 * memory */
1026 remove_style_from_list(cmp, False);
1027 /* release the style structure */
1028 free(cmp);
1029 cmp = tmp;
1030 has_modified = 1;
1032 else if (
1033 !blocksintersect(
1034 (char *)&cur->flag_mask,
1035 (char *)&interflags,
1036 sizeof(style_flags)) &&
1037 !blocksintersect(
1038 (char *)&cur->flag_default,
1039 (char *)&interflags,
1040 sizeof(style_flags)))
1042 /* merge new style into old style */
1043 window_style *tmp = SGET_PREV_STYLE(*cmp);
1045 /* Add the style to the set */
1046 blockor((char *)&sumflags,
1047 (char *)&sumflags,
1048 (char *)&cur->flag_mask,
1049 sizeof(style_flags));
1050 blockor((char *)&sumdflags,
1051 (char *)&sumflags,
1052 (char *)&cur->flag_default,
1053 sizeof(style_flags));
1054 /* merge cur into cmp and delete it
1055 * afterwards */
1056 merge_styles(cmp, cur, True);
1057 remove_style_from_list(cur, True);
1058 cur = cmp;
1059 cmp = tmp;
1060 has_modified = 1;
1061 memset(&interflags, 0, sizeof(style_flags));
1062 continue;
1064 else
1066 /* Add it to the set of interfering styles. */
1067 blockor((char *)&interflags,
1068 (char *)&interflags,
1069 (char *)&cmp->flag_mask,
1070 sizeof(style_flags));
1071 blockor((char *)&interflags,
1072 (char *)&interflags,
1073 (char *)&cmp->flag_default,
1074 sizeof(style_flags));
1075 cmp = SGET_PREV_STYLE(*cmp);
1080 return has_modified;
1083 static void style_set_old_focus_policy(window_style *ps, int policy)
1085 focus_policy_t fp;
1087 switch (policy)
1089 case 0:
1090 /* ClickToFocus */
1091 FPS_FOCUS_ENTER(S_FOCUS_POLICY(SCF(*ps)), 0);
1092 FPS_UNFOCUS_LEAVE(S_FOCUS_POLICY(SCF(*ps)), 0);
1093 FPS_FOCUS_CLICK_CLIENT(S_FOCUS_POLICY(SCF(*ps)), 1);
1094 FPS_FOCUS_CLICK_DECOR(S_FOCUS_POLICY(SCF(*ps)), 1);
1095 FPS_FOCUS_CLICK_ICON(S_FOCUS_POLICY(SCF(*ps)), 1);
1096 FPS_FOCUS_BY_FUNCTION(S_FOCUS_POLICY(SCF(*ps)), 1);
1097 FPS_FOCUS_BY_PROGRAM(fp, 1);
1098 FPS_GRAB_FOCUS(fp, 1);
1099 FPS_RELEASE_FOCUS(fp, 1);
1100 FPS_RAISE_FOCUSED_CLIENT_CLICK(fp, 1);
1101 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(fp, 1);
1102 FPS_RAISE_FOCUSED_DECOR_CLICK(fp, 1);
1103 FPS_RAISE_UNFOCUSED_DECOR_CLICK(fp, 1);
1104 FPS_PASS_FOCUS_CLICK(fp, 1);
1105 FPS_PASS_RAISE_CLICK(fp, 1);
1106 FPS_ALLOW_FUNC_FOCUS_CLICK(fp, 1);
1107 FPS_ALLOW_FUNC_RAISE_CLICK(fp, 1);
1108 FPS_WARP_POINTER_ON_FOCUS_FUNC(fp, 0);
1109 break;
1110 case 1:
1111 /* MouseFocus */
1112 FPS_FOCUS_ENTER(S_FOCUS_POLICY(SCF(*ps)), 1);
1113 FPS_UNFOCUS_LEAVE(S_FOCUS_POLICY(SCF(*ps)), 1);
1114 FPS_FOCUS_CLICK_CLIENT(S_FOCUS_POLICY(SCF(*ps)), 0);
1115 FPS_FOCUS_CLICK_DECOR(S_FOCUS_POLICY(SCF(*ps)), 0);
1116 FPS_FOCUS_CLICK_ICON(S_FOCUS_POLICY(SCF(*ps)), 0);
1117 FPS_FOCUS_BY_FUNCTION(S_FOCUS_POLICY(SCF(*ps)), 1);
1118 FPS_FOCUS_BY_PROGRAM(fp, 1);
1119 FPS_GRAB_FOCUS(fp, 0);
1120 FPS_RELEASE_FOCUS(fp, 0);
1121 FPS_RAISE_FOCUSED_CLIENT_CLICK(fp, 0);
1122 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(fp, 0);
1123 FPS_RAISE_FOCUSED_DECOR_CLICK(fp, 0);
1124 FPS_RAISE_UNFOCUSED_DECOR_CLICK(fp, 0);
1125 FPS_PASS_FOCUS_CLICK(fp, 1);
1126 FPS_PASS_RAISE_CLICK(fp, 1);
1127 FPS_ALLOW_FUNC_FOCUS_CLICK(fp, 0);
1128 FPS_ALLOW_FUNC_RAISE_CLICK(fp, 0);
1129 FPS_WARP_POINTER_ON_FOCUS_FUNC(fp, 1);
1130 break;
1131 case 2:
1132 /* SloppyFocus */
1133 FPS_FOCUS_ENTER(S_FOCUS_POLICY(SCF(*ps)), 1);
1134 FPS_UNFOCUS_LEAVE(S_FOCUS_POLICY(SCF(*ps)), 0);
1135 FPS_FOCUS_CLICK_CLIENT(S_FOCUS_POLICY(SCF(*ps)), 0);
1136 FPS_FOCUS_CLICK_DECOR(S_FOCUS_POLICY(SCF(*ps)), 0);
1137 FPS_FOCUS_CLICK_ICON(S_FOCUS_POLICY(SCF(*ps)), 0);
1138 FPS_FOCUS_BY_FUNCTION(S_FOCUS_POLICY(SCF(*ps)), 1);
1139 FPS_FOCUS_BY_PROGRAM(fp, 1);
1140 FPS_GRAB_FOCUS(fp, 0);
1141 FPS_RELEASE_FOCUS(fp, 1);
1142 FPS_RAISE_FOCUSED_CLIENT_CLICK(fp, 0);
1143 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(fp, 0);
1144 FPS_RAISE_FOCUSED_DECOR_CLICK(fp, 0);
1145 FPS_RAISE_UNFOCUSED_DECOR_CLICK(fp, 0);
1146 FPS_PASS_FOCUS_CLICK(fp, 1);
1147 FPS_PASS_RAISE_CLICK(fp, 1);
1148 FPS_ALLOW_FUNC_FOCUS_CLICK(fp, 0);
1149 FPS_ALLOW_FUNC_RAISE_CLICK(fp, 0);
1150 FPS_WARP_POINTER_ON_FOCUS_FUNC(fp, 1);
1151 break;
1152 case 3:
1153 /* NeverFocus */
1154 FPS_FOCUS_ENTER(S_FOCUS_POLICY(SCF(*ps)), 0);
1155 FPS_UNFOCUS_LEAVE(S_FOCUS_POLICY(SCF(*ps)), 0);
1156 FPS_FOCUS_CLICK_CLIENT(S_FOCUS_POLICY(SCF(*ps)), 0);
1157 FPS_FOCUS_CLICK_DECOR(S_FOCUS_POLICY(SCF(*ps)), 0);
1158 FPS_FOCUS_CLICK_ICON(S_FOCUS_POLICY(SCF(*ps)), 0);
1159 FPS_FOCUS_BY_FUNCTION(S_FOCUS_POLICY(SCF(*ps)), 0);
1160 FPS_FOCUS_BY_PROGRAM(fp, 1);
1161 FPS_GRAB_FOCUS(fp, 0);
1162 FPS_RELEASE_FOCUS(fp, 0);
1163 FPS_RAISE_FOCUSED_CLIENT_CLICK(fp, 0);
1164 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(fp, 0);
1165 FPS_RAISE_FOCUSED_DECOR_CLICK(fp, 0);
1166 FPS_RAISE_UNFOCUSED_DECOR_CLICK(fp, 0);
1167 FPS_PASS_FOCUS_CLICK(fp, 1);
1168 FPS_PASS_RAISE_CLICK(fp, 1);
1169 FPS_ALLOW_FUNC_FOCUS_CLICK(fp, 1);
1170 FPS_ALLOW_FUNC_RAISE_CLICK(fp, 1);
1171 FPS_WARP_POINTER_ON_FOCUS_FUNC(fp, 0);
1172 break;
1174 FPS_FOCUS_ENTER(S_FOCUS_POLICY(SCM(*ps)), 1);
1175 FPS_FOCUS_ENTER(S_FOCUS_POLICY(SCC(*ps)), 1);
1176 FPS_UNFOCUS_LEAVE(S_FOCUS_POLICY(SCM(*ps)), 1);
1177 FPS_UNFOCUS_LEAVE(S_FOCUS_POLICY(SCC(*ps)), 1);
1178 FPS_FOCUS_CLICK_CLIENT(S_FOCUS_POLICY(SCM(*ps)), 1);
1179 FPS_FOCUS_CLICK_CLIENT(S_FOCUS_POLICY(SCC(*ps)), 1);
1180 FPS_FOCUS_CLICK_DECOR(S_FOCUS_POLICY(SCM(*ps)), 1);
1181 FPS_FOCUS_CLICK_DECOR(S_FOCUS_POLICY(SCC(*ps)), 1);
1182 FPS_FOCUS_CLICK_ICON(S_FOCUS_POLICY(SCM(*ps)), 1);
1183 FPS_FOCUS_CLICK_ICON(S_FOCUS_POLICY(SCC(*ps)), 1);
1184 FPS_FOCUS_BY_FUNCTION(S_FOCUS_POLICY(SCM(*ps)), 1);
1185 FPS_FOCUS_BY_FUNCTION(S_FOCUS_POLICY(SCC(*ps)), 1);
1187 if (!FP_DO_FOCUS_BY_PROGRAM(S_FOCUS_POLICY(SCM(*ps))))
1189 FPS_FOCUS_BY_PROGRAM(
1190 S_FOCUS_POLICY(SCF(*ps)), FP_DO_FOCUS_BY_PROGRAM(fp));
1191 FPS_FOCUS_BY_PROGRAM(S_FOCUS_POLICY(SCD(*ps)), 1);
1192 FPS_FOCUS_BY_PROGRAM(S_FOCUS_POLICY(SCC(*ps)), 1);
1194 if (!FP_DO_GRAB_FOCUS(S_FOCUS_POLICY(SCM(*ps))))
1196 FPS_GRAB_FOCUS(S_FOCUS_POLICY(SCF(*ps)), FP_DO_GRAB_FOCUS(fp));
1197 FPS_GRAB_FOCUS(S_FOCUS_POLICY(SCD(*ps)), 1);
1198 FPS_GRAB_FOCUS(S_FOCUS_POLICY(SCC(*ps)), 1);
1200 if (!FP_DO_RELEASE_FOCUS(S_FOCUS_POLICY(SCM(*ps))))
1202 FPS_RELEASE_FOCUS(
1203 S_FOCUS_POLICY(SCF(*ps)), FP_DO_RELEASE_FOCUS(fp));
1204 FPS_RELEASE_FOCUS(S_FOCUS_POLICY(SCD(*ps)), 1);
1205 FPS_RELEASE_FOCUS(S_FOCUS_POLICY(SCC(*ps)), 1);
1207 if (!FP_DO_RAISE_FOCUSED_CLIENT_CLICK(S_FOCUS_POLICY(SCM(*ps))))
1209 FPS_RAISE_FOCUSED_CLIENT_CLICK(
1210 S_FOCUS_POLICY(SCF(*ps)),
1211 FP_DO_RAISE_FOCUSED_CLIENT_CLICK(fp));
1212 FPS_RAISE_FOCUSED_CLIENT_CLICK(S_FOCUS_POLICY(SCD(*ps)), 1);
1213 FPS_RAISE_FOCUSED_CLIENT_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
1215 if (!FP_DO_RAISE_UNFOCUSED_CLIENT_CLICK(S_FOCUS_POLICY(SCM(*ps))))
1217 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
1218 S_FOCUS_POLICY(SCF(*ps)),
1219 FP_DO_RAISE_UNFOCUSED_CLIENT_CLICK(fp));
1220 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(S_FOCUS_POLICY(SCD(*ps)), 1);
1221 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
1223 if (!FP_DO_RAISE_FOCUSED_DECOR_CLICK(S_FOCUS_POLICY(SCM(*ps))))
1225 FPS_RAISE_FOCUSED_DECOR_CLICK(
1226 S_FOCUS_POLICY(SCF(*ps)),
1227 FP_DO_RAISE_FOCUSED_DECOR_CLICK(fp));
1228 FPS_RAISE_FOCUSED_DECOR_CLICK(S_FOCUS_POLICY(SCD(*ps)), 1);
1229 FPS_RAISE_FOCUSED_DECOR_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
1231 if (!FP_DO_RAISE_UNFOCUSED_DECOR_CLICK(S_FOCUS_POLICY(SCM(*ps))))
1233 FPS_RAISE_UNFOCUSED_DECOR_CLICK(
1234 S_FOCUS_POLICY(SCF(*ps)),
1235 FP_DO_RAISE_UNFOCUSED_DECOR_CLICK(fp));
1236 FPS_RAISE_UNFOCUSED_DECOR_CLICK(S_FOCUS_POLICY(SCD(*ps)), 1);
1237 FPS_RAISE_UNFOCUSED_DECOR_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
1239 if (!FP_DO_PASS_FOCUS_CLICK(S_FOCUS_POLICY(SCM(*ps))))
1241 FPS_PASS_FOCUS_CLICK(
1242 S_FOCUS_POLICY(SCF(*ps)), FP_DO_PASS_FOCUS_CLICK(fp));
1243 FPS_PASS_FOCUS_CLICK(S_FOCUS_POLICY(SCD(*ps)), 1);
1244 FPS_PASS_FOCUS_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
1246 if (!FP_DO_PASS_RAISE_CLICK(S_FOCUS_POLICY(SCM(*ps))))
1248 FPS_PASS_RAISE_CLICK(
1249 S_FOCUS_POLICY(SCF(*ps)), FP_DO_PASS_RAISE_CLICK(fp));
1250 FPS_PASS_RAISE_CLICK(S_FOCUS_POLICY(SCD(*ps)), 1);
1251 FPS_PASS_RAISE_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
1253 if (!FP_DO_ALLOW_FUNC_FOCUS_CLICK(S_FOCUS_POLICY(SCM(*ps))))
1255 FPS_ALLOW_FUNC_FOCUS_CLICK(
1256 S_FOCUS_POLICY(SCF(*ps)),
1257 FP_DO_ALLOW_FUNC_FOCUS_CLICK(fp));
1258 FPS_ALLOW_FUNC_FOCUS_CLICK(S_FOCUS_POLICY(SCD(*ps)), 1);
1259 FPS_ALLOW_FUNC_FOCUS_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
1261 if (!FP_DO_ALLOW_FUNC_RAISE_CLICK(S_FOCUS_POLICY(SCM(*ps))))
1263 FPS_ALLOW_FUNC_RAISE_CLICK(
1264 S_FOCUS_POLICY(SCF(*ps)),
1265 FP_DO_ALLOW_FUNC_RAISE_CLICK(fp));
1266 FPS_ALLOW_FUNC_RAISE_CLICK(S_FOCUS_POLICY(SCD(*ps)), 1);
1267 FPS_ALLOW_FUNC_RAISE_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
1269 if (!FP_DO_WARP_POINTER_ON_FOCUS_FUNC(
1270 S_FOCUS_POLICY(SCM(*ps))))
1272 FPS_WARP_POINTER_ON_FOCUS_FUNC(
1273 S_FOCUS_POLICY(SCF(*ps)),
1274 FP_DO_WARP_POINTER_ON_FOCUS_FUNC(fp));
1275 FPS_WARP_POINTER_ON_FOCUS_FUNC(S_FOCUS_POLICY(SCD(*ps)), 1);
1276 FPS_WARP_POINTER_ON_FOCUS_FUNC(S_FOCUS_POLICY(SCC(*ps)), 1);
1278 if (!FP_DO_SORT_WINDOWLIST_BY(S_FOCUS_POLICY(SCM(*ps))))
1280 FPS_SORT_WINDOWLIST_BY(
1281 S_FOCUS_POLICY(SCF(*ps)),
1282 FP_DO_SORT_WINDOWLIST_BY(fp));
1283 FPS_SORT_WINDOWLIST_BY(S_FOCUS_POLICY(SCD(*ps)), 1);
1284 FPS_SORT_WINDOWLIST_BY(S_FOCUS_POLICY(SCC(*ps)), 1);
1287 return;
1290 static char *style_parse_button_style(
1291 window_style *ps, char *button_string, int on)
1293 int button;
1294 char *rest;
1296 button = -1;
1297 GetIntegerArguments(button_string, &rest, &button, 1);
1298 button = BUTTON_INDEX(button);
1299 if (button < 0 || button >= NUMBER_OF_TITLE_BUTTONS)
1301 fvwm_msg(
1302 ERR, "CMD_Style",
1303 "Button and NoButton styles require an argument");
1305 else
1307 if (on)
1309 ps->flags.is_button_disabled &= ~(1 << button);
1310 ps->flag_mask.is_button_disabled |= (1 << button);
1311 ps->change_mask.is_button_disabled |= (1 << button);
1313 else
1315 ps->flags.is_button_disabled |= (1 << button);
1316 ps->flag_mask.is_button_disabled |= (1 << button);
1317 ps->change_mask.is_button_disabled |= (1 << button);
1321 return rest;
1324 static Bool style_parse_focus_policy_style(
1325 char *option, char *rest, char **ret_rest, Bool is_reversed,
1326 focus_policy_t *f, focus_policy_t *m, focus_policy_t *c)
1328 char *optlist[] = {
1329 "SortWindowlistByFocus",
1330 "FocusClickButtons",
1331 "FocusClickModifiers",
1332 "ClickRaisesFocused",
1333 "ClickDecorRaisesFocused",
1334 "ClickIconRaisesFocused",
1335 "ClickRaisesUnfocused",
1336 "ClickDecorRaisesUnfocused",
1337 "ClickIconRaisesUnfocused",
1338 "ClickToFocus",
1339 "ClickDecorToFocus",
1340 "ClickIconToFocus",
1341 "EnterToFocus",
1342 "LeaveToUnfocus",
1343 "FocusByProgram",
1344 "FocusByFunction",
1345 "FocusByFunctionWarpPointer",
1346 "Lenient",
1347 "PassFocusClick",
1348 "PassRaiseClick",
1349 "IgnoreFocusClickMotion",
1350 "IgnoreRaiseClickMotion",
1351 "AllowFocusClickFunction",
1352 "AllowRaiseClickFunction",
1353 "GrabFocus",
1354 "GrabFocusTransient",
1355 "OverrideGrabFocus",
1356 "ReleaseFocus",
1357 "ReleaseFocusTransient",
1358 "OverrideReleaseFocus",
1359 NULL
1361 Bool found;
1362 int val;
1363 int index;
1364 char *token;
1366 if (ret_rest)
1368 *ret_rest = rest;
1371 found = True;
1372 val = !is_reversed;
1373 GetNextTokenIndex(option, optlist, 0, &index);
1374 switch (index)
1376 case 0:
1377 /* SortWindowlistByFocus */
1378 FPS_SORT_WINDOWLIST_BY(
1379 *f, (val) ?
1380 FPOL_SORT_WL_BY_FOCUS : FPOL_SORT_WL_BY_OPEN);
1381 FPS_SORT_WINDOWLIST_BY(*m, 1);
1382 FPS_SORT_WINDOWLIST_BY(*c, 1);
1383 break;
1384 case 1:
1385 /* FocusClickButtons */
1386 if (is_reversed)
1388 found = False;
1389 break;
1391 token = PeekToken(rest, ret_rest);
1392 val = 0;
1393 for ( ; token != NULL && isdigit(*token); token++)
1395 int button;
1396 char s[2];
1398 s[0] = *token;
1399 s[1] = 0;
1400 button = atoi(s);
1401 if (button == 0)
1403 val = ~0;
1405 else if (button > NUMBER_OF_EXTENDED_MOUSE_BUTTONS)
1407 break;
1409 else
1411 val |= (1 << (button - 1));
1414 if (token != NULL && *token != 0)
1416 fvwm_msg(
1417 ERR, "style_parse_focus_policy_style",
1418 "illegal mouse button '%c'", *token);
1419 val = DEF_FP_MOUSE_BUTTONS;
1421 if (token == NULL)
1423 val = DEF_FP_MOUSE_BUTTONS;
1425 FPS_MOUSE_BUTTONS(*f, val);
1426 FPS_MOUSE_BUTTONS(*m, ~0);
1427 FPS_MOUSE_BUTTONS(*c, ~0);
1428 break;
1429 case 2:
1430 /* FocusClickModifiers */
1431 if (is_reversed)
1433 found = False;
1434 break;
1436 token = PeekToken(rest, ret_rest);
1437 if (token == NULL ||
1438 modifiers_string_to_modmask(token, &val) == 1)
1440 val = DEF_FP_MODIFIERS;
1442 if (val & AnyModifier)
1444 val = FPOL_ANY_MODIFIER;
1446 FPS_MODIFIERS(*f, val);
1447 FPS_MODIFIERS(*m, ~0);
1448 FPS_MODIFIERS(*c, ~0);
1449 break;
1450 case 3:
1451 /* ClickRaisesFocused */
1452 FPS_RAISE_FOCUSED_CLIENT_CLICK(*f, val);
1453 FPS_RAISE_FOCUSED_CLIENT_CLICK(*m, 1);
1454 FPS_RAISE_FOCUSED_CLIENT_CLICK(*c, 1);
1455 break;
1456 case 4:
1457 /* ClickDecorRaisesFocused */
1458 FPS_RAISE_FOCUSED_DECOR_CLICK(*f, val);
1459 FPS_RAISE_FOCUSED_DECOR_CLICK(*m, 1);
1460 FPS_RAISE_FOCUSED_DECOR_CLICK(*c, 1);
1461 break;
1462 case 5:
1463 /* ClickIconRaisesFocused */
1464 FPS_RAISE_FOCUSED_ICON_CLICK(*f, val);
1465 FPS_RAISE_FOCUSED_ICON_CLICK(*m, 1);
1466 FPS_RAISE_FOCUSED_ICON_CLICK(*c, 1);
1467 break;
1468 case 6:
1469 /* ClickRaisesUnfocused */
1470 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(*f, val);
1471 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(*m, 1);
1472 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(*c, 1);
1473 break;
1474 case 7:
1475 /* ClickDecorRaisesUnfocused */
1476 FPS_RAISE_UNFOCUSED_DECOR_CLICK(*f, val);
1477 FPS_RAISE_UNFOCUSED_DECOR_CLICK(*m, 1);
1478 FPS_RAISE_UNFOCUSED_DECOR_CLICK(*c, 1);
1479 break;
1480 case 8:
1481 /* ClickIconRaisesUnfocused */
1482 FPS_RAISE_UNFOCUSED_ICON_CLICK(*f, val);
1483 FPS_RAISE_UNFOCUSED_ICON_CLICK(*m, 1);
1484 FPS_RAISE_UNFOCUSED_ICON_CLICK(*c, 1);
1485 break;
1486 case 9:
1487 /* ClickToFocus */
1488 FPS_FOCUS_CLICK_CLIENT(*f, val);
1489 FPS_FOCUS_CLICK_CLIENT(*m, 1);
1490 FPS_FOCUS_CLICK_CLIENT(*c, 1);
1491 break;
1492 case 10:
1493 /* ClickDecorToFocus */
1494 FPS_FOCUS_CLICK_DECOR(*f, val);
1495 FPS_FOCUS_CLICK_DECOR(*m, 1);
1496 FPS_FOCUS_CLICK_DECOR(*c, 1);
1497 break;
1498 case 11:
1499 /* ClickIconToFocus */
1500 FPS_FOCUS_CLICK_ICON(*f, val);
1501 FPS_FOCUS_CLICK_ICON(*m, 1);
1502 FPS_FOCUS_CLICK_ICON(*c, 1);
1503 break;
1504 case 12:
1505 /* EnterToFocus */
1506 FPS_FOCUS_ENTER(*f, val);
1507 FPS_FOCUS_ENTER(*m, 1);
1508 FPS_FOCUS_ENTER(*c, 1);
1509 break;
1510 case 13:
1511 /* LeaveToUnfocus */
1512 FPS_UNFOCUS_LEAVE(*f, val);
1513 FPS_UNFOCUS_LEAVE(*m, 1);
1514 FPS_UNFOCUS_LEAVE(*c, 1);
1515 break;
1516 case 14:
1517 /* FocusByProgram */
1518 FPS_FOCUS_BY_PROGRAM(*f, val);
1519 FPS_FOCUS_BY_PROGRAM(*m, 1);
1520 FPS_FOCUS_BY_PROGRAM(*c, 1);
1521 break;
1522 case 15:
1523 /* FocusByFunction */
1524 FPS_FOCUS_BY_FUNCTION(*f, val);
1525 FPS_FOCUS_BY_FUNCTION(*m, 1);
1526 FPS_FOCUS_BY_FUNCTION(*c, 1);
1527 break;
1528 case 16:
1529 /* FocusByFunctionWarpPointer */
1530 FPS_WARP_POINTER_ON_FOCUS_FUNC(*f, val);
1531 FPS_WARP_POINTER_ON_FOCUS_FUNC(*m, 1);
1532 FPS_WARP_POINTER_ON_FOCUS_FUNC(*c, 1);
1533 break;
1534 case 17:
1535 /* Lenient */
1536 FPS_LENIENT(*f, val);
1537 FPS_LENIENT(*m, 1);
1538 FPS_LENIENT(*c, 1);
1539 break;
1540 case 18:
1541 /* PassFocusClick */
1542 FPS_PASS_FOCUS_CLICK(*f, val);
1543 FPS_PASS_FOCUS_CLICK(*m, 1);
1544 FPS_PASS_FOCUS_CLICK(*c, 1);
1545 break;
1546 case 19:
1547 /* PassRaiseClick */
1548 FPS_PASS_RAISE_CLICK(*f, val);
1549 FPS_PASS_RAISE_CLICK(*m, 1);
1550 FPS_PASS_RAISE_CLICK(*c, 1);
1551 break;
1552 case 20:
1553 /* IgnoreFocusClickMotion */
1554 FPS_IGNORE_FOCUS_CLICK_MOTION(*f, val);
1555 FPS_IGNORE_FOCUS_CLICK_MOTION(*m, 1);
1556 FPS_IGNORE_FOCUS_CLICK_MOTION(*c, 1);
1557 break;
1558 case 21:
1559 /* IgnoreRaiseClickMotion */
1560 FPS_IGNORE_RAISE_CLICK_MOTION(*f, val);
1561 FPS_IGNORE_RAISE_CLICK_MOTION(*m, 1);
1562 FPS_IGNORE_RAISE_CLICK_MOTION(*c, 1);
1563 break;
1564 case 22:
1565 /* AllowFocusClickFunction */
1566 FPS_ALLOW_FUNC_FOCUS_CLICK(*f, val);
1567 FPS_ALLOW_FUNC_FOCUS_CLICK(*m, 1);
1568 FPS_ALLOW_FUNC_FOCUS_CLICK(*c, 1);
1569 break;
1570 case 23:
1571 /* AllowRaiseClickFunction */
1572 FPS_ALLOW_FUNC_RAISE_CLICK(*f, val);
1573 FPS_ALLOW_FUNC_RAISE_CLICK(*m, 1);
1574 FPS_ALLOW_FUNC_RAISE_CLICK(*c, 1);
1575 break;
1576 case 24:
1577 /* GrabFocus */
1578 FPS_GRAB_FOCUS(*f, val);
1579 FPS_GRAB_FOCUS(*m, 1);
1580 FPS_GRAB_FOCUS(*c, 1);
1581 break;
1582 case 25:
1583 /* GrabFocusTransient */
1584 FPS_GRAB_FOCUS_TRANSIENT(*f, val);
1585 FPS_GRAB_FOCUS_TRANSIENT(*m, 1);
1586 FPS_GRAB_FOCUS_TRANSIENT(*c, 1);
1587 break;
1588 case 26:
1589 /* OverrideGrabFocus */
1590 FPS_OVERRIDE_GRAB_FOCUS(*f, val);
1591 FPS_OVERRIDE_GRAB_FOCUS(*m, 1);
1592 FPS_OVERRIDE_GRAB_FOCUS(*c, 1);
1593 break;
1594 case 27:
1595 /* ReleaseFocus */
1596 FPS_RELEASE_FOCUS(*f, val);
1597 FPS_RELEASE_FOCUS(*m, 1);
1598 FPS_RELEASE_FOCUS(*c, 1);
1599 break;
1600 case 28:
1601 /* ReleaseFocusTransient */
1602 FPS_RELEASE_FOCUS_TRANSIENT(*f, val);
1603 FPS_RELEASE_FOCUS_TRANSIENT(*m, 1);
1604 FPS_RELEASE_FOCUS_TRANSIENT(*c, 1);
1605 break;
1606 case 29:
1607 /* OverrideReleaseFocus */
1608 FPS_OVERRIDE_RELEASE_FOCUS(*f, val);
1609 FPS_OVERRIDE_RELEASE_FOCUS(*m, 1);
1610 FPS_OVERRIDE_RELEASE_FOCUS(*c, 1);
1611 break;
1612 default:
1613 found = False;
1614 break;
1617 return found;
1620 static char *style_parse_icon_size_style(
1621 char *option, char *rest, window_style *ps)
1623 int vals[4];
1624 int i;
1626 option = PeekToken(rest, NULL);
1627 if (StrEquals(option, "Stretched"))
1629 SSET_ICON_RESIZE_TYPE(*ps, ICON_RESIZE_TYPE_STRETCHED);
1630 option = PeekToken(rest, &rest);
1632 else if (StrEquals(option, "Adjusted"))
1634 SSET_ICON_RESIZE_TYPE(*ps, ICON_RESIZE_TYPE_ADJUSTED);
1635 option = PeekToken(rest, &rest);
1637 else if (StrEquals(option, "Shrunk"))
1639 SSET_ICON_RESIZE_TYPE(*ps, ICON_RESIZE_TYPE_SHRUNK);
1640 option = PeekToken(rest, &rest);
1642 else
1644 SSET_ICON_RESIZE_TYPE(*ps, ICON_RESIZE_TYPE_NONE);
1647 switch (GetIntegerArguments(rest, &rest, vals, 4))
1649 case 0:
1650 /* No arguments results in default values */
1651 vals[0] = vals[1] = UNSPECIFIED_ICON_DIMENSION;
1652 /* fall through */
1653 case 2:
1654 /* Max and min values are the same */
1655 vals[2] = vals[0];
1656 vals[3] = vals[1];
1657 /* fall through */
1658 case 4:
1659 /* Validate values */
1660 for (i = 0; i < 4; i++)
1662 int use_default = 0;
1664 if (vals[i] != UNSPECIFIED_ICON_DIMENSION &&
1665 (vals[i] < MIN_ALLOWABLE_ICON_DIMENSION ||
1666 vals[i] > MAX_ALLOWABLE_ICON_DIMENSION))
1668 fvwm_msg(
1669 ERR, "CMD_Style",
1670 "IconSize dimension (%d) not in valid"
1671 " range (%d-%d)",
1672 vals[i], MIN_ALLOWABLE_ICON_DIMENSION,
1673 MAX_ALLOWABLE_ICON_DIMENSION);
1674 use_default = 1;
1677 /* User requests default value for this dimension */
1678 else if (vals[i] == UNSPECIFIED_ICON_DIMENSION)
1680 use_default = 1;
1683 if (use_default)
1685 /* Set default value for this dimension. The
1686 * first two indexes refer to min values, the
1687 * latter two to max values. */
1688 vals[i] = i < 2 ? MIN_ALLOWABLE_ICON_DIMENSION :
1689 MAX_ALLOWABLE_ICON_DIMENSION;
1692 SSET_MIN_ICON_WIDTH(*ps, vals[0]);
1693 SSET_MIN_ICON_HEIGHT(*ps, vals[1]);
1694 SSET_MAX_ICON_WIDTH(*ps, vals[2]);
1695 SSET_MAX_ICON_HEIGHT(*ps, vals[3]);
1697 ps->flags.has_icon_size_limits = 1;
1698 ps->flag_mask.has_icon_size_limits = 1;
1699 ps->change_mask.has_icon_size_limits = 1;
1700 break;
1701 default:
1702 fvwm_msg(
1703 ERR, "CMD_Style",
1704 "IconSize requires exactly 0, 2 or 4"
1705 " numerical arguments");
1706 break;
1709 return rest;
1712 static char *style_parse_icon_box_style(
1713 icon_boxes **ret_ib, char *option, char *rest, window_style *ps)
1715 icon_boxes *IconBoxes = NULL;
1716 Bool is_screen_given = False;
1717 int val[4];
1718 int num;
1719 int i;
1721 option = PeekToken(rest, NULL);
1722 if (!option || StrEquals(option, "none"))
1724 option = PeekToken(rest, &rest);
1725 /* delete icon boxes from style */
1726 if (SGET_ICON_BOXES(*ps))
1728 remove_icon_boxes_from_style(ps);
1730 (*ret_ib) = NULL;
1731 if (option)
1733 /* disable default icon box */
1734 S_SET_DO_IGNORE_ICON_BOXES(SCF(*ps), 1);
1736 else
1738 /* use default icon box */
1739 S_SET_DO_IGNORE_ICON_BOXES(SCF(*ps), 0);
1741 S_SET_DO_IGNORE_ICON_BOXES(SCM(*ps), 1);
1742 S_SET_DO_IGNORE_ICON_BOXES(SCC(*ps), 1);
1743 ps->flags.has_icon_boxes = 0;
1744 ps->flag_mask.has_icon_boxes = 1;
1745 ps->change_mask.has_icon_boxes = 1;
1746 return rest;
1749 /* otherwise try to parse the icon box */
1750 IconBoxes = (icon_boxes *)safemalloc(sizeof(icon_boxes));
1751 /* clear it */
1752 memset(IconBoxes, 0, sizeof(icon_boxes));
1753 IconBoxes->IconScreen = FSCREEN_GLOBAL;
1754 /* init grid x */
1755 IconBoxes->IconGrid[0] = 3;
1756 /* init grid y */
1757 IconBoxes->IconGrid[1] = 3;
1759 /* check for screen (for 4 numbers) */
1760 if (StrEquals(option, "screen"))
1762 is_screen_given = True;
1763 option = PeekToken(rest, &rest); /* skip screen */
1764 option = PeekToken(rest, &rest); /* get the screen spec */
1765 IconBoxes->IconScreen =
1766 FScreenGetScreenArgument(option, FSCREEN_SPEC_PRIMARY);
1769 /* try for 4 numbers x y x y */
1770 num = GetIntegerArguments(rest, NULL, val, 4);
1772 /* if 4 numbers */
1773 if (num == 4)
1775 for (i = 0; i < 4; i++)
1777 /* make sure the value fits into a short */
1778 if (val[i] < -32768)
1780 val[i] = -32768;
1782 if (val[i] > 32767)
1784 val[i] = 32767;
1786 IconBoxes->IconBox[i] = val[i];
1787 /* If leading minus sign */
1788 option = PeekToken(rest, &rest);
1789 if (option[0] == '-')
1791 IconBoxes->IconSign[i]='-';
1792 } /* end leading minus sign */
1794 /* Note: here there is no test for valid co-ords, use geom */
1796 else if (is_screen_given)
1798 /* screen-spec is given but not 4 numbers */
1799 fvwm_msg(
1800 ERR,"CMD_Style",
1801 "IconBox requires 4 numbers if screen is given!"
1802 " Invalid: <%s>.", option);
1803 /* Drop the box */
1804 free(IconBoxes);
1805 /* forget about it */
1806 IconBoxes = 0;
1808 else
1810 /* Not 4 numeric args dje */
1811 /* bigger than =32767x32767+32767+32767 */
1812 int geom_flags;
1813 int l;
1814 int width;
1815 int height;
1817 /* read in 1 word w/o advancing */
1818 option = PeekToken(rest, NULL);
1819 if (!option)
1821 return rest;
1823 l = strlen(option);
1824 if (l > 0 && l < 24)
1826 /* advance */
1827 option = PeekToken(rest, &rest);
1828 /* if word found, not too long */
1829 geom_flags = FScreenParseGeometryWithScreen(
1830 option, &IconBoxes->IconBox[0],
1831 &IconBoxes->IconBox[1], (unsigned int*)&width,
1832 (unsigned int*)&height,
1833 &IconBoxes->IconScreen);
1834 if (width == 0 || !(geom_flags & WidthValue))
1836 /* zero width is invalid */
1837 fvwm_msg(
1838 ERR,"CMD_Style",
1839 "IconBox requires 4 numbers or"
1840 " geometry! Invalid string <%s>.",
1841 option);
1842 /* Drop the box */
1843 free(IconBoxes);
1844 /* forget about it */
1845 IconBoxes = 0;
1847 else
1849 /* got valid iconbox geom */
1850 if (geom_flags & XNegative)
1852 IconBoxes->IconBox[0] =
1853 /* neg x coord */
1854 IconBoxes->IconBox[0] -
1855 width - 2;
1856 /* save for later */
1857 IconBoxes->IconSign[0]='-';
1858 IconBoxes->IconSign[2]='-';
1860 if (geom_flags & YNegative)
1862 IconBoxes->IconBox[1] =
1863 /* neg y coord */
1864 IconBoxes->IconBox[1]
1865 - height -2;
1866 /* save for later */
1867 IconBoxes->IconSign[1]='-';
1868 IconBoxes->IconSign[3]='-';
1870 /* x + wid = right x */
1871 IconBoxes->IconBox[2] =
1872 width + IconBoxes->IconBox[0];
1873 /* y + height = bottom y */
1874 IconBoxes->IconBox[3] =
1875 height + IconBoxes->IconBox[1];
1876 } /* end icon geom worked */
1878 else
1880 /* no word or too long; drop the box */
1881 free(IconBoxes);
1882 /* forget about it */
1883 IconBoxes = 0;
1884 } /* end word found, not too long */
1885 } /* end not 4 args */
1886 /* If we created an IconBox, put it in the chain. */
1887 if (IconBoxes != 0)
1889 /* no error */
1890 if (SGET_ICON_BOXES(*ps) == 0)
1892 /* first one, chain to root */
1893 SSET_ICON_BOXES(*ps, IconBoxes);
1895 else
1897 /* else not first one, add to end of chain */
1898 (*ret_ib)->next = IconBoxes;
1899 } /* end not first one */
1900 /* new current box. save for grid */
1901 (*ret_ib) = IconBoxes;
1902 } /* end no error */
1903 S_SET_DO_IGNORE_ICON_BOXES(SCF(*ps), 0);
1904 S_SET_DO_IGNORE_ICON_BOXES(SCM(*ps), 1);
1905 S_SET_DO_IGNORE_ICON_BOXES(SCC(*ps), 1);
1906 ps->flags.has_icon_boxes = !!(SGET_ICON_BOXES(*ps));
1907 ps->flag_mask.has_icon_boxes = 1;
1908 ps->change_mask.has_icon_boxes = 1;
1910 return rest;
1913 static char *style_parse_icon_grid_style(
1914 char *option, char *rest, window_style *ps, icon_boxes *ib)
1916 int val[4];
1917 int num;
1918 int i;
1920 /* The grid always affects the prior iconbox */
1921 if (ib == 0)
1923 /* If no current box */
1924 fvwm_msg(
1925 ERR,"CMD_Style",
1926 "IconGrid must follow an IconBox in same Style"
1927 " command");
1928 return rest;
1930 /* have a place to grid */
1931 /* 2 ints */
1932 num = GetIntegerArguments(rest, &rest, val, 2);
1933 if (num != 2 || val[0] < 1 || val[1] < 1)
1935 fvwm_msg(
1936 ERR,"CMD_Style",
1937 "IconGrid needs 2 numbers > 0. Got %d numbers."
1938 " x=%d y=%d!", num, val[0], val[1]);
1939 /* reset grid */
1940 ib->IconGrid[0] = 3;
1941 ib->IconGrid[1] = 3;
1943 else
1945 for (i = 0; i < 2; i++)
1947 ib->IconGrid[i] = val[i];
1949 } /* end bad grid */
1951 return rest;
1954 static char *style_parse_icon_fill_style(
1955 char *option, char *rest, window_style *ps, icon_boxes *ib)
1957 /* first type direction parsed */
1958 unsigned char IconFill_1;
1959 /* second type direction parsed */
1960 unsigned char IconFill_2;
1962 /* direction to fill iconbox */
1963 /* The fill always affects the prior iconbox */
1964 if (ib == 0)
1966 /* If no current box */
1967 fvwm_msg(
1968 ERR,"CMD_Style",
1969 "IconFill must follow an IconBox in same Style"
1970 " command");
1971 return rest;
1973 /* have a place to fill */
1974 option = PeekToken(rest, &rest);
1975 /* top/bot/lft/rgt */
1976 if (!option || Get_TBLR(option, &IconFill_1) == 0)
1978 /* its wrong */
1979 if (!option)
1981 option = "(none)";
1983 fvwm_msg(
1984 ERR,"CMD_Style",
1985 "IconFill must be followed by T|B|R|L, found"
1986 " %s.", option);
1987 return rest;
1989 /* first word valid */
1991 /* read in second word */
1992 option = PeekToken(rest, &rest);
1993 /* top/bot/lft/rgt */
1994 if (!option || Get_TBLR(option, &IconFill_2) == 0)
1996 /* its wrong */
1997 if (!option)
1999 option = "(none)";
2001 fvwm_msg(
2002 ERR,"CMD_Style",
2003 "IconFill must be followed by T|B|R|L,"
2004 " found %s.", option);
2005 return rest;
2007 if ((IconFill_1 & ICONFILLHRZ) == (IconFill_2 & ICONFILLHRZ))
2009 fvwm_msg(
2010 ERR, "CMD_Style",
2011 "IconFill must specify a horizontal"
2012 " and vertical direction.");
2013 return rest;
2015 /* Its valid! */
2016 /* merge in flags */
2017 ib->IconFlags |= IconFill_1;
2018 /* ignore horiz in 2nd arg */
2019 IconFill_2 &= ~ICONFILLHRZ;
2020 /* merge in flags */
2021 ib->IconFlags |= IconFill_2;
2023 return rest;
2026 static Bool style_parse_one_style_option(
2027 char *token, char *rest, char **ret_rest, char *prefix,
2028 window_style *ps, icon_boxes **cur_ib)
2030 window_style *add_style;
2031 /* work area for button number */
2032 int num;
2033 int i;
2034 int tmpno[3] = { -1, -1, -1 };
2035 int val[4];
2036 int spargs = 0;
2037 Bool found;
2038 int on;
2039 char *token_l = NULL;
2041 found = True;
2042 on = 1;
2043 while (token[0] == '!')
2045 on ^= 1;
2046 token++;
2048 if (prefix != NULL && *prefix != 0)
2050 int l;
2052 l = strlen(prefix);
2053 if (strncasecmp(token, prefix, l) != 0)
2055 /* add missing prefix */
2056 token_l = (char *)safemalloc(l + strlen(token) + 1);
2057 strcpy(token_l, prefix);
2058 strcat(token_l, token);
2059 token = token_l;
2062 switch (tolower(token[0]))
2064 case 'a':
2065 if (StrEquals(token, "ACTIVEPLACEMENT"))
2067 ps->flags.placement_mode &= (~PLACE_RANDOM);
2068 ps->flag_mask.placement_mode |= PLACE_RANDOM;
2069 ps->change_mask.placement_mode |= PLACE_RANDOM;
2071 else if (StrEquals(token, "ACTIVEPLACEMENTHONORSSTARTSONPAGE"))
2073 ps->flags.manual_placement_honors_starts_on_page = on;
2074 ps->flag_mask.manual_placement_honors_starts_on_page =
2076 ps->change_mask.manual_placement_honors_starts_on_page
2077 = 1;
2079 else if (StrEquals(
2080 token, "ACTIVEPLACEMENTIGNORESSTARTSONPAGE"))
2082 ps->flags.manual_placement_honors_starts_on_page = !on;
2083 ps->flag_mask.manual_placement_honors_starts_on_page =
2085 ps->change_mask.manual_placement_honors_starts_on_page
2086 = 1;
2088 else if (StrEquals(token, "AllowRestack"))
2090 S_SET_DO_IGNORE_RESTACK(SCF(*ps), !on);
2091 S_SET_DO_IGNORE_RESTACK(SCM(*ps), 1);
2092 S_SET_DO_IGNORE_RESTACK(SCC(*ps), 1);
2094 else if (StrEquals(token, "AllowMaximizeFixedSize"))
2096 S_SET_MAXIMIZE_FIXED_SIZE_DISALLOWED(SCF(*ps), !on);
2097 S_SET_MAXIMIZE_FIXED_SIZE_DISALLOWED(SCM(*ps), 1);
2098 S_SET_MAXIMIZE_FIXED_SIZE_DISALLOWED(SCC(*ps), 1);
2100 else
2102 found = False;
2104 break;
2106 case 'b':
2107 if (StrEquals(token, "BackColor"))
2109 rest = GetNextToken(rest, &token);
2110 if (token)
2112 SAFEFREE(SGET_BACK_COLOR_NAME(*ps));
2113 SSET_BACK_COLOR_NAME(*ps, token);
2114 ps->flags.has_color_back = 1;
2115 ps->flag_mask.has_color_back = 1;
2116 ps->change_mask.has_color_back = 1;
2117 ps->flags.use_colorset = 0;
2118 ps->flag_mask.use_colorset = 1;
2119 ps->change_mask.use_colorset = 1;
2121 else
2123 fvwm_msg(
2124 ERR, "style_parse_on_estyle_option",
2125 "Style BackColor requires color"
2126 " argument");
2129 else if (StrEquals(token, "Button"))
2131 rest = style_parse_button_style(ps, rest, on);
2133 else if (StrEquals(token, "BorderWidth"))
2135 if (GetIntegerArguments(rest, &rest, val, 1))
2137 SSET_BORDER_WIDTH(*ps, (short)*val);
2138 ps->flags.has_border_width = 1;
2139 ps->flag_mask.has_border_width = 1;
2140 ps->change_mask.has_border_width = 1;
2142 else
2144 ps->flags.has_border_width = 0;
2145 ps->flag_mask.has_border_width = 1;
2146 ps->change_mask.has_border_width = 1;
2149 else if (StrEquals(token, "BackingStore"))
2151 ps->flags.use_backing_store = BACKINGSTORE_ON;
2152 ps->flag_mask.use_backing_store = BACKINGSTORE_MASK;
2153 ps->change_mask.use_backing_store = BACKINGSTORE_MASK;
2155 else if (StrEquals(token, "BackingStoreOff"))
2157 ps->flags.use_backing_store = BACKINGSTORE_OFF;
2158 ps->flag_mask.use_backing_store = BACKINGSTORE_MASK;
2159 ps->change_mask.use_backing_store = BACKINGSTORE_MASK;
2161 else if (StrEquals(token, "BackingStoreWindowDefault"))
2163 ps->flags.use_backing_store = BACKINGSTORE_DEFAULT;
2164 ps->flag_mask.use_backing_store = BACKINGSTORE_MASK;
2165 ps->change_mask.use_backing_store = BACKINGSTORE_MASK;
2167 else if (StrEquals(token, "BorderColorset"))
2169 *val = -1;
2170 GetIntegerArguments(rest, &rest, val, 1);
2171 SSET_BORDER_COLORSET(*ps, *val);
2172 alloc_colorset(*val);
2173 ps->flags.use_border_colorset = (*val >= 0);
2174 ps->flag_mask.use_border_colorset = 1;
2175 ps->change_mask.use_border_colorset = 1;
2177 else if (StrEquals(token, "BottomTitleRotated"))
2179 S_SET_IS_BOTTOM_TITLE_ROTATED(SCF(*ps), on);
2180 S_SET_IS_BOTTOM_TITLE_ROTATED(SCM(*ps), 1);
2181 S_SET_IS_BOTTOM_TITLE_ROTATED(SCC(*ps), 1);
2183 else if (StrEquals(token, "BottomTitleNotRotated"))
2185 S_SET_IS_BOTTOM_TITLE_ROTATED(SCF(*ps), !on);
2186 S_SET_IS_BOTTOM_TITLE_ROTATED(SCM(*ps), 1);
2187 S_SET_IS_BOTTOM_TITLE_ROTATED(SCC(*ps), 1);
2189 else if (StrEquals(token, "Borders"))
2191 S_SET_HAS_NO_BORDER(SCF(*ps), !on);
2192 S_SET_HAS_NO_BORDER(SCM(*ps), 1);
2193 S_SET_HAS_NO_BORDER(SCC(*ps), 1);
2195 else
2197 found = False;
2199 break;
2201 case 'c':
2202 if (StrEquals(token, "CascadePlacement"))
2204 ps->flags.placement_mode = PLACE_CASCADE;
2205 ps->flag_mask.placement_mode = PLACE_MASK;
2206 ps->change_mask.placement_mode = PLACE_MASK;
2208 else if (StrEquals(token, "CLEVERPLACEMENT"))
2210 ps->flags.placement_mode |= PLACE_CLEVER;
2211 ps->flag_mask.placement_mode |= PLACE_CLEVER;
2212 ps->change_mask.placement_mode |= PLACE_CLEVER;
2214 else if (StrEquals(token, "CleverPlacementOff"))
2216 ps->flags.placement_mode &= (~PLACE_CLEVER);
2217 ps->flag_mask.placement_mode |= PLACE_CLEVER;
2218 ps->change_mask.placement_mode |= PLACE_CLEVER;
2220 else if (StrEquals(token, "CaptureHonorsStartsOnPage"))
2222 ps->flags.capture_honors_starts_on_page = on;
2223 ps->flag_mask.capture_honors_starts_on_page = 1;
2224 ps->change_mask.capture_honors_starts_on_page = 1;
2226 else if (StrEquals(token, "CaptureIgnoresStartsonPage"))
2228 ps->flags.capture_honors_starts_on_page = !on;
2229 ps->flag_mask.capture_honors_starts_on_page = 1;
2230 ps->change_mask.capture_honors_starts_on_page = 1;
2232 else if (StrEquals(token, "ColorSet"))
2234 *val = -1;
2235 GetIntegerArguments(rest, &rest, val, 1);
2236 if (*val < 0)
2238 *val = -1;
2240 SSET_COLORSET(*ps, *val);
2241 alloc_colorset(*val);
2242 ps->flags.use_colorset = (*val >= 0);
2243 ps->flag_mask.use_colorset = 1;
2244 ps->change_mask.use_colorset = 1;
2246 else if (StrEquals(token, "Color"))
2248 char c = 0;
2249 char *next;
2251 next = GetNextToken(rest, &token);
2252 if (token == NULL)
2254 fvwm_msg(
2255 ERR, "style_parse_one_style_option",
2256 "Color Style requires a color"
2257 " argument");
2258 break;
2260 if (strncasecmp(token, "rgb:", 4) == 0)
2262 char *s;
2263 int i;
2265 /* spool to third '/' */
2266 for (i = 0, s = token + 4; *s && i < 3; s++)
2268 if (*s == '/')
2270 i++;
2273 s--;
2274 if (i == 3)
2276 *s = 0;
2277 /* spool to third '/' in original
2278 * string too */
2279 for (i = 0, s = rest; *s && i < 3; s++)
2281 if (*s == '/')
2283 i++;
2286 next = s - 1;
2289 else
2291 free(token);
2292 next = DoGetNextToken(
2293 rest, &token, NULL, ",/", &c);
2295 rest = next;
2296 SAFEFREE(SGET_FORE_COLOR_NAME(*ps));
2297 SSET_FORE_COLOR_NAME(*ps, token);
2298 ps->flags.has_color_fore = 1;
2299 ps->flag_mask.has_color_fore = 1;
2300 ps->change_mask.has_color_fore = 1;
2301 ps->flags.use_colorset = 0;
2302 ps->flag_mask.use_colorset = 1;
2303 ps->change_mask.use_colorset = 1;
2305 /* skip over '/' */
2306 if (c != '/')
2308 while (rest && *rest &&
2309 isspace((unsigned char)*rest) &&
2310 *rest != ',' && *rest != '/')
2312 rest++;
2314 if (*rest == '/')
2316 rest++;
2320 rest=GetNextToken(rest, &token);
2321 if (!token)
2323 fvwm_msg(
2324 ERR, "style_parse_one_style_option",
2325 "Color Style called with incomplete"
2326 " color argument.");
2327 break;
2329 SAFEFREE(SGET_BACK_COLOR_NAME(*ps));
2330 SSET_BACK_COLOR_NAME(*ps, token);
2331 ps->flags.has_color_back = 1;
2332 ps->flag_mask.has_color_back = 1;
2333 ps->change_mask.has_color_back = 1;
2334 break;
2336 else if (StrEquals(token, "CirculateSkipIcon"))
2338 S_SET_DO_CIRCULATE_SKIP_ICON(SCF(*ps), on);
2339 S_SET_DO_CIRCULATE_SKIP_ICON(SCM(*ps), 1);
2340 S_SET_DO_CIRCULATE_SKIP_ICON(SCC(*ps), 1);
2342 else if (StrEquals(token, "CirculateSkipShaded"))
2344 S_SET_DO_CIRCULATE_SKIP_SHADED(SCF(*ps), on);
2345 S_SET_DO_CIRCULATE_SKIP_SHADED(SCM(*ps), 1);
2346 S_SET_DO_CIRCULATE_SKIP_SHADED(SCC(*ps), 1);
2348 else if (StrEquals(token, "CirculateHitShaded"))
2350 S_SET_DO_CIRCULATE_SKIP_SHADED(SCF(*ps), !on);
2351 S_SET_DO_CIRCULATE_SKIP_SHADED(SCM(*ps), 1);
2352 S_SET_DO_CIRCULATE_SKIP_SHADED(SCC(*ps), 1);
2354 else if (StrEquals(token, "CirculateHitIcon"))
2356 S_SET_DO_CIRCULATE_SKIP_ICON(SCF(*ps), !on);
2357 S_SET_DO_CIRCULATE_SKIP_ICON(SCM(*ps), 1);
2358 S_SET_DO_CIRCULATE_SKIP_ICON(SCC(*ps), 1);
2360 else if (StrEquals(token, "ClickToFocus"))
2362 style_set_old_focus_policy(ps, 0);
2364 else if (StrEquals(token, "ClickToFocusPassesClick"))
2366 FPS_PASS_FOCUS_CLICK(S_FOCUS_POLICY(SCF(*ps)), on);
2367 FPS_PASS_FOCUS_CLICK(S_FOCUS_POLICY(SCM(*ps)), 1);
2368 FPS_PASS_FOCUS_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
2369 FPS_PASS_RAISE_CLICK(S_FOCUS_POLICY(SCF(*ps)), on);
2370 FPS_PASS_RAISE_CLICK(S_FOCUS_POLICY(SCM(*ps)), 1);
2371 FPS_PASS_RAISE_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
2373 else if (StrEquals(token, "ClickToFocusPassesClickOff"))
2375 FPS_PASS_FOCUS_CLICK(S_FOCUS_POLICY(SCF(*ps)), !on);
2376 FPS_PASS_FOCUS_CLICK(S_FOCUS_POLICY(SCM(*ps)), 1);
2377 FPS_PASS_FOCUS_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
2378 FPS_PASS_RAISE_CLICK(S_FOCUS_POLICY(SCF(*ps)), !on);
2379 FPS_PASS_RAISE_CLICK(S_FOCUS_POLICY(SCM(*ps)), 1);
2380 FPS_PASS_RAISE_CLICK(S_FOCUS_POLICY(SCC(*ps)), 1);
2382 else if (StrEquals(token, "ClickToFocusRaises"))
2384 FPS_RAISE_FOCUSED_CLIENT_CLICK(
2385 S_FOCUS_POLICY(SCF(*ps)), on);
2386 FPS_RAISE_FOCUSED_CLIENT_CLICK(
2387 S_FOCUS_POLICY(SCM(*ps)), 1);
2388 FPS_RAISE_FOCUSED_CLIENT_CLICK(
2389 S_FOCUS_POLICY(SCC(*ps)), 1);
2390 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
2391 S_FOCUS_POLICY(SCF(*ps)), on);
2392 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
2393 S_FOCUS_POLICY(SCM(*ps)), 1);
2394 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
2395 S_FOCUS_POLICY(SCC(*ps)), 1);
2397 else if (StrEquals(token, "ClickToFocusRaisesOff"))
2399 FPS_RAISE_FOCUSED_CLIENT_CLICK(
2400 S_FOCUS_POLICY(SCF(*ps)), !on);
2401 FPS_RAISE_FOCUSED_CLIENT_CLICK(
2402 S_FOCUS_POLICY(SCM(*ps)), 1);
2403 FPS_RAISE_FOCUSED_CLIENT_CLICK(
2404 S_FOCUS_POLICY(SCC(*ps)), 1);
2405 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
2406 S_FOCUS_POLICY(SCF(*ps)), !on);
2407 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
2408 S_FOCUS_POLICY(SCM(*ps)), 1);
2409 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
2410 S_FOCUS_POLICY(SCC(*ps)), 1);
2412 else if (StrEquals(token, "CirculateSkip"))
2414 S_SET_DO_CIRCULATE_SKIP(SCF(*ps), on);
2415 S_SET_DO_CIRCULATE_SKIP(SCM(*ps), 1);
2416 S_SET_DO_CIRCULATE_SKIP(SCC(*ps), 1);
2418 else if (StrEquals(token, "CirculateHit"))
2420 S_SET_DO_CIRCULATE_SKIP(SCF(*ps), !on);
2421 S_SET_DO_CIRCULATE_SKIP(SCM(*ps), 1);
2422 S_SET_DO_CIRCULATE_SKIP(SCC(*ps), 1);
2424 else if (StrEquals(token, "Closable"))
2426 S_SET_IS_UNCLOSABLE(SCF(*ps), !on);
2427 S_SET_IS_UNCLOSABLE(SCM(*ps), 1);
2428 S_SET_IS_UNCLOSABLE(SCC(*ps), 1);
2430 else
2432 found = False;
2434 break;
2436 case 'd':
2437 if (StrEquals(token, "DepressableBorder"))
2439 S_SET_HAS_DEPRESSABLE_BORDER(SCF(*ps), on);
2440 S_SET_HAS_DEPRESSABLE_BORDER(SCM(*ps), 1);
2441 S_SET_HAS_DEPRESSABLE_BORDER(SCC(*ps), 1);
2443 else if (StrEquals(token, "DecorateTransient"))
2445 ps->flags.do_decorate_transient = on;
2446 ps->flag_mask.do_decorate_transient = 1;
2447 ps->change_mask.do_decorate_transient = 1;
2449 else if (StrEquals(token, "DumbPlacement"))
2451 ps->flags.placement_mode &= (~PLACE_SMART);
2452 ps->flag_mask.placement_mode |= PLACE_SMART;
2453 ps->change_mask.placement_mode |= PLACE_SMART;
2455 else if (StrEquals(token, "DONTRAISETRANSIENT"))
2457 S_SET_DO_RAISE_TRANSIENT(SCF(*ps), !on);
2458 S_SET_DO_RAISE_TRANSIENT(SCM(*ps), 1);
2459 S_SET_DO_RAISE_TRANSIENT(SCC(*ps), 1);
2461 else if (StrEquals(token, "DONTLOWERTRANSIENT"))
2463 S_SET_DO_LOWER_TRANSIENT(SCF(*ps), !on);
2464 S_SET_DO_LOWER_TRANSIENT(SCM(*ps), 1);
2465 S_SET_DO_LOWER_TRANSIENT(SCC(*ps), 1);
2467 else if (StrEquals(token, "DontStackTransientParent"))
2469 S_SET_DO_STACK_TRANSIENT_PARENT(SCF(*ps), !on);
2470 S_SET_DO_STACK_TRANSIENT_PARENT(SCM(*ps), 1);
2471 S_SET_DO_STACK_TRANSIENT_PARENT(SCC(*ps), 1);
2473 else
2475 found = False;
2477 break;
2479 case 'e':
2480 if (StrEquals(token, "ExactWindowName"))
2482 S_SET_USE_INDEXED_WINDOW_NAME(SCF(*ps), !on);
2483 S_SET_USE_INDEXED_WINDOW_NAME(SCM(*ps), 1);
2484 S_SET_USE_INDEXED_WINDOW_NAME(SCC(*ps), 1);
2486 else if (StrEquals(token, "ExactIconName"))
2488 S_SET_USE_INDEXED_ICON_NAME(SCF(*ps), !on);
2489 S_SET_USE_INDEXED_ICON_NAME(SCM(*ps), 1);
2490 S_SET_USE_INDEXED_ICON_NAME(SCC(*ps), 1);
2492 else if (StrEquals(token, "EdgeMoveResistance"))
2494 int num;
2495 unsigned has_move;
2496 unsigned has_xinerama_move;
2498 num = GetIntegerArguments(rest, &rest, val, 2);
2499 if (num == 1)
2501 has_move = 1;
2502 has_xinerama_move = 0;
2504 else if (num == 2)
2506 has_move = 1;
2507 has_xinerama_move = 1;
2509 else
2511 val[0] = 0;
2512 val[1] = 0;
2513 has_move = 0;
2514 has_xinerama_move = 0;
2516 if (val[0] < 0)
2518 val[0] = 0;
2520 if (val[1] < 0)
2522 val[1] = 0;
2524 ps->flags.has_edge_resistance_move = has_move;
2525 ps->flag_mask.has_edge_resistance_move = 1;
2526 ps->change_mask.has_edge_resistance_move = 1;
2527 SSET_EDGE_RESISTANCE_MOVE(*ps, val[0]);
2528 ps->flags.has_edge_resistance_xinerama_move =
2529 has_xinerama_move;
2530 ps->flag_mask.has_edge_resistance_xinerama_move = 1;
2531 ps->change_mask.has_edge_resistance_xinerama_move = 1;
2532 SSET_EDGE_RESISTANCE_XINERAMA_MOVE(*ps, val[1]);
2534 else if (StrEquals(token, "EdgeMoveDelay"))
2536 if (GetIntegerArguments(rest, &rest, val, 1))
2538 SSET_EDGE_DELAY_MS_MOVE(*ps, (short)*val);
2539 ps->flags.has_edge_delay_ms_move = 1;
2540 ps->flag_mask.has_edge_delay_ms_move = 1;
2541 ps->change_mask.has_edge_delay_ms_move = 1;
2543 else
2545 ps->flags.has_edge_delay_ms_move = 0;
2546 ps->flag_mask.has_edge_delay_ms_move = 1;
2547 ps->change_mask.has_edge_delay_ms_move = 1;
2550 else if (StrEquals(token, "EdgeResizeDelay"))
2552 if (GetIntegerArguments(rest, &rest, val, 1))
2554 SSET_EDGE_DELAY_MS_RESIZE(*ps, (short)*val);
2555 ps->flags.has_edge_delay_ms_resize = 1;
2556 ps->flag_mask.has_edge_delay_ms_resize = 1;
2557 ps->change_mask.has_edge_delay_ms_resize = 1;
2559 else
2561 ps->flags.has_edge_delay_ms_resize = 0;
2562 ps->flag_mask.has_edge_delay_ms_resize = 1;
2563 ps->change_mask.has_edge_delay_ms_resize = 1;
2566 else
2568 found = EWMH_CMD_Style(token, ps, on);
2570 break;
2572 case 'f':
2573 if (strncasecmp(token, "fp", 2) == 0)
2575 /* parse focus policy options */
2576 found = style_parse_focus_policy_style(
2577 token + 2, rest, &rest, (on) ? False : True,
2578 &S_FOCUS_POLICY(SCF(*ps)),
2579 &S_FOCUS_POLICY(SCM(*ps)),
2580 &S_FOCUS_POLICY(SCC(*ps)));
2582 else if (StrEquals(token, "Font"))
2584 SAFEFREE(SGET_WINDOW_FONT(*ps));
2585 rest = GetNextToken(rest, &token);
2586 SSET_WINDOW_FONT(*ps, token);
2587 S_SET_HAS_WINDOW_FONT(SCF(*ps), (token != NULL));
2588 S_SET_HAS_WINDOW_FONT(SCM(*ps), 1);
2589 S_SET_HAS_WINDOW_FONT(SCC(*ps), 1);
2592 else if (StrEquals(token, "ForeColor"))
2594 rest = GetNextToken(rest, &token);
2595 if (token)
2597 SAFEFREE(SGET_FORE_COLOR_NAME(*ps));
2598 SSET_FORE_COLOR_NAME(*ps, token);
2599 ps->flags.has_color_fore = 1;
2600 ps->flag_mask.has_color_fore = 1;
2601 ps->change_mask.has_color_fore = 1;
2602 ps->flags.use_colorset = 0;
2603 ps->flag_mask.use_colorset = 1;
2604 ps->change_mask.use_colorset = 1;
2606 else
2608 fvwm_msg(
2609 ERR, "style_parse_one_style_option",
2610 "ForeColor Style needs color argument"
2614 else if (StrEquals(token, "FVWMBUTTONS"))
2616 S_SET_HAS_MWM_BUTTONS(SCF(*ps), !on);
2617 S_SET_HAS_MWM_BUTTONS(SCM(*ps), 1);
2618 S_SET_HAS_MWM_BUTTONS(SCC(*ps), 1);
2620 else if (StrEquals(token, "FVWMBORDER"))
2622 S_SET_HAS_MWM_BORDER(SCF(*ps), !on);
2623 S_SET_HAS_MWM_BORDER(SCM(*ps), 1);
2624 S_SET_HAS_MWM_BORDER(SCC(*ps), 1);
2626 else if (StrEquals(token, "FocusFollowsMouse"))
2628 style_set_old_focus_policy(ps, 1);
2630 else if (StrEquals(token, "FirmBorder"))
2632 S_SET_HAS_DEPRESSABLE_BORDER(SCF(*ps), !on);
2633 S_SET_HAS_DEPRESSABLE_BORDER(SCM(*ps), 1);
2634 S_SET_HAS_DEPRESSABLE_BORDER(SCC(*ps), 1);
2636 else if (StrEquals(token, "FixedPosition") ||
2637 StrEquals(token, "FixedUSPosition"))
2639 S_SET_IS_FIXED(SCF(*ps), on);
2640 S_SET_IS_FIXED(SCM(*ps), 1);
2641 S_SET_IS_FIXED(SCC(*ps), 1);
2643 else if (StrEquals(token, "FixedPPosition"))
2645 S_SET_IS_FIXED_PPOS(SCF(*ps), on);
2646 S_SET_IS_FIXED_PPOS(SCM(*ps), 1);
2647 S_SET_IS_FIXED_PPOS(SCC(*ps), 1);
2649 else if (StrEquals(token, "FixedSize") ||
2650 StrEquals(token, "FixedUSSize"))
2652 S_SET_IS_SIZE_FIXED(SCF(*ps), on);
2653 S_SET_IS_SIZE_FIXED(SCM(*ps), 1);
2654 S_SET_IS_SIZE_FIXED(SCC(*ps), 1);
2656 else if (StrEquals(token, "FixedPSize"))
2658 S_SET_IS_PSIZE_FIXED(SCF(*ps), on);
2659 S_SET_IS_PSIZE_FIXED(SCM(*ps), 1);
2660 S_SET_IS_PSIZE_FIXED(SCC(*ps), 1);
2662 else
2664 found = False;
2666 break;
2668 case 'g':
2669 if (StrEquals(token, "GrabFocusOff"))
2671 FPS_GRAB_FOCUS(S_FOCUS_POLICY(SCF(*ps)), !on);
2672 FPS_GRAB_FOCUS(S_FOCUS_POLICY(SCM(*ps)), 1);
2673 FPS_GRAB_FOCUS(S_FOCUS_POLICY(SCC(*ps)), 1);
2675 else if (StrEquals(token, "GrabFocus"))
2677 FPS_GRAB_FOCUS(S_FOCUS_POLICY(SCF(*ps)), on);
2678 FPS_GRAB_FOCUS(S_FOCUS_POLICY(SCM(*ps)), 1);
2679 FPS_GRAB_FOCUS(S_FOCUS_POLICY(SCC(*ps)), 1);
2681 else if (StrEquals(token, "GrabFocusTransientOff"))
2683 FPS_GRAB_FOCUS_TRANSIENT(
2684 S_FOCUS_POLICY(SCF(*ps)), !on);
2685 FPS_GRAB_FOCUS_TRANSIENT(S_FOCUS_POLICY(SCM(*ps)), 1);
2686 FPS_GRAB_FOCUS_TRANSIENT(S_FOCUS_POLICY(SCC(*ps)), 1);
2688 else if (StrEquals(token, "GrabFocusTransient"))
2690 FPS_GRAB_FOCUS_TRANSIENT(S_FOCUS_POLICY(SCF(*ps)), on);
2691 FPS_GRAB_FOCUS_TRANSIENT(S_FOCUS_POLICY(SCM(*ps)), 1);
2692 FPS_GRAB_FOCUS_TRANSIENT(S_FOCUS_POLICY(SCC(*ps)), 1);
2694 else if (StrEquals(token, "GNOMEIgnoreHints"))
2696 S_SET_DO_IGNORE_GNOME_HINTS(SCF(*ps), on);
2697 S_SET_DO_IGNORE_GNOME_HINTS(SCM(*ps), 1);
2698 S_SET_DO_IGNORE_GNOME_HINTS(SCC(*ps), 1);
2700 else if (StrEquals(token, "GNOMEUseHints"))
2702 S_SET_DO_IGNORE_GNOME_HINTS(SCF(*ps), !on);
2703 S_SET_DO_IGNORE_GNOME_HINTS(SCM(*ps), 1);
2704 S_SET_DO_IGNORE_GNOME_HINTS(SCC(*ps), 1);
2706 else
2708 found = False;
2710 break;
2712 case 'h':
2713 if (StrEquals(token, "HintOverride"))
2715 S_SET_HAS_MWM_OVERRIDE(SCF(*ps), on);
2716 S_SET_HAS_MWM_OVERRIDE(SCM(*ps), 1);
2717 S_SET_HAS_MWM_OVERRIDE(SCC(*ps), 1);
2719 else if (StrEquals(token, "Handles"))
2721 ps->flags.has_no_handles = !on;
2722 ps->flag_mask.has_no_handles = 1;
2723 ps->change_mask.has_no_handles = 1;
2725 else if (StrEquals(token, "HandleWidth"))
2727 if (GetIntegerArguments(rest, &rest, val, 1))
2729 SSET_HANDLE_WIDTH(*ps, (short)*val);
2730 ps->flags.has_handle_width = 1;
2731 ps->flag_mask.has_handle_width = 1;
2732 ps->change_mask.has_handle_width = 1;
2734 else
2736 ps->flags.has_handle_width = 0;
2737 ps->flag_mask.has_handle_width = 1;
2738 ps->change_mask.has_handle_width = 1;
2741 else if (StrEquals(token, "HilightFore"))
2743 rest = GetNextToken(rest, &token);
2744 if (token)
2746 SAFEFREE(SGET_FORE_COLOR_NAME_HI(*ps));
2747 SSET_FORE_COLOR_NAME_HI(*ps, token);
2748 ps->flags.has_color_fore_hi = 1;
2749 ps->flag_mask.has_color_fore_hi = 1;
2750 ps->change_mask.has_color_fore_hi = 1;
2751 ps->flags.use_colorset_hi = 0;
2752 ps->flag_mask.use_colorset_hi = 1;
2753 ps->change_mask.use_colorset_hi = 1;
2755 else
2757 fvwm_msg(
2758 ERR, "style_parse_one_style_option",
2759 "HilightFore Style needs color"
2760 " argument");
2763 else if (StrEquals(token, "HilightBack"))
2765 rest = GetNextToken(rest, &token);
2766 if (token)
2768 SAFEFREE(SGET_BACK_COLOR_NAME_HI(*ps));
2769 SSET_BACK_COLOR_NAME_HI(*ps, token);
2770 ps->flags.has_color_back_hi = 1;
2771 ps->flag_mask.has_color_back_hi = 1;
2772 ps->change_mask.has_color_back_hi = 1;
2773 ps->flags.use_colorset_hi = 0;
2774 ps->flag_mask.use_colorset_hi = 1;
2775 ps->change_mask.use_colorset_hi = 1;
2777 else
2779 fvwm_msg(
2780 ERR, "style_parse_one_style_option",
2781 "HilightBack Style needs color"
2782 " argument");
2785 else if (StrEquals(token, "HilightColorset"))
2787 *val = -1;
2788 GetIntegerArguments(rest, &rest, val, 1);
2789 SSET_COLORSET_HI(*ps, *val);
2790 alloc_colorset(*val);
2791 ps->flags.use_colorset_hi = (*val >= 0);
2792 ps->flag_mask.use_colorset_hi = 1;
2793 ps->change_mask.use_colorset_hi = 1;
2795 else if (StrEquals(token, "HilightBorderColorset"))
2797 *val = -1;
2798 GetIntegerArguments(rest, &rest, val, 1);
2799 SSET_BORDER_COLORSET_HI(*ps, *val);
2800 alloc_colorset(*val);
2801 ps->flags.use_border_colorset_hi = (*val >= 0);
2802 ps->flag_mask.use_border_colorset_hi = 1;
2803 ps->change_mask.use_border_colorset_hi = 1;
2805 else if (StrEquals(token, "HilightIconTitleColorset"))
2807 *val = -1;
2808 GetIntegerArguments(rest, &rest, val, 1);
2809 SSET_ICON_TITLE_COLORSET_HI(*ps, *val);
2810 alloc_colorset(*val);
2811 ps->flags.use_icon_title_colorset_hi = (*val >= 0);
2812 ps->flag_mask.use_icon_title_colorset_hi = 1;
2813 ps->change_mask.use_icon_title_colorset_hi = 1;
2815 else
2817 found = False;
2819 break;
2821 case 'i':
2822 if (StrEquals(token, "Icon"))
2824 if (on == 1)
2826 rest = GetNextToken(rest, &token);
2828 SAFEFREE(SGET_ICON_NAME(*ps));
2829 SSET_ICON_NAME(*ps,token);
2830 ps->flags.has_icon = (token != NULL);
2831 ps->flag_mask.has_icon = 1;
2832 ps->change_mask.has_icon = 1;
2834 S_SET_IS_ICON_SUPPRESSED(SCF(*ps), 0);
2835 S_SET_IS_ICON_SUPPRESSED(SCM(*ps), 1);
2836 S_SET_IS_ICON_SUPPRESSED(SCC(*ps), 1);
2838 else
2840 S_SET_IS_ICON_SUPPRESSED(SCF(*ps), 1);
2841 S_SET_IS_ICON_SUPPRESSED(SCM(*ps), 1);
2842 S_SET_IS_ICON_SUPPRESSED(SCC(*ps), 1);
2845 else if (StrEquals(token, "IconBackgroundColorset"))
2847 *val = -1;
2848 GetIntegerArguments(rest, &rest, val, 1);
2849 SSET_ICON_BACKGROUND_COLORSET(*ps, *val);
2850 alloc_colorset(*val);
2851 ps->flags.use_icon_background_colorset = (*val >= 0);
2852 ps->flag_mask.use_icon_background_colorset = 1;
2853 ps->change_mask.use_icon_background_colorset = 1;
2855 else if (StrEquals(token, "IconBackgroundPadding"))
2857 *val = ICON_BACKGROUND_PADDING;
2858 GetIntegerArguments(rest, &rest, val, 1);
2859 if (*val < 0)
2861 *val = 0;
2863 else if (*val > 50)
2865 *val = 50;
2867 SSET_ICON_BACKGROUND_PADDING(*ps, (unsigned char)*val);
2868 ps->flags.has_icon_background_padding = 1;
2869 ps->flag_mask.has_icon_background_padding = 1;
2870 ps->change_mask.has_icon_background_padding = 1;
2872 else if (StrEquals(token, "IconBackgroundRelief"))
2874 *val = ICON_RELIEF_WIDTH;
2875 GetIntegerArguments(rest, &rest, val, 1);
2876 if (*val < -50)
2878 *val = -50;
2880 else if (*val > 50)
2882 *val = 50;
2884 SSET_ICON_BACKGROUND_RELIEF(*ps, (signed char)*val);
2885 ps->flags.has_icon_background_relief = 1;
2886 ps->flag_mask.has_icon_background_relief = 1;
2887 ps->change_mask.has_icon_background_relief = 1;
2889 else if (StrEquals(token, "IconFont"))
2891 SAFEFREE(SGET_ICON_FONT(*ps));
2892 rest = GetNextToken(rest, &token);
2893 SSET_ICON_FONT(*ps, token);
2894 S_SET_HAS_ICON_FONT(SCF(*ps), (token != NULL));
2895 S_SET_HAS_ICON_FONT(SCM(*ps), 1);
2896 S_SET_HAS_ICON_FONT(SCC(*ps), 1);
2899 else if (StrEquals(token, "IconOverride"))
2901 S_SET_ICON_OVERRIDE(SCF(*ps), ICON_OVERRIDE);
2902 S_SET_ICON_OVERRIDE(SCM(*ps), ICON_OVERRIDE_MASK);
2903 S_SET_ICON_OVERRIDE(SCC(*ps), ICON_OVERRIDE_MASK);
2905 else if (StrEquals(token, "IgnoreRestack"))
2907 S_SET_DO_IGNORE_RESTACK(SCF(*ps), on);
2908 S_SET_DO_IGNORE_RESTACK(SCM(*ps), 1);
2909 S_SET_DO_IGNORE_RESTACK(SCC(*ps), 1);
2911 else if (StrEquals(token, "IconTitle"))
2913 S_SET_HAS_NO_ICON_TITLE(SCF(*ps), !on);
2914 S_SET_HAS_NO_ICON_TITLE(SCM(*ps), 1);
2915 S_SET_HAS_NO_ICON_TITLE(SCC(*ps), 1);
2917 else if (StrEquals(token, "IconTitleColorset"))
2919 *val = -1;
2920 GetIntegerArguments(rest,&rest, val, 1);
2921 SSET_ICON_TITLE_COLORSET(*ps, *val);
2922 alloc_colorset(*val);
2923 ps->flags.use_icon_title_colorset = (*val >= 0);
2924 ps->flag_mask.use_icon_title_colorset = 1;
2925 ps->change_mask.use_icon_title_colorset = 1;
2927 else if (StrEquals(token, "IconTitleRelief"))
2929 *val = ICON_RELIEF_WIDTH;
2930 GetIntegerArguments(rest, &rest, val, 1);
2931 if (*val < -50)
2933 *val = -50;
2935 else if (*val > 50)
2937 *val = 50;
2939 SSET_ICON_TITLE_RELIEF(*ps, (signed char)*val);
2940 ps->flags.has_icon_title_relief = 1;
2941 ps->flag_mask.has_icon_title_relief = 1;
2942 ps->change_mask.has_icon_title_relief = 1;
2944 else if (StrEquals(token, "IconSize"))
2946 rest = style_parse_icon_size_style(token, rest, ps);
2948 else if (StrEquals(token, "IconBox"))
2950 rest = style_parse_icon_box_style(cur_ib, token, rest,
2951 ps);
2952 } /* end iconbox parameter */
2953 else if (StrEquals(token, "ICONGRID"))
2955 rest = style_parse_icon_grid_style(token, rest, ps,
2956 *cur_ib);
2958 else if (StrEquals(token, "ICONFILL"))
2960 rest = style_parse_icon_fill_style(token, rest, ps,
2961 *cur_ib);
2962 } /* end iconfill */
2963 else if (StrEquals(token, "IconifyWindowGroups"))
2965 S_SET_DO_ICONIFY_WINDOW_GROUPS(SCF(*ps), on);
2966 S_SET_DO_ICONIFY_WINDOW_GROUPS(SCM(*ps), 1);
2967 S_SET_DO_ICONIFY_WINDOW_GROUPS(SCC(*ps), 1);
2969 else if (StrEquals(token, "IconifyWindowGroupsOff"))
2971 S_SET_DO_ICONIFY_WINDOW_GROUPS(SCF(*ps), !on);
2972 S_SET_DO_ICONIFY_WINDOW_GROUPS(SCM(*ps), 1);
2973 S_SET_DO_ICONIFY_WINDOW_GROUPS(SCC(*ps), 1);
2975 else if (StrEquals(token, "Iconifiable"))
2977 S_SET_IS_UNICONIFIABLE(SCF(*ps), !on);
2978 S_SET_IS_UNICONIFIABLE(SCM(*ps), 1);
2979 S_SET_IS_UNICONIFIABLE(SCC(*ps), 1);
2981 else if (StrEquals(token, "IndexedWindowName"))
2983 S_SET_USE_INDEXED_WINDOW_NAME(SCF(*ps), on);
2984 S_SET_USE_INDEXED_WINDOW_NAME(SCM(*ps), 1);
2985 S_SET_USE_INDEXED_WINDOW_NAME(SCC(*ps), 1);
2987 else if (StrEquals(token, "IndexedIconName"))
2989 S_SET_USE_INDEXED_ICON_NAME(SCF(*ps), on);
2990 S_SET_USE_INDEXED_ICON_NAME(SCM(*ps), 1);
2991 S_SET_USE_INDEXED_ICON_NAME(SCC(*ps), 1);
2993 else if (StrEquals(token, "InitialMapCommand"))
2995 char *s;
2997 s = (rest != NULL) ? strdup(rest) : NULL;
2998 SSET_INITIAL_MAP_COMMAND_STRING(*ps, s);
2999 ps->flags.has_initial_map_command_string = on;
3000 ps->flag_mask.has_initial_map_command_string = on;
3001 ps->change_mask.has_initial_map_command_string = 1;
3002 rest = NULL; /* consume the entire string */
3004 else
3006 found = False;
3008 break;
3010 case 'j':
3011 if (0)
3014 else
3016 found = False;
3018 break;
3020 case 'k':
3021 if (StrEquals(token, "KeepWindowGroupsOnDesk"))
3023 S_SET_DO_USE_WINDOW_GROUP_HINT(SCF(*ps), on);
3024 S_SET_DO_USE_WINDOW_GROUP_HINT(SCM(*ps), 1);
3025 S_SET_DO_USE_WINDOW_GROUP_HINT(SCC(*ps), 1);
3027 else
3029 found = False;
3031 break;
3033 case 'l':
3034 if (StrEquals(token, "LeftTitleRotatedCW"))
3036 S_SET_IS_LEFT_TITLE_ROTATED_CW(SCF(*ps), on);
3037 S_SET_IS_LEFT_TITLE_ROTATED_CW(SCM(*ps), 1);
3038 S_SET_IS_LEFT_TITLE_ROTATED_CW(SCC(*ps), 1);
3040 else if (StrEquals(token, "LeftTitleRotatedCCW"))
3042 S_SET_IS_LEFT_TITLE_ROTATED_CW(SCF(*ps), !on);
3043 S_SET_IS_LEFT_TITLE_ROTATED_CW(SCM(*ps), 1);
3044 S_SET_IS_LEFT_TITLE_ROTATED_CW(SCC(*ps), 1);
3046 else if (StrEquals(token, "Lenience"))
3048 FPS_LENIENT(S_FOCUS_POLICY(SCF(*ps)), on);
3049 FPS_LENIENT(S_FOCUS_POLICY(SCM(*ps)), 1);
3050 FPS_LENIENT(S_FOCUS_POLICY(SCC(*ps)), 1);
3052 else if (StrEquals(token, "Layer"))
3054 *val = -1;
3055 if (GetIntegerArguments(rest, &rest, val, 1) &&
3056 *val < 0)
3058 fvwm_msg(ERR, "style_parse_one_style_option",
3059 "Layer must be positive or zero.");
3061 if (*val < 0)
3063 SSET_LAYER(*ps, -9);
3064 /* mark layer unset */
3065 ps->flags.use_layer = 0;
3066 ps->flag_mask.use_layer = 1;
3067 ps->change_mask.use_layer = 1;
3069 else
3071 SSET_LAYER(*ps, *val);
3072 ps->flags.use_layer = 1;
3073 ps->flag_mask.use_layer = 1;
3074 ps->change_mask.use_layer = 1;
3077 else if (StrEquals(token, "LOWERTRANSIENT"))
3079 S_SET_DO_LOWER_TRANSIENT(SCF(*ps), on);
3080 S_SET_DO_LOWER_TRANSIENT(SCM(*ps), 1);
3081 S_SET_DO_LOWER_TRANSIENT(SCC(*ps), 1);
3083 else
3085 found = False;
3087 break;
3089 case 'm':
3090 if (StrEquals(token, "ManualPlacement"))
3092 ps->flags.placement_mode = PLACE_MANUAL;
3093 ps->flag_mask.placement_mode = PLACE_MASK;
3094 ps->change_mask.placement_mode = PLACE_MASK;
3096 else if (StrEquals(token, "ManualPlacementHonorsStartsOnPage"))
3098 ps->flags.manual_placement_honors_starts_on_page = on;
3099 ps->flag_mask.manual_placement_honors_starts_on_page =
3101 ps->change_mask.manual_placement_honors_starts_on_page
3102 = 1;
3104 else if (StrEquals(
3105 token, "ManualPlacementIgnoresStartsOnPage"))
3107 ps->flags.manual_placement_honors_starts_on_page = !on;
3108 ps->flag_mask.manual_placement_honors_starts_on_page =
3110 ps->change_mask.manual_placement_honors_starts_on_page
3111 = 1;
3113 else if (StrEquals(token, "Maximizable"))
3115 S_SET_IS_UNMAXIMIZABLE(SCF(*ps), !on);
3116 S_SET_IS_UNMAXIMIZABLE(SCM(*ps), 1);
3117 S_SET_IS_UNMAXIMIZABLE(SCC(*ps), 1);
3119 else if (StrEquals(token, "MinOverlapPlacement"))
3121 ps->flags.placement_mode = PLACE_MINOVERLAP;
3122 ps->flag_mask.placement_mode = PLACE_MASK;
3123 ps->change_mask.placement_mode = PLACE_MASK;
3125 else if (StrEquals(token, "MinOverlapPercentPlacement"))
3127 ps->flags.placement_mode = PLACE_MINOVERLAPPERCENT;
3128 ps->flag_mask.placement_mode = PLACE_MASK;
3129 ps->change_mask.placement_mode = PLACE_MASK;
3131 else if (StrEquals(token, "MinOverlapPlacementPenalties"))
3133 float f[6] = {-1, -1, -1, -1, -1, -1};
3134 Bool bad = False;
3136 num = 0;
3137 if (on != 0 && rest != NULL)
3139 num = sscanf(
3140 rest, "%f %f %f %f %f %f", &f[0],
3141 &f[1], &f[2], &f[3], &f[4], &f[5]);
3142 for (i=0; i < num; i++)
3144 PeekToken(rest,&rest);
3145 if (f[i] < 0)
3147 bad = True;
3151 if (bad)
3153 fvwm_msg(
3154 ERR, "style_parse_one_style_option",
3155 "Bad argument to MinOverlap"
3156 "PlacementPenalties: %s", rest);
3157 break;
3160 pl_penalty_struct *p;
3162 p = SGET_PLACEMENT_PENALTY_PTR(*ps);
3163 *p = default_pl_penalty;
3165 if (num > 0)
3167 (*ps).pl_penalty.normal = f[0];
3169 if (num > 1)
3171 (*ps).pl_penalty.ontop = f[1];
3173 if (num > 2)
3175 (*ps).pl_penalty.icon = f[2];
3177 if (num > 3)
3179 (*ps).pl_penalty.sticky = f[3];
3181 if (num > 4)
3183 (*ps).pl_penalty.below = f[4];
3185 if (num > 5)
3187 (*ps).pl_penalty.strut = f[5];
3189 ps->flags.has_placement_penalty = 1;
3190 ps->flag_mask.has_placement_penalty = 1;
3191 ps->change_mask.has_placement_penalty = 1;
3193 else if (StrEquals(
3194 token, "MinOverlapPercentPlacementPenalties"))
3196 Bool bad = False;
3198 num = 0;
3199 if (on != 0)
3201 num = GetIntegerArguments(rest, &rest, val, 4);
3202 for (i=0; i < num; i++)
3204 if (val[i] < 0)
3205 bad = True;
3208 if (bad)
3210 fvwm_msg(
3211 ERR, "style_parse_one_style_option",
3212 "Bad argument to MinOverlapPercent"
3213 "PlacementPenalties: %s", rest);
3214 break;
3217 pl_percent_penalty_struct *p;
3219 p = SGET_PLACEMENT_PERCENTAGE_PENALTY_PTR(*ps);
3220 *p = default_pl_percent_penalty;
3222 if (num > 0)
3224 (*ps).pl_percent_penalty.p99 = val[0];
3226 if (num > 1)
3228 (*ps).pl_percent_penalty.p95 = val[1];
3230 if (num > 2)
3232 (*ps).pl_percent_penalty.p85 = val[2];
3234 if (num > 3)
3236 (*ps).pl_percent_penalty.p75 = val[3];
3238 ps->flags.has_placement_percentage_penalty = 1;
3239 ps->flag_mask.has_placement_percentage_penalty = 1;
3240 ps->change_mask.has_placement_percentage_penalty = 1;
3242 else if (StrEquals(token, "MwmButtons"))
3244 S_SET_HAS_MWM_BUTTONS(SCF(*ps), on);
3245 S_SET_HAS_MWM_BUTTONS(SCM(*ps), 1);
3246 S_SET_HAS_MWM_BUTTONS(SCC(*ps), 1);
3248 else if (StrEquals(token, "MiniIcon"))
3250 if (!FMiniIconsSupported)
3252 break;
3254 rest = GetNextToken(rest, &token);
3255 if (token)
3257 SAFEFREE(SGET_MINI_ICON_NAME(*ps));
3258 SSET_MINI_ICON_NAME(*ps, token);
3259 ps->flags.has_mini_icon = 1;
3260 ps->flag_mask.has_mini_icon = 1;
3261 ps->change_mask.has_mini_icon = 1;
3263 else
3265 fvwm_msg(
3266 ERR, "style_parse_one_style_option",
3267 "MiniIcon Style requires an Argument");
3270 else if (StrEquals(token, "MwmBorder"))
3272 S_SET_HAS_MWM_BORDER(SCF(*ps), on);
3273 S_SET_HAS_MWM_BORDER(SCM(*ps), 1);
3274 S_SET_HAS_MWM_BORDER(SCC(*ps), 1);
3276 else if (StrEquals(token, "MwmDecor"))
3278 ps->flags.has_mwm_decor = on;
3279 ps->flag_mask.has_mwm_decor = 1;
3280 ps->change_mask.has_mwm_decor = 1;
3282 else if (StrEquals(token, "MwmFunctions"))
3284 ps->flags.has_mwm_functions = on;
3285 ps->flag_mask.has_mwm_functions = 1;
3286 ps->change_mask.has_mwm_functions = 1;
3288 else if (StrEquals(token, "MouseFocus"))
3290 style_set_old_focus_policy(ps, 1);
3292 else if (StrEquals(token, "MouseFocusClickRaises"))
3294 FPS_RAISE_FOCUSED_CLIENT_CLICK(
3295 S_FOCUS_POLICY(SCF(*ps)), on);
3296 FPS_RAISE_FOCUSED_CLIENT_CLICK(
3297 S_FOCUS_POLICY(SCM(*ps)), 1);
3298 FPS_RAISE_FOCUSED_CLIENT_CLICK(
3299 S_FOCUS_POLICY(SCC(*ps)), 1);
3300 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
3301 S_FOCUS_POLICY(SCF(*ps)), on);
3302 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
3303 S_FOCUS_POLICY(SCM(*ps)), 1);
3304 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
3305 S_FOCUS_POLICY(SCC(*ps)), 1);
3307 else if (StrEquals(token, "MouseFocusClickRaisesOff"))
3309 FPS_RAISE_FOCUSED_CLIENT_CLICK(
3310 S_FOCUS_POLICY(SCF(*ps)), !on);
3311 FPS_RAISE_FOCUSED_CLIENT_CLICK(
3312 S_FOCUS_POLICY(SCM(*ps)), 1);
3313 FPS_RAISE_FOCUSED_CLIENT_CLICK(
3314 S_FOCUS_POLICY(SCC(*ps)), 1);
3315 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
3316 S_FOCUS_POLICY(SCF(*ps)), !on);
3317 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
3318 S_FOCUS_POLICY(SCM(*ps)), 1);
3319 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
3320 S_FOCUS_POLICY(SCC(*ps)), 1);
3322 else if (StrEquals(token, "MinWindowSize"))
3324 int val1;
3325 int val2;
3326 int val1_unit;
3327 int val2_unit;
3329 num = GetTwoArguments(
3330 rest, &val1, &val2, &val1_unit, &val2_unit);
3331 rest = SkipNTokens(rest, num);
3332 if (num != 2)
3334 val1 = 0;
3335 val2 = 0;
3337 else
3339 val1 = val1 * val1_unit / 100;
3340 val2 = val2 * val2_unit / 100;
3342 if (val1 < 0)
3344 val1 = 0;
3346 if (val2 < 0)
3348 val2 = 0;
3350 SSET_MIN_WINDOW_WIDTH(*ps, val1);
3351 SSET_MIN_WINDOW_HEIGHT(*ps, val2);
3352 ps->flags.has_min_window_size = 1;
3353 ps->flag_mask.has_min_window_size = 1;
3354 ps->change_mask.has_min_window_size = 1;
3356 else if (StrEquals(token, "MaxWindowSize"))
3358 int val1;
3359 int val2;
3360 int val1_unit;
3361 int val2_unit;
3363 num = GetTwoArguments(
3364 rest, &val1, &val2, &val1_unit, &val2_unit);
3365 rest = SkipNTokens(rest, num);
3366 if (num != 2)
3368 val1 = DEFAULT_MAX_MAX_WINDOW_WIDTH;
3369 val2 = DEFAULT_MAX_MAX_WINDOW_HEIGHT;
3371 else
3373 val1 = val1 * val1_unit / 100;
3374 val2 = val2 * val2_unit / 100;
3376 if (val1 < DEFAULT_MIN_MAX_WINDOW_WIDTH)
3378 val1 = DEFAULT_MIN_MAX_WINDOW_WIDTH;
3380 if (val1 > DEFAULT_MAX_MAX_WINDOW_WIDTH || val1 <= 0)
3382 val1 = DEFAULT_MAX_MAX_WINDOW_WIDTH;
3384 if (val2 < DEFAULT_MIN_MAX_WINDOW_HEIGHT)
3386 val2 = DEFAULT_MIN_MAX_WINDOW_HEIGHT;
3388 if (val2 > DEFAULT_MAX_MAX_WINDOW_HEIGHT || val2 <= 0)
3390 val2 = DEFAULT_MAX_MAX_WINDOW_HEIGHT;
3392 SSET_MAX_WINDOW_WIDTH(*ps, val1);
3393 SSET_MAX_WINDOW_HEIGHT(*ps, val2);
3394 ps->flags.has_max_window_size = 1;
3395 ps->flag_mask.has_max_window_size = 1;
3396 ps->change_mask.has_max_window_size = 1;
3398 else if (StrEquals(token, "MoveByProgramMethod"))
3400 int i;
3401 char *methodlist[] = {
3402 "AutoDetect",
3403 "UseGravity",
3404 "IgnoreGravity",
3405 NULL
3408 i = GetTokenIndex(rest, methodlist, 0, &rest);
3409 if (i == -1)
3411 i = WS_CR_MOTION_METHOD_AUTO;
3413 SCR_MOTION_METHOD(&ps->flags) = i;
3414 SCR_MOTION_METHOD(&ps->flag_mask) =
3415 WS_CR_MOTION_METHOD_MASK;
3416 SCR_MOTION_METHOD(&ps->change_mask) =
3417 WS_CR_MOTION_METHOD_MASK;
3419 else
3421 found = False;
3423 break;
3425 case 'n':
3426 if (StrEquals(token, "NoActiveIconOverride"))
3428 S_SET_ICON_OVERRIDE(SCF(*ps), NO_ACTIVE_ICON_OVERRIDE);
3429 S_SET_ICON_OVERRIDE(SCM(*ps), ICON_OVERRIDE_MASK);
3430 S_SET_ICON_OVERRIDE(SCC(*ps), ICON_OVERRIDE_MASK);
3432 else if (StrEquals(token, "NoIconOverride"))
3434 S_SET_ICON_OVERRIDE(SCF(*ps), NO_ICON_OVERRIDE);
3435 S_SET_ICON_OVERRIDE(SCM(*ps), ICON_OVERRIDE_MASK);
3436 S_SET_ICON_OVERRIDE(SCC(*ps), ICON_OVERRIDE_MASK);
3438 else if (StrEquals(token, "NoIconTitle"))
3440 S_SET_HAS_NO_ICON_TITLE(SCF(*ps), on);
3441 S_SET_HAS_NO_ICON_TITLE(SCM(*ps), 1);
3442 S_SET_HAS_NO_ICON_TITLE(SCC(*ps), 1);
3444 else if (StrEquals(token, "NOICON"))
3446 S_SET_IS_ICON_SUPPRESSED(SCF(*ps), on);
3447 S_SET_IS_ICON_SUPPRESSED(SCM(*ps), 1);
3448 S_SET_IS_ICON_SUPPRESSED(SCC(*ps), 1);
3450 else if (StrEquals(token, "NOTITLE"))
3452 ps->flags.has_no_title = on;
3453 ps->flag_mask.has_no_title = 1;
3454 ps->change_mask.has_no_title = 1;
3456 else if (StrEquals(token, "NoPPosition"))
3458 ps->flags.use_no_pposition = on;
3459 ps->flag_mask.use_no_pposition = 1;
3460 ps->change_mask.use_no_pposition = 1;
3462 else if (StrEquals(token, "NoUSPosition"))
3464 ps->flags.use_no_usposition = on;
3465 ps->flag_mask.use_no_usposition = 1;
3466 ps->change_mask.use_no_usposition = 1;
3468 else if (StrEquals(token, "NoTransientPPosition"))
3470 ps->flags.use_no_transient_pposition = on;
3471 ps->flag_mask.use_no_transient_pposition = 1;
3472 ps->change_mask.use_no_transient_pposition = 1;
3474 else if (StrEquals(token, "NoTransientUSPosition"))
3476 ps->flags.use_no_transient_usposition = on;
3477 ps->flag_mask.use_no_transient_usposition = 1;
3478 ps->change_mask.use_no_transient_usposition = 1;
3480 else if (StrEquals(token, "NoIconPosition"))
3482 S_SET_USE_ICON_POSITION_HINT(SCF(*ps), !on);
3483 S_SET_USE_ICON_POSITION_HINT(SCM(*ps), 1);
3484 S_SET_USE_ICON_POSITION_HINT(SCC(*ps), 1);
3486 else if (StrEquals(token, "NakedTransient"))
3488 ps->flags.do_decorate_transient = !on;
3489 ps->flag_mask.do_decorate_transient = 1;
3490 ps->change_mask.do_decorate_transient = 1;
3492 else if (StrEquals(token, "NODECORHINT"))
3494 ps->flags.has_mwm_decor = !on;
3495 ps->flag_mask.has_mwm_decor = 1;
3496 ps->change_mask.has_mwm_decor = 1;
3498 else if (StrEquals(token, "NOFUNCHINT"))
3500 ps->flags.has_mwm_functions = !on;
3501 ps->flag_mask.has_mwm_functions = 1;
3502 ps->change_mask.has_mwm_functions = 1;
3504 else if (StrEquals(token, "NOOVERRIDE"))
3506 S_SET_HAS_MWM_OVERRIDE(SCF(*ps), !on);
3507 S_SET_HAS_MWM_OVERRIDE(SCM(*ps), 1);
3508 S_SET_HAS_MWM_OVERRIDE(SCC(*ps), 1);
3510 else if (StrEquals(token, "NORESIZEOVERRIDE") ||
3511 StrEquals(token, "NORESIZEHINTOVERRIDE"))
3513 S_SET_HAS_OVERRIDE_SIZE(SCF(*ps), !on);
3514 S_SET_HAS_OVERRIDE_SIZE(SCM(*ps), 1);
3515 S_SET_HAS_OVERRIDE_SIZE(SCC(*ps), 1);
3517 else if (StrEquals(token, "NOHANDLES"))
3519 ps->flags.has_no_handles = on;
3520 ps->flag_mask.has_no_handles = 1;
3521 ps->change_mask.has_no_handles = 1;
3523 else if (StrEquals(token, "NOLENIENCE"))
3525 FPS_LENIENT(S_FOCUS_POLICY(SCF(*ps)), !on);
3526 FPS_LENIENT(S_FOCUS_POLICY(SCM(*ps)), 1);
3527 FPS_LENIENT(S_FOCUS_POLICY(SCC(*ps)), 1);
3529 else if (StrEquals(token, "NoButton"))
3531 rest = style_parse_button_style(ps, rest, !on);
3533 else if (StrEquals(token, "NOOLDECOR"))
3535 ps->flags.has_ol_decor = !on;
3536 ps->flag_mask.has_ol_decor = 1;
3537 ps->change_mask.has_ol_decor = 1;
3539 else if (StrEquals(token, "NeverFocus"))
3541 style_set_old_focus_policy(ps, 3);
3543 else
3545 found = False;
3547 break;
3549 case 'o':
3550 if (StrEquals(token, "OLDECOR"))
3552 ps->flags.has_ol_decor = on;
3553 ps->flag_mask.has_ol_decor = 1;
3554 ps->change_mask.has_ol_decor = 1;
3556 else if (StrEquals(token, "Opacity"))
3558 ps->flags.use_parent_relative = !on;
3559 ps->flag_mask.use_parent_relative = 1;
3560 ps->change_mask.use_parent_relative = 1;
3562 else
3564 found = False;
3566 break;
3568 case 'p':
3569 if (StrEquals(token, "PositionPlacement"))
3571 char *s;
3573 ps->flags.placement_mode = PLACE_POSITION;
3574 ps->flag_mask.placement_mode = PLACE_MASK;
3575 ps->change_mask.placement_mode = PLACE_MASK;
3576 s = (rest != NULL) ? strdup(rest) : NULL;
3577 rest = NULL; /* consume the entire string */
3578 SSET_PLACEMENT_POSITION_STRING(*ps, s);
3579 ps->flags.has_placement_position_string = 1;
3580 ps->flag_mask.has_placement_position_string = 1;
3581 ps->change_mask.has_placement_position_string = 1;
3583 else if (StrEquals(token, "ParentalRelativity"))
3585 ps->flags.use_parent_relative = on;
3586 ps->flag_mask.use_parent_relative = 1;
3587 ps->change_mask.use_parent_relative = 1;
3589 else
3591 found = False;
3593 break;
3595 case 'q':
3596 if (0)
3599 else
3601 found = False;
3603 break;
3605 case 'r':
3606 if (StrEquals(token, "RAISETRANSIENT"))
3608 S_SET_DO_RAISE_TRANSIENT(SCF(*ps), on);
3609 S_SET_DO_RAISE_TRANSIENT(SCM(*ps), 1);
3610 S_SET_DO_RAISE_TRANSIENT(SCC(*ps), 1);
3612 else if (StrEquals(token, "RANDOMPLACEMENT"))
3614 ps->flags.placement_mode |= PLACE_RANDOM;
3615 ps->flag_mask.placement_mode |= PLACE_RANDOM;
3616 ps->change_mask.placement_mode |= PLACE_RANDOM;
3618 else if (StrEquals(token, "RECAPTUREHONORSSTARTSONPAGE"))
3620 ps->flags.recapture_honors_starts_on_page = on;
3621 ps->flag_mask.recapture_honors_starts_on_page = 1;
3622 ps->change_mask.recapture_honors_starts_on_page = 1;
3624 else if (StrEquals(token, "RECAPTUREIGNORESSTARTSONPAGE"))
3626 ps->flags.recapture_honors_starts_on_page = !on;
3627 ps->flag_mask.recapture_honors_starts_on_page = 1;
3628 ps->change_mask.recapture_honors_starts_on_page = 1;
3630 else if (StrEquals(token, "RESIZEHINTOVERRIDE"))
3632 S_SET_HAS_OVERRIDE_SIZE(SCF(*ps), on);
3633 S_SET_HAS_OVERRIDE_SIZE(SCM(*ps), 1);
3634 S_SET_HAS_OVERRIDE_SIZE(SCC(*ps), 1);
3636 else if (StrEquals(token, "ResizeOpaque"))
3638 S_SET_DO_RESIZE_OPAQUE(SCF(*ps), on);
3639 S_SET_DO_RESIZE_OPAQUE(SCM(*ps), 1);
3640 S_SET_DO_RESIZE_OPAQUE(SCC(*ps), 1);
3642 else if (StrEquals(token, "ResizeOutline"))
3644 S_SET_DO_RESIZE_OPAQUE(SCF(*ps), !on);
3645 S_SET_DO_RESIZE_OPAQUE(SCM(*ps), 1);
3646 S_SET_DO_RESIZE_OPAQUE(SCC(*ps), 1);
3648 else if (StrEquals(token, "RightTitleRotatedCW"))
3650 S_SET_IS_RIGHT_TITLE_ROTATED_CW(SCF(*ps), on);
3651 S_SET_IS_RIGHT_TITLE_ROTATED_CW(SCM(*ps), 1);
3652 S_SET_IS_RIGHT_TITLE_ROTATED_CW(SCC(*ps), 1);
3654 else if (StrEquals(token, "RightTitleRotatedCCW"))
3656 S_SET_IS_RIGHT_TITLE_ROTATED_CW(SCF(*ps), !on);
3657 S_SET_IS_RIGHT_TITLE_ROTATED_CW(SCM(*ps), 1);
3658 S_SET_IS_RIGHT_TITLE_ROTATED_CW(SCC(*ps), 1);
3660 else
3662 found = False;
3664 break;
3666 case 's':
3667 if (StrEquals(token, "SMARTPLACEMENT"))
3669 ps->flags.placement_mode |= PLACE_SMART;
3670 ps->flag_mask.placement_mode |= PLACE_SMART;
3671 ps->change_mask.placement_mode |= PLACE_SMART;
3673 else if (StrEquals(token, "SkipMapping"))
3675 S_SET_DO_NOT_SHOW_ON_MAP(SCF(*ps), on);
3676 S_SET_DO_NOT_SHOW_ON_MAP(SCM(*ps), 1);
3677 S_SET_DO_NOT_SHOW_ON_MAP(SCC(*ps), 1);
3679 else if (StrEquals(token, "ShowMapping"))
3681 S_SET_DO_NOT_SHOW_ON_MAP(SCF(*ps), !on);
3682 S_SET_DO_NOT_SHOW_ON_MAP(SCM(*ps), 1);
3683 S_SET_DO_NOT_SHOW_ON_MAP(SCC(*ps), 1);
3685 else if (StrEquals(token, "StackTransientParent"))
3687 S_SET_DO_STACK_TRANSIENT_PARENT(SCF(*ps), on);
3688 S_SET_DO_STACK_TRANSIENT_PARENT(SCM(*ps), 1);
3689 S_SET_DO_STACK_TRANSIENT_PARENT(SCC(*ps), 1);
3691 else if (StrEquals(token, "StickyIcon"))
3693 S_SET_IS_ICON_STICKY_ACROSS_PAGES(SCF(*ps), on);
3694 S_SET_IS_ICON_STICKY_ACROSS_PAGES(SCM(*ps), 1);
3695 S_SET_IS_ICON_STICKY_ACROSS_PAGES(SCC(*ps), 1);
3696 S_SET_IS_ICON_STICKY_ACROSS_DESKS(SCF(*ps), on);
3697 S_SET_IS_ICON_STICKY_ACROSS_DESKS(SCM(*ps), 1);
3698 S_SET_IS_ICON_STICKY_ACROSS_DESKS(SCC(*ps), 1);
3700 else if (StrEquals(token, "StickyAcrossPagesIcon"))
3702 S_SET_IS_ICON_STICKY_ACROSS_PAGES(SCF(*ps), on);
3703 S_SET_IS_ICON_STICKY_ACROSS_PAGES(SCM(*ps), 1);
3704 S_SET_IS_ICON_STICKY_ACROSS_PAGES(SCC(*ps), 1);
3706 else if (StrEquals(token, "StickyAcrossDesksIcon"))
3708 S_SET_IS_ICON_STICKY_ACROSS_DESKS(SCF(*ps), on);
3709 S_SET_IS_ICON_STICKY_ACROSS_DESKS(SCM(*ps), 1);
3710 S_SET_IS_ICON_STICKY_ACROSS_DESKS(SCC(*ps), 1);
3712 else if (StrEquals(token, "SlipperyIcon"))
3714 S_SET_IS_ICON_STICKY_ACROSS_PAGES(SCF(*ps), !on);
3715 S_SET_IS_ICON_STICKY_ACROSS_PAGES(SCM(*ps), 1);
3716 S_SET_IS_ICON_STICKY_ACROSS_PAGES(SCC(*ps), 1);
3717 S_SET_IS_ICON_STICKY_ACROSS_DESKS(SCF(*ps), !on);
3718 S_SET_IS_ICON_STICKY_ACROSS_DESKS(SCM(*ps), 1);
3719 S_SET_IS_ICON_STICKY_ACROSS_DESKS(SCC(*ps), 1);
3721 else if (StrEquals(token, "SloppyFocus"))
3723 style_set_old_focus_policy(ps, 2);
3725 else if (StrEquals(token, "StartIconic"))
3727 ps->flags.do_start_iconic = on;
3728 ps->flag_mask.do_start_iconic = 1;
3729 ps->change_mask.do_start_iconic = 1;
3731 else if (StrEquals(token, "StartNormal"))
3733 ps->flags.do_start_iconic = !on;
3734 ps->flag_mask.do_start_iconic = 1;
3735 ps->change_mask.do_start_iconic = 1;
3737 else if (StrEquals(token, "StaysOnBottom"))
3739 SSET_LAYER(
3740 *ps, (on) ? Scr.BottomLayer : Scr.DefaultLayer);
3741 ps->flags.use_layer = 1;
3742 ps->flag_mask.use_layer = 1;
3743 ps->change_mask.use_layer = 1;
3745 else if (StrEquals(token, "StaysOnTop"))
3747 SSET_LAYER(
3748 *ps, (on) ? Scr.BottomLayer : Scr.DefaultLayer);
3749 SSET_LAYER(*ps, Scr.TopLayer);
3750 ps->flags.use_layer = 1;
3751 ps->flag_mask.use_layer = 1;
3752 ps->change_mask.use_layer = 1;
3754 else if (StrEquals(token, "StaysPut"))
3756 SSET_LAYER(*ps, Scr.DefaultLayer);
3757 ps->flags.use_layer = 1;
3758 ps->flag_mask.use_layer = 1;
3759 ps->change_mask.use_layer = 1;
3761 else if (StrEquals(token, "Sticky"))
3763 S_SET_IS_STICKY_ACROSS_PAGES(SCF(*ps), on);
3764 S_SET_IS_STICKY_ACROSS_PAGES(SCM(*ps), 1);
3765 S_SET_IS_STICKY_ACROSS_PAGES(SCC(*ps), 1);
3766 S_SET_IS_STICKY_ACROSS_DESKS(SCF(*ps), on);
3767 S_SET_IS_STICKY_ACROSS_DESKS(SCM(*ps), 1);
3768 S_SET_IS_STICKY_ACROSS_DESKS(SCC(*ps), 1);
3770 else if (StrEquals(token, "StickyAcrossPages"))
3772 S_SET_IS_STICKY_ACROSS_PAGES(SCF(*ps), on);
3773 S_SET_IS_STICKY_ACROSS_PAGES(SCM(*ps), 1);
3774 S_SET_IS_STICKY_ACROSS_PAGES(SCC(*ps), 1);
3776 else if (StrEquals(token, "StickyAcrossDesks"))
3778 S_SET_IS_STICKY_ACROSS_DESKS(SCF(*ps), on);
3779 S_SET_IS_STICKY_ACROSS_DESKS(SCM(*ps), 1);
3780 S_SET_IS_STICKY_ACROSS_DESKS(SCC(*ps), 1);
3782 else if (StrEquals(token, "StickyStippledTitle"))
3784 S_SET_HAS_NO_STICKY_STIPPLED_TITLE(SCF(*ps), !on);
3785 S_SET_HAS_NO_STICKY_STIPPLED_TITLE(SCM(*ps), 1);
3786 S_SET_HAS_NO_STICKY_STIPPLED_TITLE(SCC(*ps), 1);
3788 else if (StrEquals(token, "StickyStippledIconTitle"))
3790 S_SET_HAS_NO_STICKY_STIPPLED_ICON_TITLE(SCF(*ps), !on);
3791 S_SET_HAS_NO_STICKY_STIPPLED_ICON_TITLE(SCM(*ps), 1);
3792 S_SET_HAS_NO_STICKY_STIPPLED_ICON_TITLE(SCC(*ps), 1);
3794 else if (StrEquals(token, "Slippery"))
3796 S_SET_IS_STICKY_ACROSS_PAGES(SCF(*ps), !on);
3797 S_SET_IS_STICKY_ACROSS_PAGES(SCM(*ps), 1);
3798 S_SET_IS_STICKY_ACROSS_PAGES(SCC(*ps), 1);
3799 S_SET_IS_STICKY_ACROSS_DESKS(SCF(*ps), !on);
3800 S_SET_IS_STICKY_ACROSS_DESKS(SCM(*ps), 1);
3801 S_SET_IS_STICKY_ACROSS_DESKS(SCC(*ps), 1);
3803 else if (StrEquals(token, "STARTSONDESK"))
3805 spargs = GetIntegerArguments(rest, NULL, tmpno, 1);
3806 if (spargs == 1)
3808 PeekToken(rest,&rest);
3809 ps->flags.use_start_on_desk = 1;
3810 ps->flag_mask.use_start_on_desk = 1;
3811 ps->change_mask.use_start_on_desk = 1;
3812 /* RBW - 11/20/1998 - allow for the special
3813 * case of -1 */
3814 SSET_START_DESK(
3815 *ps, (tmpno[0] > -1) ?
3816 tmpno[0] + 1 : tmpno[0]);
3818 else
3820 fvwm_msg(ERR,"style_parse_one_style_option",
3821 "bad StartsOnDesk arg: %s", rest);
3824 /* StartsOnPage is like StartsOnDesk-Plus */
3825 else if (StrEquals(token, "STARTSONPAGE"))
3827 char *ret_rest;
3828 spargs = GetIntegerArguments(rest, &ret_rest,
3829 tmpno, 3);
3830 if (spargs == 1 || spargs == 3)
3832 /* We have a desk no., with or without page. */
3833 /* RBW - 11/20/1998 - allow for the special
3834 * case of -1 */
3835 /* Desk is now actual + 1 */
3836 SSET_START_DESK(
3837 *ps, (tmpno[0] > -1) ?
3838 tmpno[0] + 1 : tmpno[0]);
3840 if (spargs == 2 || spargs == 3)
3842 if (spargs == 3)
3844 /* RBW - 11/20/1998 - allow for the
3845 * special case of -1 */
3846 SSET_START_PAGE_X(
3847 *ps, (tmpno[1] > -1) ?
3848 tmpno[1] + 1 : tmpno[1]);
3849 SSET_START_PAGE_Y(
3850 *ps, (tmpno[2] > -1) ?
3851 tmpno[2] + 1 : tmpno[2]);
3853 else
3855 SSET_START_PAGE_X(
3856 *ps, (tmpno[0] > -1) ?
3857 tmpno[0] + 1 : tmpno[0]);
3858 SSET_START_PAGE_Y(
3859 *ps, (tmpno[1] > -1) ?
3860 tmpno[1] + 1 : tmpno[1]);
3863 if (spargs < 1 || spargs > 3)
3865 fvwm_msg(ERR, "style_parse_one_style_option",
3866 "bad StartsOnPage args: %s", rest);
3868 else
3870 ps->flags.use_start_on_desk = 1;
3871 ps->flag_mask.use_start_on_desk = 1;
3872 ps->change_mask.use_start_on_desk = 1;
3874 rest = ret_rest;
3876 else if (StrEquals(token, "STARTSONPAGEINCLUDESTRANSIENTS"))
3878 ps->flags.use_start_on_page_for_transient = on;
3879 ps->flag_mask.use_start_on_page_for_transient = 1;
3880 ps->change_mask.use_start_on_page_for_transient = 1;
3882 else if (StrEquals(token, "STARTSONPAGEIGNORESTRANSIENTS"))
3884 ps->flags.use_start_on_page_for_transient = !on;
3885 ps->flag_mask.use_start_on_page_for_transient = 1;
3886 ps->change_mask.use_start_on_page_for_transient = 1;
3888 else if (StrEquals(token, "StartsOnScreen"))
3890 if (rest)
3892 tmpno[0] = FScreenGetScreenArgument(rest, 'c');
3893 PeekToken(rest,&rest);
3894 ps->flags.use_start_on_screen = 1;
3895 ps->flag_mask.use_start_on_screen = 1;
3896 ps->change_mask.use_start_on_screen = 1;
3897 SSET_START_SCREEN(*ps, tmpno[0]);
3899 else
3901 ps->flags.use_start_on_screen = 0;
3902 ps->flag_mask.use_start_on_screen = 1;
3903 ps->change_mask.use_start_on_screen = 1;
3906 else if (StrEquals(token, "STARTSANYWHERE"))
3908 ps->flags.use_start_on_desk = 0;
3909 ps->flag_mask.use_start_on_desk = 1;
3910 ps->change_mask.use_start_on_desk = 1;
3912 else if (StrEquals(token, "STARTSLOWERED"))
3914 ps->flags.do_start_lowered = on;
3915 ps->flag_mask.do_start_lowered = 1;
3916 ps->change_mask.do_start_lowered = 1;
3918 else if (StrEquals(token, "STARTSRAISED"))
3920 ps->flags.do_start_lowered = !on;
3921 ps->flag_mask.do_start_lowered = 1;
3922 ps->change_mask.do_start_lowered = 1;
3924 else if (StrEquals(token, "StartShaded"))
3926 token = PeekToken(rest, &rest);
3928 if (token)
3930 direction_t direction;
3932 direction = gravity_parse_dir_argument(
3933 token, &token, DIR_NONE);
3934 if (direction >= 0 && direction <= DIR_MASK)
3936 SSET_STARTS_SHADED_DIR(*ps, direction);
3938 else
3940 fvwm_msg(
3941 ERR,
3942 "style_parse_one_style_option",
3943 "Option: %s is not valid with"
3944 " StartShaded", token);
3947 else
3949 SSET_STARTS_SHADED_DIR(*ps, DIR_N);
3951 ps->flags.do_start_shaded = on;
3952 ps->flag_mask.do_start_shaded = 1;
3953 ps->change_mask.do_start_shaded = 1;
3955 else if (StrEquals(token, "SaveUnder"))
3957 ps->flags.do_save_under = on;
3958 ps->flag_mask.do_save_under = 1;
3959 ps->change_mask.do_save_under = 1;
3961 else if (StrEquals(token, "SaveUnderOff"))
3963 ps->flags.do_save_under = !on;
3964 ps->flag_mask.do_save_under = 1;
3965 ps->change_mask.do_save_under = 1;
3967 else if (StrEquals(token, "StippledTitle"))
3969 S_SET_HAS_STIPPLED_TITLE(SCF(*ps), on);
3970 S_SET_HAS_STIPPLED_TITLE(SCM(*ps), 1);
3971 S_SET_HAS_STIPPLED_TITLE(SCC(*ps), 1);
3973 else if (StrEquals(token, "StippledTitleOff"))
3975 S_SET_HAS_STIPPLED_TITLE(SCF(*ps), !on);
3976 S_SET_HAS_STIPPLED_TITLE(SCM(*ps), 1);
3977 S_SET_HAS_STIPPLED_TITLE(SCC(*ps), 1);
3979 else if (StrEquals(token, "StippledIconTitle"))
3981 S_SET_HAS_STIPPLED_ICON_TITLE(SCF(*ps), on);
3982 S_SET_HAS_STIPPLED_ICON_TITLE(SCM(*ps), 1);
3983 S_SET_HAS_STIPPLED_ICON_TITLE(SCC(*ps), 1);
3985 else if (StrEquals(token, "ScatterWindowGroups"))
3987 S_SET_DO_USE_WINDOW_GROUP_HINT(SCF(*ps), !on);
3988 S_SET_DO_USE_WINDOW_GROUP_HINT(SCM(*ps), 1);
3989 S_SET_DO_USE_WINDOW_GROUP_HINT(SCC(*ps), 1);
3991 else if (StrEquals(token, "State"))
3993 unsigned int mask;
3994 unsigned int states;
3996 spargs = GetIntegerArguments(rest, NULL, tmpno, 1);
3997 if (spargs == 1 && tmpno[0] >= 0 && tmpno[0] <= 31)
3999 PeekToken(rest,&rest);
4000 states = S_USER_STATES(SCF(*ps));
4001 mask = (1 << tmpno[0]);
4002 if (on)
4004 states |= mask;
4006 else
4008 states &= ~mask;
4010 S_SET_USER_STATES(SCF(*ps), states);
4011 S_ADD_USER_STATES(SCM(*ps), mask);
4012 S_ADD_USER_STATES(SCC(*ps), mask);
4014 else
4016 fvwm_msg(
4017 ERR,"style_parse_one_style_option",
4018 "bad State arg: %s", rest);
4021 else if (StrEquals(token, "SnapAttraction"))
4023 int val;
4024 char *token;
4025 int snap_proximity;
4026 int snap_mode;
4030 snap_proximity = DEFAULT_SNAP_ATTRACTION;
4031 snap_mode = DEFAULT_SNAP_ATTRACTION_MODE;
4032 if (
4033 GetIntegerArguments(
4034 rest, &rest, &val, 1) != 1)
4036 break;
4038 if (val >= 0)
4040 snap_proximity = val;
4042 if (val == 0)
4044 break;
4046 token = PeekToken(rest, &rest);
4047 if (token == NULL)
4049 break;
4051 if (StrEquals(token, "All"))
4053 snap_mode = SNAP_ICONS | SNAP_WINDOWS;
4054 token = PeekToken(rest, &rest);
4056 else if (StrEquals(token, "None"))
4058 snap_mode = SNAP_NONE;
4059 token = PeekToken(rest, &rest);
4061 else if (StrEquals(token, "SameType"))
4063 snap_mode = SNAP_SAME;
4064 token = PeekToken(rest, &rest);
4066 else if (StrEquals(token, "Icons"))
4068 snap_mode = SNAP_ICONS;
4069 token = PeekToken(rest, &rest);
4071 else if (StrEquals(token, "Windows"))
4073 snap_mode = SNAP_WINDOWS;
4074 token = PeekToken(rest, &rest);
4076 if (token == NULL)
4078 break;
4080 if (StrEquals(token, "Screen"))
4082 snap_mode |= SNAP_SCREEN;
4084 else if (StrEquals(token, "ScreenWindows"))
4086 snap_mode |= SNAP_SCREEN_WINDOWS;
4088 else if (StrEquals(token, "ScreenIcons"))
4090 snap_mode |= SNAP_SCREEN_ICONS;
4092 else if (StrEquals(token, "ScreenAll"))
4094 snap_mode |= SNAP_SCREEN_ALL;
4096 } while (0);
4097 ps->flags.has_snap_attraction = 1;
4098 ps->flag_mask.has_snap_attraction = 1;
4099 ps->change_mask.has_snap_attraction = 1;
4100 SSET_SNAP_PROXIMITY(*ps, snap_proximity);
4101 SSET_SNAP_MODE(*ps, snap_mode);
4103 else if (StrEquals(token, "SnapGrid"))
4105 int num;
4107 num = GetIntegerArguments(rest, &rest, val, 2);
4108 if (num != 2)
4110 val[0] = DEFAULT_SNAP_GRID_X;
4111 val[1] = DEFAULT_SNAP_GRID_Y;
4113 if (val[0] < 0)
4115 val[0] = DEFAULT_SNAP_GRID_X;
4117 if (val[1] < 0)
4119 val[1] = DEFAULT_SNAP_GRID_Y;
4121 ps->flags.has_snap_grid = 1;
4122 ps->flag_mask.has_snap_grid = 1;
4123 ps->change_mask.has_snap_grid = 1;
4124 SSET_SNAP_GRID_X(*ps, val[0]);
4125 SSET_SNAP_GRID_Y(*ps, val[1]);
4127 else
4129 found = False;
4131 break;
4133 case 't':
4134 if (StrEquals(token, "TileCascadePlacement"))
4136 ps->flags.placement_mode = PLACE_TILECASCADE;
4137 ps->flag_mask.placement_mode = PLACE_MASK;
4138 ps->change_mask.placement_mode = PLACE_MASK;
4140 else if (StrEquals(token, "TileManualPlacement"))
4142 ps->flags.placement_mode = PLACE_TILEMANUAL;
4143 ps->flag_mask.placement_mode = PLACE_MASK;
4144 ps->change_mask.placement_mode = PLACE_MASK;
4146 else if (StrEquals(token, "Title"))
4148 ps->flags.has_no_title = !on;
4149 ps->flag_mask.has_no_title = 1;
4150 ps->change_mask.has_no_title = 1;
4152 else if (StrEquals(token, "TitleAtBottom"))
4154 S_SET_TITLE_DIR(SCF(*ps), DIR_S);
4155 S_SET_TITLE_DIR(SCM(*ps), DIR_MAJOR_MASK);
4156 S_SET_TITLE_DIR(SCC(*ps), DIR_MAJOR_MASK);
4158 else if (StrEquals(token, "TitleAtTop"))
4160 S_SET_TITLE_DIR(SCF(*ps), DIR_N);
4161 S_SET_TITLE_DIR(SCM(*ps), DIR_MAJOR_MASK);
4162 S_SET_TITLE_DIR(SCC(*ps), DIR_MAJOR_MASK);
4164 else if (StrEquals(token, "TitleAtLeft"))
4166 S_SET_TITLE_DIR(SCF(*ps), DIR_W);
4167 S_SET_TITLE_DIR(SCM(*ps), DIR_MAJOR_MASK);
4168 S_SET_TITLE_DIR(SCC(*ps), DIR_MAJOR_MASK);
4170 else if (StrEquals(token, "TitleAtRight"))
4172 S_SET_TITLE_DIR(SCF(*ps), DIR_E);
4173 S_SET_TITLE_DIR(SCM(*ps), DIR_MAJOR_MASK);
4174 S_SET_TITLE_DIR(SCC(*ps), DIR_MAJOR_MASK);
4176 else if (StrEquals(token, "TopTitleRotated"))
4178 S_SET_IS_TOP_TITLE_ROTATED(SCF(*ps), on);
4179 S_SET_IS_TOP_TITLE_ROTATED(SCM(*ps), 1);
4180 S_SET_IS_TOP_TITLE_ROTATED(SCC(*ps), 1);
4182 else if (StrEquals(token, "TopTitleNotRotated"))
4184 S_SET_IS_TOP_TITLE_ROTATED(SCF(*ps), !on);
4185 S_SET_IS_TOP_TITLE_ROTATED(SCM(*ps), 1);
4186 S_SET_IS_TOP_TITLE_ROTATED(SCC(*ps), 1);
4188 else
4190 found = False;
4192 break;
4194 case 'u':
4195 if (StrEquals(token, "UsePPosition"))
4197 ps->flags.use_no_pposition = !on;
4198 ps->flag_mask.use_no_pposition = 1;
4199 ps->change_mask.use_no_pposition = 1;
4201 else if (StrEquals(token, "UseUSPosition"))
4203 ps->flags.use_no_usposition = !on;
4204 ps->flag_mask.use_no_usposition = 1;
4205 ps->change_mask.use_no_usposition = 1;
4207 else if (StrEquals(token, "UseTransientPPosition"))
4209 ps->flags.use_no_transient_pposition = !on;
4210 ps->flag_mask.use_no_transient_pposition = 1;
4211 ps->change_mask.use_no_transient_pposition = 1;
4213 else if (StrEquals(token, "UseTransientUSPosition"))
4215 ps->flags.use_no_transient_usposition = !on;
4216 ps->flag_mask.use_no_transient_usposition = 1;
4217 ps->change_mask.use_no_transient_usposition = 1;
4219 else if (StrEquals(token, "UseIconPosition"))
4221 S_SET_USE_ICON_POSITION_HINT(SCF(*ps), on);
4222 S_SET_USE_ICON_POSITION_HINT(SCM(*ps), 1);
4223 S_SET_USE_ICON_POSITION_HINT(SCC(*ps), 1);
4225 else if (StrEquals(token, "UseTitleDecorRotation"))
4227 S_SET_USE_TITLE_DECOR_ROTATION(SCF(*ps), on);
4228 S_SET_USE_TITLE_DECOR_ROTATION(SCM(*ps), 1);
4229 S_SET_USE_TITLE_DECOR_ROTATION(SCC(*ps), 1);
4231 #ifdef USEDECOR
4232 else if (StrEquals(token, "UseDecor"))
4234 SAFEFREE(SGET_DECOR_NAME(*ps));
4235 rest = GetNextToken(rest, &token);
4236 SSET_DECOR_NAME(*ps, token);
4237 ps->flags.has_decor = (token != NULL);
4238 ps->flag_mask.has_decor = 1;
4239 ps->change_mask.has_decor = 1;
4241 #endif
4242 else if (StrEquals(token, "UseStyle"))
4244 int hit;
4246 token = PeekToken(rest, &rest);
4247 if (!token)
4249 fvwm_msg(ERR, "style_parse_one_style_option",
4250 "UseStyle needs an argument");
4251 break;
4253 hit = 0;
4254 /* changed to accum multiple Style definitions
4255 * (veliaa@rpi.edu) */
4256 for (add_style = all_styles; add_style;
4257 add_style = SGET_NEXT_STYLE(*add_style))
4259 if (SGET_ID_HAS_NAME(*add_style) &&
4260 StrEquals(token, SGET_NAME(*add_style)))
4262 /* match style */
4263 hit = 1;
4264 merge_styles(ps, add_style, True);
4265 } /* end found matching style */
4266 } /* end looking at all styles */
4267 /* move forward one word */
4268 if (!hit)
4270 fvwm_msg(
4271 ERR, "style_parse_one_style_option",
4272 "UseStyle: %s style not found", token);
4275 else if (StrEquals(token, "Unmanaged"))
4277 ps->flags.is_unmanaged = on;
4278 ps->flag_mask.is_unmanaged = 1;
4279 ps->change_mask.is_unmanaged = 1;
4281 else
4283 found = False;
4285 break;
4287 case 'v':
4288 if (StrEquals(token, "VariablePosition") ||
4289 StrEquals(token, "VariableUSPosition"))
4291 S_SET_IS_FIXED(SCF(*ps), !on);
4292 S_SET_IS_FIXED(SCM(*ps), 1);
4293 S_SET_IS_FIXED(SCC(*ps), 1);
4295 else if (StrEquals(token, "VariablePPosition"))
4297 S_SET_IS_FIXED_PPOS(SCF(*ps), !on);
4298 S_SET_IS_FIXED_PPOS(SCM(*ps), 1);
4299 S_SET_IS_FIXED_PPOS(SCC(*ps), 1);
4301 else if (StrEquals(token, "VariableSize") ||
4302 StrEquals(token, "VariableUSSize"))
4304 S_SET_IS_SIZE_FIXED(SCF(*ps), !on);
4305 S_SET_IS_SIZE_FIXED(SCM(*ps), 1);
4306 S_SET_IS_SIZE_FIXED(SCC(*ps), 1);
4308 else if (StrEquals(token, "VariablePSize"))
4310 S_SET_IS_PSIZE_FIXED(SCF(*ps), !on);
4311 S_SET_IS_PSIZE_FIXED(SCM(*ps), 1);
4312 S_SET_IS_PSIZE_FIXED(SCC(*ps), 1);
4314 else
4316 found = False;
4318 break;
4320 case 'w':
4321 if (StrEquals(token, "WindowListSkip"))
4323 S_SET_DO_WINDOW_LIST_SKIP(SCF(*ps), on);
4324 S_SET_DO_WINDOW_LIST_SKIP(SCM(*ps), 1);
4325 S_SET_DO_WINDOW_LIST_SKIP(SCC(*ps), 1);
4327 else if (StrEquals(token, "WindowListHit"))
4329 S_SET_DO_WINDOW_LIST_SKIP(SCF(*ps), !on);
4330 S_SET_DO_WINDOW_LIST_SKIP(SCM(*ps), 1);
4331 S_SET_DO_WINDOW_LIST_SKIP(SCC(*ps), 1);
4333 else if (StrEquals(token, "WindowShadeSteps"))
4335 int n = 0;
4336 int val = 0;
4337 int unit = 0;
4339 n = GetOnePercentArgument(rest, &val, &unit);
4340 if (n != 1)
4342 val = 0;
4344 else
4346 PeekToken(rest,&rest);
4348 /* we have a 'pixel' suffix if unit != 0; negative
4349 * values mean pixels */
4350 val = (unit != 0) ? -val : val;
4351 ps->flags.has_window_shade_steps = 1;
4352 ps->flag_mask.has_window_shade_steps = 1;
4353 ps->change_mask.has_window_shade_steps = 1;
4354 SSET_WINDOW_SHADE_STEPS(*ps, val);
4356 else if (StrEquals(token, "WindowShadeScrolls"))
4358 S_SET_DO_SHRINK_WINDOWSHADE(SCF(*ps), !on);
4359 S_SET_DO_SHRINK_WINDOWSHADE(SCM(*ps), 1);
4360 S_SET_DO_SHRINK_WINDOWSHADE(SCC(*ps), 1);
4362 else if (StrEquals(token, "WindowShadeShrinks"))
4364 S_SET_DO_SHRINK_WINDOWSHADE(SCF(*ps), on);
4365 S_SET_DO_SHRINK_WINDOWSHADE(SCM(*ps), 1);
4366 S_SET_DO_SHRINK_WINDOWSHADE(SCC(*ps), 1);
4368 else if (StrEquals(token, "WindowShadeLazy"))
4370 S_SET_WINDOWSHADE_LAZINESS(SCF(*ps), WINDOWSHADE_LAZY);
4371 S_SET_WINDOWSHADE_LAZINESS(
4372 SCM(*ps), WINDOWSHADE_LAZY_MASK);
4373 S_SET_WINDOWSHADE_LAZINESS(
4374 SCC(*ps), WINDOWSHADE_LAZY_MASK);
4376 else if (StrEquals(token, "WindowShadeAlwaysLazy"))
4378 S_SET_WINDOWSHADE_LAZINESS(
4379 SCF(*ps), WINDOWSHADE_ALWAYS_LAZY);
4380 S_SET_WINDOWSHADE_LAZINESS(
4381 SCM(*ps), WINDOWSHADE_LAZY_MASK);
4382 S_SET_WINDOWSHADE_LAZINESS(
4383 SCC(*ps), WINDOWSHADE_LAZY_MASK);
4385 else if (StrEquals(token, "WindowShadeBusy"))
4387 S_SET_WINDOWSHADE_LAZINESS(SCF(*ps), WINDOWSHADE_BUSY);
4388 S_SET_WINDOWSHADE_LAZINESS(
4389 SCM(*ps), WINDOWSHADE_LAZY_MASK);
4390 S_SET_WINDOWSHADE_LAZINESS(
4391 SCC(*ps), WINDOWSHADE_LAZY_MASK);
4393 else
4395 found = False;
4397 break;
4399 case 'x':
4400 case 'y':
4401 case 'z':
4402 if (0)
4405 else
4407 found = False;
4409 break;
4411 default:
4412 found = False;
4413 break;
4415 if (ret_rest)
4417 *ret_rest = rest;
4419 if (token_l != NULL)
4421 free(token_l);
4424 return found;
4427 static
4428 void parse_and_set_window_style(char *action, char *prefix, window_style *ps)
4430 char *line;
4431 char *option;
4432 char *token;
4433 char *rest;
4434 Bool found;
4435 /* which current boxes to chain to */
4436 icon_boxes *cur_ib = NULL;
4438 while (isspace((unsigned char)*action))
4440 action++;
4442 line = action;
4443 while (action && *action && *action != '\n')
4445 action = GetNextFullOption(action, &option);
4446 if (!option)
4448 break;
4450 token = PeekToken(option, &rest);
4451 if (!token)
4453 free(option);
4454 break;
4457 /* It might make more sense to capture the whole word, fix its
4458 * case, and use strcmp, but there aren't many caseless compares
4459 * because of this "switch" on the first letter. */
4460 found = style_parse_one_style_option(
4461 token, rest, &rest, prefix, ps, &cur_ib);
4463 if (found == False)
4465 fvwm_msg(
4466 ERR, "style_parse_and_set_window_style",
4467 "Bad style option: %s", option);
4468 /* Can't return here since all malloced memory will be
4469 * lost. Ignore rest of line instead. */
4470 /* No, I think we /can/ return here. In fact, /not/
4471 * bombing out leaves a half-done style in the list!
4472 * N.Bird 07-Sep-1999 */
4473 /* domivogt (01-Oct-1999): Which is exactly what we
4474 * want! Why should all the styles be thrown away if a
4475 * single one is mis-spelled? Let's just continue
4476 * parsing styles. */
4478 else if (rest != NULL)
4480 rest = SkipSpaces(rest,NULL,0);
4481 if (*rest)
4483 fvwm_msg(WARN,
4484 "style_parse_and_set_window_style",
4485 "Unconsumed argument in %s: %s",
4486 option, rest);
4489 free(option);
4490 } /* end while still stuff on command */
4492 return;
4495 /* Process a style command. First built up in a temp area.
4496 * If valid, added to the list in a malloced area.
4498 * *** Important note ***
4500 * Remember that *all* styles need a flag, flag_mask and change_mask.
4501 * It is not enough to add the code for new styles in this function.
4502 * There *must* be corresponding code in handle_new_window_style()
4503 * and merge_styles() too. And don't forget that allocated memory
4504 * must be freed in ProcessDestroyStyle().
4507 static void __style_command(F_CMD_ARGS, char *prefix, Bool is_window_style)
4509 /* temp area to build name list */
4510 window_style *ps;
4512 ps = (window_style *)safemalloc(sizeof(window_style));
4513 /* init temp window_style area */
4514 memset(ps, 0, sizeof(window_style));
4515 /* init default focus policy */
4516 fpol_init_default_fp(&S_FOCUS_POLICY(SCF(*ps)));
4517 /* mark style as changed */
4518 ps->has_style_changed = 1;
4519 /* set global flag */
4520 Scr.flags.do_need_window_update = 1;
4521 /* default StartsOnPage behavior for initial capture */
4522 ps->flags.capture_honors_starts_on_page = 1;
4524 if (!is_window_style)
4526 /* parse style name */
4527 action = GetNextToken(action, &SGET_NAME(*ps));
4528 /* in case there was no argument! */
4529 if (SGET_NAME(*ps) == NULL)
4531 free(ps);
4532 return;
4534 SSET_ID_HAS_NAME(*ps, True);
4536 else
4538 SSET_WINDOW_ID(*ps, (XID)FW_W(exc->w.fw));
4539 SSET_ID_HAS_WINDOW_ID(*ps, True);
4540 CopyString(&SGET_NAME(*ps), ""); /* safe */
4543 if (action == NULL)
4545 free(SGET_NAME(*ps));
4546 free(ps);
4547 return;
4550 parse_and_set_window_style(action, prefix, ps);
4552 /* capture default icons */
4553 if (SGET_ID_HAS_NAME(*ps) && StrEquals(SGET_NAME(*ps), "*"))
4555 if (ps->flags.has_icon == 1)
4557 if (Scr.DefaultIcon)
4559 free(Scr.DefaultIcon);
4561 Scr.DefaultIcon = SGET_ICON_NAME(*ps);
4562 ps->flags.has_icon = 0;
4563 ps->flag_mask.has_icon = 0;
4564 ps->change_mask.has_icon = 1;
4565 SSET_ICON_NAME(*ps, NULL);
4568 if (last_style_in_list && styles_have_same_id(ps, last_style_in_list))
4570 /* merge with previous style */
4571 merge_styles(last_style_in_list, ps, True);
4572 free_style(ps);
4573 free(ps);
4575 else
4577 /* add temp name list to list */
4578 add_style_to_list(ps);
4579 cleanup_style_defaults(ps);
4582 return;
4585 /* ---------------------------- interface functions ------------------------ */
4587 /* Compare two flag structures passed as byte arrays. Only compare bits set in
4588 * the mask.
4590 * Returned Value:
4591 * zero if the flags are the same
4592 * non-zero otherwise
4594 * Inputs:
4595 * flags1 - first byte array of flags to compare
4596 * flags2 - second byte array of flags to compare
4597 * mask - byte array of flags to be considered for the comparison
4598 * len - number of bytes to compare */
4599 Bool blockcmpmask(char *blk1, char *blk2, char *mask, int length)
4601 int i;
4603 for (i = 0; i < length; i++)
4605 if ((blk1[i] & mask[i]) != (blk2[i] & mask[i]))
4607 /* flags are not the same, return 1 */
4608 return False;
4611 return True;
4614 void free_icon_boxes(icon_boxes *ib)
4616 icon_boxes *temp;
4618 for ( ; ib != NULL; ib = temp)
4620 temp = ib->next;
4621 if (ib->use_count == 0)
4623 free(ib);
4625 else
4627 /* we can't delete the icon box yet, it is still in use
4629 ib->is_orphan = True;
4633 return;
4636 void simplify_style_list(void)
4638 /* one pass through the style list, then process other events first */
4639 Scr.flags.do_need_style_list_update = __simplify_style_list();
4641 return;
4644 /* lookup_style - look through a list for a window name, or class
4646 * Returned Value:
4647 * merged matching styles in callers window_style.
4649 * Inputs:
4650 * fw - FvwmWindow structure to match against
4651 * styles - callers return area
4653 void lookup_style(FvwmWindow *fw, window_style *styles)
4655 window_style *nptr;
4657 /* clear callers return area */
4658 memset(styles, 0, sizeof(window_style));
4660 /* look thru all styles in order defined. */
4661 for (nptr = all_styles; nptr != NULL; nptr = SGET_NEXT_STYLE(*nptr))
4663 if (fw_match_style_id(fw, SGET_ID(*nptr)))
4665 merge_styles(styles, nptr, False);
4668 if (!DO_IGNORE_GNOME_HINTS(fw))
4670 window_style gnome_style;
4672 /* use GNOME hints if not overridden by user with
4673 * GNOMEIgnoreHitns */
4674 memset(&gnome_style, 0, sizeof(window_style));
4675 GNOME_GetStyle(fw, &gnome_style);
4676 merge_styles(&gnome_style, styles, False);
4677 memcpy(styles, &gnome_style, sizeof(window_style));
4679 EWMH_GetStyle(fw, styles);
4681 return;
4684 /* This function sets the style update flags as necessary */
4685 void check_window_style_change(
4686 FvwmWindow *t, update_win *flags, window_style *ret_style)
4688 int i;
4689 char *wf;
4690 char *sf;
4691 char *sc;
4693 lookup_style(t, ret_style);
4694 if (!ret_style->has_style_changed && !IS_STYLE_DELETED(t))
4696 /* nothing to do */
4697 return;
4700 /* do_ignore_gnome_hints
4702 * must handle these first because they may alter the style */
4703 if (S_DO_IGNORE_GNOME_HINTS(SCC(*ret_style)) &&
4704 !S_DO_IGNORE_GNOME_HINTS(SCF(*ret_style)))
4706 GNOME_GetStyle(t, ret_style);
4707 /* may need further treatment for some styles */
4708 flags->do_update_gnome_styles = 1;
4711 /*** common style flags ***/
4713 wf = (char *)(&FW_COMMON_STATIC_FLAGS(t));
4714 sf = (char *)(&SCFS(*ret_style));
4715 if (IS_STYLE_DELETED(t))
4717 /* update all styles */
4718 memset(flags, 0xff, sizeof(*flags));
4719 SET_STYLE_DELETED(t, 0);
4720 /* copy the static common window flags */
4721 for (i = 0; i < sizeof(SCFS(*ret_style)); i++)
4723 wf[i] = sf[i];
4726 return;
4728 /* All static common styles can simply be copied. For some there is
4729 * additional work to be done below. */
4730 sc = (char *)(&SCCS(*ret_style));
4731 for (i = 0; i < sizeof(SCFS(*ret_style)); i++)
4733 wf[i] = (wf[i] & ~sc[i]) | (sf[i] & sc[i]);
4734 sf[i] = wf[i];
4737 /* is_sticky
4738 * is_icon_sticky */
4739 if (S_IS_STICKY_ACROSS_PAGES(SCC(*ret_style)) ||
4740 S_IS_STICKY_ACROSS_DESKS(SCC(*ret_style)))
4742 flags->do_update_stick = 1;
4744 else if (S_IS_ICON_STICKY_ACROSS_PAGES(SCC(*ret_style)) &&
4745 IS_ICONIFIED(t) && !IS_STICKY_ACROSS_PAGES(t))
4747 flags->do_update_stick_icon = 1;
4749 else if (S_IS_ICON_STICKY_ACROSS_DESKS(SCC(*ret_style)) &&
4750 IS_ICONIFIED(t) && !IS_STICKY_ACROSS_DESKS(t))
4752 flags->do_update_stick_icon = 1;
4755 /* focus policy */
4756 if (fpol_is_policy_changed(&S_FOCUS_POLICY(SCC(*ret_style))))
4758 flags->do_setup_focus_policy = 1;
4761 /* is_left_title_rotated_cw
4762 * is_right_title_rotated_cw
4763 * is_top_title_rotated
4764 * is_bottom_title_rotated */
4765 if (S_IS_LEFT_TITLE_ROTATED_CW(SCC(*ret_style)) ||
4766 S_IS_RIGHT_TITLE_ROTATED_CW(SCC(*ret_style)) ||
4767 S_IS_TOP_TITLE_ROTATED(SCC(*ret_style)) ||
4768 S_IS_BOTTOM_TITLE_ROTATED(SCC(*ret_style)))
4770 flags->do_update_title_text_dir = 1;
4773 /* title_dir */
4774 if (S_TITLE_DIR(SCC(*ret_style)))
4776 flags->do_update_title_dir = 1;
4779 /* use_title_decor_rotation */
4780 if (S_USE_TITLE_DECOR_ROTATION(SCC(*ret_style)))
4782 flags->do_update_rotated_title = 1;
4785 /* has_mwm_border
4786 * has_mwm_buttons */
4787 if (S_HAS_MWM_BORDER(SCC(*ret_style)) ||
4788 S_HAS_MWM_BUTTONS(SCC(*ret_style)))
4790 flags->do_redecorate = 1;
4793 /* has_icon_font */
4794 if (S_HAS_ICON_FONT(SCC(*ret_style)))
4796 flags->do_update_icon_font = 1;
4799 /* has_window_font */
4800 if (S_HAS_WINDOW_FONT(SCC(*ret_style)))
4802 flags->do_update_window_font = 1;
4805 /* has_stippled_title */
4806 if (S_HAS_STIPPLED_TITLE(SCC(*ret_style)) ||
4807 S_HAS_NO_STICKY_STIPPLED_TITLE(SCC(*ret_style)) ||
4808 S_HAS_STIPPLED_ICON_TITLE(SCC(*ret_style)) ||
4809 S_HAS_NO_STICKY_STIPPLED_ICON_TITLE(SCC(*ret_style)))
4811 flags->do_redraw_decoration = 1;
4814 /* has_no_icon_title
4815 * is_icon_suppressed
4817 * handled below */
4819 /*** private style flags ***/
4821 /* nothing to do for these flags (only used when mapping new windows):
4823 * do_place_random
4824 * do_place_smart
4825 * do_start_lowered
4826 * use_no_pposition
4827 * use_no_usposition
4828 * use_no_transient_pposition
4829 * use_no_transient_usposition
4830 * use_start_on_desk
4831 * use_start_on_page_for_transient
4832 * use_start_on_screen
4833 * manual_placement_honors_starts_on_page
4834 * capture_honors_starts_on_page
4835 * recapture_honors_starts_on_page
4836 * ewmh_placement_mode
4839 /* not implemented yet:
4841 * handling the 'usestyle' style
4844 /* do_window_list_skip */
4845 if (S_DO_WINDOW_LIST_SKIP(SCC(*ret_style)))
4847 flags->do_update_modules_flags = 1;
4848 flags->do_update_ewmh_state_hints = 1;
4851 /* has_icon
4852 * icon_override */
4853 if (ret_style->change_mask.has_icon ||
4854 S_ICON_OVERRIDE(SCC(*ret_style)))
4856 flags->do_update_icon_font = 1;
4857 flags->do_update_icon = 1;
4860 /* has_icon_background_padding
4861 * has_icon_background_relief
4862 * has_icon_title_relief */
4863 if (ret_style->change_mask.has_icon_background_padding ||
4864 ret_style->change_mask.has_icon_background_relief ||
4865 ret_style->change_mask.has_icon_title_relief)
4867 flags->do_update_icon = 1;
4870 /* has_no_icon_title
4871 * is_icon_suppressed */
4872 if (S_HAS_NO_ICON_TITLE(SCC(*ret_style)) ||
4873 S_IS_ICON_SUPPRESSED(SCC(*ret_style)))
4875 flags->do_update_icon_font = 1;
4876 flags->do_update_icon_title = 1;
4877 flags->do_update_icon = 1;
4878 flags->do_update_modules_flags = 1;
4881 /* has_icon_size_limits */
4882 if (ret_style->change_mask.has_icon_size_limits)
4884 flags->do_update_icon_size_limits = 1;
4885 flags->do_update_icon = 1;
4888 /* has_icon_boxes */
4889 if (ret_style->change_mask.has_icon_boxes)
4891 flags->do_update_icon_boxes = 1;
4892 flags->do_update_icon = 1;
4895 /* do_ewmh_donate_icon */
4896 if (S_DO_EWMH_DONATE_ICON(SCC(*ret_style)))
4898 flags->do_update_ewmh_icon = 1;
4901 /* has_mini_icon
4902 * do_ewmh_mini_icon_override */
4903 if (
4904 FMiniIconsSupported && (
4905 ret_style->change_mask.has_mini_icon ||
4906 S_DO_EWMH_MINI_ICON_OVERRIDE(SCC(*ret_style))))
4908 flags->do_update_mini_icon = 1;
4909 flags->do_update_ewmh_mini_icon = 1;
4910 flags->do_redecorate = 1;
4913 /* do_ewmh_donate_mini_icon */
4914 if (FMiniIconsSupported && S_DO_EWMH_DONATE_MINI_ICON(SCC(*ret_style)))
4916 flags->do_update_ewmh_mini_icon = 1;
4919 /* has_min_window_size */
4920 /* has_max_window_size */
4921 if (ret_style->change_mask.has_min_window_size)
4923 flags->do_resize_window = 1;
4924 flags->do_update_ewmh_allowed_actions = 1;
4925 flags->do_update_modules_flags = 1;
4927 if (ret_style->change_mask.has_max_window_size)
4929 flags->do_resize_window = 1;
4930 flags->do_update_ewmh_allowed_actions = 1;
4931 flags->do_update_modules_flags = 1;
4934 /* has_color_back
4935 * has_color_fore
4936 * use_colorset
4937 * use_border_colorset */
4938 if (ret_style->change_mask.has_color_fore ||
4939 ret_style->change_mask.has_color_back ||
4940 ret_style->change_mask.use_colorset ||
4941 ret_style->change_mask.use_border_colorset)
4943 flags->do_update_window_color = 1;
4945 /* has_color_back_hi
4946 * has_color_fore_hi
4947 * use_colorset_hi
4948 * use_border_colorset_hi */
4949 if (ret_style->change_mask.has_color_fore_hi ||
4950 ret_style->change_mask.has_color_back_hi ||
4951 ret_style->change_mask.use_colorset_hi ||
4952 ret_style->change_mask.use_border_colorset_hi)
4954 flags->do_update_window_color_hi = 1;
4957 /* use_icon_title_colorset */
4958 if (ret_style->change_mask.use_icon_title_colorset)
4960 flags->do_update_icon_title_cs = 1;
4963 /* use_icon_title_colorset_hi */
4964 if (ret_style->change_mask.use_icon_title_colorset_hi)
4966 flags->do_update_icon_title_cs_hi = 1;
4969 /* use_icon_title_colorset */
4970 if (ret_style->change_mask.use_icon_title_colorset)
4972 flags->do_update_icon_title_cs = 1;
4975 /* use_icon_background_colorset */
4976 if (ret_style->change_mask.use_icon_background_colorset)
4978 flags->do_update_icon_background_cs = 1;
4981 /* has_decor */
4982 if (ret_style->change_mask.has_decor)
4984 flags->do_redecorate = 1;
4985 flags->do_update_window_font_height = 1;
4988 /* has_no_title */
4989 if (ret_style->change_mask.has_no_title)
4991 flags->do_redecorate = 1;
4992 flags->do_update_window_font = 1;
4995 /* do_decorate_transient */
4996 if (ret_style->change_mask.do_decorate_transient)
4998 flags->do_redecorate_transient = 1;
5001 /* has_ol_decor */
5002 if (ret_style->change_mask.has_ol_decor)
5004 /* old decor overrides 'has_no_icon_title'! */
5005 flags->do_update_icon_font = 1;
5006 flags->do_update_icon_title = 1;
5007 flags->do_update_icon = 1;
5008 flags->do_redecorate = 1;
5011 /* Changing layer. */
5012 if (ret_style->change_mask.use_layer)
5014 flags->do_update_layer = 1;
5017 /* has_no_border
5018 * has_border_width
5019 * has_handle_width
5020 * has_mwm_decor
5021 * has_mwm_functions
5022 * has_no_handles
5023 * is_button_disabled */
5024 if (S_HAS_NO_BORDER(SCC(*ret_style)) ||
5025 ret_style->change_mask.has_border_width ||
5026 ret_style->change_mask.has_handle_width ||
5027 ret_style->change_mask.has_mwm_decor ||
5028 ret_style->change_mask.has_mwm_functions ||
5029 ret_style->change_mask.has_no_handles ||
5030 ret_style->change_mask.is_button_disabled)
5032 flags->do_redecorate = 1;
5033 flags->do_update_ewmh_allowed_actions = 1;
5034 flags->do_update_modules_flags = 1;
5037 if (ret_style->change_mask.do_save_under ||
5038 ret_style->change_mask.use_backing_store ||
5039 ret_style->change_mask.use_parent_relative)
5041 flags->do_update_frame_attributes = 1;
5044 if (ret_style->change_mask.use_parent_relative &&
5045 ret_style->flags.use_parent_relative)
5047 /* needed only for Opacity -> ParentalRelativity */
5048 flags->do_refresh = 1;
5051 /* has_placement_penalty
5052 * has_placement_percentage_penalty */
5053 if (ret_style->change_mask.has_placement_penalty ||
5054 ret_style->change_mask.has_placement_percentage_penalty)
5056 flags->do_update_placement_penalty = 1;
5059 /* do_ewmh_ignore_strut_hints */
5060 if (S_DO_EWMH_IGNORE_STRUT_HINTS(SCC(*ret_style)))
5062 flags->do_update_working_area = 1;
5065 /* do_ewmh_ignore_state_hints */
5066 if (S_DO_EWMH_IGNORE_STATE_HINTS(SCC(*ret_style)))
5068 flags->do_update_ewmh_state_hints = 1;
5069 flags->do_update_modules_flags = 1;
5072 /* do_ewmh_use_staking_hints */
5073 if (S_DO_EWMH_USE_STACKING_HINTS(SCC(*ret_style)))
5075 flags->do_update_ewmh_stacking_hints = 1;
5078 /* use_indexed_window_name */
5079 if (S_USE_INDEXED_WINDOW_NAME(SCC(*ret_style)))
5081 flags->do_update_visible_window_name = 1;
5082 flags->do_redecorate = 1;
5085 /* use_indexed_icon_name */
5086 if (S_USE_INDEXED_ICON_NAME(SCC(*ret_style)))
5088 flags->do_update_visible_icon_name = 1;
5089 flags->do_update_icon_title = 1;
5092 /* is_fixed */
5093 if (S_IS_FIXED(SCC(*ret_style)) ||
5094 S_IS_FIXED_PPOS(SCC(*ret_style)) ||
5095 S_IS_SIZE_FIXED(SCC(*ret_style)) ||
5096 S_IS_PSIZE_FIXED(SCC(*ret_style)) ||
5097 S_HAS_OVERRIDE_SIZE(SCC(*ret_style)))
5099 flags->do_update_ewmh_allowed_actions = 1;
5100 flags->do_update_modules_flags = 1;
5103 /* cr_motion_method */
5104 if (SCR_MOTION_METHOD(&ret_style->change_mask))
5106 flags->do_update_cr_motion_method = 1;
5109 return;
5112 /* Mark all styles as unchanged. */
5113 void reset_style_changes(void)
5115 window_style *temp;
5117 for (temp = all_styles; temp != NULL; temp = SGET_NEXT_STYLE(*temp))
5119 temp->has_style_changed = 0;
5120 memset(&SCCS(*temp), 0, sizeof(SCCS(*temp)));
5121 memset(&(temp->change_mask), 0, sizeof(temp->change_mask));
5124 return;
5127 /* Mark styles as updated if their colorset changed. */
5128 void update_style_colorset(int colorset)
5130 window_style *temp;
5132 for (temp = all_styles; temp != NULL; temp = SGET_NEXT_STYLE(*temp))
5134 if (SUSE_COLORSET(&temp->flags) &&
5135 SGET_COLORSET(*temp) == colorset)
5137 temp->has_style_changed = 1;
5138 temp->change_mask.use_colorset = 1;
5139 Scr.flags.do_need_window_update = 1;
5141 if (SUSE_COLORSET_HI(&temp->flags) &&
5142 SGET_COLORSET_HI(*temp) == colorset)
5144 temp->has_style_changed = 1;
5145 temp->change_mask.use_colorset_hi = 1;
5146 Scr.flags.do_need_window_update = 1;
5148 if (SUSE_BORDER_COLORSET(&temp->flags) &&
5149 SGET_BORDER_COLORSET(*temp) == colorset)
5151 temp->has_style_changed = 1;
5152 temp->change_mask.use_border_colorset = 1;
5153 Scr.flags.do_need_window_update = 1;
5155 if (SUSE_BORDER_COLORSET_HI(&temp->flags) &&
5156 SGET_BORDER_COLORSET_HI(*temp) == colorset)
5158 temp->has_style_changed = 1;
5159 temp->change_mask.use_border_colorset_hi = 1;
5160 Scr.flags.do_need_window_update = 1;
5162 if (SUSE_ICON_TITLE_COLORSET(&temp->flags) &&
5163 SGET_ICON_TITLE_COLORSET(*temp) == colorset)
5165 temp->has_style_changed = 1;
5166 temp->change_mask.use_icon_title_colorset = 1;
5167 Scr.flags.do_need_window_update = 1;
5169 if (SUSE_ICON_TITLE_COLORSET_HI(&temp->flags) &&
5170 SGET_ICON_TITLE_COLORSET_HI(*temp) == colorset)
5172 temp->has_style_changed = 1;
5173 temp->change_mask.use_icon_title_colorset_hi = 1;
5174 Scr.flags.do_need_window_update = 1;
5176 if (SUSE_ICON_BACKGROUND_COLORSET(&temp->flags) &&
5177 SGET_ICON_BACKGROUND_COLORSET(*temp) == colorset)
5179 temp->has_style_changed = 1;
5180 temp->change_mask.use_icon_background_colorset = 1;
5181 Scr.flags.do_need_window_update = 1;
5185 return;
5188 /* Update fore and back colours for a specific window */
5189 void update_window_color_style(FvwmWindow *fw, window_style *pstyle)
5191 int cs = Scr.DefaultColorset;
5193 if (SUSE_COLORSET(&pstyle->flags))
5195 cs = SGET_COLORSET(*pstyle);
5196 fw->cs = cs;
5198 else
5200 fw->cs = -1;
5202 if (SGET_FORE_COLOR_NAME(*pstyle) != NULL &&
5203 !SUSE_COLORSET(&pstyle->flags))
5205 fw->colors.fore = GetColor(SGET_FORE_COLOR_NAME(*pstyle));
5207 else
5209 fw->colors.fore = Colorset[cs].fg;
5211 if (SGET_BACK_COLOR_NAME(*pstyle) != NULL &&
5212 !SUSE_COLORSET(&pstyle->flags))
5214 fw->colors.back = GetColor(SGET_BACK_COLOR_NAME(*pstyle));
5215 fw->colors.shadow = GetShadow(fw->colors.back);
5216 fw->colors.hilight = GetHilite(fw->colors.back);
5218 else
5220 fw->colors.hilight = Colorset[cs].hilite;
5221 fw->colors.shadow = Colorset[cs].shadow;
5222 fw->colors.back = Colorset[cs].bg;
5224 if (SUSE_BORDER_COLORSET(&pstyle->flags))
5226 cs = SGET_BORDER_COLORSET(*pstyle);
5227 fw->border_cs = cs;
5228 fw->border_colors.hilight = Colorset[cs].hilite;
5229 fw->border_colors.shadow = Colorset[cs].shadow;
5230 fw->border_colors.back = Colorset[cs].bg;
5232 else
5234 fw->border_cs = -1;
5235 fw->border_colors.hilight = fw->colors.hilight;
5236 fw->border_colors.shadow = fw->colors.shadow;
5237 fw->border_colors.back = fw->colors.back;
5241 void update_window_color_hi_style(FvwmWindow *fw, window_style *pstyle)
5243 int cs = Scr.DefaultColorset;
5245 if (SUSE_COLORSET_HI(&pstyle->flags))
5247 cs = SGET_COLORSET_HI(*pstyle);
5248 fw->cs_hi = cs;
5250 else
5252 fw->cs_hi = -1;
5254 if (
5255 SGET_FORE_COLOR_NAME_HI(*pstyle) != NULL &&
5256 !SUSE_COLORSET_HI(&pstyle->flags))
5258 fw->hicolors.fore = GetColor(SGET_FORE_COLOR_NAME_HI(*pstyle));
5260 else
5262 fw->hicolors.fore = Colorset[cs].fg;
5264 if (
5265 SGET_BACK_COLOR_NAME_HI(*pstyle) != NULL &&
5266 !SUSE_COLORSET_HI(&pstyle->flags))
5268 fw->hicolors.back = GetColor(SGET_BACK_COLOR_NAME_HI(*pstyle));
5269 fw->hicolors.shadow = GetShadow(fw->hicolors.back);
5270 fw->hicolors.hilight = GetHilite(fw->hicolors.back);
5272 else
5274 fw->hicolors.hilight = Colorset[cs].hilite;
5275 fw->hicolors.shadow = Colorset[cs].shadow;
5276 fw->hicolors.back = Colorset[cs].bg;
5278 if (SUSE_BORDER_COLORSET_HI(&pstyle->flags))
5280 cs = SGET_BORDER_COLORSET_HI(*pstyle);
5281 fw->border_cs_hi = cs;
5282 fw->border_hicolors.hilight = Colorset[cs].hilite;
5283 fw->border_hicolors.shadow = Colorset[cs].shadow;
5284 fw->border_hicolors.back = Colorset[cs].bg;
5286 else
5288 fw->border_cs_hi = -1;
5289 fw->border_hicolors.hilight = fw->hicolors.hilight;
5290 fw->border_hicolors.shadow = fw->hicolors.shadow;
5291 fw->border_hicolors.back = fw->hicolors.back;
5295 void update_icon_title_cs_style(FvwmWindow *fw, window_style *pstyle)
5297 if (SUSE_ICON_TITLE_COLORSET(&pstyle->flags))
5299 fw->icon_title_cs = SGET_ICON_TITLE_COLORSET(*pstyle);
5301 else
5303 fw->icon_title_cs = -1;
5307 void update_icon_title_cs_hi_style(FvwmWindow *fw, window_style *pstyle)
5309 if (SUSE_ICON_TITLE_COLORSET_HI(&pstyle->flags))
5311 fw->icon_title_cs_hi = SGET_ICON_TITLE_COLORSET_HI(*pstyle);
5313 else
5315 fw->icon_title_cs_hi = -1;
5319 void update_icon_background_cs_style(FvwmWindow *fw, window_style *pstyle)
5321 if (SUSE_ICON_BACKGROUND_COLORSET(&pstyle->flags))
5323 fw->icon_background_cs =
5324 SGET_ICON_BACKGROUND_COLORSET(*pstyle);
5326 else
5328 fw->icon_background_cs = -1;
5332 void style_destroy_style(style_id_t s_id)
5334 FvwmWindow *t;
5336 if (remove_all_of_style_from_list(s_id))
5338 /* compact the current list of styles */
5339 Scr.flags.do_need_style_list_update = 1;
5341 else
5343 return;
5345 /* mark windows for update */
5346 for (t = Scr.FvwmRoot.next; t != NULL; t = t->next)
5348 if (fw_match_style_id(t, s_id))
5350 SET_STYLE_DELETED(t, 1);
5351 Scr.flags.do_need_window_update = 1;
5355 return;
5358 void print_styles(int verbose)
5360 window_style *nptr;
5361 int count = 0;
5362 int mem = 0;
5364 fprintf(stderr,"Info on fvwm Styles:\n");
5365 if (verbose)
5367 fprintf(stderr," List of Styles Names:\n");
5369 for (nptr = all_styles; nptr != NULL; nptr = SGET_NEXT_STYLE(*nptr))
5371 count++;
5372 if (SGET_ID_HAS_NAME(*nptr))
5374 mem += strlen(SGET_NAME(*nptr));
5375 if (verbose)
5377 fprintf(stderr," * %s\n", SGET_NAME(*nptr));
5380 else
5382 mem++;
5383 if (verbose)
5385 fprintf(stderr," * 0x%lx\n",
5386 (unsigned long)SGET_WINDOW_ID(*nptr));
5389 if (SGET_BACK_COLOR_NAME(*nptr))
5391 mem += strlen(SGET_BACK_COLOR_NAME(*nptr));
5392 if (verbose > 1)
5394 fprintf(
5395 stderr," Back Color: %s\n",
5396 SGET_BACK_COLOR_NAME(*nptr));
5399 if (SGET_FORE_COLOR_NAME(*nptr))
5401 mem += strlen(SGET_FORE_COLOR_NAME(*nptr));
5402 if (verbose > 1)
5404 fprintf(
5405 stderr," Fore Color: %s\n",
5406 SGET_FORE_COLOR_NAME(*nptr));
5409 if (SGET_BACK_COLOR_NAME_HI(*nptr))
5411 mem += strlen(SGET_BACK_COLOR_NAME_HI(*nptr));
5412 if (verbose > 1)
5414 fprintf(
5415 stderr," Back Color hi: %s\n",
5416 SGET_BACK_COLOR_NAME_HI(*nptr));
5419 if (SGET_FORE_COLOR_NAME_HI(*nptr))
5421 mem += strlen(SGET_FORE_COLOR_NAME_HI(*nptr));
5422 if (verbose > 1)
5424 fprintf(
5425 stderr," Fore Color hi: %s\n",
5426 SGET_FORE_COLOR_NAME_HI(*nptr));
5429 if (SGET_DECOR_NAME(*nptr))
5431 mem += strlen(SGET_DECOR_NAME(*nptr));
5432 if (verbose > 1)
5434 fprintf(
5435 stderr," Decor: %s\n",
5436 SGET_DECOR_NAME(*nptr));
5439 if (SGET_WINDOW_FONT(*nptr))
5441 mem += strlen(SGET_WINDOW_FONT(*nptr));
5442 if (verbose > 1)
5444 fprintf(
5445 stderr," Window Font: %s\n",
5446 SGET_WINDOW_FONT(*nptr));
5449 if (SGET_ICON_FONT(*nptr))
5451 mem += strlen(SGET_ICON_FONT(*nptr));
5452 if (verbose > 1)
5454 fprintf(
5455 stderr," Icon Font: %s\n",
5456 SGET_ICON_FONT(*nptr));
5459 if (SGET_ICON_NAME(*nptr))
5461 mem += strlen(SGET_ICON_NAME(*nptr));
5462 if (verbose > 1)
5464 fprintf(
5465 stderr," Icon Name: %s\n",
5466 SGET_ICON_NAME(*nptr));
5469 if (SGET_MINI_ICON_NAME(*nptr))
5471 mem += strlen(SGET_MINI_ICON_NAME(*nptr));
5472 if (verbose > 1)
5474 fprintf(
5475 stderr," MiniIcon Name: %s\n",
5476 SGET_MINI_ICON_NAME(*nptr));
5479 if (SGET_ICON_BOXES(*nptr))
5481 mem += sizeof(icon_boxes);
5484 fprintf(stderr," Number of styles: %d, Memory Used: %d bits\n",
5485 count, (int)(count*sizeof(window_style) + mem));
5487 return;
5490 /* ---------------------------- builtin commands --------------------------- */
5492 void CMD_Style(F_CMD_ARGS)
5494 __style_command(F_PASS_ARGS, NULL, False);
5496 return;
5499 void CMD_WindowStyle(F_CMD_ARGS)
5501 __style_command(F_PASS_ARGS, NULL, True);
5503 return;
5506 void CMD_FocusStyle(F_CMD_ARGS)
5508 __style_command(F_PASS_ARGS, "FP", False);
5510 return;
5513 void CMD_DestroyStyle(F_CMD_ARGS)
5515 char *name;
5516 style_id_t s_id;
5518 /* parse style name */
5519 name = PeekToken(action, &action);
5521 /* in case there was no argument! */
5522 if (name == NULL)
5523 return;
5525 memset(&s_id, 0, sizeof(style_id_t));
5526 SID_SET_NAME(s_id, name);
5527 SID_SET_HAS_NAME(s_id, True);
5529 /* Do it */
5530 style_destroy_style(s_id);
5531 return;
5534 void CMD_DestroyWindowStyle(F_CMD_ARGS)
5536 style_id_t s_id;
5538 memset(&s_id, 0, sizeof(style_id_t));
5539 SID_SET_WINDOW_ID(s_id, (XID)FW_W(exc->w.fw));
5540 SID_SET_HAS_WINDOW_ID(s_id, True);
5542 /* Do it */
5543 style_destroy_style(s_id);
5544 return;