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
|
/* window object */
/* vim: set sw=2 et: */
/*
* Copyright (C) 2001 Havoc Pennington
* Copyright (C) 2003 Kim Woelders
* Copyright (C) 2003 Red Hat, Inc.
* Copyright (C) 2006-2007 Vincent Untz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <glib/gi18n-lib.h>
#include <string.h>
#include <time.h>
#include "window.h"
#include "class-group.h"
#include "util.h"
#include "xutils.h"
#include "private.h"
#include "wnck-enum-types.h"
#include "wnck-marshal.h"
/**
* SECTION:window
* @short_description: an object representing a window.
* @see_also: #WnckWorkspace, #WnckApplication, #WnckClassGroup
* @stability: Unstable
*
* The #WnckWindow objects are always owned by libwnck and must not be
* referenced or unreferenced.
*/
#define FALLBACK_NAME _("Untitled window")
#define ALL_WORKSPACES (0xFFFFFFFF)
static GHashTable *window_hash = NULL;
/* Keep 0-7 in sync with the numbers in the WindowState enum. Yeah I'm
* a loser.
*/
#define COMPRESS_STATE(window) \
( ((window)->priv->is_minimized << 0) | \
((window)->priv->is_maximized_horz << 1) | \
((window)->priv->is_maximized_vert << 2) | \
((window)->priv->is_shaded << 3) | \
((window)->priv->skip_pager << 4) | \
((window)->priv->skip_taskbar << 5) | \
((window)->priv->is_sticky << 6) | \
((window)->priv->is_hidden << 7) | \
((window)->priv->is_fullscreen << 8) | \
((window)->priv->demands_attention << 9) | \
((window)->priv->is_urgent << 10)| \
((window)->priv->is_above << 11)| \
((window)->priv->is_below << 12))
struct _WnckWindowPrivate
{
Window xwindow;
WnckScreen *screen;
WnckApplication *app;
WnckClassGroup *class_group;
Window group_leader;
Window transient_for;
GdkRectangle icon_geometry;
char *name;
char *icon_name;
char *session_id;
char *session_id_utf8;
int pid;
int workspace;
gint sort_order;
WnckWindowType wintype;
GdkPixbuf *icon;
GdkPixbuf *mini_icon;
WnckIconCache *icon_cache;
WnckWindowActions actions;
int x;
int y;
int width;
int height;
int left_frame;
int right_frame;
int top_frame;
int bottom_frame;
char *startup_id;
char *res_class;
char *res_name;
/* true if transient_for points to root window,
* not another app window
*/
guint transient_for_root : 1;
/* window state */
guint is_minimized : 1;
guint is_maximized_horz : 1;
guint is_maximized_vert : 1;
guint is_shaded : 1;
guint is_above : 1;
guint is_below : 1;
guint skip_pager : 1;
guint skip_taskbar : 1;
guint is_sticky : 1;
guint is_hidden : 1;
guint is_fullscreen : 1;
guint demands_attention : 1;
guint is_urgent : 1;
time_t needs_attention_time;
/* _NET_WM_STATE_HIDDEN doesn't map directly into an
* externally-visible state (it determines the WM_STATE
* interpretation)
*/
guint net_wm_state_hidden : 1;
guint wm_state_iconic : 1;
/* idle handler for updates */
guint update_handler;
/* if you add flags, be sure to set them
* when we create the window so we get an initial update
*/
guint need_update_name : 1;
guint need_update_state : 1;
guint need_update_wm_state : 1;
guint need_update_icon_name : 1;
guint need_update_workspace : 1;
guint need_update_actions : 1;
guint need_update_wintype : 1;
guint need_update_transient_for : 1;
guint need_update_startup_id : 1;
guint need_update_wmclass : 1;
guint need_update_wmhints : 1;
guint need_update_frame_extents : 1;
guint need_emit_name_changed : 1;
guint need_emit_icon_changed : 1;
};
G_DEFINE_TYPE (WnckWindow, wnck_window, G_TYPE_OBJECT);
#define WNCK_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), WNCK_TYPE_WINDOW, WnckWindowPrivate))
enum {
NAME_CHANGED,
STATE_CHANGED,
WORKSPACE_CHANGED,
ICON_CHANGED,
ACTIONS_CHANGED,
GEOMETRY_CHANGED,
LAST_SIGNAL
};
static void wnck_window_init (WnckWindow *window);
static void wnck_window_class_init (WnckWindowClass *klass);
static void wnck_window_finalize (GObject *object);
static void emit_name_changed (WnckWindow *window);
static void emit_state_changed (WnckWindow *window,
WnckWindowState changed_mask,
WnckWindowState new_state);
static void emit_workspace_changed (WnckWindow *window);
static void emit_icon_changed (WnckWindow *window);
static void emit_actions_changed (WnckWindow *window,
WnckWindowActions changed_mask,
WnckWindowActions new_actions);
static void emit_geometry_changed (WnckWindow *window);
static void update_name (WnckWindow *window);
static void update_state (WnckWindow *window);
static void update_wm_state (WnckWindow *window);
static void update_icon_name (WnckWindow *window);
static void update_workspace (WnckWindow *window);
static void update_actions (WnckWindow *window);
static void update_wintype (WnckWindow *window);
static void update_transient_for (WnckWindow *window);
static void update_startup_id (WnckWindow *window);
static void update_wmclass (WnckWindow *window);
static void update_frame_extents (WnckWindow *window);
static void unqueue_update (WnckWindow *window);
static void queue_update (WnckWindow *window);
static void force_update_now (WnckWindow *window);
static WnckWindow* find_last_transient_for (GList *windows,
Window xwindow);
static guint signals[LAST_SIGNAL] = { 0 };
static void
wnck_window_init (WnckWindow *window)
{
window->priv = WNCK_WINDOW_GET_PRIVATE (window);
window->priv->xwindow = None;
window->priv->name = NULL;
window->priv->app = NULL;
window->priv->class_group = NULL;
window->priv->group_leader = None;
window->priv->transient_for = None;
window->priv->icon_geometry.width = -1; /* invalid cached value */
window->priv->name = NULL;
window->priv->icon_name = NULL;
window->priv->session_id = NULL;
window->priv->session_id_utf8 = NULL;
window->priv->pid = 0;
window->priv->workspace = -1;
window->priv->sort_order = G_MAXINT;
/* FIXME: should we have an invalid window type for this? */
window->priv->wintype = 0;
window->priv->icon = NULL;
window->priv->mini_icon = NULL;
window->priv->icon_cache = _wnck_icon_cache_new ();
window->priv->actions = 0;
window->priv->x = 0;
window->priv->y = 0;
window->priv->width = 0;
window->priv->height = 0;
window->priv->left_frame = 0;
window->priv->right_frame = 0;
window->priv->top_frame = 0;
window->priv->bottom_frame = 0;
window->priv->startup_id = NULL;
window->priv->res_class = NULL;
window->priv->res_name = NULL;
window->priv->transient_for_root = FALSE;
window->priv->is_minimized = FALSE;
window->priv->is_maximized_horz = FALSE;
window->priv->is_maximized_vert = FALSE;
window->priv->is_shaded = FALSE;
window->priv->is_above = FALSE;
window->priv->is_below = FALSE;
window->priv->skip_pager = FALSE;
window->priv->skip_taskbar = FALSE;
window->priv->is_sticky = FALSE;
window->priv->is_hidden = FALSE;
window->priv->is_fullscreen = FALSE;
window->priv->demands_attention = FALSE;
window->priv->is_urgent = FALSE;
window->priv->needs_attention_time = 0;
window->priv->net_wm_state_hidden = FALSE;
window->priv->wm_state_iconic = FALSE;
window->priv->update_handler = 0;
window->priv->need_update_name = FALSE;
window->priv->need_update_state = FALSE;
window->priv->need_update_wm_state = FALSE;
window->priv->need_update_icon_name = FALSE;
window->priv->need_update_workspace = FALSE;
window->priv->need_update_actions = FALSE;
window->priv->need_update_wintype = FALSE;
window->priv->need_update_transient_for = FALSE;
window->priv->need_update_startup_id = FALSE;
window->priv->need_update_wmclass = FALSE;
window->priv->need_update_wmhints = FALSE;
window->priv->need_update_frame_extents = FALSE;
window->priv->need_emit_name_changed = FALSE;
window->priv->need_emit_icon_changed = FALSE;
}
static void
wnck_window_class_init (WnckWindowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (WnckWindowPrivate));
object_class->finalize = wnck_window_finalize;
/**
* WnckWindow::name-changed:
* @window: the #WnckWindow which emitted the signal.
*
* Emitted when the name of @window changes.
*/
signals[NAME_CHANGED] =
g_signal_new ("name_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WnckWindowClass, name_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* WnckWindow::state-changed:
* @window: the #WnckWindow which emitted the signal.
* @changed_mask: the bitmask containing bits set for all states of @window
* that have changed.
* @new_state: the new state of @window.
*
* Emitted when the state of @window changes. This can happen when @window is
* (un)minimized, (un)maximized, (un)sticked, (un)shaded, (un)made above,
* (un)made below, (un)set fullscreen, when it needs attention, etc. See
* #WnckWindowState for the complete list of states that might have changed.
*/
signals[STATE_CHANGED] =
g_signal_new ("state_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WnckWindowClass, state_changed),
NULL, NULL,
_wnck_marshal_VOID__FLAGS_FLAGS,
G_TYPE_NONE, 2,
WNCK_TYPE_WINDOW_STATE, WNCK_TYPE_WINDOW_STATE);
/**
* WnckWindow::workspace-changed:
* @window: the #WnckWindow which emitted the signal.
*
* Emitted when the current workspace of @window changes, or if @window has
* been pinned or unpinned.
*/
signals[WORKSPACE_CHANGED] =
g_signal_new ("workspace_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WnckWindowClass, workspace_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* WnckWindow::icon-changed:
* @window: the #WnckWindow which emitted the signal.
*
* Emitted when the icon of @window changes.
*/
signals[ICON_CHANGED] =
g_signal_new ("icon_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WnckWindowClass, icon_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* WnckWindow::actions-changed:
* @window: the #WnckWindow which emitted the signal.
* @changed_mask: the bitmask containing bits set for all actions
* availabilities for @window that have changed.
* @new_state: the new actions availabilities for @window.
*
* Emitted when the actions availabilities for @window change.
*/
signals[ACTIONS_CHANGED] =
g_signal_new ("actions_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WnckWindowClass, actions_changed),
NULL, NULL,
_wnck_marshal_VOID__FLAGS_FLAGS,
G_TYPE_NONE, 2,
WNCK_TYPE_WINDOW_ACTIONS,
WNCK_TYPE_WINDOW_ACTIONS);
/**
* WnckWindow::geometry-changed:
* @window: the #WnckWindow which emitted the signal.
*
* Emitted when the geometry of @window changes.
*/
signals[GEOMETRY_CHANGED] =
g_signal_new ("geometry_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WnckWindowClass, geometry_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
static void
wnck_window_finalize (GObject *object)
{
WnckWindow *window;
window = WNCK_WINDOW (object);
unqueue_update (window);
if (window->priv->app)
g_object_unref (G_OBJECT (window->priv->app));
window->priv->app = NULL;
if (window->priv->class_group)
g_object_unref (G_OBJECT (window->priv->class_group));
window->priv->class_group = NULL;
g_free (window->priv->name);
window->priv->name = NULL;
g_free (window->priv->icon_name);
window->priv->icon_name = NULL;
g_free (window->priv->session_id);
window->priv->session_id = NULL;
g_free (window->priv->session_id_utf8);
window->priv->session_id_utf8 = NULL;
if (window->priv->icon)
g_object_unref (G_OBJECT (window->priv->icon));
window->priv->icon = NULL;
if (window->priv->mini_icon)
g_object_unref (G_OBJECT (window->priv->mini_icon));
window->priv->mini_icon = NULL;
_wnck_icon_cache_free (window->priv->icon_cache);
window->priv->icon_cache = NULL;
g_free (window->priv->startup_id);
window->priv->startup_id = NULL;
g_free (window->priv->res_class);
window->priv->res_class = NULL;
g_free (window->priv->res_name);
window->priv->res_name = NULL;
G_OBJECT_CLASS (wnck_window_parent_class)->finalize (object);
}
/**
* wnck_window_get:
* @xwindow: an X window ID.
*
* Gets a preexisting #WnckWindow for the X window @xwindow. This will not
* create a #WnckWindow if none exists. The function is robust against bogus
* window IDs.
*
* Return value: (transfer none): the #WnckWindow for @xwindow. The returned
* #WnckWindow is owned by libwnck and must not be referenced or unreferenced.
**/
WnckWindow*
wnck_window_get (gulong xwindow)
{
if (window_hash == NULL)
return NULL;
else
return g_hash_table_lookup (window_hash, &xwindow);
}
/**
* wnck_window_get_screen:
* @window: a #WnckWindow.
*
* Gets the #WnckScreen @window is on.
*
* Return value: (transfer none): the #WnckScreen @window is on. The returned
* #WnckScreen is owned by libwnck and must not be referenced or unreferenced.
**/
WnckScreen*
wnck_window_get_screen (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
return window->priv->screen;
}
WnckWindow*
_wnck_window_create (Window xwindow,
WnckScreen *screen,
gint sort_order)
{
WnckWindow *window;
if (window_hash == NULL)
window_hash = g_hash_table_new (_wnck_xid_hash, _wnck_xid_equal);
g_return_val_if_fail (g_hash_table_lookup (window_hash, &xwindow) == NULL,
NULL);
window = g_object_new (WNCK_TYPE_WINDOW, NULL);
window->priv->xwindow = xwindow;
window->priv->screen = screen;
g_hash_table_insert (window_hash, &window->priv->xwindow, window);
/* Hash now owns one ref, caller gets none */
/* Note that xwindow may correspond to a WnckApplication's xwindow,
* that's why we select the union of the mask we want for Application
* and the one we want for window
*/
_wnck_select_input (window->priv->xwindow,
WNCK_APP_WINDOW_EVENT_MASK);
/* Default the group leader to the window itself; it is set in
* update_wmhints() if a different group leader is specified.
*/
window->priv->group_leader = window->priv->xwindow;
window->priv->session_id =
_wnck_get_session_id (window->priv->xwindow);
window->priv->pid =
_wnck_get_pid (window->priv->xwindow);
window->priv->x = 0;
window->priv->y = 0;
window->priv->width = 0;
window->priv->height = 0;
_wnck_get_window_geometry (WNCK_SCREEN_XSCREEN (window->priv->screen),
xwindow,
&window->priv->x,
&window->priv->y,
&window->priv->width,
&window->priv->height);
window->priv->sort_order = sort_order;
window->priv->need_update_name = TRUE;
window->priv->need_update_state = TRUE;
window->priv->need_update_icon_name = TRUE;
window->priv->need_update_wm_state = TRUE;
window->priv->need_update_workspace = TRUE;
window->priv->need_update_actions = TRUE;
window->priv->need_update_wintype = TRUE;
window->priv->need_update_transient_for = TRUE;
window->priv->need_update_startup_id = TRUE;
window->priv->need_update_wmclass = TRUE;
window->priv->need_update_wmhints = TRUE;
window->priv->need_update_frame_extents = TRUE;
window->priv->need_emit_name_changed = FALSE;
window->priv->need_emit_icon_changed = FALSE;
force_update_now (window);
return window;
}
void
_wnck_window_destroy (WnckWindow *window)
{
g_return_if_fail (wnck_window_get (window->priv->xwindow) == window);
g_hash_table_remove (window_hash, &window->priv->xwindow);
g_return_if_fail (wnck_window_get (window->priv->xwindow) == NULL);
window->priv->xwindow = None;
/* remove hash's ref on the window */
g_object_unref (G_OBJECT (window));
}
static Display *
_wnck_window_get_display (WnckWindow *window)
{
return DisplayOfScreen (WNCK_SCREEN_XSCREEN (window->priv->screen));
}
/**
* wnck_window_has_name:
* @window: a #WnckWindow.
*
* Checks whether or not @window has a name. wnck_window_get_name()
* will always return some value, even if @window has no name set;
* wnck_window_has_name() can be used to tell if that name is
* real or not.
*
* For icons titles, use wnck_window_has_icon_name() instead.
*
* Return value: %TRUE if wnck_window_get_name() returns @window<!-- -->'s
* name, %FALSE if it returns a fallback name.
*
* Since: 2.16
**/
gboolean
wnck_window_has_name (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->name != NULL;
}
/**
* wnck_window_get_name:
* @window: a #WnckWindow.
*
* Gets the name of @window, as it should be displayed in a pager
* or tasklist. Always returns some value, even if @window has no name
* set; use wnck_window_has_name() if you need to know whether the returned
* name is "real" or not.
*
* For icons titles, use wnck_window_get_icon_name() instead.
*
* Return value: the name of @window, or a fallback name if no name is
* available.
**/
const char*
wnck_window_get_name (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
if (window->priv->name)
return window->priv->name;
else
return FALLBACK_NAME;
}
/**
* wnck_window_has_icon_name:
* @window: a #WnckWindow
*
* Checks whether or not @window has an icon name.
* wnck_window_get_icon_name() will always return some value, even if
* @window has no icon name set; wnck_window_has_icon_name() can
* be used to tell if that icon name is real or not.
*
* (Note that if wnck_window_has_icon_name() returns %FALSE, but
* wnck_window_has_name() returns %TRUE, then the name returned by
* wnck_window_get_icon_name() is @window<!-- -->'s name. Only when both
* methods return %FALSE does wnck_window_get_icon_name() return a
* generic fallback name.)
*
* Return value: %TRUE if wnck_window_get_icon_name() returns
* @window<!-- -->'s icon name, %FALSE if it returns a fallback name.
*
* Since: 2.16
**/
gboolean
wnck_window_has_icon_name (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->icon_name != NULL;
}
/**
* wnck_window_get_icon_name:
* @window: a #WnckWindow
*
* Gets the icon name of @window, as it should be displayed for an icon
* (minimized state). Always returns some value, even if @window has no icon
* name set; use wnck_window_has_icon_name() if you need to know whether the
* returned icon name is "real" or not.
*
* Contrast with wnck_window_get_name(), which returns @window<!-- -->'s
* title, not its icon title.
*
* Return value: the icon name of @window, or a fallback icon name if no icon
* name is available.
**/
const char*
wnck_window_get_icon_name (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
if (window->priv->icon_name)
return window->priv->icon_name;
else if (window->priv->name)
return window->priv->name;
else
return FALLBACK_NAME;
}
char *
_wnck_window_get_name_for_display (WnckWindow *window,
gboolean use_icon_name,
gboolean use_state_decorations)
{
const char *name;
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
if (use_icon_name && wnck_window_has_icon_name (window))
name = wnck_window_get_icon_name (window);
else
name = wnck_window_get_name (window);
if (use_state_decorations)
{
if (window->priv->is_shaded)
return g_strdup_printf ("=%s=", name);
else if (window->priv->is_minimized)
return g_strdup_printf ("[%s]", name);
else
return g_strdup (name);
}
else
return g_strdup (name);
}
/**
* wnck_window_get_application:
* @window: a #WnckWindow.
*
* Gets the #WnckApplication to which @window belongs.
*
* Return value: (transfer none): the #WnckApplication to which @window belongs.
* The returned #WnckApplication is owned by libwnck and must not be referenced
* or unreferenced.
**/
WnckApplication*
wnck_window_get_application (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
return window->priv->app;
}
/**
* wnck_window_get_transient:
* @window: a #WnckWindow.
*
* Gets the #WnckWindow for which @window is transient.
*
* Return value: the #WnckWindow for which @window is transient, or %NULL if
* @window is not transient for any #WnckWindow.
*
* Since: 2.12
**/
WnckWindow*
wnck_window_get_transient (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
return wnck_window_get (window->priv->transient_for);
}
/**
* wnck_window_get_group_leader:
* @window: a #WnckWindow.
*
* Gets the group leader of the group of windows to which @window belongs.
*
* Return value: the group leader of the group of windows to which @window
* belongs, or the X window ID of @window if @window does not belong to any
* group.
**/
gulong
wnck_window_get_group_leader (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), None);
return window->priv->group_leader;
}
/**
* wnck_window_get_xid:
* @window: a #WnckWindow.
*
* Gets the X window ID of @window.
*
* Return value: the X window ID of @window.
**/
gulong
wnck_window_get_xid (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), None);
return window->priv->xwindow;
}
/**
* wnck_window_get_class_group:
* @window: a #WnckWindow.
*
* Gets the #WnckClassGroup to which @window belongs.
*
* Return value: (transfer none): the #WnckClassGroup to which @window belongs.
* The returned #WnckClassGroup is owned by libwnck and must not be referenced
* or unreferenced.
*
* Since: 2.2
**/
WnckClassGroup *
wnck_window_get_class_group (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
return window->priv->class_group;
}
/**
* wnck_window_get_session_id:
* @window: a #WnckWindow.
*
* Gets the session ID for @window in Latin-1 encoding.
* NOTE: this is invalid UTF-8. You can't display this
* string in a GTK+ widget without converting to UTF-8.
* See wnck_window_get_session_id_utf8().
*
* Return value: the session ID for @window in Latin-1, or %NULL if @window has
* no session ID.
**/
const char*
wnck_window_get_session_id (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
return window->priv->session_id;
}
/**
* wnck_window_get_session_id_utf8:
* @window: a #WnckWindow.
*
* Gets the session ID for @window in UTF-8 encoding.
* The session ID should be in Latin-1 encoding, so the conversion should work,
* but a broken client could set a session ID that might not be convertable to
* UTF-8.
*
* Return value: the session ID for @window in UTF-8, or %NULL if @window has
* no session ID.
**/
const char*
wnck_window_get_session_id_utf8 (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
if (window->priv->session_id_utf8 == NULL &&
window->priv->session_id != NULL)
{
GString *str;
char *p;
str = g_string_new ("");
p = window->priv->session_id;
while (*p)
{
g_string_append_unichar (str, g_utf8_get_char (p));
p = g_utf8_next_char (p);
}
window->priv->session_id_utf8 = g_string_free (str, FALSE);
}
return window->priv->session_id_utf8;
}
/**
* wnck_window_get_pid:
* @window: a #WnckWindow.
*
* Gets the process ID of @window.
*
* Return value: the process ID of @window, or 0 if none is available.
**/
int
wnck_window_get_pid (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), 0);
return window->priv->pid;
}
/**
* wnck_window_get_sort_order:
* @window: a #WnckWindow.
*
* Gets the sort order of @window, used for ordering of @window in
* #WnckSelector and #WnckTasklist. The sort order is an internal state in
* libwnck. The initial value is defined when the window is created.
*
* Return value: the sort order of @window, or G_MAXINT if none is available.
*
* Since: 2.10
**/
gint
wnck_window_get_sort_order (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), G_MAXINT);
return window->priv->sort_order;
}
/**
* wnck_window_set_sort_order:
* @window: a #WnckWindow.
* @order: new sort order for @window.
*
* Sets the sort order of @window. The sort order is used for ordering of
* @window in #WnckSelector and #WnckTasklist.
*
* Since: 2.20
**/
void wnck_window_set_sort_order (WnckWindow *window,
gint order)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
window->priv->sort_order = order;
return;
}
/**
* wnck_window_get_window_type:
* @window: a #WnckWindow.
*
* Gets the semantic type of @window.
*
* Return value: the semantic type of @window.
**/
WnckWindowType
wnck_window_get_window_type (WnckWindow *window)
{
/* FIXME: should we have an invalid window type for this? */
g_return_val_if_fail (WNCK_IS_WINDOW (window), 0);
return window->priv->wintype;
}
/**
* wnck_window_set_window_type:
* @window: a #WnckWindow.
* @wintype: a semantic type.
*
* Sets the semantic type of @window to @wintype.
*
* Since: 2.12
**/
void
wnck_window_set_window_type (WnckWindow *window, WnckWindowType wintype)
{
Atom atom;
g_return_if_fail (WNCK_IS_WINDOW (window));
switch (wintype) {
case WNCK_WINDOW_NORMAL:
atom = _wnck_atom_get ("_NET_WM_WINDOW_TYPE_NORMAL");
break;
case WNCK_WINDOW_DESKTOP:
atom = _wnck_atom_get ("_NET_WM_WINDOW_TYPE_DESKTOP");
break;
case WNCK_WINDOW_DOCK:
atom = _wnck_atom_get ("_NET_WM_WINDOW_TYPE_DOCK");
break;
case WNCK_WINDOW_DIALOG:
atom = _wnck_atom_get ("_NET_WM_WINDOW_TYPE_DIALOG");
break;
case WNCK_WINDOW_TOOLBAR:
atom = _wnck_atom_get ("_NET_WM_WINDOW_TYPE_TOOLBAR");
break;
case WNCK_WINDOW_MENU:
atom = _wnck_atom_get ("_NET_WM_WINDOW_TYPE_MENU");
break;
case WNCK_WINDOW_UTILITY:
atom = _wnck_atom_get ("_NET_WM_WINDOW_TYPE_UTILITY");
break;
case WNCK_WINDOW_SPLASHSCREEN:
atom = _wnck_atom_get ("_NET_WM_WINDOW_TYPE_SPLASH");
break;
default:
return;
}
_wnck_error_trap_push ();
XChangeProperty (_wnck_window_get_display (window),
window->priv->xwindow,
_wnck_atom_get ("_NET_WM_WINDOW_TYPE"),
XA_ATOM, 32, PropModeReplace,
(guchar *)&atom, 1);
_wnck_error_trap_pop ();
}
/**
* wnck_window_is_minimized:
* @window: a #WnckWindow.
*
* Gets whether @window is minimized. Minimization state may change anytime
* a #WnckWindow::state-changed signal gets emitted.
*
* Return value: %TRUE if @window is minimized, %FALSE otherwise.
**/
gboolean
wnck_window_is_minimized (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->is_minimized;
}
/**
* wnck_window_needs_attention:
* @window: a #WnckWindow.
*
* Gets whether @window needs attention. This state may change anytime
* a #WnckWindow::state-changed signal gets emitted.
*
* This state depends on flags such as the demands_attention and is_urgent
* hints.
*
* Return value: %TRUE if @window needs attention, %FALSE otherwise.
*
* Since: 2.12
**/
gboolean
wnck_window_needs_attention (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->demands_attention || window->priv->is_urgent;
}
time_t
_wnck_window_get_needs_attention_time (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), 0);
return window->priv->needs_attention_time;
}
/* Return whether the transient of @window needs attention */
static WnckWindow *
transient_needs_attention (WnckWindow *window)
{
GList *windows;
WnckWindow *transient;
if (!WNCK_IS_WINDOW (window))
return NULL;
windows = wnck_screen_get_windows_stacked (window->priv->screen);
transient = window;
while ((transient = find_last_transient_for (windows, transient->priv->xwindow)))
{
/* catch transient cycles */
if (transient == window)
return NULL;
if (wnck_window_needs_attention (transient))
return transient;
}
return FALSE;
}
time_t
_wnck_window_or_transient_get_needs_attention_time (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), 0);
if (_wnck_window_get_needs_attention_time (window) == 0)
{
WnckWindow *transient;
transient = transient_needs_attention (window);
if (transient)
return _wnck_window_get_needs_attention_time (transient);
else
return 0;
}
else
return _wnck_window_get_needs_attention_time (window);
}
/**
* wnck_window_or_transient_needs_attention:
* @window: a #WnckWindow.
*
* Gets whether @window or one of its transients needs attention. This state
* may change anytime a #WnckWindow::state-changed signal gets emitted.
*
* Return value: %TRUE if @window or one of its transients needs attention,
* %FALSE otherwise.
*
* Since: 2.12
**/
gboolean
wnck_window_or_transient_needs_attention (WnckWindow *window)
{
return wnck_window_needs_attention (window) ||
transient_needs_attention (window) != NULL;
}
/**
* wnck_window_is_maximized_horizontally:
* @window: a #WnckWindow.
*
* Gets whether @window is maximized horizontally. Horizontal maximization
* state may change anytime a #WnckWindow::state-changed signal gets emitted.
*
* Return value: %TRUE if @window is maximized horizontally, %FALSE otherwise.
**/
gboolean
wnck_window_is_maximized_horizontally (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->is_maximized_horz;
}
/**
* wnck_window_is_maximized_vertically:
* @window: a #WnckWindow.
*
* Gets whether @window is maximized vertically. vertiVal maximization
* state may change anytime a #WnckWindow::state-changed signal gets emitted.
*
* Return value: %TRUE if @window is maximized vertically, %FALSE otherwise.
**/
gboolean
wnck_window_is_maximized_vertically (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->is_maximized_vert;
}
const char*
_wnck_window_get_startup_id (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
if (window->priv->startup_id == NULL &&
window->priv->group_leader != None)
{
WnckApplication *app;
/* Fall back to group leader property */
app = wnck_application_get (window->priv->group_leader);
if (app != NULL)
return wnck_application_get_startup_id (app);
else
return NULL;
}
return window->priv->startup_id;
}
const char*
_wnck_window_get_resource_class (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
return window->priv->res_class;
}
const char*
_wnck_window_get_resource_name (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
return window->priv->res_name;
}
/**
* wnck_window_is_maximized:
* @window: a #WnckWindow.
*
* Gets whether @window is maximized. Maximization state may change
* anytime a #WnckWindow::state-changed signal gets emitted.
*
* As for GDK, "maximized" means both vertically and horizontally. If @window
* is maximized in only one direction, then @window is not considered
* maximized.
*
* Return value: %TRUE if @window is maximized in both directions, %FALSE
* otherwise.
**/
gboolean
wnck_window_is_maximized (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return
window->priv->is_maximized_horz &&
window->priv->is_maximized_vert;
}
/**
* wnck_window_is_shaded:
* @window: a #WnckWindow.
*
* Gets whether @window is shaded. Shade state may change anytime
* a #WnckWindow::state-changed signal gets emitted.
*
* Return value: %TRUE if @window is shaded, %FALSE otherwise.
**/
gboolean
wnck_window_is_shaded (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->is_shaded;
}
/**
* wnck_window_is_above:
* @window: a #WnckWindow.
*
* Gets whether @window is above other windows. This state may change
* anytime a #WnckWindow::state-changed signal gets emitted.
*
* See wnck_window_make_above() for more details on this state.
*
* Return value: %TRUE if @window is above other windows, %FALSE otherwise.
*
* Since: 2.14
**/
gboolean
wnck_window_is_above (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->is_above;
}
/**
* wnck_window_is_below:
* @window: a #WnckWindow.
*
* Gets whether @window is below other windows. This state may change
* anytime a #WnckWindow::state-changed signal gets emitted.
*
* See wnck_window_make_below() for more details on this state.
*
* Return value: %TRUE if @window is below other windows, %FALSE otherwise.
*
* Since: 2.20
**/
gboolean
wnck_window_is_below (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->is_below;
}
/**
* wnck_window_is_skip_pager:
* @window: a #WnckWindow.
*
* Gets whether @window is included on pagers. This state may change
* anytime a #WnckWindow::state-changed signal gets emitted.
*
* Return value: %TRUE if @window is included on pagers, %FALSE otherwise.
**/
gboolean
wnck_window_is_skip_pager (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->skip_pager;
}
/**
* wnck_window_set_skip_pager:
* @window: a #WnckWindow.
* @skip: whether @window should be included on pagers.
*
* Asks the window manager to make @window included or not included on pagers.
**/
void
wnck_window_set_skip_pager (WnckWindow *window,
gboolean skip)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
skip,
_wnck_atom_get ("_NET_WM_STATE_SKIP_PAGER"),
0);
}
/**
* wnck_window_is_skip_tasklist:
* @window: a #WnckWindow.
*
* Gets whether @window is included on tasklists. This state may change
* anytime a #WnckWindow::state-changed signal gets emitted.
*
* Return value: %TRUE if @window is included on tasklists, %FALSE otherwise.
**/
gboolean
wnck_window_is_skip_tasklist (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->skip_taskbar;
}
/**
* wnck_window_is_fullscreen:
* @window: a #WnckWindow.
*
* Gets whether @window is fullscreen. Fullscreen state may change
* anytime a #WnckWindow::state-changed signal gets emitted.
*
* Return value: %TRUE if @window is fullscreen, %FALSE otherwise.
*
* Since: 2.8
**/
gboolean
wnck_window_is_fullscreen (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->is_fullscreen;
}
/**
* wnck_window_set_skip_tasklist:
* @window: a #WnckWindow.
* @skip: whether @window should be included on tasklists.
*
* Asks the window manager to make @window included or not included on
* tasklists.
**/
void
wnck_window_set_skip_tasklist (WnckWindow *window,
gboolean skip)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
skip,
_wnck_atom_get ("_NET_WM_STATE_SKIP_TASKBAR"),
0);
}
/**
* wnck_window_set_fullscreen:
* @window: a #WnckWindow.
* @fullscreen: whether to make @window fullscreen.
*
* Asks the window manager to set the fullscreen state of @window according to
* @fullscreen.
*
* Since: 2.8
**/
void
wnck_window_set_fullscreen (WnckWindow *window,
gboolean fullscreen)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
fullscreen,
_wnck_atom_get ("_NET_WM_STATE_FULLSCREEN"),
0);
}
/**
* wnck_window_is_sticky:
* @window: a #WnckWindow.
*
* Gets whether @window is sticky. Sticky state may change
* anytime a #WnckWindow::state-changed signal gets emitted.
*
* Sticky here means "stuck to the glass", i.e. does not scroll with the
* viewport. In GDK/GTK+ (e.g. gdk_window_stick()/gtk_window_stick()), sticky
* means "stuck to the glass" and <emphasis>also</emphasis> that the window is
* on all workspaces. But here it only means the viewport aspect of it.
*
* Return value: %TRUE if @window is "stuck to the glass", %FALSE otherwise.
**/
gboolean
wnck_window_is_sticky (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->is_sticky;
}
/**
* wnck_window_close:
* @window: a #WnckWindow.
* @timestamp: the X server timestamp of the user interaction event that caused
* this call to occur.
*
* Closes @window.
*
* This function existed before 2.6, but the @timestamp argument was missing
* in earlier versions.
*
* Since: 2.6
**/
void
wnck_window_close (WnckWindow *window,
guint32 timestamp)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_close (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow, timestamp);
}
/**
* wnck_window_minimize:
* @window: a #WnckWindow.
*
* Minimizes @window.
**/
void
wnck_window_minimize (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_iconify (window->priv->xwindow);
}
/**
* wnck_window_unminimize:
* @window: a #WnckWindow.
* @timestamp: the X server timestamp of the user interaction event that caused
* this call to occur.
*
* Unminimizes @window by activating it or one of its transients. See
* wnck_window_activate_transient() for details on how the activation is done.
**/
void
wnck_window_unminimize (WnckWindow *window,
guint32 timestamp)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
wnck_window_activate_transient (window, timestamp);
}
/**
* wnck_window_maximize:
* @window: a #WnckWindow.
*
* Asks the window manager to maximize @window.
**/
void
wnck_window_maximize (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
TRUE,
_wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_VERT"),
_wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_HORZ"));
}
/**
* wnck_window_unmaximize:
* @window: a #WnckWindow.
*
* Asks the window manager to unmaximize @window.
**/
void
wnck_window_unmaximize (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
FALSE,
_wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_VERT"),
_wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_HORZ"));
}
/**
* wnck_window_maximize_horizontally:
* @window: a #WnckWindow.
*
* Asks the window manager to maximize horizontally @window.
**/
void
wnck_window_maximize_horizontally (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
TRUE,
_wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_HORZ"),
0);
}
/**
* wnck_window_unmaximize_horizontally:
* @window: a #WnckWindow.
*
* Asks the window manager to unmaximize horizontally @window.
**/
void
wnck_window_unmaximize_horizontally (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
FALSE,
_wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_HORZ"),
0);
}
/**
* wnck_window_maximize_vertically:
* @window: a #WnckWindow.
*
* Asks the window manager to maximize vertically @window.
**/
void
wnck_window_maximize_vertically (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
TRUE,
_wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_VERT"),
0);
}
/**
* wnck_window_unmaximize_vertically:
* @window: a #WnckWindow.
*
* Asks the window manager to unmaximize vertically @window.
**/
void
wnck_window_unmaximize_vertically (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
FALSE,
_wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_VERT"),
0);
}
/**
* wnck_window_shade:
* @window: a #WnckWindow.
*
* Asks the window manager to shade @window.
**/
void
wnck_window_shade (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
TRUE,
_wnck_atom_get ("_NET_WM_STATE_SHADED"),
0);
}
/**
* wnck_window_unshade:
* @window: a #WnckWindow.
*
* Asks the window manager to unshade @window.
**/
void
wnck_window_unshade (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
FALSE,
_wnck_atom_get ("_NET_WM_STATE_SHADED"),
0);
}
/**
* wnck_window_make_above:
* @window: a #WnckWindow.
*
* Asks the window manager to put @window on top of most windows (@window will
* not be on top of focused fullscreen windows, of other windows with this
* setting and of dock windows).
*
* Since: 2.14
**/
void
wnck_window_make_above (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
TRUE,
_wnck_atom_get ("_NET_WM_STATE_ABOVE"),
0);
}
/**
* wnck_window_unmake_above:
* @window: a #WnckWindow.
*
* Asks the window manager to not put @window on top of most windows, and to
* put it again in the stack with other windows.
*
* Since: 2.14
**/
void
wnck_window_unmake_above (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
FALSE,
_wnck_atom_get ("_NET_WM_STATE_ABOVE"),
0);
}
/**
* wnck_window_make_below:
* @window: a #WnckWindow.
*
* Asks the window manager to put @window below most windows.
*
* Since: 2.20
**/
void
wnck_window_make_below (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
TRUE,
_wnck_atom_get ("_NET_WM_STATE_BELOW"),
0);
}
/**
* wnck_window_unmake_below:
* @window: a #WnckWindow.
*
* Asks the window manager to not put @window below most windows, and to
* put it again in the stack with other windows.
*
* Since: 2.20
**/
void
wnck_window_unmake_below (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
FALSE,
_wnck_atom_get ("_NET_WM_STATE_BELOW"),
0);
}
/**
* wnck_window_stick:
* @window: a #WnckWindow.
*
* Asks the window manager to keep the @window<!-- -->'s position fixed on the
* screen, even when the workspace or viewport scrolls.
**/
void
wnck_window_stick (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
TRUE,
_wnck_atom_get ("_NET_WM_STATE_STICKY"),
0);
}
/**
* wnck_window_unstick:
* @window: a #WnckWindow.
*
* Asks the window manager to not have @window<!-- -->'s position fixed on the
* screen when the workspace or viewport scrolls.
**/
void
wnck_window_unstick (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_state (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
FALSE,
_wnck_atom_get ("_NET_WM_STATE_STICKY"),
0);
}
/**
* wnck_window_keyboard_move:
* @window: a #WnckWindow.
*
* Asks the window manager to start moving @window via the keyboard.
**/
void
wnck_window_keyboard_move (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_keyboard_move (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow);
}
/**
* wnck_window_keyboard_size:
* @window: a #WnckWindow.
*
* Asks the window manager to start resizing @window via the keyboard.
**/
void
wnck_window_keyboard_size (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_keyboard_size (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow);
}
/**
* wnck_window_get_workspace:
* @window: a #WnckWindow.
*
* Gets the current workspace @window is on. If the window is pinned (on all
* workspaces), or not on any workspaces, %NULL may be returned.
*
* Return value: (transfer none): the single current workspace @window is on, or
* %NULL. The returned #WnckWorkspace is owned by libwnck and must not be
* referenced or unreferenced.
**/
WnckWorkspace*
wnck_window_get_workspace (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
if (window->priv->workspace == ALL_WORKSPACES)
return NULL;
else
return wnck_screen_get_workspace (window->priv->screen, window->priv->workspace);
}
/**
* wnck_window_move_to_workspace:
* @window: a #WnckWindow.
* @space: a #WnckWorkspace.
*
* Asks the window manager to move @window to @space. If @window was pinned, it
* will also result in @window being visible only on @space.
**/
void
wnck_window_move_to_workspace (WnckWindow *window,
WnckWorkspace *space)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
g_return_if_fail (WNCK_IS_WORKSPACE (space));
_wnck_change_workspace (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
wnck_workspace_get_number (space));
}
/**
* wnck_window_is_pinned:
* @window: a #WnckWindow.
*
* Gets whether @window is on all workspace. Pinned state may change
* anytime a #WnckWindow::workspace-changed signal gets emitted, but not when
* a #WnckWindow::state-changed gets emitted.
*
* Return value: %TRUE if @window is on all workspaces, %FALSE otherwise.
**/
gboolean
wnck_window_is_pinned (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window->priv->workspace == ALL_WORKSPACES;
}
/**
* wnck_window_pin:
* @window: a #WnckWindow.
*
* Asks the window manager to put @window on all workspaces.
**/
void
wnck_window_pin (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_change_workspace (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
ALL_WORKSPACES);
}
/**
* wnck_window_unpin:
* @window: a #WnckWindow.
*
* Asks the window manager to put @window only in the currently active
* workspace, if @window was previously pinned. If @window was not pinned,
* does not change @window<!-- -->'s workspace. If the active workspace
* is not known for some reason (it should not happen much), sets
* @window<!-- -->'s workspace to the first workspace.
**/
void
wnck_window_unpin (WnckWindow *window)
{
WnckWorkspace *active;
g_return_if_fail (WNCK_IS_WINDOW (window));
if (window->priv->workspace != ALL_WORKSPACES)
return;
active = wnck_screen_get_active_workspace (window->priv->screen);
_wnck_change_workspace (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
active ? wnck_workspace_get_number (active) : 0);
}
/**
* wnck_window_activate:
* @window: a #WnckWindow.
* @timestamp: the X server timestamp of the user interaction event that caused
* this call to occur.
*
* Asks the window manager to make @window the active window. The
* window manager may choose to raise @window along with focusing it, and may
* decide to refuse the request (to not steal the focus if there is a more
* recent user activity, for example).
*
* This function existed before 2.10, but the @timestamp argument was missing
* in earlier versions.
*
* Since: 2.10
**/
void
wnck_window_activate (WnckWindow *window,
guint32 timestamp)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
_wnck_activate (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
timestamp);
}
/**
* wnck_window_is_active:
* @window: a #WnckWindow.
*
* Gets whether @window is the active window on its #WnckScreen.
*
* Return value: %TRUE if @window is the active window on its #WnckScreen,
* %FALSE otherwise.
**/
gboolean
wnck_window_is_active (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return window == wnck_screen_get_active_window (window->priv->screen);
}
/**
* wnck_window_is_most_recently_activated:
* @window: a #WnckWindow.
*
* Gets whether @window is the most recently activated window on its
* #WnckScreen.
*
* The most recently activated window is identical to the active
* window for click and sloppy focus methods (since a window is always
* active in those cases) but differs slightly for mouse focus since
* there often is no active window.
*
* Return value: %TRUE if @window was the most recently activated window on its
* #WnckScreen, %FALSE otherwise.
*
* Since: 2.8
**/
gboolean
wnck_window_is_most_recently_activated (WnckWindow *window)
{
WnckWindow * current;
WnckWindow * previous;
WnckWindow * most_recently_activated_window;
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
current = wnck_screen_get_active_window (window->priv->screen);
previous = wnck_screen_get_previously_active_window (window->priv->screen);
if (current)
most_recently_activated_window = current;
else
most_recently_activated_window = previous;
return (window == most_recently_activated_window);
}
static WnckWindow*
find_last_transient_for (GList *windows,
Window xwindow)
{
GList *tmp;
WnckWindow *retval;
/* find _last_ transient for xwindow in the list */
retval = NULL;
tmp = windows;
while (tmp != NULL)
{
WnckWindow *w = tmp->data;
if (w->priv->transient_for == xwindow &&
w->priv->wintype != WNCK_WINDOW_UTILITY)
retval = w;
tmp = tmp->next;
}
return retval;
}
/**
* wnck_window_activate_transient:
* @window: a #WnckWindow.
* @timestamp: the X server timestamp of the user interaction event that caused
* this call to occur.
*
* If @window has transients, activates the most likely transient
* instead of the window itself. Otherwise activates @window.
*
* FIXME the ideal behavior of this function is probably to activate
* the most recently active window among @window and its transients.
* This is probably best implemented on the window manager side.
*
* This function existed before 2.10, but the @timestamp argument was missing
* in earlier versions.
*
* Since: 2.10
**/
void
wnck_window_activate_transient (WnckWindow *window,
guint32 timestamp)
{
GList *windows;
WnckWindow *transient;
WnckWindow *next;
g_return_if_fail (WNCK_IS_WINDOW (window));
windows = wnck_screen_get_windows_stacked (window->priv->screen);
transient = NULL;
next = find_last_transient_for (windows, window->priv->xwindow);
while (next != NULL)
{
if (next == window)
{
/* catch transient cycles */
transient = NULL;
break;
}
transient = next;
next = find_last_transient_for (windows, transient->priv->xwindow);
}
if (transient != NULL)
wnck_window_activate (transient, timestamp);
else
wnck_window_activate (window, timestamp);
}
/**
* wnck_window_transient_is_most_recently_activated:
* @window: a #WnckWindow.
*
* Gets whether one of the transients of @window is the most
* recently activated window. See
* wnck_window_is_most_recently_activated() for a more complete
* description of what is meant by most recently activated. This
* function is needed because clicking on a #WnckTasklist once will
* activate a transient instead of @window itself
* (wnck_window_activate_transient), and clicking again should
* minimize @window and its transients. (Not doing this can be
* especially annoying in the case of modal dialogs that don't appear
* in the #WnckTaslist).
*
* Return value: %TRUE if one of the transients of @window is the most recently
* activated window, %FALSE otherwise.
*
* Since: 2.12
**/
gboolean
wnck_window_transient_is_most_recently_activated (WnckWindow *window)
{
GList *windows;
WnckWindow *transient;
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
windows = wnck_screen_get_windows_stacked (window->priv->screen);
transient = window;
while ((transient = find_last_transient_for (windows, transient->priv->xwindow)))
{
/* catch transient cycles */
if (transient == window)
return FALSE;
if (wnck_window_is_most_recently_activated (transient))
return TRUE;
}
return FALSE;
}
static void
get_icons (WnckWindow *window)
{
GdkPixbuf *icon;
GdkPixbuf *mini_icon;
icon = NULL;
mini_icon = NULL;
if (_wnck_read_icons (window->priv->xwindow,
window->priv->icon_cache,
&icon,
DEFAULT_ICON_WIDTH, DEFAULT_ICON_HEIGHT,
&mini_icon,
DEFAULT_MINI_ICON_WIDTH,
DEFAULT_MINI_ICON_HEIGHT))
{
window->priv->need_emit_icon_changed = TRUE;
if (window->priv->icon)
g_object_unref (G_OBJECT (window->priv->icon));
if (window->priv->mini_icon)
g_object_unref (G_OBJECT (window->priv->mini_icon));
window->priv->icon = icon;
window->priv->mini_icon = mini_icon;
}
g_assert ((window->priv->icon && window->priv->mini_icon) ||
!(window->priv->icon || window->priv->mini_icon));
}
/**
* wnck_window_get_icon:
* @window: a #WnckWindow.
*
* Gets the icon to be used for @window. If no icon was found, a fallback
* icon is used. wnck_window_get_icon_is_fallback() can be used to tell if the
* icon is the fallback icon.
*
* Return value: the icon for @window. The caller should reference the
* returned <classname>GdkPixbuf</classname> if it needs to keep the icon
* around.
**/
GdkPixbuf*
wnck_window_get_icon (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
get_icons (window);
if (window->priv->need_emit_icon_changed)
queue_update (window); /* not done in get_icons since we call that from
* the update
*/
return window->priv->icon;
}
/**
* wnck_window_get_mini_icon:
* @window: a #WnckWindow.
*
* Gets the mini-icon to be used for @window. If no mini-icon was found, a
* fallback mini-icon is used. wnck_window_get_icon_is_fallback() can be used
* to tell if the mini-icon is the fallback mini-icon.
*
* Return value: the mini-icon for @window. The caller should reference the
* returned <classname>GdkPixbuf</classname> if it needs to keep the icon
* around.
**/
GdkPixbuf*
wnck_window_get_mini_icon (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
get_icons (window);
if (window->priv->need_emit_icon_changed)
queue_update (window); /* not done in get_icons since we call that from
* the update
*/
return window->priv->mini_icon;
}
/**
* wnck_window_get_icon_is_fallback:
* @window: a #WnckWindow.
*
* Gets whether a default fallback icon is used for @window (because none
* was set on @window).
*
* Return value: %TRUE if the icon for @window is a fallback, %FALSE otherwise.
**/
gboolean
wnck_window_get_icon_is_fallback (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
return _wnck_icon_cache_get_is_fallback (window->priv->icon_cache);
}
/**
* wnck_window_get_actions:
* @window: a #WnckWindow.
*
* Gets the actions that can be done for @window.
*
* Return value: bitmask of actions that can be done for @window.
**/
WnckWindowActions
wnck_window_get_actions (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), 0);
return window->priv->actions;
}
/**
* wnck_window_get_state:
* @window: a #WnckWindow.
*
* Gets the state of @window.
*
* Return value: bitmask of active states for @window.
**/
WnckWindowState
wnck_window_get_state (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), 0);
return COMPRESS_STATE (window);
}
/**
* wnck_window_get_client_window_geometry:
* @window: a #WnckWindow.
* @xp: return location for X coordinate in pixels of @window.
* @yp: return location for Y coordinate in pixels of @window.
* @widthp: return location for width in pixels of @window.
* @heightp: return location for height in pixels of @window.
*
* Gets the size and position of @window, as last received
* in a ConfigureNotify event (i.e. this call does not round-trip
* to the server, just gets the last size we were notified of).
* The X and Y coordinates are relative to the root window.
*
* The window manager usually adds a frame around windows. If
* you need to know the size of @window with the frame, use
* wnck_window_get_geometry().
*
* Since: 2.20
**/
void
wnck_window_get_client_window_geometry (WnckWindow *window,
int *xp,
int *yp,
int *widthp,
int *heightp)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
if (xp)
*xp = window->priv->x;
if (yp)
*yp = window->priv->y;
if (widthp)
*widthp = window->priv->width;
if (heightp)
*heightp = window->priv->height;
}
/**
* wnck_window_get_geometry:
* @window: a #WnckWindow.
* @xp: return location for X coordinate in pixels of @window.
* @yp: return location for Y coordinate in pixels of @window.
* @widthp: return location for width in pixels of @window.
* @heightp: return location for height in pixels of @window.
*
* Gets the size and position of @window, including decorations. This
* function uses the information last received in a ConfigureNotify
* event and adjusts it according to the size of the frame that is
* added by the window manager (this call does not round-trip to the
* server, it just gets the last sizes that were notified). The
* X and Y coordinates are relative to the root window.
*
* If you need to know the actual size of @window ignoring the frame
* added by the window manager, use wnck_window_get_client_window_geometry().
**/
void
wnck_window_get_geometry (WnckWindow *window,
int *xp,
int *yp,
int *widthp,
int *heightp)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
if (xp)
*xp = window->priv->x - window->priv->left_frame;
if (yp)
*yp = window->priv->y - window->priv->top_frame;
if (widthp)
*widthp = window->priv->width + window->priv->left_frame + window->priv->right_frame;
if (heightp)
*heightp = window->priv->height + window->priv->top_frame + window->priv->bottom_frame;
}
/**
* wnck_window_set_geometry:
* @window: a #WnckWindow.
* @gravity: the gravity point to use as a reference for the new position.
* @geometry_mask: a bitmask containing flags for what should be set.
* @x: new X coordinate in pixels of @window.
* @y: new Y coordinate in pixels of @window.
* @width: new width in pixels of @window.
* @height: new height in pixels of @window.
*
* Sets the size and position of @window. The X and Y coordinates should be
* relative to the root window.
*
* Note that the new size and position apply to @window with its frame added
* by the window manager. Therefore, using wnck_window_set_geometry() with
* the values returned by wnck_window_get_geometry() should be a no-op, while
* using wnck_window_set_geometry() with the values returned by
* wnck_window_get_client_window_geometry() should reduce the size of @window
* and move it.
*
* Since: 2.16
**/
void
wnck_window_set_geometry (WnckWindow *window,
WnckWindowGravity gravity,
WnckWindowMoveResizeMask geometry_mask,
int x,
int y,
int width,
int height)
{
int gravity_and_flags;
int source;
g_return_if_fail (WNCK_IS_WINDOW (window));
source = _wnck_get_client_type();
gravity_and_flags = gravity;
gravity_and_flags |= geometry_mask << 8;
gravity_and_flags |= source << 12;
x += window->priv->left_frame;
y += window->priv->top_frame;
width -= window->priv->left_frame + window->priv->right_frame;
height -= window->priv->top_frame + window->priv->bottom_frame;
_wnck_set_window_geometry (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
gravity_and_flags, x, y, width, height);
}
/**
* wnck_window_is_visible_on_workspace:
* @window: a #WnckWindow.
* @workspace: a #WnckWorkspace.
*
* Like wnck_window_is_on_workspace(), but also checks that
* the window is in a visible state (i.e. not minimized or shaded).
*
* Return value: %TRUE if @window appears on @workspace in normal state, %FALSE
* otherwise.
**/
gboolean
wnck_window_is_visible_on_workspace (WnckWindow *window,
WnckWorkspace *workspace)
{
WnckWindowState state;
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
g_return_val_if_fail (WNCK_IS_WORKSPACE (workspace), FALSE);
state = wnck_window_get_state (window);
if (state & WNCK_WINDOW_STATE_HIDDEN)
return FALSE; /* not visible */
return wnck_window_is_on_workspace (window, workspace);
}
/**
* wnck_window_set_icon_geometry:
* @window: a #WnckWindow.
* @x: X coordinate in pixels.
* @y: Y coordinate in pixels.
* @width: width in pixels.
* @height: height in pixels.
*
* Sets the icon geometry for @window. A typical use case for this is the
* destination of the minimization animation of @window.
*/
void
wnck_window_set_icon_geometry (WnckWindow *window,
int x,
int y,
int width,
int height)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
if (window->priv->icon_geometry.x == x &&
window->priv->icon_geometry.y == y &&
window->priv->icon_geometry.width == width &&
window->priv->icon_geometry.height == height)
return;
window->priv->icon_geometry.x = x;
window->priv->icon_geometry.y = y;
window->priv->icon_geometry.width = width;
window->priv->icon_geometry.height = height;
_wnck_set_icon_geometry (window->priv->xwindow,
x, y, width, height);
}
/**
* wnck_window_is_on_workspace:
* @window: a #WnckWindow.
* @workspace: a #WnckWorkspace.
*
* Gets whether @window appears on @workspace.
*
* Return value: %TRUE if @window appears on @workspace, %FALSE otherwise.
**/
gboolean
wnck_window_is_on_workspace (WnckWindow *window,
WnckWorkspace *workspace)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
g_return_val_if_fail (WNCK_IS_WORKSPACE (workspace), FALSE);
return wnck_window_is_pinned (window) ||
wnck_window_get_workspace (window) == workspace;
}
/**
* wnck_window_is_in_viewport:
* @window: a #WnckWindow.
* @workspace: a #WnckWorkspace.
*
* Gets %TRUE if @window appears in the current viewport of @workspace.
*
* Return value: %TRUE if @window appears in current viewport of @workspace,
* %FALSE otherwise.
*
* Since: 2.4
**/
gboolean
wnck_window_is_in_viewport (WnckWindow *window,
WnckWorkspace *workspace)
{
GdkRectangle window_rect;
GdkRectangle viewport_rect;
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
g_return_val_if_fail (WNCK_IS_WORKSPACE (workspace), FALSE);
if (wnck_window_is_pinned (window) )
return TRUE;
if (wnck_window_get_workspace (window) != workspace)
return FALSE;
viewport_rect.x = wnck_workspace_get_viewport_x (workspace);
viewport_rect.y = wnck_workspace_get_viewport_y (workspace);
viewport_rect.width = wnck_screen_get_width (window->priv->screen);
viewport_rect.height = wnck_screen_get_height (window->priv->screen);
window_rect.x = window->priv->x - window->priv->left_frame + viewport_rect.x;
window_rect.y = window->priv->y - window->priv->top_frame + viewport_rect.y;
window_rect.width = window->priv->width + window->priv->left_frame + window->priv->right_frame;
window_rect.height = window->priv->height + window->priv->top_frame + window->priv->bottom_frame;
return gdk_rectangle_intersect (&viewport_rect, &window_rect, &window_rect);
}
void
_wnck_window_set_application (WnckWindow *window,
WnckApplication *app)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
g_return_if_fail (app == NULL || WNCK_IS_APPLICATION (app));
if (app)
g_object_ref (G_OBJECT (app));
if (window->priv->app)
g_object_unref (G_OBJECT (window->priv->app));
window->priv->app = app;
}
void
_wnck_window_set_class_group (WnckWindow *window,
WnckClassGroup *class_group)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
g_return_if_fail (class_group == NULL || WNCK_IS_CLASS_GROUP (class_group));
if (class_group)
g_object_ref (G_OBJECT (class_group));
if (window->priv->class_group)
g_object_unref (G_OBJECT (window->priv->class_group));
window->priv->class_group = class_group;
}
void
_wnck_window_process_property_notify (WnckWindow *window,
XEvent *xevent)
{
if (xevent->xproperty.atom ==
_wnck_atom_get ("_NET_WM_STATE"))
{
window->priv->need_update_state = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("WM_STATE"))
{
window->priv->need_update_wm_state = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
XA_WM_NAME ||
xevent->xproperty.atom ==
_wnck_atom_get ("_NET_WM_NAME") ||
xevent->xproperty.atom ==
_wnck_atom_get ("_NET_WM_VISIBLE_NAME"))
{
window->priv->need_update_name = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
XA_WM_ICON_NAME ||
xevent->xproperty.atom ==
_wnck_atom_get ("_NET_WM_ICON_NAME") ||
xevent->xproperty.atom ==
_wnck_atom_get ("_NET_WM_VISIBLE_ICON_NAME"))
{
window->priv->need_update_icon_name = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("_NET_WM_ALLOWED_ACTIONS"))
{
window->priv->need_update_actions = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("_NET_WM_DESKTOP"))
{
window->priv->need_update_workspace = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("_NET_WM_WINDOW_TYPE"))
{
window->priv->need_update_wintype = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("WM_TRANSIENT_FOR"))
{
window->priv->need_update_transient_for = TRUE;
window->priv->need_update_wintype = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("_NET_STARTUP_ID"))
{
window->priv->need_update_startup_id = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom == XA_WM_CLASS)
{
window->priv->need_update_wmclass = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("_NET_WM_ICON") ||
xevent->xproperty.atom ==
_wnck_atom_get ("KWM_WIN_ICON"))
{
_wnck_icon_cache_property_changed (window->priv->icon_cache,
xevent->xproperty.atom);
queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("WM_HINTS"))
{
window->priv->need_update_wmhints = TRUE;
queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("_NET_FRAME_EXTENTS"))
{
window->priv->need_update_frame_extents = TRUE;
queue_update (window);
}
}
void
_wnck_window_process_configure_notify (WnckWindow *window,
XEvent *xevent)
{
if (xevent->xconfigure.send_event)
{
window->priv->x = xevent->xconfigure.x;
window->priv->y = xevent->xconfigure.y;
}
else
{
_wnck_get_window_position (WNCK_SCREEN_XSCREEN (window->priv->screen),
window->priv->xwindow,
&window->priv->x,
&window->priv->y);
}
window->priv->width = xevent->xconfigure.width;
window->priv->height = xevent->xconfigure.height;
emit_geometry_changed (window);
}
static void
update_wm_state (WnckWindow *window)
{
int state;
if (!window->priv->need_update_wm_state)
return;
window->priv->need_update_wm_state = FALSE;
window->priv->wm_state_iconic = FALSE;
state = _wnck_get_wm_state (window->priv->xwindow);
if (state == IconicState)
window->priv->wm_state_iconic = TRUE;
}
static void
update_state (WnckWindow *window)
{
Atom *atoms;
int n_atoms;
int i;
gboolean reread_net_wm_state;
reread_net_wm_state = window->priv->need_update_state;
window->priv->need_update_state = FALSE;
/* This is a bad hack, we always add the
* state based on window type in to the state,
* even if no state update is pending (since the
* state update just means the _NET_WM_STATE prop
* changed
*/
if (reread_net_wm_state)
{
gboolean demanded_attention;
demanded_attention = window->priv->demands_attention;
window->priv->is_maximized_horz = FALSE;
window->priv->is_maximized_vert = FALSE;
window->priv->is_sticky = FALSE;
window->priv->is_shaded = FALSE;
window->priv->is_above = FALSE;
window->priv->is_below = FALSE;
window->priv->skip_taskbar = FALSE;
window->priv->skip_pager = FALSE;
window->priv->net_wm_state_hidden = FALSE;
window->priv->is_fullscreen = FALSE;
window->priv->demands_attention = FALSE;
atoms = NULL;
n_atoms = 0;
_wnck_get_atom_list (window->priv->xwindow,
_wnck_atom_get ("_NET_WM_STATE"),
&atoms, &n_atoms);
i = 0;
while (i < n_atoms)
{
if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_VERT"))
window->priv->is_maximized_vert = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_MAXIMIZED_HORZ"))
window->priv->is_maximized_horz = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_HIDDEN"))
window->priv->net_wm_state_hidden = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_STICKY"))
window->priv->is_sticky = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_SHADED"))
window->priv->is_shaded = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_ABOVE"))
window->priv->is_above = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_BELOW"))
window->priv->is_below = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_FULLSCREEN"))
window->priv->is_fullscreen = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_SKIP_TASKBAR"))
window->priv->skip_taskbar = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_SKIP_PAGER"))
window->priv->skip_pager = TRUE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_DEMANDS_ATTENTION"))
window->priv->demands_attention = TRUE;
++i;
}
if (window->priv->demands_attention != demanded_attention)
{
if (window->priv->demands_attention)
time (&window->priv->needs_attention_time);
else if (!window->priv->is_urgent)
window->priv->needs_attention_time = 0;
}
g_free (atoms);
}
switch (window->priv->wintype)
{
case WNCK_WINDOW_DESKTOP:
case WNCK_WINDOW_DOCK:
case WNCK_WINDOW_SPLASHSCREEN:
window->priv->skip_taskbar = TRUE;
break;
case WNCK_WINDOW_TOOLBAR:
case WNCK_WINDOW_MENU:
case WNCK_WINDOW_UTILITY:
case WNCK_WINDOW_DIALOG:
/* Skip taskbar if the window is transient
* for some main application window
*/
if (wnck_window_get_transient (window) != NULL &&
!window->priv->transient_for_root)
window->priv->skip_taskbar = TRUE;
break;
case WNCK_WINDOW_NORMAL:
break;
}
/* FIXME!!!!!!!!!! What in the world is this buggy duplicate of the code
* immediately above this for??!?!?
*/
switch (window->priv->wintype)
{
case WNCK_WINDOW_DESKTOP:
case WNCK_WINDOW_DOCK:
case WNCK_WINDOW_TOOLBAR:
case WNCK_WINDOW_MENU:
case WNCK_WINDOW_SPLASHSCREEN:
window->priv->skip_pager = TRUE;
break;
case WNCK_WINDOW_NORMAL:
case WNCK_WINDOW_DIALOG:
case WNCK_WINDOW_UTILITY:
break;
}
/* FIXME we need to recompute this if the window manager changes */
if (wnck_screen_net_wm_supports (window->priv->screen,
"_NET_WM_STATE_HIDDEN"))
{
window->priv->is_hidden = window->priv->net_wm_state_hidden;
/* FIXME this is really broken; need to bring it up on
* wm-spec-list. It results in showing an "Unminimize" menu
* item on task list, for shaded windows.
*/
window->priv->is_minimized = window->priv->is_hidden;
}
else
{
window->priv->is_minimized = window->priv->wm_state_iconic;
window->priv->is_hidden = window->priv->is_minimized || window->priv->is_shaded;
}
}
static void
update_name (WnckWindow *window)
{
char *new_name;
if (!window->priv->need_update_name)
return;
window->priv->need_update_name = FALSE;
new_name = _wnck_get_name (window->priv->xwindow);
if (g_strcmp0 (window->priv->name, new_name) != 0)
window->priv->need_emit_name_changed = TRUE;
g_free (window->priv->name);
window->priv->name = new_name;
}
static void
update_icon_name (WnckWindow *window)
{
char *new_name = NULL;
if (!window->priv->need_update_icon_name)
return;
window->priv->need_update_icon_name = FALSE;
new_name = _wnck_get_icon_name (window->priv->xwindow);
if (g_strcmp0 (window->priv->icon_name, new_name) != 0)
window->priv->need_emit_name_changed = TRUE;
g_free (window->priv->icon_name);
window->priv->icon_name = new_name;
}
static void
update_workspace (WnckWindow *window)
{
int val;
int old;
if (!window->priv->need_update_workspace)
return;
window->priv->need_update_workspace = FALSE;
old = window->priv->workspace;
val = ALL_WORKSPACES;
_wnck_get_cardinal (window->priv->xwindow,
_wnck_atom_get ("_NET_WM_DESKTOP"),
&val);
window->priv->workspace = val;
if (old != window->priv->workspace)
emit_workspace_changed (window);
}
static void
update_actions (WnckWindow *window)
{
Atom *atoms;
int n_atoms;
int i;
if (!window->priv->need_update_actions)
return;
window->priv->need_update_actions = FALSE;
window->priv->actions = 0;
atoms = NULL;
n_atoms = 0;
if (!_wnck_get_atom_list (window->priv->xwindow,
_wnck_atom_get ("_NET_WM_ALLOWED_ACTIONS"),
&atoms,
&n_atoms))
{
window->priv->actions =
WNCK_WINDOW_ACTION_MOVE |
WNCK_WINDOW_ACTION_RESIZE |
WNCK_WINDOW_ACTION_SHADE |
WNCK_WINDOW_ACTION_STICK |
WNCK_WINDOW_ACTION_MAXIMIZE_HORIZONTALLY |
WNCK_WINDOW_ACTION_MAXIMIZE_VERTICALLY |
WNCK_WINDOW_ACTION_CHANGE_WORKSPACE |
WNCK_WINDOW_ACTION_CLOSE |
WNCK_WINDOW_ACTION_UNMAXIMIZE_HORIZONTALLY |
WNCK_WINDOW_ACTION_UNMAXIMIZE_VERTICALLY |
WNCK_WINDOW_ACTION_UNSHADE |
WNCK_WINDOW_ACTION_UNSTICK |
WNCK_WINDOW_ACTION_MINIMIZE |
WNCK_WINDOW_ACTION_UNMINIMIZE |
WNCK_WINDOW_ACTION_MAXIMIZE |
WNCK_WINDOW_ACTION_UNMAXIMIZE |
WNCK_WINDOW_ACTION_FULLSCREEN |
WNCK_WINDOW_ACTION_ABOVE |
WNCK_WINDOW_ACTION_BELOW;
return;
}
i = 0;
while (i < n_atoms)
{
if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_MOVE"))
window->priv->actions |= WNCK_WINDOW_ACTION_MOVE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_RESIZE"))
window->priv->actions |= WNCK_WINDOW_ACTION_RESIZE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_SHADE"))
window->priv->actions |= WNCK_WINDOW_ACTION_SHADE |
WNCK_WINDOW_ACTION_UNSHADE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_STICK"))
window->priv->actions |= WNCK_WINDOW_ACTION_STICK |
WNCK_WINDOW_ACTION_UNSTICK;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_MINIMIZE"))
window->priv->actions |= WNCK_WINDOW_ACTION_MINIMIZE |
WNCK_WINDOW_ACTION_UNMINIMIZE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_MAXIMIZE_HORZ"))
window->priv->actions |= WNCK_WINDOW_ACTION_MAXIMIZE_HORIZONTALLY |
WNCK_WINDOW_ACTION_UNMAXIMIZE_HORIZONTALLY;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_MAXIMIZE_VERT"))
window->priv->actions |= WNCK_WINDOW_ACTION_MAXIMIZE_VERTICALLY |
WNCK_WINDOW_ACTION_UNMAXIMIZE_VERTICALLY;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_CHANGE_DESKTOP"))
window->priv->actions |= WNCK_WINDOW_ACTION_CHANGE_WORKSPACE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_CLOSE"))
window->priv->actions |= WNCK_WINDOW_ACTION_CLOSE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_FULLSCREEN"))
window->priv->actions |= WNCK_WINDOW_ACTION_FULLSCREEN;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_ABOVE"))
window->priv->actions |= WNCK_WINDOW_ACTION_ABOVE;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_ACTION_BELOW"))
window->priv->actions |= WNCK_WINDOW_ACTION_BELOW;
else
{
const char *name = _wnck_atom_name (atoms [i]);
g_warning ("Unhandled action type %s", name ? name: "(nil)");
}
i++;
}
g_free (atoms);
if ((window->priv->actions & WNCK_WINDOW_ACTION_MAXIMIZE_HORIZONTALLY) &&
(window->priv->actions & WNCK_WINDOW_ACTION_MAXIMIZE_VERTICALLY))
window->priv->actions |=
WNCK_WINDOW_ACTION_MAXIMIZE |
WNCK_WINDOW_ACTION_UNMAXIMIZE;
}
static void
update_wintype (WnckWindow *window)
{
Atom *atoms;
int n_atoms;
WnckWindowType type;
gboolean found_type;
if (!window->priv->need_update_wintype)
return;
window->priv->need_update_wintype = FALSE;
found_type = FALSE;
type = WNCK_WINDOW_NORMAL;
atoms = NULL;
n_atoms = 0;
if (_wnck_get_atom_list (window->priv->xwindow,
_wnck_atom_get ("_NET_WM_WINDOW_TYPE"),
&atoms,
&n_atoms))
{
int i;
i = 0;
while (i < n_atoms && !found_type)
{
/* We break as soon as we find one we recognize,
* supposed to prefer those near the front of the list
*/
found_type = TRUE;
if (atoms[i] == _wnck_atom_get ("_NET_WM_WINDOW_TYPE_DESKTOP"))
type = WNCK_WINDOW_DESKTOP;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_WINDOW_TYPE_DOCK"))
type = WNCK_WINDOW_DOCK;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_WINDOW_TYPE_TOOLBAR"))
type = WNCK_WINDOW_TOOLBAR;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_WINDOW_TYPE_MENU"))
type = WNCK_WINDOW_MENU;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_WINDOW_TYPE_DIALOG"))
type = WNCK_WINDOW_DIALOG;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_WINDOW_TYPE_NORMAL"))
type = WNCK_WINDOW_NORMAL;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_WINDOW_TYPE_UTILITY"))
type = WNCK_WINDOW_UTILITY;
else if (atoms[i] == _wnck_atom_get ("_NET_WM_WINDOW_TYPE_SPLASH"))
type = WNCK_WINDOW_SPLASHSCREEN;
else
found_type = FALSE;
++i;
}
g_free (atoms);
}
if (!found_type)
{
if (window->priv->transient_for != None)
{
type = WNCK_WINDOW_DIALOG;
}
else
{
type = WNCK_WINDOW_NORMAL;
}
found_type = TRUE;
}
window->priv->wintype = type;
}
static void
update_transient_for (WnckWindow *window)
{
Window parent;
if (!window->priv->need_update_transient_for)
return;
window->priv->need_update_transient_for = FALSE;
parent = None;
if (_wnck_get_window (window->priv->xwindow,
_wnck_atom_get ("WM_TRANSIENT_FOR"),
&parent) &&
parent != window->priv->xwindow)
{
window->priv->transient_for = parent;
if (wnck_screen_get_for_root (window->priv->transient_for) != NULL)
window->priv->transient_for_root = TRUE;
else
window->priv->transient_for_root = FALSE;
}
else
{
window->priv->transient_for = None;
window->priv->transient_for_root = FALSE;
}
}
static void
update_startup_id (WnckWindow *window)
{
if (!window->priv->need_update_startup_id)
return;
window->priv->need_update_startup_id = FALSE;
g_free (window->priv->startup_id);
window->priv->startup_id =
_wnck_get_utf8_property (window->priv->xwindow,
_wnck_atom_get ("_NET_STARTUP_ID"));
}
static void
update_wmclass (WnckWindow *window)
{
if (!window->priv->need_update_wmclass)
return;
window->priv->need_update_wmclass = FALSE;
g_free (window->priv->res_class);
g_free (window->priv->res_name);
window->priv->res_class = NULL;
window->priv->res_name = NULL;
_wnck_get_wmclass (window->priv->xwindow,
&window->priv->res_class,
&window->priv->res_name);
}
static void
update_wmhints (WnckWindow *window)
{
XWMHints *hints;
if (!window->priv->need_update_wmhints)
return;
_wnck_error_trap_push ();
hints = XGetWMHints (_wnck_window_get_display (window), window->priv->xwindow);
_wnck_error_trap_pop ();
if (hints)
{
if ((hints->flags & IconPixmapHint) ||
(hints->flags & IconMaskHint))
_wnck_icon_cache_property_changed (window->priv->icon_cache,
_wnck_atom_get ("WM_HINTS"));
if (hints->flags & WindowGroupHint)
window->priv->group_leader = hints->window_group;
if (hints->flags & XUrgencyHint)
{
window->priv->is_urgent = TRUE;
time (&window->priv->needs_attention_time);
}
else
{
window->priv->is_urgent = FALSE;
if (!window->priv->demands_attention)
window->priv->needs_attention_time = 0;
}
XFree (hints);
}
window->priv->need_update_wmhints = FALSE;
}
static void
update_frame_extents (WnckWindow *window)
{
int left, right, top, bottom;
if (!window->priv->need_update_frame_extents)
return;
window->priv->need_update_frame_extents = FALSE;
left = right = top = bottom = 0;
if (!_wnck_get_frame_extents (window->priv->xwindow,
&left, &right, &top, &bottom))
return;
if (left != window->priv->left_frame ||
right != window->priv->right_frame ||
top != window->priv->top_frame ||
bottom != window->priv->bottom_frame)
{
window->priv->left_frame = left;
window->priv->right_frame = right;
window->priv->top_frame = top;
window->priv->bottom_frame = bottom;
emit_geometry_changed (window);
}
}
static void
force_update_now (WnckWindow *window)
{
WnckWindowState old_state;
WnckWindowState new_state;
WnckWindowActions old_actions;
unqueue_update (window);
/* Name must be done before all other stuff,
* because we have iconsistent state across the
* update_name/update_icon_name functions (no window name),
* and we have to fix that before we emit any other signals
*/
update_name (window);
update_icon_name (window);
if (window->priv->need_emit_name_changed)
emit_name_changed (window);
old_state = COMPRESS_STATE (window);
old_actions = window->priv->actions;
update_startup_id (window); /* no side effects */
update_wmclass (window);
update_wmhints (window);
update_transient_for (window); /* wintype needs this to be first */
update_wintype (window);
update_wm_state (window);
update_state (window); /* must come after the above, since they affect
* our calculated state
*/
update_workspace (window); /* emits signals */
update_actions (window);
update_frame_extents (window); /* emits signals */
get_icons (window);
new_state = COMPRESS_STATE (window);
if (old_state != new_state)
emit_state_changed (window, old_state ^ new_state, new_state);
if (old_actions != window->priv->actions)
emit_actions_changed (window, old_actions ^ window->priv->actions,
window->priv->actions);
if (window->priv->need_emit_icon_changed)
emit_icon_changed (window);
}
static gboolean
update_idle (gpointer data)
{
WnckWindow *window = WNCK_WINDOW (data);
window->priv->update_handler = 0;
force_update_now (window);
return FALSE;
}
static void
queue_update (WnckWindow *window)
{
if (window->priv->update_handler != 0)
return;
window->priv->update_handler = g_idle_add (update_idle, window);
}
static void
unqueue_update (WnckWindow *window)
{
if (window->priv->update_handler != 0)
{
g_source_remove (window->priv->update_handler);
window->priv->update_handler = 0;
}
}
static void
emit_name_changed (WnckWindow *window)
{
window->priv->need_emit_name_changed = FALSE;
g_signal_emit (G_OBJECT (window),
signals[NAME_CHANGED],
0);
}
static void
emit_state_changed (WnckWindow *window,
WnckWindowState changed_mask,
WnckWindowState new_state)
{
g_signal_emit (G_OBJECT (window),
signals[STATE_CHANGED],
0, changed_mask, new_state);
}
static void
emit_workspace_changed (WnckWindow *window)
{
g_signal_emit (G_OBJECT (window),
signals[WORKSPACE_CHANGED],
0);
}
static void
emit_icon_changed (WnckWindow *window)
{
window->priv->need_emit_icon_changed = FALSE;
g_signal_emit (G_OBJECT (window),
signals[ICON_CHANGED],
0);
}
static void
emit_actions_changed (WnckWindow *window,
WnckWindowActions changed_mask,
WnckWindowActions new_actions)
{
g_signal_emit (G_OBJECT (window),
signals[ACTIONS_CHANGED],
0, changed_mask, new_actions);
}
static void
emit_geometry_changed (WnckWindow *window)
{
g_signal_emit (G_OBJECT (window),
signals[GEOMETRY_CHANGED],
0);
}
|