From 8f03bb3723ec93f9ba057e782996831cdfb06f93 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Fri, 22 Apr 2016 09:07:29 +0200 Subject: guilib: only dialogs are allowed to call ProcessRenderLoop --- .../binary/interfaces/api1/GUI/AddonGUIWindow.cpp | 2 +- xbmc/dialogs/GUIDialogBusy.cpp | 2 +- xbmc/dialogs/GUIDialogProgress.cpp | 2 +- xbmc/filesystem/Directory.cpp | 38 ++++++---------------- xbmc/filesystem/PluginDirectory.cpp | 9 ++--- xbmc/guilib/GUIDialog.cpp | 5 +++ xbmc/guilib/GUIDialog.h | 2 ++ xbmc/guilib/GUIWindowManager.h | 7 +++- xbmc/network/upnp/UPnPPlayer.cpp | 21 ++---------- xbmc/pvr/windows/GUIWindowPVRBase.cpp | 32 +----------------- xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp | 6 ++-- xbmc/windows/GUIMediaWindow.cpp | 5 +++ xbmc/windows/GUIMediaWindow.h | 2 ++ 13 files changed, 42 insertions(+), 91 deletions(-) diff --git a/xbmc/addons/binary/interfaces/api1/GUI/AddonGUIWindow.cpp b/xbmc/addons/binary/interfaces/api1/GUI/AddonGUIWindow.cpp index 67fd5aa99d..335c62a260 100644 --- a/xbmc/addons/binary/interfaces/api1/GUI/AddonGUIWindow.cpp +++ b/xbmc/addons/binary/interfaces/api1/GUI/AddonGUIWindow.cpp @@ -339,7 +339,7 @@ void CGUIAddonWindowDialog::Show_Internal(bool show /* = true */) m_renderOrder = RENDER_ORDER_DIALOG; while (m_bRunning && !g_application.m_bStop) { - g_windowManager.ProcessRenderLoop(); + ProcessRenderLoop(); } } else // hide diff --git a/xbmc/dialogs/GUIDialogBusy.cpp b/xbmc/dialogs/GUIDialogBusy.cpp index 6816b45cc6..8ea5161637 100644 --- a/xbmc/dialogs/GUIDialogBusy.cpp +++ b/xbmc/dialogs/GUIDialogBusy.cpp @@ -71,7 +71,7 @@ bool CGUIDialogBusy::WaitOnEvent(CEvent &event, unsigned int displaytime /* = 10 while(!event.WaitMSec(1)) { - g_windowManager.ProcessRenderLoop(false); + dialog->ProcessRenderLoop(false); if (allowCancel && dialog->IsCanceled()) { cancelled = true; diff --git a/xbmc/dialogs/GUIDialogProgress.cpp b/xbmc/dialogs/GUIDialogProgress.cpp index dc1427150f..af54e49fbf 100644 --- a/xbmc/dialogs/GUIDialogProgress.cpp +++ b/xbmc/dialogs/GUIDialogProgress.cpp @@ -85,7 +85,7 @@ void CGUIDialogProgress::Progress() { if (m_active) { - g_windowManager.ProcessRenderLoop(); + ProcessRenderLoop(); } } diff --git a/xbmc/filesystem/Directory.cpp b/xbmc/filesystem/Directory.cpp index 0b3e394721..1a713dc0fe 100644 --- a/xbmc/filesystem/Directory.cpp +++ b/xbmc/filesystem/Directory.cpp @@ -88,6 +88,11 @@ public: CJobManager::GetInstance().CancelJob(m_id); } + CEvent& GetEvent() + { + return m_result->m_event; + } + bool Wait(unsigned int timeout) { return m_result->m_event.WaitMSec(timeout); @@ -168,36 +173,13 @@ bool CDirectory::GetDirectory(const CURL& url, CFileItemList &items, const CHint CSingleExit ex(g_graphicsContext); CGetDirectory get(pDirectory, realURL, url); - if(!get.Wait(TIME_TO_BUSY_DIALOG)) + + if (!CGUIDialogBusy::WaitOnEvent(get.GetEvent(), TIME_TO_BUSY_DIALOG)) { - CGUIDialogBusy* dialog = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY); - if (dialog) - { - dialog->Open(); - - while(!get.Wait(10)) - { - CSingleLock lock(g_graphicsContext); - - // update progress - float progress = pDirectory->GetProgress(); - if (progress > 0) - dialog->SetProgress(progress); - - if (dialog->IsCanceled()) - { - cancel = true; - pDirectory->CancelDirectory(); - break; - } - - lock.Leave(); // prevent an occasional deadlock on exit - g_windowManager.ProcessRenderLoop(false); - } - - dialog->Close(); - } + cancel = true; + pDirectory->CancelDirectory(); } + result = get.GetDirectory(items); } else diff --git a/xbmc/filesystem/PluginDirectory.cpp b/xbmc/filesystem/PluginDirectory.cpp index e8b63bf616..0987e3aa4e 100644 --- a/xbmc/filesystem/PluginDirectory.cpp +++ b/xbmc/filesystem/PluginDirectory.cpp @@ -36,7 +36,6 @@ #include "utils/JobManager.h" #include "utils/StringUtils.h" #include "messaging/ApplicationMessenger.h" -#include "Application.h" #include "URL.h" using namespace XFILE; @@ -457,7 +456,6 @@ bool CPluginDirectory::WaitOnScriptResult(const std::string &scriptPath, int scr unsigned int startTime = XbmcThreads::SystemClockMillis(); CGUIDialogProgress *progressBar = NULL; bool cancelled = false; - bool inMainAppThread = g_application.IsCurrentThread(); CLog::Log(LOGDEBUG, "%s - waiting on the %s (id=%d) plugin...", __FUNCTION__, scriptName.c_str(), scriptId); while (true) @@ -513,17 +511,14 @@ bool CPluginDirectory::WaitOnScriptResult(const std::string &scriptPath, int scr m_cancelled = true; } } - else // if the progressBar exists and we call StartModal or Progress we get the - // ProcessRenderLoop call anyway. - if (inMainAppThread) - g_windowManager.ProcessRenderLoop(); if (!cancelled && m_cancelled) { cancelled = true; startTime = XbmcThreads::SystemClockMillis(); } - if ((cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript) || g_application.m_bStop) + + if ((cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript)) { // cancel our script if (scriptId != -1 && CScriptInvocationManager::GetInstance().IsRunning(scriptId)) { diff --git a/xbmc/guilib/GUIDialog.cpp b/xbmc/guilib/GUIDialog.cpp index d158af2bbb..24ffe8574f 100644 --- a/xbmc/guilib/GUIDialog.cpp +++ b/xbmc/guilib/GUIDialog.cpp @@ -242,3 +242,8 @@ void CGUIDialog::CancelAutoClose(void) { m_autoClosing = false; } + +void CGUIDialog::ProcessRenderLoop(bool renderOnly) +{ + g_windowManager.ProcessRenderLoop(renderOnly); +} diff --git a/xbmc/guilib/GUIDialog.h b/xbmc/guilib/GUIDialog.h index 06aa718b1a..5142bc7bc1 100644 --- a/xbmc/guilib/GUIDialog.h +++ b/xbmc/guilib/GUIDialog.h @@ -76,6 +76,8 @@ protected: virtual void Open_Internal(bool bProcessRenderLoop, const std::string ¶m = ""); virtual void OnDeinitWindow(int nextWindowID); + void ProcessRenderLoop(bool renderOnly = false); + bool m_wasRunning; ///< \brief true if we were running during the last DoProcess() bool m_autoClosing; bool m_enableSound; diff --git a/xbmc/guilib/GUIWindowManager.h b/xbmc/guilib/GUIWindowManager.h index 76be88d298..27741d8e02 100644 --- a/xbmc/guilib/GUIWindowManager.h +++ b/xbmc/guilib/GUIWindowManager.h @@ -40,6 +40,8 @@ #include "utils/GlobalsHandling.h" class CGUIDialog; +class CGUIMediaWindow; + enum class DialogModalityType; namespace KODI @@ -58,6 +60,8 @@ namespace KODI */ class CGUIWindowManager : public KODI::MESSAGING::IMessageTarget { + friend CGUIDialog; + friend CGUIMediaWindow; public: CGUIWindowManager(void); virtual ~CGUIWindowManager(void); @@ -140,7 +144,6 @@ public: bool DestroyWindows(); CGUIWindow* GetWindow(int id) const; - void ProcessRenderLoop(bool renderOnly = false); void SetCallback(IWindowManagerCallback& callback); void DeInitialize(); @@ -204,6 +207,8 @@ private: */ void ActivateWindow_Internal(int windowID, const std::vector ¶ms, bool swappingWindows, bool force = false); + void ProcessRenderLoop(bool renderOnly = false); + typedef std::map WindowMap; WindowMap m_mapWindows; std::vector m_vecCustomWindows; diff --git a/xbmc/network/upnp/UPnPPlayer.cpp b/xbmc/network/upnp/UPnPPlayer.cpp index 760e250a24..e0adea445d 100644 --- a/xbmc/network/upnp/UPnPPlayer.cpp +++ b/xbmc/network/upnp/UPnPPlayer.cpp @@ -193,25 +193,10 @@ static NPT_Result WaitOnEvent(CEvent& event, XbmcThreads::EndTime& timeout, CGUI if(event.WaitMSec(0)) return NPT_SUCCESS; - if(dialog == NULL) { - dialog = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY); - dialog->Open(); - } - - g_windowManager.ProcessRenderLoop(false); - - do { - if(event.WaitMSec(100)) - return NPT_SUCCESS; - - g_windowManager.ProcessRenderLoop(false); + if (!CGUIDialogBusy::WaitOnEvent(event)) + return NPT_FAILURE; - if(dialog->IsCanceled()) - return NPT_FAILURE; - - } while(!timeout.IsTimePast()); - - return NPT_FAILURE; + return NPT_SUCCESS; } int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options, CGUIDialogBusy*& dialog, XbmcThreads::EndTime& timeout) diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.cpp b/xbmc/pvr/windows/GUIWindowPVRBase.cpp index 988f762d33..58fac2fca3 100644 --- a/xbmc/pvr/windows/GUIWindowPVRBase.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRBase.cpp @@ -141,37 +141,7 @@ void CGUIWindowPVRBase::OnInitWindow(void) { if (!g_PVRManager.IsStarted() || !g_PVRClients->HasCreatedClients()) { - // wait until the PVR manager has been started - CGUIDialogProgress* dialog = static_cast(g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS)); - if (dialog) - { - dialog->SetHeading(CVariant{19235}); - dialog->SetText(CVariant{19045}); - dialog->ShowProgressBar(false); - dialog->Open(); - - // do not block the gfx context while waiting - CSingleExit exit(g_graphicsContext); - - CEvent event(true); - while(!event.WaitMSec(1)) - { - if (g_PVRManager.IsStarted() && g_PVRClients->HasCreatedClients()) - event.Set(); - - if (dialog->IsCanceled()) - { - // return to previous window if canceled - dialog->Close(); - g_windowManager.PreviousWindow(); - return; - } - - g_windowManager.ProcessRenderLoop(false); - } - - dialog->Close(); - } + return; } { diff --git a/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp index f4873c2ba7..3ed99ad24c 100644 --- a/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp +++ b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp @@ -730,7 +730,7 @@ void CGUIDialogAudioDSPManager::Update() m_availableItems[iModeType]->Add(pItem); } } - g_windowManager.ProcessRenderLoop(false); + ProcessRenderLoop(false); } m_availableItems[iModeType]->Sort(SortByLabel, SortOrderAscending); @@ -850,7 +850,7 @@ bool CGUIDialogAudioDSPManager::UpdateDatabase(CGUIDialogBusy* pDlgBusy) } } - g_windowManager.ProcessRenderLoop(false); + ProcessRenderLoop(false); } for (int iListPtr = 0; iListPtr < m_availableItems[i]->Size(); iListPtr++) @@ -883,7 +883,7 @@ bool CGUIDialogAudioDSPManager::UpdateDatabase(CGUIDialogBusy* pDlgBusy) } } - g_windowManager.ProcessRenderLoop(false); + ProcessRenderLoop(false); } } db.Close(); diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index 5360581194..36b3d8163f 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -2002,3 +2002,8 @@ std::string CGUIMediaWindow::RemoveParameterFromPath(const std::string &strDirec return strDirectory; } + +void CGUIMediaWindow::ProcessRenderLoop(bool renderOnly) +{ + g_windowManager.ProcessRenderLoop(renderOnly); +} diff --git a/xbmc/windows/GUIMediaWindow.h b/xbmc/windows/GUIMediaWindow.h index 738fae4ee4..b1eb511624 100644 --- a/xbmc/windows/GUIMediaWindow.h +++ b/xbmc/windows/GUIMediaWindow.h @@ -179,6 +179,8 @@ protected: */ static std::string RemoveParameterFromPath(const std::string &strDirectory, const std::string &strParameter); + void ProcessRenderLoop(bool renderOnly = false); + XFILE::CVirtualDirectory m_rootDir; CGUIViewControl m_viewControl; -- cgit v1.2.3 From ff9dc0be8121c30f7be09a44029baca83bcb9f6d Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Fri, 22 Apr 2016 18:00:27 +0200 Subject: guilib: drop CGUIDialogProgress::ProgressKeys --- xbmc/dialogs/GUIDialogProgress.cpp | 8 -------- xbmc/dialogs/GUIDialogProgress.h | 1 - 2 files changed, 9 deletions(-) diff --git a/xbmc/dialogs/GUIDialogProgress.cpp b/xbmc/dialogs/GUIDialogProgress.cpp index af54e49fbf..d405c81649 100644 --- a/xbmc/dialogs/GUIDialogProgress.cpp +++ b/xbmc/dialogs/GUIDialogProgress.cpp @@ -89,14 +89,6 @@ void CGUIDialogProgress::Progress() } } -void CGUIDialogProgress::ProgressKeys() -{ - if (m_active) - { - g_application.FrameMove(true); - } -} - bool CGUIDialogProgress::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) diff --git a/xbmc/dialogs/GUIDialogProgress.h b/xbmc/dialogs/GUIDialogProgress.h index a654f92043..a9f0702326 100644 --- a/xbmc/dialogs/GUIDialogProgress.h +++ b/xbmc/dialogs/GUIDialogProgress.h @@ -35,7 +35,6 @@ public: virtual bool OnBack(int actionID); virtual void OnWindowLoaded(); void Progress(); - void ProgressKeys(); bool IsCanceled() const { return m_bCanceled; } void SetPercentage(int iPercentage); int GetPercentage() const { return m_percentage; }; -- cgit v1.2.3 From 0491dced6a9846983d2887ecce1970c57e791b21 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sat, 30 Apr 2016 21:39:23 +0200 Subject: iOS: adapt iOS keyboard to changes in ProcessRenderLoop --- Kodi.xcodeproj/project.pbxproj | 8 +++ project/VS2010Express/XBMC.vcxproj | 2 + project/VS2010Express/XBMC.vcxproj.filters | 6 ++ xbmc/dialogs/CMakeLists.txt | 2 + xbmc/dialogs/GUIDialogKeyboardTouch.cpp | 99 +++++++++++++++++++++++++++++ xbmc/dialogs/GUIDialogKeyboardTouch.h | 49 ++++++++++++++ xbmc/dialogs/Makefile | 1 + xbmc/guilib/GUIKeyboardFactory.cpp | 19 ++---- xbmc/guilib/GUIWindowManager.cpp | 3 + xbmc/guilib/WindowIDs.h | 1 + xbmc/platform/darwin/ios/IOSKeyboard.h | 2 +- xbmc/platform/darwin/ios/IOSKeyboard.mm | 2 +- xbmc/platform/darwin/ios/IOSKeyboardView.mm | 8 +-- 13 files changed, 179 insertions(+), 23 deletions(-) create mode 100644 xbmc/dialogs/GUIDialogKeyboardTouch.cpp create mode 100644 xbmc/dialogs/GUIDialogKeyboardTouch.h diff --git a/Kodi.xcodeproj/project.pbxproj b/Kodi.xcodeproj/project.pbxproj index 3d25c1758e..0fbe231070 100644 --- a/Kodi.xcodeproj/project.pbxproj +++ b/Kodi.xcodeproj/project.pbxproj @@ -685,6 +685,8 @@ 7CE3FB8D1C9D3CCA00366A4C /* ServiceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE3FB8A1C9D3CCA00366A4C /* ServiceManager.cpp */; }; 7CE3FB901C9D40EA00366A4C /* ServiceBroker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE3FB8E1C9D40EA00366A4C /* ServiceBroker.cpp */; }; 7CE3FB911C9D40EA00366A4C /* ServiceBroker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE3FB8E1C9D40EA00366A4C /* ServiceBroker.cpp */; }; + 7CE514AA1CD5154A0046BC5C /* GUIDialogKeyboardTouch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE514A81CD5154A0046BC5C /* GUIDialogKeyboardTouch.cpp */; }; + 7CE514AB1CD5154A0046BC5C /* GUIDialogKeyboardTouch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE514A81CD5154A0046BC5C /* GUIDialogKeyboardTouch.cpp */; }; 7CEBD8A80F33A0D800CAF6AD /* SpecialProtocolDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CEBD8A60F33A0D800CAF6AD /* SpecialProtocolDirectory.cpp */; }; 7CED59391CD340460093F573 /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7CED59381CD340460093F573 /* VideoToolbox.framework */; }; 7CED593A1CD340460093F573 /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7CED59381CD340460093F573 /* VideoToolbox.framework */; }; @@ -3398,6 +3400,8 @@ 7CE3FB8B1C9D3CCA00366A4C /* ServiceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = ServiceManager.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 7CE3FB8E1C9D40EA00366A4C /* ServiceBroker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceBroker.cpp; sourceTree = ""; }; 7CE3FB8F1C9D40EA00366A4C /* ServiceBroker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceBroker.h; sourceTree = ""; }; + 7CE514A81CD5154A0046BC5C /* GUIDialogKeyboardTouch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIDialogKeyboardTouch.cpp; sourceTree = ""; }; + 7CE514A91CD5154A0046BC5C /* GUIDialogKeyboardTouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDialogKeyboardTouch.h; sourceTree = ""; }; 7CEBD8A60F33A0D800CAF6AD /* SpecialProtocolDirectory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpecialProtocolDirectory.cpp; sourceTree = ""; }; 7CEBD8A70F33A0D800CAF6AD /* SpecialProtocolDirectory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpecialProtocolDirectory.h; sourceTree = ""; }; 7CED59381CD340460093F573 /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; }; @@ -5730,6 +5734,8 @@ E38A06CD0D95AA5500FF8227 /* GUIDialogKaiToast.h */, DF830D0A15BB260C00602BE6 /* GUIDialogKeyboardGeneric.cpp */, DF830D0B15BB260C00602BE6 /* GUIDialogKeyboardGeneric.h */, + 7CE514A81CD5154A0046BC5C /* GUIDialogKeyboardTouch.cpp */, + 7CE514A91CD5154A0046BC5C /* GUIDialogKeyboardTouch.h */, 36A95DA31624894400727135 /* GUIDialogMediaFilter.cpp */, 36A95DA41624894400727135 /* GUIDialogMediaFilter.h */, E38E17B80D25F9FA00618676 /* GUIDialogMediaSource.cpp */, @@ -9648,6 +9654,7 @@ E38E1F5A0D25F9FD00618676 /* emu_kernel32.cpp in Sources */, E38E1F5C0D25F9FD00618676 /* emu_msvcrt.cpp in Sources */, E38E1F6F0D25F9FD00618676 /* EmuFileWrapper.cpp in Sources */, + 7CE514AA1CD5154A0046BC5C /* GUIDialogKeyboardTouch.cpp in Sources */, E38E1F710D25F9FD00618676 /* wrapper.c in Sources */, E38E1F720D25F9FD00618676 /* ldt_keeper.c in Sources */, E38E1F730D25F9FD00618676 /* LibraryLoader.cpp in Sources */, @@ -10922,6 +10929,7 @@ E4991213174E5D5A00741B6D /* PAPlayer.cpp in Sources */, E499121B174E5D5A00741B6D /* PlayerCoreFactory.cpp in Sources */, E499121C174E5D5A00741B6D /* PlayerSelectionRule.cpp in Sources */, + 7CE514AB1CD5154A0046BC5C /* GUIDialogKeyboardTouch.cpp in Sources */, E499121D174E5D5A00741B6D /* ConvolutionKernels.cpp in Sources */, E499121E174E5D5A00741B6D /* VideoFilterShader.cpp in Sources */, E499121F174E5D5A00741B6D /* YUV2RGBShader.cpp in Sources */, diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index 560b852f7f..780b6029fb 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -334,6 +334,7 @@ copy "..\Win32BuildSetup\dependencies\python27.dll" "$(TargetDir)" + @@ -1089,6 +1090,7 @@ copy "..\Win32BuildSetup\dependencies\python27.dll" "$(TargetDir)" + diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index 4f17fd1ee9..43758b2252 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -3462,6 +3462,9 @@ epg + + dialogs + @@ -6723,6 +6726,9 @@ epg + + dialogs + diff --git a/xbmc/dialogs/CMakeLists.txt b/xbmc/dialogs/CMakeLists.txt index e780a89dcd..abdd6ee50e 100644 --- a/xbmc/dialogs/CMakeLists.txt +++ b/xbmc/dialogs/CMakeLists.txt @@ -9,6 +9,7 @@ set(SOURCES GUIDialogBoxBase.cpp GUIDialogGamepad.cpp GUIDialogKaiToast.cpp GUIDialogKeyboardGeneric.cpp + GUIDialogKeyboardTouch.cpp GUIDialogMediaFilter.cpp GUIDialogMediaSource.cpp GUIDialogNumeric.cpp @@ -38,6 +39,7 @@ set(HEADERS GUIDialogBoxBase.h GUIDialogGamepad.h GUIDialogKaiToast.h GUIDialogKeyboardGeneric.h + GUIDialogKeyboardTouch.h GUIDialogMediaFilter.h GUIDialogMediaSource.h GUIDialogNumeric.h diff --git a/xbmc/dialogs/GUIDialogKeyboardTouch.cpp b/xbmc/dialogs/GUIDialogKeyboardTouch.cpp new file mode 100644 index 0000000000..004c847e61 --- /dev/null +++ b/xbmc/dialogs/GUIDialogKeyboardTouch.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2012-2016 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ + +#include "GUIDialogKeyboardTouch.h" +#if defined(TARGET_DARWIN_IOS) +#include "platform/darwin/ios/IOSKeyboard.h" +#endif + +CGUIDialogKeyboardTouch::CGUIDialogKeyboardTouch() +: CGUIDialog(WINDOW_DIALOG_KEYBOARD_TOUCH, "") +, CGUIKeyboard() +, CThread("keyboard") +, m_pCharCallback(NULL) +{ +} + +bool CGUIDialogKeyboardTouch::ShowAndGetInput(char_callback_t pCallback, const std::string &initialString, std::string &typedString, const std::string &heading, bool bHiddenInput) +{ +#if defined(TARGET_DARWIN_IOS) + m_keyboard.reset(new CIOSKeyboard()); +#endif + + if (!m_keyboard) + return false; + + m_pCharCallback = pCallback; + m_initialString = initialString; + m_typedString = typedString; + m_heading = heading; + m_bHiddenInput = bHiddenInput; + + m_confirmed = false; + Initialize(); + Open(); + + m_keyboard.reset(); + + if (m_confirmed) + { + typedString = m_typedString; + return true; + } + + return false; +} + +bool CGUIDialogKeyboardTouch::SetTextToKeyboard(const std::string &text, bool closeKeyboard) +{ + if (m_keyboard) + return m_keyboard->SetTextToKeyboard(text, closeKeyboard); + + return false; +} + +void CGUIDialogKeyboardTouch::Cancel() +{ + if (m_keyboard) + m_keyboard->Cancel(); + return; +} + +int CGUIDialogKeyboardTouch::GetWindowId() const +{ + return GetID(); +} + +void CGUIDialogKeyboardTouch::OnInitWindow() +{ + CGUIDialog::OnInitWindow(); + m_windowLoaded = true; + m_active = true; + Create(); +} + +void CGUIDialogKeyboardTouch::Process() +{ + if (m_keyboard) + { + m_confirmed = m_keyboard->ShowAndGetInput(m_pCharCallback, m_initialString, m_typedString, m_heading, m_bHiddenInput); + } + Close(); +} \ No newline at end of file diff --git a/xbmc/dialogs/GUIDialogKeyboardTouch.h b/xbmc/dialogs/GUIDialogKeyboardTouch.h new file mode 100644 index 0000000000..e1cb5d83f1 --- /dev/null +++ b/xbmc/dialogs/GUIDialogKeyboardTouch.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ +#pragma once + +#include "guilib/GUIDialog.h" +#include "guilib/GUIKeyboard.h" +#include +#include + +class CGUIDialogKeyboardTouch : public CGUIDialog, public CGUIKeyboard, public CThread +{ +public: + CGUIDialogKeyboardTouch(); + bool ShowAndGetInput(char_callback_t pCallback, const std::string &initialString, std::string &typedString, const std::string &heading, bool bHiddenInput) override; + bool SetTextToKeyboard(const std::string &text, bool closeKeyboard = false) override; + void Cancel() override; + int GetWindowId() const override; + +protected: + void OnInitWindow() override; + void Process() override; + + char_callback_t m_pCharCallback; + std::string m_initialString; + std::string m_typedString; + std::string m_heading; + bool m_bHiddenInput; + + std::unique_ptr m_keyboard; + std::atomic_bool m_active; + bool m_confirmed; +}; diff --git a/xbmc/dialogs/Makefile b/xbmc/dialogs/Makefile index 941847bb0a..5bb886970e 100644 --- a/xbmc/dialogs/Makefile +++ b/xbmc/dialogs/Makefile @@ -9,6 +9,7 @@ SRCS=GUIDialogBoxBase.cpp \ GUIDialogGamepad.cpp \ GUIDialogKaiToast.cpp \ GUIDialogKeyboardGeneric.cpp \ + GUIDialogKeyboardTouch.cpp \ GUIDialogMediaFilter.cpp \ GUIDialogMediaSource.cpp \ GUIDialogNumeric.cpp \ diff --git a/xbmc/guilib/GUIKeyboardFactory.cpp b/xbmc/guilib/GUIKeyboardFactory.cpp index 2a0c532644..4c6ea497f0 100644 --- a/xbmc/guilib/GUIKeyboardFactory.cpp +++ b/xbmc/guilib/GUIKeyboardFactory.cpp @@ -32,8 +32,7 @@ #include "dialogs/GUIDialogKeyboardGeneric.h" #if defined(TARGET_DARWIN_IOS) -#include "platform/darwin/ios/IOSKeyboard.h" -#include "windowing/WindowingFactory.h" +#include "dialogs/GUIDialogKeyboardTouch.h" #endif using namespace KODI::MESSAGING; @@ -88,7 +87,6 @@ bool CGUIKeyboardFactory::ShowAndGetInput(std::string& aTextString, CVariant hea { bool confirmed = false; CGUIKeyboard *kb = NULL; - bool needsFreeing = true; //heading can be a string or a localization id std::string headingStr; if (heading.isString()) @@ -97,24 +95,17 @@ bool CGUIKeyboardFactory::ShowAndGetInput(std::string& aTextString, CVariant hea headingStr = g_localizeStrings.Get((uint32_t)heading.asInteger()); #if defined(TARGET_DARWIN_IOS) - if (g_Windowing.GetCurrentScreen() == 0) - kb = new CIOSKeyboard(); + kb = (CGUIDialogKeyboardTouch*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD_TOUCH); +#else + kb = (CGUIDialogKeyboardGeneric*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD); #endif - if(!kb) - { - kb = (CGUIDialogKeyboardGeneric*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD); - needsFreeing = false; - } - - if(kb) + if (kb) { g_activedKeyboard = kb; kb->startAutoCloseTimer(autoCloseMs); confirmed = kb->ShowAndGetInput(keyTypedCB, aTextString, aTextString, headingStr, hiddenInput); g_activedKeyboard = NULL; - if(needsFreeing) - delete kb; } if (confirmed) diff --git a/xbmc/guilib/GUIWindowManager.cpp b/xbmc/guilib/GUIWindowManager.cpp index 309064339e..788558e0dc 100644 --- a/xbmc/guilib/GUIWindowManager.cpp +++ b/xbmc/guilib/GUIWindowManager.cpp @@ -87,6 +87,7 @@ #include "settings/dialogs/GUIDialogContentSettings.h" #include "dialogs/GUIDialogBusy.h" #include "dialogs/GUIDialogKeyboardGeneric.h" +#include "dialogs/GUIDialogKeyboardTouch.h" #include "dialogs/GUIDialogYesNo.h" #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogProgress.h" @@ -199,6 +200,7 @@ void CGUIWindowManager::CreateWindows() Add(new CGUIDialogProgress); Add(new CGUIDialogExtendedProgressBar); Add(new CGUIDialogKeyboardGeneric); + Add(new CGUIDialogKeyboardTouch); Add(new CGUIDialogVolumeBar); Add(new CGUIDialogSeekBar); Add(new CGUIDialogSubMenu); @@ -320,6 +322,7 @@ bool CGUIWindowManager::DestroyWindows() Delete(WINDOW_DIALOG_SELECT); Delete(WINDOW_DIALOG_OK); Delete(WINDOW_DIALOG_KEYBOARD); + Delete(WINDOW_DIALOG_KEYBOARD_TOUCH); Delete(WINDOW_FULLSCREEN_VIDEO); Delete(WINDOW_DIALOG_PROFILE_SETTINGS); Delete(WINDOW_DIALOG_LOCK_SETTINGS); diff --git a/xbmc/guilib/WindowIDs.h b/xbmc/guilib/WindowIDs.h index 8ad8eb8a17..b5c76da753 100644 --- a/xbmc/guilib/WindowIDs.h +++ b/xbmc/guilib/WindowIDs.h @@ -104,6 +104,7 @@ #define WINDOW_DIALOG_SUBTITLES 10153 #define WINDOW_DIALOG_AUDIO_DSP_MANAGER 10154 #define WINDOW_DIALOG_AUDIO_DSP_OSD_SETTINGS 10155 +#define WINDOW_DIALOG_KEYBOARD_TOUCH 10156 #define WINDOW_MUSIC_PLAYLIST 10500 #define WINDOW_MUSIC_FILES 10501 diff --git a/xbmc/platform/darwin/ios/IOSKeyboard.h b/xbmc/platform/darwin/ios/IOSKeyboard.h index c870a75002..9077006cfb 100644 --- a/xbmc/platform/darwin/ios/IOSKeyboard.h +++ b/xbmc/platform/darwin/ios/IOSKeyboard.h @@ -28,7 +28,7 @@ class CIOSKeyboard : public CGUIKeyboard virtual bool ShowAndGetInput(char_callback_t pCallback, const std::string &initialString, std::string &typedString, const std::string &heading, bool bHiddenInput); virtual void Cancel(); void fireCallback(const std::string &str); - void invalidateCallback(){m_pCharCallback = NULL;} + void invalidateCallback() {m_pCharCallback = NULL;} virtual bool SetTextToKeyboard(const std::string &text, bool closeKeyboard = false); private: diff --git a/xbmc/platform/darwin/ios/IOSKeyboard.mm b/xbmc/platform/darwin/ios/IOSKeyboard.mm index 93e6e0b601..9b8fe77a66 100644 --- a/xbmc/platform/darwin/ios/IOSKeyboard.mm +++ b/xbmc/platform/darwin/ios/IOSKeyboard.mm @@ -66,7 +66,7 @@ bool CIOSKeyboard::ShowAndGetInput(char_callback_t pCallback, const std::string if (!m_bCanceled) { [g_pIosKeyboard setCancelFlag:&m_bCanceled]; - [g_pIosKeyboard activate]; // blocks and loops our application loop (like a modal dialog) + [g_pIosKeyboard activate]; // blocks and shows keyboard // user is done - get resulted text and confirmation confirmed = g_pIosKeyboard.isConfirmed; if (confirmed) diff --git a/xbmc/platform/darwin/ios/IOSKeyboardView.mm b/xbmc/platform/darwin/ios/IOSKeyboardView.mm index 4f1c9389d0..725d7d9d59 100644 --- a/xbmc/platform/darwin/ios/IOSKeyboardView.mm +++ b/xbmc/platform/darwin/ios/IOSKeyboardView.mm @@ -18,7 +18,6 @@ * */ #define BOOL XBMC_BOOL -#include "guilib/GUIWindowManager.h" #include "guilib/GUIKeyboardFactory.h" #include "threads/Event.h" #include "Application.h" @@ -245,19 +244,14 @@ static CEvent keyboardFinishedEvent; return; } - // emulate a modale dialog here // we are waiting on the user finishing the keyboard - // and have to process our app while doing that - // basicall what our GUIDialog does if called modal - while(!keyboardFinishedEvent.WaitMSec(500) && !g_application.m_bStop) + while(!keyboardFinishedEvent.WaitMSec(500)) { if (NULL != _canceled && *_canceled) { [self deactivate]; _canceled = NULL; } - // if we are not in xbmc main thread, ProcessRenderLoop() is nop. - g_windowManager.ProcessRenderLoop(); } } -- cgit v1.2.3