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

Method CScreenXLib

Service/ScreenXLib.cpp:43–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43CScreenXLib::CScreenXLib(QObject *parent) : CScreen(parent)
44{
45 QString szErr;
46 Display* dsp = NULL;
47 dsp = XOpenDisplay(NULL);/* Connect to a local display */
48 if(NULL == dsp)
49 {
50 szErr = "Cannot connect to local display";
51 qCritical(LogScreen) << szErr;
52 throw std::runtime_error(szErr.toStdString().c_str());
53 }
54 do{
55 Visual* vis = DefaultVisual(dsp, DefaultScreen(dsp));
56 if (vis->c_class != TrueColor) {
57 szErr = "pseudocolour not supported";
58 qCritical(LogScreen) << szErr;
59 break;
60 }
61
62 m_pImage = XCreateImage(dsp, vis, DefaultDepth(dsp, DefaultScreen(dsp)),
63 ZPixmap, 0, 0, Width(), Height(),
64 BitmapPad(dsp), 0);
65 m_pImage->data = (char *)malloc(m_pImage->bytes_per_line * m_pImage->height);
66 if (m_pImage->data == NULL) {
67 szErr = "malloc() failed";
68 qCritical(LogScreen) << szErr;
69 }
70 } while(0);
71
72 XCloseDisplay(dsp);
73 if(!szErr.isEmpty())
74 throw std::runtime_error(szErr.toStdString().c_str());
75
76 m_Screen = QImage((uchar*)m_pImage->data, Width(), Height(), GetFormat(m_pImage));
77}
78
79CScreenXLib::~CScreenXLib()
80{

Callers

nothing calls this directly

Calls 2

GetFormatFunction · 0.85
isEmptyMethod · 0.45

Tested by

no test coverage detected