1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
|
/*
* Parser backend routines.
*
* Roughly, these are the routines that the lex/yacc output calls to do
* its work.
*
* This is very similar to the meaning of parse_yacc.c; the two may be
* merged at some point.
*/
#include "ctwm.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <X11/Xatom.h>
#include "ctwm_atoms.h"
#include "screen.h"
#include "util.h"
#include "animate.h"
#include "functions_defs.h"
#include "image.h"
#include "list.h"
#include "occupation.h"
#include "parse.h"
#include "parse_be.h"
#include "parse_yacc.h"
#include "r_area.h"
#include "r_area_list.h"
#include "r_layout.h"
#ifdef SOUNDS
# include "sound.h"
#endif
#include "gram.tab.h"
static int ParseRandomPlacement(const char *s);
static int ParseButtonStyle(const char *s);
static int ParseUsePPosition(const char *s);
static int ParseIconifyStyle(const char *s);
/**********************************************************************
*
* Parsing table and routines
*
***********************************************************************/
typedef struct _TwmKeyword {
const char *name;
int value;
int subnum;
} TwmKeyword;
#define kw0_NoDefaults 1
#define kw0_AutoRelativeResize 2
#define kw0_ForceIcons 3
#define kw0_NoIconManagers 4
#define kw0_InterpolateMenuColors 6
//#define kw0_NoVersion 7
#define kw0_SortIconManager 8
#define kw0_NoGrabServer 9
#define kw0_NoMenuShadows 10
#define kw0_NoRaiseOnMove 11
#define kw0_NoRaiseOnResize 12
#define kw0_NoRaiseOnDeiconify 13
#define kw0_DontMoveOff 14
#define kw0_NoBackingStore 15
#define kw0_NoSaveUnders 16
#define kw0_RestartPreviousState 17
#define kw0_ClientBorderWidth 18
#define kw0_NoTitleFocus 19
#define kw0_DecorateTransients 21
#define kw0_ShowIconManager 22
#define kw0_NoCaseSensitive 23
#define kw0_NoRaiseOnWarp 24
#define kw0_WarpUnmapped 25
#define kw0_ShowWorkspaceManager 27
#define kw0_StartInMapState 28
#define kw0_NoShowOccupyAll 29
#define kw0_AutoOccupy 30
#define kw0_TransientHasOccupation 31
#define kw0_DontPaintRootWindow 32
#define kw0_Use3DMenus 33
#define kw0_Use3DTitles 34
#define kw0_Use3DIconManagers 35
#define kw0_Use3DBorders 36
#define kw0_SunkFocusWindowTitle 37
#define kw0_BeNiceToColormap 38
#define kw0_WarpRingOnScreen 40
#define kw0_NoIconManagerFocus 41
#define kw0_StayUpMenus 42
#define kw0_ClickToFocus 43
#define kw0_BorderResizeCursors 44
#define kw0_ReallyMoveInWorkspaceManager 45
#define kw0_ShowWinWhenMovingInWmgr 46
#define kw0_Use3DWMap 47
#define kw0_ReverseCurrentWorkspace 48
#define kw0_DontWarpCursorInWMap 49
#define kw0_CenterFeedbackWindow 50
#define kw0_WarpToDefaultMenuEntry 51
#define kw0_ShrinkIconTitles 52
#define kw0_AutoRaiseIcons 53
//#define kw0_use3DIconBorders 54
#define kw0_UseSunkTitlePixmap 55
#define kw0_ShortAllWindowsMenus 56
#define kw0_RaiseWhenAutoUnSqueeze 57
#define kw0_RaiseOnClick 58
#define kw0_IgnoreLockModifier 59
#define kw0_AutoFocusToTransients 60 /* kai */
#define kw0_PackNewWindows 61
#define kw0_IgnoreCaseInMenuSelection 62
#define kw0_SloppyFocus 63
#define kw0_NoImagesInWorkSpaceManager 64
#define kw0_NoWarpToMenuTitle 65
#define kw0_SaveWorkspaceFocus 66 /* blais */
#define kw0_RaiseOnWarp 67
#define kw0_DontShowWelcomeWindow 68
#define kw0_AutoPriority 69
#define kw0_DontToggleWorkspacemanagerState 70
#define kw0_BackingStore 71
#define kw0_StartInButtonState 72
#define kw0_NoSortIconManager 73
#define kw0_NoRestartPreviousState 74
#define kw0_NoDecorateTransients 75
#define kw0_GrabServer 76
#define kw0_DontNameDecorations 77
#define kw0_StrictWinNameEncoding 78
#define kws_UsePPosition 1
#define kws_IconFont 2
#define kws_ResizeFont 3
#define kws_MenuFont 4
#define kws_TitleFont 5
#define kws_IconManagerFont 6
#define kws_UnknownIcon 7
#define kws_IconDirectory 8
#define kws_MaxWindowSize 9
#define kws_PixmapDirectory 10
/* RandomPlacement moved because it's now a string string keyword */
#define kws_IconJustification 12
#define kws_TitleJustification 13
#define kws_IconRegionJustification 14
#define kws_IconRegionAlignement 15
#define kws_SoundHost 16
#define kws_WMgrButtonStyle 17
#define kws_WorkSpaceFont 18
#define kws_IconifyStyle 19
#define kws_IconSize 20
#define kws_RplaySoundHost 21
#define kwss_RandomPlacement 1
#define kwn_ConstrainedMoveTime 1
#define kwn_MoveDelta 2
#define kwn_XorValue 3
#define kwn_FramePadding 4
#define kwn_TitlePadding 5
#define kwn_ButtonIndent 6
#define kwn_BorderWidth 7
#define kwn_IconBorderWidth 8
#define kwn_TitleButtonBorderWidth 9
#define kwn_RaiseDelay 10
#define kwn_TransientOnTop 11
#define kwn_OpaqueMoveThreshold 12
#define kwn_OpaqueResizeThreshold 13
#define kwn_WMgrVertButtonIndent 14
#define kwn_WMgrHorizButtonIndent 15
#define kwn_ClearShadowContrast 16
#define kwn_DarkShadowContrast 17
#define kwn_WMgrButtonShadowDepth 18
#define kwn_MaxIconTitleWidth 19
#define kwn_AnimationSpeed 20
#define kwn_ThreeDBorderWidth 21
#define kwn_MoveOffResistance 22
#define kwn_BorderShadowDepth 23
#define kwn_TitleShadowDepth 24
#define kwn_TitleButtonShadowDepth 25
#define kwn_MenuShadowDepth 26
#define kwn_IconManagerShadowDepth 27
#define kwn_MovePackResistance 28
#define kwn_XMoveGrid 29
#define kwn_YMoveGrid 30
#define kwn_OpenWindowTimeout 31
#define kwn_RaiseOnClickButton 32
#define kwn_BorderTop 33
#define kwn_BorderBottom 34
#define kwn_BorderLeft 35
#define kwn_BorderRight 36
#define kwcl_BorderColor 1
#define kwcl_IconManagerHighlight 2
#define kwcl_BorderTileForeground 3
#define kwcl_BorderTileBackground 4
#define kwcl_TitleForeground 5
#define kwcl_TitleBackground 6
#define kwcl_IconForeground 7
#define kwcl_IconBackground 8
#define kwcl_IconBorderColor 9
#define kwcl_IconManagerForeground 10
#define kwcl_IconManagerBackground 11
#define kwcl_MapWindowBackground 12
#define kwcl_MapWindowForeground 13
#define kwc_DefaultForeground 1
#define kwc_DefaultBackground 2
#define kwc_MenuForeground 3
#define kwc_MenuBackground 4
#define kwc_MenuTitleForeground 5
#define kwc_MenuTitleBackground 6
#define kwc_MenuShadowColor 7
/*
* The following is sorted alphabetically according to name (which must be
* in lowercase and only contain the letters a-z). It is fed to a binary
* search to parse keywords.
*/
static const TwmKeyword keytable[] = {
{ "a", ALTER, 0 },
{ "all", ALL, 0 },
{ "alter", ALTER, 0 },
{ "alwaysontop", ALWAYS_ON_TOP, 0 },
{ "alwaysshowwindowwhenmovingfromworkspacemanager", KEYWORD, kw0_ShowWinWhenMovingInWmgr },
{ "alwayssqueezetogravity", ALWAYSSQUEEZETOGRAVITY, 0 },
{ "animationspeed", NKEYWORD, kwn_AnimationSpeed },
{ "autofocustotransients", KEYWORD, kw0_AutoFocusToTransients }, /* kai */
{ "autolower", AUTO_LOWER, 0 },
{ "autooccupy", KEYWORD, kw0_AutoOccupy },
{ "autopopup", AUTO_POPUP, 0 },
{ "autopriority", KEYWORD, kw0_AutoPriority },
{ "autoraise", AUTO_RAISE, 0 },
{ "autoraiseicons", KEYWORD, kw0_AutoRaiseIcons },
{ "autorelativeresize", KEYWORD, kw0_AutoRelativeResize },
{ "autosqueeze", AUTOSQUEEZE, 0 },
{ "backingstore", KEYWORD, kw0_BackingStore },
{ "benicetocolormap", KEYWORD, kw0_BeNiceToColormap },
{ "borderbottom", NKEYWORD, kwn_BorderBottom },
{ "bordercolor", CLKEYWORD, kwcl_BorderColor },
{ "borderleft", NKEYWORD, kwn_BorderLeft },
{ "borderresizecursors", KEYWORD, kw0_BorderResizeCursors },
{ "borderright", NKEYWORD, kwn_BorderRight },
{ "bordershadowdepth", NKEYWORD, kwn_BorderShadowDepth },
{ "bordertilebackground", CLKEYWORD, kwcl_BorderTileBackground },
{ "bordertileforeground", CLKEYWORD, kwcl_BorderTileForeground },
{ "bordertop", NKEYWORD, kwn_BorderTop },
{ "borderwidth", NKEYWORD, kwn_BorderWidth },
{ "button", BUTTON, 0 },
{ "buttonindent", NKEYWORD, kwn_ButtonIndent },
{ "c", CONTROL, 0 },
{ "center", SIJENUM, SIJ_CENTER },
{ "centerfeedbackwindow", KEYWORD, kw0_CenterFeedbackWindow },
{ "changeworkspacefunction", CHANGE_WORKSPACE_FUNCTION, 0 },
{ "clearshadowcontrast", NKEYWORD, kwn_ClearShadowContrast },
{ "clicktofocus", KEYWORD, kw0_ClickToFocus },
{ "clientborderwidth", KEYWORD, kw0_ClientBorderWidth },
{ "color", COLOR, 0 },
{ "constrainedmovetime", NKEYWORD, kwn_ConstrainedMoveTime },
{ "control", CONTROL, 0 },
{ "cursors", CURSORS, 0 },
{ "darkshadowcontrast", NKEYWORD, kwn_DarkShadowContrast },
{ "decoratetransients", KEYWORD, kw0_DecorateTransients },
{ "defaultbackground", CKEYWORD, kwc_DefaultBackground },
{ "defaultforeground", CKEYWORD, kwc_DefaultForeground },
{ "defaultfunction", DEFAULT_FUNCTION, 0 },
{ "deiconifyfunction", DEICONIFY_FUNCTION, 0 },
{ "destroy", KILL, 0 },
{ "donticonifybyunmapping", DONT_ICONIFY_BY_UNMAPPING, 0 },
{ "dontmoveoff", KEYWORD, kw0_DontMoveOff },
{ "dontnamedecorations", KEYWORD, kw0_DontNameDecorations },
{ "dontpaintrootwindow", KEYWORD, kw0_DontPaintRootWindow },
{ "dontsave", DONT_SAVE, 0 },
{ "dontsetinactive", DONTSETINACTIVE, 0 },
{ "dontshowwelcomewindow", KEYWORD, kw0_DontShowWelcomeWindow },
{ "dontsqueezetitle", DONT_SQUEEZE_TITLE, 0 },
{ "donttoggleworkspacemanagerstate", KEYWORD, kw0_DontToggleWorkspacemanagerState},
{ "dontwarpcursorinwmap", KEYWORD, kw0_DontWarpCursorInWMap },
{ "east", GRAVITY, GRAV_EAST },
{ "ewmhignore", EWMH_IGNORE, 0 },
{ "f", FRAME, 0 },
{ "forcefocus", FORCE_FOCUS, 0 },
{ "forceicons", KEYWORD, kw0_ForceIcons },
{ "frame", FRAME, 0 },
{ "framepadding", NKEYWORD, kwn_FramePadding },
{ "function", FUNCTION, 0 },
{ "grabserver", KEYWORD, kw0_GrabServer },
{ "i", ICON, 0 },
{ "icon", ICON, 0 },
{ "iconbackground", CLKEYWORD, kwcl_IconBackground },
{ "iconbordercolor", CLKEYWORD, kwcl_IconBorderColor },
{ "iconborderwidth", NKEYWORD, kwn_IconBorderWidth },
{ "icondirectory", SKEYWORD, kws_IconDirectory },
{ "iconfont", SKEYWORD, kws_IconFont },
{ "iconforeground", CLKEYWORD, kwcl_IconForeground },
{ "iconifybyunmapping", ICONIFY_BY_UNMAPPING, 0 },
{ "iconifyfunction", ICONIFY_FUNCTION, 0 },
{ "iconifystyle", SKEYWORD, kws_IconifyStyle },
{ "iconjustification", SKEYWORD, kws_IconJustification },
{ "iconmanagerbackground", CLKEYWORD, kwcl_IconManagerBackground },
{ "iconmanagerdontshow", ICONMGR_NOSHOW, 0 },
{ "iconmanagerfont", SKEYWORD, kws_IconManagerFont },
{ "iconmanagerforeground", CLKEYWORD, kwcl_IconManagerForeground },
{ "iconmanagergeometry", ICONMGR_GEOMETRY, 0 },
{ "iconmanagerhighlight", CLKEYWORD, kwcl_IconManagerHighlight },
{ "iconmanagers", ICONMGRS, 0 },
{ "iconmanagershadowdepth", NKEYWORD, kwn_IconManagerShadowDepth },
{ "iconmanagershow", ICONMGR_SHOW, 0 },
{ "iconmenudontshow", ICONMENU_DONTSHOW, 0 },
{ "iconmgr", ICONMGR, 0 },
{ "iconregion", ICON_REGION, 0 },
{ "iconregionalignement", SKEYWORD, kws_IconRegionAlignement },
{ "iconregionjustification", SKEYWORD, kws_IconRegionJustification },
{ "icons", ICONS, 0 },
{ "iconsize", SKEYWORD, kws_IconSize },
{ "ignorecaseinmenuselection", KEYWORD, kw0_IgnoreCaseInMenuSelection },
{ "ignorelockmodifier", KEYWORD, kw0_IgnoreLockModifier },
{ "ignoremodifier", IGNOREMODIFIER, 0 },
{ "ignoretransient", IGNORE_TRANSIENT, 0 },
{ "interpolatemenucolors", KEYWORD, kw0_InterpolateMenuColors },
{ "l", LOCK, 0 },
{ "left", SIJENUM, SIJ_LEFT },
{ "lefttitlebutton", LEFT_TITLEBUTTON, 0 },
{ "lock", LOCK, 0 },
{ "m", META, 0 },
{ "maketitle", MAKE_TITLE, 0 },
{ "mapwindowbackground", CLKEYWORD, kwcl_MapWindowBackground },
{ "mapwindowcurrentworkspace", MAPWINDOWCURRENTWORKSPACE, 0},
{ "mapwindowdefaultworkspace", MAPWINDOWDEFAULTWORKSPACE, 0},
{ "mapwindowforeground", CLKEYWORD, kwcl_MapWindowForeground },
{ "maxicontitlewidth", NKEYWORD, kwn_MaxIconTitleWidth },
{ "maxwindowsize", SKEYWORD, kws_MaxWindowSize },
{ "menu", MENU, 0 },
{ "menubackground", CKEYWORD, kwc_MenuBackground },
{ "menufont", SKEYWORD, kws_MenuFont },
{ "menuforeground", CKEYWORD, kwc_MenuForeground },
{ "menushadowcolor", CKEYWORD, kwc_MenuShadowColor },
{ "menushadowdepth", NKEYWORD, kwn_MenuShadowDepth },
{ "menutitlebackground", CKEYWORD, kwc_MenuTitleBackground },
{ "menutitleforeground", CKEYWORD, kwc_MenuTitleForeground },
{ "meta", META, 0 },
{ "mod", META, 0 }, /* fake it */
{ "monitorlayout", MONITOR_LAYOUT, 0 },
{ "monochrome", MONOCHROME, 0 },
{ "move", MOVE, 0 },
{ "movedelta", NKEYWORD, kwn_MoveDelta },
{ "moveoffresistance", NKEYWORD, kwn_MoveOffResistance },
{ "movepackresistance", NKEYWORD, kwn_MovePackResistance },
{ "mwmignore", MWM_IGNORE, 0 },
{ "nobackingstore", KEYWORD, kw0_NoBackingStore },
{ "noborder", NO_BORDER, 0 },
{ "nocasesensitive", KEYWORD, kw0_NoCaseSensitive },
{ "nodecoratetransients", KEYWORD, kw0_NoDecorateTransients },
{ "nodefaults", KEYWORD, kw0_NoDefaults },
{ "nograbserver", KEYWORD, kw0_NoGrabServer },
{ "nohighlight", NO_HILITE, 0 },
{ "noiconmanagerfocus", KEYWORD, kw0_NoIconManagerFocus },
{ "noiconmanagers", KEYWORD, kw0_NoIconManagers },
{ "noicontitle", NO_ICON_TITLE, 0 },
{ "noimagesinworkspacemanager", KEYWORD, kw0_NoImagesInWorkSpaceManager },
{ "nomenushadows", KEYWORD, kw0_NoMenuShadows },
{ "noopaquemove", NOOPAQUEMOVE, 0 },
{ "noopaqueresize", NOOPAQUERESIZE, 0 },
{ "noraiseondeiconify", KEYWORD, kw0_NoRaiseOnDeiconify },
{ "noraiseonmove", KEYWORD, kw0_NoRaiseOnMove },
{ "noraiseonresize", KEYWORD, kw0_NoRaiseOnResize },
{ "noraiseonwarp", KEYWORD, kw0_NoRaiseOnWarp },
{ "norestartpreviousstate", KEYWORD, kw0_NoRestartPreviousState },
{ "north", GRAVITY, GRAV_NORTH },
{ "nosaveunders", KEYWORD, kw0_NoSaveUnders },
{ "noshowoccupyall", KEYWORD, kw0_NoShowOccupyAll },
{ "nosorticonmanager", KEYWORD, kw0_NoSortIconManager },
{ "nostackmode", NO_STACKMODE, 0 },
{ "notitle", NO_TITLE, 0 },
{ "notitlefocus", KEYWORD, kw0_NoTitleFocus },
{ "notitlehighlight", NO_TITLE_HILITE, 0 },
{ "nowarptomenutitle", KEYWORD, kw0_NoWarpToMenuTitle },
{ "occupy", OCCUPYLIST, 0 },
{ "occupyall", OCCUPYALL, 0 },
{ "ontoppriority", ON_TOP_PRIORITY, 0 },
{ "opaquemove", OPAQUEMOVE, 0 },
{ "opaquemovethreshold", NKEYWORD, kwn_OpaqueMoveThreshold },
{ "opaqueresize", OPAQUERESIZE, 0 },
{ "opaqueresizethreshold", NKEYWORD, kwn_OpaqueResizeThreshold },
{ "openwindowtimeout", NKEYWORD, kwn_OpenWindowTimeout },
{ "packnewwindows", KEYWORD, kw0_PackNewWindows },
{ "pixmapdirectory", SKEYWORD, kws_PixmapDirectory },
{ "pixmaps", PIXMAPS, 0 },
{ "prioritynotswitching", PRIORITY_NOT_SWITCHING, 0 },
{ "priorityswitching", PRIORITY_SWITCHING, 0 },
{ "r", ROOT, 0 },
{ "raisedelay", NKEYWORD, kwn_RaiseDelay },
{ "raiseonclick", KEYWORD, kw0_RaiseOnClick },
{ "raiseonclickbutton", NKEYWORD, kwn_RaiseOnClickButton },
{ "raiseonwarp", KEYWORD, kw0_RaiseOnWarp },
{ "raisewhenautounsqueeze", KEYWORD, kw0_RaiseWhenAutoUnSqueeze },
{ "randomplacement", SSKEYWORD, kwss_RandomPlacement },
{ "reallymoveinworkspacemanager", KEYWORD, kw0_ReallyMoveInWorkspaceManager },
{ "resize", RESIZE, 0 },
{ "resizefont", SKEYWORD, kws_ResizeFont },
{ "restartpreviousstate", KEYWORD, kw0_RestartPreviousState },
{ "reversecurrentworkspace", KEYWORD, kw0_ReverseCurrentWorkspace },
{ "right", SIJENUM, SIJ_RIGHT },
{ "righttitlebutton", RIGHT_TITLEBUTTON, 0 },
{ "root", ROOT, 0 },
{ "rplaysoundhost", SKEYWORD, kws_RplaySoundHost },
{ "rplaysounds", RPLAY_SOUNDS, 0 },
{ "s", SHIFT, 0 },
{ "savecolor", SAVECOLOR, 0},
{ "saveworkspacefocus", KEYWORD, kw0_SaveWorkspaceFocus },
{ "schrinkicontitles", KEYWORD, kw0_ShrinkIconTitles },
{ "select", SELECT, 0 },
{ "shift", SHIFT, 0 },
{ "shortallwindowsmenus", KEYWORD, kw0_ShortAllWindowsMenus },
{ "showiconmanager", KEYWORD, kw0_ShowIconManager },
{ "showworkspacemanager", KEYWORD, kw0_ShowWorkspaceManager },
{ "shrinkicontitles", KEYWORD, kw0_ShrinkIconTitles },
{ "sloppyfocus", KEYWORD, kw0_SloppyFocus },
{ "sorticonmanager", KEYWORD, kw0_SortIconManager },
{ "soundhost", SKEYWORD, kws_SoundHost },
{ "south", GRAVITY, GRAV_SOUTH },
{ "squeezetitle", SQUEEZE_TITLE, 0 },
{ "starticonified", START_ICONIFIED, 0 },
{ "startinbuttonstate", KEYWORD, kw0_StartInButtonState },
{ "startinmapstate", KEYWORD, kw0_StartInMapState },
{ "startsqueezed", STARTSQUEEZED, 0 },
{ "stayupmenus", KEYWORD, kw0_StayUpMenus },
{ "strictwinnameencoding", KEYWORD, kw0_StrictWinNameEncoding },
{ "sunkfocuswindowtitle", KEYWORD, kw0_SunkFocusWindowTitle },
{ "t", TITLE, 0 },
{ "threedborderwidth", NKEYWORD, kwn_ThreeDBorderWidth },
{ "title", TITLE, 0 },
{ "titlebackground", CLKEYWORD, kwcl_TitleBackground },
{ "titlebuttonborderwidth", NKEYWORD, kwn_TitleButtonBorderWidth },
{ "titlebuttonshadowdepth", NKEYWORD, kwn_TitleButtonShadowDepth },
{ "titlefont", SKEYWORD, kws_TitleFont },
{ "titleforeground", CLKEYWORD, kwcl_TitleForeground },
{ "titlehighlight", TITLE_HILITE, 0 },
{ "titlejustification", SKEYWORD, kws_TitleJustification },
{ "titlepadding", NKEYWORD, kwn_TitlePadding },
{ "titleshadowdepth", NKEYWORD, kwn_TitleShadowDepth },
{ "transienthasoccupation", KEYWORD, kw0_TransientHasOccupation },
{ "transientontop", NKEYWORD, kwn_TransientOnTop },
{ "unknownicon", SKEYWORD, kws_UnknownIcon },
{ "unmapbymovingfaraway", UNMAPBYMOVINGFARAWAY, 0 },
{ "usepposition", SKEYWORD, kws_UsePPosition },
{ "usesunktitlepixmap", KEYWORD, kw0_UseSunkTitlePixmap },
{ "usethreedborders", KEYWORD, kw0_Use3DBorders },
{ "usethreediconmanagers", KEYWORD, kw0_Use3DIconManagers },
{ "usethreedmenus", KEYWORD, kw0_Use3DMenus },
{ "usethreedtitles", KEYWORD, kw0_Use3DTitles },
{ "usethreedwmap", KEYWORD, kw0_Use3DWMap },
#ifdef VSCREEN
{ "virtualscreens", VIRTUAL_SCREENS, 0 },
#endif
{ "w", WINDOW, 0 },
{ "wait", WAITC, 0 },
{ "warpcursor", WARP_CURSOR, 0 },
{ "warpondeiconify", WARP_ON_DEICONIFY, 0 },
{ "warpringonscreen", KEYWORD, kw0_WarpRingOnScreen },
{ "warptodefaultmenuentry", KEYWORD, kw0_WarpToDefaultMenuEntry },
{ "warpunmapped", KEYWORD, kw0_WarpUnmapped },
{ "west", GRAVITY, GRAV_WEST },
{ "window", WINDOW, 0 },
#ifdef WINBOX
{ "windowbox", WINDOW_BOX, 0 },
#endif
{ "windowfunction", WINDOW_FUNCTION, 0 },
{ "windowgeometries", WINDOW_GEOMETRIES, 0 },
{ "windowregion", WINDOW_REGION, 0 },
{ "windowring", WINDOW_RING, 0 },
{ "windowringexclude", WINDOW_RING_EXCLUDE, 0},
{ "wmgrbuttonshadowdepth", NKEYWORD, kwn_WMgrButtonShadowDepth },
{ "wmgrbuttonstyle", SKEYWORD, kws_WMgrButtonStyle },
{ "wmgrhorizbuttonindent", NKEYWORD, kwn_WMgrHorizButtonIndent },
{ "wmgrvertbuttonindent", NKEYWORD, kwn_WMgrVertButtonIndent },
{ "workspace", WORKSPACE, 0 },
{ "workspacefont", SKEYWORD, kws_WorkSpaceFont },
{ "workspacemanagergeometry", WORKSPCMGR_GEOMETRY, 0 },
{ "workspaces", WORKSPACES, 0},
{ "xmovegrid", NKEYWORD, kwn_XMoveGrid },
{ "xorvalue", NKEYWORD, kwn_XorValue },
{ "xpmicondirectory", SKEYWORD, kws_PixmapDirectory },
{ "ymovegrid", NKEYWORD, kwn_YMoveGrid },
{ "zoom", ZOOM, 0 },
};
static const size_t numkeywords = (sizeof(keytable) / sizeof(keytable[0]));
/*
* The lookup table for functions is generated.
*/
#include "functions_parse_table.h"
static int
kt_compare(const void *lhs, const void *rhs)
{
const TwmKeyword *l = lhs;
const TwmKeyword *r = rhs;
return strcasecmp(l->name, r->name);
}
int
parse_keyword(const char *s, int *nump)
{
const TwmKeyword srch = { .name = s };
TwmKeyword *ret;
const TwmKeyword *srchtab;
size_t nstab;
/* Guard; nothing can't be a valid keyword */
if(s == NULL || strlen(s) < 1) {
return ERRORTOKEN;
}
/*
* Functions are in their own table, so check for them there.
*
* This is safe as long as (strlen >= 1), which we already checked.
*/
if(s[0] == 'f' && s[1] == '.') {
srchtab = funckeytable;
nstab = numfunckeywords;
}
else {
srchtab = keytable;
nstab = numkeywords;
}
/* Find it */
ret = bsearch(&srch, srchtab, nstab, sizeof(TwmKeyword), kt_compare);
if(ret) {
*nump = ret->subnum;
return ret->value;
}
return ERRORTOKEN;
}
/*
* Simple tester function
*/
void
chk_keytable_order(void)
{
int i;
for(i = 0 ; i < (numkeywords - 1) ; i++) {
if(strcasecmp(keytable[i].name, keytable[i + 1].name) >= 0) {
fprintf(stderr, "%s: INTERNAL ERROR: keytable sorting: "
"'%s' >= '%s'\n", ProgramName,
keytable[i].name, keytable[i + 1].name);
}
}
for(i = 0 ; i < (numfunckeywords - 1) ; i++) {
if(strcasecmp(funckeytable[i].name, funckeytable[i + 1].name) >= 0) {
fprintf(stderr, "%s: INTERNAL ERROR: funckeytable sorting: "
"'%s' >= '%s'\n", ProgramName,
funckeytable[i].name, funckeytable[i + 1].name);
}
}
}
/*
* action routines called by grammar
*/
bool
do_single_keyword(int keyword)
{
switch(keyword) {
case kw0_NoDefaults:
Scr->NoDefaults = true;
return true;
case kw0_AutoRelativeResize:
Scr->AutoRelativeResize = true;
return true;
case kw0_ForceIcons:
if(Scr->FirstTime) {
Scr->ForceIcon = true;
}
return true;
case kw0_NoIconManagers:
Scr->NoIconManagers = true;
return true;
case kw0_InterpolateMenuColors:
if(Scr->FirstTime) {
Scr->InterpolateMenuColors = true;
}
return true;
case kw0_SortIconManager:
if(Scr->FirstTime) {
Scr->SortIconMgr = true;
}
return true;
case kw0_NoSortIconManager:
if(Scr->FirstTime) {
Scr->SortIconMgr = false;
}
return true;
case kw0_GrabServer:
Scr->NoGrabServer = false;
return true;
case kw0_NoGrabServer:
Scr->NoGrabServer = true;
return true;
case kw0_NoMenuShadows:
if(Scr->FirstTime) {
Scr->Shadow = false;
}
return true;
case kw0_NoRaiseOnMove:
if(Scr->FirstTime) {
Scr->NoRaiseMove = true;
}
return true;
case kw0_NoRaiseOnResize:
if(Scr->FirstTime) {
Scr->NoRaiseResize = true;
}
return true;
case kw0_NoRaiseOnDeiconify:
if(Scr->FirstTime) {
Scr->NoRaiseDeicon = true;
}
return true;
case kw0_DontMoveOff:
Scr->DontMoveOff = true;
return true;
case kw0_NoBackingStore:
Scr->BackingStore = false;
return true;
case kw0_BackingStore:
Scr->BackingStore = true;
return true;
case kw0_NoSaveUnders:
Scr->SaveUnder = false;
return true;
// XXX Shouldn't these be in Scr too?
case kw0_RestartPreviousState:
RestartPreviousState = true;
return true;
case kw0_NoRestartPreviousState:
RestartPreviousState = false;
return true;
case kw0_ClientBorderWidth:
if(Scr->FirstTime) {
Scr->ClientBorderWidth = true;
}
return true;
case kw0_NoTitleFocus:
Scr->TitleFocus = false;
return true;
case kw0_DecorateTransients:
Scr->DecorateTransients = true;
return true;
case kw0_NoDecorateTransients:
Scr->DecorateTransients = false;
return true;
case kw0_ShowIconManager:
Scr->ShowIconManager = true;
return true;
case kw0_ShowWorkspaceManager:
Scr->ShowWorkspaceManager = true;
return true;
case kw0_StartInButtonState:
Scr->workSpaceMgr.initialstate = WMS_buttons;
return true;
case kw0_StartInMapState:
Scr->workSpaceMgr.initialstate = WMS_map;
return true;
case kw0_NoShowOccupyAll:
Scr->workSpaceMgr.noshowoccupyall = true;
return true;
case kw0_AutoOccupy:
Scr->AutoOccupy = true;
return true;
case kw0_AutoPriority:
Scr->AutoPriority = true;
return true;
case kw0_TransientHasOccupation:
Scr->TransientHasOccupation = true;
return true;
case kw0_DontPaintRootWindow:
Scr->DontPaintRootWindow = true;
return true;
case kw0_UseSunkTitlePixmap:
Scr->UseSunkTitlePixmap = true;
return true;
case kw0_Use3DBorders:
Scr->use3Dborders = true;
return true;
case kw0_Use3DIconManagers:
Scr->use3Diconmanagers = true;
return true;
case kw0_Use3DMenus:
Scr->use3Dmenus = true;
return true;
case kw0_Use3DTitles:
Scr->use3Dtitles = true;
return true;
case kw0_Use3DWMap:
Scr->use3Dwmap = true;
return true;
case kw0_SunkFocusWindowTitle:
Scr->SunkFocusWindowTitle = true;
return true;
case kw0_BeNiceToColormap:
Scr->BeNiceToColormap = true;
return true;
case kw0_BorderResizeCursors:
Scr->BorderCursors = true;
return true;
case kw0_NoCaseSensitive:
Scr->CaseSensitive = false;
return true;
case kw0_NoRaiseOnWarp:
Scr->RaiseOnWarp = false;
return true;
case kw0_RaiseOnWarp:
Scr->RaiseOnWarp = true;
return true;
case kw0_WarpUnmapped:
Scr->WarpUnmapped = true;
return true;
case kw0_WarpRingOnScreen:
Scr->WarpRingAnyWhere = false;
return true;
case kw0_NoIconManagerFocus:
Scr->IconManagerFocus = false;
return true;
case kw0_StayUpMenus:
Scr->StayUpMenus = true;
return true;
case kw0_ClickToFocus:
Scr->ClickToFocus = true;
return true;
case kw0_ReallyMoveInWorkspaceManager:
Scr->ReallyMoveInWorkspaceManager = true;
return true;
case kw0_ShowWinWhenMovingInWmgr:
Scr->ShowWinWhenMovingInWmgr = true;
return true;
case kw0_ReverseCurrentWorkspace:
Scr->ReverseCurrentWorkspace = true;
return true;
case kw0_DontWarpCursorInWMap:
Scr->DontWarpCursorInWMap = true;
return true;
case kw0_CenterFeedbackWindow:
Scr->CenterFeedbackWindow = true;
return true;
case kw0_WarpToDefaultMenuEntry:
Scr->WarpToDefaultMenuEntry = true;
return true;
case kw0_ShrinkIconTitles:
Scr->ShrinkIconTitles = true;
return true;
case kw0_AutoRaiseIcons:
Scr->AutoRaiseIcons = true;
return true;
/* kai */
case kw0_AutoFocusToTransients:
Scr->AutoFocusToTransients = true;
return true;
case kw0_ShortAllWindowsMenus:
Scr->ShortAllWindowsMenus = true;
return true;
case kw0_RaiseWhenAutoUnSqueeze:
Scr->RaiseWhenAutoUnSqueeze = true;
return true;
case kw0_RaiseOnClick:
Scr->RaiseOnClick = true;
return true;
case kw0_IgnoreLockModifier:
Scr->IgnoreModifier |= LockMask;
return true;
case kw0_PackNewWindows:
Scr->PackNewWindows = true;
return true;
case kw0_IgnoreCaseInMenuSelection:
Scr->IgnoreCaseInMenuSelection = true;
return true;
case kw0_SloppyFocus:
Scr->SloppyFocus = true;
return true;
case kw0_SaveWorkspaceFocus:
Scr->SaveWorkspaceFocus = true;
return true;
case kw0_NoImagesInWorkSpaceManager:
Scr->NoImagesInWorkSpaceManager = true;
return true;
case kw0_NoWarpToMenuTitle:
Scr->NoWarpToMenuTitle = true;
return true;
case kw0_DontShowWelcomeWindow:
Scr->ShowWelcomeWindow = false;
return true;
case kw0_DontToggleWorkspacemanagerState:
Scr->DontToggleWorkspaceManagerState = true;
return true;
case kw0_DontNameDecorations:
Scr->NameDecorations = false;
return true;
case kw0_StrictWinNameEncoding:
Scr->StrictWinNameEncoding = true;
return true;
}
return false;
}
bool
do_string_string_keyword(int keyword, const char *s1, const char *s2)
{
switch(keyword) {
case kwss_RandomPlacement: {
/* RandomPlacement {on,off,all,unmapped} [displacement geom] */
int rp;
int gmask, gx, gy; // Geometry mask/x/y values
unsigned int gjw, gjh; // width/height (ignored)
int exmask = (XValue | YValue); // Bits we need in the mask
rp = ParseRandomPlacement(s1);
if(rp < 0) {
twmrc_error_prefix();
fprintf(stderr,
"ignoring invalid RandomPlacement argument 1 \"%s\"\n",
s1);
}
else {
Scr->RandomPlacement = rp;
}
/* If no geom, we're done */
if(s2 == NULL) {
return true;
}
/*
* Figure what the geom means. We actually don't care about
* the size (it probably won't even be provided), so the
* width/height are junk. The X/Y offsets are what we need.
* But we do need them.
*/
gmask = XParseGeometry(s2, &gx, &gy, &gjw, &gjh);
#ifdef DEBUG
fprintf(stderr, "DEBUG:: Mask = %x, Width = %d, Height = %d\n",
gmask, gjw, gjh);
fprintf(stderr, "DEBUG:: X = %d, Y = %d\n", gx, gy);
#endif
if((gmask & exmask) != exmask) {
/* Didn't get X and Y */
twmrc_error_prefix();
fprintf(stderr,
"ignoring invalid RandomPlacement displacement \"%s\"\n", s2);
}
else {
Scr->RandomDisplacementX = gx;
Scr->RandomDisplacementY = gy;
}
/* Done */
return true;
}
}
return false;
}
bool
do_string_keyword(int keyword, char *s)
{
switch(keyword) {
case kws_UsePPosition: {
int ppos = ParseUsePPosition(s);
if(ppos < 0) {
twmrc_error_prefix();
fprintf(stderr,
"ignoring invalid UsePPosition argument \"%s\"\n", s);
}
else {
Scr->UsePPosition = ppos;
}
return true;
}
case kws_IconFont:
if(!Scr->HaveFonts) {
Scr->IconFont.basename = s;
}
return true;
case kws_ResizeFont:
if(!Scr->HaveFonts) {
Scr->SizeFont.basename = s;
}
return true;
case kws_MenuFont:
if(!Scr->HaveFonts) {
Scr->MenuFont.basename = s;
}
return true;
case kws_WorkSpaceFont:
if(!Scr->HaveFonts) {
Scr->workSpaceMgr.windowFont.basename = s;
}
return true;
case kws_TitleFont:
if(!Scr->HaveFonts) {
Scr->TitleBarFont.basename = s;
}
return true;
case kws_IconManagerFont:
if(!Scr->HaveFonts) {
Scr->IconManagerFont.basename = s;
}
return true;
case kws_UnknownIcon:
if(Scr->FirstTime) {
Scr->UnknownImage = GetImage(s, Scr->IconC);
}
return true;
case kws_IconDirectory:
if(Scr->FirstTime) {
Scr->IconDirectory = ExpandFilePath(s);
}
return true;
case kws_PixmapDirectory:
if(Scr->FirstTime) {
Scr->PixmapDirectory = ExpandFilePath(s);
}
return true;
case kws_MaxWindowSize: {
int gmask;
int exmask = (WidthValue | HeightValue);
unsigned int gw, gh; // Stuff we care about
int gjx, gjy; // Stuff we don't
gmask = XParseGeometry(s, &gjx, &gjy, &gw, &gh);
if((gmask & exmask) != exmask) {
twmrc_error_prefix();
fprintf(stderr, "bad MaxWindowSize \"%s\"\n", s);
return false;
}
if(gw == 0 || gh == 0) {
twmrc_error_prefix();
fprintf(stderr, "MaxWindowSize \"%s\" must be non-zero\n", s);
return false;
}
Scr->MaxWindowWidth = gw;
Scr->MaxWindowHeight = gh;
return true;
}
case kws_IconJustification: {
int just = ParseTitleJustification(s);
if((just < 0) || (just == TJ_UNDEF)) {
twmrc_error_prefix();
fprintf(stderr,
"ignoring invalid IconJustification argument \"%s\"\n", s);
}
else {
Scr->IconJustification = just;
}
return true;
}
case kws_IconRegionJustification: {
int just = ParseIRJustification(s);
if(just < 0 || (just == IRJ_UNDEF)) {
twmrc_error_prefix();
fprintf(stderr,
"ignoring invalid IconRegionJustification argument \"%s\"\n", s);
}
else {
Scr->IconRegionJustification = just;
}
return true;
}
case kws_IconRegionAlignement: {
int just = ParseAlignement(s);
if(just < 0) {
twmrc_error_prefix();
fprintf(stderr,
"ignoring invalid IconRegionAlignement argument \"%s\"\n", s);
}
else {
Scr->IconRegionAlignement = just;
}
return true;
}
case kws_TitleJustification: {
int just = ParseTitleJustification(s);
if((just < 0) || (just == TJ_UNDEF)) {
twmrc_error_prefix();
fprintf(stderr,
"ignoring invalid TitleJustification argument \"%s\"\n", s);
}
else {
Scr->TitleJustification = just;
}
return true;
}
case kws_RplaySoundHost:
case kws_SoundHost:
if(Scr->FirstTime) {
/* Warning to be enabled in the future before removal */
if(0 && keyword == kws_SoundHost) {
twmrc_error_prefix();
fprintf(stderr, "SoundHost is deprecated, please "
"use RplaySoundHost instead.\n");
}
#ifdef SOUNDS
set_sound_host(s);
#else
twmrc_error_prefix();
fprintf(stderr, "Ignoring %sSoundHost; rplay not ronfigured.\n",
(keyword == kws_RplaySoundHost ? "Rplay" : ""));
#endif
}
return true;
case kws_WMgrButtonStyle: {
int style = ParseButtonStyle(s);
if(style < 0) {
twmrc_error_prefix();
fprintf(stderr,
"ignoring invalid WMgrButtonStyle argument \"%s\"\n", s);
}
else {
Scr->workSpaceMgr.buttonStyle = style;
}
return true;
}
case kws_IconifyStyle: {
int style = ParseIconifyStyle(s);
if(style < 0) {
twmrc_error_prefix();
fprintf(stderr, "ignoring invalid IconifyStyle argument \"%s\"\n", s);
}
else {
Scr->IconifyStyle = style;
}
return true;
}
#ifdef EWMH
case kws_IconSize:
if(sscanf(s, "%dx%d", &Scr->PreferredIconWidth,
&Scr->PreferredIconHeight) == 2) {
/* ok */
}
else if(sscanf(s, "%d", &Scr->PreferredIconWidth) == 1) {
Scr->PreferredIconHeight = Scr->PreferredIconWidth;
}
else {
Scr->PreferredIconHeight = Scr->PreferredIconWidth = 48;
}
return true;
#endif
}
return false;
}
bool
do_number_keyword(int keyword, int num)
{
switch(keyword) {
case kwn_ConstrainedMoveTime:
ConstrainedMoveTime = num;
return true;
case kwn_MoveDelta:
Scr->MoveDelta = num;
return true;
case kwn_MoveOffResistance:
Scr->MoveOffResistance = num;
return true;
case kwn_MovePackResistance:
if(num < 0) {
num = 20;
}
Scr->MovePackResistance = num;
return true;
case kwn_XMoveGrid:
if(num < 1) {
num = 1;
}
if(num > 100) {
num = 100;
}
Scr->XMoveGrid = num;
return true;
case kwn_YMoveGrid:
if(num < 1) {
num = 1;
}
if(num > 100) {
num = 100;
}
Scr->YMoveGrid = num;
return true;
case kwn_XorValue:
if(Scr->FirstTime) {
Scr->XORvalue = num;
}
return true;
case kwn_FramePadding:
if(Scr->FirstTime) {
Scr->FramePadding = num;
}
return true;
case kwn_TitlePadding:
if(Scr->FirstTime) {
Scr->TitlePadding = num;
}
return true;
case kwn_ButtonIndent:
if(Scr->FirstTime) {
Scr->ButtonIndent = num;
}
return true;
case kwn_ThreeDBorderWidth:
if(Scr->FirstTime) {
Scr->ThreeDBorderWidth = num;
}
return true;
case kwn_BorderWidth:
if(Scr->FirstTime) {
Scr->BorderWidth = num;
}
return true;
case kwn_IconBorderWidth:
if(Scr->FirstTime) {
Scr->IconBorderWidth = num;
}
return true;
case kwn_TitleButtonBorderWidth:
if(Scr->FirstTime) {
Scr->TBInfo.border = num;
}
return true;
case kwn_RaiseDelay:
RaiseDelay = num;
return true;
case kwn_TransientOnTop:
if(Scr->FirstTime) {
Scr->TransientOnTop = num;
}
return true;
case kwn_OpaqueMoveThreshold:
if(Scr->FirstTime) {
Scr->OpaqueMoveThreshold = num;
}
return true;
case kwn_OpaqueResizeThreshold:
if(Scr->FirstTime) {
Scr->OpaqueResizeThreshold = num;
}
return true;
case kwn_WMgrVertButtonIndent:
if(Scr->FirstTime) {
Scr->WMgrVertButtonIndent = num;
}
if(Scr->WMgrVertButtonIndent < 0) {
Scr->WMgrVertButtonIndent = 0;
}
Scr->workSpaceMgr.vspace = Scr->WMgrVertButtonIndent;
Scr->workSpaceMgr.occupyWindow->vspace = Scr->WMgrVertButtonIndent;
return true;
case kwn_WMgrHorizButtonIndent:
if(Scr->FirstTime) {
Scr->WMgrHorizButtonIndent = num;
}
if(Scr->WMgrHorizButtonIndent < 0) {
Scr->WMgrHorizButtonIndent = 0;
}
Scr->workSpaceMgr.hspace = Scr->WMgrHorizButtonIndent;
Scr->workSpaceMgr.occupyWindow->hspace = Scr->WMgrHorizButtonIndent;
return true;
case kwn_WMgrButtonShadowDepth:
if(Scr->FirstTime) {
Scr->WMgrButtonShadowDepth = num;
}
if(Scr->WMgrButtonShadowDepth < 1) {
Scr->WMgrButtonShadowDepth = 1;
}
return true;
case kwn_MaxIconTitleWidth:
if(Scr->FirstTime) {
Scr->MaxIconTitleWidth = num;
}
return true;
case kwn_ClearShadowContrast:
if(Scr->FirstTime) {
Scr->ClearShadowContrast = num;
}
if(Scr->ClearShadowContrast < 0) {
Scr->ClearShadowContrast = 0;
}
if(Scr->ClearShadowContrast > 100) {
Scr->ClearShadowContrast = 100;
}
return true;
case kwn_DarkShadowContrast:
if(Scr->FirstTime) {
Scr->DarkShadowContrast = num;
}
if(Scr->DarkShadowContrast < 0) {
Scr->DarkShadowContrast = 0;
}
if(Scr->DarkShadowContrast > 100) {
Scr->DarkShadowContrast = 100;
}
return true;
case kwn_AnimationSpeed:
if(num < 0) {
num = 0;
}
SetAnimationSpeed(num);
return true;
case kwn_BorderShadowDepth:
if(Scr->FirstTime) {
Scr->BorderShadowDepth = num;
}
if(Scr->BorderShadowDepth < 0) {
Scr->BorderShadowDepth = 2;
}
return true;
case kwn_BorderLeft:
if(Scr->FirstTime) {
Scr->BorderLeft = num;
}
if(Scr->BorderLeft < 0) {
Scr->BorderLeft = 0;
}
return true;
case kwn_BorderRight:
if(Scr->FirstTime) {
Scr->BorderRight = num;
}
if(Scr->BorderRight < 0) {
Scr->BorderRight = 0;
}
return true;
case kwn_BorderTop:
if(Scr->FirstTime) {
Scr->BorderTop = num;
}
if(Scr->BorderTop < 0) {
Scr->BorderTop = 0;
}
return true;
case kwn_BorderBottom:
if(Scr->FirstTime) {
Scr->BorderBottom = num;
}
if(Scr->BorderBottom < 0) {
Scr->BorderBottom = 0;
}
return true;
case kwn_TitleButtonShadowDepth:
if(Scr->FirstTime) {
Scr->TitleButtonShadowDepth = num;
}
if(Scr->TitleButtonShadowDepth < 0) {
Scr->TitleButtonShadowDepth = 2;
}
return true;
case kwn_TitleShadowDepth:
if(Scr->FirstTime) {
Scr->TitleShadowDepth = num;
}
if(Scr->TitleShadowDepth < 0) {
Scr->TitleShadowDepth = 2;
}
return true;
case kwn_IconManagerShadowDepth:
if(Scr->FirstTime) {
Scr->IconManagerShadowDepth = num;
}
if(Scr->IconManagerShadowDepth < 0) {
Scr->IconManagerShadowDepth = 2;
}
return true;
case kwn_MenuShadowDepth:
if(Scr->FirstTime) {
Scr->MenuShadowDepth = num;
}
if(Scr->MenuShadowDepth < 0) {
Scr->MenuShadowDepth = 2;
}
return true;
case kwn_OpenWindowTimeout:
if(Scr->FirstTime) {
Scr->OpenWindowTimeout = num;
}
if(Scr->OpenWindowTimeout < 0) {
Scr->OpenWindowTimeout = 0;
}
return true;
case kwn_RaiseOnClickButton:
if(Scr->FirstTime) {
Scr->RaiseOnClickButton = num;
}
if(Scr->RaiseOnClickButton < 1) {
Scr->RaiseOnClickButton = 1;
}
if(Scr->RaiseOnClickButton > MAX_BUTTONS) {
Scr->RaiseOnClickButton = MAX_BUTTONS;
}
return true;
}
return false;
}
name_list **
do_colorlist_keyword(int keyword, int colormode, char *s)
{
switch(keyword) {
case kwcl_BorderColor:
GetColor(colormode, &Scr->BorderColorC.back, s);
return &Scr->BorderColorL;
case kwcl_IconManagerHighlight:
GetColor(colormode, &Scr->IconManagerHighlight, s);
return &Scr->IconManagerHighlightL;
case kwcl_BorderTileForeground:
GetColor(colormode, &Scr->BorderTileC.fore, s);
return &Scr->BorderTileForegroundL;
case kwcl_BorderTileBackground:
GetColor(colormode, &Scr->BorderTileC.back, s);
return &Scr->BorderTileBackgroundL;
case kwcl_TitleForeground:
GetColor(colormode, &Scr->TitleC.fore, s);
return &Scr->TitleForegroundL;
case kwcl_TitleBackground:
GetColor(colormode, &Scr->TitleC.back, s);
return &Scr->TitleBackgroundL;
case kwcl_IconForeground:
GetColor(colormode, &Scr->IconC.fore, s);
return &Scr->IconForegroundL;
case kwcl_IconBackground:
GetColor(colormode, &Scr->IconC.back, s);
return &Scr->IconBackgroundL;
case kwcl_IconBorderColor:
GetColor(colormode, &Scr->IconBorderColor, s);
return &Scr->IconBorderColorL;
case kwcl_IconManagerForeground:
GetColor(colormode, &Scr->IconManagerC.fore, s);
return &Scr->IconManagerFL;
case kwcl_IconManagerBackground:
GetColor(colormode, &Scr->IconManagerC.back, s);
return &Scr->IconManagerBL;
case kwcl_MapWindowBackground:
GetColor(colormode, &Scr->workSpaceMgr.windowcp.back, s);
Scr->workSpaceMgr.windowcpgiven = true;
return &Scr->workSpaceMgr.windowBackgroundL;
case kwcl_MapWindowForeground:
GetColor(colormode, &Scr->workSpaceMgr.windowcp.fore, s);
Scr->workSpaceMgr.windowcpgiven = true;
return &Scr->workSpaceMgr.windowForegroundL;
}
return NULL;
}
bool
do_color_keyword(int keyword, int colormode, char *s)
{
switch(keyword) {
case kwc_DefaultForeground:
GetColor(colormode, &Scr->DefaultC.fore, s);
return true;
case kwc_DefaultBackground:
GetColor(colormode, &Scr->DefaultC.back, s);
return true;
case kwc_MenuForeground:
GetColor(colormode, &Scr->MenuC.fore, s);
return true;
case kwc_MenuBackground:
GetColor(colormode, &Scr->MenuC.back, s);
return true;
case kwc_MenuTitleForeground:
GetColor(colormode, &Scr->MenuTitleC.fore, s);
return true;
case kwc_MenuTitleBackground:
GetColor(colormode, &Scr->MenuTitleC.back, s);
return true;
case kwc_MenuShadowColor:
GetColor(colormode, &Scr->MenuShadowColor, s);
return true;
}
return false;
}
/*
* put_pixel_on_root() Save a pixel value in twm root window color property.
*/
static void
put_pixel_on_root(Pixel pixel)
{
bool addone = true;
Atom retAtom;
int retFormat;
unsigned long nPixels, retAfter;
Pixel *retProp;
// Get current list
if(XGetWindowProperty(dpy, Scr->Root, XA__MIT_PRIORITY_COLORS, 0, 8192,
False, XA_CARDINAL, &retAtom,
&retFormat, &nPixels, &retAfter,
(unsigned char **)&retProp) != Success || !retProp) {
return;
}
// See if we already have this one
for(int i = 0; i < nPixels; i++) {
if(pixel == retProp[i]) {
addone = false;
}
}
XFree(retProp);
// If not, append it
if(addone) {
XChangeProperty(dpy, Scr->Root, XA__MIT_PRIORITY_COLORS,
XA_CARDINAL, 32, PropModeAppend,
(unsigned char *)&pixel, 1);
}
}
/*
* Stash for SaveColor{} values during config parsing.
*/
typedef struct _cnode {
int i;
int cmode;
char *sname;
struct _cnode *next;
} Cnode;
static Cnode *chead = NULL;
/**
* Add a SaveColor{} entry to our stash.
*/
static void
add_cnode(int kwcl, int cmode, char *colname)
{
Cnode *cnew;
cnew = calloc(1, sizeof(Cnode));
cnew->i = kwcl;
cnew->cmode = cmode;
cnew->sname = colname;
if(!chead) {
chead = cnew;
}
else {
cnew->next = chead;
chead = cnew;
}
return;
}
/*
* do_string_savecolor() save a color from a string in the twmrc file.
*/
void
do_string_savecolor(int colormode, char *s)
{
add_cnode(0, colormode, s);
}
/*
* do_var_savecolor() save a color from a var in the twmrc file.
*/
void
do_var_savecolor(int key)
{
add_cnode(key, 0, NULL);
}
/*
* assign_var_savecolor() traverse the var save color list placeing the pixels
* in the root window property.
*/
void
assign_var_savecolor(void)
{
Cnode *cp = chead;
// Start with an empty property
XChangeProperty(dpy, Scr->Root, XA__MIT_PRIORITY_COLORS,
XA_CARDINAL, 32, PropModeReplace, NULL, 0);
// Loop over, stash 'em, and clean up
while(cp != NULL) {
Cnode *tmp_cp = cp;
switch(cp->i) {
case kwcl_BorderColor:
put_pixel_on_root(Scr->BorderColorC.back);
break;
case kwcl_IconManagerHighlight:
put_pixel_on_root(Scr->IconManagerHighlight);
break;
case kwcl_BorderTileForeground:
put_pixel_on_root(Scr->BorderTileC.fore);
break;
case kwcl_BorderTileBackground:
put_pixel_on_root(Scr->BorderTileC.back);
break;
case kwcl_TitleForeground:
put_pixel_on_root(Scr->TitleC.fore);
break;
case kwcl_TitleBackground:
put_pixel_on_root(Scr->TitleC.back);
break;
case kwcl_IconForeground:
put_pixel_on_root(Scr->IconC.fore);
break;
case kwcl_IconBackground:
put_pixel_on_root(Scr->IconC.back);
break;
case kwcl_IconBorderColor:
put_pixel_on_root(Scr->IconBorderColor);
break;
case kwcl_IconManagerForeground:
put_pixel_on_root(Scr->IconManagerC.fore);
break;
case kwcl_IconManagerBackground:
put_pixel_on_root(Scr->IconManagerC.back);
break;
case kwcl_MapWindowForeground:
put_pixel_on_root(Scr->workSpaceMgr.windowcp.fore);
break;
case kwcl_MapWindowBackground:
put_pixel_on_root(Scr->workSpaceMgr.windowcp.back);
break;
case 0: {
// This means it's a string, not one of our keywords
Pixel p;
GetColor(cp->cmode, &p, cp->sname);
put_pixel_on_root(p);
}
}
cp = cp->next;
free(tmp_cp);
}
if(chead) {
chead = NULL;
}
}
/*
* RandomPlacement [...] parse
*/
static int
ParseRandomPlacement(const char *s)
{
/* No first arg -> 'all' */
if(s == NULL) {
return RP_ALL;
}
if(strlen(s) == 0) {
return RP_ALL;
}
#define CHK(str, ret) if(strcasecmp(s, str) == 0) { return RP_##ret; }
CHK(DEFSTRING, ALL);
CHK("on", ALL);
CHK("all", ALL);
CHK("off", OFF);
CHK("unmapped", UNMAPPED);
#undef CHK
return -1;
}
/*
* Parse out IconRegionJustification string.
*
* X-ref comment on ParseAlignement about return value.
*/
int
ParseIRJustification(const char *s)
{
if(strlen(s) == 0) {
return -1;
}
#define CHK(str, ret) if(strcasecmp(s, str) == 0) { return IRJ_##ret; }
CHK(DEFSTRING, CENTER);
CHK("undef", UNDEF);
CHK("left", LEFT);
CHK("center", CENTER);
CHK("right", RIGHT);
CHK("border", BORDER);
#undef CHK
return -1;
}
/*
* Parse out string for title justification. From TitleJustification,
* IconJustification, iconjust arg to IconRegion.
*
* X-ref comment on ParseAlignement about return value.
*/
int
ParseTitleJustification(const char *s)
{
if(strlen(s) == 0) {
return -1;
}
#define CHK(str, ret) if(strcasecmp(s, str) == 0) { return TJ_##ret; }
/* XXX Different uses really have different defaults... */
CHK(DEFSTRING, CENTER);
CHK("undef", UNDEF);
CHK("left", LEFT);
CHK("center", CENTER);
CHK("right", RIGHT);
#undef CHK
return -1;
}
/*
* Parse out the string specifier for IconRegion Alignement[sic].
* Strictly speaking, this [almost always] returns an IRAlignement enum
* value. However, it's specified as int to allow the -1 return for
* invalid values. enum's start numbering from 0 (unless specific values
* are given), so that's a safe out-of-bounds value. And making an
* IRA_INVALID value would just add unnecessary complication, since
* during parsing is the only time it makes sense.
*/
int
ParseAlignement(const char *s)
{
if(strlen(s) == 0) {
return -1;
}
#define CHK(str, ret) if(strcasecmp(s, str) == 0) { return IRA_##ret; }
CHK(DEFSTRING, CENTER);
CHK("center", CENTER);
CHK("top", TOP);
CHK("bottom", BOTTOM);
CHK("border", BORDER);
CHK("undef", UNDEF);
#undef CHK
return -1;
}
static int
ParseUsePPosition(const char *s)
{
if(strlen(s) == 0) {
return -1;
}
#define CHK(str, ret) if(strcasecmp(s, str) == 0) { return PPOS_##ret; }
CHK(DEFSTRING, OFF);
CHK("off", OFF);
CHK("on", ON);
CHK("non-zero", NON_ZERO);
CHK("nonzero", NON_ZERO);
#undef CHK
return -1;
}
static int
ParseButtonStyle(const char *s)
{
if(s == NULL || strlen(s) == 0) {
return -1;
}
#define CHK(str, ret) if(strcasecmp(s, str) == 0) { return STYLE_##ret; }
CHK(DEFSTRING, NORMAL);
CHK("normal", NORMAL);
CHK("style1", STYLE1);
CHK("style2", STYLE2);
CHK("style3", STYLE3);
#undef CHK
return -1;
}
static int
ParseIconifyStyle(const char *s)
{
if(s == NULL || strlen(s) == 0) {
return -1;
}
#define CHK(str, ret) if(strcasecmp(s, str) == 0) { return ICONIFY_##ret; }
CHK(DEFSTRING, NORMAL);
CHK("normal", NORMAL);
CHK("mosaic", MOSAIC);
CHK("zoomin", ZOOMIN);
CHK("zoomout", ZOOMOUT);
CHK("fade", FADE);
CHK("sweep", SWEEP);
#undef CHK
return -1;
}
void
do_squeeze_entry(name_list **slist, // squeeze or dont-squeeze list
const char *name, // window name
SIJust justify, // left, center, right
int num, // signed num
int denom) // 0 or indicates fraction denom
{
int absnum = (num < 0 ? -num : num);
if(denom < 0) {
twmrc_error_prefix();
fprintf(stderr, "negative SqueezeTitle denominator %d\n", denom);
ParseError = true;
return;
}
if(absnum > denom && denom != 0) {
twmrc_error_prefix();
fprintf(stderr, "SqueezeTitle fraction %d/%d outside window\n",
num, denom);
ParseError = true;
return;
}
/* Process the special cases from the manual here rather than
* each time we calculate the position of the title bar
* in ComputeTitleLocation().
* In fact, it's better to get rid of them entirely, but we
* probably should not do that for compatibility's sake.
* By using a non-zero denominator the position will be relative.
*/
if(denom == 0 && num == 0) {
if(justify == SIJ_CENTER) {
num = 1;
denom = 2;
}
else if(justify == SIJ_RIGHT) {
num = 2;
denom = 2;
}
twmrc_error_prefix();
fprintf(stderr, "deprecated SqueezeTitle faction 0/0, assuming %d/%d\n",
num, denom);
}
if(HasShape) {
SqueezeInfo *sinfo;
sinfo = malloc(sizeof(SqueezeInfo));
if(!sinfo) {
twmrc_error_prefix();
fprintf(stderr, "unable to allocate %lu bytes for squeeze info\n",
(unsigned long) sizeof(SqueezeInfo));
ParseError = true;
return;
}
sinfo->justify = justify;
sinfo->num = num;
sinfo->denom = denom;
AddToList(slist, name, sinfo);
}
return;
}
/*
* Parsing for EWMHIgnore { } lists
*/
void
proc_ewmh_ignore(void)
{
#ifndef EWMH
twmrc_error_prefix();
fprintf(stderr, "EWMH not enabled, EWMHIgnore { } ignored.\n");
ParseError = true;
return;
#endif
/* else nada */
return;
}
void
add_ewmh_ignore(char *s)
{
#ifndef EWMH
return;
#else
#define HANDLE(x) \
if(strcasecmp(s, (x)) == 0) { \
AddToList(&Scr->EWMHIgnore, (x), ""); \
return; \
}
HANDLE("STATE_MAXIMIZED_VERT");
HANDLE("STATE_MAXIMIZED_HORZ");
HANDLE("STATE_FULLSCREEN");
HANDLE("STATE_SHADED");
HANDLE("STATE_ABOVE");
HANDLE("STATE_BELOW");
#undef HANDLE
twmrc_error_prefix();
fprintf(stderr, "Unexpected EWMHIgnore value '%s'\n", s);
ParseError = true;
return;
#endif /* EWMH */
}
/*
* Parsing for MWMIgnore { } lists
*/
void
proc_mwm_ignore(void)
{
/* Nothing to do */
return;
}
void
add_mwm_ignore(char *s)
{
#define HANDLE(x) \
if(strcasecmp(s, (x)) == 0) { \
AddToList(&Scr->MWMIgnore, (x), ""); \
return; \
}
HANDLE("DECOR_BORDER");
HANDLE("DECOR_TITLE");
#undef HANDLE
twmrc_error_prefix();
fprintf(stderr, "Unexpected MWMIgnore value '%s'\n", s);
ParseError = true;
return;
}
/*
* Parsing for Layout { } lists, to override the monitor layout we
* assumed or got from RANDR.
*/
static RAreaList *override_monitors;
static struct {
char **names;
int len;
int cap;
} override_monitors_names;
/**
* Allocate space for our monitor override list.
*/
void
init_layout_override(void)
{
// 4 seems like a good guess. If we're doing this, we're probably
// making at least 2 monitors, and >4 is gonna be pretty rare, so...
const int initsz = 4;
override_monitors = RAreaListNew(initsz, NULL);
if(override_monitors == NULL) {
twmrc_error_prefix();
fprintf(stderr, "Failed allocating RAreaList for monitors.\n");
ParseError = true;
return;
// Maybe we should just abort(); if malloc failed allocating a
// few dozen bytes this early, we're _screwed_.
}
override_monitors_names.names = calloc(initsz, sizeof(char *));
override_monitors_names.len = 0;
override_monitors_names.cap = initsz;
return;
}
/**
* Add an entry to our monitor list
*
* Expecting: [Name:]WxH[+X[+Y]]
*/
void
add_layout_override_entry(const char *s)
{
const char *tmp;
int xpgret;
int x, y;
unsigned int width, height;
if(override_monitors == NULL) {
// alloc failed, so just give up; we'll fail in the end anyway...
return;
}
// Got a name?
tmp = strchr(s, ':');
if(tmp != NULL && tmp != s) {
// Stash the name
override_monitors_names.names[override_monitors_names.len]
= strndup(s, tmp - s);
// len advances below
// Advance to geom
s = tmp + 1;
}
// Advance whether we got a name or not, to keep in sync.
override_monitors_names.len++;
// Either way, s points at the geom now
xpgret = XParseGeometry(s, &x, &y, &width, &height);
// Width and height are non-optional. If x/y aren't given, we assume
// +0+0. If we're given -0's, well, we don't _support_ that, but
// XPG() turns them into positives for us, so just accept it...
const int has_hw = (WidthValue | HeightValue);
if((xpgret & has_hw) != has_hw) {
twmrc_error_prefix();
fprintf(stderr, "Need both height and width in '%s'\n", s);
ParseError = true;
// Don't bother free()'ing stuff, we're going to exit after
// parse completes
return;
}
if(!(xpgret & XValue)) {
x = 0;
}
if(!(xpgret & YValue)) {
y = 0;
}
// And stash it
RAreaListAdd(override_monitors, RAreaNewStatic(x, y, width, height));
// Whether we had a name for this 'monitor' or not, we need to
// possibly grow the names list, since it has to stay in lockstep
// with the areas as we add 'em.
{
char ***names = &override_monitors_names.names;
int len = override_monitors_names.len;
if(len == override_monitors_names.cap) {
char **tnames = realloc(*names, (len + 1) * sizeof(char *));
if(tnames == NULL) {
abort();
}
*names = tnames;
override_monitors_names.cap++;
}
}
return;
}
/**
* Finalize the override layout and store it up globally.
*/
void
proc_layout_override(void)
{
RLayout *new_layout;
// Guard
if(RAreaListLen(override_monitors) < 1) {
// Make this non-fatal, so an empty spec not-quite-quietly does
// nothing.
twmrc_error_prefix();
fprintf(stderr, "no monitors specified, ignoring MonitorLayout\n");
// Since it's non-fatal, we _do_ need to cleanup more
// carefully...
RAreaListFree(override_monitors);
for(int i = 0; i < override_monitors_names.len ; i++) {
free(override_monitors_names.names[i]);
}
free(override_monitors_names.names);
return;
}
new_layout = RLayoutNew(override_monitors);
RLayoutSetMonitorsNames(new_layout, override_monitors_names.names);
// Silently stop paying attention to o_m_n. Don't free() anything,
// since new_layout now owns it. If we get another MonitorLayout{}
// block, it'll start over again with init(), and allocate new space.
#ifdef DEBUG
fprintf(stderr, "Overridden layout: ");
RLayoutPrint(new_layout);
#endif
RLayoutFree(Scr->Layout);
Scr->Layout = new_layout;
return;
}
|