MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / Open

Method Open

Service/DisplayXLib.cpp:74–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74int CDisplayXLib::Open()
75{
76 int nRet = 0;
77 /* Connect to a local display.
78 * it defaults to the value of the DISPLAY environment variable. */
79 m_pDisplay = XOpenDisplay(NULL);
80 do{
81 if(!m_pDisplay)
82 {
83 nRet = -1;
84 }
85
86 if (strstr(ServerVendor(m_pDisplay), "X.Org")) {
87 int vendrel = VendorRelease(m_pDisplay);
88
89 QString version("X.Org version: ");
90 version += QString::number(vendrel / 10000000);
91 version += "." + QString::number((vendrel / 100000) % 100),
92 version += "." + QString::number((vendrel / 1000) % 100);
93 if (vendrel % 1000) {
94 version += "." + QString::number(vendrel % 1000);
95 }
96 qInfo(LogScreen) << version;
97 }
98
99 m_RootWindow = DefaultRootWindow(m_pDisplay); // RootWindow(dsp,0);/* Refer to the root window */
100 if(0 == m_RootWindow)
101 {
102 qCritical(LogScreen) << "cannot get root window";
103 nRet = -2;
104 break;
105 }
106 }while(0);
107
108 if(nRet)
109 {
110 Close();
111 return nRet;
112 }
113
114 // Initial QImage and XImage
115 Visual* vis = DefaultVisual(m_pDisplay, DefaultScreen(m_pDisplay));
116 if (vis && vis->c_class == TrueColor) {
117 m_pImage = XCreateImage(m_pDisplay, vis,
118 DefaultDepth(m_pDisplay, DefaultScreen(m_pDisplay)),
119 ZPixmap, 0, 0, Width(), Height(),
120 BitmapPad(m_pDisplay), 0);
121 if(m_pImage) {
122 m_pImage->data = (char *)malloc(m_pImage->bytes_per_line * m_pImage->height);
123 if (m_pImage->data) {
124 m_Format = GetFormat(m_pImage);
125 if(QImage::Format_Invalid != GetFormat()) {
126 m_Desktop = QImage((uchar*)m_pImage->data,
127 Width(), Height(), GetFormat());
128 //m_Desktop.fill(QColor(0,0,0,0));
129 }
130 }
131

Callers

nothing calls this directly

Calls 1

GetFormatFunction · 0.85

Tested by

no test coverage detected