Use XCB for startup and multi-head check in KWin
Multi-head is somehow tested with Xvfb. At least the fork works and the display variables are properly adjusted.
This commit is contained in:
parent
16fdecb495
commit
1b30755b32
1 changed files with 9 additions and 8 deletions
17
main.cpp
17
main.cpp
|
@ -402,14 +402,15 @@ KDE_EXPORT int kdemain(int argc, char * argv[])
|
|||
mallopt(M_TRIM_THRESHOLD, 5*pagesize);
|
||||
#endif // M_TRIM_THRESHOLD
|
||||
|
||||
Display* dpy = XOpenDisplay(NULL);
|
||||
if (!dpy) {
|
||||
int primaryScreen = 0;
|
||||
xcb_connection_t *c = xcb_connect(nullptr, &primaryScreen);
|
||||
if (!c || xcb_connection_has_error(c)) {
|
||||
fprintf(stderr, "%s: FATAL ERROR while trying to open display %s\n",
|
||||
argv[0], XDisplayName(NULL));
|
||||
argv[0], qgetenv("DISPLAY").constData());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int number_of_screens = ScreenCount(dpy);
|
||||
const int number_of_screens = xcb_setup_roots_length(xcb_get_setup(c));
|
||||
|
||||
// multi head
|
||||
auto isMultiHead = []() -> bool {
|
||||
|
@ -421,11 +422,11 @@ KDE_EXPORT int kdemain(int argc, char * argv[])
|
|||
};
|
||||
if (number_of_screens != 1 && isMultiHead()) {
|
||||
KWin::is_multihead = true;
|
||||
KWin::screen_number = DefaultScreen(dpy);
|
||||
KWin::screen_number = primaryScreen;
|
||||
int pos; // Temporarily needed to reconstruct DISPLAY var if multi-head
|
||||
QByteArray display_name = XDisplayString(dpy);
|
||||
XCloseDisplay(dpy);
|
||||
dpy = 0;
|
||||
QByteArray display_name = qgetenv("DISPLAY");
|
||||
xcb_disconnect(c);
|
||||
c = nullptr;
|
||||
|
||||
if ((pos = display_name.lastIndexOf('.')) != -1)
|
||||
display_name.remove(pos, 10); // 10 is enough to be sure we removed ".s"
|
||||
|
|
Loading…
Reference in a new issue