[Test] Added tests for CUtil::SplitParams
[xbmc.git] / xbmc / windowing / osx / WinSystemOSX.h
blobc431d70cd9b81ba7307825b1d033601e73d72635
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 #pragma once
11 #include "threads/CriticalSection.h"
12 #include "threads/SystemClock.h"
13 #include "threads/Timer.h"
14 #include "windowing/WinSystem.h"
16 #include <memory>
17 #include <optional>
18 #include <string>
19 #include <vector>
21 typedef struct _CGLContextObject* CGLContextObj;
22 typedef struct CGRect NSRect;
23 class IDispResource;
24 class CWinEventsOSX;
25 #ifdef __OBJC__
26 @class NSWindowController;
27 @class NSWindow;
28 @class OSXGLView;
29 @class NSEvent;
30 #else
31 struct NSWindow;
32 struct OSXGLView;
33 struct NSEvent;
34 struct NSWindowController;
36 #endif
38 class CWinSystemOSX : public CWinSystemBase, public ITimerCallback
40 public:
41 CWinSystemOSX();
42 ~CWinSystemOSX() override;
44 struct ScreenResolution
46 bool interlaced{false};
47 size_t resWidth{0};
48 size_t resHeight{0};
49 size_t pixelWidth{0};
50 size_t pixelHeight{0};
51 double refreshrate{0.0};
54 // ITimerCallback interface
55 void OnTimeout() override;
57 // CWinSystemBase
58 bool InitWindowSystem() override;
59 bool DestroyWindowSystem() override;
60 bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override;
61 bool DestroyWindow() override;
62 bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) override;
63 bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override;
64 void UpdateResolutions() override;
65 bool Minimize() override;
66 bool Restore() override;
67 bool Hide() override;
68 bool HasCursor() override;
69 bool Show(bool raise = true) override;
70 unsigned int GetScreenId(const std::string& screen) override;
71 void MoveToScreen(unsigned int screenIdx) override;
72 void OnMove(int x, int y) override;
73 void OnChangeScreen(unsigned int screenIdx) override;
74 CGraphicContext& GetGfxContext() const override;
75 bool HasValidResolution() const;
77 std::string GetClipboardText() override;
79 void Register(IDispResource* resource) override;
80 void Unregister(IDispResource* resource) override;
82 std::unique_ptr<CVideoSync> GetVideoSync(CVideoReferenceClock* clock) override;
84 void WindowChangedScreen();
86 void AnnounceOnLostDevice();
87 void AnnounceOnResetDevice();
88 void HandleOnResetDevice();
89 void StartLostDeviceTimer();
90 void StopLostDeviceTimer();
92 int CheckDisplayChanging(uint32_t flags);
93 void SetFullscreenWillToggle(bool toggle) { m_fullscreenWillToggle = toggle; }
94 bool GetFullscreenWillToggle() { return m_fullscreenWillToggle; }
95 void SignalFullScreenStateChanged(bool fullscreenState);
97 CGLContextObj GetCGLContextObj();
99 std::vector<std::string> GetConnectedOutputs() override;
101 // winevents override
102 bool MessagePump() override;
104 NSRect GetWindowDimensions();
105 void enableInputEvents();
106 void disableInputEvents();
108 void signalMouseEntered();
109 void signalMouseExited();
110 void SendInputEvent(NSEvent* nsEvent);
112 protected:
113 std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl() override;
115 ScreenResolution GetScreenResolution(unsigned long screenIdx);
116 void EnableVSync(bool enable);
117 bool SwitchToVideoMode(RESOLUTION_INFO& res);
118 void FillInVideoModes();
119 bool FlushBuffer();
121 bool DestroyWindowInternal();
123 std::unique_ptr<CWinEventsOSX> m_winEvents;
125 std::string m_name;
126 NSWindow* m_appWindow;
127 OSXGLView* m_glView;
128 unsigned long m_lastDisplayNr;
129 double m_refreshRate;
131 CCriticalSection m_resourceSection;
132 std::vector<IDispResource*> m_resources;
133 CTimer m_lostDeviceTimer;
134 bool m_delayDispReset;
135 XbmcThreads::EndTime<> m_dispResetTimer;
136 bool m_fullscreenWillToggle;
137 bool m_hasCursor{false};
138 //! Set while moving the fullscreen window to another screen. Stores the target screen id.
139 std::optional<unsigned long> m_fullScreenMovingToScreen;
140 CCriticalSection m_critSection;
142 private:
143 NSWindowController* m_appWindowController;