backends/x11: Simplify backend initialization

This commit is contained in:
Vlad Zahorodnii 2022-12-02 18:04:12 +02:00
parent b18a3b3625
commit 28baea1c29

View file

@ -176,18 +176,16 @@ X11WindowedBackend::~X11WindowedBackend()
bool X11WindowedBackend::initialize()
{
int screen = 0;
xcb_connection_t *c = nullptr;
Display *xDisplay = XOpenDisplay(m_options.display.toLatin1().constData());
if (xDisplay) {
c = XGetXCBConnection(xDisplay);
XSetEventQueueOwner(xDisplay, XCBOwnsEventQueue);
screen = XDefaultScreen(xDisplay);
m_display = XOpenDisplay(m_options.display.toLatin1().constData());
if (!m_display) {
return false;
}
if (c && !xcb_connection_has_error(c)) {
m_connection = c;
m_screenNumber = screen;
m_display = xDisplay;
m_connection = XGetXCBConnection(m_display);
m_screenNumber = XDefaultScreen(m_display);
XSetEventQueueOwner(m_display, XCBOwnsEventQueue);
int screen = m_screenNumber;
for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(m_connection));
it.rem;
--screen, xcb_screen_next(&it)) {
@ -209,9 +207,6 @@ bool X11WindowedBackend::initialize()
}
Q_EMIT outputsQueried();
return true;
} else {
return false;
}
}
void X11WindowedBackend::initXInput()