[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / application / AppInboundProtocol.cpp
blobce6e7f40dee0ffe9844c0282bcf1c5de26636ba5
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "AppInboundProtocol.h"
11 #include "ServiceBroker.h"
12 #include "application/Application.h"
13 #include "application/ApplicationComponents.h"
14 #include "application/ApplicationPowerHandling.h"
15 #include "guilib/GUIComponent.h"
16 #include "guilib/GUIWindowManager.h"
17 #include "input/InputManager.h"
18 #include "input/actions/Action.h"
19 #include "input/actions/ActionIDs.h"
20 #include "messaging/ApplicationMessenger.h"
21 #include "settings/AdvancedSettings.h"
22 #include "settings/DisplaySettings.h"
23 #include "settings/Settings.h"
24 #include "settings/SettingsComponent.h"
25 #include "threads/SingleLock.h"
27 CAppInboundProtocol::CAppInboundProtocol(CApplication &app) : m_pApp(app)
31 bool CAppInboundProtocol::OnEvent(const XBMC_Event& newEvent)
33 std::unique_lock<CCriticalSection> lock(m_portSection);
34 if (m_closed)
35 return false;
36 m_portEvents.push_back(newEvent);
37 return true;
40 void CAppInboundProtocol::Close()
42 std::unique_lock<CCriticalSection> lock(m_portSection);
43 m_closed = true;
46 void CAppInboundProtocol::SetRenderGUI(bool renderGUI)
48 auto& components = CServiceBroker::GetAppComponents();
49 const auto appPower = components.GetComponent<CApplicationPowerHandling>();
50 appPower->SetRenderGUI(renderGUI);
53 void CAppInboundProtocol::HandleEvents()
55 std::unique_lock<CCriticalSection> lock(m_portSection);
56 while (!m_portEvents.empty())
58 auto newEvent = m_portEvents.front();
59 m_portEvents.pop_front();
60 CSingleExit lock(m_portSection);
61 switch (newEvent.type)
63 case XBMC_QUIT:
64 if (!m_pApp.m_bStop)
65 CServiceBroker::GetAppMessenger()->PostMsg(TMSG_QUIT);
66 break;
67 case XBMC_VIDEORESIZE:
68 if (CServiceBroker::GetGUI()->GetWindowManager().Initialized())
70 if (!CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_fullScreen)
72 CServiceBroker::GetWinSystem()->GetGfxContext().ApplyWindowResize(newEvent.resize.w,
73 newEvent.resize.h);
75 const auto settings = CServiceBroker::GetSettingsComponent()->GetSettings();
76 settings->SetInt(CSettings::SETTING_WINDOW_WIDTH, newEvent.resize.w);
77 settings->SetInt(CSettings::SETTING_WINDOW_HEIGHT, newEvent.resize.h);
78 settings->Save();
80 else
82 const auto& res_info = CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP);
83 CServiceBroker::GetWinSystem()->ForceFullScreen(res_info);
86 break;
87 case XBMC_VIDEOMOVE:
89 CServiceBroker::GetWinSystem()->OnMove(newEvent.move.x, newEvent.move.y);
91 break;
92 case XBMC_MODECHANGE:
93 CServiceBroker::GetWinSystem()->GetGfxContext().ApplyModeChange(newEvent.mode.res);
94 break;
95 case XBMC_SCREENCHANGE:
96 CServiceBroker::GetWinSystem()->OnChangeScreen(newEvent.screen.screenIdx);
97 break;
98 case XBMC_USEREVENT:
99 CServiceBroker::GetAppMessenger()->PostMsg(static_cast<uint32_t>(newEvent.user.code));
100 break;
101 case XBMC_SETFOCUS:
103 // Reset the screensaver
104 const auto appPower = m_pApp.GetComponent<CApplicationPowerHandling>();
105 appPower->ResetScreenSaver();
106 appPower->WakeUpScreenSaverAndDPMS();
107 // Send a mouse motion event with no dx,dy for getting the current guiitem selected
108 m_pApp.OnAction(CAction(ACTION_MOUSE_MOVE, 0, static_cast<float>(newEvent.focus.x),
109 static_cast<float>(newEvent.focus.y), 0, 0));
110 break;
112 default:
113 CServiceBroker::GetInputManager().OnEvent(newEvent);