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
|
/* ========================================================================================================
* dockedWorkspaces.js - dock object that holds the workspaces thumbnailsBox
* --------------------------------------------------------------------------------------------------------
* CREDITS: This code was copied from the dash-to-dock extension https://github.com/micheleg/dash-to-dock
* and modified to create a workspaces dock. Many thanks to michele_g for a great extension.
*
* Part of this code also comes from gnome-shell-extensions:
* http://git.gnome.org/browse/gnome-shell-extensions/
* ========================================================================================================
*/
const _DEBUG_ = false;
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Clutter = imports.gi.Clutter;
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const Signals = imports.signals;
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const IconTheme = imports.gi.Gtk.IconTheme;
const Params = imports.misc.params;
const Main = imports.ui.main;
const WorkspacesView = imports.ui.workspacesView;
const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
const Tweener = imports.ui.tweener;
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
const Overview = imports.ui.overview;
const OverviewControls = imports.ui.overviewControls;
const Layout = imports.ui.layout;
const MessageTray = imports.ui.messageTray;
const ExtensionSystem = imports.ui.extensionSystem;
const ExtensionUtils = imports.misc.extensionUtils;
const Config = imports.misc.config;
const Me = ExtensionUtils.getCurrentExtension();
const Extension = Me.imports.extension;
const Convenience = Me.imports.convenience;
const MyWorkspaceThumbnail = Me.imports.myWorkspaceThumbnail;
const ShortcutsPanel = Me.imports.shortcutsPanel;
const MyWorkspaceSwitcherPopup = Me.imports.myWorkspaceSwitcherPopup;
const MyPressureBarrier = Me.imports.myPressureBarrier;
const DashToDock_UUID = "dash-to-dock@micxgx.gmail.com";
let DashToDockExtension = null;
let DashToDock = null;
const DOCK_EDGE_VISIBLE_WIDTH = 5;
const DOCK_EDGE_VISIBLE_OVERVIEW_WIDTH = 32;
const PRESSURE_TIMEOUT = 1000;
let GSFunctions = {};
const IntellihideAction = {
SHOW_FULL: 0,
SHOW_PARTIAL: 1,
SHOW_PARTIAL_FIXED: 2
};
const OverviewAction = {
SHOW_FULL: 0, // Dock is always visible
HIDE: 1, // Dock is always invisible. Visible on mouse hover
SHOW_PARTIAL: 2 // Dock partially hidden. Visible on mouse hover
};
const DockState = {
HIDDEN: 0,
SHOWING: 1,
SHOWN: 2,
HIDING: 3
};
// Return the actual position reverseing left and right in rtl
function getPosition(settings) {
let position = settings.get_enum('dock-position');
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) {
if (position == St.Side.LEFT)
position = St.Side.RIGHT;
else if (position == St.Side.RIGHT)
position = St.Side.LEFT;
}
return position;
}
function getDockStateDesc(state) {
let desc = "";
switch (state) {
case DockState.HIDDEN:
desc = "HIDDEN";
break;
case DockState.SHOWING:
desc = "SHOWING";
break;
case DockState.SHOWN:
desc = "SHOWN";
break;
case DockState.HIDING:
desc = "HIDING";
break;
}
return desc;
}
var ThumbnailsSlider = new Lang.Class({
Name: 'workspacestodockThumbnailsSlider',
_init: function(params) {
this._settings = Convenience.getSettings('org.gnome.shell.extensions.workspaces-to-dock');
let initialTriggerWidth = 1;
// Default local params
let localDefaults = {
side: St.Side.LEFT,
initialSlideValue: 1,
initialSlideoutSize: initialTriggerWidth
}
let localParams = Params.parse(params, localDefaults, true);
if (params){
// Remove local params before passing the params to the parent
// constructor to avoid errors.
let prop;
for (prop in localDefaults) {
if ((prop in params))
delete params[prop];
}
}
this.actor = new Shell.GenericContainer(params);
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate));
this.actor._delegate = this;
this._child = null;
// slide parameter: 1 = visible, 0 = hidden.
this._slidex = localParams.initialSlideValue;
this._side = localParams.side;
this._slideoutSize = localParams.initialSlideoutSize; // minimum size when slid out
this._partialSlideoutSize = initialTriggerWidth + DOCK_EDGE_VISIBLE_OVERVIEW_WIDTH;
},
destroy: function() {
},
_allocate: function(actor, box, flags) {
if (this._child == null)
return;
let availWidth = box.x2 - box.x1;
let availHeight = box.y2 - box.y1;
let [minChildWidth, minChildHeight, natChildWidth, natChildHeight] =
this._child.get_preferred_size();
let childWidth = natChildWidth;
let childHeight = natChildHeight;
let childBox = new Clutter.ActorBox();
let slideoutSize = this._slideoutSize;
if (this._side == St.Side.LEFT) {
childBox.x1 = (this._slidex -1) * (childWidth - slideoutSize);
childBox.x2 = slideoutSize + this._slidex * (childWidth - slideoutSize);
childBox.y1 = 0;
childBox.y2 = childBox.y1 + childHeight;
} else if (this._side == St.Side.RIGHT
|| this._side == St.Side.BOTTOM) {
childBox.x1 = 0;
childBox.x2 = childWidth;
childBox.y1 = 0;
childBox.y2 = childBox.y1 + childHeight;
} else if (this._side == St.Side.TOP) {
childBox.x1 = 0;
childBox.x2 = childWidth;
childBox.y1 = (this._slidex -1) * (childHeight - slideoutSize);
childBox.y2 = slideoutSize + this._slidex * (childHeight - slideoutSize);
}
this._child.allocate(childBox, flags);
this._child.set_clip(-childBox.x1, -childBox.y1,
-childBox.x1+availWidth,-childBox.y1 + availHeight);
},
// Just the child width but taking into account the slided out part
_getPreferredWidth: function(actor, forHeight, alloc) {
let slideoutSize = this._slideoutSize;
let [minWidth, natWidth ] = this._child.get_preferred_width(forHeight);
if (this._side == St.Side.LEFT
|| this._side == St.Side.RIGHT) {
minWidth = (minWidth - slideoutSize)*this._slidex + slideoutSize;
natWidth = (natWidth - slideoutSize)*this._slidex + slideoutSize;
}
alloc.min_size = minWidth;
alloc.natural_size = natWidth;
},
// Just the child height but taking into account the slided out part
_getPreferredHeight: function(actor, forWidth, alloc) {
let slideoutSize = this._slideoutSize;
let [minHeight, natHeight] = this._child.get_preferred_height(forWidth);
if (this._side == St.Side.TOP
|| this._side == St.Side.BOTTOM) {
minHeight = (minHeight - slideoutSize)*this._slidex + slideoutSize;
natHeight = (natHeight - slideoutSize)*this._slidex + slideoutSize;
}
alloc.min_size = minHeight;
alloc.natural_size = natHeight;
},
// I was expecting it to be a virtual function... stil I don't understand
// how things work.
add_child: function(actor) {
// I'm supposed to have only one child
if(this._child !== null) {
this.actor.remove_child(actor);
}
this._child = actor;
this.actor.add_child(actor);
},
set slidex(value) {
this._slidex = value;
this._child.queue_relayout();
},
get slidex() {
return this._slidex;
},
set slideoutSize(value) {
this._slideoutSize = value;
},
get slideoutSize() {
return this._slideoutSize;
},
set partialSlideoutSize(value) {
this._partialSlideoutSize = value;
},
get partialSlideoutSize() {
return this._partialSlideoutSize;
}
});
var DockedWorkspaces = new Lang.Class({
Name: 'workspacestodockDockedWorkspaces',
_init: function() {
if (_DEBUG_) global.log("dockedWorkspaces: init * * * * *");
this._gsCurrentVersion = Config.PACKAGE_VERSION.split('.');
this._settings = Convenience.getSettings('org.gnome.shell.extensions.workspaces-to-dock');
this._signalHandler = new Convenience.globalSignalHandler();
// Temporarily disable redisplay until initialized
// NOTE: This prevents connected signals from trying to update dock visibility
this._disableRedisplay = true;
this._refreshThumbnailsOnRegionUpdate = true;
if (_DEBUG_) global.log("dockedWorkspaces: init - disableRediplay");
// set RTL value
this._rtl = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL;
if (_DEBUG_) global.log("dockedWorkspaces: init - rtl = "+this._rtl);
// Load settings
this._bindSettingsChanges();
// Set position of dock
this._position = getPosition(this._settings);
this._isHorizontal = (this._position == St.Side.TOP ||
this._position == St.Side.BOTTOM);
// Authohide current status. Not to be confused with autohide enable/disagle global (g)settings
// Initially set to null - will be set during first enable/disable autohide
this._autohideStatus = null;
// Initialize dock state
this._dockState = DockState.HIDDEN;
// Initialize popup menu flag
this._popupMenuShowing = false;
// Initialize colors with generic values
this._defaultBackground = {red:0, green:0, blue:0, alpha:0};
this._customBackground = {red:0, green:0, blue:0, alpha:0};
this._defaultBorder = {red:0, green:0, blue:0, alpha:0};
this._customBorder = {red:0, green:0, blue:0, alpha:0};
this._cssStylesheet = null;
// Initialize pressure barrier variables
this._canUsePressure = false;
this._pressureSensed = false;
this._pressureBarrier = null;
this._barrier = null;
this._removeBarrierTimeoutId = 0;
// Override Gnome Shell functions
this._overrideGnomeShellFunctions();
// Set the _monitor property to the primary monitor
this._monitor = Main.layoutManager.primaryMonitor;
// Create a new thumbnailsbox object
this._thumbnailsBox = new MyWorkspaceThumbnail.myThumbnailsBox(this);
// Create a shortcuts panel object
this._shortcutsPanel = new ShortcutsPanel.ShortcutsPanel(this);
this._shortcutsPanel.connect("update-favorite-apps", Lang.bind(this, this._onShortcutsPanelUpdated));
this._shortcutsPanel.connect("update-running-apps", Lang.bind(this, this._onShortcutsPanelUpdated));
// Create custom workspace switcher popup
this._workspaceSwitcher = null;
if (this._isHorizontal && this._settings.get_boolean('horizontal-workspace-switching'))
this._workspaceSwitcher = new MyWorkspaceSwitcherPopup.WorkspaceSwitcher();
// Create position styles for dock container
let positionStyleClass = ['top', 'right', 'bottom', 'left'];
let styleClass = positionStyleClass[this._position];
if (this._settings.get_boolean('dock-fixed')
|| (this._settings.get_boolean('intellihide') && this._settings.get_enum('intellihide-action') == IntellihideAction.SHOW_PARTIAL_FIXED)) {
styleClass += " fixed";
}
let shortcutsPanelOrientation = this._settings.get_enum('shortcuts-panel-orientation');
if (this._settings.get_boolean('show-shortcuts-panel')) {
if (shortcutsPanelOrientation == 1) {
styleClass += " inside";
} else {
styleClass += " outside";
}
}
if (this._settings.get_boolean('customize-height') && this._settings.get_int('customize-height-option') == 1) {
if (this._settings.get_double('top-margin') == 0 || this._settings.get_double('bottom-margin') == 0) {
styleClass += " fullheight";
}
}
// Set _extendContainer property
if (this._settings.get_boolean('customize-height') && this._settings.get_int('customize-height-option') == 1) {
this._extendContainer = true;
} else {
this._extendContainer = false;
}
// Set _centerContainer property
if (this._settings.get_boolean('customize-height') && this._settings.get_boolean('center-thumbnails-on-dock')) {
this._centerContainer = true;
} else {
this._centerContainer = false;
}
// Set _centerPanelsIndependently property
if (this._centerContainer && this._settings.get_int('center-thumbnails-option') == 0) {
this._centerPanelsIndependently = true;
} else {
this._centerPanelsIndependently = false;
}
// Initialize alignment and box packing variables
let align;
let packStart;
let packVertical = this._isHorizontal? true : false;
if (this._position == St.Side.TOP || this._position == St.Side.LEFT) {
align = St.Align.START;
packStart = true;
} else {
align = St.Align.END;
packStart = false;
}
// Create the main dock and container
this._dock = new St.BoxLayout({
name: 'workspacestodockDock',
reactive: true,
track_hover: true,
vertical: packVertical,
pack_start: !packStart,
style_class: styleClass
});
this._dockContainer = new St.BoxLayout({
name: 'workspacestodockDockContainer',
reactive: false,
track_hover: false,
vertical: !packVertical
});
// Create the panels and container
this._panels = new St.BoxLayout({
name: 'workspacestodockPanels',
reactive: false,
track_hover: false,
vertical: packVertical,
pack_start: !packStart
});
this._panelsContainer = new St.BoxLayout({
name: 'workspacestodockPanelsContainer',
reactive: false,
track_hover: false,
vertical: packVertical,
pack_start: packStart
});
// To center the panels on the extended dock, we expand the panels box to fit the
// dock container and align it in the middle
let expandContainer = this._centerContainer ? true : false;
this._panels.add_actor(this._panelsContainer);
this._dockContainer.add(this._panels,{x_fill: false, y_fill: false, x_align: St.Align.MIDDLE, y_align: St.Align.MIDDLE, expand: expandContainer});
// Initialize keyboard toggle timeout
this._toggleWithKeyboardTimeoutId = 0;
// Connect the _dock hover, scroll and button release events
this._checkHoverStatusId = 0;
this._scrollWorkspaceSwitchDeadTimeId = 0;
this._dock.connect("notify::hover", Lang.bind(this, this._hoverChanged));
this._dock.connect("scroll-event", Lang.bind(this, this._onScrollEvent));
this._dock.connect("button-release-event", Lang.bind(this, this._onDockClicked));
// Add workspaces, and shortcuts panel to dock container based on dock position
// and shortcuts panel orientation
if (shortcutsPanelOrientation == 1) {
if (this._centerContainer && this._centerPanelsIndependently) {
this._panelsContainer.add(this._shortcutsPanel.actor,{x_fill: false, y_fill: false, x_align: St.Align.MIDDLE, y_align: St.Align.MIDDLE});
this._panelsContainer.add(this._thumbnailsBox.actor,{x_fill: false, y_fill: false, x_align: St.Align.MIDDLE, y_align: St.Align.MIDDLE});
} else {
this._panelsContainer.add_actor(this._shortcutsPanel.actor);
this._panelsContainer.add_actor(this._thumbnailsBox.actor);
}
} else {
if (this._centerContainer && this._centerPanelsIndependently) {
this._panelsContainer.add(this._thumbnailsBox.actor,{x_fill: false, y_fill: false, x_align: St.Align.MIDDLE, y_align: St.Align.MIDDLE});
this._panelsContainer.add(this._shortcutsPanel.actor,{x_fill: false, y_fill: false, x_align: St.Align.MIDDLE, y_align: St.Align.MIDDLE});
} else {
this._panelsContainer.add_actor(this._thumbnailsBox.actor);
this._panelsContainer.add_actor(this._shortcutsPanel.actor);
}
}
// Create the sliding actor whose allocation is to be tracked for input regions
let slideoutSize = this._settings.get_boolean('dock-edge-visible') ? this._triggerWidth + DOCK_EDGE_VISIBLE_WIDTH : this._triggerWidth;
this._slider = new ThumbnailsSlider({side: this._position, initialSlideoutSize: slideoutSize});
// Create the dock main actor
this.actor = new St.Bin({ name: 'workspacestodockMainActor',
reactive: false,
x_align: align,
y_align: align
});
this.actor._delegate = this;
this._realizeId = this.actor.connect("realize", Lang.bind(this, this._initialize));
// Add the dock to slider and then to the main container actor
this._dock.add_actor(this._dockContainer);
this._slider.add_child(this._dock);
this.actor.set_child(this._slider.actor);
// Connect global signals
let workspaceManager = global.workspace_manager;
this._signalHandler.push(
[
this._thumbnailsBox.actor,
'notify::width',
Lang.bind(this, this._thumbnailsBoxResized)
],
[
this._thumbnailsBox.actor,
'notify::height',
Lang.bind(this, this._thumbnailsBoxResized)
],
[
Main.layoutManager,
'monitors-changed',
Lang.bind(this, this._onMonitorsChanged)
],
[
St.ThemeContext.get_for_stage(global.stage),
'changed',
Lang.bind(this, this._onThemeChanged)
],
[
IconTheme.get_default(),
'changed',
Lang.bind(this, this._onIconsChanged)
],
[
ExtensionSystem._signals,
'extension-state-changed',
Lang.bind(this, this._onExtensionSystemStateChanged)
],
[
Main.overview.viewSelector,
'notify::y',
Lang.bind(this, this._updateYPosition)
],
[
global.display,
'in-fullscreen-changed',
Lang.bind(this, this._updateBarrier)
],
[
workspaceManager,
'workspace-added',
Lang.bind(this, this._onWorkspaceAdded)
],
[
workspaceManager,
'workspace-removed',
Lang.bind(this, this._onWorkspaceRemoved)
]
);
if (_DEBUG_) global.log("dockedWorkspaces: init - signals being captured");
// Bind keyboard shortcuts
if (this._settings.get_boolean('toggle-dock-with-keyboard-shortcut'))
this._bindDockKeyboardShortcut();
// Connect DashToDock hover signal if the extension is already loaded and enabled
this._hoveringDash = false;
DashToDockExtension = ExtensionUtils.extensions[DashToDock_UUID];
if (DashToDockExtension) {
if (DashToDockExtension.state == ExtensionSystem.ExtensionState.ENABLED) {
if (_DEBUG_) global.log("dockeWorkspaces: init - DashToDock extension is installed and enabled");
DashToDock = DashToDockExtension.imports.extension;
if (DashToDock) {
DashToDockExtension.hasDockPositionKey = false;
if (DashToDock.dockManager) {
DashToDockExtension.hasDockPositionKey = true;
} else {
var keys = DashToDock.dock._settings.list_keys();
if (keys.indexOf('dock-position') > -1) {
DashToDockExtension.hasDockPositionKey = true;
}
}
this._connectDashToDockSignals();
}
}
}
// Intialize trigger spacing
// We use this space to trigger the dock (show/hide) if the pressure barrier is not present (or disabled)
// We also use this space for scrolling when the dock is hidden
this._triggerWidth = 1;
this._updateTriggerWidth();
// Hide the dock while initializing and setting position
// But since we need to access its width, we use opacity
this.actor.set_opacity(0);
// Since the actor is not a topLevel child and its parent is now not added to the Chrome,
// the allocation change of the parent container (slide in and slideout) doesn't trigger
// anymore an update of the input regions. Force the update manually.
this.actor.connect('notify::allocation',
Lang.bind(Main.layoutManager, Main.layoutManager._queueUpdateRegions));
// Create struts actor for tracking workspace region of fixed dock or partially fixed dock
this._struts = new St.Bin({ reactive: false });
if (this._settings.get_boolean('dock-fixed')
|| (this._settings.get_boolean('intellihide') && this._settings.get_enum('intellihide-action') == IntellihideAction.SHOW_PARTIAL_FIXED)) {
Main.uiGroup.add_child(this._struts);
Main.layoutManager.uiGroup.set_child_below_sibling(this._struts, Main.layoutManager.modalDialogGroup);
Main.layoutManager._trackActor(this._struts, {affectsStruts: true, trackFullscreen: true});
// Force region update to update workspace area
Main.layoutManager._queueUpdateRegions();
}
// Add aligning container without tracking it for input region (old affectsinputRegion: false that was removed).
// The public method trackChrome requires the actor to be child of a tracked actor. Since I don't want the parent
// to be tracked I use the private internal _trackActor instead.
Main.uiGroup.add_child(this.actor);
Main.layoutManager.uiGroup.set_child_below_sibling(this.actor, Main.layoutManager.modalDialogGroup);
if (this._settings.get_boolean('dock-fixed')
|| (this._settings.get_boolean('intellihide') && this._settings.get_enum('intellihide-action') == IntellihideAction.SHOW_PARTIAL_FIXED)) {
Main.layoutManager._trackActor(this._slider.actor, {trackFullscreen: true});
} else {
if (this._settings.get_boolean('autohide-in-fullscreen')) {
Main.layoutManager._trackActor(this._slider.actor);
} else {
Main.layoutManager._trackActor(this._slider.actor, {trackFullscreen: true});
}
}
},
_initialize: function() {
if (_DEBUG_) global.log("dockedWorkspaces: initializing * * * * *");
if(this._realizeId > 0){
this.actor.disconnect(this._realizeId);
this._realizeId = 0;
}
// Show the thumbnailsBox. We need it to calculate the width of the dock.
this._thumbnailsBox._createThumbnails();
// Set shortcuts panel visibility
if (this._settings.get_boolean('show-shortcuts-panel')) {
this._shortcutsPanel.actor.show();
} else {
this._shortcutsPanel.actor.hide();
}
// Set initial position and opacity
this._resetPosition();
this.actor.set_opacity(255);
this._disableRedisplay = false;
if (_DEBUG_) global.log("dockedWorkspaces: initialize - turn on redisplay");
// Now that the dock is on the stage and custom themes are loaded
// retrieve background color and set background opacity
this._updateAppearancePreferences();
// Setup pressure barrier (GS38+ only)
this._updatePressureBarrier();
this._updateBarrier();
// NOTE: GS3.14+ thumbnailsBox width signal triggers ealier so now we need this.
this._redisplay();
},
destroy: function() {
if (_DEBUG_) global.log("dockedWorkspaces: destroying * * * * *");
// Destroy thumbnailsBox & global signals
this._thumbnailsBox._destroyThumbnails();
this._shortcutsPanel.destroy();
if (this._workspaceSwitcher)
this._workspaceSwitcher.destroy();
// Disconnect global signals
this._signalHandler.disconnect();
// Unbind keyboard shortcuts
this._unbindDockKeyboardShortcut();
// Remove existing barrier
this._removeBarrier();
if (this._pressureBarrier) {
if (_DEBUG_) global.log("... destroying old pressureBarrier object");
this._pressureBarrier.destroy();
this._pressureBarrier = null;
}
this._slider.destroy();
this._struts.destroy();
// Destroy main clutter actor: this should be sufficient
// From clutter documentation:
// If the actor is inside a container, the actor will be removed.
// When you destroy a container, its children will be destroyed as well.
this.actor.destroy();
// Restore normal Gnome Shell functions
this._restoreGnomeShellFunctions();
// Disconnect GSettings signals
// We wait until after _restoreGnomeShellFunctions because we needed
// settings to determine how to restore the dash
this._settings.run_dispose();
},
// function called during init to override gnome shell 3.4/3.6/3.8
_overrideGnomeShellFunctions: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _overrideGnomeShellFunctions");
let self = this;
// Hide normal Dash
if (this._settings.get_boolean('hide-dash')) {
// Hide normal dash
Main.overview._controls.dash.actor.hide();
Main.overview._controls.dash.actor.set_width(1);
}
// Change source of swarm animation to shortcuts panel apps button
GSFunctions['Overview_getShowAppsButton'] = Overview.Overview.prototype.getShowAppsButton;
Overview.Overview.prototype.getShowAppsButton = function() {
if (self._settings.get_boolean('show-shortcuts-panel') && self._settings.get_boolean('shortcuts-panel-appsbutton-animation')) {
return self._shortcutsPanel._appsButton.actor;
} else {
return this._dash.showAppsButton;
}
};
// Hide normal workspaces thumbnailsBox
Main.overview._controls._thumbnailsSlider.actor.opacity = 0;
// Override WorkspaceSwitcherPopup _show function to prevent popup from showing when disabled
GSFunctions['WorkspaceSwitcherPopup_show'] = WorkspaceSwitcherPopup.WorkspaceSwitcherPopup.prototype._show;
WorkspaceSwitcherPopup.WorkspaceSwitcherPopup.prototype._show = function() {
if (self._settings.get_boolean('hide-workspace-switcher-popup')) {
return false;
} else {
let ret = GSFunctions['WorkspaceSwitcherPopup_show'].call(this);
return ret;
}
};
// Extend LayoutManager _updateRegions function to destroy/create workspace thumbnails when completed.
// NOTE1: needed because 'monitors-changed' signal doesn't wait for queued regions to update.
// We need to wait so that the screen workspace workarea is adjusted before creating workspace thumbnails.
// Otherwise when we move the primary workspace to another monitor, the workspace thumbnails won't adjust for the top panel.
// NOTE2: also needed when dock-fixed is enabled/disabled to adjust for workspace area change
GSFunctions['LayoutManager_updateRegions'] = Layout.LayoutManager.prototype._updateRegions;
Layout.LayoutManager.prototype._updateRegions = function() {
let workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
let ret = GSFunctions['LayoutManager_updateRegions'].call(this);
// SANITY CHECK:
if (_DEBUG_) global.log("dockedWorkspaces: UPDATEREGIONS - workArea W= "+workArea.width + " H= "+workArea.height+ " X= "+workArea.x+ " Y= "+workArea.y+" CURRENT W="+self._workAreaWidth+" H="+self._workAreaHeight+" FORCED?="+self._refreshThumbnailsOnRegionUpdate);
if (self._refreshThumbnailsOnRegionUpdate) {
self._refreshThumbnailsOnRegionUpdate = false;
self._refreshThumbnails();
} else {
if (self._workAreaWidth) {
let widthTolerance = workArea.width * .01;
let heightTolerance = workArea.height * .01;
if (self._workAreaWidth < workArea.width-widthTolerance || self._workAreaWidth > workArea.width+widthTolerance) {
self._refreshThumbnails();
} else if (self._workAreaHeight < workArea.height-heightTolerance || self._workAreaHeight > workArea.height+heightTolerance) {
self._refreshThumbnails();
}
} else {
self._refreshThumbnails();
}
}
return ret;
};
// Override geometry calculations of activities overview to use workspaces-to-dock instead of the default thumbnailsbox.
// NOTE: This is needed for when the dock is positioned on a secondary monitor and also for when the shortcuts panel is visible
// causing the dock to be wider than normal.
GSFunctions['WorkspacesDisplay_updateWorkspacesActualGeometry'] = WorkspacesView.WorkspacesDisplay.prototype._updateWorkspacesActualGeometry;
WorkspacesView.WorkspacesDisplay.prototype._updateWorkspacesActualGeometry = function() {
if (_DEBUG_) global.log("WORKSPACESDISPLAY - _UPDATE ACTUALGEOMETRY");
if (!this._workspacesViews.length)
return;
let [x, y] = this.actor.get_transformed_position();
let allocation = this.actor.allocation;
let width = allocation.x2 - allocation.x1;
let height = allocation.y2 - allocation.y1;
let spacing = Main.overview._controls.actor.get_theme_node().get_length('spacing');
let monitors = Main.layoutManager.monitors;
// Get Dash monitor index
let dashMonitorIndex = this._primaryIndex;
let dashMultiMonitor = false;
if (DashToDock) {
if (DashToDock.dockManager) {
dashMonitorIndex = DashToDock.dockManager._preferredMonitorIndex;
dashMultiMonitor = DashToDock.dockManager._settings.get_boolean('multi-monitor');
} else {
dashMonitorIndex = DashToDock.dock._settings.get_int('preferred-monitor');
if (dashMonitorIndex < 0 || dashMonitorIndex >= Main.layoutManager.monitors.length) {
dashMonitorIndex = this._primaryIndex;
}
}
}
// Get thumbnails monitor index
let preferredMonitorIndex = self._settings.get_int('preferred-monitor');
let thumbnailsMonitorIndex = (Main.layoutManager.primaryIndex + preferredMonitorIndex) % Main.layoutManager.monitors.length ;
// Iterate through monitors
for (let i = 0; i < monitors.length; i++) {
let geometry = { x: monitors[i].x, y: monitors[i].y, width: monitors[i].width, height: monitors[i].height };
// Adjust index to point to correct dock
// Only needed when using DashToDock.dockManager
let idx;
if (i == dashMonitorIndex || dashMultiMonitor) {
idx = 0;
} else if (i < dashMonitorIndex) {
idx = i + 1;
}
// Adjust width for dash
let dashWidth = 0;
let dashHeight = 0;
let monitorHasDashDock = false;
if (DashToDock) {
if (DashToDock.dockManager) {
if (DashToDock.dockManager._allDocks[0]) {
if (i == dashMonitorIndex || dashMultiMonitor) {
monitorHasDashDock = true;
if (DashToDock.dockManager._allDocks[idx]._position == St.Side.LEFT ||
DashToDock.dockManager._allDocks[idx]._position == St.Side.RIGHT) {
dashWidth = DashToDock.dockManager._allDocks[idx]._box.width + spacing;
}
if (DashToDock.dockManager._allDocks[idx]._position == St.Side.TOP ||
DashToDock.dockManager._allDocks[idx]._position == St.Side.BOTTOM) {
dashHeight = DashToDock.dockManager._allDocks[idx]._box.height + spacing;
}
}
}
} else {
if (i == dashMonitorIndex) {
monitorHasDashDock = true;
if (DashToDockExtension.hasDockPositionKey) {
if (DashToDock.dock._position == St.Side.LEFT ||
DashToDock.dock._position == St.Side.RIGHT) {
dashWidth = DashToDock.dock._box.width + spacing;
}
if (DashToDock.dock._position == St.Side.TOP ||
DashToDock.dock._position == St.Side.BOTTOM) {
dashHeight = DashToDock.dock._box.height + spacing;
}
} else {
dashWidth = DashToDock.dock._box.width + spacing;
}
}
}
} else {
if (!self._settings.get_boolean('hide-dash') &&
i == this._primaryIndex) {
dashWidth = Main.overview._controls._dashSlider.getVisibleWidth() + spacing;
}
}
// Adjust width for workspaces thumbnails
let thumbnailsWidth = 0;
let thumbnailsHeight = 0;
let monitorHasThumbnailsDock = false;
if (i == thumbnailsMonitorIndex) {
monitorHasThumbnailsDock = true;
let fixedPosition = self._settings.get_boolean('dock-fixed');
let overviewAction = self._settings.get_enum('overview-action');
let visibleEdge = self._triggerWidth;
if (self._settings.get_boolean('dock-edge-visible')) {
visibleEdge = self._triggerWidth + DOCK_EDGE_VISIBLE_WIDTH;
}
if (self._position == St.Side.LEFT ||
self._position == St.Side.RIGHT) {
if (fixedPosition) {
thumbnailsWidth = self.actor.get_width() + spacing;
} else {
if (overviewAction == OverviewAction.HIDE) {
thumbnailsWidth = visibleEdge;
} else if (overviewAction == OverviewAction.SHOW_PARTIAL) {
thumbnailsWidth = self._slider.partialSlideoutSize;
} else {
thumbnailsWidth = self.actor.get_width() + spacing;
}
}
}
if (self._position == St.Side.TOP ||
self._position == St.Side.BOTTOM) {
if (fixedPosition) {
thumbnailsHeight = self.actor.get_height() + spacing;
} else {
if (overviewAction == OverviewAction.HIDE) {
thumbnailsHeight = visibleEdge;
} else if (overviewAction == OverviewAction.SHOW_PARTIAL) {
thumbnailsHeight = self._slider.partialSlideoutSize;
} else {
thumbnailsHeight = self.actor.get_height() + spacing;
}
}
}
}
// Adjust x and width for workspacesView geometry
let controlsWidth = dashWidth + thumbnailsWidth;
if (DashToDock && DashToDockExtension.hasDockPositionKey) {
if (DashToDock.dockManager) {
if (DashToDock.dockManager._allDocks[0]) {
// What if dash and thumbnailsbox are both on the same side?
if ((monitorHasDashDock && DashToDock.dockManager._allDocks[idx]._position == St.Side.LEFT) &&
(monitorHasThumbnailsDock && self._position == St.Side.LEFT)) {
controlsWidth = Math.max(dashWidth, thumbnailsWidth);
geometry.x += controlsWidth;
} else {
if (monitorHasDashDock && DashToDock.dockManager._allDocks[idx]._position == St.Side.LEFT) {
geometry.x += dashWidth;
}
if (monitorHasThumbnailsDock && self._position == St.Side.LEFT) {
geometry.x += thumbnailsWidth;
}
}
if ((monitorHasDashDock && DashToDock.dockManager._allDocks[idx]._position == St.Side.RIGHT) &&
(monitorHasThumbnailsDock && self._position == St.Side.RIGHT)) {
controlsWidth = Math.max(dashWidth, thumbnailsWidth);
}
}
} else {
// What if dash and thumbnailsbox are both on the same side?
if ((monitorHasDashDock && DashToDock.dock._position == St.Side.LEFT) &&
(monitorHasThumbnailsDock && self._position == St.Side.LEFT)) {
controlsWidth = Math.max(dashWidth, thumbnailsWidth);
geometry.x += controlsWidth;
} else {
if (monitorHasDashDock && DashToDock.dock._position == St.Side.LEFT) {
geometry.x += dashWidth;
}
if (monitorHasThumbnailsDock && self._position == St.Side.LEFT) {
geometry.x += thumbnailsWidth;
}
}
if ((monitorHasDashDock && DashToDock.dock._position == St.Side.RIGHT) &&
(monitorHasThumbnailsDock && self._position == St.Side.RIGHT)) {
controlsWidth = Math.max(dashWidth, thumbnailsWidth);
}
}
} else {
if (this.actor.get_text_direction() == Clutter.TextDirection.LTR) {
if (monitorHasThumbnailsDock && self._position == St.Side.LEFT) {
controlsWidth = Math.max(dashWidth, thumbnailsWidth);
geometry.x += controlsWidth;
} else {
geometry.x += dashWidth;
}
} else {
if (monitorHasThumbnailsDock && self._position == St.Side.RIGHT) {
controlsWidth = Math.max(dashWidth, thumbnailsWidth);
} else {
geometry.x += thumbnailsWidth;
}
}
}
geometry.width -= controlsWidth;
// Adjust y and height for workspacesView geometry for primary monitor (top panel, etc.)
if (i == this._primaryIndex) {
geometry.y = y;
geometry.height = height;
}
// What if dash and thumbnailsBox are not on the primary monitor?
let controlsHeight = dashHeight + thumbnailsHeight;
if (DashToDock && DashToDockExtension.hasDockPositionKey) {
if (DashToDock.dockManager) {
if (DashToDock.dockManager._allDocks[0]) {
if ((monitorHasDashDock && DashToDock.dockManager._allDocks[idx]._position == St.Side.TOP) &&
(monitorHasThumbnailsDock && self._position == St.Side.TOP)) {
controlsHeight = Math.max(dashHeight, thumbnailsHeight);
geometry.y += controlsHeight;
} else {
if (monitorHasDashDock && DashToDock.dockManager._allDocks[idx]._position == St.Side.TOP) {
geometry.y += dashHeight;
}
if (monitorHasThumbnailsDock && self._position == St.Side.TOP) {
geometry.y += thumbnailsHeight;
}
}
if ((monitorHasDashDock && DashToDock.dockManager._allDocks[idx]._position == St.Side.BOTTOM) &&
(monitorHasThumbnailsDock && self._position == St.Side.BOTTOM)) {
controlsHeight = Math.max(dashHeight, thumbnailsHeight);
}
}
} else {
if ((monitorHasDashDock && DashToDock.dock._position == St.Side.TOP) &&
(monitorHasThumbnailsDock && self._position == St.Side.TOP)) {
controlsHeight = Math.max(dashHeight, thumbnailsHeight);
geometry.y += controlsHeight;
} else {
if (monitorHasDashDock && DashToDock.dock._position == St.Side.TOP) {
geometry.y += dashHeight;
}
if (monitorHasThumbnailsDock && self._position == St.Side.TOP) {
geometry.y += thumbnailsHeight;
}
}
if ((monitorHasDashDock && DashToDock.dock._position == St.Side.BOTTOM) &&
(monitorHasThumbnailsDock && self._position == St.Side.BOTTOM)) {
controlsHeight = Math.max(dashHeight, thumbnailsHeight);
}
}
} else {
if (monitorHasThumbnailsDock && self._position == St.Side.TOP) {
geometry.y += thumbnailsHeight;
}
}
geometry.height -= controlsHeight;
if (_DEBUG_) global.log("MONITOR = "+i);
this._workspacesViews[i].setMyActualGeometry(geometry);
}
};
// This override is needed to prevent calls from updateWorkspacesActualGeometry bound to the workspacesDisplay object
// without destroying and recreating Main.overview.viewSelector._workspacesDisplay.
// We replace this function with a new setMyActualGeometry function (see below)
// TODO: This is very hackish. We need to find a better way to accomplish this
GSFunctions['WorkspacesViewBase_setActualGeometry'] = WorkspacesView.WorkspacesViewBase.prototype.setActualGeometry;
WorkspacesView.WorkspacesViewBase.prototype.setActualGeometry = function(geom) {
if (_DEBUG_) global.log("WORKSPACESVIEW - setActualGeometry");
//GSFunctions['WorkspacesView_setActualGeometry'].call(this, geom);
return;
};
// This additional function replaces the WorkspacesView setActualGeometry function above.
// TODO: This is very hackish. We need to find a better way to accomplish this
WorkspacesView.WorkspacesViewBase.prototype.setMyActualGeometry = function(geom) {
if (_DEBUG_) global.log("WORKSPACESVIEW - setMyActualGeometry");
this._actualGeometry = geom;
this._syncActualGeometry();
};
this._overrideComplete = true;
},
// function called during destroy to restore gnome shell 3.4/3.6/3.8
_restoreGnomeShellFunctions: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _restoreGnomeShellFunctions");
// Restore normal Dash
if (this._settings.get_boolean('hide-dash')) {
if (!DashToDock) {
// Show normal dash (if no dash-to-dock)
Main.overview._controls.dash.actor.show();
Main.overview._controls.dash.actor.set_width(-1);
// This forces the recalculation of the icon size
Main.overview._controls.dash._maxHeight = -1;
}
}
// Restore source of swarm animation to normal apps button
Overview.Overview.prototype.getShowAppsButton = GSFunctions['Overview_getShowAppsButton'];
// Show normal workspaces thumbnailsBox
Main.overview._controls._thumbnailsSlider.actor.opacity = 255;
// Restore normal WorkspaceSwitcherPopup_show function
WorkspaceSwitcherPopup.WorkspaceSwitcherPopup.prototype._show = GSFunctions['WorkspaceSwitcherPopup_show'];
// Restore normal LayoutManager _updateRegions function
// Layout.LayoutManager.prototype._queueUpdateRegions = GSFunctions['LayoutManager_queueUpdateRegions'];
Layout.LayoutManager.prototype._updateRegions = GSFunctions['LayoutManager_updateRegions'];
// Restore normal WorkspacesDisplay _updateworksapgesActualGeometray function
WorkspacesView.WorkspacesDisplay.prototype._updateWorkspacesActualGeometry = GSFunctions['WorkspacesDisplay_updateWorkspacesActualGeometry'];
// Restore normal WorkspacesView _setActualGeometry function
WorkspacesView.WorkspacesViewBase.prototype.setActualGeometry = GSFunctions['WorkspacesViewBase_setActualGeometry'];
WorkspacesView.WorkspacesViewBase.prototype.setMyActualGeometry = null;
},
// handler for when shortcuts panel is updated
_onShortcutsPanelUpdated: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onShortcutsPanelUpdated");
this._updateSize();
this._redisplay();
},
// handler for when thumbnailsBox is resized
_thumbnailsBoxResized: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _thumbnailsBoxResized");
this._updateSize();
this._redisplay();
},
// handler for when dock y position is updated
_updateYPosition: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _updateYPosition");
this._updateSize();
},
// handler for when workspaces are added
_onWorkspaceAdded: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onWorkspaceAdded");
this._updateSize();
this._redisplay();
},
// handler for when workspaces are removed
_onWorkspaceRemoved: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onWorkspaceRemoved");
this._updateSize();
this._redisplay();
},
_updateTriggerWidth: function(force) {
if (_DEBUG_) global.log("dockedWorkspaces: _updateTriggerWidth");
// Calculate and set triggerWidth
let previousTriggerWidth = this._triggerWidth;
if (this._settings.get_boolean('dock-fixed')) {
this._triggerWidth = 0;
} else if (this._settings.get_boolean('intellihide') && this._settings.get_enum('intellihide-action') == IntellihideAction.SHOW_PARTIAL_FIXED) {
this._triggerWidth = 1;
} else {
if (!this._settings.get_boolean('dock-edge-visible') &&
this._settings.get_boolean('require-pressure-to-show') &&
this._settings.get_boolean('disable-scroll')) {
if (this._pressureSensed) {
this._triggerWidth = 1;
} else if (this._dockState == DockState.SHOWN) {
this._triggerWidth = 1;
} else {
this._triggerWidth = 0;
}
} else {
this._triggerWidth = 1;
}
}
if (previousTriggerWidth == this._triggerWidth && !force)
return;
if (!this._disableRedisplay)
this._updateSize();
},
// handler for when dock height is updated
_updateHeight: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _updateHeight");
this._updateSize();
},
// handler to bind settings when preferences changed
_bindSettingsChanges: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _bindSettingsChanges");
this._settings.connect('changed::opaque-background', Lang.bind(this, function() {
this._updateBackgroundOpacity();
}));
this._settings.connect('changed::background-opacity', Lang.bind(this, function() {
this._updateBackgroundOpacity();
}));
this._settings.connect('changed::straight-corners', Lang.bind(this, function() {
this._updateStraightCorners();
}));
this._settings.connect('changed::autohide', Lang.bind(this, function() {
this.emit('box-changed');
this._updateBarrier();
}));
this._settings.connect('changed::preferred-monitor', Lang.bind(this, function() {
this._resetPosition();
this._redisplay();
}));
this._settings.connect('changed::hide-dash', Lang.bind(this, function() {
if (this._settings.get_boolean('hide-dash')) {
Main.overview._controls.dash.actor.hide();
Main.overview._controls.dash.actor.set_width(1);
} else {
if (!DashToDock) {
// Show normal dash (if no dash-to-dock)
Main.overview._controls.dash.actor.show();
Main.overview._controls.dash.actor.set_width(-1);
// This forces the recalculation of the icon size
Main.overview._controls.dash._maxHeight = -1;
}
}
}));
this._settings.connect('changed::show-shortcuts-panel', Lang.bind(this, function() {
let shortcutsPanelOrientation = this._settings.get_enum('shortcuts-panel-orientation');
if (this._settings.get_boolean('show-shortcuts-panel')) {
if (shortcutsPanelOrientation == 1) {
this._dock.add_style_class_name('inside');
}
this._shortcutsPanel.actor.show();
} else {
if (shortcutsPanelOrientation == 1) {
this._dock.remove_style_class_name('inside');
}
this._shortcutsPanel.actor.hide();
}
this._updateSize();
this._redisplay();
}));
this._settings.connect('changed::shortcuts-panel-icon-size', Lang.bind(this, function() {
this._shortcutsPanel.refresh();
this._updateSize();
this._redisplay();
}));
this._settings.connect('changed::shortcuts-panel-show-running', Lang.bind(this, function() {
this._shortcutsPanel.refresh();
this._updateSize();
this._redisplay();
}));
this._settings.connect('changed::shortcuts-panel-show-places', Lang.bind(this, function() {
this._shortcutsPanel.refresh();
this._updateSize();
this._redisplay();
}));
this._settings.connect('changed::dock-edge-visible', Lang.bind(this, function() {
this._updateTriggerWidth(true);
this._redisplay();
}));
this._settings.connect('changed::require-pressure-to-show', Lang.bind(this, function() {
this._updateTriggerWidth(true);
this._redisplay();
}));
this._settings.connect('changed::pressure-threshold', Lang.bind(this, function() {
this._updatePressureBarrier();
this._updateBarrier();
}));
this._settings.connect('changed::use-pressure-speed-limit', Lang.bind(this, function() {
this._updatePressureBarrier();
this._updateBarrier();
}));
this._settings.connect('changed::pressure-speed-limit', Lang.bind(this, function() {
this._updatePressureBarrier();
this._updateBarrier();
}));
this._settings.connect('changed::disable-scroll', Lang.bind(this, function() {
this._updateTriggerWidth(true);
this._redisplay();
}));
this._settings.connect('changed::screen-edge-padding', Lang.bind(this, function() {
this._updateSize();
this._redisplay();
}));
this._settings.connect('changed::customize-thumbnail', Lang.bind(this, function() {
// hide and show thumbnailsBox to resize thumbnails
this._refreshThumbnails();
}));
this._settings.connect('changed::thumbnail-size', Lang.bind(this, function() {
// hide and show thumbnailsBox to resize thumbnails
this._refreshThumbnails();
}));
this._settings.connect('changed::customize-thumbnail-visible-width', Lang.bind(this, function() {
this._updateTriggerWidth(true);
this._redisplay();
}));
this._settings.connect('changed::thumbnail-visible-width', Lang.bind(this, function() {
this._updateTriggerWidth(true);
this._redisplay();
}));
this._settings.connect('changed::workspace-captions', Lang.bind(this, function() {
// hide and show thumbnailsBox to reset workspace apps in caption
this._refreshThumbnails();
}));
this._settings.connect('changed::workspace-caption-position', Lang.bind(this, function() {
// hide and show thumbnailsBox to reset workspace apps in caption
this._refreshThumbnails();
}));
this._settings.connect('changed::workspace-caption-height', Lang.bind(this, function() {
// hide and show thumbnailsBox to reset workspace apps in caption
this._refreshThumbnails();
}));
this._settings.connect('changed::workspace-caption-items', Lang.bind(this, function() {
// hide and show thumbnailsBox to reset workspace apps in caption
this._refreshThumbnails();
}));
this._settings.connect('changed::workspace-caption-windowcount-image', Lang.bind(this, function() {
// hide and show thumbnailsBox to reset workspace apps in caption
this._refreshThumbnails();
}));
this._settings.connect('changed::workspace-caption-taskbar-icon-size', Lang.bind(this, function() {
// hide and show thumbnailsBox to reset workspace apps in caption
this._refreshThumbnails();
}));
this._settings.connect('changed::top-margin', Lang.bind(this, function() {
// Add or remove addtional style class when workspace is fixed and set to full height
if (this._settings.get_boolean('customize-height') && this._settings.get_int('customize-height-option') == 1) {
if (this._settings.get_double('top-margin') == 0 || this._settings.get_double('bottom-margin') == 0) {
this._dock.add_style_class_name('fullheight');
} else {
this._dock.remove_style_class_name('fullheight');
}
} else {
this._dock.remove_style_class_name('fullheight');
}
this._updateSize();
}));
this._settings.connect('changed::bottom-margin', Lang.bind(this, function() {
// Add or remove addtional style class when workspace is fixed and set to full height
if (this._settings.get_boolean('customize-height') && this._settings.get_int('customize-height-option') == 1) {
if (this._settings.get_double('top-margin') == 0 || this._settings.get_double('bottom-margin') == 0) {
this._dock.add_style_class_name('fullheight');
} else {
this._dock.remove_style_class_name('fullheight');
}
} else {
this._dock.remove_style_class_name('fullheight');
}
this._updateSize();
}));
this._settings.connect('changed::toggle-dock-with-keyboard-shortcut', Lang.bind(this, function(){
if (this._settings.get_boolean('toggle-dock-with-keyboard-shortcut'))
this._bindDockKeyboardShortcut();
else
this._unbindDockKeyboardShortcut();
}));
},
_updatePressureBarrier: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _updatePressureBarrier");
let self = this;
this._canUsePressure = global.display.supports_extended_barriers();
let pressureThreshold = this._settings.get_double('pressure-threshold');
let speedLimit;
if (this._settings.get_boolean('use-pressure-speed-limit'))
speedLimit = this._settings.get_double('pressure-speed-limit');
// Remove existing pressure barrier
if (this._pressureBarrier) {
if (_DEBUG_) global.log("... destroying old pressureBarrier object");
this._pressureBarrier.destroy();
this._pressureBarrier = null;
}
// Create new pressure barrier based on pressure threshold setting
if (this._canUsePressure) {
if (_DEBUG_) global.log("... creating pressureBarrier object");
this._pressureBarrier = new MyPressureBarrier.myPressureBarrier(pressureThreshold, speedLimit, PRESSURE_TIMEOUT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW);
this._pressureBarrier.connect('trigger', function(barrier){
self._onPressureSensed();
});
this._pressureBarrier.connect('speed-exceeded', function(barrier){
self._onSpeedExceeded();
});
if (_DEBUG_) global.log("dockedWorkspaces: init - canUsePressure = "+this._canUsePressure);
}
},
_bindDockKeyboardShortcut: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _bindDockKeyboardShortcut");
Main.wm.addKeybinding('dock-keyboard-shortcut', this._settings, Meta.KeyBindingFlags.NONE, Shell.ActionMode.NORMAL,
Lang.bind(this, function() {
if (_DEBUG_) global.log("KEYBOARD SHORTCUT PRESSED autohideStatus = "+this._autohideStatus);
if (this._autohideStatus) {
if (this._dockState == DockState.HIDDEN || this._dockState == DockState.HIDING) {
this._toggleWithKeyboard(true);
} else {
this._toggleWithKeyboard(false);
}
} else {
if (this._dockState == DockState.SHOWN || this._dockState == DockState.SHOWING) {
this._toggleWithKeyboard(false);
} else {
this._toggleWithKeyboard(true);
}
}
})
);
},
_toggleWithKeyboard: function(show) {
if (_DEBUG_) global.log("dockedWorkspaces: _toggleWithKeyboard");
// Clear keyboard toggle timeout
if (this._toggleWithKeyboardTimeoutId > 0) {
Mainloop.source_remove(this._toggleWithKeyboardTimeoutId);
this._toggleWithKeyboardTimeoutId = 0;
}
// Hide dock after timeout
if (show) {
this._show();
let timeout = this._settings.get_double('keyboard-toggle-timeout') * 1000;
this._toggleWithKeyboardTimeoutId = Mainloop.timeout_add(timeout, Lang.bind(this, function(){
this._toggleWithKeyboard(false);
}));
} else {
this._hide();
}
},
_unbindDockKeyboardShortcut: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _unbindDockKeyboardShortcut");
Main.wm.removeKeybinding('dock-keyboard-shortcut');
},
// Determine if mouse is hovering dock container
_isHovering: function() {
if (this._dock.hover) {
if (_DEBUG_) global.log("dockedWorkspaces: _isHovering DOCK true");
return true;
} else {
if (_DEBUG_) global.log("dockedWorkspaces: _isHovering DOCK false");
return false;
}
},
// handler for mouse hover events
_hoverChanged: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _hoverChanged - isHovering = "+this._isHovering()+" autohideStatus-dodging = "+this._autohideStatus+" dockState = "+getDockStateDesc(this._dockState)+" pSensed="+this._pressureSensed+" barrier="+this._barrier);
if (this._settings.get_boolean('dock-fixed')) {
return;
}
if (this._canUsePressure && this._settings.get_boolean('require-pressure-to-show') && this._barrier) {
if (this._pressureSensed == false && this._dockState != DockState.SHOWN) {
if (_DEBUG_) global.log("dockedWorkspaces: _hoverChanged - presureSensed = "+this._pressureSensed+" RETURN");
if (this._isHovering()) {
return;
}
}
}
if (this._settings.get_boolean('require-click-to-show')) {
// check if metaWin is maximized
let workspaceManager = global.workspace_manager;
let activeWorkspace = workspaceManager.get_active_workspace();
let maximized = false;
let windows = global.get_window_actors();
for (let i = windows.length-1; i >= 0; i--) {
let metaWin = windows[i].get_meta_window();
if (metaWin.get_workspace() == activeWorkspace) {
if(_DEBUG_) global.log("dockedWorkspaces: _hoverChanged - window is on active workspace");
if(_DEBUG_) global.log("dockedWorkspaces: _hoverChanged - window class = "+metaWin.get_wm_class());
if (metaWin.appears_focused && metaWin.maximized_horizontally) {
maximized = true;
if (_DEBUG_) global.log("dockedWorkspaces: _hoverChanged - window is focused and maximized");
break;
}
}
}
// set hovering flag if maximized
// used by the _onDockClicked function (hover+click)
if (maximized) {
if (this._isHovering()) {
this._hovering = true;
if (this._dockState != DockState.SHOWN) {
return;
}
} else {
this._hovering = false;
}
} else {
this._hovering = false;
}
}
//Skip if dock is not in autohide mode for instance because it is shown by intellihide
if (_DEBUG_) global.log("dockedWorkspaces: _hoverChanged - show or hide?");
if (this._settings.get_boolean('autohide')) {
if (this._isHovering()) {
if (_DEBUG_) global.log("dockedWorkspaces: _hoverChanged - show");
this._show();
} else {
if (_DEBUG_) global.log("dockedWorkspaces: _hoverChanged - hide");
this._hide();
}
} else {
this._hide();
}
},
_checkHoverStatus: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _checkHoverStatus");
if (this._checkHoverStatusId > 0) {
Mainloop.source_remove(this._checkHoverStatusId);
this._checkHoverStatusId = 0;
}
if (Extension.intellihide._toggledOverviewOnDrag == false) {
if (this._toggleWithKeyboardTimeoutId == 0) {
this._hoverChanged();
}
}
},
// handler for mouse click events - works in conjuction with hover event to show dock for maxmized windows
_onDockClicked: function(actor, event) {
if (_DEBUG_) global.log("dockedWorkspaces: _onDockClicked");
// Show overview if button is right click
if (this._settings.get_boolean('toggle-overview')) {
let button = event.get_button();
if (button == 3) { //right click
if (Main.overview.visible) {
Main.overview.hide(); // force normal mode
} else {
Main.overview.show(); // force overview mode
}
// pass right-click event on allowing it to bubble up
return Clutter.EVENT_PROPAGATE;
}
}
if (this._settings.get_boolean('require-click-to-show')) {
if (this._hovering) {
//Skip if dock is not in autohide mode for instance because it is shown by intellihide
if (this._settings.get_boolean('autohide') && this._autohideStatus) {
if (this._isHovering()) {
this._show();
} else {
this._hide();
}
}
this._hovering = false;
}
}
return Clutter.EVENT_STOP;
},
_onSpeedExceeded: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onSpeedExceeded");
// FIX ISSUE: #23
// Remove barrier so that mouse pointer can access monitors on other side of dock quickly
// --------------
// CONTINUE IF
// dock NOT in single monitor config
// dock NOT on first monitor && in left position
// dock NOT on last monitor && in right position
if (this._settings.get_boolean('use-pressure-speed-limit')) {
if ((Main.layoutManager.monitors.length > 1) &&
!(this._monitor == 0 && this._position == St.Side.LEFT) &&
!(this._monitor == Main.layoutManager.monitors.length-1 && this._position == St.Side.RIGHT)) {
// Remove barrier immediately
this._removeBarrier();
// Restore barrier after short timeout
if (this._restoreBarrierTimeoutId > 0) {
Mainloop.source_remove(this._restoreBarrierTimeoutId);
this._restoreBarrierTimeoutId = 0;
}
this._restoreBarrierTimeoutId = Mainloop.timeout_add(500, Lang.bind(this, this._updateBarrier));
}
}
},
// handler for mouse pressure sensed (GS38+ only)
_onPressureSensed: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onPressureSensed");
this._pressureSensed = true;
this._updateTriggerWidth();
this._hoverChanged();
},
_onDashToDockShowing: function() {
if (_DEBUG_) global.log("Dash SHOWING");
//Skip if dock is not in dashtodock hover mode
if (this._settings.get_boolean('dashtodock-hover')) {
if (DashToDock && Main.overview.visible == false) {
if (DashToDock.dockManager) {
if (DashToDock.dockManager._allDocks[0]._box.hover) {
this._hoveringDash = true;
this._show();
}
} else {
if (DashToDock.dock._box.hover) {
this._hoveringDash = true;
this._show();
}
}
}
}
},
_onDashToDockHiding: function() {
if (_DEBUG_) global.log("Dash HIDING");
//Skip if dock is not in dashtodock hover mode
if (this._settings.get_boolean('dashtodock-hover')) {
if (DashToDock) {
this._hoveringDash = false;
this._hide();
}
}
},
_onDashToDockLeave: function() {
if (_DEBUG_) global.log("Dash Button LEAVE");
// NOTE: Causing workspaces-to-dock to hide when switching workspaces in Gnome 3.14.
// Remove until a workaround can be found.
// this._hoveringDash = false;
},
// handler for DashToDock hover events
_onDashToDockHoverChanged: function() {
if (_DEBUG_) global.log("Dash HOVER Changed");
//Skip if dock is not in dashtodock hover mode
if (this._settings.get_boolean('dashtodock-hover')) {
if (DashToDock) {
if (DashToDock.dockManager) {
if (DashToDock.dockManager._allDocks[0]._box.hover) {
if (Main.overview.visible == false) {
this._hoveringDash = true;
this._show();
}
} else {
this._hoveringDash = false;
this._hide();
}
} else {
if (DashToDock.dock._box.hover) {
if (Main.overview.visible == false) {
this._hoveringDash = true;
this._show();
}
} else {
this._hoveringDash = false;
this._hide();
}
}
}
}
},
_onDashToDockToggled: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onDashToDockToggled DASHTODOCK MULTIMONITOR TOGGLED");
this._hoveringDash = false;
this._disconnectDashToDockSignals();
this._connectDashToDockSignals();
},
_onDashToDockBoxDestroy: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onDashToDockBoxDestroy for DASHTODOCK");
this._signalHandler.disconnectWithLabel('DashToDockBoxHoverSignal');
},
_disconnectDashToDockSignals: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _disconnectDashToDockSignals for DASHTODOCK");
this._signalHandler.disconnectWithLabel('DashToDockBoxHoverSignal');
this._signalHandler.disconnectWithLabel('DashToDockManagerSignal');
},
_connectDashToDockSignals: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _connectDashToDockSignals for DASHTODOCK");
if (DashToDock) {
// Connect DashToDock hover signal
if (DashToDock.dockManager) {
if (DashToDock.dockManager._allDocks[0]) {
this._signalHandler.pushWithLabel(
'DashToDockBoxHoverSignal',
[
DashToDock.dockManager._allDocks[0]._box,
'destroy',
Lang.bind(this, this._onDashToDockBoxDestroy)
],
[
DashToDock.dockManager._allDocks[0]._box,
'notify::hover',
Lang.bind(this, this._onDashToDockHoverChanged)
],
[
DashToDock.dockManager._allDocks[0]._box,
'leave-event',
Lang.bind(this, this._onDashToDockLeave)
]
);
this._signalHandler.pushWithLabel(
'DashToDockManagerSignal',
[
DashToDock.dockManager._allDocks[0],
'showing',
Lang.bind(this, this._onDashToDockShowing)
],
[
DashToDock.dockManager._allDocks[0],
'hiding',
Lang.bind(this, this._onDashToDockHiding)
],
[
DashToDock.dockManager,
'toggled',
Lang.bind(this, this._onDashToDockToggled)
]
);
}
} else {
this._signalHandler.pushWithLabel(
'DashToDockHoverSignal',
[
DashToDock.dock._box,
'notify::hover',
Lang.bind(this, this._onDashToDockHoverChanged)
],
[
DashToDock.dock._box,
'leave-event',
Lang.bind(this, this._onDashToDockLeave)
],
[
DashToDock.dock,
'showing',
Lang.bind(this, this._onDashToDockShowing)
],
[
DashToDock.dock,
'hiding',
Lang.bind(this, this._onDashToDockHiding)
]
);
}
}
},
// handler for extensionSystem state changes
_onExtensionSystemStateChanged: function(source, extension) {
// Only looking for DashToDock state changes
if (extension.uuid == DashToDock_UUID) {
if (_DEBUG_) global.log("dockedWorkspaces: _onExtensionSystemStateChanged for "+extension.uuid+" state= "+extension.state);
DashToDockExtension = extension;
if (DashToDockExtension.state == ExtensionSystem.ExtensionState.ENABLED) {
DashToDock = DashToDockExtension.imports.extension;
if (DashToDock) {
DashToDockExtension.hasDockPositionKey = false;
if (DashToDock.dockManager) {
DashToDockExtension.hasDockPositionKey = true;
} else {
var keys = DashToDock.dock._settings.list_keys();
if (keys.indexOf('dock-position') > -1) {
DashToDockExtension.hasDockPositionKey = true;
}
}
this._connectDashToDockSignals();
}
} else if (extension.state == ExtensionSystem.ExtensionState.DISABLED || extension.state == ExtensionSystem.ExtensionState.UNINSTALLED) {
DashToDock = null;
this._hoveringDash = false;
this._disconnectDashToDockSignals();
}
}
},
// handler for mouse scroll events
// Switches workspace by scrolling over the dock
// This comes from desktop-scroller@obsidien.github.com
_onScrollEvent: function (actor, event) {
if (_DEBUG_) global.log("dockedWorkspaces: _onScrollEvent autohideStatus = "+this._autohideStatus+" dockState = "+this._dockState + " slidex = "+this._slider.slidex);
if (this._settings.get_boolean('disable-scroll') &&
this._autohideStatus &&
this._slider.slidex == 0 && // Need to check the slidex for partially showing dock
(this._dockState == DockState.HIDDEN || this._dockState == DockState.HIDING))
return Clutter.EVENT_STOP;
let workspaceManager = global.workspace_manager;
let activeWs = workspaceManager.get_active_workspace();
let direction;
switch (event.get_scroll_direction()) {
case Clutter.ScrollDirection.UP:
if (this._isHorizontal && this._settings.get_boolean('horizontal-workspace-switching')) {
direction = Meta.MotionDirection.LEFT;
} else {
direction = Meta.MotionDirection.UP;
}
break;
case Clutter.ScrollDirection.DOWN:
if (this._isHorizontal && this._settings.get_boolean('horizontal-workspace-switching')) {
direction = Meta.MotionDirection.RIGHT;
} else {
direction = Meta.MotionDirection.DOWN;
}
break;
case Clutter.ScrollDirection.LEFT:
if (this._isHorizontal && this._settings.get_boolean('horizontal-workspace-switching')) {
direction = Meta.MotionDirection.LEFT;
}
break;
case Clutter.ScrollDirection.RIGHT:
if (this._isHorizontal && this._settings.get_boolean('horizontal-workspace-switching')) {
direction = Meta.MotionDirection.RIGHT;
}
break;
}
if (direction) {
if (this._settings.get_boolean('scroll-with-touchpad')) {
// passingthru67: copied from dash-to-dock
// Prevent scroll events from triggering too many workspace switches
// by adding a 250ms deadtime between each scroll event.
// Usefull on laptops when using a touchpad.
// During the deadtime do nothing
if(this._scrollWorkspaceSwitchDeadTimeId > 0)
return false;
else {
this._scrollWorkspaceSwitchDeadTimeId =
Mainloop.timeout_add(250,
Lang.bind(this, function() {
this._scrollWorkspaceSwitchDeadTimeId = 0;
}
));
}
}
let ws = activeWs.get_neighbor(direction);
if (Main.wm._workspaceSwitcherPopup == null) {
if (this._isHorizontal && this._settings.get_boolean('horizontal-workspace-switching')) {
Main.wm._workspaceSwitcherPopup = new MyWorkspaceSwitcherPopup.myWorkspaceSwitcherPopup();
} else {
Main.wm._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
}
}
// Set the workspaceSwitcherPopup actor to non reactive,
// to prevent it from grabbing focus away from the dock
Main.wm._workspaceSwitcherPopup.actor.reactive = false;
Main.wm._workspaceSwitcherPopup.connect('destroy', function() {
Main.wm._workspaceSwitcherPopup = null;
});
// Do not show wokspaceSwitcher in overview
if (!Main.overview.visible)
Main.wm._workspaceSwitcherPopup.display(direction, ws.index());
Main.wm.actionMoveWorkspace(ws);
}
return Clutter.EVENT_STOP;
},
// autohide function to show dock
_show: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _show autohideStatus = "+this._autohideStatus+" dockState = "+getDockStateDesc(this._dockState));
// Only show if dock hidden, is hiding, or is partially shown/hidden
if (this._dockState == DockState.HIDDEN || this._dockState == DockState.HIDING || this._slider.slidex < 1) {
this._removeAnimations();
// If the dock is hidden, wait this._settings.get_double('show-delay') before showing it;
// otherwise show it immediately.
let delay = 0;
if (this._dockState == DockState.HIDDEN)
delay = this._settings.get_double('show-delay');
this._animateIn(this._settings.get_double('animation-time'), delay, true);
}
},
// autohide function to hide dock
_hide: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _hide autohideStatus-dodging = "+this._autohideStatus+" dockState = "+getDockStateDesc(this._dockState));
this._updateTriggerWidth();
if (this._settings.get_boolean('dock-fixed')) {
return;
}
if (this._isHovering() || (this._hoveringDash && !Main.overview._shown)) {
return;
}
let intellihideAction = this._settings.get_enum('intellihide-action');
if (!Main.overview._shown && intellihideAction == IntellihideAction.SHOW_FULL && !this._autohideStatus) {
return;
}
let overviewAction = this._settings.get_enum('overview-action');
if (Main.overview._shown && overviewAction == OverviewAction.SHOW_FULL && !this._autohideStatus) {
return;
}
// Only hide if dock is shown, is showing, or is partially shown
if (this._dockState == DockState.SHOWN || this._dockState == DockState.SHOWING || this._slider.slidex > 0) {
this._removeAnimations();
// If the dock is shown, wait this._settings.get_double('show-delay') before hiding it;
// otherwise hide it immediately.
let delay = 0;
if (this._dockState == DockState.SHOWN)
delay = this._settings.get_double('hide-delay');
if (Main.overview._shown && Main.overview.viewSelector._activePage == Main.overview.viewSelector._workspacesPage) {
this._animateOut(this._settings.get_double('animation-time'), delay, false);
} else {
this._animateOut(this._settings.get_double('animation-time'), delay, this._autohideStatus);
}
}
},
setPopupMenuFlag: function(showing) {
if (_DEBUG_) global.log("dockedWorkspaces: setPopupMenuFlag - showing="+showing);
this._popupMenuShowing = showing;
if (!showing) {
if (this._isHovering()) {
this._dock.sync_hover();
} else {
this._hide();
}
}
},
// autohide function to animate the show dock process
_animateIn: function(time, delay, force) {
if (_DEBUG_) global.log("dockedWorkspaces: _animateIN force="+force+" dockState = "+getDockStateDesc(this._dockState));
let sliderVariable = 1;
let fixedPosition = this._settings.get_boolean('dock-fixed')
let overviewAction = this._settings.get_enum('overview-action');
let intellihideAction = this._settings.get_enum('intellihide-action');
let intellihide = this._settings.get_boolean('intellihide')
if (_DEBUG_) global.log("... overview="+Main.overview.visible+" - "+Main.overview._shown+" ia="+intellihideAction+" oa="+overviewAction);
if (!force && !fixedPosition) {
if ((Main.overview._shown && overviewAction == OverviewAction.SHOW_PARTIAL)
|| (!Main.overview._shown && intellihide && (intellihideAction == IntellihideAction.SHOW_PARTIAL || intellihideAction == IntellihideAction.SHOW_PARTIAL_FIXED))) {
if (this._slider.partialSlideoutSize) {
if (_DEBUG_) global.log("... animateIn: partial="+this._slider.partialSlideoutSize);
let fullsize;
if (this._isHorizontal) {
fullsize = this._dock.height;
} else {
fullsize = this._dock.width;
}
if (this._settings.get_boolean('dock-edge-visible')) {
let triggerWidth = 1; // We need trigger width to always be set to 1
let slideoutSize = DOCK_EDGE_VISIBLE_WIDTH - triggerWidth;
sliderVariable = (this._slider.partialSlideoutSize - slideoutSize) / fullsize;
} else {
sliderVariable = this._slider.partialSlideoutSize / fullsize;
}
}
} else {
this._dockState = DockState.SHOWING;
}
} else {
this._dockState = DockState.SHOWING;
}
Tweener.addTween(this._slider, {
slidex: sliderVariable,
time: time,
delay: delay,
transition: 'easeOutQuad',
onComplete: Lang.bind(this, function() {
if (_DEBUG_) global.log("dockedWorkspaces: _animateIN onComplete");
if (!force && !fixedPosition) {
if ((Main.overview._shown && overviewAction == OverviewAction.SHOW_PARTIAL)
|| (!Main.overview._shown && (intellihideAction == IntellihideAction.SHOW_PARTIAL || intellihideAction == IntellihideAction.SHOW_PARTIAL_FIXED))) {
this._updateBarrier();
} else {
this._dockState = DockState.SHOWN;
// Remove barrier so that mouse pointer is released and can access monitors on other side of dock
// NOTE: Delay needed to keep mouse from moving past dock and re-hiding dock immediately. This
// gives users an opportunity to hover over the dock
if (this._removeBarrierTimeoutId > 0) {
Mainloop.source_remove(this._removeBarrierTimeoutId);
this._removeBarrierTimeoutId = 0;
}
this._removeBarrierTimeoutId = Mainloop.timeout_add(100, Lang.bind(this, this._removeBarrier));
this._updateTriggerWidth();
}
} else {
this._dockState = DockState.SHOWN;
// Remove barrier so that mouse pointer is released and can access monitors on other side of dock
// NOTE: Delay needed to keep mouse from moving past dock and re-hiding dock immediately. This
// gives users an opportunity to hover over the dock
if (this._removeBarrierTimeoutId > 0) {
Mainloop.source_remove(this._removeBarrierTimeoutId);
this._removeBarrierTimeoutId = 0;
}
this._removeBarrierTimeoutId = Mainloop.timeout_add(100, Lang.bind(this, this._removeBarrier));
this._updateTriggerWidth();
}
// Prevent dock from getting stuck animated in when mouse is no longer hovering
if (this._checkHoverStatusId > 0) {
Mainloop.source_remove(this._checkHoverStatusId);
this._checkHoverStatusId = 0;
}
this._checkHoverStatusId = Mainloop.timeout_add(100, Lang.bind(this, this._checkHoverStatus));
})
});
},
// autohide function to animate the hide dock process
_animateOut: function(time, delay, force) {
if (this._popupMenuShowing)
return;
if (_DEBUG_) global.log("dockedWorkspaces: _animateOUT force="+force+" dockState = "+getDockStateDesc(this._dockState));
this._dockState = DockState.HIDING;
let sliderVariable = 0;
let fixedPosition = this._settings.get_boolean('dock-fixed')
let overviewAction = this._settings.get_enum('overview-action');
let intellihideAction = this._settings.get_enum('intellihide-action');
let intellihide = this._settings.get_boolean('intellihide')
if (_DEBUG_) global.log("... overview="+Main.overview.visible+" - "+Main.overview._shown+" ia="+intellihideAction+" oa="+overviewAction);
if (!force && !fixedPosition) {
if ((Main.overview._shown && overviewAction == OverviewAction.SHOW_PARTIAL)
|| (!Main.overview._shown && intellihide && (intellihideAction == IntellihideAction.SHOW_PARTIAL || intellihideAction == IntellihideAction.SHOW_PARTIAL_FIXED))) {
if (this._slider.partialSlideoutSize) {
if (_DEBUG_) global.log("... animateOut: partial="+this._slider.partialSlideoutSize);
let fullsize;
if (this._isHorizontal) {
fullsize = this._dock.height;
} else {
fullsize = this._dock.width;
}
if (this._settings.get_boolean('dock-edge-visible')) {
let triggerWidth = 1; // We need trigger width to always be set to 1
let slideoutSize = DOCK_EDGE_VISIBLE_WIDTH - triggerWidth;
sliderVariable = (this._slider.partialSlideoutSize - slideoutSize) / fullsize;
} else {
sliderVariable = this._slider.partialSlideoutSize / fullsize;
}
}
}
}
Tweener.addTween(this._slider, {
slidex: sliderVariable,
time: time,
delay: delay,
transition: 'easeOutQuad',
onComplete: Lang.bind(this, function() {
if (_DEBUG_) global.log("dockedWorkspaces: _animateOUT onComplete");
this._dockState = DockState.HIDDEN;
this._updateBarrier();
})
});
},
// autohide function to remove show-hide animations
_removeAnimations: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _removeAnimations");
Tweener.removeTweens(this._slider);
},
// autohide function to fade out opaque background
_fadeOutBackground: function(time, delay) {
if (_DEBUG_) global.log("dockedWorkspaces: _fadeOutBackground");
// CSS time is in ms
this._thumbnailsBox.actor.set_style('transition-duration:' + time*1000 + ';' +
'transition-delay:' + delay*1000 + ';' +
'background-color: rgba(0,0,0,0);' +
'border-color:' + this._defaultBorder);
this._shortcutsPanel.actor.set_style('transition-duration:' + time*1000 + ';' +
'transition-delay:' + delay*1000 + ';' +
'background-color: rgba(0,0,0,0);' +
'border-color:' + this._defaultBorder);
this._dockContainer.set_style('transition-duration:' + time*1000 + ';' +
'transition-delay:' + delay*1000 + ';' +
'background-color:' + this._defaultBackground + ';' +
'border-color:' + this._defaultBorder);
},
// autohide function to fade in opaque background
_fadeInBackground: function(time, delay) {
if (_DEBUG_) global.log("dockedWorkspaces: _fadeInBackground");
// CSS time is in ms
this._thumbnailsBox.actor.set_style('transition-duration:' + time*1000 + ';' +
'transition-delay:' + delay*1000 + ';' +
'background-color: rgba(0,0,0,0);' +
'border-color:' + this._customBorder);
this._shortcutsPanel.actor.set_style('transition-duration:' + time*1000 + ';' +
'transition-delay:' + delay*1000 + ';' +
'background-color: rgba(0,0,0,0);' +
'border-color:' + this._customBorder);
this._dockContainer.set_style('transition-duration:' + time*1000 + ';' +
'transition-delay:' + delay*1000 + ';' +
'background-color:' + this._customBackground + ';' +
'border-color:' + this._customBorder);
},
// This function handles hiding the dock when dock is in stationary-fixed
// position but overlapped by gnome panel menus or meta popup windows
fadeOutDock: function(time, delay) {
if (_DEBUG_) global.log("dockedWorkspaces: fadeOutDock");
if (Main.layoutManager._inOverview) {
// Hide fixed dock when in overviewmode applications view
this.actor.opacity = 0;
}
// Make thumbnail windowclones non-reactive
// NOTE: Need this for when in overviewmode applications view and dock is in fixed mode.
// Fixed dock has opacity set to 0 but is still reactive.
this._dock.reactive = false;
this._shortcutsPanel.setReactiveState(false);
this._thumbnailsBox.actor.reactive = false;
for (let i = 0; i < this._thumbnailsBox._thumbnails.length; i++) {
let thumbnail = this._thumbnailsBox._thumbnails[i];
thumbnail.setCaptionReactiveState(false);
thumbnail.setWindowClonesReactiveState(false);
}
},
// This function handles showing the dock when dock is stationary-fixed
// position but overlapped by gnome panel menus or meta popup windows
fadeInDock: function(time, delay) {
if (_DEBUG_) global.log("dockedWorkspaces: fadeInDock");
this.actor.opacity = 255;
// Return thumbnail windowclones to reactive state
this._dock.reactive = true;
this._shortcutsPanel.setReactiveState(true);
this._thumbnailsBox.actor.reactive = true;
for (let i = 0; i < this._thumbnailsBox._thumbnails.length; i++) {
let thumbnail = this._thumbnailsBox._thumbnails[i];
thumbnail.setCaptionReactiveState(true);
thumbnail.setWindowClonesReactiveState(true);
}
if (!this._workAreaHeight || !this._workAreaWidth) {
this._refreshThumbnailsOnRegionUpdate = true;
Main.layoutManager._queueUpdateRegions();
}
},
// retrieve default background color
_getBackgroundColor: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _getBackgroundColor");
// Remove custom style
let oldStyle = this._thumbnailsBox.actor.get_style();
this._thumbnailsBox.actor.set_style(null);
// Prevent shell crash if the actor is not on the stage
// It happens enabling/disabling repeatedly the extension
if (!this._thumbnailsBox.actor.get_stage())
return null;
let themeNode = this._thumbnailsBox.actor.get_theme_node();
this._thumbnailsBox.actor.set_style(oldStyle);
// Just in case the theme has different border colors ..
// We want to find the inside border-color of the dock because it is
// the side most visible to the user. We do this by finding the side
// opposite the position
let side = this._position + 2;
if (side > 3)
side = Math.abs(side - 4);
let backgroundColor = themeNode.get_background_color();
let borderColor = themeNode.get_border_color(side);
return [backgroundColor, borderColor];
},
_updateAppearancePreferences: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _updateAppearancePreferences");
this._updateStraightCorners();
this._updateBackgroundOpacity();
},
_updateStraightCorners: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _updateStraightCorners");
if (this._settings.get_boolean('straight-corners')) {
this._dock.add_style_class_name('straight-corners');
} else {
this._dock.remove_style_class_name('straight-corners');
}
},
// update background opacity based on preferences
_updateBackgroundOpacity: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _updateBackgroundOpacity");
let [backgroundColor, borderColor] = this._getBackgroundColor();
if (backgroundColor) {
// We check the background alpha for a minimum of .001 to prevent
// division by 0 errors when calculating borderAlpha later
let backgroundAlpha = Math.max(Math.round(backgroundColor.alpha/2.55)/100, .001);
let newAlpha = this._settings.get_double('background-opacity');
this._defaultBackground = "rgba(" + backgroundColor.red + "," + backgroundColor.green + "," + backgroundColor.blue + "," + backgroundAlpha + ")";
this._customBackground = "rgba(" + backgroundColor.red + "," + backgroundColor.green + "," + backgroundColor.blue + "," + newAlpha + ")";
if (borderColor) {
// The border and background alphas should remain in sync
// We also limit the borderAlpha to a maximum of 1 (full opacity)
let borderAlpha = Math.round(borderColor.alpha/2.55)/100;
borderAlpha = Math.min((borderAlpha/backgroundAlpha)*newAlpha, 1);
this._defaultBorder = "rgba(" + borderColor.red + "," + borderColor.green + "," + borderColor.blue + "," + Math.round(borderColor.alpha/2.55)/100 + ")";
this._customBorder = "rgba(" + borderColor.red + "," + borderColor.green + "," + borderColor.blue + "," + borderAlpha + ")";
}
if (this._settings.get_boolean('opaque-background')) {
this._fadeInBackground(this._settings.get_double('animation-time'), 0);
} else {
this._fadeOutBackground(this._settings.get_double('animation-time'), 0);
}
}
},
// handler for theme changes
_onThemeChanged: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onThemeChanged");
this._changeStylesheet();
if (!this._disableRedisplay)
this._updateAppearancePreferences();
},
// function to change stylesheets
_changeStylesheet: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _changeStylesheet");
// Get css filename
let filename = "workspaces-to-dock.css";
// Get new theme stylesheet
let themeStylesheet = Main._getDefaultStylesheet();
if (Main.getThemeStylesheet())
themeStylesheet = Main.getThemeStylesheet();
// Get theme directory
let themeDirectory = themeStylesheet.get_path() ? GLib.path_get_dirname(themeStylesheet.get_path()) : "";
// Test for workspacesToDock stylesheet
let newStylesheet = null;
if (themeDirectory != "")
newStylesheet = Gio.file_new_for_path(themeDirectory + '/extensions/workspaces-to-dock/' + filename);
if (_DEBUG_) global.log("dockedWorkspaces: _changeStylesheet - test newStylesheet");
if (!newStylesheet || !newStylesheet.query_exists(null)) {
if (_DEBUG_) global.log("dockedWorkspaces: _changeStylesheet - Theme doesn't support workspacesToDock .. use default stylesheet");
let defaultStylesheet = Gio.File.new_for_path(Me.path + "/themes/default/" + filename);
if (defaultStylesheet.query_exists(null)) {
newStylesheet = defaultStylesheet;
} else {
throw new Error(_("No Workspaces-To-Dock stylesheet found") + " (extension.js).");
}
}
if (Extension.workspacesToDockStylesheet && Extension.workspacesToDockStylesheet.equal(newStylesheet)) {
if (_DEBUG_) global.log("dockedWorkspaces: _changeStylesheet - No change in stylesheet. Exit");
return false;
}
// Change workspacesToDock stylesheet by updating theme
let themeContext = St.ThemeContext.get_for_stage(global.stage);
if (!themeContext)
return false;
if (_DEBUG_) global.log("dockedWorkspaces: _changeStylesheet - themeContext is valid");
let theme = themeContext.get_theme();
if (!theme)
return false;
if (_DEBUG_) global.log("dockedWorkspaces: _changeStylesheet - theme is valid");
let customStylesheets = theme.get_custom_stylesheets();
if (!customStylesheets)
return false;
let previousStylesheet = Extension.workspacesToDockStylesheet;
Extension.workspacesToDockStylesheet = newStylesheet;
// let newTheme = new St.Theme ({ application_stylesheet: themeStylesheet,
// default_stylesheet: Main._defaultCssStylesheet });
let newTheme = new St.Theme ({ application_stylesheet: themeStylesheet });
for (let i = 0; i < customStylesheets.length; i++) {
if (!customStylesheets[i].equal(previousStylesheet)) {
newTheme.load_stylesheet(customStylesheets[i]);
}
}
if (_DEBUG_) global.log("dockedWorkspaces: _changeStylesheet - Removed previous stylesheet");
newTheme.load_stylesheet(Extension.workspacesToDockStylesheet);
if (_DEBUG_) global.log("dockedWorkspaces: _changeStylesheet - Added new stylesheet");
themeContext.set_theme (newTheme);
if (!this._disableRedisplay) {
this._refreshThumbnails();
}
return true;
},
// handler for icon changes
_onIconsChanged: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onIconsChanged");
if (this._disableRedisplay)
return
this._refreshThumbnails();
},
// resdiplay dock called if size-position changed due to dock resizing
_redisplay: function() {
if (this._disableRedisplay)
return
if (_DEBUG_) global.log("dockedWorkspaces: _redisplay autohide-dodge="+this._autohideStatus);
// Initial display of dock .. sets autohideStatus
if (this._autohideStatus == null) {
if (this._settings.get_boolean('dock-fixed')) {
this._autohideStatus = false;
this.fadeInDock(this._settings.get_double('animation-time'), 0);
} else {
// Initial animation is out .. intellihide will animate in if its needed
this._removeAnimations();
this._animateOut(0, 0);
this._autohideStatus = true;
}
} else {
// Redisplay dock by animating back in .. necessary if thumbnailsBox size changed
// even if dock is fixed
if (this._autohideStatus) {
if (!this._isHovering() && !(this._hoveringDash && !Main.overview._shown)) {
this._removeAnimations();
this._animateOut(0, 0, true);
}
this._autohideStatus = true;
} else {
if (!this._isHovering() && !(this._hoveringDash && !Main.overview._shown)) {
// had to comment out because GS3.4 fixed-dock isn't fully faded in yet when redisplay occurs again
//this._removeAnimations();
this._animateIn(this._settings.get_double('animation-time'), 0);
}
this._autohideStatus = false;
}
}
this._updateAppearancePreferences();
this._updateBarrier();
},
// update the dock size and position
_updateSize: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _updateSize");
// Accommodate shortcuts panel in calculations
let shortcutsPanelThickness = 0;
if (this._settings.get_boolean('show-shortcuts-panel')) {
if (this._isHorizontal) {
shortcutsPanelThickness = this._shortcutsPanel.actor.height;
} else {
shortcutsPanelThickness = this._shortcutsPanel.actor.width;
}
}
// Get workspace area
// This takes into account primary monitor and any additional extensions
// that may affect width and height calculations
let workArea = Main.layoutManager.getWorkAreaForMonitor(this._monitor.index);
// get the scale factor
let scale_factor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
// Get screen edge padding from preferences and multiply it by scale_factor for HiDPI monitors
let screenEdgePadding = this._settings.get_double('screen-edge-padding') * scale_factor;
let x, y, width, height, anchorPoint;
if (this._isHorizontal) {
// Get x position and width
if (this._settings.get_boolean('customize-height')) {
let leftMargin = Math.floor(this._settings.get_double('top-margin') * this._monitor.width);
let rightMargin = Math.floor(this._settings.get_double('bottom-margin') * this._monitor.width);
x = workArea.x + leftMargin;
width = workArea.width - leftMargin - rightMargin;
} else {
let margin = this._monitor.width * .1;
x = this._monitor.x + margin;
width = this._monitor.width - (margin * 2);
}
// Get y position, height, and anchorpoint
height = this._thumbnailsBox._thumbnailsBoxHeight + shortcutsPanelThickness + screenEdgePadding;
if (this._position == St.Side.TOP) {
y = this._monitor.y;
anchorPoint = Clutter.Gravity.NORTH_WEST;
} else {
y = this._monitor.y + this._monitor.height;
anchorPoint = Clutter.Gravity.SOUTH_WEST;
}
} else {
// Get x position, width, and anchorpoint
width = this._thumbnailsBox._thumbnailsBoxWidth + shortcutsPanelThickness + screenEdgePadding;
if (this._position == St.Side.LEFT) {
x = this._monitor.x;
anchorPoint = Clutter.Gravity.NORTH_WEST;
} else {
x = this._monitor.x + this._monitor.width;
anchorPoint = Clutter.Gravity.NORTH_EAST;
}
// Get y position and height
if (this._settings.get_boolean('customize-height')) {
let topMargin = Math.floor(this._settings.get_double('top-margin') * this._monitor.height);
let bottomMargin = Math.floor(this._settings.get_double('bottom-margin') * this._monitor.height);
y = workArea.y + topMargin;
height = workArea.height - topMargin - bottomMargin;
} else {
let controlsTop = 45;
y = this._monitor.y + Main.panel.actor.height + controlsTop + Main.overview._searchEntryBin.height;
height = this._monitor.height - (y + Main.overview._searchEntryBin.height);
}
}
//// skip updating if size is same ??
//if ((this.actor.y == y) && (this.actor.width == this._thumbnailsBox._thumbnailsBoxWidth + shortcutsPanelThickness) && (this.actor.height == height)) {
//return;
//}
// Update position of main actor (used to detect window overlaps)
this.actor.set_position(x, y);
this._struts.set_position(x, y);
if (_DEBUG_) global.log("dockedWorkspaces: _updateSize new x = "+x+" y = "+y);
// Update size of the main actor as well as the _dock & _panels inside
// NOTE: Rather than rely on the builtin box layout mechanics, we control
// both width and height based on the thumbnail & shortcuts panels. This
// allows us to control the trigger space for showing/hiding and scrolling
if (this._isHorizontal) {
if (this._settings.get_boolean('customize-height')) {
let [minThumbnailsBoxWidth, minThumbnailsBoxHeight, natThumbnailsBoxWidth, natThumbnailsBoxHeight] = this._thumbnailsBox.actor.get_preferred_size();
let minShortcutsPanelWidth = 0, minShortcutsPanelHeight = 0, natShortcutsPanelWidth = 0, natShortcutsPanelHeight = 0;
if (this._settings.get_boolean('show-shortcuts-panel')) {
[minShortcutsPanelWidth, minShortcutsPanelHeight, natShortcutsPanelWidth, natShortcutsPanelHeight] = this._shortcutsPanel.actor.get_preferred_size();
}
let containerWidth = natThumbnailsBoxWidth > natShortcutsPanelWidth ? natThumbnailsBoxWidth : natShortcutsPanelWidth;
if (containerWidth > width) {
containerWidth = width;
}
this._panelsContainer.set_size(containerWidth, height);
this._panels.set_size(containerWidth, height);
if (this._extendContainer) {
this._dockContainer.set_size(width, height);
this._dock.set_size(width, height + this._triggerWidth);
this.actor.set_size(width, height + this._triggerWidth);
} else {
this._dockContainer.set_size(containerWidth, height);
this._dock.set_size(containerWidth, height + this._triggerWidth);
this.actor.set_size(containerWidth, height + this._triggerWidth);
if (this._centerContainer) {
if (width > containerWidth) {
let xMiddle = x + Math.round((width - containerWidth) / 2);
this.actor.set_position(xMiddle, y);
}
}
}
} else {
this._panelsContainer.set_size(width, height);
this._panels.set_size(width, height);
this._dockContainer.set_size(width, height);
this._dock.set_size(width, height + this._triggerWidth);
this.actor.set_size(width, height + this._triggerWidth);
}
} else {
if (this._settings.get_boolean('customize-height')) {
let [minThumbnailsBoxWidth, minThumbnailsBoxHeight, natThumbnailsBoxWidth, natThumbnailsBoxHeight] = this._thumbnailsBox.actor.get_preferred_size();
let minShortcutsPanelWidth = 0, minShortcutsPanelHeight = 0, natShortcutsPanelWidth = 0, natShortcutsPanelHeight = 0;
if (this._settings.get_boolean('show-shortcuts-panel')) {
[minShortcutsPanelWidth, minShortcutsPanelHeight, natShortcutsPanelWidth, natShortcutsPanelHeight] = this._shortcutsPanel.actor.get_preferred_size();
}
let containerHeight = natThumbnailsBoxHeight > natShortcutsPanelHeight ? natThumbnailsBoxHeight : natShortcutsPanelHeight;
if (containerHeight > height) {
containerHeight = height;
}
this._panelsContainer.set_size(width, containerHeight);
this._panels.set_size(width, containerHeight);
if (this._extendContainer) {
this._dockContainer.set_size(width, height);
this._dock.set_size(width + this._triggerWidth, height);
this.actor.set_size(width + this._triggerWidth, height);
} else {
this._dockContainer.set_size(width, containerHeight);
this._dock.set_size(width + this._triggerWidth, containerHeight);
this.actor.set_size(width + this._triggerWidth, containerHeight);
if (this._centerContainer) {
if (height > containerHeight) {
let yMiddle = y + Math.round((height - containerHeight) / 2);
this.actor.set_position(x, yMiddle);
}
}
}
} else {
this._panelsContainer.set_size(width, height);
this._panels.set_size(width, height);
this._dockContainer.set_size(width, height);
this._dock.set_size(width + this._triggerWidth, height);
this.actor.set_size(width + this._triggerWidth, height);
}
}
// Set anchor points
this.actor.move_anchor_point_from_gravity(anchorPoint);
this._struts.move_anchor_point_from_gravity(anchorPoint);
// Update slider slideout width
let slideoutSize = this._settings.get_boolean('dock-edge-visible') ? this._triggerWidth + DOCK_EDGE_VISIBLE_WIDTH : this._triggerWidth;
this._slider.slideoutSize = slideoutSize;
// Update slider partial width
// NOTE: only effects slider width when dock is set to partially hide in overview
let slidePartialVisibleWidth = this._triggerWidth + DOCK_EDGE_VISIBLE_OVERVIEW_WIDTH;
if (this._settings.get_boolean('show-shortcuts-panel')
&& this._settings.get_enum('shortcuts-panel-orientation') == 1) {
if (this._isHorizontal) {
slidePartialVisibleWidth = this._shortcutsPanel.actor.height;
} else {
slidePartialVisibleWidth = this._shortcutsPanel.actor.width;
}
} else {
// NOTE: Gnome css top panel height is 1.86em
if (this._settings.get_boolean('customize-thumbnail-visible-width')) {
slidePartialVisibleWidth = this._settings.get_double('thumbnail-visible-width');
} else {
let themeVisibleWidth = this._thumbnailsBox.actor.get_theme_node().get_length('visible-width');
if (themeVisibleWidth > 0)
slidePartialVisibleWidth = themeVisibleWidth;
}
}
this._slider.partialSlideoutSize = slidePartialVisibleWidth;
// Set struts size
if (!this._settings.get_boolean('dock-fixed')
&& (this._settings.get_boolean('intellihide') && this._settings.get_enum('intellihide-action') == IntellihideAction.SHOW_PARTIAL_FIXED)) {
if (this._isHorizontal) {
this._struts.set_size(width, slidePartialVisibleWidth);
} else {
this._struts.set_size(slidePartialVisibleWidth, height);
}
} else {
this._struts.set_size(this.actor.width, this.actor.height);
}
},
// 'Hard' reset dock positon: called on start and when monitor changes
_resetPosition: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _resetPosition");
this._monitor = this._getMonitor();
this._updateSize();
this._updateAppearancePreferences();
this._updateBarrier();
},
_onMonitorsChanged: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _onMonitorsChanged");
// Reset the dock position and redisplay
this._resetPosition();
this._redisplay();
this._refreshThumbnailsOnRegionUpdate = true;
Main.layoutManager._queueUpdateRegions();
},
_refreshThumbnails: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _refreshThumbnails");
let workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
this._workAreaWidth = workArea.width;
this._workAreaHeight = workArea.height;
if (this._thumbnailsBox) {
this._thumbnailsBox._destroyThumbnails();
this._thumbnailsBox._createThumbnails();
}
// NOTE: restarting Gnome Shell with the dock height extended leaves the top of the dock hidden
// under the shell's top bar. Resetting the position after a thumbnail refresh (during Region Updates)
// fixes this issue.
this._resetPosition();
},
// Retrieve the preferred monitor
_getMonitor: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _getMonitor");
// We are using Gdk in settings prefs which sets the primary monitor to 0
// The shell can assign a different number (Main.layoutManager.primaryMonitor)
// This ensures that the indexing in the settings (Gdk) and in the shell are matched,
// i.e. that we start counting from the primaryMonitorIndex
let preferredMonitorIndex = this._settings.get_int('preferred-monitor');
let monitorIndex = (Main.layoutManager.primaryIndex + preferredMonitorIndex) % Main.layoutManager.monitors.length ;
let monitor = Main.layoutManager.monitors[monitorIndex];
return monitor;
},
// Remove pressure barrier (GS38+ only)
_removeBarrier: function() {
if (_DEBUG_) global.log("dockedWorkspaces: _removeBarrier");
if (this._barrier) {
if (this._pressureBarrier) {
this._pressureBarrier.removeBarrier(this._barrier);
if (_DEBUG_) global.log("... removing barrier from pressureBarrier object");
}
this._barrier.destroy();
this._barrier = null;
}
// Remove barrier timeout
if (this._removeBarrierTimeoutId > 0) {
Mainloop.source_remove(this._removeBarrierTimeoutId);
this._removeBarrierTimeoutId = 0;
}
return false;
},
// Update pressure barrier size (GS38+ only)
_updateBarrier: function() {
// Remove existing barrier
this._removeBarrier();
// Manually reset pressure barrier
// This is necessary because we remove the pressure barrier when it is triggered to show the dock
if (this._pressureBarrier) {
this._pressureBarrier._reset();
this._pressureBarrier._isTriggered = false;
}
// Create new barrier
// Note: dock in fixed possition doesn't use pressure barrier
if (_DEBUG_) global.log("dockedWorkspaces: _updateBarrier");
if (this.actor.visible && this._canUsePressure && this._settings.get_boolean('autohide')
&& this._settings.get_boolean('require-pressure-to-show')
&& !this._settings.get_boolean('dock-fixed')) {
let x1, x2, y1, y2, direction;
if(this._position==St.Side.LEFT){
x1 = this._monitor.x;
x2 = this._monitor.x;
y1 = this.actor.y;
y2 = this.actor.y + this.actor.height;
direction = Meta.BarrierDirection.POSITIVE_X;
} else if(this._position==St.Side.RIGHT) {
x1 = this._monitor.x + this._monitor.width;
x2 = this._monitor.x + this._monitor.width;
y1 = this.actor.y;
y2 = this.actor.y + this.actor.height;
direction = Meta.BarrierDirection.NEGATIVE_X;
} else if(this._position==St.Side.TOP) {
let hotCornerPadding = 1;
x1 = this.actor.x + hotCornerPadding;
x2 = this.actor.x + hotCornerPadding + this.actor.width;
y1 = this._monitor.y;
y2 = this._monitor.y;
direction = Meta.BarrierDirection.POSITIVE_Y;
} else if (this._position==St.Side.BOTTOM) {
x1 = this.actor.x;
x2 = this.actor.x + this.actor.width;
y1 = this._monitor.y + this._monitor.height;
y2 = this._monitor.y + this._monitor.height;
direction = Meta.BarrierDirection.NEGATIVE_Y;
}
if (_DEBUG_) global.log("... creating barrier");
this._barrier = new Meta.Barrier({display: global.display,
x1: x1, x2: x2,
y1: y1, y2: y2,
directions: direction});
if (this._pressureBarrier) {
if (_DEBUG_) global.log("... adding barrier to pressureBarrier object");
this._pressureBarrier.addBarrier(this._barrier);
}
}
// Reset pressureSensed flag
if (!this._isHovering() && this._dockState != DockState.SHOWN) {
if (_DEBUG_) global.log("... pressureSensed flag reset");
this._pressureSensed = false;
this._updateTriggerWidth();
}
},
// Disable autohide effect, thus show workspaces
disableAutoHide: function(force) {
if (_DEBUG_) global.log("dockedWorkspaces: disableAutoHide - autohideStatus = "+this._autohideStatus+" dockState = "+getDockStateDesc(this._dockState));
// NOTE: default functionality is to not force complete animateIn
this._autohideStatus = false;
if (this._dockState == DockState.HIDING || this._dockState == DockState.HIDDEN) {
this._removeAnimations();
if (force) {
this._animateIn(this._settings.get_double('animation-time'), 0, true);
} else {
this._animateIn(this._settings.get_double('animation-time'), 0);
}
}
},
// Enable autohide effect, hide workspaces
enableAutoHide: function(dontforce) {
if (_DEBUG_) global.log("dockedWorkspaces: enableAutoHide - autohideStatus = "+this._autohideStatus);
// NOTE: default functionality is to force complete animateOut
// autohide status shouldn't change if not completely animating out
if (dontforce) {
this._autohideStatus = false;
} else {
this._autohideStatus = true;
}
if (this._isHovering()) {
this._dock.sync_hover();
}
let delay = 0; // immediately fadein background if hide is blocked by mouseover, otherwise start fadein when dock is already hidden.
if (this._settings.get_boolean('autohide')) {
if (_DEBUG_) global.log("dockedWorkspaces: enableAutoHide - autohide settings true");
if (!this._isHovering() && !(this._hoveringDash && !Main.overview._shown)) {
if (_DEBUG_) global.log("dockedWorkspaces: enableAutoHide - mouse not hovering OR dock not using autohide, so animate out");
this._removeAnimations();
if (dontforce) {
this._animateOut(this._settings.get_double('animation-time'), 0, false);
} else {
if (Main.overview._shown && Main.overview.viewSelector._activePage == Main.overview.viewSelector._workspacesPage) {
this._animateOut(this._settings.get_double('animation-time'), 0, false);
} else {
this._animateOut(this._settings.get_double('animation-time'), 0, true);
}
}
delay = this._settings.get_double('animation-time');
}
} else {
if (_DEBUG_) global.log("dockedWorkspaces: enableAutoHide - autohide off so animate out");
this._removeAnimations();
if (dontforce) {
this._animateOut(this._settings.get_double('animation-time'), 0, false);
} else {
if (Main.overview._shown && Main.overview.viewSelector._activePage == Main.overview.viewSelector._workspacesPage) {
this._animateOut(this._settings.get_double('animation-time'), 0, false);
} else {
this._animateOut(this._settings.get_double('animation-time'), 0, true);
}
}
delay = this._settings.get_double('animation-time');
}
}
});
Signals.addSignalMethods(DockedWorkspaces.prototype);
|