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