File: sawfish.texi

package info (click to toggle)
sawfish 1:1.5.3-2.4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 18,160 kB
  • ctags: 1,428
  • sloc: lisp: 23,542; ansic: 15,824; sh: 10,268; makefile: 615; perl: 19
file content (6842 lines) | stat: -rw-r--r-- 234,902 bytes parent folder | download | duplicates (2)
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
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
\input texinfo  @c -*-Texinfo-*-
@setfilename sawfish.info
@settitle sawfish Programming Manual
@footnotestyle end

@set EDITION 0.14
@set VERSION 1.5.0
@set UPDATED 02 Apr 2009
@set UPDATE-MONTH Apr 2009

@ifinfo
@dircategory Programming
@direntry
* sawfish: (sawfish).		sawfish programming manual
@end direntry

This is Edition @value{EDITION}, last updated @value{UPDATED}, of
@cite{The sawfish Programming Manual}, for sawfish, Version
@value{VERSION}.

Copyright 1999 John Harper.

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
@end ignore

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.
@end ifinfo

@titlepage
@title sawfish
@subtitle An Extensible X11 Window Manager
@subtitle Programming Manual
@subtitle Edition @value{EDITION}
@subtitle @value{UPDATE-MONTH}
@author John Harper
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1999 John Harper.

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.
@end titlepage

@node Top, Copying, (dir), (dir)

@ifnottex
This document describes the Lisp programming interface to
@code{sawfish}, an extensible X11 window manager.

This is Edition @value{EDITION} of its documentation,
last updated @value{UPDATED} for Sawfish version @value{VERSION}.
@end ifnottex

@menu
* Copying::                     Distribution conditions
* Introduction::                Brief introduction to sawfish
* News::                        Feature history

* Colors::			Color type
* Fonts::			Font type
* Images::			Image type
* Cursors::			Cursor type
* Windows::			Window type
* Customization::		Supporting user-configuration

* Window Frames::		Decorating windows
* Viewports::			Subdivided desktop areas
* Workspaces::			Multiple desktop areas
* Multi-Head Environments::     Multiple monitors
* Window Placement::            Controlling placement of new windows
* Popup Menus::			Displaying menus
* Events::			Input event types
* Commands::			Functions you can invoke interactively
* Keymaps::			Bindings events to actions
* Event Loop::			Handling input events
* Miscellaneous Functions::	Useful features
* Standard Hooks::		Hooking into wm actions
* Standard Properties::		Window properties
* Session Management::		Saving state across sessions
* Low-level X Interface::       Accessing the server directly

* FAQ::				Frequently asked questions

* Function Index::              Menu of all documented functions
* Variable Index::              All variables which have been mentioned
* Concept Index::               Main index, references to all sections
@end menu

@node Copying, Introduction, Top, Top
@chapter Copying
@cindex Copying

Sawfish is copyright (C) 1999 John Harper and is released under the
terms of the GNU General Public License. See the included file
@file{COPYING} for the full text of the license (or @pxref{Copying, ,
Copying, emacs, The GNU Emacs Manual}).

@quotation
This is free software -- you are welcome to redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or
(at your option) any later version.

Sawfish is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
@end quotation


@node Introduction, News, Copying, Top
@chapter Introduction
@cindex Introduction

Sawfish is a lisp-extensible window manager for X11. Its aim is to
allow all areas of window management (decoration, manipulation) to be
customized as far as is possible, yet still remain as fast or faster
than existing window managers.

Despite this extensibility its policy is very minimal compared to most
window managers. It does not implement desktop backgrounds,
applications docks, or other things that may be achieved through
separate applications.

All high-level window management functions are implemented in Lisp for
future extensibility or redefinition. Also, most received events are
exported to the Lisp environment through key-bindings and hooks,
similar to in Emacs. These events include pointer behavior and many
internal X11 events.

Sawfish uses the librep Lisp environment (@pxref{Top, , Overview,
librep, The Librep Manual}), this is a run-time library implementing a
language similar to Emacs Lisp (@pxref{Top, , Overview, elisp, The
Emacs-Lisp Manual}), but with many extensions, and using lexical
instead of dynamic scope. This manual assumes at least a basic
knowledge of the language.

Homepage and mailing list are listed in @xref{FAQ}.

@node News, Colors, Introduction, Top

@include news.texi


@node Colors, Fonts, News, Top
@chapter Colors
@cindex Colors

Sawfish provides a primitive type allowing colors to be represented.
Each color object allows a single color value to be named and passed
between Lisp functions.

@defun colorp arg
Returns @code{t} when @var{arg} is a member of the color type.
@end defun

