Changeset View
Changeset View
Standalone View
Standalone View
main_x11.cpp
Show First 20 Lines • Show All 357 Lines • ▼ Show 20 Line(s) | 357 | if (number_of_screens != 1 && isMultiHead()) { | |||
---|---|---|---|---|---|
358 | KWin::Application::setX11MultiHead(true); | 358 | KWin::Application::setX11MultiHead(true); | ||
359 | KWin::Application::setX11ScreenNumber(primaryScreen); | 359 | KWin::Application::setX11ScreenNumber(primaryScreen); | ||
360 | int pos; // Temporarily needed to reconstruct DISPLAY var if multi-head | 360 | int pos; // Temporarily needed to reconstruct DISPLAY var if multi-head | ||
361 | QByteArray display_name = qgetenv("DISPLAY"); | 361 | QByteArray display_name = qgetenv("DISPLAY"); | ||
362 | 362 | | |||
363 | if ((pos = display_name.lastIndexOf('.')) != -1) | 363 | if ((pos = display_name.lastIndexOf('.')) != -1) | ||
364 | display_name.remove(pos, 10); // 10 is enough to be sure we removed ".s" | 364 | display_name.remove(pos, 10); // 10 is enough to be sure we removed ".s" | ||
365 | 365 | | |||
366 | QString envir; | | |||
367 | for (int i = 0; i < number_of_screens; i++) { | 366 | for (int i = 0; i < number_of_screens; i++) { | ||
368 | // If execution doesn't pass by here, then kwin | 367 | // If execution doesn't pass by here, then kwin | ||
369 | // acts exactly as previously | 368 | // acts exactly as previously | ||
370 | if (i != KWin::Application::x11ScreenNumber() && fork() == 0) { | 369 | if (i != KWin::Application::x11ScreenNumber() && fork() == 0) { | ||
371 | KWin::Application::setX11ScreenNumber(i); | 370 | KWin::Application::setX11ScreenNumber(i); | ||
372 | QByteArray dBusSuffix = qgetenv("KWIN_DBUS_SERVICE_SUFFIX"); | 371 | QByteArray dBusSuffix = qgetenv("KWIN_DBUS_SERVICE_SUFFIX"); | ||
373 | if (!dBusSuffix.isNull()) { | 372 | if (!dBusSuffix.isNull()) { | ||
374 | dBusSuffix.append("."); | 373 | dBusSuffix.append("."); | ||
375 | } | 374 | } | ||
376 | dBusSuffix.append(QByteArrayLiteral("head-")).append(QByteArray::number(i)); | 375 | dBusSuffix.append(QByteArrayLiteral("head-")).append(QByteArray::number(i)); | ||
377 | qputenv("KWIN_DBUS_SERVICE_SUFFIX", dBusSuffix); | 376 | qputenv("KWIN_DBUS_SERVICE_SUFFIX", dBusSuffix); | ||
378 | // Break here because we are the child process, we don't | 377 | // Break here because we are the child process, we don't | ||
379 | // want to fork() anymore | 378 | // want to fork() anymore | ||
380 | break; | 379 | break; | ||
381 | } | 380 | } | ||
382 | } | 381 | } | ||
383 | // In the next statement, display_name shouldn't contain a screen | 382 | // In the next statement, display_name shouldn't contain a screen | ||
384 | // number. If it had it, it was removed at the "pos" check | 383 | // number. If it had it, it was removed at the "pos" check | ||
385 | envir.sprintf("DISPLAY=%s.%d", display_name.data(), KWin::Application::x11ScreenNumber()); | 384 | const QString envir = QStringLiteral("DISPLAY=%1.%2") | ||
385 | .arg(display_name.data()) | ||||
386 | .arg(KWin::Application::x11ScreenNumber()); | ||||
386 | 387 | | |||
387 | if (putenv(strdup(envir.toLatin1().constData()))) { | 388 | if (putenv(strdup(envir.toLatin1().constData()))) { | ||
388 | fprintf(stderr, "%s: WARNING: unable to set DISPLAY environment variable\n", argv[0]); | 389 | fprintf(stderr, "%s: WARNING: unable to set DISPLAY environment variable\n", argv[0]); | ||
389 | perror("putenv()"); | 390 | perror("putenv()"); | ||
390 | } | 391 | } | ||
391 | } | 392 | } | ||
392 | 393 | | |||
393 | if (signal(SIGTERM, KWin::sighandler) == SIG_IGN) | 394 | if (signal(SIGTERM, KWin::sighandler) == SIG_IGN) | ||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |