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.
9 #include "GUIWindowPointer.h"
11 #include "ServiceBroker.h"
12 #include "input/InputManager.h"
13 #include "input/mouse/MouseStat.h"
14 #include "windowing/WinSystem.h"
18 CGUIWindowPointer::CGUIWindowPointer(void)
19 : CGUIDialog(WINDOW_DIALOG_POINTER
, "Pointer.xml", DialogModalityType::MODELESS
)
22 m_loadType
= LOAD_ON_GUI_INIT
;
23 m_needsScaling
= false;
25 m_renderOrder
= RENDER_ORDER_WINDOW_POINTER
;
28 CGUIWindowPointer::~CGUIWindowPointer(void) = default;
30 void CGUIWindowPointer::SetPointer(int pointer
)
32 if (m_pointer
== pointer
) return;
33 // set the new pointer visible
34 CGUIControl
*pControl
= GetControl(pointer
);
37 pControl
->SetVisible(true);
38 // disable the old pointer
39 pControl
= GetControl(m_pointer
);
40 if (pControl
) pControl
->SetVisible(false);
41 // set pointer to the new one
46 void CGUIWindowPointer::UpdateVisibility()
48 if(CServiceBroker::GetWinSystem()->HasCursor())
50 if (CServiceBroker::GetInputManager().IsMouseActive())
61 void CGUIWindowPointer::OnWindowLoaded()
62 { // set all our pointer images invisible
63 for (iControls i
= m_children
.begin();i
!= m_children
.end(); ++i
)
65 CGUIControl
* pControl
= *i
;
66 pControl
->SetVisible(false);
68 CGUIWindow::OnWindowLoaded();
69 DynamicResourceAlloc(false);
71 m_renderOrder
= RENDER_ORDER_WINDOW_POINTER
;
74 void CGUIWindowPointer::Process(unsigned int currentTime
, CDirtyRegionList
&dirtyregions
)
76 bool active
= CServiceBroker::GetInputManager().IsMouseActive();
77 if (active
!= m_active
)
82 MousePosition pos
= CServiceBroker::GetInputManager().GetMousePosition();
83 SetPosition((float)pos
.x
, (float)pos
.y
);
84 SetPointer(CServiceBroker::GetInputManager().GetMouseState());
85 return CGUIWindow::Process(currentTime
, dirtyregions
);