| 1 |
/* |
| 2 |
* Copyright (C) 2005-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "interfaces/IAnnouncer.h" |
| 12 |
#include "windowing/WinEvents.h" |
| 13 |
|
| 14 |
#include <concurrent_queue.h> |
| 15 |
#include <winrt/Windows.Media.h> |
| 16 |
|
| 17 |
class CRemoteControlXbox; |
| 18 |
|
| 19 |
class CWinEventsWin10 : public IWinEvents |
| 20 |
, public ANNOUNCEMENT::IAnnouncer |
| 21 |
{ |
| 22 |
public: |
| 23 |
CWinEventsWin10(); |
| 24 |
virtual ~CWinEventsWin10(); |
| 25 |
|
| 26 |
void MessagePush(XBMC_Event *newEvent); |
| 27 |
bool MessagePump() override; |
| 28 |
virtual size_t GetQueueSize(); |
| 29 |
|
| 30 |
// initialization |
| 31 |
void InitEventHandlers(const winrt::Windows::UI::Core::CoreWindow&); |
| 32 |
static void InitOSKeymap(void); |
| 33 |
|
| 34 |
// Window event handlers. |
| 35 |
void OnWindowSizeChanged(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::UI::Core::WindowSizeChangedEventArgs&); |
| 36 |
void OnWindowResizeStarted(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::Foundation::IInspectable&); |
| 37 |
void OnWindowResizeCompleted(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::Foundation::IInspectable&); |
| 38 |
void OnWindowClosed(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::UI::Core::CoreWindowEventArgs&); |
| 39 |
static void OnWindowActivationChanged(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::UI::Core::WindowActivatedEventArgs&); |
| 40 |
static void OnVisibilityChanged(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::UI::Core::VisibilityChangedEventArgs&); |
| 41 |
// touch mouse and pen |
| 42 |
void OnPointerPressed(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::UI::Core::PointerEventArgs&); |
| 43 |
void OnPointerMoved(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::UI::Core::PointerEventArgs&); |
| 44 |
void OnPointerReleased(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::UI::Core::PointerEventArgs&); |
| 45 |
void OnPointerExited(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::UI::Core::PointerEventArgs&); |
| 46 |
void OnPointerWheelChanged(const winrt::Windows::UI::Core::CoreWindow&, const winrt::Windows::UI::Core::PointerEventArgs&); |
| 47 |
// keyboard |
| 48 |
void OnAcceleratorKeyActivated(const winrt::Windows::UI::Core::CoreDispatcher&, const winrt::Windows::UI::Core::AcceleratorKeyEventArgs&); |
| 49 |
|
| 50 |
// DisplayInformation event handlers. |
| 51 |
static void OnDpiChanged(const winrt::Windows::Graphics::Display::DisplayInformation&, const winrt::Windows::Foundation::IInspectable&); |
| 52 |
static void OnOrientationChanged(const winrt::Windows::Graphics::Display::DisplayInformation&, const winrt::Windows::Foundation::IInspectable&); |
| 53 |
static void OnDisplayContentsInvalidated(const winrt::Windows::Graphics::Display::DisplayInformation&, const winrt::Windows::Foundation::IInspectable&); |
| 54 |
// system |
| 55 |
static void OnBackRequested(const winrt::Windows::Foundation::IInspectable&, const winrt::Windows::UI::Core::BackRequestedEventArgs&); |
| 56 |
// system media handlers |
| 57 |
static void OnSystemMediaButtonPressed(const winrt::Windows::Media::SystemMediaTransportControls& |
| 58 |
, const winrt::Windows::Media::SystemMediaTransportControlsButtonPressedEventArgs&); |
| 59 |
// IAnnouncer overrides |
| 60 |
void Announce(ANNOUNCEMENT::AnnouncementFlag flag, |
| 61 |
const std::string& sender, |
| 62 |
const std::string& message, |
| 63 |
const CVariant& data) override; |
| 64 |
|
| 65 |
private: |
| 66 |
friend class CWinSystemWin10; |
| 67 |
|
| 68 |
void OnResize(float width, float height); |
| 69 |
void UpdateWindowSize(); |
| 70 |
void Kodi_KeyEvent(unsigned int vkey, uint32_t scancode, unsigned keycode, bool isDown); |
| 71 |
void HandleWindowSizeChanged(); |
| 72 |
|
| 73 |
Concurrency::concurrent_queue<XBMC_Event> m_events; |
| 74 |
winrt::Windows::Media::SystemMediaTransportControls m_smtc{ nullptr }; |
| 75 |
bool m_bResized{ false }; |
| 76 |
bool m_bMoved{ false }; |
| 77 |
bool m_sizeChanging{ false }; |
| 78 |
float m_logicalWidth{ 0 }; |
| 79 |
float m_logicalHeight{ 0 }; |
| 80 |
float m_logicalPosX{ 0 }; |
| 81 |
float m_logicalPosY{ 0 }; |
| 82 |
std::unique_ptr<CRemoteControlXbox> m_remote; |
| 83 |
}; |