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
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "GUIWindowManager.h"
#include "GUIAudioManager.h"
#include "GUIDialog.h"
#include "GUIInfoManager.h"
#include "GUIPassword.h"
#include "GUITexture.h"
#include "ServiceBroker.h"
#include "WindowIDs.h"
#include "addons/Skin.h"
#include "addons/gui/GUIWindowAddonBrowser.h"
#include "addons/interfaces/gui/Window.h"
#include "application/Application.h"
#include "application/ApplicationComponents.h"
#include "application/ApplicationPlayer.h"
#include "events/windows/GUIWindowEventLog.h"
#include "favourites/GUIWindowFavourites.h"
#include "input/actions/Action.h"
#include "input/actions/ActionIDs.h"
#include "messaging/ApplicationMessenger.h"
#include "messaging/helpers/DialogHelper.h"
#include "music/dialogs/GUIDialogInfoProviderSettings.h"
#include "music/dialogs/GUIDialogMusicInfo.h"
#include "music/windows/GUIWindowMusicNav.h"
#include "music/windows/GUIWindowMusicPlaylist.h"
#include "music/windows/GUIWindowMusicPlaylistEditor.h"
#include "music/windows/GUIWindowVisualisation.h"
#include "pictures/GUIWindowPictures.h"
#include "pictures/GUIWindowSlideShow.h"
#include "profiles/windows/GUIWindowSettingsProfile.h"
#include "programs/GUIWindowPrograms.h"
#include "settings/AdvancedSettings.h"
#include "settings/SettingsComponent.h"
#include "settings/windows/GUIWindowSettings.h"
#include "settings/windows/GUIWindowSettingsCategory.h"
#include "settings/windows/GUIWindowSettingsScreenCalibration.h"
#include "threads/SingleLock.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/Variant.h"
#include "utils/log.h"
#include "video/dialogs/GUIDialogVideoInfo.h"
#include "video/dialogs/GUIDialogVideoManagerExtras.h"
#include "video/dialogs/GUIDialogVideoManagerVersions.h"
#include "video/dialogs/GUIDialogVideoOSD.h"
#include "video/windows/GUIWindowFullScreen.h"
#include "video/windows/GUIWindowVideoNav.h"
#include "video/windows/GUIWindowVideoPlaylist.h"
#include "weather/GUIWindowWeather.h"
#include "windows/GUIWindowDebugInfo.h"
#include "windows/GUIWindowFileManager.h"
#include "windows/GUIWindowHome.h"
#include "windows/GUIWindowLoginScreen.h"
#include "windows/GUIWindowPointer.h"
#include "windows/GUIWindowScreensaver.h"
#include "windows/GUIWindowScreensaverDim.h"
#include "windows/GUIWindowSplash.h"
#include "windows/GUIWindowStartup.h"
#include "windows/GUIWindowSystemInfo.h"
#include <mutex>
// Dialog includes
#include "music/dialogs/GUIDialogMusicOSD.h"
#include "music/dialogs/GUIDialogVisualisationPresetList.h"
#include "dialogs/GUIDialogTextViewer.h"
#include "network/GUIDialogNetworkSetup.h"
#include "dialogs/GUIDialogMediaSource.h"
#if defined(HAS_GL) || defined(HAS_DX)
#include "video/dialogs/GUIDialogCMSSettings.h"
#endif
#include "addons/gui/GUIDialogAddonInfo.h"
#include "addons/gui/GUIDialogAddonSettings.h"
#include "dialogs/GUIDialogBusy.h"
#include "dialogs/GUIDialogBusyNoCancel.h"
#include "dialogs/GUIDialogButtonMenu.h"
#include "dialogs/GUIDialogColorPicker.h"
#include "dialogs/GUIDialogContextMenu.h"
#include "dialogs/GUIDialogExtendedProgressBar.h"
#include "dialogs/GUIDialogGamepad.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "dialogs/GUIDialogKeyboardGeneric.h"
#include "dialogs/GUIDialogKeyboardTouch.h"
#include "dialogs/GUIDialogNumeric.h"
#include "dialogs/GUIDialogOK.h"
#include "dialogs/GUIDialogPlayerControls.h"
#include "dialogs/GUIDialogPlayerProcessInfo.h"
#include "dialogs/GUIDialogProgress.h"
#include "dialogs/GUIDialogSeekBar.h"
#include "dialogs/GUIDialogSelect.h"
#include "dialogs/GUIDialogSmartPlaylistEditor.h"
#include "dialogs/GUIDialogSmartPlaylistRule.h"
#include "dialogs/GUIDialogSubMenu.h"
#include "dialogs/GUIDialogVolumeBar.h"
#include "dialogs/GUIDialogYesNo.h"
#include "music/dialogs/GUIDialogSongInfo.h"
#include "pictures/GUIDialogPictureInfo.h"
#include "profiles/dialogs/GUIDialogLockSettings.h"
#include "profiles/dialogs/GUIDialogProfileSettings.h"
#include "settings/dialogs/GUIDialogContentSettings.h"
#include "settings/dialogs/GUIDialogLibExportSettings.h"
#include "video/dialogs/GUIDialogAudioSettings.h"
#include "video/dialogs/GUIDialogSubtitleSettings.h"
#include "video/dialogs/GUIDialogVideoBookmarks.h"
#include "video/dialogs/GUIDialogVideoSettings.h"
/* PVR related include Files */
#include "pvr/dialogs/GUIDialogPVRChannelGuide.h"
#include "pvr/dialogs/GUIDialogPVRChannelManager.h"
#include "pvr/dialogs/GUIDialogPVRChannelsOSD.h"
#include "pvr/dialogs/GUIDialogPVRClientPriorities.h"
#include "pvr/dialogs/GUIDialogPVRGroupManager.h"
#include "pvr/dialogs/GUIDialogPVRGuideControls.h"
#include "pvr/dialogs/GUIDialogPVRGuideInfo.h"
#include "pvr/dialogs/GUIDialogPVRGuideSearch.h"
#include "pvr/dialogs/GUIDialogPVRRadioRDSInfo.h"
#include "pvr/dialogs/GUIDialogPVRRecordingInfo.h"
#include "pvr/dialogs/GUIDialogPVRRecordingSettings.h"
#include "pvr/dialogs/GUIDialogPVRTimerSettings.h"
#include "pvr/windows/GUIWindowPVRChannels.h"
#include "pvr/windows/GUIWindowPVRGuide.h"
#include "pvr/windows/GUIWindowPVRRecordings.h"
#include "pvr/windows/GUIWindowPVRSearch.h"
#include "pvr/windows/GUIWindowPVRTimerRules.h"
#include "pvr/windows/GUIWindowPVRTimers.h"
#include "video/dialogs/GUIDialogTeletext.h"
#include "dialogs/GUIDialogSlider.h"
#ifdef HAS_OPTICAL_DRIVE
#include "dialogs/GUIDialogPlayEject.h"
#endif
#include "dialogs/GUIDialogMediaFilter.h"
#include "video/dialogs/GUIDialogSubtitles.h"
#include "peripherals/dialogs/GUIDialogPeripherals.h"
#include "peripherals/dialogs/GUIDialogPeripheralSettings.h"
/* Game related include files */
#include "cores/RetroPlayer/guiwindows/GameWindowFullScreen.h"
#include "games/agents/windows/GUIAgentWindow.h"
#include "games/controllers/windows/GUIControllerWindow.h"
#include "games/dialogs/osd/DialogGameAdvancedSettings.h"
#include "games/dialogs/osd/DialogGameOSD.h"
#include "games/dialogs/osd/DialogGameSaves.h"
#include "games/dialogs/osd/DialogGameStretchMode.h"
#include "games/dialogs/osd/DialogGameVideoFilter.h"
#include "games/dialogs/osd/DialogGameVideoRotation.h"
#include "games/dialogs/osd/DialogGameVolume.h"
#include "games/dialogs/osd/DialogInGameSaves.h"
#include "games/ports/windows/GUIPortWindow.h"
#include "games/windows/GUIWindowGames.h"
using namespace KODI;
using namespace PVR;
using namespace PERIPHERALS;
CGUIWindowManager::CGUIWindowManager()
{
m_pCallback = nullptr;
m_iNested = 0;
m_initialized = false;
}
CGUIWindowManager::~CGUIWindowManager() = default;
void CGUIWindowManager::Initialize()
{
m_tracker.SelectAlgorithm();
m_initialized = true;
LoadNotOnDemandWindows();
CServiceBroker::GetAppMessenger()->RegisterReceiver(this);
}
void CGUIWindowManager::CreateWindows()
{
Add(new CGUIWindowHome);
Add(new CGUIWindowPrograms);
Add(new CGUIWindowPictures);
Add(new CGUIWindowFileManager);
Add(new CGUIWindowSettings);
Add(new CGUIWindowSystemInfo);
Add(new CGUIWindowSettingsScreenCalibration);
Add(new CGUIWindowSettingsCategory);
Add(new CGUIWindowVideoNav);
Add(new CGUIWindowVideoPlaylist);
Add(new CGUIWindowLoginScreen);
Add(new CGUIWindowSettingsProfile);
Add(new CGUIWindow(WINDOW_SKIN_SETTINGS, "SkinSettings.xml"));
Add(new CGUIWindowAddonBrowser);
Add(new CGUIWindowScreensaverDim);
Add(new CGUIWindowDebugInfo);
Add(new CGUIWindowPointer);
Add(new CGUIDialogYesNo);
Add(new CGUIDialogProgress);
Add(new CGUIDialogExtendedProgressBar);
Add(new CGUIDialogKeyboardGeneric);
Add(new CGUIDialogKeyboardTouch);
Add(new CGUIDialogVolumeBar);
Add(new CGUIDialogSeekBar);
Add(new CGUIDialogSubMenu);
Add(new CGUIDialogContextMenu);
Add(new CGUIDialogKaiToast);
Add(new CGUIDialogNumeric);
Add(new CGUIDialogGamepad);
Add(new CGUIDialogButtonMenu);
Add(new CGUIDialogPlayerControls);
Add(new CGUIDialogPlayerProcessInfo);
Add(new CGUIDialogSlider);
Add(new CGUIDialogMusicOSD);
Add(new CGUIDialogVisualisationPresetList);
#if defined(HAS_GL) || defined(HAS_DX)
Add(new CGUIDialogCMSSettings);
#endif
Add(new CGUIDialogVideoSettings);
Add(new CGUIDialogAudioSettings);
Add(new CGUIDialogSubtitleSettings);
Add(new CGUIDialogVideoBookmarks);
// Don't add the filebrowser dialog - it's created and added when it's needed
Add(new CGUIDialogNetworkSetup);
Add(new CGUIDialogMediaSource);
Add(new CGUIDialogProfileSettings);
Add(new CGUIDialogSongInfo);
Add(new CGUIDialogSmartPlaylistEditor);
Add(new CGUIDialogSmartPlaylistRule);
Add(new CGUIDialogBusy);
Add(new CGUIDialogBusyNoCancel);
Add(new CGUIDialogPictureInfo);
Add(new CGUIDialogAddonInfo);
Add(new CGUIDialogAddonSettings);
Add(new CGUIDialogLockSettings);
Add(new CGUIDialogContentSettings);
Add(new CGUIDialogLibExportSettings);
Add(new CGUIDialogInfoProviderSettings);
#ifdef HAS_OPTICAL_DRIVE
Add(new CGUIDialogPlayEject);
#endif
Add(new CGUIDialogPeripherals);
Add(new CGUIDialogPeripheralSettings);
Add(new CGUIDialogMediaFilter);
Add(new CGUIDialogSubtitles);
Add(new CGUIWindowMusicPlayList);
Add(new CGUIWindowMusicNav);
Add(new CGUIWindowMusicPlaylistEditor);
/* Load PVR related Windows and Dialogs */
Add(new CGUIDialogTeletext);
Add(new CGUIWindowPVRTVChannels);
Add(new CGUIWindowPVRTVRecordings);
Add(new CGUIWindowPVRTVGuide);
Add(new CGUIWindowPVRTVTimers);
Add(new CGUIWindowPVRTVTimerRules);
Add(new CGUIWindowPVRTVSearch);
Add(new CGUIWindowPVRRadioChannels);
Add(new CGUIWindowPVRRadioRecordings);
Add(new CGUIWindowPVRRadioGuide);
Add(new CGUIWindowPVRRadioTimers);
Add(new CGUIWindowPVRRadioTimerRules);
Add(new CGUIWindowPVRRadioSearch);
Add(new CGUIDialogPVRRadioRDSInfo);
Add(new CGUIDialogPVRGuideInfo);
Add(new CGUIDialogPVRRecordingInfo);
Add(new CGUIDialogPVRTimerSettings);
Add(new CGUIDialogPVRGroupManager);
Add(new CGUIDialogPVRChannelManager);
Add(new CGUIDialogPVRGuideSearch);
Add(new CGUIDialogPVRChannelsOSD);
Add(new CGUIDialogPVRChannelGuide);
Add(new CGUIDialogPVRRecordingSettings);
Add(new CGUIDialogPVRClientPriorities);
Add(new CGUIDialogPVRGuideControls);
Add(new CGUIDialogSelect);
Add(new CGUIDialogColorPicker);
Add(new CGUIDialogMusicInfo);
Add(new CGUIDialogOK);
Add(new CGUIDialogVideoInfo);
Add(new CGUIDialogVideoManagerVersions);
Add(new CGUIDialogVideoManagerExtras);
Add(new CGUIDialogSelect(WINDOW_DIALOG_SELECT_VIDEO_VERSION));
Add(new CGUIDialogSelect(WINDOW_DIALOG_SELECT_VIDEO_EXTRA));
Add(new CGUIDialogTextViewer);
Add(new CGUIWindowFullScreen);
Add(new CGUIWindowVisualisation);
Add(new CGUIWindowSlideShow);
Add(new CGUIDialogVideoOSD);
Add(new CGUIWindowScreensaver);
Add(new CGUIWindowWeather);
Add(new CGUIWindowStartup);
Add(new CGUIWindowSplash);
Add(new CGUIWindowEventLog);
Add(new CGUIWindowFavourites);
Add(new GAME::CGUIControllerWindow);
Add(new GAME::CGUIPortWindow);
Add(new GAME::CGUIWindowGames);
Add(new GAME::CDialogGameOSD);
Add(new GAME::CDialogGameSaves);
Add(new GAME::CDialogGameVideoFilter);
Add(new GAME::CDialogGameStretchMode);
Add(new GAME::CDialogGameVolume);
Add(new GAME::CDialogGameAdvancedSettings);
Add(new GAME::CDialogGameVideoRotation);
Add(new GAME::CDialogInGameSaves);
Add(new GAME::CGUIAgentWindow);
Add(new RETRO::CGameWindowFullScreen);
}
bool CGUIWindowManager::DestroyWindows()
{
try
{
DestroyWindow(WINDOW_SPLASH);
DestroyWindow(WINDOW_MUSIC_PLAYLIST);
DestroyWindow(WINDOW_MUSIC_PLAYLIST_EDITOR);
DestroyWindow(WINDOW_MUSIC_NAV);
DestroyWindow(WINDOW_DIALOG_MUSIC_INFO);
DestroyWindow(WINDOW_DIALOG_VIDEO_INFO);
DestroyWindow(WINDOW_DIALOG_SELECT_VIDEO_EXTRA);
DestroyWindow(WINDOW_DIALOG_SELECT_VIDEO_VERSION);
DestroyWindow(WINDOW_DIALOG_MANAGE_VIDEO_EXTRAS);
DestroyWindow(WINDOW_DIALOG_MANAGE_VIDEO_VERSIONS);
DestroyWindow(WINDOW_VIDEO_PLAYLIST);
DestroyWindow(WINDOW_VIDEO_NAV);
DestroyWindow(WINDOW_FILES);
DestroyWindow(WINDOW_DIALOG_YES_NO);
DestroyWindow(WINDOW_DIALOG_PROGRESS);
DestroyWindow(WINDOW_DIALOG_NUMERIC);
DestroyWindow(WINDOW_DIALOG_GAMEPAD);
DestroyWindow(WINDOW_DIALOG_SUB_MENU);
DestroyWindow(WINDOW_DIALOG_BUTTON_MENU);
DestroyWindow(WINDOW_DIALOG_CONTEXT_MENU);
DestroyWindow(WINDOW_DIALOG_PLAYER_CONTROLS);
DestroyWindow(WINDOW_DIALOG_PLAYER_PROCESS_INFO);
DestroyWindow(WINDOW_DIALOG_MUSIC_OSD);
DestroyWindow(WINDOW_DIALOG_VIS_PRESET_LIST);
DestroyWindow(WINDOW_DIALOG_SELECT);
DestroyWindow(WINDOW_DIALOG_OK);
DestroyWindow(WINDOW_DIALOG_KEYBOARD);
DestroyWindow(WINDOW_DIALOG_KEYBOARD_TOUCH);
DestroyWindow(WINDOW_FULLSCREEN_VIDEO);
DestroyWindow(WINDOW_DIALOG_PROFILE_SETTINGS);
DestroyWindow(WINDOW_DIALOG_LOCK_SETTINGS);
DestroyWindow(WINDOW_DIALOG_NETWORK_SETUP);
DestroyWindow(WINDOW_DIALOG_MEDIA_SOURCE);
DestroyWindow(WINDOW_DIALOG_CMS_OSD_SETTINGS);
DestroyWindow(WINDOW_DIALOG_VIDEO_OSD_SETTINGS);
DestroyWindow(WINDOW_DIALOG_AUDIO_OSD_SETTINGS);
DestroyWindow(WINDOW_DIALOG_SUBTITLE_OSD_SETTINGS);
DestroyWindow(WINDOW_DIALOG_VIDEO_BOOKMARKS);
DestroyWindow(WINDOW_DIALOG_CONTENT_SETTINGS);
DestroyWindow(WINDOW_DIALOG_INFOPROVIDER_SETTINGS);
DestroyWindow(WINDOW_DIALOG_LIBEXPORT_SETTINGS);
DestroyWindow(WINDOW_DIALOG_SONG_INFO);
DestroyWindow(WINDOW_DIALOG_SMART_PLAYLIST_EDITOR);
DestroyWindow(WINDOW_DIALOG_SMART_PLAYLIST_RULE);
DestroyWindow(WINDOW_DIALOG_BUSY);
DestroyWindow(WINDOW_DIALOG_BUSY_NOCANCEL);
DestroyWindow(WINDOW_DIALOG_PICTURE_INFO);
DestroyWindow(WINDOW_DIALOG_ADDON_INFO);
DestroyWindow(WINDOW_DIALOG_ADDON_SETTINGS);
DestroyWindow(WINDOW_DIALOG_SLIDER);
DestroyWindow(WINDOW_DIALOG_MEDIA_FILTER);
DestroyWindow(WINDOW_DIALOG_SUBTITLES);
DestroyWindow(WINDOW_DIALOG_COLOR_PICKER);
/* Delete PVR related windows and dialogs */
DestroyWindow(WINDOW_TV_CHANNELS);
DestroyWindow(WINDOW_TV_RECORDINGS);
DestroyWindow(WINDOW_TV_GUIDE);
DestroyWindow(WINDOW_TV_TIMERS);
DestroyWindow(WINDOW_TV_TIMER_RULES);
DestroyWindow(WINDOW_TV_SEARCH);
DestroyWindow(WINDOW_RADIO_CHANNELS);
DestroyWindow(WINDOW_RADIO_RECORDINGS);
DestroyWindow(WINDOW_RADIO_GUIDE);
DestroyWindow(WINDOW_RADIO_TIMERS);
DestroyWindow(WINDOW_RADIO_TIMER_RULES);
DestroyWindow(WINDOW_RADIO_SEARCH);
DestroyWindow(WINDOW_DIALOG_PVR_GUIDE_INFO);
DestroyWindow(WINDOW_DIALOG_PVR_RECORDING_INFO);
DestroyWindow(WINDOW_DIALOG_PVR_TIMER_SETTING);
DestroyWindow(WINDOW_DIALOG_PVR_GROUP_MANAGER);
DestroyWindow(WINDOW_DIALOG_PVR_CHANNEL_MANAGER);
DestroyWindow(WINDOW_DIALOG_PVR_GUIDE_SEARCH);
DestroyWindow(WINDOW_DIALOG_PVR_CHANNEL_SCAN);
DestroyWindow(WINDOW_DIALOG_PVR_RADIO_RDS_INFO);
DestroyWindow(WINDOW_DIALOG_PVR_UPDATE_PROGRESS);
DestroyWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS);
DestroyWindow(WINDOW_DIALOG_PVR_CHANNEL_GUIDE);
DestroyWindow(WINDOW_DIALOG_OSD_TELETEXT);
DestroyWindow(WINDOW_DIALOG_PVR_RECORDING_SETTING);
DestroyWindow(WINDOW_DIALOG_PVR_CLIENT_PRIORITIES);
DestroyWindow(WINDOW_DIALOG_PVR_GUIDE_CONTROLS);
DestroyWindow(WINDOW_DIALOG_TEXT_VIEWER);
#ifdef HAS_OPTICAL_DRIVE
DestroyWindow(WINDOW_DIALOG_PLAY_EJECT);
#endif
DestroyWindow(WINDOW_STARTUP_ANIM);
DestroyWindow(WINDOW_LOGIN_SCREEN);
DestroyWindow(WINDOW_VISUALISATION);
DestroyWindow(WINDOW_SETTINGS_MENU);
DestroyWindow(WINDOW_SETTINGS_PROFILES);
DestroyWindow(WINDOW_SCREEN_CALIBRATION);
DestroyWindow(WINDOW_SYSTEM_INFORMATION);
DestroyWindow(WINDOW_SCREENSAVER);
DestroyWindow(WINDOW_DIALOG_VIDEO_OSD);
DestroyWindow(WINDOW_SLIDESHOW);
DestroyWindow(WINDOW_ADDON_BROWSER);
DestroyWindow(WINDOW_SKIN_SETTINGS);
DestroyWindow(WINDOW_HOME);
DestroyWindow(WINDOW_PROGRAMS);
DestroyWindow(WINDOW_PICTURES);
DestroyWindow(WINDOW_WEATHER);
DestroyWindow(WINDOW_DIALOG_GAME_CONTROLLERS);
DestroyWindow(WINDOW_DIALOG_GAME_PORTS);
DestroyWindow(WINDOW_GAMES);
DestroyWindow(WINDOW_DIALOG_GAME_OSD);
DestroyWindow(WINDOW_DIALOG_GAME_SAVES);
DestroyWindow(WINDOW_DIALOG_GAME_VIDEO_FILTER);
DestroyWindow(WINDOW_DIALOG_GAME_STRETCH_MODE);
DestroyWindow(WINDOW_DIALOG_GAME_VOLUME);
DestroyWindow(WINDOW_DIALOG_GAME_ADVANCED_SETTINGS);
DestroyWindow(WINDOW_DIALOG_GAME_VIDEO_ROTATION);
DestroyWindow(WINDOW_DIALOG_IN_GAME_SAVES);
DestroyWindow(WINDOW_DIALOG_GAME_AGENTS);
DestroyWindow(WINDOW_FULLSCREEN_GAME);
Remove(WINDOW_SETTINGS_SERVICE);
Remove(WINDOW_SETTINGS_MYPVR);
Remove(WINDOW_SETTINGS_PLAYER);
Remove(WINDOW_SETTINGS_MEDIA);
Remove(WINDOW_SETTINGS_INTERFACE);
Remove(WINDOW_SETTINGS_MYGAMES);
DestroyWindow(WINDOW_SETTINGS_SYSTEM); // all the settings categories
Remove(WINDOW_DIALOG_KAI_TOAST);
Remove(WINDOW_DIALOG_SEEK_BAR);
Remove(WINDOW_DIALOG_VOLUME_BAR);
DestroyWindow(WINDOW_EVENT_LOG);
DestroyWindow(WINDOW_FAVOURITES);
DestroyWindow(WINDOW_DIALOG_PERIPHERALS);
DestroyWindow(WINDOW_DIALOG_PERIPHERAL_SETTINGS);
}
catch (...)
{
CLog::Log(LOGERROR, "Exception in CGUIWindowManager::DestroyWindows()");
return false;
}
return true;
}
void CGUIWindowManager::DestroyWindow(int id)
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
CGUIWindow *pWindow = GetWindow(id);
if (pWindow)
{
Remove(id);
pWindow->FreeResources(true);
delete pWindow;
}
}
bool CGUIWindowManager::SendMessage(int message, int senderID, int destID, int param1, int param2)
{
CGUIMessage msg(message, senderID, destID, param1, param2);
return SendMessage(msg);
}
bool CGUIWindowManager::SendMessage(CGUIMessage& message)
{
bool handled = false;
// CLog::Log(LOGDEBUG,"SendMessage: mess={} send={} control={} param1={}", message.GetMessage(), message.GetSenderId(), message.GetControlId(), message.GetParam1());
// Send the message to all none window targets
for (int i = 0; i < int(m_vecMsgTargets.size()); i++)
{
IMsgTargetCallback* pMsgTarget = m_vecMsgTargets[i];
if (pMsgTarget)
{
if (pMsgTarget->OnMessage( message )) handled = true;
}
}
// A GUI_MSG_NOTIFY_ALL is send to any active modal dialog
// and all windows whether they are active or not
if (message.GetMessage()==GUI_MSG_NOTIFY_ALL)
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
for (auto it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it)
{
(*it)->OnMessage(message);
}
for (const auto& entry : m_mapWindows)
{
entry.second->OnMessage(message);
}
return true;
}
// Normal messages are sent to:
// 1. All active modeless dialogs
// 2. The topmost dialog that accepts the message
// 3. The underlying window (only if it is the sender or receiver if a modal dialog is active)
bool hasModalDialog(false);
bool modalAcceptedMessage(false);
// don't use an iterator for this loop, as some messages mean that m_activeDialogs is altered,
// which will invalidate any iterator
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
size_t topWindow = m_activeDialogs.size();
while (topWindow)
{
CGUIWindow* dialog = m_activeDialogs[--topWindow];
if (!modalAcceptedMessage && dialog->IsModalDialog())
{ // modal window
hasModalDialog = true;
if (!modalAcceptedMessage && dialog->OnMessage( message ))
{
modalAcceptedMessage = handled = true;
}
}
else if (!dialog->IsModalDialog())
{ // modeless
if (dialog->OnMessage( message ))
handled = true;
}
if (topWindow > m_activeDialogs.size())
topWindow = m_activeDialogs.size();
}
// now send to the underlying window
CGUIWindow* window = GetWindow(GetActiveWindow());
if (window)
{
if (hasModalDialog)
{
// only send the message to the underlying window if it's the recipient
// or sender (or we have no sender)
if (message.GetSenderId() == window->GetID() ||
message.GetControlId() == window->GetID() ||
message.GetSenderId() == 0 )
{
if (window->OnMessage(message)) handled = true;
}
}
else
{
if (window->OnMessage(message)) handled = true;
}
}
return handled;
}
bool CGUIWindowManager::SendMessage(CGUIMessage& message, int window)
{
if (window == 0)
// send to no specified windows.
return SendMessage(message);
CGUIWindow* pWindow = GetWindow(window);
if(pWindow)
return pWindow->OnMessage(message);
else
return false;
}
void CGUIWindowManager::AddUniqueInstance(CGUIWindow *window)
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
// increment our instance (upper word of windowID)
// until we get a window we don't have
int instance = 0;
while (GetWindow(window->GetID()))
window->SetID(window->GetID() + (++instance << 16));
Add(window);
}
void CGUIWindowManager::Add(CGUIWindow* pWindow)
{
if (!pWindow)
{
CLog::Log(LOGERROR, "Attempted to add a NULL window pointer to the window manager.");
return;
}
// push back all the windows if there are more than one covered by this class
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
for (int id : pWindow->GetIDRange())
{
auto it = m_mapWindows.find(id);
if (it != m_mapWindows.end())
{
CLog::Log(LOGERROR,
"Error, trying to add a second window with id {} "
"to the window manager",
id);
return;
}
m_mapWindows.insert(std::make_pair(id, pWindow));
}
}
void CGUIWindowManager::AddCustomWindow(CGUIWindow* pWindow)
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
Add(pWindow);
m_vecCustomWindows.emplace_back(pWindow);
}
void CGUIWindowManager::RegisterDialog(CGUIWindow* dialog)
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
// only add the window if it does not exists
for (const auto& window : m_activeDialogs)
{
if (window->GetID() == dialog->GetID())
return;
}
m_activeDialogs.emplace_back(dialog);
}
void CGUIWindowManager::Remove(int id)
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
auto it = m_mapWindows.find(id);
if (it != m_mapWindows.end())
{
CGUIWindow *window = it->second;
m_windowHistory.erase(std::remove_if(m_windowHistory.begin(),
m_windowHistory.end(),
[id](int winId){ return winId == id; }),
m_windowHistory.end());
m_activeDialogs.erase(std::remove_if(m_activeDialogs.begin(),
m_activeDialogs.end(),
[window](CGUIWindow* w){ return w == window; }),
m_activeDialogs.end());
m_mapWindows.erase(it);
}
else
{
CLog::Log(LOGWARNING,
"Attempted to remove window {} "
"from the window manager when it didn't exist",
id);
}
}
// removes and deletes the window. Should only be called
// from the class that created the window using new.
void CGUIWindowManager::Delete(int id)
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
CGUIWindow *pWindow = GetWindow(id);
if (pWindow)
{
Remove(id);
m_deleteWindows.emplace_back(pWindow);
}
}
void CGUIWindowManager::PreviousWindow()
{
// deactivate any window
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Deactivate");
int currentWindow = GetActiveWindow();
CGUIWindow *pCurrentWindow = GetWindow(currentWindow);
if (!pCurrentWindow)
return; // no windows or window history yet
// check to see whether our current window has a <previouswindow> tag
if (pCurrentWindow->GetPreviousWindow() != WINDOW_INVALID)
{
//! @todo we may need to test here for the
//! whether our history should be changed
// don't reactivate the previouswindow if it is ourselves.
if (currentWindow != pCurrentWindow->GetPreviousWindow())
ActivateWindow(pCurrentWindow->GetPreviousWindow());
return;
}
// get the previous window in our stack
if (m_windowHistory.size() < 2)
{
// no previous window history yet - check if we should just activate home
if (GetActiveWindow() != WINDOW_INVALID && GetActiveWindow() != WINDOW_HOME)
{
CloseWindowSync(pCurrentWindow);
ClearWindowHistory();
ActivateWindow(WINDOW_HOME);
}
return;
}
m_windowHistory.pop_back();
int previousWindow = GetActiveWindow();
m_windowHistory.emplace_back(currentWindow);
CGUIWindow *pNewWindow = GetWindow(previousWindow);
if (!pNewWindow)
{
CLog::Log(LOGERROR, "Unable to activate the previous window");
CloseWindowSync(pCurrentWindow);
ClearWindowHistory();
ActivateWindow(WINDOW_HOME);
return;
}
// ok to go to the previous window now
// tell our info manager which window we are going to
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetGUIControlsInfoProvider().SetNextWindow(previousWindow);
// deinitialize our window
CloseWindowSync(pCurrentWindow);
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetGUIControlsInfoProvider().SetNextWindow(WINDOW_INVALID);
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetGUIControlsInfoProvider().SetPreviousWindow(currentWindow);
// remove the current window off our window stack
m_windowHistory.pop_back();
// ok, initialize the new window
CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Activate new");
CGUIMessage msg2(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, GetActiveWindow());
pNewWindow->OnMessage(msg2);
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetGUIControlsInfoProvider().SetPreviousWindow(WINDOW_INVALID);
}
void CGUIWindowManager::ChangeActiveWindow(int newWindow, const std::string& strPath)
{
std::vector<std::string> params;
if (!strPath.empty())
params.emplace_back(strPath);
ActivateWindow(newWindow, params, true);
}
void CGUIWindowManager::ActivateWindow(int iWindowID, const std::string& strPath)
{
std::vector<std::string> params;
if (!strPath.empty())
params.emplace_back(strPath);
ActivateWindow(iWindowID, params, false);
}
void CGUIWindowManager::ForceActivateWindow(int iWindowID, const std::string& strPath)
{
std::vector<std::string> params;
if (!strPath.empty())
params.emplace_back(strPath);
ActivateWindow(iWindowID, params, false, true);
}
void CGUIWindowManager::ActivateWindow(int iWindowID, const std::vector<std::string>& params, bool swappingWindows /* = false */, bool force /* = false */)
{
if (!CServiceBroker::GetAppMessenger()->IsProcessThread())
{
// make sure graphics lock is not held
CSingleExit leaveIt(CServiceBroker::GetWinSystem()->GetGfxContext());
CServiceBroker::GetAppMessenger()->SendMsg(TMSG_GUI_ACTIVATE_WINDOW, iWindowID,
swappingWindows ? 1 : 0, nullptr, "", params);
}
else
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
ActivateWindow_Internal(iWindowID, params, swappingWindows, force);
}
}
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const std::vector<std::string>& params, bool swappingWindows, bool force /* = false */)
{
// translate virtual windows
if (iWindowID == WINDOW_START)
{ // virtual start window
iWindowID = g_SkinInfo->GetStartWindow();
}
// debug
CLog::Log(LOGDEBUG, "Activating window ID: {}", iWindowID);
// make sure we check mediasources from home
if (GetActiveWindow() == WINDOW_HOME)
{
g_passwordManager.SetMediaSourcePath(!params.empty() ? params[0] : "");
}
else
{
g_passwordManager.SetMediaSourcePath("");
}
if (!g_passwordManager.CheckMenuLock(iWindowID))
{
CLog::Log(LOGERROR,
"MasterCode or MediaSource-code is wrong: Window with id {} will not be loaded! "
"Enter a correct code!",
iWindowID);
if (GetActiveWindow() == WINDOW_INVALID && iWindowID != WINDOW_HOME)
ActivateWindow(WINDOW_HOME);
return;
}
// first check existence of the window we wish to activate.
CGUIWindow *pNewWindow = GetWindow(iWindowID);
if (!pNewWindow)
{ // nothing to see here - move along
CLog::Log(LOGERROR, "Unable to locate window with id {}. Check skin files",
iWindowID - WINDOW_HOME);
if (IsWindowActive(WINDOW_STARTUP_ANIM))
ActivateWindow(WINDOW_HOME);
return ;
}
else if (!pNewWindow->CanBeActivated())
{
if (IsWindowActive(WINDOW_STARTUP_ANIM))
ActivateWindow(WINDOW_HOME);
return;
}
else if (pNewWindow->IsDialog())
{ // if we have a dialog, we do a DoModal() rather than activate the window
if (!pNewWindow->IsDialogRunning())
{
CSingleExit exitit(CServiceBroker::GetWinSystem()->GetGfxContext());
static_cast<CGUIDialog *>(pNewWindow)->Open(params.size() > 0 ? params[0] : "");
// Invalidate underlying windows after closing a modal dialog
MarkDirty();
}
return;
}
// don't activate a window if there are active modal dialogs of type MODAL
if (!force && HasModalDialog(true))
{
CLog::Log(LOGINFO, "Activate of window '{}' refused because there are active modal dialogs",
iWindowID);
CServiceBroker::GetGUI()->GetAudioManager().PlayActionSound(CAction(ACTION_ERROR));
return;
}
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetGUIControlsInfoProvider().SetNextWindow(iWindowID);
// deactivate any window
int currentWindow = GetActiveWindow();
CGUIWindow *pWindow = GetWindow(currentWindow);
if (pWindow)
CloseWindowSync(pWindow, iWindowID);
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetGUIControlsInfoProvider().SetNextWindow(WINDOW_INVALID);
// Add window to the history list (we must do this before we activate it,
// as all messages done in WINDOW_INIT will want to be sent to the new
// topmost window). If we are swapping windows, we pop the old window
// off the history stack
if (swappingWindows && !m_windowHistory.empty())
m_windowHistory.pop_back();
AddToWindowHistory(iWindowID);
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetGUIControlsInfoProvider().SetPreviousWindow(currentWindow);
// Send the init message
CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID);
msg.SetStringParams(params);
pNewWindow->OnMessage(msg);
// CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetGUIControlsInfoProvider().SetPreviousWindow(WINDOW_INVALID);
}
void CGUIWindowManager::CloseDialogs(bool forceClose) const
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
//This is to avoid an assert about out of bounds iterator
//when m_activeDialogs happens to be empty
if (m_activeDialogs.empty())
return;
auto activeDialogs = m_activeDialogs;
for (const auto& window : activeDialogs)
{
if (window->IsModalDialog())
window->Close(forceClose);
}
}
void CGUIWindowManager::CloseInternalModalDialogs(bool forceClose) const
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
if (m_activeDialogs.empty())
return;
auto activeDialogs = m_activeDialogs;
for (const auto& window : activeDialogs)
{
if (window->IsModalDialog() && !IsAddonWindow(window->GetID()) && !IsPythonWindow(window->GetID()))
window->Close(forceClose);
}
}
// SwitchToFullScreen() returns true if a switch is made, else returns false
bool CGUIWindowManager::SwitchToFullScreen(bool force /* = false */)
{
// don't switch if the slideshow is active
if (IsWindowActive(WINDOW_SLIDESHOW))
return false;
// if playing from the video info window, close it first!
if (IsModalDialogTopmost(WINDOW_DIALOG_VIDEO_INFO))
{
CGUIDialogVideoInfo* pDialog = GetWindow<CGUIDialogVideoInfo>(WINDOW_DIALOG_VIDEO_INFO);
if (pDialog)
pDialog->Close(true);
}
// if playing from the album info window, close it first!
if (IsModalDialogTopmost(WINDOW_DIALOG_MUSIC_INFO))
{
CGUIDialogVideoInfo* pDialog = GetWindow<CGUIDialogVideoInfo>(WINDOW_DIALOG_MUSIC_INFO);
if (pDialog)
pDialog->Close(true);
}
// if playing from the song info window, close it first!
if (IsModalDialogTopmost(WINDOW_DIALOG_SONG_INFO))
{
CGUIDialogVideoInfo* pDialog = GetWindow<CGUIDialogVideoInfo>(WINDOW_DIALOG_SONG_INFO);
if (pDialog)
pDialog->Close(true);
}
const int activeWindowID = GetActiveWindow();
int windowID = WINDOW_INVALID;
const auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
// See if we're playing a game
if (activeWindowID != WINDOW_FULLSCREEN_GAME && appPlayer->IsPlayingGame())
windowID = WINDOW_FULLSCREEN_GAME;
// See if we're playing a video
else if (activeWindowID != WINDOW_FULLSCREEN_VIDEO && appPlayer->IsPlayingVideo())
windowID = WINDOW_FULLSCREEN_VIDEO;
// See if we're playing an audio song
if (activeWindowID != WINDOW_VISUALISATION && appPlayer->IsPlayingAudio())
windowID = WINDOW_VISUALISATION;
if (windowID != WINDOW_INVALID && (force || windowID != activeWindowID))
{
if (force)
ForceActivateWindow(windowID);
else
ActivateWindow(windowID);
return true;
}
return false;
}
void CGUIWindowManager::OnApplicationMessage(ThreadMessage* pMsg)
{
switch (pMsg->dwMessage)
{
case TMSG_GUI_DIALOG_OPEN:
{
if (pMsg->lpVoid)
static_cast<CGUIDialog*>(pMsg->lpVoid)->Open(pMsg->param2, pMsg->strParam);
else
{
CGUIDialog* pDialog = static_cast<CGUIDialog*>(GetWindow(pMsg->param1));
if (pDialog)
pDialog->Open(pMsg->strParam);
}
}
break;
case TMSG_GUI_WINDOW_CLOSE:
{
CGUIWindow *window = static_cast<CGUIWindow *>(pMsg->lpVoid);
if (window)
window->Close((pMsg->param1 & 0x1) ? true : false, pMsg->param1, (pMsg->param1 & 0x2) ? true : false);
}
break;
case TMSG_GUI_ACTIVATE_WINDOW:
{
ActivateWindow(pMsg->param1, pMsg->params, pMsg->param2 > 0);
}
break;
case TMSG_GUI_PREVIOUS_WINDOW:
{
PreviousWindow();
}
break;
case TMSG_GUI_ADDON_DIALOG:
{
if (pMsg->lpVoid)
{
static_cast<ADDON::CGUIAddonWindowDialog*>(pMsg->lpVoid)->Show_Internal(pMsg->param2 > 0);
}
}
break;
#ifdef HAS_PYTHON
case TMSG_GUI_PYTHON_DIALOG:
{
// This hack is not much better but at least I don't need to make ApplicationMessenger
// know about Addon (Python) specific classes.
CAction caction(pMsg->param1);
static_cast<CGUIWindow*>(pMsg->lpVoid)->OnAction(caction);
}
break;
#endif
case TMSG_GUI_ACTION:
{
if (pMsg->lpVoid)
{
CAction *action = static_cast<CAction *>(pMsg->lpVoid);
if (pMsg->param1 == WINDOW_INVALID)
g_application.OnAction(*action);
else
{
CGUIWindow *pWindow = GetWindow(pMsg->param1);
if (pWindow)
pWindow->OnAction(*action);
else
CLog::Log(LOGWARNING, "Failed to get window with ID {} to send an action to",
pMsg->param1);
}
delete action;
}
}
break;
case TMSG_GUI_MESSAGE:
if (pMsg->lpVoid)
{
CGUIMessage *message = static_cast<CGUIMessage *>(pMsg->lpVoid);
SendMessage(*message, pMsg->param1);
delete message;
}
break;
case TMSG_GUI_DIALOG_YESNO:
{
if (!pMsg->lpVoid && pMsg->param1 < 0 && pMsg->param2 < 0)
return;
auto dialog = static_cast<CGUIDialogYesNo*>(GetWindow(WINDOW_DIALOG_YES_NO));
if (!dialog)
return;
if (pMsg->lpVoid)
pMsg->SetResult(dialog->ShowAndGetInput(*static_cast<HELPERS::DialogYesNoMessage*>(pMsg->lpVoid)));
else
{
HELPERS::DialogYesNoMessage options;
options.heading = pMsg->param1;
options.text = pMsg->param2;
pMsg->SetResult(dialog->ShowAndGetInput(options));
}
}
break;
case TMSG_GUI_DIALOG_OK:
{
if (!pMsg->lpVoid && pMsg->param1 < 0 && pMsg->param2 < 0)
return;
auto dialogOK = static_cast<CGUIDialogOK*>(GetWindow(WINDOW_DIALOG_OK));
if (!dialogOK)
return;
if (pMsg->lpVoid)
dialogOK->ShowAndGetInput(*static_cast<HELPERS::DialogOKMessage*>(pMsg->lpVoid));
else
{
HELPERS::DialogOKMessage options;
options.heading = pMsg->param1;
options.text = pMsg->param2;
dialogOK->ShowAndGetInput(options);
}
pMsg->SetResult(static_cast<int>(dialogOK->IsConfirmed()));
}
break;
}
}
int CGUIWindowManager::GetMessageMask()
{
return TMSG_MASK_WINDOWMANAGER;
}
bool CGUIWindowManager::OnAction(const CAction &action) const
{
auto actionId = action.GetID();
if (actionId == ACTION_GESTURE_BEGIN)
{
m_touchGestureActive = true;
}
bool ret;
if (!m_inhibitTouchGestureEvents || !action.IsGesture())
{
ret = HandleAction(action);
}
else
{
// We swallow the event, so it is handled
ret = true;
CLog::Log(LOGDEBUG, "Swallowing touch action {} due to inhibition on window switch", actionId);
}
if (actionId == ACTION_GESTURE_END || actionId == ACTION_GESTURE_ABORT)
{
m_touchGestureActive = false;
m_inhibitTouchGestureEvents = false;
}
return ret;
}
bool CGUIWindowManager::HandleAction(CAction const& action) const
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
size_t topmost = m_activeDialogs.size();
while (topmost)
{
CGUIWindow *dialog = m_activeDialogs[--topmost];
lock.unlock();
if (dialog->IsModalDialog())
{ // we have the topmost modal dialog
if (!dialog->IsAnimating(ANIM_TYPE_WINDOW_CLOSE))
{
bool fallThrough = (dialog->GetID() == WINDOW_DIALOG_FULLSCREEN_INFO);
if (dialog->OnAction(action))
return true;
// dialog didn't want the action - we'd normally return false
// but for some dialogs we want to drop the actions through
if (fallThrough)
{
lock.lock();
break;
}
return false;
}
CLog::Log(LOGWARNING,
"CGUIWindowManager - {} - ignoring action {}, because topmost modal dialog closing "
"animation is running",
__FUNCTION__, action.GetID());
return true; // do nothing with the action until the anim is finished
}
lock.lock();
if (topmost > m_activeDialogs.size())
topmost = m_activeDialogs.size();
}
lock.unlock();
CGUIWindow* window = GetWindow(GetActiveWindow());
if (window)
return window->OnAction(action);
return false;
}
bool RenderOrderSortFunction(CGUIWindow *first, CGUIWindow *second)
{
return first->GetRenderOrder() < second->GetRenderOrder();
}
void CGUIWindowManager::Process(unsigned int currentTime)
{
assert(CServiceBroker::GetAppMessenger()->IsProcessThread());
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
m_dirtyregions.clear();
CGUIWindow* pWindow = GetWindow(GetActiveWindow());
if (pWindow)
pWindow->DoProcess(currentTime, m_dirtyregions);
// process all dialogs - visibility may change etc.
for (const auto& entry : m_mapWindows)
{
CGUIWindow *pWindow = entry.second;
if (pWindow && pWindow->IsDialog())
pWindow->DoProcess(currentTime, m_dirtyregions);
}
for (auto& itr : m_dirtyregions)
m_tracker.MarkDirtyRegion(itr);
}
void CGUIWindowManager::MarkDirty()
{
MarkDirty(CRect(0, 0, float(CServiceBroker::GetWinSystem()->GetGfxContext().GetWidth()), float(CServiceBroker::GetWinSystem()->GetGfxContext().GetHeight())));
}
void CGUIWindowManager::MarkDirty(const CRect& rect)
{
m_tracker.MarkDirtyRegion(CDirtyRegion(rect));
CGUIWindow* pWindow = GetWindow(GetActiveWindow());
if (pWindow)
pWindow->MarkDirtyRegion();
// make copy of vector as we may remove items from it as we go
auto activeDialogs = m_activeDialogs;
for (const auto& window : activeDialogs)
if (window->IsDialogRunning())
window->MarkDirtyRegion();
}
void CGUIWindowManager::RenderPass() const
{
CGUIWindow* pWindow = GetWindow(GetActiveWindow());
if (pWindow)
{
pWindow->ClearBackground();
pWindow->DoRender();
}
// we render the dialogs based on their render order.
auto renderList = m_activeDialogs;
stable_sort(renderList.begin(), renderList.end(), RenderOrderSortFunction);
for (const auto& window : renderList)
{
if (window->IsDialogRunning())
window->DoRender();
}
}
void CGUIWindowManager::RenderEx() const
{
CGUIWindow* pWindow = GetWindow(GetActiveWindow());
if (pWindow)
pWindow->RenderEx();
// We don't call RenderEx for now on dialogs since it is used
// to trigger non gui video rendering. We can activate it later at any time.
/*
vector<CGUIWindow *> &activeDialogs = m_activeDialogs;
for (iDialog it = activeDialogs.begin(); it != activeDialogs.end(); ++it)
{
if ((*it)->IsDialogRunning())
(*it)->RenderEx();
}
*/
}
bool CGUIWindowManager::Render()
{
assert(CServiceBroker::GetAppMessenger()->IsProcessThread());
CSingleExit lock(CServiceBroker::GetWinSystem()->GetGfxContext());
CDirtyRegionList dirtyRegions = m_tracker.GetDirtyRegions();
bool hasRendered = false;
// If we visualize the regions we will always render the entire viewport
if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiVisualizeDirtyRegions || CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_FILL_VIEWPORT_ALWAYS)
{
RenderPass();
hasRendered = true;
}
else if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_FILL_VIEWPORT_ON_CHANGE)
{
if (!dirtyRegions.empty())
{
RenderPass();
hasRendered = true;
}
}
else
{
for (const auto& i : dirtyRegions)
{
if (i.IsEmpty())
continue;
CServiceBroker::GetWinSystem()->GetGfxContext().SetScissors(i);
RenderPass();
hasRendered = true;
}
CServiceBroker::GetWinSystem()->GetGfxContext().ResetScissors();
}
if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiVisualizeDirtyRegions)
{
CServiceBroker::GetWinSystem()->GetGfxContext().SetRenderingResolution(CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(), false);
const CDirtyRegionList &markedRegions = m_tracker.GetMarkedRegions();
for (const auto& i : markedRegions)
CGUITexture::DrawQuad(i, 0x0fff0000);
for (const auto& i : dirtyRegions)
CGUITexture::DrawQuad(i, 0x4c00ff00);
}
return hasRendered;
}
void CGUIWindowManager::AfterRender()
{
m_tracker.CleanMarkedRegions();
CGUIWindow* pWindow = GetWindow(GetActiveWindow());
if (pWindow)
pWindow->AfterRender();
// make copy of vector as we may remove items from it as we go
auto activeDialogs = m_activeDialogs;
for (const auto& window : activeDialogs)
{
if (window->IsDialogRunning())
{
window->AfterRender();
// Dialog state can affect visibility states
if (pWindow && window->IsControlDirty())
pWindow->MarkDirtyRegion();
}
}
}
void CGUIWindowManager::FrameMove()
{
assert(CServiceBroker::GetAppMessenger()->IsProcessThread());
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
if(m_iNested == 0)
{
// delete any windows queued for deletion
for (const auto& window : m_deleteWindows)
{
// Free any window resources
window->FreeResources(true);
delete window;
}
m_deleteWindows.clear();
}
CGUIWindow* pWindow = GetWindow(GetActiveWindow());
if (pWindow)
pWindow->FrameMove();
// update any dialogs - we take a copy of the vector as some dialogs may close themselves
// during this call
auto dialogs = m_activeDialogs;
for (const auto& window : dialogs)
{
window->FrameMove();
}
CServiceBroker::GetGUI()->GetInfoManager().UpdateAVInfo();
}
CGUIDialog* CGUIWindowManager::GetDialog(int id) const
{
CGUIWindow *window = GetWindow(id);
if (window && window->IsDialog())
return dynamic_cast<CGUIDialog*>(window);
return nullptr;
}
CGUIWindow* CGUIWindowManager::GetWindow(int id) const
{
if (id == 0 || id == WINDOW_INVALID)
return nullptr;
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
auto it = m_mapWindows.find(id);
if (it != m_mapWindows.end())
return it->second;
return nullptr;
}
bool CGUIWindowManager::ProcessRenderLoop(bool renderOnly)
{
bool renderGui = true;
if (CServiceBroker::GetAppMessenger()->IsProcessThread() && m_pCallback)
{
renderGui = m_pCallback->GetRenderGUI();
m_iNested++;
if (!renderOnly)
m_pCallback->Process();
{
CSingleExit leaveIt(CServiceBroker::GetWinSystem()->GetGfxContext());
m_pCallback->FrameMove(!renderOnly);
}
m_pCallback->Render();
m_iNested--;
}
if (g_application.m_bStop || !renderGui)
return false;
else
return true;
}
void CGUIWindowManager::SetCallback(IWindowManagerCallback& callback)
{
m_pCallback = &callback;
}
void CGUIWindowManager::DeInitialize()
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
// Need a copy because addon-dialogs removes itself on Close()
std::unordered_map<int, CGUIWindow*> closeMap(m_mapWindows);
for (const auto& entry : closeMap)
{
CGUIWindow* pWindow = entry.second;
if (IsWindowActive(entry.first, false))
{
pWindow->DisableAnimations();
pWindow->Close(true);
}
pWindow->ResetControlStates();
pWindow->FreeResources(true);
}
UnloadNotOnDemandWindows();
m_vecMsgTargets.erase( m_vecMsgTargets.begin(), m_vecMsgTargets.end() );
// destroy our custom windows...
for (int i = 0; i < int(m_vecCustomWindows.size()); i++)
{
CGUIWindow *pWindow = m_vecCustomWindows[i];
RemoveFromWindowHistory(pWindow->GetID());
Remove(pWindow->GetID());
delete pWindow;
}
// clear our vectors of windows
m_vecCustomWindows.clear();
m_activeDialogs.clear();
m_initialized = false;
}
/// \brief Unroute window
/// \param id ID of the window routed
void CGUIWindowManager::RemoveDialog(int id)
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
m_activeDialogs.erase(std::remove_if(m_activeDialogs.begin(),
m_activeDialogs.end(),
[id](CGUIWindow* dialog) { return dialog->GetID() == id; }),
m_activeDialogs.end());
}
bool CGUIWindowManager::HasModalDialog(bool ignoreClosing) const
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
for (const auto& window : m_activeDialogs)
{
if (window->IsDialog() &&
window->IsModalDialog() &&
(!ignoreClosing || !window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)))
{
return true;
}
}
return false;
}
bool CGUIWindowManager::HasVisibleModalDialog() const
{
return HasModalDialog(false);
}
int CGUIWindowManager::GetTopmostDialog(bool modal, bool ignoreClosing) const
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
for (auto it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it)
{
CGUIWindow *dialog = *it;
if ((!modal || dialog->IsModalDialog()) && (!ignoreClosing || !dialog->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)))
return dialog->GetID();
}
return WINDOW_INVALID;
}
int CGUIWindowManager::GetTopmostDialog(bool ignoreClosing /*= false*/) const
{
return GetTopmostDialog(false, ignoreClosing);
}
int CGUIWindowManager::GetTopmostModalDialog(bool ignoreClosing /*= false*/) const
{
return GetTopmostDialog(true, ignoreClosing);
}
void CGUIWindowManager::SendThreadMessage(CGUIMessage& message, int window /*= 0*/)
{
std::unique_lock<CCriticalSection> lock(m_critSection);
CGUIMessage* msg = new CGUIMessage(message);
m_vecThreadMessages.emplace_back(msg, window);
}
void CGUIWindowManager::DispatchThreadMessages()
{
// This method only be called in the xbmc main thread.
// XXX: for more info of this method
// check the pr here: https://github.com/xbmc/xbmc/pull/2253
// As a thread message queue service, it should follow these rules:
// 1. [Must] Thread safe, message can be pushed into queue in arbitrary thread context.
// 2. Messages [must] be processed in dispatch message thread context with the same
// order as they be pushed into the queue.
// 3. Dispatch function [must] support call itself during message process procedure,
// and do not break other rules listed here. to make it clear: in the
// SendMessage(), it could start another xbmc main thread loop, calling
// DispatchThreadMessages() in it's internal loop, this must be supported.
// 4. During DispatchThreadMessages() processing, any new pushed message [should] not
// be processed by the current loop in DispatchThreadMessages(), prevent dead loop.
// 5. If possible, queued messages can be removed by certain filter condition
// and not break above.
std::unique_lock<CCriticalSection> lock(m_critSection);
while (!m_vecThreadMessages.empty())
{
// pop up one message per time to make messages be processed by order.
// this will ensure rule No.2 & No.3
CGUIMessage *pMsg = m_vecThreadMessages.front().first;
int window = m_vecThreadMessages.front().second;
m_vecThreadMessages.pop_front();
lock.unlock();
// XXX: during SendMessage(), there could be a deeper 'xbmc main loop' inited by e.g. doModal
// which may loop there and callback to DispatchThreadMessages() multiple times.
if (window)
SendMessage( *pMsg, window );
else
SendMessage( *pMsg );
delete pMsg;
lock.lock();
}
}
int CGUIWindowManager::RemoveThreadMessageByMessageIds(int *pMessageIDList)
{
std::unique_lock<CCriticalSection> lock(m_critSection);
int removedMsgCount = 0;
for (std::list < std::pair<CGUIMessage*,int> >::iterator it = m_vecThreadMessages.begin();
it != m_vecThreadMessages.end();)
{
CGUIMessage *pMsg = it->first;
int *pMsgID;
for(pMsgID = pMessageIDList; *pMsgID != 0; ++pMsgID)
if (pMsg->GetMessage() == *pMsgID)
break;
if (*pMsgID)
{
it = m_vecThreadMessages.erase(it);
delete pMsg;
++removedMsgCount;
}
else
{
++it;
}
}
return removedMsgCount;
}
void CGUIWindowManager::AddMsgTarget(IMsgTargetCallback* pMsgTarget)
{
m_vecMsgTargets.emplace_back(pMsgTarget);
}
int CGUIWindowManager::GetActiveWindow() const
{
if (!m_windowHistory.empty())
return m_windowHistory.back();
return WINDOW_INVALID;
}
int CGUIWindowManager::GetActiveWindowOrDialog() const
{
// if there is a dialog active get the dialog id instead
int iWin = GetTopmostModalDialog() & WINDOW_ID_MASK;
if (iWin != WINDOW_INVALID)
return iWin;
// get the currently active window
return GetActiveWindow() & WINDOW_ID_MASK;
}
bool CGUIWindowManager::IsWindowActive(int id, bool ignoreClosing /* = true */) const
{
// mask out multiple instances of the same window
id &= WINDOW_ID_MASK;
if ((GetActiveWindow() & WINDOW_ID_MASK) == id)
return true;
// run through the dialogs
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
for (const auto& window : m_activeDialogs)
{
if ((window->GetID() & WINDOW_ID_MASK) == id && (!ignoreClosing || !window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)))
return true;
}
return false; // window isn't active
}
bool CGUIWindowManager::IsWindowActive(const std::string &xmlFile, bool ignoreClosing /* = true */) const
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
CGUIWindow *window = GetWindow(GetActiveWindow());
if (window && StringUtils::EqualsNoCase(URIUtils::GetFileName(window->GetProperty("xmlfile").asString()), xmlFile))
return true;
// run through the dialogs
for (const auto& window : m_activeDialogs)
{
if (StringUtils::EqualsNoCase(URIUtils::GetFileName(window->GetProperty("xmlfile").asString()), xmlFile) &&
(!ignoreClosing || !window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)))
return true;
}
return false; // window isn't active
}
bool CGUIWindowManager::IsWindowVisible(int id) const
{
return IsWindowActive(id, false);
}
bool CGUIWindowManager::IsWindowVisible(const std::string &xmlFile) const
{
return IsWindowActive(xmlFile, false);
}
void CGUIWindowManager::LoadNotOnDemandWindows()
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
for (const auto& entry : m_mapWindows)
{
CGUIWindow *pWindow = entry.second;
if (pWindow->GetLoadType() == CGUIWindow::LOAD_ON_GUI_INIT)
{
pWindow->FreeResources(true);
pWindow->Initialize();
}
}
}
void CGUIWindowManager::UnloadNotOnDemandWindows()
{
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
for (const auto& entry : m_mapWindows)
{
CGUIWindow *pWindow = entry.second;
if (pWindow->GetLoadType() == CGUIWindow::LOAD_ON_GUI_INIT ||
pWindow->GetLoadType() == CGUIWindow::KEEP_IN_MEMORY)
{
pWindow->FreeResources(true);
}
}
}
void CGUIWindowManager::AddToWindowHistory(int newWindowID)
{
// Check the window stack to see if this window is in our history,
// and if so, pop all the other windows off the stack so that we
// always have a predictable "Back" behaviour for each window
std::deque<int> history = m_windowHistory;
while (!history.empty())
{
if (history.back() == newWindowID)
break;
history.pop_back();
}
if (!history.empty())
{ // found window in history
m_windowHistory.swap(history);
}
else
{
// didn't find window in history - add it to the stack
m_windowHistory.emplace_back(newWindowID);
}
}
void CGUIWindowManager::RemoveFromWindowHistory(int windowID)
{
std::deque<int> history = m_windowHistory;
// pop windows from stack until we found the window
while (!history.empty())
{
if (history.back() == windowID)
break;
history.pop_back();
}
// found window in history
if (!history.empty())
{
history.pop_back(); // remove window from stack
m_windowHistory.swap(history);
}
}
bool CGUIWindowManager::IsModalDialogTopmost(int id) const
{
return IsDialogTopmost(id, true);
}
bool CGUIWindowManager::IsModalDialogTopmost(const std::string &xmlFile) const
{
return IsDialogTopmost(xmlFile, true);
}
bool CGUIWindowManager::IsDialogTopmost(int id, bool modal /* = false */) const
{
CGUIWindow *topmost = GetWindow(GetTopmostDialog(modal, false));
if (topmost && (topmost->GetID() & WINDOW_ID_MASK) == id)
return true;
return false;
}
bool CGUIWindowManager::IsDialogTopmost(const std::string &xmlFile, bool modal /* = false */) const
{
CGUIWindow *topmost = GetWindow(GetTopmostDialog(modal, false));
if (topmost && StringUtils::EqualsNoCase(URIUtils::GetFileName(topmost->GetProperty("xmlfile").asString()), xmlFile))
return true;
return false;
}
bool CGUIWindowManager::HasVisibleControls()
{
CSingleExit lock(CServiceBroker::GetWinSystem()->GetGfxContext());
if (m_activeDialogs.empty())
{
CGUIWindow *window(GetWindow(GetActiveWindow()));
return !window || window->HasVisibleControls();
}
else
return true;
}
void CGUIWindowManager::ClearWindowHistory()
{
while (!m_windowHistory.empty())
m_windowHistory.pop_back();
}
void CGUIWindowManager::CloseWindowSync(CGUIWindow *window, int nextWindowID /*= 0*/)
{
// Abort touch action if active
if (m_touchGestureActive && !m_inhibitTouchGestureEvents)
{
CLog::Log(LOGDEBUG, "Closing window {} with active touch gesture, sending gesture abort event",
window->GetID());
window->OnAction({ACTION_GESTURE_ABORT});
// Don't send any mid-gesture events to next window until new touch starts
m_inhibitTouchGestureEvents = true;
}
window->Close(false, nextWindowID);
bool renderLoopProcessed = true;
while (window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE) && renderLoopProcessed)
renderLoopProcessed = ProcessRenderLoop(true);
}
#ifdef _DEBUG
void CGUIWindowManager::DumpTextureUse()
{
CGUIWindow* pWindow = GetWindow(GetActiveWindow());
if (pWindow)
pWindow->DumpTextureUse();
std::unique_lock<CCriticalSection> lock(CServiceBroker::GetWinSystem()->GetGfxContext());
for (const auto& window : m_activeDialogs)
{
if (window->IsDialogRunning())
window->DumpTextureUse();
}
}
#endif
|