kodi
WinSystemX11.h
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 "settings/lib/ISettingCallback.h"
12 #include "threads/CriticalSection.h"
13 #include "threads/SystemClock.h"
14 #include "utils/Stopwatch.h"
15 #include "windowing/WinSystem.h"
16 
17 #include <string>
18 #include <vector>
19 
20 #include <X11/Xlib.h>
21 #include <X11/Xutil.h>
22 
23 class IDispResource;
24 
25 namespace KODI
26 {
27 namespace WINDOWING
28 {
29 namespace X11
30 {
31 
32 class CWinEventsX11;
33 
35 {
36 public:
37  CWinSystemX11();
38  ~CWinSystemX11() override;
39 
40  const std::string GetName() override { return "x11"; }
41 
42  // CWinSystemBase
43  bool InitWindowSystem() override;
44  bool DestroyWindowSystem() override;
45  bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override;
46  bool DestroyWindow() override;
47  bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) override;
48  void FinishWindowResize(int newWidth, int newHeight) override;
49  bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override;
50  void UpdateResolutions() override;
51  void ShowOSMouse(bool show) override;
52 
53  void NotifyAppActiveChange(bool bActivated) override;
54  void NotifyAppFocusChange(bool bGaining) override;
55 
56  bool Minimize() override;
57  bool Restore() override;
58  bool Hide() override;
59  bool Show(bool raise = true) override;
60  void Register(IDispResource *resource) override;
61  void Unregister(IDispResource *resource) override;
62  bool HasCalibration(const RESOLUTION_INFO &resInfo) override;
63  bool UseLimitedColor() override;
64 
65  std::vector<std::string> GetConnectedOutputs() override;
66 
67  // Local to WinSystemX11 only
68  Display* GetDisplay() { return m_dpy; }
69  int GetScreen() { return m_screen; }
70  void NotifyXRREvent();
71  bool IsCurrentOutput(const std::string& output);
72  void RecreateWindow();
73  int GetCrtc() { return m_crtc; }
74 
75  // winevents override
76  bool MessagePump() override;
77 
78 protected:
79  std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl() override;
80 
81  virtual bool SetWindow(int width, int height, bool fullscreen, const std::string &output, int *winstate = NULL) = 0;
82  virtual XVisualInfo* GetVisual() = 0;
83 
84  void OnLostDevice();
85 
86  Window m_glWindow = 0, m_mainWindow = 0;
87  int m_screen = 0;
88  Display *m_dpy;
89  Cursor m_invisibleCursor = 0;
90  Pixmap m_icon;
91  bool m_bIsRotated;
92  bool m_bWasFullScreenBeforeMinimize;
93  bool m_minimized;
94  bool m_bIgnoreNextFocusMessage;
95  CCriticalSection m_resourceSection;
96  std::vector<IDispResource*> m_resources;
97  bool m_delayDispReset;
98  XbmcThreads::EndTime<> m_dispResetTimer;
99  std::string m_currentOutput;
100  std::string m_userOutput;
101  bool m_windowDirty;
102  bool m_bIsInternalXrr;
103  int m_MouseX, m_MouseY;
104  int m_crtc;
105  CWinEventsX11 *m_winEventsX11;
106 
107 private:
108  bool IsSuitableVisual(XVisualInfo *vInfo);
109  static int XErrorHandler(Display* dpy, XErrorEvent* error);
110  bool CreateIconPixmap();
111  bool HasWindowManager();
112  void UpdateCrtc();
113 };
114 
115 }
116 }
117 }
Definition: WinSystem.h:49
Definition: SystemClock.h:31
Definition: WinEventsX11.h:27
Definition: DispResource.h:14
Provide info of a resolution.
Definition: Resolution.h:66
Definition: AudioDecoder.h:18
Definition: WinSystemX11.h:34