xbmc
XRandR.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 <map>
12 #include <string>
13 #include <vector>
14 
15 class XMode
16 {
17 public:
18  XMode()
19  {
20  hz=0.0f;
21  isPreferred=false;
22  isCurrent=false;
23  w=h=0;
24  }
25  bool operator==(XMode& mode) const
26  {
27  if (id != mode.id)
28  return false;
29  if (name != mode.name)
30  return false;
31  if (hz != mode.hz)
32  return false;
33  if (isPreferred != mode.isPreferred)
34  return false;
35  if (isCurrent != mode.isCurrent)
36  return false;
37  if (w != mode.w)
38  return false;
39  if (h != mode.h)
40  return false;
41  return true;
42  }
43  bool IsInterlaced()
44  {
45  return name.back() == 'i';
46  }
47  std::string id;
48  std::string name;
49  float hz;
50  bool isPreferred;
51  bool isCurrent;
52  unsigned int w;
53  unsigned int h;
54 };
55 
56 class XOutput
57 {
58 public:
59  XOutput()
60  {
61  isConnected = false;
62  w = h = x = y = wmm = hmm = 0;
63  }
64  std::string name;
65  bool isConnected;
66  int screen;
67  int w;
68  int h;
69  int x;
70  int y;
71  int crtc;
72  int wmm;
73  int hmm;
74  std::vector<XMode> modes;
75  bool isRotated;
76 };
77 
78 class CXRandR
79 {
80 public:
81  explicit CXRandR(bool query=false);
82  bool Query(bool force=false, bool ignoreoff=true);
83  bool Query(bool force, int screennum, bool ignoreoff=true);
84  std::vector<XOutput> GetModes(void);
85  XMode GetCurrentMode(const std::string& outputName);
86  XMode GetPreferredMode(const std::string& outputName);
87  XOutput *GetOutput(const std::string& outputName);
88  bool SetMode(const XOutput& output, const XMode& mode);
89  void LoadCustomModeLinesToAllOutputs(void);
90  void SaveState();
91  void SetNumScreens(unsigned int num);
92  bool IsOutputConnected(const std::string& name);
93  bool TurnOffOutput(const std::string& name);
94  bool TurnOnOutput(const std::string& name);
95  int GetCrtc(int x, int y, float &hz);
96  //bool Has1080i();
97  //bool Has1080p();
98  //bool Has720p();
99  //bool Has480p();
100 
101 private:
102  bool m_bInit;
103  std::vector<XOutput> m_outputs;
104  std::string m_currentOutput;
105  std::string m_currentMode;
106  unsigned int m_numScreens;
107 };
108 
109 extern CXRandR g_xrandr;
Definition: XRandR.h:56
Definition: XRandR.h:78
Definition: XRandR.h:15