@defun get-color name &optional alpha
Returns the color object representing the color specified by the string
@var{name}. This is according to the standard X11 color specifiers,
either a named color from the @file{rgb.txt} database, or a string
defining the red, green and blue components of the color, either eight
or sixteen bits in hexadecimal, i.e. @samp{#RRGGBB} or
@samp{#RRRRGGGGBBBB}.

Optional argument @var{alpha} becomes the alpha value of
the returned color.  It is passed through to @code{get-color-rgb}.

Signals an error if no known color has the name @var{name}.
@end defun

@defun get-color-rgb red green blue &optional alpha
Return the color object representing the color with RGB components as
specified (each component ranging from 0 to 65535).

Optional argument @var{alpha} becomes the alpha value of the returned
color.  Use an integer value in the range from 0 to 65535.  Integers
outside that range are not supported, while non-integers such as
@code{nil} are silently converted to 65535 (fully opaque).
@end defun

Given a color object, it's possible to find both the actual rgb values
defining the color and one of the names that X11 uses to refer to the
color.

@defun color-rgb color
Return a list of integers @code{(@var{red} @var{green} @var{blue}
@var{alpha})}, the actual color values of the color represented by
object COLOR.  The individual values range from 0 to 65535.
@end defun

@defun color-rgb-8 color
Return a list of integers @code{(@var{red} @var{green} @var{blue}
@var{alpha})}, just like @code{color-rgb}.  However, the color values
are scaled to fit a range from from 0 to 255.
@end defun

@defun color-name color
Return the name of the color represented by the color object
@var{color}.  Note that this picks one name from the set of valid
names for this color; it may well be different to the name used when
the color was originally allocated.

The X11 name does not include alpha information.
@end defun

Where a color object is used to define the foreground color of a piece
of text, the @code{default-foreground} color provides the default value
used if no actual color is specified.

@defvar default-foreground
The color used for text where no other color is defined.
@end defvar


@node Fonts, Images, Colors, Top
@chapter Fonts
@cindex Fonts

As with the color type, the font type allows X11 fonts to be
manipulated by Lisp code.

@defun fontp arg
Returns @code{t} if @var{arg} is a font object.
@end defun

Sawfish supports two types of fonts: X11 core fonts (fontsets and
fontstructs) and Xft fonts.  Calling code must look up fonts by
giving both a name and a type: an @code{xlfd} argument indicates the
core fonts, and @code{Xft} indicates Xft fonts.  These types are
always literal strings.

@defun font-type-exists-p type
Returns true if fonts with the type described by the string @var{type}
can be loaded, false otherwise.
@end defun

@defun get-font-typed type name
Return a font object representing the X11 font specified by the string
@var{name}.  Argument @var{type} indicates the type of font to look
for; it must be one of the strings @code{xlfd} for a X11 core fonts
(based on fontsets or a fontstructs), or @code{Xft} for an Xft font.

Signals an error if @var{type} is not one of the literal strings
listed above.  Also signals an error if no font named @var{name}
can be found within the requested type.
@end defun

@defun get-font name
Return a font object representing the X11 core font (fontset or
fontstruct) specified by the string @var{name}.

Signals an error if no font named @var{name} is available among the
X11 core fonts.
@end defun

Several functions allow the attributes associated with a font object to
be found.

@defun font-name font
Returns the name of the X11 font represented by object @var{font} (a
string).
@end defun

@defun font-type font
Returns a string indicating the font's class.  This is @code{xlfd}
for X11 core fonts, or @code{Xft} for Xft fonts.
@end defun

@defun font-height font
Returns the bounding height of glyphs in the font represented by object
@var{font}.
@end defun

@defun font-ascent &optional font
Returns the ascent of glyphs rendered using the font represented by
@var{font}.  If no font argument is given, use the default font.
@end defun

@defun font-descent &optional font
Returns the descent of glyphs rendered using the font represented by
@var{font}.  If no font argument is given, use the default font.
@end defun

@defun text-width string &optional font
Returns the number of horizontal pixels that would be required to
display the text @var{string} using font object @var{font} (or the
value of the @code{default-font} variable if @var{font} is undefined).
@end defun

As with colors, a default font may be specified, to be used where no
other font is specified.

@defvar default-font
Font object used when no other font has been specified.
@end defvar

Fonts can have Lisp properties associated with them (similar to the
property lists associated with symbols). Currently these aren't
actually used by the window manager.

@defun font-put font property value
Associate the lisp object @var{value} with the property named by the
symbol @var{property} of the font object @var{font}.
@end defun

@defun font-get font property
Return the value of the property named by the symbol @var{property} of
the font @var{font}, or @code{nil} if no such property exists.
@end defun

@defvar fonts-are-fontsets
True if the X fonts in use are fontsets.  This will be false if
@code{setlocale} fails, or returns an ASCII locale, or if X doesn't
support the locale.
@end defvar


@node Images, Cursors, Fonts, Top
@chapter Images
@cindex Images

The image type allows arbitrary 24-bit images to be manipulated by the
window manager. Images may be both loaded from files, and rendered
dynamically.

@defun imagep arg
Returns @code{t} when @var{arg} is a member of the image type.
@end defun

@defun make-image file-name &optional plist
Creates and returns an image object containing the image defined by the
contents of the file named @var{file-name} (a string). The
@code{image-load-path} directory provides the search path used while
trying to find a directory containing the file named @var{file-name}.

All common image formats will likely be able to be loaded. But PNG,
JPEG and XPM should always be supported.

Argument @var{plist} becomes the property list of the returned image.

Signals an error if file called @var{file-name} may be found, or if an
image may not be constructed from the file.
@end defun

@defvar image-directory
Directory containing built-in Sawfish images.  By default, this is
@code{@var{sawfish-directory}/images}.
@end defvar

@defvar image-load-path
A list of directory names. This defines the search path used when
loading images.  By default, this is @code{("."
@var{image-directory})}.  Modifying @var{image-directory} does not
modify @var{image-load-path}.
@end defvar

@defun make-sized-image width height &optional color
Create and return a new image, of size @var{width},  @var{height}. If
@var{color} is defined it specifies the color of all pixels in the
image. If undefined, all pixels will be black.
@end defun

@defun make-image-from-x-drawable id &optional mask-id
Create and return an new image.  The image is constructed by copying
an X Drawable (identified by @var{id}) into a Sawfish image object.
The function automatically handles depth conversion.

If @var{mask-id} is given, it identifies another X Drawable.  Black
pixels in this drawable indicate transparent pixels in the image
object (non-black pixels have no effect on the image object).
@end defun

@defun copy-image image
Returns a newly allocated image object, an exact copy of the image
object @var{image}.
@end defun

@defun image-dimensions image
Returns a cons-cell @code{(@var{width} . @var{height})} defining the
dimensions of the image represented by @var{image}.
@end defun

@defun flip-image-horizontally image
Flip the contents of @var{image} about the vertical axis.
This is a mutating operation that returns the modified argument.
@end defun

@defun flip-image-vertically image
Flip the contents of @var{image} about the horizontal axis.
This is a mutating operation that returns the modified argument.
@end defun

@defun flip-image-diagonally image
Flip the contents of @var{image} about an axis running from the
top-left corner to the bottom-right corner of the image.
This is a mutating operation that returns the modified argument.
@end defun

As with many of the other types, arbitrary state may be associated with
image objects.

@defun image-put image property value
Set the property named @var{property} (a symbol) of @var{image} to
@var{value}.
@end defun

@defun image-get image property
Return the property named @var{property} of @var{image}, or @code{nil}
if no such property exists.
@end defun

The only predefined property is the symbol @code{tiled}, used when an
image is displayed in a window decoration. When set to a non-nil value
the image is not scaled to the size of the decoration (the default),
but is tiled across the decoration.

When images are scaled across border decorations the pixels that are
actually scaled are defined by the @dfn{border} of the image. The
border defines the outer rectangle of pixels that are left as-is, and
the inner rectangle which is scaled.

@defun image-border image
Returns a list of integers @code{(@var{left} @var{right} @var{top}
@var{bottom})}, the border of the image object @var{image}.

The number associated with each edge of the image defines the number of
pixels adjacent to that edge that @emph{will not} be scaled.
@end defun

@defun set-image-border image left right top bottom
Sets the border of @var{image}.

The number associated with each edge of the image defines the number of
pixels adjacent to that edge that @emph{will not} be scaled.
@end defun

The shape of the image may also be specified, this defines which pixels
are treated as being transparent. Each image may define a single color
as marking transparent pixels.

Image shapes are not supported under GDK Pixbuf.  Sawfish will
print a diagnostic message to @code{STDERR} if the function is called
without being supported.

@defun image-shape-color image
Return the color marking transparent pixels in @var{image}, or
@code{nil} if no such color has been specified.
@end defun

@defun set-image-shape-color image color
Specify that @var{color} marks transparent pixels in @var{image}.
@end defun

It's also possible to define @dfn{color modifiers} for each image.
These define the transformation applied to the value of each pixel when
it is displayed. Four different modifiers exist for each image, one for
each color component, and one for the image as a whole.

@defun image-modifier image type
Return the modifier defined by the symbol @var{type} of @var{image}, a
list of integers @code{(@var{gamma} @var{brightness} @var{contrast})}.
Each integer has a value between zero and 255 representing the weight
applied to the associated attribute when rendering the image.

The four types are @code{red}, @code{green}, @code{blue} and @code{nil}
(all colors).  The argument must be @code{eq} to one of those symbols.
@end defun

@defun set-image-modifier image type gamma brightness contrast
Set the image modifier of @var{image} defined by @var{type}.
@var{Type} may be one of the values of (not the symbols) @code{red},
@code{green} or @code{blue}.
@end defun

There are also several other functions manipulating images:

@defun bevel-image image border upwards &optional bevel-percent
Transform the edgemost pixels of @var{image} to give it a ``bevelled''
effect. @var{BORDER} is an integer defining the width of the bevel. If
@var{upwards} is non-nil the bevel is raised, otherwise it is lowered.

If @var{bevel-percent} is defined it specifies the height or depth of
the drawn bevel. When undefined, the value of the parameter is taken
from the @code{default-bevel-percent} variable.
@end defun

@defvar default-bevel-percent
Default height of drawn bevels, as a percentage.  Normally 50%.
@end defvar

@defun clear-image image &optional color
Set all pixels in @var{image} to @var{color} (or black if @var{color}
is undefined).
@end defun

@defun tile-image dest-image source-image
Tiles @var{source-image} into @var{dest-image}, starting from the
upper-left corner, working outwards.
@end defun

@defun scale-image image width height
Return a copy of @var{image}, scaled to @var{width} by @var{height}
pixels.
@end defun

@defun composite-images image1 image2 &optional x y
Copy the contents of @var{image2} into @var{image1}.  @var{Image2} is
cropped to fit.  Arguments @var{x} and @var{y} indicate the position
in @var{image1} of the top-left corner of @var{image2}.  If not
supplied, they default to 0.
@end defun

@defun crop-image image x y width height
Return a new image that is a rectangular section of @var{image}.  The
result image starts at pixel (@var{x}, @var{y}) in @var{image}, and
extends over @var{width} and @var{height} pixels in @var{image}.

When the cropped image extends beyond the boundary of @var{image}, the
behavior is undefined.
@end defun

The following functions allow users to manipulate images on a
pixel-by-pixel level.  They all use a list representation for pixels:
(@var{r}, @var{g}, @var{b}, @var{a}) indicating the red, green, blue
and alpha components

@defun image-ref image x y
Return a list (@var{r}, @var{g}, @var{b}, @var{a}) of the red, green,
blue and alpha components of the pixel (@var{x}, @var{y}) in
@var{image}.

When the pixel position extends outside the bounds of the image, the
behavior is undefined.
@end defun

@defun image-set image x y pixel
Set the pixel at (@var{x}, @var{y}) in @var{image} to @var{pixel}.
@var{Pixel} is a list of four numbers (@var{r}, @var{g}, @var{b},
@var{a}), the red, green, blue and alpha components.

When the pixel position extends outside the bounds of the image, the
behavior is undefined.
@end defun

@defun image-map xform image
Transform each pixel in @var{image} in place by calling @var{xform} on
each pixel in the image.

@var{Xform} takes a single argument, a four element list (@var{r},
@var{g}, @var{b}, @var{a}) indicating the red, green, blue and alpha
components of a pixel.  @var{Xform} should return the new value for
the pixel it was given.  The return format is the same four-element
list.

@var{Xform} is allowed to return @code{nil}.  In this case,
@code{image-map} immediately returns an invalid object.
@end defun

@defun image-fill generator image
Set each pixel in @var{image} based on the results of calling
@var{generator}.

@var{Generator} takes two arguments: the X and Y coordinates of a
pixel.  It returns a four element list (@var{r}, @var{g}, @var{b},
@var{a}) indicating the red, green, blue and alpha components of a
pixel.  This new pixel replaces the current pixel contents at (X, Y).

@var{Generator} is allowed to return @code{nil}.  In this case,
@code{image-map} immediately returns an invalid object.
@end defun

@defun pixmap-cache-control max
Tell Sawfish to cache no more than @var{max} pixels.  Returns a
four-element list indicating the current cache status:
@code{(@var{max-cached-pixels}, @var{cached-pixels}, @var{hits},
@var{misses})}.
@end defun


@node Cursors, Windows, Images, Top
@chapter Cursors
@cindex Cursors

Cursors define the shape and hot-spot of the mouse pointer's image.  A
lisp type is provided for manipulating these objects.  In addition,
Sawfish provides functions for manipulating the position of the
cursor.

@menu
* Cursor Appearance::
* Cursor Positioning::
@end menu

@node Cursor Appearance, Cursor Positioning, Cursors, Cursors
@section Cursor Appearance

@defun cursorp arg
Returns @code{t} if @var{arg} is a member of the cursor type.
@end defun

@defun get-cursor data
Returns the cursor object representing the cursor defined by
@var{data}. If @var{data} is a symbol, it's replaced by its
@code{cursor-shape} property.

Possible @var{data} values are an integer representing a glyph in the
standard X11 cursor font, or a four-element vector.

The format for a vector is @code{[@var{image} @var{mask} @var{fg}
@var{bg}]} where @var{image} and @var{mask} are the filenames of
standard X11 bitmaps, and @var{fg} and @var{bg} are colors (or names of
colors). All bitmap files are searched for using the
@code{image-load-path} variable.
@end defun

@defun recolor-cursor cursor fg bg
Change the colors of the cursor object @var{cursor} to @var{fg} and
@var{bg} (either color objects or the names of colors).
@end defun

@defun default-cursor &optional cursor
Set the cursor object displayed in the root window, and in parts of
window frames that have no other cursor specified, to @var{cursor}.

If called with no argument, simply return the current such cursor
object.
@end defun

So that the integer indices of glyphs in the X11 cursor font do not
have to be remembered, the @code{cursor-shape} properties of the
following symbols are automatically set:

@noindent
@code{X_cursor}, @code{arrow}, @code{based_arrow_down},
@code{based_arrow_up}, @code{boat}, @code{bogosity},
@code{bottom_left_corner}, @code{bottom_right_corner},
@code{bottom_side}, @code{bottom_tee}, @code{box_spiral},
@code{center_ptr}, @code{circle}, @code{clock}, @code{coffee_mug},
@code{cross}, @code{cross_reverse}, @code{crosshair},
@code{diamond_cross}, @code{dot}, @code{dotbox}, @code{double_arrow},
@code{draft_large}, @code{draft_small}, @code{draped_box},
@code{exchange}, @code{fleur}, @code{gobbler}, @code{gumby},
@code{hand1}, @code{hand2}, @code{heart}, @code{icon},
@code{iron_cross}, @code{left_ptr}, @code{left_side}, @code{left_tee},
@code{leftbutton}, @code{ll_angle}, @code{lr_angle}, @code{man},
@code{middlebutton}, @code{mouse}, @code{pencil}, @code{pirate},
@code{plus}, @code{question_arrow}, @code{right_ptr},
@code{right_side}, @code{right_tee}, @code{rightbutton},
@code{rtl_logo}, @code{sailboat}, @code{sb_down_arrow},
@code{sb_h_double_arrow}, @code{sb_left_arrow}, @code{sb_right_arrow},
@code{sb_up_arrow}, @code{sb_v_double_arrow}, @code{shuttle},
@code{sizing}, @code{spider}, @code{spraycan}, @code{star},
@code{target}, @code{tcross}, @code{top_left_arrow},
@code{top_left_corner}, @code{top_right_corner}, @code{top_side},
@code{top_tee}, @code{trek}, @code{ul_angle}, @code{umbrella},
@code{ur_angle}, @code{watch}, @code{xterm}.

The glyphs associated with these names are shown in Appendix I, of
Volume Two, @cite{Xlib Reference Manual}.

@node Cursor Positioning,  , Cursor Appearance, Cursors
@section Cursor Positioning

Sawfish provides one basic command for adjusting the relative position
of the cursor.

@defun move-cursor right down
Move the cursor @var{right} pixels to the right across the screen, and
@var{down} pixels down the screen.  The cursor stops at the edge of
the screen (although in multi-head environments, this may not be at
the edge of the display).
@end defun

There are also more specialized cursor movement commands.

@defun move-cursor-left-fine
@defunx move-cursor-right-fine
@defunx move-cursor-up-fine
@defunx move-cursor-down-fine
Move the cursor 1 pixel in the indicated direction.
@end defun

@defun move-cursor-left
@defunx move-cursor-right
@defunx move-cursor-up
@defunx move-cursor-down
Move the cursor @code{move-cursor-increment} pixels in the indicated
direction.
@end defun

@defvar move-cursor-increment 16
The @code{move-cursor-@var{DIRECTION}} functions move this cursor this
many pixels at a time.
@end defvar

@node Windows, Customization, Cursors, Top
@chapter Windows
@cindex Windows

One of the most important data types in sawfish is the window type. All
managed client windows have a single window object associated with
them.

@defun windowp arg
Returns @code{t} if @var{arg} is a member of the window type, and has a
client window associated with it.
@end defun

@defun managed-windows
Returns a list containing all managed window objects, in the order that
they were adopted by the window manager (first to last).
@end defun

@defun get-window-by-id xid
Return a window object with id @var{xid}, or @code{nil}.
@end defun

@defun get-window-by-name name
Return a window object with name @var{name}, or @code{nil}.
@end defun

@defun get-window-by-name-re name
Return a window object with name matching regular expression
@var{name}, or @code{nil}.
@end defun

@defun activate-window window
Do everything necessary to make @var{window} active, including raising
it, giving it focus, etc.  Certain steps may be skipped (e.g., giving
focus) if the window doesn't allow that operation.
@end defun

@defun filter-windows pred
Return the list of windows (mapped or unmapped) that match the
predicate function @var{pred}.
@end defun

@defun map-windows function
Call @code{(@var{function} @var{window})} on all existing windows.
Returns the value of the last @var{function} invocation.  If any
@var{function} returns @code{nil}, @code{map-windows} returns
@code{nil} immediately.
@end defun

@defun window-class window
Return the class that @var{window} belongs to as a string, or nil if
@var{window} has no associated class.
@end defun

@defun get-window-wm-protocols window
Return a list of symbols defining the X11 window manager protocols
supported by client @var{window}.
@end defun
@defun window-supports-wm-protocol-p window atom
Return true if @var{window} includes @var{atom} in its
@code{WM_PROTOCOLS} property.
@end defun

@menu
* Window Property Lists::
* Window Types::
* Window Attributes::
* Input Focus::
* X Properties::
* Window Stacking::
* Moving and Resizing Windows::
* Showing and Hiding Windows::
* Destroying Windows::
* Shading Windows::
* Iconifying Windows::
* Window Stickiness::
* Ignored Windows::
* Avoided Windows::
* Maximizing Windows::
* Animating Windows::
* Cycling Between Windows::
* Window Groups::
@end menu


@node Window Property Lists, Window Types, , Windows
@section Window Property Lists
@cindex  Window property lists
@cindex Property lists, of windows

Many window manager extensions need to be able to associate Lisp data
with individual windows. For example, the module handling iconification
needs to associate a boolean value with each window---whether that
window is iconified or not.

To solve this problem, Sawfish gives each window a property list. These
are exactly analogous to the property lists stored with each symbol
(@pxref{Property Lists, , Property Lists, librep, The Librep Manual});
they allow values to be associated with Lisp symbols, for a particular
window.

Note that these properties are different to the properties that X
stores with each window, since these properties are internal to the
window manager (@pxref{X Properties}).

For a list of the standard window properties, see @ref{Standard Properties}.

@defun window-put window property value
Set the lisp property named @var{property} (a symbol) associated with
window object @var{window} to @var{value}.  Note that these are Lisp
properties not X properties.
@end defun

@defun window-get window property &optional checker
Return the window property named @var{property} (a symbol) associated
with the window object @var{window}, or @code{nil} if no such property
exists.  Note that these are Lisp properties not X properties.

If the optional third argument @var{checker} is non-nil, then @var{checker}
is returned if the requested property does not exist. This is used to
distinguish the assigned value of @code{nil} from property's absence.
A symbol is usually a good choice for @var{checker}.
@end defun

@defun map-window-properties function window
Call @code{(@var{function} @var{property} @var{value})} on each of the
Lisp properties bound to @var{window}.  Returns the value of the last
@var{function} invocation.  If any @var{function} returns @code{nil},
@code{map-window-properties} returns @code{nil} immediately.
@end defun

@defun window-plist window
Returns the property list of the window @var{window} which is of the form
@code{(prop value prop value ...)}. 

Do not attempt to change properties by modifying the property list in place.
Use window-put instead.
@end defun

@defun window-remprop window property
Remove @var{property} of @var{window}. Returns @code{t} for success,
@code{nil} if the property did not exist.
@end defun

@node Window Types, Window Attributes, Window Property Lists, Windows
@section Window Types
@cindex Window types
@cindex Types, of windows
@cindex Windows, types of

Transient windows are pop-up or dialog windows associated with a main
application.  They tend to have less window decorations, and are
intended to last a short time only.

@defun window-transient-p arg
Returns @code{t} if @var{arg} represents a transient window.
@end defun

@defun mark-window-as-transient w
Mark that the window associated with object @var{w} is a transient
window.
@end defun

@defun transient-of-p child parent
Return true if window @var{child} is directly a transient for window
@var{parent}, false otherwise.
@end defun

@defun indirect-transient-of-p descendant ancestor
Return true if window @var{descendant} is (directly or indirectly) a
transient for window @var{ancestor}, false otherwise.
@end defun

@defun transient-parents child &optional indirectly
Return the list of windows that window @var{child} is a transient
for.  If @var{indirectly} is true, then return the list of all
ancestors rather than parents.
@end defun 

@defun transient-children parent &optional indirectly
Return the list of windows that are transients for window
@var{parent}.  If @var{indirectly} is true, then return the list of
all descendants rather than children.
@end defun

@defun transient-group window &optional by-depth
Return the list of windows which is either a transient window for
window @var{window}, or a window which @var{window} is a transient
for.  This always includes W.  The `transient window for' relation holds
for windows which are direct or indirect transients of the parent
window in question.

If the @var{by-depth} argument is true, then the retrurned list is in
stacking order.
@end defun

@defun map-transient-group fun window
Map the single argument function @var{fun} over all windows in the same
transient group as window @var{window}.
@end defun

@defun raise-window-and-transients window
Raise window @var{window} to its highest allowed position in the
stacking order.  Also raise any transient windows that it has.
@end defun

@defun lower-window-and-transients window
Lower window @var{window} to its lowest allowed position in the
stacking order.  Also lower any transient windows that it has.
@end defun

@defun raise-lower-window-and-transients window
If window @var{window} is at its highest possible position, then lower
it to its lowest possible position.  Otherwise raise it as far as
allowed.  Also changes the level of any transient windows it has.
@end defun

@defvr Customizable focus-windows-when-mapped
Focus on application windows when they first appear.  Defaults to
true, must be true or false.
@end defvr

@defvar decorate-transients
Decorate dialog windows similarly to application windows.  Defaults to
false.
@end defvar

Desktop windows are root windows or viewport windows.

@defun desktop-window-p arg
Returns @code{t} if @var{arg} represents a desktop window.
@end defun

@defun mark-window-as-desktop w
Mark that the window associated with object @var{w} is a desktop
window.
@end defun

@defvar desktop-window-properties
List of properties set (to true) on windows marked as desktops.
Defaults to
@lisp
'(fixed-position sticky sticky-viewport)
@end lisp
@end defvar

@defvar desktop-window-depth
The stacking depth of desktop windows.  Defaults to -4.
@end defvar

Dock windows are simply those with the @code{dock-type} property.
GNOME panels are one example.  Sawfish does not currently assign them
any special behavior.

@defun dock-window-p arg
Returns @code{t} if @var{arg} represents a dock window.
@end defun

@defun mark-window-as-dock w
Mark that the window associated with object @var{w} is a dock
window.
@end defun

@defvar dock-window-properties
List of properties set (to true) on windows marked as docks.
Defaults to
@lisp
'(window-list-skip cycle-skip fixed-position focus-click-through
  avoid no-history never-iconify never-maximize sticky
  sticky-viewport placed)
@end lisp
@end defvar

@defvar dock-window-depth
The stacking depth of dock windows.  Defaults to 0.
@end defvar

@node Window Attributes, Input Focus, Window Types, Windows
@section Window Attributes
@cindex Window attributes
@cindex Attributes, of windows
@cindex Windows, attributes of

@defun window-name window
Return the name associated with @var{window}.
@end defun

@defun window-full-name window
Return the full-name associated with @var{window}. This may or may not
be the same as the normal name.
@end defun

Sawfish provides functions to ensure that window names are unique.

@defun uniquify-name proposal existing
Uniquify the string @var{proposal} against the list of strings
@var{existing}.  Uses the format string @code{uniquify-name-format} to
generate unique names.
@end defun

@defvar uniquify-name-format
Format to create unique window names.  Defaults to @code{"%s [%d]"}.
@end defvar

@deffn Function uniquify-window-name window
@deffnx Command uniquify-window-name window
Force @var{window} to have a unique title.
@end deffn

@defun window-icon-name window
Return the icon name associated with @var{window}.
@end defun

@defun window-mapped-p window
Return @code{t} if the client window associated with object
@var{window} is mapped. (Note that this doesn't necessarily mean that
it is visible.)
@end defun

@defun window-transient-p window
Returns @code{nil} if @var{window} isn't marked as a transient window.
Otherwise returns an integer, the xid of the parent window.
@end defun

@defun window-shaped-p window
Return @code{t} if @var{window} is shaped (possibly not rectangular).
@end defun

@defun window-id window
If window object @var{window} has a client window associated with,
return an integer defining its xid, otherwise return @code{nil}.
@end defun

@defun root-window-id
Returns the numeric ID of the root window of the managed screen.
@end defun

@defun window-group-id window
If @var{window} is part of a group, return the X window id of the
leader of that group.  Otherwise return @code{nil}.
@end defun

@defun window-wants-input-p window
Return @code{t} when the client window associated with object
@var{window} has asked for the input focus to be assigned to it when
applicable (through the @code{input} field of its @code{WM_HINTS}
property).
@end defun

@defun window-really-wants-input-p window
Return @code{nil} if the client window associated with object
@var{window} should never be focused, @code{t} otherwise.
@end defun

@defun window-dimensions window
Returns a cons cell @code{(@var{width} . @var{height})} defining the
dimensions of the client window associated with object @var{window}.
@end defun

@defun window-position window
Returns a cons-cell @code{(@var{x} . @var{y})} defining the position
relative to the root window of @var{window}.
@end defun

@defun window-size-hints window
Return an alist defining the size-hints structure specified by the
client window associated with @var{window}. Possible keys in the alist
are @code{min-height}, @code{max-height}, @code{min-width},
@code{max-width}, @code{height-inc}, @code{width-inc},
@code{min-aspect}, @code{max-aspect}, @code{base-height},
@code{base-width}, @code{user-position}, @code{program-position},
@code{user-size}, @code{program-size}, @code{window-gravity},
@code{border-size}.
@end defun

@defun stacking-visibility window
Returns @code{unobscured} if @code{window} is unobscured,
@code{fully-obscured} if one or more windows completely obscure
@code{window}, or @code{partially-obscured} if one or more window
partially obscure @code{window}.

Deciding between fully and partially obscured can be expensive.  If
@code{window-obscured} satisfies your needs, use that in preference to
@code{stacking-visibility}.
@end defun

@defun window-obscured window
Returns @code{nil} if @code{window} is unobscured, @code{t} if
@code{window} is completely obscured by exactly one other window, or a
list of windows that partially obscure @code{window}.

If a list of partially obscuring windows is returned, taken together
they may or may not fully obscure @code{window}.
@end defun

@deffn {Obsolete Function} window-visibility window
Returns a symbol defining the current visibility of @var{window}.
Possible returned symbols are @code{fully-obscured},
@code{partially-obscured} or @code{unobscured}.

@code{window-visibility} is deprecated.  It is unreliable when using
the Composite extention, as every window is reported unobscured.  Use
@code{window-obscured} and @code{stacking-visibility} instead.
@end deffn

@defun window-urgent-p window
Return @code{t} if the ``Urgency'' hint of the window associated with
@var{window} is set.
@end defun


@node Input Focus, X Properties, Window Attributes, Windows
@section Input Focus
@cindex Input focus
@cindex Keyboard focus
@cindex Focus, input
@cindex Windows, input focus

The input focus defines exactly which client window will receive events
generated by the keyboard.

@defun input-focus
Returns the window object of the currently focused window, or
@code{nil} if no window is focused.
@end defun

@defun set-input-focus window
Sets the focus to the client window associated with @var{window}.

If @var{window} is @code{nil}, then no window will have the focus.
@end defun

The window manager is responsible for switching the input focus from
client window to client window.  Sawfish implements several
@dfn{focus modes} that provide this behavior.  Each focus mode is
bound to a symbol; the implementation is bound to that symbol's
@code{focus-mode} property slot.

@defvar focus-mode
Defines the current method of using the mouse to assign the input
focus.  This is a symbol from the list @code{focus-modes}.
@end defvar

@defvar focus-modes
A list containing all names of focus modes.  The built-in values are
@code{enter-exit}, @code{enter-only}, @code{enter-click} and @code{click}.
@end defvar

Focus mode @code{enter-exit} changes focus when the pointer enters a
window or leaves the focused window.  Focus mode @code{enter-only}
changes focus when the pointer enters a window, but not when it leaves
the focused window.  Focus mode @code{click} changes focus when you
click on a window.  Focus mode @code{enter-click} is the union of
@code{enter-only} and @code{click}, and changes focus on any
of their conditions.

It is possible to add additional focus modes by defining your own
handler function.  The handler function must obey a
``focus-mode-handler'' protocol.

@deftp {Function Protocol} focus-mode-handler window event-name &optional args
A function that implements the @code{focus-mode-handler} protocol can
be used to define a focus mode.  A @code{focus-mode-handler} responds
to events associated with windows.

Argument @var{window} is the window that received this event.

Argument @var{event-name} is one of the following symbols:

@table @code
@item pointer-in
@itemx pointer-out
The pointer has entered or exited the window.  The handler is
responsible for checking whether an entered window wants input events.
The desktop never receives @code{pointer-in} or @code{pointer-out};
only normal windows do.

@item
@item enter-root
@itemx leave-root
The pointer has entered or exited the desktop (which is the
@var{window} argument).  Normal windows never receive
@code{enter-root} or @code{leave-root}.

@item focus-in
@itemx focus-out
The window argument has gotten or lost focus.  Note that the
@code{focus-in} handler is not responsible for updating the
window-order list.

@item before-mode-change
@itemx after-mode-change
Sawfish sends these synthetic events to each window before/after
changing that window's focus mode.  When the global focus mode
changes, all windows get these events.

@item add-window
Sawfish sends this event to every window immediately after mapping it.
Handlers can use this to initialize window-internal data structures.

@item warp-if-necessary
Warp the cursor to the window if doing so would make the cursor
position ``consistent'' with the focus mode.  For example, in
@code{enter-exit} mode we warp the cursor if it is not already in this
window.  In @code{enter-only} mode, we warp the cursor if it is in
another window, but not if it is over the desktop---a window would not
lose focus when the cursor moved from it to the desktop.

This event is implemented via @code{warp-cursor-to-window}, so Sawfish
will not warp unless @code{warp-to-window-enabled} is true.

@item focus-revert
The focused window has disappeared (the @var{window} argument is not
used here).  The focus mode may react by setting focus to some other
window.  If a focused transient window disappears, focus normally
reverts to the window that the disappearing window was transient for.
@code{focus-revert} is not invoked in that case.
@end table

The protocol allows for any number of additional arguments, but does
not define any.  Any handler function must be prepared to receive and
ignore them.

Unsupported events may be ignored.  The return value of this function
is ignored.
@end deftp

@defun define-focus-mode name fun
Defines a new focus mode called @var{name} (a symbol).  The focus-mode
handler @var{fun} implements this focus mode.

See the documentation for @code{focus-mode-handler} for more
information.
@end defun

@defun set-focus-mode window mode
Set the focus mode of window @var{window} to @var{mode}.
This triggers @code{before-mode-change} and @code{after-mode-change}
focus-mode events on @var{window}.
@end defun

@defun warp-pointer-if-necessary window
Generate a @code{warp-if-necessary} event and sends it to the window's
focus function.

Various functions call @code{warp-pointer-if-necessary} if they move
the focused window out from underneath the pointer.
@end defun

@defvar focus-click-through
When in @code{click} focus mode, the focus-assigning click is only
passed through to the client window if this variable is @code{t} (the
default).

This option may be set on a per-window basis by setting the
@code{focus-click-through} property of the window (using the
@code{window-put} function).
@end defvar

@defvar focus-ignore-pointer-events
When true, pointer in/out events don't cause focus changes.  This is
independent of the current focus mode.
@end defvar

@defvar focus-within-click-event
When true, the current command is being called from within a
click-to-focus button press event.

This is a fluid object, not an ordinary variable.
@end defvar

Sawfish also maintains the order in which windows were recently
focused.

@defun window-order &optional workspace allow-iconified all-viewports
Return a list of windows, in most-recently-focused order.

If @var{workspace} is an integer, then only windows on that workspace
are included, otherwise all workspaces are searched.

If @var{allow-iconified} is non-nil, iconified windows are included. If
@code{all-viewports} is non-nil, then all viewports of the workspace(s)
are scanned.
@end defun

@defun window-order-push window
Push window object @var{window} onto the top of the focus stack.
@end defun

@defun window-order-pop window
Remove window object @var{window} from the focus stack.
@end defun

@defun window-order-most-recent &optional windows
Return the most-recently focused window in the current workspace.  If
the optional argument @var{windows} is given, it must be a list of
windows.  In that case, the function will return the most-recently
focused window from that list.
@end defun

@defun window-order-focus-most-recent
Focus the most-recently-focused window of the current workspace.
@end defun

@defvar focus-dont-push
When true, focusing a window doesn't change it's position in the stack of
most-recently focused windows.
@end defvar

@defun window-in-cycle-p window &keyword ignore-cycle-skip
Returns @code{t} if the window @var{window} should be included when
cycling between windows.  Desktop windows and those with the
@code{cycle-skip} property should normally not be included.

When @code{t}, the @var{ignore-cycle-skip} keyword argument
forces the function to include windows with the @code{cycle-skip}
property.
@end defun

@defun focus-push-map window keymap
@defunx focus-pop-map window
Maintain a two-element keymap stack for @var{window}.

@code{focus-push-map} makes @var{keymap} current for @var{window}, but
saves the existing keymap.  We can restore this existing keymap with
@code{focus-pop-map}.

These functions are intended to support click-to-focus.  They enforce
certain sanity rules: pushing into a two-element stack will only
overwrite the top element, while popping a one-element stack has no
effect.
@end defun

@defun autoload-focus-mode name func
MISSING.  This does not seem to be used anywhere, and its behavior is
unclear.
@end defun

@defun select-window
Waits for the user to left-click on a window, and returns that window.
The mouse cursor changes shape, and all normal input events are
suppressed until a window is selected.
@end defun

@defvar select-window-cursor-shape
The cursor shape to use when selecting a window.  Defaults to
@code{crosshair}.
@end defvar

@node X Properties, Window Stacking, Input Focus, Windows
@section X Properties
@cindex X properties
@cindex Properties, X
@cindex Windows, X properties

The X window system associates properties with windows (these are
totally separate to the properties that sawfish associates with window
@emph{objects}, @pxref{Window Property Lists}). Most inter-client
communication is performed through manipulation of these properties.

All functions defined below, that operate on X properties, accept their
@var{window} parameter as either a window object (denoting the
associated client window), the numeric xid of a window, or the symbol
@code{root} denoting the root window.

Sawfish represents X atoms (both the names and data types of  X
properties) as symbols. There is an exact correspondence between the
names of atoms and the name of the symbol representing them. For
example, the X atom @samp{STRING} is represented by the lisp symbol
@code{STRING}.

@defun list-x-properties window
Return a list of symbols defining the X properties set on @var{window}.
@end defun

@defun delete-x-property window property
Deletes the X property named @var{property} (a symbol) associated with
@var{window}.
@end defun

@defun get-x-property window property
Returns a list @code{(@var{type} @var{format} @var{data})} representing
the X property @var{property} of @var{window}. If no such property
exists, return nil.

@var{type} is the atom defining the type of the property. @var{format}
is an integer, either 8, 16 or 32, defining the number of bits in each
of the data items. @var{data} is an array, either a string for an 8-bit
format property, or a vector of integers otherwise.

If @var{type} is @code{ATOM} and @var{format} is 32, then @var{data}
will be a vector of symbols, representing the atoms read.
@end defun

@defun set-x-property window property data type format
Set the X property @var{property} of @var{window} to the array
@var{data}, either a string or a vector of integers.

@var{type} is a symbol representing the atom defining the type of the
property; @var{format} is either 8, 16 or 32 defining the number of
bits in the data values.

If @var{type} is @code{ATOM} and @var{format} is 32, then any symbols
in @var{data} will be converted to their numeric X atoms.
@end defun

The standard X property formats don't allow for an array of strings to
be stored, so these are often encoded as the strings concatenated,
separated by zero characters. These are usually called @dfn{text
properties}. Sawfish has two functions for manipulating them:

@defun get-x-text-property window property
Similar to @code{get-x-property}, but returns either @code{nil} or a
vector of strings.
@end defun

@defun set-x-text-property window property data
Sets the X text property @var{property} of @var{window} to the array
of strings @var{data}.
@end defun

It's also possible to detect when the value of any property associated
with a managed window changes, using the @code{property-notify-hook}.
@xref{Standard Hooks}.  The following convenience function takes
advantage of this hook:

@defun call-after-property-changed prop fun
Arrange for function @var{fun} to be called with arguments
@samp{(window property state)} when the X11 property named @var{prop}
(a symbol) changes.  @var{Prop} may also be a list of property names
to monitor.
@end defun


@node Window Stacking, Moving and Resizing Windows, X Properties, Windows
@section Window Stacking
@cindex Window stacking
@cindex Stacking, of windows
@cindex Windows, stacking

The stacking order of the display defines the order in which windows
are shown, from topmost to bottommost.  Sawfish maintains this list.
Raising or lowering windows changes their positions in this list.

@menu
* Stacking Order::
* Raising and Lowering Windows::
@end menu

@node Stacking Order, Raising and Lowering Windows, Window Stacking, Window Stacking
@subsection Stacking Order

@defun stacking-order
Return a list of window objects defining the current stacking order of
all client windows, from top-most to bottom-most.
@end defun

@defun mapped-stacking-order
Similar to @code{stacking-order}, but only returns windows that are
mapped.
@end defun

@defun restack-windows list
Restack all client windows specified in the list of window objects
@var{list} in the order they occur in the list (from top to bottom).
The stacking order of any unspecified windows isn't affected.
@end defun

Sawfish allows the stacking order to be managed as a sequence of
layers, with windows being assigned a particular depth within the
order. For any given window with depth @var{d}, it will be above all
windows with depth less than @var{d}, and below all windows with depth
greater than @var{d}. It may be above or below any other windows with
depth @var{d}.

The @code{depth} property of each window is used to store this depth. A
depth of zero is ``normal'', with negative depths stacked below, and
positive depths stacked above this normal level.

@defun stacking-order-by-depth depth
Similar to @code{stacking-order}, but only returns windows with depth
@var{depth}.
@end defun

@defun window-depth window
Returns the depth of @var{window}.
@end defun

@defun set-window-depth window depth
Sets the stacking depth of @var{window} to @var{depth}, then restacks
the windows to reflect this change.
@end defun

@defun window-on-top-p window
Returns @code{t} if @var{window} is at the top of its stacking depth.
@end defun

@defun stack-window-below below above
Change stacking order of window @var{below} so that it is immediately
below window @var{above}.
@end defun

@defun stack-window-above above below
Change stacking order of window @var{above} so that it is immediately
above window @var{below}.
@end defun

@defmac save-stacking-order &rest forms
Evaluate @var{forms} in an implicit @code{progn}, then restore the
original window stacking order, returning the value of the
@code{progn}.
@end defmac

@defun restack-window w
Assuming that the current stacking order is in a consistent state
except, possibly, for the position of window @var{w}, restore the
consistent state including window @var{w}. This is achieved by raising
or lowering window W as appropriate.
@end defun

@node Raising and Lowering Windows,  , Stacking Order, Window Stacking
@subsection Raising and Lowering Windows
@cindex Windows, raising
@cindex Windows, lowering

Over time, Sawfish has accumulated several subtle variations of
functions for raising and lowering windows.  One set of functions
operates on single windows.

@deffn Function lower-window window
@deffnx Command lower-single-window window
Lower @var{window} to the bottom of its stacking depth.
@end deffn

@deffn Function raise-window window
@deffnx Command raise-single-window window
Raise @var{window} to the top of its stacking depth.
@end deffn

@deffn Function raise-lower-window window
@deffnx Command raise-lower-single-window window
If @var{window} is the highest in its stacking level, lower it to the
bottom of this level, otherwise raise it to the top of its level.
@end deffn

Notice how the function name and command name for each pair differs
slightly.  Another set of functions supports operating on multiple windows
simultaneously.  Again, the function name and command name for each
pair is different.

@deffn Function lower-window* window
@deffnx Command lower-window window
Lower @var{window} and possibly associated windows to the bottom of
their stacking depths. 
@end deffn

@deffn Function raise-window* window
@deffnx Command raise-window window
Raise @var{window} and possibly associated windows to the top of their
stacking depth.
@end deffn

@deffn Function raise-lower-window* window
@deffnx Command raise-lower-window window
If @var{window} is the highest in its stacking level, lower it and
possibly associated windows to the bottom of their level, otherwise
raise them to the top of their level.
@end deffn

@defvar user-raise-type
Indicates which windows the @code{lower-window*}, @code{raise-window*}
and @code{raise-lower-window*} functions affect.  This variable can be

@table @code
@item none
Only the specific argument window is affected.
@item transients
The specific argument window and all of its transients are affected.
This is the default.
@item group
The specific argument window and all windows in its group are
affected.
@end table
@end defvar

@defun maybe-raise-window w
If window @var{w} supports the @code{_SAWFISH_WM_RAISE_WINDOW}
protocol, ask it whether it wants to raise itself or not.  Otherwise,
raise the window unconditionally.
@end defun

@defun maybe-lower-window w
If window @var{w} supports the @code{_SAWFISH_WM_LOWER_WINDOW}
protocol, ask it whether it wants to lower itself or not.  Otherwise,
lower the window unconditionally.
@end defun

Sawfish has more general operations that raising a window to the top
or lowering it to the bottom.  It can place a window relative to one
or more other managed windows.

@defun raise-windows w order
@defunx lower-windows w order
@defunx raise-lower-windows w order
Raise (or lower) all windows in @var{order}, such that items earlier in
the list are higher (or lower) than later items.  The window @var{w}
is special, always being the highest or lowest window, even if appears
in the middle of @var{order}.

For @code{raise-lower-windows}, if @var{w} would be raised or lowered,
then all the other windows are also raised or lowered.
@end defun

There are also functions (and associated commands) to change a
window's depth.

@deffn Function lower-window-depth window
@deffnx Command lower-window-depth window
Decrement the stacking depth of @var{window}.
@end deffn

@deffn Function raise-window-depth window
@deffnx Command raise-window-depth window
Increment the stacking depth of @var{window}.
@end deffn

Sawfish provides special support for ``click-to-focus'' mode, where
you may or may not want to raise the window or pass the click to the
underlying application.

@defun raise-and-pass-through-click w
Raise the window that received the current event with
@code{maybe-raise-window}.  Then replay any pointer events that
invoked the command.
@end defun

@defun raise-and-pass-through-click-if-focused w
Raise the window that received the current event (if it's focused)
with @code{maybe-raise-window}.  Then replay any pointer events that
invoked the command.
@end defun

@defun raise-or-pass-through-click w
If the window that received the current event is not on top, raise it
with @code{maybe-raise-window}.  Otherwise replay any pointer events
that invoked the command, sending them to the window.
@end defun

When the above commands are called interactively, Sawfish will try to
invoke them on the window that received the current event.  Failing
that, Sawfish will invoke them on the currently focused window.

@node Moving and Resizing Windows, Showing and Hiding Windows, Window Stacking, Windows
@section Moving and Resizing Windows
@cindex Moving and resizing windows
@cindex Resizing and moving windows
@cindex Windows, moving and resizing

As noted above (@pxref{Window Attributes}), the
@code{window-dimensions} and @code{window-position} functions return
the current configuration of a window.

@defun move-window-to window x y
Move the top-left corner of the window frame of @var{window} to
(@var{x}, @var{y}).
@end defun

@defun resize-window-to window width height
Set the dimensions of the client window associated with object
@var{window} to (@var{width}, @var{height}).
@end defun

@defun move-resize-window-to window x y width height
Move the top-left corner of the window frame of @var{window} to
(@var{x}, @var{y}), and set the dimensions of the frame to
(@var{width}, @var{height}).
@end defun

@defun resize-window-with-hints window cols rows &optional hints
@defunx resize-window-with-hints* window width height &optional hints
Resize the window associated with object @var{window} so that it has
certain X and Y dimensions.  For the first function, the dimensions
are @var{cols} columns and @var{rows} rows.   For the second function,
the dimensions are @var{width} pixels and @var{height} pixels.

The @var{hints} parameters is either the size hints alist to use, or
@code{nil} in which case the @code{window-size-hints} function is used
to retrieve the window's hints.
@end defun

Usually, however, it is left to the user to configure windows. The
following functions may be called interactively: their sole argument is
then either the window that received the current event or the currently
focused window.

Sawfish honors the @code{min-aspect} and @code{max-aspect} window
hints when interactively resizing a window.

@deffn Command move-window-interactively window
Move @var{window} interactively using the mouse. Releasing any mouse
button places the window at its current position.
@end deffn

@deffn Command resize-window-interactively window
Resize @var{window} interactively using the mouse. Releasing any mouse
button places the window at its current position.

Note that this function selects the edge or edges of the window to move
from the current position of the mouse when the resizing begins. The
window is divided into a three-by-three grid; the rectangle containing
the mouse pointer gives the direction to resize in. If the pointer is
in the central rectangle the bottom and right edges are moved.
@end deffn

@deffn Command move-selected-window
Wait for the user to select a window using the mouse, then
interactively move that window.
@end deffn

@deffn Command resize-selected-window
Wait for the user to select a window with the mouse, then interactively
resize that window.
@end deffn

The interactive move and resize behavior can be customized through the
following variables:

@defvar move-outline-mode
A symbol defining the visual method of interactively moving windows.
Current options include @code{box} for a wire-frame grid, and
@code{opaque} for full redisplay.
@end defvar

@defvar resize-outline-mode
A symbol defining the visual method of interactively resizing windows.
Current options include @code{box} for a wire-frame grid, and
@code{opaque} for full redisplay.
@end defvar

@defvar move-show-position
When non-nil, the current window position is shown in the center of the
screen.
@end defvar

@defvar resize-show-position
When non-nil, the window size is shown in the center of the screen.
@end defvar

@defvar move-snap-edges
When non-nil, the window position is ``snapped'' to edges of other
windows within close proximity.
@end defvar

@defvar move-snap-epsilon
The distance in pixels before snapping together two edges.
@end defvar

Windows have a ``gravity'' property, which affect how they are placed
in particular positions.

@defun window-gravity window &optional hints
Returns the gravity of window.  The order of precedence is Sawfish
@code{gravity} window property, explicit @var{hints} argument, X
window size hints.  The default gravity when nothing else is specified
is @code{north-west} (specified by ICCCM).
@end defun

@node Showing and Hiding Windows, Destroying Windows, Moving and Resizing Windows, Windows
@section Showing and Hiding Windows
@cindex Showing and hiding windows
@cindex Hiding and showing windows
@cindex Windows, showing and hiding

Sawfish provides two low-level functions for withdrawing client windows
from the display. These are used to implement both virtual workspaces
(@pxref{Workspaces}) and iconification (@pxref{Iconifying Windows}).

@defun hide-window window
Prevent object @var{window} from being displayed.  See
@code{show-window}.
@end defun

@defun show-window window
Ensure that @var{window} (if it has been mapped, and is within the
screen boundary) is visible.  See @code{hide-window}.
@end defun

@defun window-visible-p window
Returns @code{t} if object @var{window} has not been hidden by the
@code{hide-window} function.
@end defun


@node Destroying Windows, Shading Windows, Showing and Hiding Windows, Windows
@section Destroying Windows
@cindex Destroying windows
@cindex Windows, destroying

There are several methods through which X11 client windows may be
removed from the display. These differ in the level ``politeness'' they
show the window and its owning application.

@deffn Command delete-window window
Delete @var{window}, i.e. send a @code{WM_DELETE_WINDOW} client-message
if possible, or just kill the associated X11 client if not.
@var{window} may be a window object or a numeric window id.
@end deffn

@deffn Command delete-window-safely window
If the application owning @var{window} supports it, send a
@code{WM_DELETE_WINDOW} message to @var{window}. Otherwise just emit a
beep.
@end deffn

@deffn Command destroy-window window
Destroy @var{window} without giving the owning application any warning.
@var{window} may be a window object or a numeric window id.
@end deffn

@defun x-kill-client window
Force a close down of the X11 client that created the window specified
by @var{window} (a window object, or numeric id).
@end defun

When a managed window is destroyed, the @code{destroy-notify-hook} will
subsequently be invoked (@pxref{Standard Hooks}).

@node Shading Windows, Iconifying Windows, Destroying Windows, Windows
@section Shading Windows
@cindex Shading windows
@cindex Windows, shading

Many window managers allow a window to be @dfn{shaded}; when in this
state only the title bar of the window is visible.

@defun window-shaded-p window
Returns true when @var{window} is shaded, false otherwise.
@end defun

@deffn Command shade-window window
Arrange for only the title bar of @var{window} to be visible.
@end deffn

@deffn Command unshade-window window
If the window is shaded, restore it to it's original state.
@end deffn

@deffn Command toggle-window-shaded
Toggle the shaded state of the window.
@end deffn

@defvar raise-windows-when-unshaded nil
When true, raise windows when they are unshaded.  Defaults to false.
@end defvar

The @code{shaded} property of a window is set to @code{t} when the
window is shaded. If a window is added with this property already set,
then the window will appear in its shaded state.


@node Iconifying Windows, Window Stickiness, Shading Windows, Windows
@section Iconifying Windows
@cindex Iconifying windows
@cindex Windows, iconifying

X defines an iconic state for windows, often windows in this state are
displayed as small icons. Sawfish does not display these icons, instead
iconified windows are shown slightly differently in the menu of all
windows.

@deffn Command iconify-window window
Iconify the window associated with object @var{window}.
@end deffn

@deffn Command uniconify-window window
Return the window associated with @var{window} from its iconified state.
@end deffn

@deffn Command toggle-window-iconified window
Minimize the window associated with @var{window}, or restore it if it
is already minimized.
@end deffn

@deffn Command iconify-workspace-windows
Minimize all windows in the current workspace.
@end deffn

A window's iconic state may be tested through examination of its
@code{iconified} property---when @code{t} the window is iconified.
But it is preferable to use explicit testing functions instead:

@defun window-iconified-p window
Returns true if the window associated with @var{window} is iconified,
false otherwise.
@end defun

@defun window-iconifiable-p window
Returns true if the window associated with @var{window} can be
iconified, false otherwise.  Some reasons a window might not be
iconifiable are: it has a @code{never-iconify} property; it is
already iconified; it is not a desktop window; or it is marked
@code{ignored} and @code{iconify-ignored} is not true.
@end defun

@defvar iconify-ignored nil
Unmanaged (@code{ignored}) windows may be iconified.  Defaults to nil.
@end defvar

Sawfish allows you to control certain behaviors when restoring
minimized windows.

@defvar focus-windows-on-uniconify
Windows are focused after being unminimized.  Defaults to false.
@end defvar

@defvar raise-windows-on-uniconify
Windows are raised after being unminimized.  Defaults to true.
@end defvar

@defvar uniconify-to-current-workspace
Move windows to the current workspace when they are unminimized.
Defaults to true.
@end defvar

When iconifying, it is possible to force other windows to iconify.

@defvr Customizable iconify-group-mode
@defvrx Customizable uniconify-group-mode
Policy for performing chains of minimizations or restorations.  When a
particular window is minimized or restored, it can cause other windows
to be minimized or restored at the same time.  Their allowed values
are set to the following list.  By default, both variables are bound
to the symbol @code{transients}. but they are not required to have the
same value.
@end defvr

@table @code
@item none
No additional windows are minimized or restored.
@item transients
All transient windows associated with the target window are minimized
or restored.
@item group
All windows in the target window's group are minimized or restored.
@end table

Finally, it's possible to get the icon that would normally be
displayed for an iconified window.

@defun window-icon-image window
Return an image object representing the icon currently associated with
@var{window}, or @code{nil} if there is no such image.
@end defun

@node Window Stickiness, Ignored Windows, Iconifying Windows, Windows
@section Window Stickiness
@cindex Window stickiness
@cindex Sticky, windows

Windows normally exist in a single workspace and a single viewport
into that workspace.  When changing workspace or viewport, the current
windows disappear.  This is sometimes not the correct policy; there
are certain windows that should ``follow'' the user from window to
window.  These are typically windows that are not bound to a
particular activity.  The most common example is a dashboard window
for calling other applications.  Another example might be a diagnostic
program such as a load monitory.

Each window has ``stickiness'' flags that govern this behavior.  One
flag controls stickiness across workspaces: sticky windows will appear
in every workspace automatically.  The other flag similarly governs
stickiness across viewports.  A window is ``sticky'' if either of
these flags are set.

Sticky windows are often @code{ignored}, so they lack window
decorations, and @code{avoid}ed so other windows do not cover them up.

@defun window-sticky-p/workspace window
@defunx window-sticky-p/viewport window
@defunx window-sticky-p window
Returns true if @var{window} is sticky across a particular environment
(workspaces, viewports, or either), false otherwise.
@end defun

@defun make-window-sticky/workspace window
@defunx make-window-sticky/viewport window
@defunx make-window-sticky window
Make the @var{window} sticky across some environment (workspaces,
viewports, or both).
@end defun

@defun make-window-unsticky/workspace window
@defunx make-window-unsticky/viewport window
@defunx make-window-unsticky window
Make the @var{window} unsticky across some environment (workspaces,
viewports or both).
@end defun

@defun toggle-window-sticky window
If @code{window-sticky-p} would report true for @var{window}, make
@var{window} unsticky for all environments.  Otherwise make it sticky
for all environments.
@end defun

@node Ignored Windows, Avoided Windows, Window Stickiness, Windows
@section Ignored Windows
@cindex Windows, ignored
@cindex ignored

Sawfish has a general concept of ``ignored'' windows; the user does
not interact normally with those windows.  The concept is actually
defined by five different window properties:

@table @code
@item ignored
The window does not receive frames.

@item never-focus
The window never receives the input focus.

@item cycle-skip
The window is ignored while window cycling.

@item window-list-skip
The window will not be included in the window list.

@item task-list-skip
The window will not be included in the task list.

@end table

A monitor application such as ``xload'' might have all five of these
flags set.

Rather than directly manipulating the window properties, it is better
to use the following access functions:

@defun window-ignored-p window
Returns true if the window has the @code{ignored} property, false
otherwise.
@end defun

@deffn Command make-window-ignored window
Ignore the window @var{window}.
@end deffn

@deffn Command make-window-not-ignored window
Unignore the window @var{window}.
@end deffn

@deffn Command toggle-window-ignored window
If @code{window-ignored-p} would return true for @var{window}, make it
unignored.  Otherwise make it ignored.
@end deffn

The remaining flags only have toggle functions implemented right now:

@deffn Command toggle-window-never-focus window
@deffnx Command toggle-window-cycle-skip window
@deffnx Command toggle-window-list-skip window
@deffnx Command toggle-task-list-skip window
Toggle the appropriate flag on @var{window}.
@end deffn

All five of the flags are available through the window menu's
``Toggle'' entry.

@node Avoided Windows, Maximizing Windows, Ignored Windows, Windows
@section Avoided Windows
@cindex Windows, avoided
@cindex avoid

``Avoided'' windows are kept unobscured by other windows
wherever possible. It is involved in window placement (@pxref{Window
Placement}) and maximization (@pxref{Maximizing Windows}).
Most placement modes will attempt to place a new window avoiding
overlap with them. Windows can be maximized avoiding overlap to
avoided windows.

In this context, windows are categorized into three: windows with
@code{avoid} property, those with
@code{ignored} property (@pxref{Ignored Windows}), and the others.

It is possible to avoid overlap only with avoided windows, and
also is possible @emph{not} to avoid overlap only with ignored windows.

Remember that the window with @code{avoid} property is @emph{avoided}
by @emph{other} windows. Thus property name @code{avoid} should have
been named ``avoided''. On the other hand, related functions and
variables are named correctly, and no special care is necessary.

@defvar dont-avoid-ignored
When non-nil (the default), ignored windows aren't avoided.
@end defvar

@defvar avoid-by-default
When non-nil, any windows are avoided. Defaults to nil.
@end defvar

@defun window-avoided-p window
Returns t if @var{window} is avoided by other windows.
It is determined in the following order:

@enumerate
@item A window with @code{avoid} property is always avoided.
@item A window with @code{ignored} property is always @emph{not} avoided
unless @code{dont-avoid-ignored} is non-nil.
@item Otherwise, @code{avoid-by-default} determines if it should be avoided.
@end enumerate
@end defun

@defun avoided-windows &optional window
Returns a list of all windows that are avoided. If
@var{window} is defined, then it is excluded from the returned list.
@end defun

@node Maximizing Windows, Animating Windows, Avoided Windows, Windows
@section Maximizing Windows
@cindex Maximizing windows
@cindex Windows, maximizing

The dimensions of a window may be temporarily @dfn{maximized},
stretching as far as possible within the screen in one or two dimensions.

@defun window-maximizable-p window &optional direcion hints
Return @code{t} when @var{window} is maximizable. The window property
@var{never-maximize} prevents maximization.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.

The optional argument @var{hints} overrides the window's hints.
@end defun

@defun window-maximized-p window
Return @code{t} when @var{window} is maximized in any direction.
@end defun

@defun window-maximized-vertically-p window
Return @code{t} when @var{window} is vertically maximized.
@end defun

@defun window-maximized-horizontally-p window
Return @code{t} when @var{window} is horizontally maximized.
@end defun

@menu
* Basic Maximizations::         
* Maximizing Without Overlap::
* Maximizing Without Borders::  
* Unmaximizing::                
@end menu

@node Basic Maximizations, Maximizing Without Overlap, Maximizing Windows, Maximizing Windows
@subsection Basic Maximizations

Ordinary maximization occurs on the current screen, and possibly
rounding down to fit character sizes.

@deffn Function maximize-window window &optional direction only-1d
@deffnx Command maximize-window window
Maximize both dimensions of @var{window} on the screen.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.

The optional argument @var{only-1d} is for internal use. Don't use it.
@end deffn

@deffn Function maximize-window-vertically window
@deffnx Command maximize-window-vertically window
Maximize the vertical dimension of @var{window} in the screen.
@end deffn

@deffn Function maximize-window-horizontally window
@deffnx Command maximize-window-horizontally window
Maximize the horizontal dimension of @var{window} in the screen.
@end deffn

@deffn Function maximize-window-toggle window &optional direction
@deffnx Command maximize-window-toggle window
Toggle the state of @var{window} between maximized and unmaximized
in the screen.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.
@end deffn

@deffn Function maximize-window-vertically-toggle window
@deffnx Command maximize-window-vertically-toggle window
Toggle the state of @var{window} between vertically maximized and
unmaximized in the screen.
@end deffn

@deffn Function maximize-window-horizontally-toggle window
@deffnx Command maximize-window-horizontally-toggle window
Toggle the state of @var{window} between horizontally maximized and
unmaximized in the screen.
@end deffn

@defvr Customizable move-lock-when-maximized
When true (the default), Sawfish will not allow the user to manually
resize maximized windows.  It will also prevent the user from moving
the windows along their maximized axes.

For example, a vertically maximized window is vertically locked, so a
user can slide it left and right, but cannot move it up or down.
@end defvr

@defun window-locked-vertically-p window
Return @code{t} when @var{window} is vertically locked.
@end defun

@defun frame-part-movable-p window part
Return @code{t} if the @var{part} of @var{window} can be moved.

@var{part} is one of the symbols: @code{top-border},
@code{bottom-border}, @code{left-border}, @code{right-border},
@code{top-left-corner}, @code{top-right-corner},
@code{bottom-left-corner}, @code{bottom-right-corner}, or
@code{title} 
@end defun

@defvar maximize-raises
When true (the default), maximizing a window raises it as well.
@end defvar

@defvar maximize-always-expands
In general, if a window's dimension is larger than the screen size,
maximizing that dimension can actually shrink it to fit into the
screen.  When this variable is true (default false), maximizing a
window's dimension will never shrink it.
@end defvar

@node Maximizing Without Overlap, Maximizing Without Borders, Basic Maximizations, Maximizing Windows
@subsection Maximizing Without Overlap

It is possible to maximize a window where it gets only large enough
not to overlap with other windows. 

@defvar maximize-avoid-avoided
When true (the default), maximized window does not cover avoided
windows. (@pxref{Avoided Windows})
@end defvar

The ``fill'' category of maximizing commands provides a convenient way to
maximize without overlap to any other windows, except ``ignored'' ones.
(@pxref{Ignored Windows})

In addition, they don't shrink the window even if it is already bigger
than the screen size.

@deffn Function maximize-fill-window window &optional direction
@deffnx Command maximize-fill-window window
Maximize both dimensions of @var{window} without overlapping other
windows.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.
@end deffn

@deffn Function maximize-fill-window-vertically window
@deffnx Command maximize-fill-window-vertically window
Maximize the vertical dimension of @var{window} in the screen without
overlapping other windows.
@end deffn

@deffn Function maximize-fill-window-horizontally window
@deffnx Command maximize-fill-window-horizontally window
Maximize the horizontal dimension of @var{window} in the screen
without overlapping other windows.
@end deffn

@deffn Function maximize-fill-window-toggle window
@deffnx Command maximize-fill-window-toggle window
Toggle the state of @var{window} between maximized and unmaximized in
the screen without overlapping other windows.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.
@end deffn

@deffn Function maximize-fill-window-vertically-toggle window
@deffnx Command maximize-fill-window-vertically-toggle window
Toggle the state of @var{window} between vertically maximized and
unmaximized in the screen without overlapping other windows.
@end deffn

@deffn Function maximize-fill-window-horizontally-toggle window
@deffnx Command maximize-fill-window-horizontally-toggle window
Toggle the state of @var{window} between horizontally maximized and
unmaximized in the screen without overlapping other windows.
@end deffn

@defvar maximize-ignore-when-filling
For ``filling'' maximization, ``ignored'' windows are ignored when true
(the default). (@pxref{Ignored Windows})
@end defvar

@node Maximizing Without Borders, Unmaximizing, Maximizing Without Overlap, Maximizing Windows
@subsection Maximizing Without Borders

The ``fullscreen'' and ``fullxinerama'' categories of maximizing
commands maximize the window to some extent and remove all the
window's decorations.  If necessary, Sawfish will pad the bottom and
right window edges to make the window fill the complete extent.  (This
is usually required for terminal windows, for example.)

The ``fullscreen'' category maximizes the window to the current
screen.

@deffn Function maximize-window-fullscreen window
@deffnx Command maximize-window-fullscreen window
Maximize both dimensions of @var{window} on the screen, removing
window decorations and making the window edges flush with the screen
sides.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.
@end deffn

@deffn Function maximize-window-fullscreen-toggle window
@deffnx Command maximize-window-fullscreen-toggle window
Toggle the state of @var{window} between maximized and unmaximized in
the screen, removing window decorations and making the window edges
flush with the screen sides.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.
@end deffn

The ``fullxinerama'' category maximizes the window to the entire
Xinerama display.

@deffn Function maximize-window-fullxinerama window
@deffnx Command maximize-window-fullxinerama window
Maximize both dimensions of @var{window} across all Xinerama screens,
removing window decorations and making the window edges flush with the
screen sides.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.
@end deffn

@deffn Function maximize-window-fullxinerama-toggle window
@deffnx Command maximize-window-fullxinerama-toggle window
Toggle the state of @var{window} between maximized and unmaximized
across all Xinerama screeens, removing window decorations and making
the window edges flush with the screen sides.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.
@end deffn

@node Unmaximizing,  , Maximizing Without Borders, Maximizing Windows
@subsection Unmaximizing

One command restores windows from all the different types of
maximization.

@deffn Command unmaximize-window window &optional direction
Restore the position and dimensions of @var{window} to their original,
unmaximized, states.

Positions and dimensions that were not maximized are not affected by
unmaximizing.

If defined, @var{direction} is a symbol, either @code{vertical} or
@code{horizontal}, and maximization will only occur for that
direction.
@end deffn

@defun window-unmaximized-position window
Returns a cons-cell @code{(@var{x} . @var{y})} indicating the position
that the @code{window} would unmaximize to.

Sawfish preserves the positions of maximized axes only, so a
vertically maximized window will be restored to its original @var{y}
coordinate, but its @var{x} coordinate may have changed.
@end defun

@defun window-unmaximized-dimensions window
Returns a cons-cell @code{(@var{w} . @var{h})} indicating the
dimensions that @code{window} would unmaximize to.

Sawfish preserves the dimensions of maximized axes only, so a
vertically maximized window will be restored to its original @var{h}
dimension, but its @var{w} coordinate may have changed.
@end defun

@node Animating Windows, Cycling Between Windows, Maximizing Windows, Windows
@section Animating Windows
@cindex Windows, Animating

Sawfish provides certain window animation capabilities.  They have
been described as ``lame'', so they are off by default.

@defvar default-window-animator
The default window animation mode, used if a window has no explicit
animation set.  Normally @code{none}.
@end defvar

@defun define-window-animator name fun
Define a window animator called @var{name} (a symbol) that is managed
by function @var{fun}. @var{fun} is called as @samp{(fun window op
[action])} when it should change the state of an animation sequence.
@var{Op} may be one of the symbols @code{start}, @code{stop}.
@end defun

@defun autoload-window-animator name struct
Construct an autoloader for window animator @var{name} from structure
@var{struct}.
@end defun

@defun run-window-animator window action
Invoke an animation for action @var{action} on @var{window}.
@var{Action} may be one of the symbols @code{start}, @code{stop}.
@end defun

@defun record-window-animator window animator
Note that @var{window} currently has an animation running, being
controlled by animator function @var{animator}.
@end defun

@node Cycling Between Windows, Window Groups, Animating Windows, Windows
@section Cycling Between Windows
@cindex Windows, cycling between

Sawfish provides two categories of commands for cycling between
windows.  The first category cycles between windows in an order that
is essentially fixed.  The second category cycles between windows in a
dynamic order.

@menu
* Fixed Window Cycles::
* Dynamic Window Cycles::
@end menu

@node Fixed Window Cycles, Dynamic Window Cycles, Cycling Between Windows, Cycling Between Windows
@subsection Fixed Window Cycles
@cindex Window cycles, fixed

These commands organize the set of mangaged windows into loops.  A
loop may consist of all windows in a workspace, or it may consist of
all windows anywhere.  The positions of windows in this loop do not
change, except when a new window is managed or unmanaged.

@defun next-workspace-window
@defunx previous-workspace-window
Switch focus to the ``next'' or ``previous'' window in the current
workspace.
@end defun

@defun next-window
@defunx previous-window
Switch focus to the ``next'' or ``previous'' window in this
workspace.  If this function reaches the ``end'' of the windows in
this workspace, it switches to the next workspace and displays the
first window there.
@end defun

@node Dynamic Window Cycles,  , Fixed Window Cycles, Cycling Between Windows
@subsection Dynamic Window Cycles
@cindex Window cycles, dynamic

These commands implement something much close to Microsoft Windows'
@key{Alt-TAB} mechanism, working with a stack of recently used
windows.

@defun cycle-windows
@defunx cycle-windows-backwards
Cycle through all cycleable windows.
@end defun

@defun cycle-group
@defunx cycle-group-backwards
Cycle through all windows in this group.

This is somewhat comparable to the @key{Control-TAB} behavior of
windows.
@end defun

@defun cycle-prefix
@defunx cycle-prefix-backwards
Cycle through all windows whose titles match that of the initial
window (up to, but not including, the first colon).
@end defun

@defun cycle-class
@defunx cycle-class-backwards
Cycle through all windows whose classes match that of the initial
window.
@end defun

@defun cycle-dock
@defunx cycle-dock-backwards
Cycle through all windows in the dock, even those with the
@code{cycle-skip} property.
@end defun

Each of these cycling commands may include windows that are not
visible on-screen.

@defvar cycle-include-iconified
If true, Sawfish includes iconified windows when cycling.  Defaults to
true.
@end defvar

@defvar cycle-all-workspaces
If true, Sawfish includes windows on all workspaces when cycling.
Defaults to false.
@end defvar

@defvar cycle-all-viewports
If true, Sawfish includes windows on all viewports when cycling.
Defaults to false.
@end defvar

It is possible to configure the cycling to get more feedback during
the process.

@defvar cycle-show-window-names
If true, Sawfish displays window names and icons while cycling through
windows.  Defaults to true.
@end defvar

@defvar cycle-raise-windows t
If true, Sawfish raises windows while they're temporarily selected
during cycling, and invokes @code{warp-pointer-if-necessary}.
Defaults to true.
@end defvar

It is also possible for you to define your own stacking cycle
commands, or even to alter the window stack to suit your tastes.

@defun define-cycle-command name body &rest rest
Create a command that will not cause the current cycle operation
to abort before execution.

All arguments are passed to define-command.
@end defun

@defun define-cycle-command-pair forward-name reverse-name selector &rest rest
Create a pair of commands for cycling through windows. The command named
@var{forward-name} cycles forwards, while the command named
@var{reverse-name} cycles backwards.

@var{Selector} is called when initializing the cycle environment, it
should return the list of windows to cycle through, or the symbol `t'
to denote all cyclable windows.

Any extra arguments are passed to each call to define-command.
@end defun

@defun window-order &optional workspace allow-iconified all-viewports
Return managed windows in most-recently used order.

If @var{workspace} is non-nil, then only managed windows in that
workspace will be returned.

If @var{allow-iconified} is non-nil, then iconified windows will be
returned instead of ignored.

If @var{all-viewports} is non-nil, then windows in all viewports will
be returned, instead of just the current viewport.
@end defun

@defun window-order-push w
Push window @var{w} onto the top of the cycle stack.
@end defun

@defun window-order-pop w
Remove window @var{w} from the cycle stack.
@end defun

@defun window-order-most-recent &key windows
Return the most-recently focused window in the current workspace.  If
the @var{windows} argument is given it should be a list of windows, in
this case the function will restrict its search to the elements of
this list.
@end defun

@defun window-order-focus-most-recent
Switch input focus to the most-recently focused window in the current
workspace.
@end defun

@node Window Groups,  , Cycling Between Windows, Windows
@section Window Groups
@cindex Groups, windows

Sawfish provides extra tools and commands for dealing with ICCCM
groups.  Most ``normal'' groups work the same way as they do in the
ICCCM standard: windows have a group property that is set to the X
window ID of the group leader.  These are ``group IDs'', and they are
always positive integers.  In addition, Sawfish allows group IDs to
be:

@table @asis
@item negative integers
These are anonymous user-defined groups.
@item symbols
These are named user-defined groups.  Named user-defined groups are
saved as part of window properties when saving sessions.
@end table

@defun window-group-ids
Return the list of all group ids.
@end defun

There may be certain named groups that always exist, whether or not
any window belongs to them.

@defvar peristent-group-ids
A list of symbols naming groups that always exist.
@end defvar

In any case, a window is limited to belonging to one group, and always
belongs to one group.

@menu
* Assigning Windows to Groups::
* Operations on Groups::
@end menu

@node Assigning Windows to Groups, Operations on Groups, Window Groups, Window Groups
@subsection Assigning Windows to Groups
@cindex Groups, assigning windows to

It is possible to change the group of a window in Sawfish.  Use
@code{add-window-to-group}, or if necessary you can set the window's
@code{group} property explicitly.

@defun add-window-to-group window group-id
Place @var{window} in group @var{group-id}, replacing any previous
group membership.  If @var{group-id} is @code{nil}, then Sawfish
returns the window to whatever group membership was supplied by ICCCM.
@end defun

@defun add-window-to-new-group window
Place @var{window} into a new group, which will have @var{window} as
its sole member.  This is an anonymous user-defined group.  The new
group ID is returned.
@end defun

The Sawfish group assignment never overrides the ICCCM group
assignment, just suppresses it.  The @code{window-actual-group-id}
function implements this overriding.

@defun window-actual-group-id window
Return the (Sawfish) group ID for @var{window}.  This is, in order of
preference:
@itemize @bullet
@item The group ID assigned by Sawfish
@item The group ID passed in by ICCCM.
@item The corresponding values for an owning window, if the given window is transient.
@item The window's own window ID.
@end itemize

This means that a window is, at the very least, part of its own group.
@end defun

Each of the following functions operates on the ``actual group ID'' as
returned by the above function.

@defun windows-by-group group-id &optional by-depth
Return the list of windows in the group with id @var{group-id}.
If @var{by-depth} is non-nil, then return the windows in order of
stacking, from topmost to bottommost.
@end defun

@defun windows-in-group w &optional by-depth
Return the list of windows in the same group as window @var{w}.
If @var{by-depth} is non-nil, then return the windows in order of
stacking, from topmost to bottommost.
@end defun

@defun map-window-group fun w
Map the single argument function @var{fun} over all windows in the
same group as window @var{w}.  Note that @var{fun} needs to operate
using side-effects, rather than returning values.
@end defun

@defun map-other-window-groups fun w
Map the single argument function @var{fun} over all windows not in the
same group as window @var{w}.  Note that @var{fun} needs to operate
using side-effects, rather than returning values.
@end defun

@defun window-group-menu &optional w
Return a menu definition suitable for @code{popup-menu}.  This menu
will allow the user to assign the window @var{w} into any group of a
managed window, or into a brand new group.  The window's current group 
is checked or otherwise marked.
@end defun

@node Operations on Groups,  , Assigning Windows to Groups, Window Groups
@subsection Operations on Groups
@cindex Groups, operations on

Most of the window manipulation functions that operate on windows are
also available for window groups.  Each of these functions takes a
window as argument; the affected group is that window's group.

@defun iconify-group w
@defunx uniconify-group w
@defunx iconify-transient-group w
@defunx uniconify-transient-group w
These operate like their single-window counterparts.  They work by
temporarily rebinding @code{iconify-group-mode} and
@code{uniconify-group-mode}.
@end defun

@defun make-group-sticky w
@defunx make-group-unsticky w
These operate like their single-window counterparts.
@end defun

@defun toggle-group-sticky w
If window @var{w} is sticky, all windows in its group have their
stickyness removed.  Otherwise all windows in its group become sticky.
@end defun

@defun send-group-to-workspace w workspace
@defunx send-group-to-next-workspace w count
@defunx send-group-to-previous-workspace w count
These operate like their single-window counterparts.
@end defun

@defun send-group-to-current-workspace w
All windows in the group of @var{w} are moved from their existing
workspaces to the nearest workspace that @var{w} is in.  Sticky
windows are not affected.  If the window had the input focus and it is
visible after the move, it retains the input focus.
@end defun

@defun move-group-to-current-viewport w
@defunx move-group-viewport w
@end defun

@defun move-group-left w
@defunx move-group-right w
@defunx move-group-up w
@defunx move-group-down w
These operate like their single-window counterparts.
@end defun

@defun raise-group w
@defunx lower-group w
@defunx raise-lower-group w
@defunx raise-group-depth w
@defunx lower-group-depth w
These operate like their single-window counterparts.
@end defun

@defun set-group-frame-style w style
This operates like its single-window counterpart.
@end defun

@node Customization, Window Frames, Windows, Top
@chapter Customization
@cindex Customization

Sawfish provides two levels of configuration:

@enumerate
@item @dfn{customization}: setting variables to change the behavior of
existing features of the window manager, and,

@item @dfn{extensibility}: the ability to add entirely new features to
the window manager through the creation of new Lisp modules.
@end enumerate

Obviously the first of these requires a lot less specialized knowledge
than the second. But even then, the user has to edit startup files
containing the Lisp forms setting the variables. To remove this need
for hand-editing, Sawfish has a specialized system allowing all
customizations to be made through a GUI, and then automatically
reloaded each time that the window manager is started.

@deffn Command customize &optional group
Invoke the user-customization GUI. @var{group} defines the class of
customization variables to configure, or all classes if @var{group} is
undefined.
@end deffn

The @file{sawfish-ui} program can be used to invoke the GUI manually;
if GNOME is being used, then the GNOME Control Center can also be used
to customize certain classes.

In order to provide these customization options however, an extra
requirement is placed on the Lisp programmer. Instead of just using the
@code{defvar} special form to declare variables, the @code{defcustom}
macro must be used. This augments the variable with extra information
for the GUI, including such things as its required data type.

@menu
* Defgroup and Defcustom::      
* Customization Files::         
* Customized Variable Status::  
@end menu

@node Defgroup and Defcustom, Customization Files, Customization, Customization
@section Defgroup and Defcustom
@cindex defgroup
@cindex defcustom

Customization options are organized into groups.  Each group has a name
and contains a set of related options.  Groups can be assigned to
parent groups using the @code{:group} parameter during construction.

@defmac defgroup group real-name &rest keys
Declares a new customization group whose name is defined by the symbol
@var{group}. The string @var{real-name} is the title of the group as
seen by the user.

@var{keys} is a list, defining the properties of the group. The members
of the list are grouped into pairs of elements, the first element names
the property, the second defines its value.

@table @code
@item :group @var{group}
Specifies the parent customization group of this group.  The value of
this key is not evaluated.

@item :require @var{struct}
Before displaying the customization UI for this group, @code{require}
the structure @var{struct}.  This guarantees that all customizable
variables will be known at display time.  The value of
this key is not evaluated.

@item :layout @var{symbol}
Use a particular UI widget to display this group.  The value is a
symbol, one of:

@table @code
@item single
Holds a single customizable item.
@item vbox
Holds any number of customizable items, arranging them vertically.
This is the default.
@item hbox
Holds any number of customizable items, arranging them horizontally.
@item frame
Embed the items in a vbox in a frame.
@item keymaps
Use a special UI widget for customizing keymaps.
@end table

The value of this key is not evaluated.
@end table

This macro also creates an interactive function named
@code{customize:@var{group}} allowing the GUI to be invoked to
configure the new group.

While @code{defgroup} is a macro, there is a corresponding
@code{custom-declare-group} function.
@end defmac

@defmac defcustom variable value documentation &rest keys
The first three arguments are analogous to the @code{defvar} special
form, they declare a special variable stored in the symbol
@var{variable}, whose value is set to @var{value} if the variable is
currently unbound, with a documentation string @var{documentation}.

All other parameters are key-value pairs as with @code{defgroup}. The
possible pairs are as follows:

@table @code
@item :group @var{group}
Specifies the customization group that this variable is a member of.
This is a list of symbols, indicating a series of nested groups, e.g.,
@code{(workspace edge-flip)}.  A variable in a top-level customization
group can also be specified as a plain symbol, e.g., @code{workspace}.
The value of this key is not evaluated.

@item :type @var{type}
Specifies the required type of the variable. The current possibilities
are:

@item @code{(symbol [@var{option} @dots{}])}
A symbol.  The UI looks for a symbol property @code{:options} and
interprets it as the list of valid symbols to select from.  The
@var{option} arguments allow you to define a list at eval time.  It is
also possible to change this list at run time by changing the custom
symbol's @code{:options} property; see the access functions
@code{custom-add-options} and @code{custom-set-options} for more
information.

@item @code{(choice @var{option} @dots{})}
One of the @var{option} elements.  Each @var{option} is a symbol.
Unlike the @code{symbol} type, there is no expectation that this list
will change at run-time.

@item @code{string}
An arbitrary string.

@item @code{(number [[@var{min}] @var{max}]}
Integer number.  Two additional arguments specify the minimum and
maximum allowed values for the integer.  One additional argument
specified the maximum allowed value; the minimum defaults to zero.
Zero additional arguments implies no minimum nor maximum.

@item @code{boolean}
True (@code{t}) or false (@code{nil}) value.

@item @code{color}
A color.

@item @code{font}
A font name.

@item @code{file}
A file name.

@item @code{program}
A file name that must be an executable program.

@item @code{command}
A Sawfish command.

@item @code{event}
A Sawfish event.

@item @code{keymap}
A Sawfish keymap.

@item @code{frame-style}
The name of a defined Sawfish frame style.

@item @code{icon}
An X icon.

@item @code{modifier-list}
A list of X modifier keys.

@c @item @code{workspace-geometry}
@c A @code{(@var{columns} . @var{rows})} pair.

@end table

Except where specified, the values of these keys are not evaluated.

@table @code
@item :require @var{feature}
Denotes that the feature @var{feature} must be loaded if the variable
is set to a non-@code{nil} value by user customizations.  This is
necessary because customization options are loaded on startup, possibly
before the modules that define them.
The value of this key is not evaluated.

@item :allow-nil @var{bool}
Specifies whether the variable may be @code{nil}, instead of a member
of its actual type. This is only supported by the @code{string},
@code{symbol}, @code{font} and @code{color} types.

@item :set @var{function}
Specifies that the variable must be set by calling @var{function}
instead of the default @code{custom-set-variable}. The function should
accept three arguments: @code{(@var{variable} @var{value} &optional
@var{require})}.

The usual action of this function is to translate the value into the
correct type, then call @code{custom-set-variable}. This translation is
necessary since many of the UI widgets accept strings representing more
complex types (i.e. a color's name, instead of the actual object)

@item :get @var{function}
Provides a function for reading the current value of the variable.
Should return a value that's acceptable to the UI widget associated
with the variable. Called with a single argument, the symbol containing
the variable.

@item :before-set @var{function}
@itemx :after-set @var{function}
Functions called both immediately before and after setting the value of
the variable. Called with a single parameter: the variable itself.

@item :range (@var{min} . @var{max})
The allowed range for numeric variables.  If @var{min} is @code{nil} the
the default minimum allowed value is zero; if @var{max} is @code{nil}
then the default maximum is unbounded.  This is obsolete, since the
@code{:number} type now supports range declarations.
The value of this key is not evaluated.

@item :tooltop @var{string}
A tooltip that appears when the user's mouse hovers over the widget
item.

@item :depends @var{symbol}
This widget item is only settable when the symbol-value for
@var{symbol} is non-nil.

@end table

While @code{defcustom} is a macro, there is a corresponding
@code{custom-declare-variable} function.
@end defmac

Note that where necessary the types themselves define default
@code{:set}, @code{:get} and @code{:widget} values that may be
overridden by values in the @code{defcustom} call. Usually, however,
this will not be necessary.

Consider the following example:

@lisp
(defgroup move "Move/Resize")

(defcustom move-outline-mode 'opaque
  "The method of drawing windows being moved interactively."
  :type (set opaque box)
  :group move)

(defcustom move-snap-epsilon 8
  "Proximity in pixels before snapping to a window edge."
  :group move
  :type (number 0 64))
@end lisp

@noindent
This defines a group and two customization options.

There are two special accessor functions to make it easier to deal
with lists of allowed symbols.

@defun custom-add-option variable option
Add symbol value @var{option} to the list of symbols that can be
stored in @var{variable}.  The new option goes on the end of the
list.
@end defun

@defun custom-get-options variable
Return the list of symbols that can be stored in @var{variable}.
@end defun

@node Customization Files, Customized Variable Status, Defgroup and Defcustom, Customization
@section Customization Files
@cindex Customization files
@cindex Files, customization

@defvar custom-user-file
User configuration settings are stored in the file referenced by this
variable.  While this file contains valid Rep forms, users should not
edit it directly: Sawfish will overwrite the file's contents each time
a customization is made through the GUI.

By default, this variable is set to @code{"~/.sawfish/custom"}.  The
@code{--custom-file} command-line option sets it to a different file
on program startup.
@end defvar

@defvar custom-default-file
Default customization settings are stored in the file referenced by
this variable.  These settings are only applied if the user has no
personal settings.  By default, this variable is set to
@code{"sawfish/wm/custom-defaults.jl"} relative to the
@code{sawfish-lisp-lib-directory} directory.
@end defvar

@defun custom-load-user-file
If the file referenced by @code{custom-user-file} exists, load it.
Otherwise if @code{custom-default-file} is non-nil, interpret it as a
filename and load it.
@end defun

@node Customized Variable Status,  , Customization Files, Customization
@section Customized Variable Status

To get information about a customizable variable, you can use the
following functions.

@defun variable-customized-p symbol
Returns true if @var{symbol} has been customized by the user, false
otherwise.
@end defun

@defun variable-declared-p symbol
@defunx variable-default-value symbol
The @code{variable-declared-p} function returns true if the variable
named @var{symbol} has a default value declared for it, false
otherwise.  The @code{variable-default-value} function returns the
default value of that variable, or nil if no such default value
exists.
@end defun

@defun variable-type symbol
Returns the customizable type of the variable named @var{symbol}.
@end defun

@node Window Frames, Viewports, Customization, Top
@chapter Window Frames
@cindex Window frames
@cindex Frames, of windows

Perhaps one of the most important features of a window manager is its
ability to decorate client windows, typically seen as an added border,
and then to allow the window to be manipulated through user input on
the border.

Sawfish provides an extremely flexible method of decorating windows,
the look and feel of the border may be specified completely. Also, no
limits are placed on which windows are given which borders, if
necessary a completely different border could be dynamically created
for each window!

@menu
* Frame Basics::
* Frame Part Classes::
* Frame Part Definition::
* Frame Functions::
* Frame Types::
* Frame Styles::
* Themes::
* Removing Frame Parts::
@end menu

@node Frame Basics, Frame Part Classes, , Window Frames
@section Frame Basics
@cindex Frame basics
@cindex Window frames, basics

The @dfn{frame} of a client window is defined as all decorations added
by the window manager. Usually these decorations will be immediately
adjacent to the outer edges of the window, but there is no requirement
to use this model.

In Sawfish, each window frame is constructed from a list of @dfn{frame
parts}, conceptually rectangular objects with a specified position
relative to the edges of the client window. When shaped images are used
to define frame parts, they are still thought of as being rectangular,
just with some pixels missing from the display.

Each frame part has a list of attributes associated with it, these
include items defining the background of the part (i.e. a color or an
image), and items defining the foreground of the part (i.e. probably
some kind of text, with a color, font, etc@dots{}). Non-visual
attributes may also be defined, such as, for example, the keymap
mapping events occurring in the part to Lisp commands to execute
(@pxref{Keymaps}).

So a window frame is defined in Lisp as a list of frame part
definitions (@pxref{Frame Part Definition}). These frame parts are
added to the client window (in the order they are defined, so later
frame parts are above earlier parts at the same position), to produce
the entire window frame.


@node Frame Part Classes, Frame Part Definition, Frame Basics, Window Frames
@section Frame Part Classes
@cindex Frame part classes
@cindex Window frames, frame part classes
@cindex Classes, of frame parts

Although one of the aims of Sawfish is to provide as much flexibility
as possible, this can sometimes be detrimental to the overall
experience. For example, it would be easier for the user if all themes
use consistent keymaps and cursor images in conceptually similar parts
of window frames. That is, it would be better if all close buttons had
the same mouse button bindings and the same mouse cursor displayed when
the pointer is over them.

To achieve this, Sawfish defines a number of @dfn{classes} of frame
parts, each with several default attributes. When defining a window
frame, the definitions of each part then specifies which class it is a
member of, and inherits the associated default attributes (provided
that it hasn't explicitly specified values for these attributes).

@defvar frame-part-classes
This variable is an association list, associating symbols naming frame
part classes with an association list of default attributes for that
class.
@end defvar

The names of the pre-defined classes are as follows, their meanings
should be self-explanatory:

@code{title}, @code{menu-button}, @code{close-button},
@code{iconify-button}, @code{maximize-button}, @code{top-border},
@code{left-border}, @code{right-border}, @code{bottom-border},
@code{top-left-corner}, @code{top-right-corner},
@code{bottom-left-corner}, @code{bottom-right-corner}.

@noindent
Extra classes can be created by adding to @code{frame-part-classes}.
However, it's likely that more than one theme may need to use the same
class, and that the user may then wish to customize any extra keymaps
used. The @code{def-frame-class} macro should be used to add new
classes, since it handles these situations.

@defmac def-frame-class class alist-form &rest binding-forms @dots{}
Creates a new frame part class named by the symbol @var{CLASS}.

The @var{ALIST-FORM} is evaluated to give an association list defining
attributes for the class. Each key-value pairs is only set if no
existing value exists for that key.

If @var{binding-forms} are given, they will be evaluated when no keymap
already exists for the class. A keymap will be created, and stored in
the variable named @samp{@var{class}-name}. This variable may then be
used within the @var{binding-forms}.
@end defmac

So to define a hypothetical @code{shade-button} class, the following
might be used:

@lisp
(def-frame-class shade-button '((cursor . left_ptr))
  (bind-keys shade-button-keymap
    "Button1-Off" 'toggle-window-shaded))
@end lisp

In some cases it might be valuable to be able to override pre-defined
frame part properties. For example, it might be your preference that
text in window title bars is always blue.

@defun define-frame-class class alist-form &optional with-keymap
Creates a new frame part class named by the symbol @var{class}.

Unlike @code{def-frame-class}, the trailing argument is just a boolean
flag.  This flag only indicates whether to create a keymap for the
class.  Any bindings have to be established through a separate call to
@code{bind-keys}.

The function returns @code{t} if it was able to create and bind the
empty keymap, @code{nil} otherwise.  This allows us to check for
errors.
@end defun

@defvar override-frame-part-classes
Similar to @code{frame-part-classes} except that the properties take
precedence over values defined both in that variable and in the frame
style itself.
@end defvar

The following function may be used to simplify the customization of
these two variables:

@defun set-frame-part-value class key value &optional override
Associate @var{value} with property @var{key} for all frame parts of
class @var{class}.

If @var{override} is non-nil, then the setting is installed in the
@code{override-frame-part-classes} variable, otherwise it's stored in
the @code{frame-part-classes} variable.
@end defun

@noindent
The following example would override the colors of all title bars:

@lisp
(set-frame-part-value 'title 'background
                      '("black" "white" "green" "blue") t)
@end lisp

@noindent
(See the next section for details about what is actually being set
here.)


@node Frame Part Definition, Frame Functions, Frame Part Classes, Window Frames
@section Frame Part Definitions
@cindex Frame part definitions
@cindex Window frames, frame part definitions

Each frame part is defined as an association list (or alist), a list of
cons cells, the car of each cell defines the attribute, the cdr defines
the value given to that attribute. So, for example, the alist
@code{((foo . 1) (bar . 2))} specifies two attributes: @code{foo} with
value @code{1}, and @code{bar} with value @code{2}. @xref{Association
Lists, , Association Lists, librep, The Librep Manual}.

The attributes that may be defined are as follows:

@table @code
@item (class . @var{class})
Specifies the frame part class of the part.

@item (background . @var{data})
@itemx (background . (@var{normal} @var{focused} @var{highlighted} @var{clicked}))
Specifies the background of the part. May be a color, an image, or a
string naming a color. If a single element, then it is used for all
states of the part, otherwise if a list, then each of the four elements
defines the background for that particular state.

If an image is used it will be scaled to the size of the frame part,
unless it's @code{tiled} property is set, in which case it will be
tiled across the frame part.

@item (foreground . @var{data})
@itemx (foreground . (@var{normal} @var{focused} @var{highlighted} @var{clicked}))
Specifies a foreground color or image for the frame part, either for
all states, or for each individual state.

Unlike the @code{background} attribute, by default images are not
scaled when used to define the foreground of a frame part.

@item (scale-foreground . @var{value})
When @var{value} is non-@code{nil}, the foreground image of the frame
part will be scaled to the size of the part.

@item (font . @var{font})
@itemx (font . (@var{normal} @var{focused} @var{highlighted} @var{clicked}))
Specifies the font(s) of the part.

@item (text . @var{value})
Specifies the string to draw in the foreground of the frame part
(unless the @code{foreground} property is an image). Either a string,
or a function, that will be called each time that the part is
refreshed, that will return the string to draw.

@item (x-justify . @var{value})
Defines the horizontal position of the foreground contents of the part
(i.e. the text or foreground image). May be one of the symbols
@code{left}, @code{right} or @code{center}, or a number. If a number it
defines the number of pixels from the left edge if positive, or the
right edge if negative.

@item (y-justify . @var{value})
Similar to @code{x-justify}, but the accepted symbols are @code{top},
@code{bottom} or @code{center} instead.

@item (renderer . @var{function})
This attribute may be used instead of the @code{background} attribute.
When the part needs to be drawn @var{function} will be called with an
image in which to render the background, and the current state of the
part, a symbol @code{focused}, @code{highlighted}, @code{clicked}, or
@code{nil} (for the normal state).

@item (render-scale . @var{value})
This attribute causes the size of the image used with the
@code{renderer} property to be reduced by a factor of @var{value}, an
integer.

@item (left-edge . @var{value})
Defines the position of the left edge of the part, in relation to the
left edge of the client window.

@item (right-edge . @var{value})
Defines the position of the right edge of the part, in relation to the
right edge of the client window.

@item (top-edge . @var{value})
Defines the position of the top edge of the part, in relation to the
top edge of the client window.

@item (bottom-edge . @var{value})
Defines the position of the bottom edge of the part, in relation to the
bottom edge of the client window.

@item (width . @var{value})
Defines the width of the frame part.

@item (height . @var{value})
Defines the height of the frame part.

@item (keymap . @var{value})
Defines the keymap to use when evaluating events originating in this
frame part.

@item (cursor . @var{cursor})
Defines the cursor to display when the mouse is in this part. May be
either a cursor object, or the argument to @code{get-cursor} to create
the required cursor object.

@item (removable . @var{value})
When specified and @var{value} is non-@code{nil}, this frame part may
be removed from the frame without being detrimental to the overall
appearance of the frame. This is only important for button classes,
which may sometimes be removed at the request of the client window.

@item (below-client . @var{value})
When specified and @var{value} is non-@code{nil}, then this frame part
will be displayed beneath the client window. The default action is for
frame parts to be stacked above the client window.

@item (hidden . @var{value})
When specified and @var{value} is non-@code{nil}, don't display this
frame part.

@end table

The values specified for the @code{background}, @code{foreground},
@code{render-scale}, @code{font}, @code{left-edge}, @code{right-edge},
@code{top-edge}, @code{bottom-edge}, @code{width}, @code{height},
@code{cursor}, @code{below-client} and @code{hidden} attributes may
actually be functions. In which case the function will be called (with
a single argument, the window object) when the frame is constructed,
the value returned will be used as the actual value of the attribute.

The coordinate system used for specifying the part's position is
relative to the window edge that the position is defined against.
Positive values count in from the window edge towards the center of the
window, while negative values count out from the edge, away from the
center of the window.

Consider the following example, a solid black title bar that is twenty
pixels high, directly above the client window:

@lisp
`((background . "black")
  (foreground . "white")
  (text . ,window-name)
  (x-justify . 30)
  (y-justify . center)
  (left-edge . 0)
  (right-edge . 0)
  (top-edge . -20)
  (height . 20)
  (class . title))
@end lisp

@noindent
The backquote operator is used since the definition is only mostly
constant, the comma operator inserts the value of the
@code{window-name} variable (a function giving the name of a window)
into the definition; @pxref{Backquoting, , Backquoting, librep, The
Librep Manual}).

This function is then used to dynamically specify the string drawn in
the foreground. The window manager will automatically refresh the
foreground of all frame parts of a window whenever any X property of
that window changes.

Given a framed window, and a particular frame part class, it is
possible to retrieve the values of individual attributes from the
complete list of definitions (including inherited or overrided
definitions).

@defun frame-part-get part property
Returns the value of the property @var{property} for the frame part
object @var{part}.  Returns @code{nil} if no such attribute exists.
@end defun

@defun frame-part-put part prop value
Set the property @var{prop} of frame part @var{part} to @var{value}.
@end defun

@defun frame-part-state part
Return the current state for frame part @var{part}, one of the symbols
@code{focused}, @code{highlighted}, @code{clicked},
@code{inactive-highlighted}, @code{inactive-clicked}, or @code{nil} if
the part is inactive.
@end defun

@node Frame Functions, Frame Types, Frame Part Definition, Window Frames
@section Frame Functions
@cindex Frame functions
@cindex Window frames, functions

@defun set-window-frame window frame-def
Sets the frame of the client window associated with the object
@var{window} to that defined by the list of frame part definitions
@var{frame-def}. If the window is mapped the old frame will be
destroyed and a new frame constructed.
@end defun

@defun window-frame window
Return the list of frame part definitions defining the frame associated
with @var{window}.
@end defun

@defun window-framed-p window
Return @code{t} when @var{window} has been reparented to a frame
created by the window manager.
@end defun

@defun refresh-window window
Refresh all the frame parts belonging to @var{window}.
@end defun

@defun rebuild-frame window
Recreates the window frame associated with @var{window}, from the
previously defined frame definition. All frame parts are reinitialized
and recalibrated.
@end defun

@defun window-frame-dimensions window
Return a cons cell @code{(@var{width} . @var{height})} defining the
dimensions of the frame associated with @var{window}. These will always
be greater than or equal to the dimensions of the client window.

If @var{window} is not framed, then this function returns the same
values as @code{window-dimensions} would.
@end defun

@defun window-frame-offset window
Return a cons cell @code{(@var{x} . @var{y})} defining the offset from
the origin of the client window associated with @var{window} to the
origin of its frame.
@end defun

@defun window-border-width window
Return the width of the border of the window that @var{window}
manages.
@end defun

@defun clicked-frame-part
Return a pointer to the frame part object that was clicked on as part
of the current event.  Returns @code{nil} if no frame part was clicked
on.
@end defun

@defun frame-part-dimensions part
Return a cons cell @code{(@var{width} . @var{height})} of dimensions
for frame part @var{part}.
@end defun

@defun frame-part-position part
Return a cons cell @code{(@var{x} . @var{x})} of the @emph{relative}
position of frame part @var{part} against its window's frame
origin.
@end defun

@defun frame-part-window part
Return the window object associated with this frame part.
@end defun

@defun frame-part-x-window part
Return the X11 window ID associated with this frame part.
@end defun

@defun frame-draw-mutex lock
Called with @var{lock} equal to @code{t}, frame part redraws will be
delayed.  The redraws will take place once the function is called with
@var{lock} set to @code{nil}.
@end defun

@defun map-frame-parts function window
Call @code{(@var{function} @var{part})} on each the frame parts of
@var{window} and return @code{nil}.  If any @var{function} returns
@code{nil}, @code{map-frame-parts} returns @code{nil} immediately.
@end defun

@defun rebuild-frame-part part
Build a new copy of the frame part @var{part} and install the copy in
the owning window, replacing the old part.
@end defun

@defun refresh-frame-part part
The frame part @var{part} will be redrawn at the next opportunity.
@end defun


@node Frame Types, Frame Styles, Frame Functions, Window Frames
@section Frame Types
@cindex Frame types
@cindex Window frames, types

In order to visually differentiate between different types of windows,
several predefined types of window frame exist.

@defun window-type window
Returns a symbol naming the frame type currently associated with
@var{window}.
@end defun

These frame types currently include the following:

@table @code
@item default
The normal frame type. Includes all decorations, both borders and the
title bar.

@item transient
The frame for a transient window. This usually does not include a title
bar, but does have all four borders.

@item shaped
Shaped windows are normally decorated with only a title-bar, since
their boundary is not rectangular it makes no sense to surround them
with a rectangular border.

@item shaped-transient
A combination of the @code{shaped} and @code{transient} types, normally
just a very small title border with no text.

@item shaded
A shaded window (normally just the title bar).

@item shaded-transient
A shaded transient window.

@item unframed
No frame at all, just the client window itself. The predefined
@code{nil-frame} variable contains a null frame that may be used for
this frame type.
@end table

@defun define-frame-type-mapper fun
Function @var{fun} maps from @{@var{window}, @var{frame-type}@} to
@var{frame-type}.

Each time we want to determine a window's frame-type (@code{shaded},
@code{transient}, etc.), we calculate an initial frame type with
@code{window-type} and run the results through each frame type mapper
in sequence (most recent to oldest).  The frame type returned from the
final mapper function is ``the'' frame type.

This sequence of mappers allows us to override window frame types
based on window properties.  For example, any shaded window has to
have @code{shaded} or @code{shaded-transient} type, regardless of what
its normal type is.
@end defun

@defun window-type-add-border type
@defunx window-type-add-title type
@defunx window-type-remove-border type
@defunx window-type-remove-title type
Given a window type of @var{type}, return the closest matching window
type with the given property change.  For example:

@lisp
(window-type-add-title 'unframed)
@result{} 'shaped
@end lisp

@noindent
This is because shaped windows normally have title bars but not
borders, while unframed windows normally have neither.
@end defun

@defun frame-type-menu window
Returns a list of frame types, suitable for use by the graphical
customizer.  The frame type of @var{window} is automatically checked.
@end defun

We provide a function to simplify monitoring of window changes to certain
window states.  This monitoring runs on top of the
@code{window-state-change-hook}.

@defun call-after-state-changed states fun
Arrange for function @var{fun} to be called with arguments
@samp{(window changed-states)} when one of the states defined by the
list of symbols @var{states} has been changed.  @var{States} may also
be a single symbol.
@end defun

@node Frame Styles, Themes, Frame Types, Window Frames
@section Frame Styles
@cindex Frame styles
@cindex Styles, frame
@cindex Window frames, styles

Frame styles are used to encapsulate frames of the different types that
have a single visual appearance. Each frame style associates a name
with a function that creates a frame definition for a particular window
and frame type combination.

Several window properties are used while choosing frame styles:

@defvr {Window Property} frame-style
The user-chosen frame style of the window.  If @code{nil}, Sawfish
will use the default frame style.
@end defvr

@defvr {Window Property} current-frame-style
The current frame style of the window.  This is not set explicitly;
window update functions will change it behind the scenes.
@end defvr

@defvr {Window Property} ignored
When set, the window is not given a frame.
@end defvr

It is possible to edit certain frame styles in place with
@code{sawfish-themer}.

@defun frame-style-editable-p style
Returns @code{t} if @var{style} can be edited interactively,
@code{nil} otherwise.
@end defun

@deffn {Command} edit-frame-style style
Prompts for a frame style (defaulting to the value of @code{default-frame-style}),
and runs @code{sawfish-themer-program} on it.
@end deffn

@defun reload-frame-style name
Reloads the frame style @var{name} from disk if it is already known to
the system.  All windows with that style are reframed.
@end defun

@node Themes, Removing Frame Parts, Frame Styles, Window Frames
@section Themes
@cindex Themes
@cindex Window frames, themes

Themes and frame styles are currently almost synonymous, the slight
difference being that themes provide a mechanism for loading frame
styles from the filing system as they are required. Although it is
possible that themes may include other user-interface settings in a
later version, at the moment it seems unlikely.

When a frame style is requested, if it is not already available (i.e.
if the @code{add-frame-style} function hasn't been called for that
style) then the window manager will attempt to load a theme of the same
name from the filing system.

Each theme is stored in a directory; this directory must have the same
name as the name of the theme itself. Within this directory there must
be a Lisp script named @file{theme.jl} or @file{theme.jlc}. This script
will be evaluated, it should provide a frame style of the same name as
the theme (by calling @code{add-frame-style}).

While the theme script is evaluating the @code{image-load-path}
variable is set to include the theme directory as its first element.
This ensures that any image files stored in the directory can be loaded
using the @code{make-image} function.

Since rep has no module system, any global variables defined within the
theme must be prefixed by the name of the theme to ensure their
uniqueness. For example, in the theme @code{foo}, a variable @code{bar}
would actually be called @code{foo:bar}.

In most cases however, rep's lexical scoping can be used to avoid
declaring any global variables or functions, the only usual exception
is when declaring customization options with @code{defcustom}; these
must be globally visible.

Since themes are generally passed around very casually, sawfish
evaluates all theme code in a very restricted environment; the idea
being that themes should only be able to affect the look of the window
manager. Despite this, it is still possible for malicious themes to
lock, and possibly crash, the window manager; in the first case sending
a @code{SIGINT} signal may unblock it. Hopefully themes are unable to
affect the rest of the user's environment, but there are no
guarantees@dots{}

@defvar theme-load-path
A list of directory names, provides the search path for locating theme
directories. By default this includes the user's theme directory and
the system theme directory.
@end defvar

@defvar user-theme-directory
The name of the user's theme directory, by default
@file{~/.sawfish/themes}.
@end defvar

@defvar system-theme-directory
The name of the directory holding themes from the current Sawfish
version, by default
@lisp
(expand-file-name "../themes" sawfish-lisp-lib-directory)
@end lisp
@end defvar

@defvar site-theme-directory
The name of the directory holding system-wide themes, by default
@lisp
(expand-file-name "../../themes" sawfish-lisp-lib-directory)
@end lisp
@end defvar

@defvar theme-update-interval
Number of seconds between checking if theme files have been modified.
Default 60.
@end defvar

@defvar themes-are-gaoled
If @code{t}, non-nil themes are assumed to be malicious.  They will be
evaluated in a restricted environment.
@end defvar

@node Removing Frame Parts,  , Themes, Window Frames
@section Removing Frame Parts
@cindex Removing frame parts
@cindex Frame parts, removing
@cindex Window frames, removing frame parts

It is often useful to be able to disable certain parts of a window's
frame. For example, a window may hint to the window manager that it
doesn't want a maximize button. Sawfish allows all parts of a
particular class to be disabled or enabled on a window by window basis.
However, not all frame styles will support this (it depends on the
frame part's @code{removable} property, @ref{Frame Part Definition}).

@defun add-frame-class window class
Enable all frame parts that are a member of @var{class} in
@var{window}.
@end defun

@defun frame-class-removed-p window class
Returns @code{t} if the frame part @var{class} has been removed from
@var{window}, @code{nil} otherwise.
@end defun

@defun remove-frame-class window class
Disable all frame parts that are a member of @var{class} in
@var{window} where possible.
@end defun

@node Viewports, Workspaces, Window Frames, Top
@chapter Viewports
@cindex Viewports

It is sometimes useful to have a logical display that is larger than
the computer screen.  This is most often implemented by displaying
only a portion of the logical display at any time.  Sawfish does this
using ``viewports''.

When viewports are enabled, the Sawfish logical display becomes
potentially infinitely large in the two directions ``across'' and
``down'' (to the maximum representable size of integers).  Sawfish
divides this logical display into a potentially infinite grid of
cells.  Each cell of the grid is the same size of the virtual display.

@defvar viewport-dimensions
The current number of viewports across and down the virtual display.
This is a cons cell @code{(@var{across} . @var{down})}.  Defaults to
@code{(1 . 1)}.
@end defvar

@defun set-number-of-viewports width height
Change @code{viewport-dimensions} to have the value
@code{(@var{width} . @var{height})}.
@end defun

Note that cell indices start at zero in each dimension.  Indices are
never negative.

@menu
* Switching Viewports::
* Windows and Viewports::
@end menu

@node Switching Viewports, Windows and Viewports, Viewports, Viewports
@section Switching Viewports

A user switches viewports by telling Sawfish to move the physical
display from cell to cell.  On a cell change, windows in previous
cells are removed, and windows in the current cell appear.  Windows
that span two or more cells will appear in each cell, appropriately
displaced.

@defun screen-viewport
Returns the currently displayed viewport as a pair @code{(@var{x},
@var{y})}.
@end defun

@defun set-screen-viewport col row
Change the physical display to view cell @code{(@var{col},
@var{row})}.
@end defun

@defun move-viewport right down
Move the viewport to see the cell @var{right} slots to the right and
@var{down} slots down.  Either argument may be zero or negative.
@end defun

@defvar viewport-boundary-mode
How to act when switching via @code{set-screen-viewport} to a viewport
that is outside of @code{viewport-dimensions}.  When set to
@code{wrap-around}, it loops in the vertical and horizontal axes
enough times to keep the viewport within the defined dimensions.  When
set to @code{stop}, it refuses to switch to a viewport outside of
@code{viewport-dimensions}.  Defaults to @code{wrap-around}.
@end defvar

@defun warp-viewport x y
Change the position of the physical display, such that location
@code{(@var{x}, @var{y})} is at the top-left of the display.  The
physical display may be showing more than one cell at this point.
All windows are redisplayed as appropriate.
@end defun

@defun set-viewport x y
Change the position of the physical display, such that location
@code{(@var{x}, @var{y})} is at the top-left of the display.  The
physical display may be showing more than one cell at this point.

Unlike @code{warp-viewport}, the change takes place by dividing the
motion into @code{scroll-viewport-steps} steps, and redisplaying after
each step in the motion.
@end defun

@defvr Customizable scroll-viewport-steps
Number of steps in which to divide a viewport change for
@code{set-viewport}.  Each step requires a redisplay.  Defaults to 1,
which causes an instantaneous change to the new viewport.  The
customization limit is 50.
@end defvr

@node Windows and Viewports,  , Switching Viewports, Viewports
@section Windows and Viewports

@defun window-viewport window
Returns a cons cell @code{(@var{col} . @var{row})} of the viewport
holding the top-left corner of @var{window}.
@end defun

@defun window-outside-viewport-p window
Returns true if @var{window} is completely outside the current
viewport in any direction.
@end defun

@defun window-absolute-position window
Returns a cons cell @code{(@var{x} . @var{y})} of the position of
@var{window} in its containing viewport.  The containing viewport may
or may not be the current viewport.
@end defun

@defun set-window-viewport window col row
Move @var{window} to the cell at @code{(@var{col}, @var{row})}.  The
relative position of the window within the cells is preserved.
@end defun

@defun move-window-viewport window col-delta row-delta
Move @var{window} to the cell @var{col-delta} positions across and
@var{row-delta} positions down from its current cell.  The relative
position of the window with its cells its preserved.
@end defun

@defun move-window-to-current-viewport window
Move @var{window} from its existing viewport to the current viewport.
The window's relative position in the existing viewport is preserved
after the move.
@end defun

@defun move-viewport-to-window window
Move the viewport to a cell that shows window @var{window}.  For a
window that spans multiple cells, this function will pick the cell
showing the window's top-left corner.
@end defun

@defvar uniconify-to-current-viewport
When true, windows uniconify to the current viewport, rather than to
the viewport they were iconified on.  Defaults to true.
@end defvar

@node Workspaces, Multi-Head Environments, Viewports, Top
@chapter Workspaces
@cindex Workspaces
@cindex Desktop workspaces

Workspaces provide another way for users to organize their windows in
Sawfish.  Instead of stretching the screen real estate to the right
and down, workplaces stack screens on top of each other.  The user
drills down into the stack, or pops up through the stack, seeing the
appropriate windows in each workspace.

@menu
* Workspace Intervals::			``Interesting'' workspaces
* Workspace Manipulation::		Creating, rearranging, deleting
* Workspaces and Windows::		Adding, removing
* Edge Flipping::			Moving workspaces using the mouse
@end menu

@node Workspace Intervals, Workspace Manipulation, Workspaces, Workspaces
@section Workspace Intervals

While the stack of workspaces conceptually goes from negative infinity
to positive infinity, we normally present only the first non-empty
workspace through the last non-empty workspace to the user.  The
non-empty interval is occasionally re-normalized to start with zero.

We typically refer to workplaces with lower IDs being to the ``left''
of workplaces with higher IDs, as if on a number line.

@defvar current-workspace
The ID of the currently active workspace.  This is an integer.  The
``default'' workspace has ID 0.
@end defvar

@defun workspace-limits
Returns a pair @code{(@var{first-index} . @var{last-index})} defining
the subset of the workspace continuum that is ``interesting'' to the
user (typically, all those that have ever been explicitly created).
@end defun

@defun workspace-id-to-logical space-id &optional limits
Takes an absolute workspace ID and returns its position in the
interval of ``interesting'' workspaces.  If @var{limits} is provided,
it must be a pair @code{(@var{first-index} . @var{last-index})} like
that returned by @code{workspace-limits}.  If it is not provided, the
function uses the result of @code{workspace-limits} directly.
@end defun

@defun workspace-id-from-logical offset &optional limits
Takes an offset position into an interval of ``interesting''
workspaces, and returns the workplace ID at that position.  If
@var{limits} is provided, it must be a pair @code{(@var{first-index}
. @var{last-index})} like that returned by @code{workspace-limits}.
If it is not provided, the function uses the result of
@code{workspace-limits} directly.
@end defun

@defun popup-workspace-list
Display the menu containing the list of all workspaces.
@end defun

@defun workspace-menu
Returns a list of workspaces, suitable for display in a menu.
@end defun

@defvr Customizable workspace-names
A list of workspace names.  When displaying the workspace menu, the
first @var{N} workspaces use the corresponding list elements as their
display names (where @var{N} is the length of the list).  Normally
they get the display name @samp{space N} for some value of N.
@end defvr

@node Workspace Manipulation, Workspaces and Windows, Workspace Intervals, Workspaces
@section Workspace Manipulation

Sawfish has various functions to create, rearrage and delete
workspaces.  Windows in a deleted workspace are not lost; they are
moved to another workspace.

@defun select-workspace space &key dont-focus force
Activate workspace @var{space}, making it current.

By default in @code{enter} and @code{click} focus modes, the most
recently used window will receive focus.  The caller can disable this
behavior by passing a true @var{dont-focus} keyword argument.

If the @var{force} keyword argument is true, we will go through the
activation process even if @var{space} already is current.
@end defun

@defun select-workspace-from-first count
Select the workspace in position @var{count} from the list of
``interesting'' workspaces.
@end defun

@defun select-workspace-and-viewport space col row
Select workspace @var{space} and then switch to viewport
@code{(@var{col}, @var{row})} in that workspace.
@end defun

@defun insert-workspace &optional before
Insert a new workspace, returning its index.  The new index appears
before the workspace indicated by @var{before}, or the current
workspace if @var{before} is @code{nil}.
@end defun

@defun insert-workspace-after
Create a new workspace following the current workspace.
@end defun

@defun insert-workspace-before
Create a new workspace preceeding the current workspace.
@end defun

@defun move-workspace space count
Move the workspace @var{space} @var{count} positions forward, or
@var{count} positions backwards if @var{count} is negative.
@end defun

@defun move-workspace-forwards &optional count
Move the current workspace one place to the right (or @var{count}
places to the right if @var{count} is defined).
@end defun

@defun move-workspace-backwards &optional count
Move the current workspace one place to the left (or @var{count}
places to the left if @var{count} is defined).
@end defun

@defun next-workspace count
@defunx previous-workspace count
Switch from the current workspace (index @var{i}) to the workspace
@var{i}+@var{count}.  The @code{previous-workspace} function is
identical to @code{(next-workspace (- @var{count}))}.

These functions do not have default values for their @var{count}
arguments.
@end defun

@defun remove-workspace &optional index
Remove workspace @var{index} (or the current workspace if @var{index}
is @code{nil}).  All windows in that workspace are moved to the next
workspace @var{index}+1.  This will change the set of ``interesting''
workspaces.
@end defun

@defun merge-next-workspace
Delete the current workspace.  Its member windows are relocated to the
next workspace.
@end defun

@defun merge-previous-workspace
Delete the current workspace.  Its member windows are relocated to the
previous workspace.
@end defun

@defun set-number-of-workspaces wanted
Add or remove workspaces until the number of ``interesting''
workspaces is equal to @var{wanted}.

When adding workplaces, the new workplaces get indices higher than any
existing indices.  When removing workplaces, the lowest workplaces are
always chosen for removal (their windows are merged into the new
lowest-index workspace).
@end defun

@defvar lock-first-workspace
When true, preserve the outermost empty workspaces in the pager.
Don't quietly remove them when they become empty.  Defaults to true.
@end defvar

@node Workspaces and Windows, Edge Flipping, Workspace Manipulation, Workspaces
@section Workspaces and Windows

Workspaces do not need to have windows assigned to them, but most
operations with workspaces involve adding and removing windows.

@defun all-workspaces
Returns a list of indices for all workspaces that contain windows.
Sticky windows appear in the current workspace.
@end defun

@defun workspace-empty-p space
Returns true if workspace @var{space} contains zero (non-sticky)
windows.
@end defun

@defun delete-empty-workspaces
Delete any workspaces that don't contain any windows.
@end defun

@defvar workspace-boundary-mode
How to act when passing the first or last workspace, one of @code{stop},
@code{wrap-around} or @code{keep-going}.  Defaults to @code{stop}.
@end defvar

Each window can be a member of any (positive) number of workspaces;
their @code{workspaces} property contains a list of workspace ids.
Sticky windows appear on all workspaces, and have their @code{sticky}
property set (with a null @code{workspaces} property).  If Sawfish
begins managing a window with its @code{workspaces} property set, then
the window is added to those workspaces automatically.

@defun window-in-workspace-p window space
Returns true if @var{window} is a member of workspace @var{space},
false otherwise.
@end defun

@defun window-appears-in-workspace-p window space
Returns true if @var{window} appears in workspace @var{space}, false
otherwise.  To appear, @var{window} has to be visible, but it can
either be assigned to the workspace or be sticky.
@end defun

@defun windows-share-workspace-p window1 window2
Returns true if @var{window1} and @var{window2} are members of at
least one common workspace.
@end defun

@defun nearest-workspace-with-window window space
Returns the nearest workspace to @var{space} that contains
@var{window}.
@end defun

@defun workspace-windows &optional space include-iconified
Returns a list of all windows that are members of the current
workspace (or @var{space} if it is not @code{nil}).  The list normally
does not contain iconified windows, but they can by included by
specifying a true @var{include-iconified} argument.
@end defun

@defun popup-window-menu
Display the menu of all managed windows.
@end defun

@defun move-window-to-workspace window old new &optional was-focused
Move @var{window} from workspace @var{old} to workspace @var{new}.

We need the old workspace as an explicit argument because a window can
be in more than one workspace.  The function does the right thing if
the window already appears in workspace @var{new}.

If @var{was-focused} is true and the window is visible, it gets the
input focus in the new workspace.
@end defun

@defun copy-window-to-workspace window old new &optional was-focused
Arrange it so @var{window} appears in both @var{old} and @var{new}
workspaces.

If @var{was-focused} is true and the window is visible, it gets the
input focus in the new workspace.
@end defun

@defun send-to-next-workspace window count &optional copy select
Move the window @var{count} workspaces to the right.  @var{Count} does
not default to one.

The window is normally removed from the current workspace (if it is in
that workspace), or from the first workspace it belongs to.  Supplying
a true @var{copy} argument causes Sawfish to copy the window instead.

If @var{select} is true, then we switch to the destination workspace.
If the moved window had input focus before the move, it will have
input focus after the move as well.
@end defun

@defun send-to-previous-workspace window count &optional copy select
Move the window @var{count} workspaces to the left.  @var{Count} does
not default to one.

The window is normally removed from the current workspace (if it is in
that workspace), or from the first workspace it belongs to.  Supplying
a true @var{copy} argument causes Sawfish to copy the window instead.

If @var{select} is true, then we switch to the destination workspace.
If the moved window had input focus before the move, it will have
input focus after the move as well.

This is identical to @code{(send-to-next-workspace window count copy select)}.
@end defun

@defun copy-to-next-workspace window count select
Copy the window @var{count} workspaces to the left.  @var{Count} does
not default to one.

If @var{select} is true, then we switch to the destination workspace.
If the moved window had input focus before the move, it will have
input focus after the move as well.

This is identical to @code{(send-to-next-workspace window count t select)}.
@end defun

@defun copy-to-previous-workspace window count &optional select
Copy the window @var{count} workspaces to the right.  @var{Count} does
not default to one.

If @var{select} is true, then we switch to the destination workspace.
If the moved window had input focus before the move, it will have
input focus after the move as well.

This is identical to @code{(send-to-previous-workspace window count t select)}.
@end defun

@defun send-window-to-workspace-from-first window count &optional copy select
Move @var{window} to the workspace at position @var{count} in the
``interesting'' list.

The window is normally removed from the current workspace (if it is in
that workspace), or from the first workspace it belongs to.  Supplying
a true @var{copy} argument causes Sawfish to copy the window instead.

If @var{select} is true, then we switch to the destination workspace.
If the moved window had input focus before the move, it will have
input focus after the move as well.
@end defun

@defvar workspace-send-boundary-mode
How to act when passing the first or last workspace, while moving a
window.  One of @code{stop}, @code{keep-going}, @code{wrap-around}.
Defaults to @code{stop}.
@end defvar

@defun delete-window-instance window
Remove the copy of @var{window} on the current workspace.  If this is
the last instance remaining, then delete the actual window.  Note that
this behavior differs from the merging that happens when you delete a
workspace.
@end defun

@defun map-window-workspaces fun window
Map function @var{fun} over all workspaces containing @var{window}.
@end defun

When a window appears on more than one workspace, some of its
properties may be swapped in and out on demand when the current
workspace is changed.

@defvar workspace-local-properties
Window properties whose values may differ on differnet workspaces.
Defaults to the empty list.
@end defvar

@defvar add-swapped-properties props
Add all properties in the list @var{props} to
@var{workspace-local-properties}.
@end defvar

It is possible to hide all ``normal'' windows across workspaces.
``Normal'' in this case excludes desktop windows and dock windows, but
includes sticky and ignored windows.  The hidden windows are no longer
considered ``viewable'' according to @code{window-viewable-p}.

@defun show-desktop
Hide all windows except the desktop and dock windows.
@end defun

@defun hide-desktop
Undo the effects of the @code{show-desktop} command.
@end defun

@defun showing-desktop-p
Return true if non-desktop and non-dock windows are hidden, false
otherwise.
@end defun

@node Edge Flipping,  , Workspaces and Windows, Workspaces
@section Edge Flipping

Sawfish provides a way to flip between workspaces (or viewports)
automatically by moving the mouse to the edge of the screen.  The
technique is called ``edge flipping''.

These definitions are stored in the @code{sawfish.wm.ext.edge-flip}
structure.  They can only be enabled through the customization
interface.

@defvr Customizable edge-flip-enabled nil
When true, select the next desktop when the pointer hits screen edge.
Defaults to false.
@end defvr

@defvr Customizable edge-flip-type
Indicates what is selected when hitting the screen edge.  Must be one
of @code{viewport} or @code{workspace}.  Defaults to @code{workspace}.
@end defvr

@defvr Customizable edge-flip-only-when-moving
When true, Sawfish only flips when the user is interactively moving a
window.  Defaults to false.
@end defvr

This variable is not customizable, but it can be edited.

@defvar edge-flip-delay
Milliseconds to delay before edge flipping.  Defaults to 250.
@end defvar

Flippers are implemented as invisible windows on the edges of the
display (the windows overlap at the corners).  When the pointer moves
over any of these windows, Sawfish generates @code{enter-flipper-hook}
and @code{leave-flipper-hook} events.

Programmers can add their own callbacks to perform other actions with
the flippers.  This depends on manually enabling the flippers, using
the following functions in the @code{sawfish.wm.util.flippers}
structure.  Note that you may have to manually remove the
@code{edge-flip-enter} and @code{edge-flip-leave} callbacks from the
hooks before adding your own callbacks.

@defun enable-flippers
Add edge windows used to implement flipping.
@end defun

@defun disable-flippers
Remove the edge windows used to implement flipping.
@end defun

@node Multi-Head Environments, Window Placement, Workspaces, Top
@chapter Multi-Head Environments
@cindex Multi-head environments
@cindex Environments, multi-head
@cindex Monitors, multiple

Sawfish has special functions to support environments with multiple
monitors displaying a single logical screen (as provided by Xinerama).

@defun find-head x y
Return a ID for the display head that point (@var{x}, @var{y}) is in.
The return value is an integer; the default head has ID zero.  Returns
@code{nil} if it cannot determine the head from @var{x} and @var{y}.
@end defun

@defun head-count
Return the number of display heads on the machine.
@end defun

@defun head-dimensions id
Return the cons cell @code{(@var{width} . @var{height})} of the
dimensions of the display head indicated by @var{id}.  @var{Id} must
be a non-negative integer.  Without Xinerama support, @var{id} must be
zero and the function returns the screen size.
@end defun

@defun head-offset id
Return the cons cell @code{(@var{x} . @var{y})} of the
dimensions of the display head indicated by @var{id}.  @var{Id} must
be a non-negative integer.  Without Xinerama support, @var{id} must be
zero and the function returns @code{(0 . 0)}.
@end defun

@defun pointer-head
Return the ID of the head containing the mouse pointer.
@end defun

@defun current-head &optional window
Return the ID of the head containing the window with input focus.  If
@var{window} is supplied and a window, return the head containing that
window.  If @var{window} is supplied and @var{nil}, return
@code{(pointer-head)}.
@end defun

@defun current-head-dimensions &optional window
Return a cons-cell defining the size in pixels of the current head
(that containing the window @var{window}, or the pointer if
@var{window} is false).  Returns the screen dimensions if no such head
can be identified.
@end defun

@defun current-head-offset &optional window
Return a cons-cell defining the origin of the current head (that
containing the window @var{window}, or the pointer if @var{window} is
false).  Returns @code{'(0 . 0)} if no such head can be identified.
@end defun


@node Window Placement, Popup Menus, Multi-Head Environments, Top
@chapter Window Placement
@cindex Placement of windows

Sawfish supports multiple ways of placing new windows on the display.
There is a ``current'' placement mode for normal windows, and another
mode for transient windows.

@defvar place-window-mode
A symbol indicating the method of placing normal windows.  This
defaults to @code{top-left}.
@end defvar

@defvar place-transient-mode
A symbol indicating the method of placing transient windows.  This
defaults to @code{centered-on-parent}.
@end defvar

@defun placement-mode name
Return the placement mode object corresponding to @var{name}.
@end defun

@defvar placement-modes
List of names of all placement modes.  Sawfish 1.3 ships with the
following placement modes:

@itemize @bullet
@item @code{randomly}
The new window is placed at a random location on the screen.

@item @code{interactively}
Prompt the user to select a position with the mouse.  The new window
is created such that its top-left corner is at that position.

@item @code{centered}
The new window is created at the center of the screen.

@item @code{centered-on-parent}
The new window has a parent, it is centered on that parent.  If the
new window instead has a focused window in the same group, it is
centered on that focused window.  Otherwise the new window is simply
@code{centered}.

@item @code{under-pointer}
Create the new window so that it's under the pointer, without going
off the edge of the screen.

@item @code{first-fit}
@item @code{best-fit}
Look for positions where the new window would have a small overlap
area with already visible windows.  The @code{first-fit} algorithm
uses the first ``good'' position found.  The @code{best-fit} algorithm
looks at all possible positions and picks the best of them.

@item @code{best-fit-group}
As @code{best-fit}, but the new window is only checked for overlap
with other windows in its group.

@item @code{first-fit-or-interactive}
As @code{first-fit}, but if Sawfish cannot find a ``good'' position,
it falls back to @code{interactively} mode.

@item @code{stagger}
Attempts to place each new window below and to the right of the
previous window.  See @code{stagger-placement-step}.

@item @code{top-left}
Interpret the top-left to bottom-right screen diagonal as a series of
slots, each of which may have a window.  Find the first empty slot and
place the window there.  @emph{Sawfish will shrink the window to
prevent it from going past the right or bottom edge, or even beneath a
special window like a panel.}  If Sawfish is not allowed to shrink the
window enough to prevent this, it instead places the window randomly.

@item @code{off-center}
Tries to put windows in the center of the screen, but in such a way
that the newly placed window doesn't fully obscure an existing
window.

This is to handle the case where two windows of the same size are
created one after the other, so that the user is sure to see (at least
part of) both windows.

@item @code{none}
Make no changes to the window's position.  The window remains wherever
the X server placed it initially.
@end itemize

@end defvar

In all of these placement modes, the mode is responsible for taking
the window object as an argument, and manipulating its position with,
e.g., @code{move-window-to}.

The window to be placed avoids overlapping with already existing
``avoided'' windows (@pxref{Avoided Windows}), unless
the position is explicitly specified by coordinates, or placement mode
@code{interactively} is used.

@defvar stagger-placement-step
In @code{stagger} placement mode, the distance down and to the right
from the previously placed window to the new one.  This is measured
in pixels.
@end defvar

There are two circumstances in which Sawfish will place a window:
either the window has just been created, or Sawfish has begun managing
the window's display.  In the latter case, the window will have the
@code{placed} property.

@defvar ignore-program-positions
When @code{t}, program position size hints are not considered when
placing windows.
@end defvar

You can define your own placement modes.

@defun define-placement-mode name fun &keywords for-normal for-dialogs
Define a new window placement mode called @var{name} (a symbol).  The
function @var{fun} will be called with a single argument when a window
should be placed using this mode.  The single argument is the window
to be placed.

If the @var{for-normal} keyword is @code{t}, then this placement mode
is marked as valid for @code{place-window-mode}.  The same applies to
@var{for-dialogs} and @code{place-transient-mode}.
@end defun

@defun autoload-placement-mode name module-name &keywords for-normal for-dialogs
Define placement mode @var{name} (a symbol) to be loaded from
structure @var{structure-name} (a symbol) when first referenced.  The
@var{keyword-args} are passed along to the call to
@code{define-placement-mode} that creates the placement mode.
@end defun

@node Popup Menus, Events, Window Placement, Top
@chapter Popup Menus
@cindex Popup menus
@cindex Menus, popup

Popup menus are one of the two main methods through which the user may
invoke Lisp code (the other is via keymaps, @pxref{Keymaps}). The
@code{popup-menu} function is invoked with a list of menu item
definitions and the associated Lisp function to call for each item.
This starts a subprocess to display the menu, then at a later date the
chosen menu item is received and evaluated.

Each menu item is specified by a list, the first element of which is a
string providing the label for the menu item, the second element is a
function to be called if that item is selected by the user. If this
function has an interactive specification it will be invoked using the
@code{call-command} function, otherwise @code{funcall} will be used.
Alternatively the second element may be a lisp form to evaluate. So,
for example, a single-level menu could be defined by:

@lisp
(("Item 1" function-1)
 ("Item 2" function-2)
 ()
 ("Item 3" function-3))
@end lisp

@noindent
The null item will create a separator line in the displayed menu.

If the cdr of first element of any item is a symbol, then the rest of
the item is defined by the value of the named variable. If this value
is functional then the definition is found by calling the function.

Consider the following definition:

@lisp
(("Workspaces" . workspace-menu)
 ("Windows" . window-menu)
 ("Programs" . apps-menu)
 ("Customize" . custom-menu)
 ("About..." (customize 'about))
 ()
 ("Restart" restart)
 ("Quit" quit))
@end lisp

@noindent
This is the definition of Sawfish's root menu. We can see that four
submenus are created dynamically by dereferencing variables (in fact,
three of this variables contain functions) (@code{workspace-menu},
@code{window-menu}, @code{apps-menu} and @code{custom-menu}). Note that
these must be special variables, i.e. initially declared using the
@code{defvar} special form.

The @code{apps-menu} variable can thus be used to redefine the
applications menu. The default definition is as follows:

@lisp
(("xterm" (system "xterm &"))
 ("Emacs" (system "emacs &"))
 ("Netscape" (system "netscape &"))
 ("The GIMP" (system "gimp &"))
 ("XFIG" (system "xfig &"))
 ("GV" (system "gv &"))
 ("xcalc" (system "xcalc &")))
@end lisp

@noindent
The @code{system} function simply executes its single argument using
@file{/bin/sh}.

When displaying a menu item, it is possible to also display the
corresponding keyboard shortcut in the menu.

@defvar menus-include-shortcuts
When true, menu items also display key-binding information.  Defaults
to false.
@end defvar

The actual creation of a menu is performed by an auxiliary process,
distributed with Sawfish.  Since the overhead of starting the menu
subprocess may be noticeable on some systems, it is possible to leave
it running between menu requests.

@defvar menu-program
Location of the program implementing Sawfish's menu interface.
@end defvar

@defvar menu-program-stays-running
This variable defines if, and for how long, the menu subprocess is
allowed to remain executing for after the last menu has completed. If
@code{nil}, the program is terminated immediately, if @code{t} it is
left running indefinitely, if an integer then the program will run for
that many seconds (unless another menu is displayed).
@end defvar

The actual interface to invoke the external menu program is hidden in
the @code{popup-menu} function.

@defun popup-menu spec
Displays a menu defined by the list of item definitions @var{spec}.
@end defun

In addition, Sawfish provides various canned menus, and functions to
display those menus.

@defvar root-menu
Contains the root menu definition.
@end defvar

@defun popup-root-menu
Display the main menu.  By default, this is bound to Button2-click on
the root window.
@end defun

@defvar apps-menu
The variable containing the definition of the applications submenu of
the root menu.  The default root menu includes this as a child menu.
@end defvar

@defun popup-apps-menu
Display the applications menu.
@end defun

@defun window-ops-menu
The variable containing the definition of all window operations.
@end defun

@defun popup-window-menu
Display the menu listing all window operations.  This has several
bindings by default.  In particular, clicking on a window's menu
button displays this menu.
@end defun

@defvar window-ops-toggle-menu
A list of flags describing windows, e.g., ``sticky'' or ``shaded''.
This list is displayed in a menu, and by selecting items in this menu
a user can turn the flags on and off for a given window.
@end defvar

@defun add-window-menu-toggle label command &optional predicate
Add additional flags to @code{window-ops-toggle-menu}.  The
@var{command} is a function (or a symbol pointing to a function) that
gets run when the menu item is selected.  If @var{predicate} is
non-nil, it must be a function taking a window as argument.  If
@var{predicate} return true, the menu item will have a check mark next
to it.
@end defun

@node Events, Commands, Popup Menus, Top
@chapter Events
@cindex Events

Events refer to input events from X that the window manager receives,
either for the root window, the window frames it creates, or grabbed
from the client windows themselves. Each event induced by the mouse or
keyboard has a Lisp representation.

@defun eventp object
This function returns @code{t} if its argument is an input event.
@end defun

@menu
* Event Representation::        Objects versus string names
* Event Modifiers::             Meta, Alt, Buttons
* Event Actions::               Keys and Clicks
* Event Matching::
* Synthetic Events::            Creating events that seem real
@end menu

@node Event Representation, Event Modifiers, Events, Events
@section Event Representation

Each input event is represented by a cons cell containing two
integers, and these integers encode the event. The encoding is opaque;
the only way to access an event meaningfully is via the functions
provided.

Each event has a string representation, called its ``name''.  Names
consist of zero or more modifiers, followed by a key or mouse action
indicator.  Modifiers are separated from succeeding elements by
hyphens @samp{-}.  For example, hitting @key{x} while holding down the
@key{Control} and @key{Meta} keys would generate an event named
@key{Control-Meta-x}.  This notation is designed to closely match
Emacs Lisp's notation.

Functions are available to convert between the name of an event and the
actual event itself, and vice versa.

@defun lookup-event event-name
Create and return a new input event whose name is @var{event-name}.

@lisp
(lookup-event "C-x")
    @result{} (120 . 65540)

(lookup-event "C-M-Button1-Click1")
    @result{} (1 . 131340)
@end lisp
@end defun

@defun event-name event
This function returns a string naming the input event @var{event}.

@lisp
(event-name (lookup-event "C-x"))
    @result{} "C-x"
@end lisp
@end defun

@node Event Modifiers, Event Actions, Event Representation, Events
@section Event Modifiers
@cindex Event Modifiers
@cindex Modifiers, for events

Sawfish event modifiers are copied directly from the standard X
modifiers:

The standard X modifier names are provided, as well as four special
modifiers @key{Meta}, @key{Alt} @key{Hyper} and @key{Super} that are
mapped to the keysyms of the same name.

The following table lists the possible modifier prefixes:

@table @key
@item Control
@itemx C
The control modifier

@item Meta
@itemx M
The meta modifier

@item Alt
@itemx A
The alt modifier

@item Shift
@itemx S
The shift modifier

@item Hyper
@itemx H
The hyper modifier

@item Super
@itemx s
The super modifier; note that this is a lowercase @kbd{s}

@item Mod@var{k}
The standard X modifiers, for @var{k} between 1 and 5

@item Any
A special modifier that matches any set of modifiers in events.
@xref{Event Matching}.

@item Release
A special modifier that matches key release events, not the default
key press events.  Mouse events never have @key{Release} modifiers;
they have separate actions instead.  @xref{Event Actions}.

@item Button@var{k}
The @var{k}'th mouse button is currently pressed.

@item W
A placeholder ``window manager'' modifier that can be bound to a real
modifier on the fly.  See @code{wm-modifier} below.
@end table

The default Sawfish bindings use the @key{Meta} modifier.  For
convenience, if no X keysym generates @key{Meta}, Sawfish will treat
the first defined modifier of @key{Alt}, @key{Hyper} and @key{Super}
(in that order) as @key{Meta}.  The mapping from keysyms to
modifiers is exposed in the following variables:

@defvar meta-keysyms
A list defining the names of the X keysyms generating the virtual
@samp{Meta} or @samp{M} modifier.
@end defvar

@defvar alt-keysyms
A list defining the names of the X keysyms generating the virtual
@samp{Alt} or @samp{A} modifier.
@end defvar

@defvar hyper-keysyms
A list defining the names of the X keysyms generating the virtual
@samp{Hyper} or @samp{H} modifier.
@end defvar

@defvar super-keysyms
A list defining the names of the X keysyms generating the virtual
@samp{Super} modifier.
@end defvar

There are two functions to manipulate the placeholder ``window
manager'' (@key{W}) modifier.  Unfortunately, these are low-level
functions that operate on integer encodings.

@defun wm-modifier
Return the current value (an integer) of the placeholder ``window
manager'' (@key{W}) modifier.
@end defun

@defvr {Customizable} wm-modifier-value
An integer encoding zero or more modifier keys that form the
placeholder ``window manager'' (@key{W}) modifier.  Setting this value
through the customization UI automatically calls
@code{set-wm-modifier}.
@end defvr

@defun set-wm-modifier modifiers
Set the value of the placeholder ``window manager'' (@key{W}) modifier
to @var{modifiers} (an integer).
@end defun

@node Event Actions, Event Matching, Event Modifiers, Events
@section Event Actions

Sawfish recognizes keyboard actions and mouse actions.

@table @asis
@item Key Press
@itemx Key Release
Keys pressed on the keyboard generate one or more key press events,
followed by a key release event.  Bindings normally recognize key
press events only.  To recognize key releases, add a @key{Release}
modifier to the bound event.
@end table

Generally keys have the same names as their X keysyms.  The following
unusual names are worth listing: @samp{SPC}, @samp{TAB}, @samp{RET},
@samp{ESC}, @samp{BS}, @samp{DEL}, @samp{Up}, @samp{Down},
@samp{Left}, @samp{Right}.

For example, pressing the @key{Delete} key while @key{Control} is held
down generates a @kbd{Control-DEL} event, while releasing the @key{a}
key while @key{Hyper} is held down generates a @kbd{H-Release-a}
event.

@table @asis
@item Button Clicks
Button presses generate @key{Click} actions.  If Sawfish receives
several clicks in close succession (less than @code{multi-click-delay}
milliseconds between clicks), the second and third events are
@key{Click2} and @key{Click3}, respectively.  Any further clicks are
simple @key{Click} events.  For consistency, @key{Click1} is a synonym
for @key{Click}.

@item Button Releases
Once the button has been released from a @key{ClickN} action, Sawfish
receives a corresponding @key{OffN} action.  The actions @key{Off} and
@key{Off1} are synonyms.

@item Pointer Motion
Pointer motion generates @key{Move} actions.  The action does not
indicate anything about the pointer position; use e.g.,
@code{query-last-pointer} to find that information.
@end table

@noindent
For example, a single click of the left mouse button with the
@key{Meta} key held would be described as @kbd{M-Button1-Click1}.
After triple-clicking with the @key{Alt} key held down, Sawfish will
receive a @kbd{Alt-Off3} event.

@defvar multi-click-delay
An integer indicating the maximum number of milliseconds between
successive clicks.  Defaults to 250 milliseconds at startup; if
@code{nil}, Sawfish uses 250 milliseconds.
@end defvar

@node Event Matching, Synthetic Events, Event Actions, Events
@section Event Matching
@cindex Event Matching
@cindex Matching, Events

There is a special function that matches event objects.  If the
actions of two event objects are not identical, the events do not
match.  If they are identical, then the events match if the modifiers
are identical, or if one of the modifiers is @key{Any}.
@xref{Event Modifiers}.

@defun event-match ev1 ev2
Returns @code{t} if events @var{ev1} and @var{ev2} match, @code{nil}
otherwise.
@end defun

@node Synthetic Events,  , Event Matching, Events
@section Synthetic Events
@cindex Synthetic Events
@cindex Events, Synthetic
@cindex Events, Synthesizing

It is possible to create an event inside Sawfish that mimics a real
keyboard or mouse event.

@defun synthesize-event event window &optional propagate
Generate a synthetic key press or button press and send it to the X
window bound to the @var{window} object.  This press is automatically
followed by the appropriate release event.

The current pointer position becomes the position of the event.

@var{Event} is either an event object, or the string representation of
an event (such as @code{"A-f"} or @code{"C-M-Button3-Click2"}).
Strings are parsed into event objects before any work is done.
@xref{Event Representation}.

If @var{propagate} is true, the event will propagate up the window
ancestor chain until it is handled.
@end defun


@node Commands, Keymaps, Events, Top
@chapter Commands
@cindex Commands

A @dfn{command} is a Lisp function which may be called interactively,
that is, as a result of being bound to an input event.  To support
this, we mark them with metadata that the runtime system can query.

@menu
* Old-style Command Definition::  Emacs-Lisp style
* New-style Command Definition::  Common-Lisp style
* Interactive Calling Specification::  
* Operations on Commands::	Accessors and the like
* Invoking Commands::           call-commmand, command hooks
* Default Commands::            Sawfish ships with a few commands
@end menu

@node Old-style Command Definition, New-style Command Definition, Commands, Commands
@section Old-style Command Definition

The old-style command declaration syntax looks very much like that of
GNU Emacs Lisp.  Commands are defined like any other function (using
@code{defun}), but the first form in the body must be an
@dfn{interactive declaration}.  This marks that the function may be
called interactively and tells the @code{call-command} function how to
compute the argument values to apply to the command.

The interactive declaration looks like a call to the special form
@code{interactive}, in actual fact this special form always returns
@code{nil} and has no side-effects. The only effect of this form is to
show the @code{call-command} function that the function definition may
be called interactively. The second element of the declaration form
(after the @code{interactive} symbol) defines how the argument values
applied to the command are computed.

The structure of an interactive declaration, then, is:

@lisp
@findex interactive
(interactive [@var{calling-spec}])
@end lisp

When a command is defined this is how it includes the interactive
declaration:

@lisp
(defun some-command (arg1)
  "Optional documentation string."
  (interactive @dots{})
  @dots{}
@end lisp

The @var{calling-spec} is defined in @xref{Interactive Calling
Specification}.

@node New-style Command Definition, Interactive Calling Specification, Old-style Command Definition, Commands
@section New-style Command Definition

The new syntax does not depend on special magic in @code{defun}.
Instead, it uses keyword arguments to indicate the calling
specification and other properties.

@defun define-command name fun #!key spec type doc doc-key class
Define a window managed command called @var{name} (a symbol).  The
function @var{fun} will be called to execute the command.

@var{spec} and @var{type} may be used to define the arguments expected
by the command; @var{spec} is an interactive specification and
@var{type} is a custom-type specification.  @xref{Interactive Calling
Specification}.

@var{doc} is the documentation string associated with the command.
The command-documentation may be stored in the doc file, rather than
in the code itself; if it exists, the @var{doc-key} will be used to
look up the doc file entry.  If both arguments are provided, both will
be stored.  But the @code{command-documentation} function favors the
built-in doc string over the doc file entry.

@var{class} is an annotation for the command.  It allows the
definition to mark the class as @code{'advanced}, for example.  Other
parts of Sawfish can then take advantage of this note.
@end defun

@defun define-command-to-screen name fun #!key spec type doc doc-key class
As @code{define-command}, but any printed output of @var{fun} is sent
to the screen.
@end defun

@defun autoload-command name module #!key spec type doc doc-key class
Record that loading the module called @var{module} (a symbol) will provde a
command called @var{name}.

The keyword values have the same meanings as for
@code{define-command}.  Defining those properties as part of the
autoload provides useful feedback to the user without having to do
loading.
@end defun

@node Interactive Calling Specification, Operations on Commands, New-style Command Definition, Commands
@section Interactive Calling Specification

The @var{calling-spec} argument to @code{interactive} or
@code{define-command} defines the argument values applied to the
command when it is called interactively.  It may be one of:

@itemize @bullet
@item @code{nil} or undefined (i.e. @code{(interactive)})
No arguments are given to the command, this type of interactive
declaration just shows that the function may be called interactively.

@item A string
This is interpreted as zero or more lines (each separated by a newline
character).  Each line defines how to compute one argument value.  The
first one or two characters of each line is a prefix defining exactly
how to compute the argument, the rest of the line is an optional
argument which some prefixes may use.  See below for a list of
prefixes.  A null line produces an argument value of @code{nil}.

@item Anything else
The form is evaluated and expected to return a @emph{list} of
arguments to apply to the command.
@end itemize

The currently available prefixes are,

@table @samp
@item e
The event which caused this command to be invoked.

@item E
The event which caused this command, cooked into a string.

@item p
The prefix argument as a number, this will be 1 if no prefix argument
has been entered.

@item P
The raw prefix argument.

@item t
The symbol @code{t}.

@item %f
The window which currently has the input focus, or @code{nil} if no
window is focused.

@item %w
The result of calling the @code{current-event-window} function.

@item %W
The result of calling the @code{current-event-window} function, or if
this returns @code{nil} or @code{root}, the currently focused window.
@end table

@node Operations on Commands, Invoking Commands, Interactive Calling Specification, Commands
@section Operations on Commands

Once a command has been defined, we can extract certain information
about it.

@defun commandp @var{object}
This function returns @code{t} if its argument may be called interactively.
If @var{object} is a function (i.e. a symbol or a lambda-expression) it
is a command if it contains an interactive declaration

The only other object which is a command is a function call form; the
use of these types of commands is discouraged but they can be useful
sometimes.
@end defun

@defun command-documentation name
Return the documentation for the command @var{name}.  It returns the
first documentation found by looking at (in order): the documentation
property of the command; the doc file entry associated with the doc
key property; or the documentation for the function with the same
name.
@end defun

@defun command-spec name
@defunx command-type name
@defunx command-class name
Return the specification, type or class (respectively) of the named
command.
@end defun

@node Invoking Commands, Default Commands, Operations on Commands, Commands
@section Invoking Commands

When a command is to be invoked, the @code{call-command} function is
used. This builds a list of argument values to apply to the command
(using its interactive declaration) then calls the command.

@defun call-command command &optional prefix-arg
This function calls the command @var{command} interactively. See the
documentation of @code{commandp} above for what constitutes a command.

If the @var{prefix-argument} is non-nil it defines the value of the
@code{current-prefix-arg} variable for this command, normally the value
of this variable would be taken from the global @code{prefix-arg}
variable.

There is a corresponding @code{call-command} command that prompts for
a command to execute.
@end defun

@defun apply-command name &rest args
Call the function underlying the command @var{name}, passing in
@var{args} as the arguments.  This is useful for calling a command in
a non-interactive context.
@end defun

@defvar current-prefix-arg
When invoking an interactive command, this is set to the current
prefix argument.
@end defvar

@defvar this-command
The command currently being called, or @samp{nil} if no command is
being called.
@end defvar

@defvar last-command
The command previously called, or @samp{nil} if there is no such
command.
@end defvar

@xref{Command Hooks}, for hooks run before and after commands.

@node Default Commands,  , Invoking Commands, Commands
@section Default Commands

Sawfish defines several commands by default.

@defun run-shell-command
The command prompts the user for a string, and executes that string as
under @code{system}.
@end defun

@defun quit
@defunx restart
@defunx destroy-window
@defunx kill-client
@defunx no-operation
Calls the function of the same name.  @code{destroy-window} and
@code{kill-client} both take @code{%W} as argument.
@end defun

@node Keymaps, Event Loop, Commands, Top
@chapter Keymaps
@cindex Keymaps

Keymaps are used to associate events with commands. When an event
occurs, the associated command is found and evaluated. A keymap is
simply a list whose first element is the symbol @code{keymap}.

@defun keymapp arg
Returns @code{t} if @var{arg} may be used as a keymap.
@end defun

@defun make-keymap
Returns a newly-created empty keymap.
@end defun

@defun bind-keys keymap &rest bindings
Installs zero or more key bindings into the keymap @var{keymap}, then
returns @var{keymap}.

Each binding is defined by two elements in the list of @var{bindings},
the first defines the name of the input event (or the event itself) and
the second defines the command to be associated with the event.

For example to bind two keys in the keymap @var{keymap}; the event
@kbd{C-f} to the command @code{foo} and the event @kbd{C-b} to the
command @code{bar} the following form would be used,

@lisp
(bind-keys @var{keymap}
 "C-f" 'foo
 "C-b" 'bar)
@end lisp
@end defun

@defun unbind-keys @var{keymap} &rest @var{keys}
Removes the bindings of the events @var{keys} (these may be the names
of the events or the event objects themselves) from the keymap
@var{keymap}.
@end defun

@defun search-keymap event keymap
Search for a binding of the event @var{event} in @var{keymap}. If a
binding is found a cons cell @code{(@var{command} . @var{event})} is
returned.
@end defun

There are several pre-defined keymaps that are always available:

@table @code
@item global-keymap
Keymap containing bindings active anywhere.

@item window-keymap
Keymap containing bindings active when a client window is focused.

@item root-window-keymap
Keymap containing bindings active when the pointer is in the root
window.

@item title-keymap
@itemx border-keymap
Keymaps active in the title and borders of window frames.

@item close-button-keymap
@itemx iconify-button-keymap
@itemx maximize-button-keymap
@itemx menu-button-keymap
@itemx shade-button-keymap
Keymaps active in the standard window frame buttons.

@item override-keymap
Must be a keymap, a symbol, or @code{nil}.  If it is a keymap,
this becomes the keymap in which all lookups occur (overriding the window,
root and global keymaps).  If it is a symbol, Sawfish finds the
symbol's value and tries again.  If it is @code{nil}, Sawfish behaves
normally.

@end table


@node Event Loop, Miscellaneous Functions, Keymaps, Top
@chapter Event Loop
@cindex Event loop

The event loop reads all X events received on any of the windows that
Sawfish is aware off. Many of these events invoke hooks, as described
in @ref{Standard Hooks}. Keyboard and pointer events are translated to
their Lisp equivalents (@pxref{Events}) and then used to scan all
active keymaps for a binding. If a binding is found, the associated
command is invoked through the @code{call-command} function.

The active keymaps are determined as follows:

@itemize @bullet
@item If the variable @code{override-keymap} is non-nil, then this is
the only keymap searched

@item Otherwise three keymaps are searched:

@enumerate
@item the @code{keymap} property of the currently ``clicked'' frame
part if there is one,

@item the @code{keymap} property of the currently focused window

@item the contents of the variable @code{global-keymap}.
@end enumerate
@end itemize

Note that for @code{ButtonRelease} events, the frame part's keymap is
only searched if the pointer is actually within the frame part when the
release event occurs.

If no binding may be found in any of the active keymaps, then the
@code{unbound-key-hook} hook is called. This is an @code{or} type
hook---the first function that returns non-nil will terminate the hook
call.

@defun lookup-event-binding event
Perform the usual binding lookup for the event object @var{object}.
Returns the command found, or @code{nil} if no binding exists.
@end defun

By default, both key-release events, and events that are bound to
modifier keys (e.g. @key{Control_L}), are ignored. However, this
behavior may be changed:

@defvar eval-modifier-events
When non-nil, key events bound to modifier keys are evaluated.
@end defvar

@defvar eval-key-release-events
When non-nil, key-release events are evaluated.
@end defvar

While a command is being evaluated, information about the event that
caused it may be found:

@defun current-event
Return the event which caused the current command to be invoked
@end defun

@defun current-event-string
Returns the string which the current event would usually insert.
@end defun

@defun current-event-window &optional win
Extract the owning window of the current X event (this is a window
object, or the symbol @code{root} for the root window, or @code{nil}
if there is no window or no event).  This is stored internally as the
current event window, and returned.
@c FIXME-DLU: why does this function take a WIN parameter?
@end defun

@defun last-event
Return the previous event which occurred.
@end defun

@defun proxy-current-event window &optional mask propagate
Send the current X event to @var{window}, either a window object, a
numeric window id, or the symbol @code{root}. If a @code{ButtonPress}
event the pointer grab will be released first.

@var{Mask} may be an integer defining the X event mask to pass to the
@code{XSendEvent} function. If not defined, a mask is chosen that would
usually be used to select the type of event being proxied.

@var{Propagate} is a flag (@code{nil}/non-@code{nil}) passed directly
to an underlying @code{XSendEvent} call.  (And if someone would like
to explain what @emph{that} means, please do so @enddots{}
@end defun

@defun allow-events mode
This is a wrapper for the @code{XAllowEvents} function. The @var{mode}
parameter may be one of the following symbols: @code{async-pointer},
@code{async-keyboard}, @code{sync-pointer}, @code{sync-keyboard},
@code{replay-pointer}, @code{replay-keyboard}, @code{async-both},
@code{sync-both}.

Events that have to be grabbed to be received (i.e. all bindings in the
@code{global-keymap} and the @code{window-keymap}) are grabbed
synchronously. This means that no more events will be received until
either the command returns, or @code{allow-events} is called.

This is normally not important, but if the command expects to receive
further events it must call @code{allow-events}. See the interactive
move and resize functions for an example.
@end defun

@defun forget-button-press
Cause the next button press to be treated as a single click event, no
matter how soon it occurs after the prevous button-press event.
@end defun

@defun accept-x-input &optional mask
Handle any X events received. If @var{mask} is non-nil then only events
matching this numeric value are handled (see the X header files for
details).
@end defun

@defun x-events-queued
Returns the number of X events waiting to be handled.
@end defun


@node Miscellaneous Functions, Standard Hooks, Event Loop, Top
@chapter Miscellaneous Functions
@cindex Miscellaneous functions

@menu
* Pointer Functions::
* Grab Functions::
* Display Functions::
* Gradient Functions::
* Other Functions::
@end menu

@node Pointer Functions, Grab Functions, , Miscellaneous Functions
@section Pointer Functions
@cindex Pointer functions
@cindex Functions, pointer

@defun query-pointer &optional from-server
Returns a cons cell @code{(@var{x} . @var{y})} representing the current
mouse pointer position, relative to the origin of the root window.

If there is a mouse update current event, the position is read
directly from that event.  Otherwise it is read from the server.  If
@var{from-server} is non-nil then the position is read directly from 
the server in any case.
@end defun

@defun query-pointer-window
Returns the top-level window under the mouse pointer, or @code{nil} if
the cursor is in the root window.
@end defun

@defun query-last-pointer
Returns a cons cell @code{(@var{x} . @var{y})} representing the second
most recent mouse pointer position, relative to the root window.
@end defun

@defun query-button-press-pointer
Returns @code{(@var{mouse-x} . @var{mouse-y})} representing the mouse
position relative to the root window at the last button-press event.

Use this function to track the displacement of the pointer during a
drag.
@end defun

@defun query-button-press-window
Returns the window that the mouse was in when the button was pressed.
@end defun

@defun warp-cursor x y
Move the mouse pointer to position (@var{x}, @var{y}) relative to the
origin of the root window.
@end defun

@defun warp-cursor-to-window window &optional x y
Move the mouse pointer to position (@var{x}, @var{y}) relative to the
client window associated with object @var{window}.

If @var{x} and @var{y} are @code{nil}, then they are taken as the
top-left corner of the window's frame.

If @code{warp-to-window-enabled} is @code{nil}, this function does
nothing.
@end defun

@defvar warp-to-window-offset
Offset (%) from window edges when warping pointer. A negative number
means outside the left window edge.
@end defvar

@defvar warp-to-window-enabled
When false, disable warping the cursor to windows.
@end defvar

@defvar pointer-motion-threshold
If set to an integer value, a pointer must move by this many pixels on
either axis before Sawfish considers it to have moved.  If the pointer
has not moved by this amount, Sawfish will ignore @code{MotionNotify}
events from X.  The variable defaults to 2 pixels.  If not an integer,
Sawfish assumes a threshold of 0 pixels.
@end defvar


@node Grab Functions, Display Functions, Pointer Functions, Miscellaneous Functions
@section Grab Functions
@cindex Grab functions
@cindex Functions, grab

@defun grab-server
Prevent any other clients from accessing the X server.
@end defun

@defun ungrab-server
After a call to @code{grab-server} this will allow other clients to
access the X server again.

Note that calls to @code{grab-server} and @code{ungrab-server}
@emph{nest}.
@end defun

@defmac with-server-grabbed &rest forms
Evaluate forms with the server grabbed. Releases the grab afterwards.
@end defmac

@defun call-with-server-ungrabbed thunk
Return the result of calling the zero-parameter function
@var{thunk}.  If the server is currently grabbed, ungrab it first,
restoring the original grab status after the call to @var{thunk}
returns.
@end defun

@defun server-grabbed-p
Returns @code{t} if the X server is currently grabbed.
@end defun

@defun grab-pointer &optional window cursor ptr-sync kbd-sync confine-to
Grab the mouse pointer and direct all pointer events to window object
@var{window}.  If @var{cursor} is defined and a cursor object, display
this while the pointer is grabbed.

If @var{window} is a window object corresponding to a
visible window, the grab will be made on its frame.

If @var{window} is an integer, it specifies the window ID of the grab
window.

Otherwise the grab will be made on the root window.  This includes
@var{window} corresponding to a non-viewable window.

@var{Confine-to}, if non-@code{nil}, is a visible window to confine
the pointer to.  It is interpreted similarly to the rules for
@var{window}, except that the ``otherwise'' case is to not confine the
pointer.

If the window id of a non-viewable window was specified for either
@var{window} of @var{confine-to}, the grab will be made on the root
window without confining the pointer.

If @var{ptr-sync} or @var{kbd-sync} is non-@var{nil}, the pointer or
keyboard will be frozen, i.e., the device will not produce events
until either the grab is released or events are re-enabled using
@code{allow-events}.

Returns non-nil if the grab succeeded.
@end defun

@defun ungrab-pointer
Release the grab on the mouse pointer.
@end defun

@defun grab-keyboard &optional window ptr-sync kbd-sync
Grab the keyboard and direct all keyboard events to window object
@var{window}.

If @var{window} is a window object corresponding to a
visible window, the grab will be made on its frame.

If @var{window} is an integer, it specifies the window ID of the grab
window.

Otherwise the grab will be made on the root window.  This includes
@var{window} corresponding to a non-viewable window.

If @var{ptr-sync} or @var{kbd-sync} is non-@var{nil}, the pointer or
keyboard will be frozen, i.e., the device will not produce events
until either the grab is released or events are re-enabled using
@code{allow-events}.

Returns non-nil if the grab succeeded.
@end defun

@defun ungrab-keyboard
Release the grab on the keyboard.
@end defun

@defun call-with-keyboard-grabbed thunk
Call the zero-parameter function @var{thunk} with the keyboard
grabbed.  If unable to grab the keyboard then @var{thunk} won't be
called.
@end defun


@node Display Functions, Gradient Functions, Grab Functions, Miscellaneous Functions
@section Display Functions
@cindex Display functions
@cindex Functions, display

@defun screen-width
Return the width of the root window.
@end defun

@defun screen-height
Return the height of the root window.
@end defun

@defun screen-dimensions
Return the screen dimensions in pixels as a cons cell
@code{(@var{width} . @var{height})}.
@end defun

@defun draw-window-outline mode x y width height
Draw an outline of a window of dimensions (@var{width}, @var{height})
at position (@var{x}, @var{y}) relative to the root window.

@var{mode} is a symbol defining the type of outline drawn, currently it
may only be @code{box} for a 3x3 grid.

Use the @code{erase-window-outline} to erase the grid. Also note that
since these functions draw directly on the root window the server
should be grabbed until the outline is erased.
@end defun

@defun erase-window-outline mode x y width height
Erase a previously drawn outline of a window of dimensions
(@var{width}, @var{height}) at position (@var{x}, @var{y}) relative to
the root window.

@var{mode} is a symbol defining the type of outline drawn, currently it
may only be @code{box} for a 3x3 grid.
@end defun

@defun display-message &optional text attributes
Display the string @var{text} in a window on the screen. If @var{text}
is @code{nil} then any string previously displayed is removed. Returns
the numeric id of the window displaying the message, or @code{nil} if
no message is displayed.

@var{attributes} is an alist specifying how the string should be
displayed; each element of the list is a cons cell @code{(@var{attr} .
@var{value})} associating an attribute @var{attr} (a symbol) with it's
value.

Possible attributes currently include:

@table @code
@item font
The font to use

@item foreground
The color (or color name) to draw the text with

@item background
The color (or color name) to draw the background with

@item x-justify
The justification method for multi-line strings. One of the symbols
@code{left}, @code{right}, or @code{center}

@item spacing
The number of extra pixels of vertical spacing to leave between text
lines.

@item position
A cons cell defining the coordinates at which to display the message
window. The cell is @code{(@var{x} . @var{y})}. @var{x} and @var{y} are
integers or @code{nil} (for centered display). If negative they count
in from the left and bottom edges respectively.

@item head
The head on which to center the message when a position is not specified or
given as nil.  If not provided defaults to the head containing the window that
has the input focus.
@end table
@end defun


@node Gradient Functions, Other Functions, Display Functions, Miscellaneous Functions
@section Gradient Functions
@cindex Gradient functions
@cindex Functions, gradients

The @code{gradient} feature allows color gradients to be drawn in
images. (Evaluate @code{(require 'gradient)} to load this feature.)

@defun draw-vertical-gradient image from to
Draw a vertical color gradient in @var{image}. The color at the top of
the image will be @var{from}, the color at the bottom @var{to}, with a
smooth transition between.
@end defun

@defun draw-horizontal-gradient image from to
Draw a horizontal color gradient in @var{image}, from left to right.
The color at the left of the image will be @var{from}, the color at
the right @var{to}, with a smooth transition between.
@end defun

@defun draw-diagonal-gradient image from to
Draw a horizontal color gradient in @var{image}, from the top-left
corner to the bottom-right. The color at the top-left of the image
will be @var{from}, the color at the bottom-right @var{to}, with a
smooth transition between.
@end defun


@node Other Functions, , Gradient Functions, Miscellaneous Functions
@section Other Functions
@cindex Other functions
@cindex Functions, other

@defun sync-server
Flush all pending X requests, don't wait for them to finish.
@end defun

@defun send-client-message window type data format
Send an X @code{ClientMessage} event to @var{window} (a window object,
the symbol @code{root} or a numeric xid).

The event will be of the type @var{type} (a symbol), contain the array
of integers @var{data} (i.e. a vector or a string), and will be
transferred as @var{format} sized quantities (8, 16 or 32).
@end defun

@defun create-window parent x y width height
Create an unmapped window that is a child of @var{parent} (a window
object, an integer window id, or the symbol @code{root}), with the
specified dimensions.

Returns the window id of the new window.
@end defun

@defun exit-type
If Sawfish is shutting down, this function returns one of the strings
@code{"user-quit"}, @code{"user-restart"} or @code{"session-quit"}.
If Sawfish is not shutting down, it returns @code{nil}.
@end defun

@defun x-atom symbol
Return the integer identifying the X atom with the same name as
@var{symbol}.
@end defun

@defun x-atom-name integer
Return the symbol with the same name as the X atom identified by the
integer @var{integer}.
@end defun

@defvar canonical-display-name
A string containing the canonical name of the X display.  This
includes the full host name and the screen number.  For example:
@code{"foo.bar.com:0.0"}.
@end defvar

@defvar display-name
A string containing the name of the X display, exactly as passed to
Sawfish.  For example: @code{":0"}, or @code{"foo:0.0"}.
@end defvar

@defvar saved-command-line-args
Holds a list of all of the command line arguments (including the
executable name).
@end defvar

@defvar sawfish-directory
The home directory for Sawfish files.  For example:
@code{"/usr/share/sawfish"}.
@end defvar

@defvar sawfish-exec-directory
The directory for architechture-specific Sawfish executables.  For
example: @code{"/usr/lib/sawfish/1.3/i386-pc-linux-gnu"}.
@end defvar

@defvar sawfish-lisp-lib-directory
The top-level directory for Sawfish lisp files.  For example:
@code{"/usr/share/sawfish/1.3/lisp"}.
@end defvar

@defvar sawfish-locale-directory
The system directory where Sawfish can find locale files.  This is not
part of the Sawfish distribution.  For example:
@code{"/usr/share/locale"}.
@end defvar

@defvar sawfish-site-lisp-directory
The top-level directory for site-specific Sawfish lisp files.  For
example: @code{"/usr/share/sawfish/site-lisp"}.
@end defvar

@defvar sawfish-version
The version number of the running Sawfish.
@end defvar

@defun primitive-play-sample filename
Plays the sound file @var{filename} (which must be a string).
@end defun

@defun call-with-error-handler thunk
Call the zero-parameter function @var{thunk}.  If an error occurs,
trap it and pass its @code{car} and @code{cdr} to
@code{error-handler-function}.
@end defun

@defun load-module name
Ensure that module @var{name} has been loaded.  This does @emph{not}
import its bindings or make them accessible.
@end defun

@defun eval-in form struct-name
Evaluates @var{form} in the structure named by @var{struct-name}.
Compare this with @code{eval}, which takes a structure object as its
second parameter, not a structure name.
@end defun

@defvar *user-module*
@code{*user-module*} is the default module for human interaction with
Sawfish.
@end defvar

@defun user-eval form
@defunx user-require feature
@code{user-eval} evaluates @code{form} in @code{*user-module*}.
@code{user-require} evaluates @code{(require @var{feature})} in
@code{*user-module*}.
@end defun

@defun quote-menu-item string
Escape any @samp{_} characters in @var{string} such that the result
can be used as the label of a menu item.
@end defun

@defun make-directory-recursively dir
Create directory @var{dir}.  Any missing parent directories will also
be created.
@end defun

@defun locate-file filename dirs
Search for a file @var{filename} in any of the directories named by
the list of strings @var{dirs}.
@end defun

@defun clamp x lower upper
Return @var{x} clamped between @var{lower} and @var{upper}.  If
@var{x} is less than @var{lower}, return @var{lower}; if it is larger
than @var{upper} return @var{upper}.  Otherwise return @var{x}.
@end defun

@defun clamp* x y lower upper
Return the interval (@var{x}, @var{x}+@var{w}) clamped between
@var{lower} and @var{upper}.  If @var{x} is less than @var{lower},
return @var{lower}.  If @var{x}+@var{w} is larger than @var{upper},
return @var{upper}-@var{w}; this is a value of @var{x} that satisfies
the upper bound, although it may violate the lower bound.  Otherwise
return @var{x}.
@end defun

@defun uniquify-list lst
Remove all duplicates values from @var{lst}, using @code{eq}.  The
order of elements is not preserved.
@end defun

@node Standard Hooks, Standard Properties, Miscellaneous Functions, Top
@chapter Standard Hooks
@cindex Standard hooks
@cindex Hooks, standard

Sawfish provides many hooks to allow extension of previously defined
functions. Also, many X events are exported to the Lisp environment via
the hooks mechanism. For more details on the hooks mechanism see
@ref{Normal Hooks, , Normal Hooks, librep, The Librep Manual}.

As well as using the standard @code{call-hook} function, sawfish also
provides the @code{call-window-hook} function. This is used to invoke
hooks which refer to a single window. If the hook has a local value
defined in the window's property list then this value is used, before
the default value defined by the actual variable.

@defun call-window-hook hook window &optional args hook-type
Call @var{hook} for @var{window} with further arguments @var{args}. See
@code{call-hook} for a description of @var{hook-type}. Each function in
the hook is called with arguments @code{(@var{window} . @var{args})}.
@end defun

The available hooks are listed below.

@menu
* Command Hooks::
* Key Hooks::
* Window Construction Hooks::
* Window Destruction Hooks::
* Window Mapping Hooks::
* Window Motion Hooks::
* Window Cycling Hooks::
* X Hooks::
* Pointer Motion Hooks::
* Workspace Hooks::
* Startup and Shutdown Hooks::
* Other Hooks::
@end menu


@node Command Hooks, Key Hooks, Standard Hooks, Standard Hooks
@section Command Hooks
@cindex Command Hooks
@cindex Hooks, Command

@defvr {Hook} pre-command-hook
Called before each command is evaluated.
@end defvr

@defvr {Hook} post-command-hook
Called after each command is evaluated.
@end defvr


@node Key Hooks, Window Construction Hooks, Command Hooks, Standard Hooks
@section Key Hooks
@cindex Key Hooks
@cindex Hooks, Key

@defvr {Hook} unbound-key-hook
Called when an key or pointer event has been received which there is
no binding for.  The hook functions return no arguments.  This is an
@code{or}-type hookk---the first function that returns non-@code{nil}
will terminate the hook call.

Under normal circumstances, an unbound key release causes a
@code{throw} to top-level.  Adding @emph{any} function to this hook
suppresses that behavior.
@end defvr


@node Window Construction Hooks, Window Destruction Hooks, Key Hooks, Standard Hooks
@section Window Construction Hooks
@cindex Window Construction Hooks
@cindex Hooks, Window Construction

@defvr {Window Hook} before-add-window-hook
@defvrx {Window Hook} add-window-hook
Called when the window is first adopted by the window manager.  This
occurs before the window is created, installed or placed.  At this
early stage, the only safe action is to set properties of the window
(with @code{window-set}).

@code{add-window-hook} is a deprecated hook, replaced by
@code{before-add-window-hook}.  It is called immediately after
@code{before-add-window-hook}.
@end defvr

@defvr {Window Hook} after-add-window-hook
Called when the window is first adopted by the window manager.  This
occurs after the window has been created, installed and placed.
@end defvr

@defvr {Window Hook} after-framing-hook
Called after a window gets a frame assigned, or after a window's
frame is rebuilt.
@end defvr


@node Window Destruction Hooks, Window Mapping Hooks, Window Construction Hooks, Standard Hooks
@section Window Destruction Hooks
@cindex Window Destruction Hooks
@cindex Hooks, Window Destruction

@defvr {Window Hook} destroy-notify-hook
Called when the window is destroyed.  Note that this may be called
asynchronously to the normal event loop.  In general, once the window
manager knows the window has been destroyed, it will attempt to call
this hook as soon as possible.
@end defvr


@node Window Mapping Hooks, Window Motion Hooks, Window Destruction Hooks, Standard Hooks
@section Window Mapping Hooks
@cindex Window Mapping Hooks
@cindex Hooks, Window Mapping

@defvr {Window Hook} map-notify-hook
@defvrx {Window Hook} unmap-notify-hook
@defvrx {Window Hook} reparent-notify-hook
@defvrx {Window Hook} shape-notify-hook
Called with a window is mapped, unmapped, reparented, or has its shape
changed, respectively.

Note that iconifying and uniconifying windows triggers unmapping and
mapping, respectively.
@end defvr

@defvr {Window Hook} iconify-window-hook
@defvrx {Window Hook} uniconify-window-hook
@defvrx {Window Hook} shade-window-hook
@defvrx {Window Hook} unshade-window-hook
@defvrx {Window Hook} window-maximized-hook
@defvrx {Window Hook} window-unmaximized-hook
@defvrx {Window Hook} window-depth-change-hook
Called when a window is iconified, uniconified, shaded, unshaded,
maximized, unmaximized, or has its depth changed, respectively.
@end defvr

@defvr {Window Hook} visibility-notify-hook
Called when a window's visibility changes.  In addition to the window,
the hook is called one one of the symbols @code{fully-obscured},
@code{partially-obscured}, or @code{unobscured}.
@end defvr

@defvr {Window Hook} place-window-hook
Called the first time a window is mapped, or if the window does not
have a true @code{placed} property.  This is an @code{or}-type
hook---the first function that returns non-@code{nil} will terminate
the hook call.
@end defvr


@node Window Motion Hooks, Window Cycling Hooks, Window Mapping Hooks, Standard Hooks
@section Window Motion Hooks
@cindex Window Motion Hooks
@cindex Hooks, Window Motion

@defvr {Window Hook} window-moved-hook
@defvrx {Window Hook} window-resized-hook
Called whenever the window is moved or resized.

This hook is called inside the @code{move-window-to} and
@code{move-resize-window-to} functions, so any operation that moves
the window will trigger this hook.  The window motion does not have to
be interactive.

Note that outline window sizing and movement does not use
@code{move-window-to} or @code{move-resize-window-to}, except at the
very end of the operation.

Compare with @code{while-moving-hook} and @code{while-resizing-hook}.
@end defvr

@defvr {Window Hook} before-move-hook
@defvrx {Window Hook} before-resize-hook
Called before starting an interactive move or resize.
@end defvr

@defvr {Window Hook} while-moving-hook
@defvrx {Window Hook} while-resizing-hook
Called during every pointer motion event during a move or resize.
This includes outline window motion.  The calls take place before the
window or its outline are actually moved.

Compare with @code{window-moved-hook} and @code{window-resized-hook}.
@end defvr

@defvr {Window Hook} after-move-hook
@defvrx {Window Hook} after-resize-hook
Called after completion of an interactive move or resize.  In addition
to the window, the hook is called with a list of symbols indicating how
the window was moved or resized: 
@code{horizontal} and @code{vertical} for movement,
@code{right}, @code{left}, @code{bottom} and @code{top} for resizing.
@end defvr

@defvr {Window Hook} before-slide-hook
Called before a window move when using key binding.
@end defvr


@defvr {Hook} after-restacking-hook
Called after any window restacking operation, including (but possibly
not limited to @code{restack-windows}, @code{x-raise-window} and
@code{x-lower-window}.  The hook functions take no arguments.
@end defvr

@node Window Cycling Hooks, X Hooks, Window Motion Hooks, Standard Hooks
@section Window Cycling Hooks
@cindex Window Cycling Hooks
@cindex Hooks, Window Cycling

@defvr {Window Hook} after-cycle-step-hook
Called after each step of window cycling. (See @ref{Cycling Between Windows}.)
@end defvr

@node X Hooks, Pointer Motion Hooks, Window Cycling Hooks, Standard Hooks
@section X Hooks
@cindex X Hooks
@cindex Hooks, X

@defvr {Window Hook} configure-request-hook
Called when an X
@code{ConfigureRequest} event is received.
In addition to the window, the hook is called with an association list
of configure request properties.  This alist may contain items
@code{(stack . above)}, @code{(stack . below)},
@code{(position . @var{coordinates})},
and @code{(dimensions . @var{dimensions})}.
@end defvr

@defvr {Window Hook} property-notify-hook
Called whenever an X window property (not a Sawfish window property)
changes.  In addition to the window, the hook is called with the
atom name and one of the symbols @code{new-value} or @code{deleted}.
@end defvr

@defvr {Window Hook} window-state-change-hook
Called whenver certain window manager hints change for a window.
Currently only @code{urgency} is monitored.  The hint is an additional
argument to the hook.
@end defvr


@node Pointer Motion Hooks, Workspace Hooks, X Hooks, Standard Hooks
@section Pointer Motion Hooks
@cindex Pointer Motion Hooks
@cindex Hooks, Pointer Motion

In the hooks below, @var{focus-mode} is one of the symbols
@code{normal}, @code{grab} or @code{ungrab}.

@defvr {Window Hook} enter-notify-hook
@defvrx {Window Hook} enter-frame-part-hook
Called when the pointer enters a window (including the root window).

If the window was part of a frame, then @code{enter-frame-part-hook}
is called with three arguments: the window, the frame part class
(@pxref{Frame Part Classes}), and @var{focus-mode}.

Otherwise @code{enter-notify-hook} is called with two arguments: the
window and @var{focus-mode}.

The root window is considered to be a valid window for this hook.
Sawfish will report entering the root window.
@end defvr

@defvr {Window Hook} leave-notify-hook
@defvrx {Window Hook} leave-frame-part-hook
Called when the pointer leaves a window (including the root window).

If the window was part of a frame, then @code{leave-frame-part-hook}
is called with three arguments: the window, the frame part class
(@pxref{Frame Part Classes}), and @var{focus-mode}.

Otherwise @code{leave-notify-hook} is called with two arguments: the
window and @var{focus-mode}.

The root window is considered to be a valid window for this hook.
Sawfish will report leaving the root window.
@end defvr

@defvr {Window Hook} focus-in-hook
Called when focus gains focus.  The hook functions take two arguments:
the window that received focus, and @var{focus-mode}.

If your @var{focus-mode} is set to @code{enter-exit}, your window
focus is tightly bound to your pointer position; focus-related hooks
and enter/leave hooks will be called in lockstep.  For other values of
@code{focus-mode}, Sawfish will trigger fewer focus-related hook calls
than enter/leave hook calls.

This hook is never called for the root window, because the root window
never gets focus.
@end defvr

@defvr {Window Hook} focus-out-hook
Called when a window loses focus.  The hook functions take two
arguments: the window that lost focus, and @var{focus-mode}.

If your @var{focus-mode} is set to @code{enter-exit}, your window
focus is tightly bound to your pointer position; focus-related hooks
and enter/leave hooks will be called in lockstep.  For other values of
@code{focus-mode}, Sawfish will trigger fewer focus-related hook calls
than enter/leave hook calls.

This hook is never called for the root window, because the root window
never gets focus.
@end defvr


@node Workspace Hooks, Startup and Shutdown Hooks, Pointer Motion Hooks, Standard Hooks
@section Workspace Hooks
@cindex Workspace Hooks
@cindex Hooks, Workspace

@defvr {Hook} enter-workspace-hook
@defvrx {Hook} leave-workspace-hook
Called when switching from one workspace to another.  This includes
switching caused by adding or removing a workspace.  The hook is
called with a @emph{list} containing the workspace in question.
@end defvr

@defvr {Window Hook} add-to-workspace-hook
@defvrx {Window Hook} remove-from-workspace-hook
Called when a window is added or removed from a workspace.  In
addition to the window, the hook is called with a @emph{list}
containing the workspace being changed.  If the window is in multiple
workspaces, then removing triggers @code{remove-from-workspace-hook}
for each workspace.
@end defvr

@defvr {Hook} workspace-state-change-hook
Called when any aspect of the workspaces change, including adding a
workspace, removing a workspace, moving a workspace, inserting or
removing a window from a workspace, etc.  This hook is called with no
arguments, so you should use one of the more specific hooks if
possible.
@end defvr

@defvr {Hook} viewport-resized-hook
Called when the number of rows and columns in each virtual workspace is
changed.
@end defvr

@defvr {Hook} viewport-moved-hook
Called when the origin of the viewport into the virtual workspace is
moved.
@end defvr

@defvr {Hook} enter-flipper-hook
@defvrx {Hook} leave-flipper-hook
When viewport edge-flipping is enabled, these hooks are called as the
pointer enters and leaves the pixel-wide border on the edge of the
screen. They're called with a single argument, one of the symbols
@code{left}, @code{right}, @code{top}, @code{bottom} indicating the
edge in question.
@end defvr


@node Startup and Shutdown Hooks, Other Hooks, Workspace Hooks, Standard Hooks
@section Startup and Shutdown Hooks
@cindex Startup and Shutdown Hooks
@cindex Hooks, Startup and Shutdown

@defvr {Hook} after-initialization-hook
Called after adopting the initial set of windows.
@end defvr

@defvr {Window Hook} remove-window-hook
Called on each window as Sawfish shuts down (possibly for a restart).
The hook functions take no arguments.
@end defvr

@defvr {Hook} before-exit-hook
Called immediately before exiting.
@end defvr

@defvr {Hook} sm-window-save-functions
@defvrx {Hook} sm-restore-window-hook
@defvrx {Hook} sm-after-restore-hook
Session management hooks, @ref{Session Management}.
@end defvr


@node Other Hooks,  , Startup and Shutdown Hooks, Standard Hooks
@section Other Hooks
@cindex Other Hooks
@cindex Hooks, Other

@defvr {Hook} gtkrc-changed-hook
When using the @code{gtkrc} module to load the current gtk style
parameters, this hook is called when the style changes.
@end defvr

@defvr {Window Hook} client-message-hook
Called with arguments @code{(@var{window} @var{type}
@var{data-array})}.  This is an @code{or}-type hook---the first
function that returns non-@code{nil} will terminate the hook call.
@end defvr


@node Standard Properties, Session Management, Standard Hooks, Top
@chapter Standard Window Properties
@cindex Standard window properties
@cindex Window properties, standard

As described in an earlier section of this manual, each window has a
property list, which may be used to associate arbitrary lisp data with
symbolic keys (@pxref{Window Property Lists}). The following table
documents a subset of the keys currently used.

@vtable @code

@item ignored
When set, the window is ignored in many operations. @xref{Ignored
Windows}.

@item avoid
When set, the window will not be covered by other windows when they
are maximized or newly placed. @xref{Avoided Windows}.

@item workspaces
A list of integers defining the workspaces that the window is a member of, or
nil if the window is sticky.
@xref{Workspaces}.

@item sticky
Whether the window should appear on all workspaces.

@item sticky-viewport
When set, the window will appear in all viewports of its workspace.

@item keymap
An optional, window-local, keymap. @xref{Keymaps}.

@item focus-click-through
When set, and click-to-focus mode is enabled, the click that focuses a
window is passed through to the client window.

@item ignore-window-input-hint
When set the value of the window's input hint is ignored, i.e. the
focus @emph{will} be given to the window when appropriate

@item never-focus
When set the window will @emph{never} be given the input focus

@item focus-when-mapped
Focus the window when it is mapped on to the display.

@item ignore-program-position
When set the window's program-position property is ignored, use this
with windows that set this hint incorrectly.

@item place-mode
When set, the placement mode to be used with this window.

@item placement-weight
When set, the weight assigned to the pixels in this window when doing
fitted window placement.

@item type
The frame-type of the window, or @code{nil}. @xref{Frame Types}.

@item frame-style
The frame style explicitly chosen by the user, or unset. @xref{Frame
Styles}.

@item current-frame-style
The frame style currently used for the window. @xref{Frame Styles}.

@item removed-classes
A list of frame part classes removed from the decorations of this
window. @xref{Removing Frame Parts}.

@item shaded
Is the window shaded? @xref{Shading Windows}.

@item hide-client
Is the client window visible within its frame. Used to implement window
shading.

@item depth
An integer, the layer that the window is a member of. Layer zero is the
depth of ``normal'' windows, negative depths are below this level,
while positive depths are above. @xref{Window Stacking}.

@item placed
Has the window been placed in a position yet? The
@code{place-window-hook} is only called when this is unset.

@item iconified
Is the window iconified? @xref{Iconifying Windows}.

@item gravity
When set, overrides the window gravity field of the window's size
hints. May be one of the symbols: @code{north-west}, @code{north},
@code{north-east}, @code{west}, @code{center}, @code{east},
@code{south-west}, @code{south}, @code{south-east}.

@item fixed-position
When set, the user is not allowed to change the position of this window.

@item client-set-position
When set, the program owning the window has manually moved the window
after it was mapped.

@end vtable


@node Session Management, Low-level X Interface, Standard Properties, Top
@chapter Session Management
@cindex Session management

Sawfish has fully integrated support for the X session management
protocols. Also, this support is extensible to allow all Lisp modules
to save and reload their own window state.

There are two methods of doing this. If the module only wants to save
and restore the values of properties in each window's property list
(i.e. those values set via @code{window-put}), then the following
functions may be used:

@defun sm-add-saved-properties &rest properties
@defunx sm-add-restored-properties &rest properties
Arrange for all symbols @var{properties} to be saved or restored with
the session.
@end defun

@defvar sm-saved-window-properties
@defvarx sm-restored-window-properties
Lists of properties (symbols) to be saved or restored with each
session.
@end defvar

If a Lisp module chooses to use this method it may add a function to
the @code{add-window-hook} to act on the reloaded properties when the
session is reloaded.

For more complex window properties that can't be saved straight from
the window's plist two hooks are available:

@defvar sm-window-save-functions
A list of functions, each of which is called when the state of each
window is saved. Each function is called with a single argument (the
window) and should return a list of alist elements that will be saved
in the state file. (As such, only values with valid read syntaxes may
be included.)
@end defvar

@defvar sm-restore-window-hook
List of functions called when the state of a window is restored. Each
is called with arguments @code{(@var{window} @var{alist})}, where
@var{alist} defines the state saved for the window.

Each function should look for the properties it saved, and then take
any action dependent on the values.
@end defvar

The following hook is also called.

@defvar sm-after-restore-hook
Hook called after loading a saved session.
@end defvar

@defvar sm-save-directory
The directory that will contain all Sawfish sessions.  It must be a
string.  By default it is @code{"~/.sawfish/sessions"}.
@end defvar

@defvar sm-sloppy-id-matching
When loading sessions, the algorithm that matches saved session data
to running clients requires that if one has a session id, then so must
the other, and they must match. Setting this variable to true turns
that feature off, allowing some broken clients to be session managed.
Defaults to false.
@end defvar

@node Low-level X Interface, FAQ, Session Management, Top
@chapter Low-level X Interface

@menu
* X Server::
* X Windows::
* X Selections::
* X Keysyms::
* X Bitmaps and Pixmaps::
* X Drawing::
* Available X Symbols::
@end menu


@node X Server, X Windows, Low-level X Interface, Low-level X Interface
@section X Server

@defun x-server-timestamp &optional from-server store
Return a recent X server timestamp as an integer.

If @var{from-server} is non-@var{nil}, the timestamp is read directly
from the server; otherwise the most recent timestamp seen by the
window manager (i.e., from an event) is returned.

If @var{store} is true, this becomes the most recent timestamp seen by
the window manager.
@end defun


@node X Windows, X Selections, X Server, Low-level X Interface
@section X Windows

@defun x-create-window (x . y) (width . height) bw attrs &optional event-handler
Create a new X window at @code{(@var{x}, @var{y})} with dimensions
@code{(@var{width}, @var{height})} and border width @var{bw}.
@var{Attrs} is an alist mapping attribute names to values.  Allowed
attribute names are @code{background} and @code{border-color}.
@end defun

@defun x-configure-window window attrs
Reconfigure the window associated with @var{window}.  @var{Attrs} is 
an alist mapping attribute names to values.  Allowed attribute names
are @code{x}, @code{y}, @code{width}, @code{height} and
@code{border-width}.
@end defun

@defun x-destroy-window window
Destroy the X window @var{window}.
@end defun

@defun x-map-window window &optional unraised
Map the window associated with @var{window} to the display.  If
@var{unraised} is not specified, the window will be mapped at the top
of the window stack.
@end defun

@defun x-unmap-window window
Unmap the window associated with @var{window}.
@end defun

@defun x-window-id window
Return the X window ID (an integer) associated with @var{window}.
@end defun

@defun x-window-p obj
Return @code{t} if @var{obj} is associated with an X window object.
@end defun

@defun x-change-window-attributes window attrs
Set attributes of the window associated with @var{window}.
@var{Attrs} is an alist mapping attribute names (symbols) to values.
Allowed attribute names are @code{background} and @code{border-color}.
@end defun


@node X Selections, X Keysyms, X Windows, Low-level X Interface
@section X Selections

@defun x-get-selection sel
Return the string corresponding to the current value of the X11
selection defined by @var{sel}, or @code{nil} if the selection
currently has no value.  @var{Sel} should be one of
@code{PRIMARY}, @code{SECONDARY} or @code{CLIPBOARD}.
@end defun

@defun x-selection-active-p sel
Returns t if the X11 selection defined by the symbol @var{sel} is
available for reading.  @var{Sel} should be one of @code{PRIMARY},
@code{SECONDARY} or @code{CLIPBOARD}.
@end defun


@node X Keysyms, X Bitmaps and Pixmaps, X Selections, Low-level X Interface
@section X Keysyms

@defun x-keysym-name ks
Return the Lisp symbol naming the X11 keysym represented by the
integer @var{ks}.
@end defun

@defun x-lookup-keysym name
Return the X11 keysym (an integer) named by the Lisp symbol
@var{name}.
@end defun


@node X Bitmaps and Pixmaps, X Drawing, X Keysyms, Low-level X Interface
@section X Windows

@defun x-bitmap-p
Return @code{t} if @var{arg} is an X-bitmap object.
@end defun

@defun x-create-bitmap (width . height)
Create a bitmap of size @var{width}x@var{height}.
@end defun

@defun x-create-pixmap (width . height)
Create a pixmap of size @var{width}x@var{height}.
@end defun

@defun x-destroy-drawable drawable
Destroy the X drawable @var{drawable}.
@end defun

@defun x-drawable-height drawable
Return the height in pixels of @var{drawable}.
@end defun

@defun x-drawable-id drawable
Return the X11 drawable-ID (an integer) associated with
@var{drawable}.
@end defun

@defun x-drawable-p obj
Return @code{t} if @var{obj} is an X drawable object.
@end defun

@defun x-drawable-width drawable
Return the width in pixels of @var{drawable}.
@end defun

@defun x-grab-image-from-drawable drawable mask
Return a new image object copied from @var{drawable}.  @var{Mask} is a
stencil mask for the image; black pixels in @var{mask} become
transparent in the returned image.
@end defun

@defun x-pixmap-p obj
Return @code{t} if @var{obj} is an X pixmap object.
@end defun


@node X Drawing, Available X Symbols, X Bitmaps and Pixmaps, Low-level X Interface
@section X Windows

@defun x-clear-window window
Clear the window associated with @var{window} to its background color.
@end defun

@defun x-copy-area window gc (x . y) (width . height) (dest-x . dest-y)
Copy a region of @var{window} with top-left corner @code{(@var{x},
@var{y})} and dimensions @code{(@var{width}, @var{height})} to the
position @code{(@var{dest-x}, @var{dest-y})} using @var{gc}.
@end defun

@defun x-create-gc window attrs
Create a new GC for the specified window @var{window}.  @var{Attrs} is
an alist mapping attributes to values.  Allowed attribute names are
@code{foreground}, @code{background}, @code{line-width},
@code{line-style}, @code{cap-style}, @code{join-style},
@code{fill-style}, @code{fill-rule}, @code{arc-mode}, @code{tile},
@code{stipple}, @code{ts-x-origin}, @code{ts-y-origin},
@code{clip-mask}, @code{clip-x-origin}, @code{clip-y-origin} and
@code{function}.
@end defun

@defun x-change-gc gc attrs
Sets attributes of the X Graphical Context.  @var{Attrs} is an
association list of attribute names and values.  Allowed attribute
names are @code{foreground}, @code{background}, @code{line-width},
@code{line-style}, @code{cap-style}, @code{join-style},
@code{fill-style}, @code{fill-rule}, @code{arc-mode}, @code{tile},
@code{stipple}, @code{ts-x-origin}, @code{ts-y-origin},
@code{clip-mask}, @code{clip-x-origin}, @code{clip-y-origin} and
@code{function}.
@end defun

@defun x-create-root-xor-gc
Create a graphics context specialized for XOR-ing onto the root
window.  This is used for drawing outlines for window movement.
@end defun

@defun x-destroy-gc gc
Destroy the X graphics context @var{gc}.
@end defun

@defun x-draw-arc window gc (x . y) (width . height) (angle1 . angle2)
Draw a single circular or elliptical arc in @var{window} using the
graphics context @var{gc}.  The center of the circle or ellipse is the
center of an imaginary rectangle at @code{(@var{x}, @var{y})}.  The
major and minor axes are the @code{(@var{width}, @var{height})} of
that rectangle.  The arc sweeps from @var{angle1} to @var{angle2};
positive angles are rotated counter-clockwise from zero, and negative
angles are rotated clockwise from zero.
@end defun

@defun x-draw-image image window (x . y) &optional (width . height)
Render the image object @var{image} in @var{window} at position
@code{(@var{x}, @var{y})}.  If @var{width} and @var{height} are
defined the image is first scaled to these dimensions; otherwise it is
drawn using its natural dimensions.
@end defun

@defun x-draw-line window gc (x1 . y1) (x2 . y2)
Draw a line from @code{(@var{x1}, @var{y1})} to @code{(@var{x2},
@var{y2})} in @var{window} using the graphics context @var{gc}.
@end defun

@defun x-draw-rectangle window gc (x . y) (width . height)
Draw a rectangle with its top-left corner at @code{(@var{x}, @var{y})}
and dimensions @code{(@var{width}, @var{height})} in @var{window}
using the graphics context @var{gc}.
@end defun

@defun x-draw-string window gc (x . y) string &optional font
Draw the specified string at @code{(@var{x}, @var{y})} in @var{window}
using the graphics context @var{gc}.  If @var{font} is specified use
that font.
@end defun

@defun x-fill-arc window gc (x . y) (width . height) (angle1 . angle2)
Draw a single filled circular or elliptical arc in @var{window} using
the graphics context @var{gc}.  The center of the circle or ellipse is
the center of an imaginary rectangle at @code{(@var{x}, @var{y})}.
The major and minor axes are the @code{(@var{width}, @var{height})} of
that rectangle.  The arc sweeps from @var{angle1} to @var{angle2};
positive angles are rotated counter-clockwise from zero, and negative
angles are rotated clockwise from zero.
@end defun

@defun x-fill-polygon window gc points &optional draw-mode
Draw a single filled polygon in @var{window} using
the graphics context @var{gc}.  @var{Points} is a list of
@code{(@var{x}, @var{y})} pairs that defines the polygon vertices.

@var{Draw-mode} is a hint to the X server on how to draw the polygon;
if supplied, it should be one of the symbols @code{convex} or
@code{non-convex}.  The default mode is ``Convex''.
@end defun

@defun x-fill-rectangle window gc (x . y) (width . height)
Draw a filled rectangle with its top-left corner at @code{(@var{x},
@var{y})} and dimensions @code{(@var{width}, @var{height})} in
@var{window} using the graphics context @var{gc}.
@end defun

@defun x-gc-p obj
Returns @code{t} if @var{obj} is an X GraphicsContext object.
@end defun

@defun x-gc-set-dashes gc pixels-list &optional offset
Set the dash style of graphics context @var{gc} to the value of
@var{pixels-list}.  @var{Pixels-list} is a list of cons cells
@code{((pixels-on . pixels-off) ...)} indicating runs of on and off
pixels in a dash segment.  If @var{offset} is given, this should be an
integer indicating the number of pixels to offset the dashes.
@end defun

@defun x-window-back-buffer window
Return the X object ID (an integer) for the back buffer associated
with @var{window}.  If no such back buffer exists, the function will
attempt to create one.

If the function is unable to find or create a back buffer (possibly
because the X server does not support them), it returns the window's
own ID.
@end defun

@defun x-window-swap-buffers window
Swap the fore and back buffers of the window associated with
@var{window}.  If the X server does not support double buffers, the
function quietly does nothing.
@end defun


@node Available X Symbols,  , X Drawing, Low-level X Interface
@section Available X Symbols

The following symbols can be used where X window attributes are
expected:

@table @code
@item border-width
@itemx border-color
@itemx expose
@itemx convex
@itemx non-convex
@itemx line-width
@itemx line-style
@itemx cap-style
@itemx join-style
@itemx fill-style
@itemx fill-rule
@itemx arc-mode
@itemx tile
@itemx stipple
@itemx ts-x-origin
@itemx ts-y-origin
@itemx clip-mask
@itemx clip-x-origin
@itemx clip-y-origin
@end table

The following symbols can be used where X window attribute values are
expected:

@table @code
@item line-solid
@itemx line-on-off-dash
@itemx line-double-dash
@itemx cap-not-last
@itemx cap-butt
@itemx cap-round
@itemx cap-projecting
@itemx join-miter
@itemx join-round
@itemx join-bevel
@itemx fill-solid
@itemx fill-tiled
@itemx fill-stippled
@itemx fill-opaque-stippled
@itemx even-odd-rule
@itemx winding-rule
@itemx arc-chord
@itemx arc-pie-slice
@itemx function
@itemx clear
@itemx and
@itemx and-reverse
@itemx copy
@itemx and-inverted
@itemx no-op
@itemx xor
@itemx or
@itemx nor
@itemx equiv
@itemx invert
@itemx or-reverse
@itemx copy-inverted
@itemx or-inverted
@itemx nand
@itemx set
@end table


@node FAQ, Function Index, Low-level X Interface, Top

@include faq.texi


@node Function Index, Variable Index, FAQ, Top
@unnumbered Function Index

@printindex fn


@node Variable Index, Concept Index, Function Index, Top
@unnumbered Variable Index

@printindex vr


@node Concept Index, , Variable Index, Top
@unnumbered Concept Index

@printindex cp


@contents
@bye