Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/x11/standalone/x11_platform.cpp
Show All 29 Lines | |||||
30 | #if HAVE_X11_XINPUT | 30 | #if HAVE_X11_XINPUT | ||
31 | #include "xinputintegration.h" | 31 | #include "xinputintegration.h" | ||
32 | #endif | 32 | #endif | ||
33 | #include "abstract_client.h" | 33 | #include "abstract_client.h" | ||
34 | #include "effects_x11.h" | 34 | #include "effects_x11.h" | ||
35 | #include "eglonxbackend.h" | 35 | #include "eglonxbackend.h" | ||
36 | #include "keyboard_input.h" | 36 | #include "keyboard_input.h" | ||
37 | #include "logging.h" | 37 | #include "logging.h" | ||
38 | #include "screens_xrandr.h" | 38 | #include "screens_xrandr.h" | ||
zzag: Coding style nitpick: this include directive should be below line 45, i.e. below
```lang=cpp… | |||||
39 | #include "screenedges_filter.h" | 39 | #include "screenedges_filter.h" | ||
40 | #include "options.h" | 40 | #include "options.h" | ||
41 | #include "overlaywindow_x11.h" | 41 | #include "overlaywindow_x11.h" | ||
42 | #include "non_composited_outline.h" | 42 | #include "non_composited_outline.h" | ||
43 | #include "workspace.h" | 43 | #include "workspace.h" | ||
44 | #include "x11_decoration_renderer.h" | 44 | #include "x11_decoration_renderer.h" | ||
45 | #include "x11_output.h" | ||||
46 | #include "xcbutils.h" | ||||
45 | 47 | | |||
46 | #include <kwinxrenderutils.h> | 48 | #include <kwinxrenderutils.h> | ||
47 | 49 | | |||
48 | #include <KConfigGroup> | 50 | #include <KConfigGroup> | ||
49 | #include <KLocalizedString> | 51 | #include <KLocalizedString> | ||
50 | #include <KCrash> | 52 | #include <KCrash> | ||
51 | 53 | | |||
52 | #include <QThread> | 54 | #include <QThread> | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 99 | { | |||
101 | } | 103 | } | ||
102 | XRenderUtils::init(kwinApp()->x11Connection(), kwinApp()->x11RootWindow()); | 104 | XRenderUtils::init(kwinApp()->x11Connection(), kwinApp()->x11RootWindow()); | ||
103 | setReady(true); | 105 | setReady(true); | ||
104 | emit screensQueried(); | 106 | emit screensQueried(); | ||
105 | } | 107 | } | ||
106 | 108 | | |||
107 | Screens *X11StandalonePlatform::createScreens(QObject *parent) | 109 | Screens *X11StandalonePlatform::createScreens(QObject *parent) | ||
108 | { | 110 | { | ||
109 | return new XRandRScreens(parent); | 111 | return new XRandRScreens(this, parent); | ||
110 | } | 112 | } | ||
111 | 113 | | |||
112 | OpenGLBackend *X11StandalonePlatform::createOpenGLBackend() | 114 | OpenGLBackend *X11StandalonePlatform::createOpenGLBackend() | ||
113 | { | 115 | { | ||
114 | switch (options->glPlatformInterface()) { | 116 | switch (options->glPlatformInterface()) { | ||
115 | #if HAVE_EPOXY_GLX | 117 | #if HAVE_EPOXY_GLX | ||
116 | case GlxPlatformInterface: | 118 | case GlxPlatformInterface: | ||
117 | if (hasGlx()) { | 119 | if (hasGlx()) { | ||
▲ Show 20 Lines • Show All 316 Lines • ▼ Show 20 Line(s) | |||||
434 | #endif | 436 | #endif | ||
435 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | 437 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | ||
436 | compositors << XRenderCompositing; | 438 | compositors << XRenderCompositing; | ||
437 | #endif | 439 | #endif | ||
438 | compositors << NoCompositing; | 440 | compositors << NoCompositing; | ||
439 | return compositors; | 441 | return compositors; | ||
440 | } | 442 | } | ||
441 | 443 | | |||
444 | void X11StandalonePlatform::initOutputs() | ||||
445 | { | ||||
446 | doUpdateOutputs<Xcb::RandR::ScreenResources>(); | ||||
447 | } | ||||
448 | | ||||
449 | void X11StandalonePlatform::updateOutputs() | ||||
450 | { | ||||
451 | doUpdateOutputs<Xcb::RandR::CurrentResources>(); | ||||
452 | } | ||||
453 | | ||||
454 | template <typename T> | ||||
455 | void X11StandalonePlatform::doUpdateOutputs() | ||||
456 | { | ||||
457 | auto fallback = [this]() { | ||||
458 | auto *o = new X11Output(this); | ||||
459 | o->setRefreshRate(-1.0f); | ||||
460 | o->setName(QStringLiteral("Xinerama")); | ||||
461 | m_outputs << o; | ||||
462 | }; | ||||
463 | | ||||
464 | // TODO: instead of resetting all outputs, check if new output is added/removed | ||||
465 | // or still available and leave still available outputs in m_outputs | ||||
466 | // untouched (like in DRM backend) | ||||
467 | qDeleteAll(m_outputs); | ||||
468 | m_outputs.clear(); | ||||
469 | | ||||
470 | if (!Xcb::Extensions::self()->isRandrAvailable()) { | ||||
471 | fallback(); | ||||
472 | return; | ||||
473 | } | ||||
474 | T resources(rootWindow()); | ||||
475 | if (resources.isNull()) { | ||||
476 | fallback(); | ||||
477 | return; | ||||
478 | } | ||||
479 | xcb_randr_crtc_t *crtcs = resources.crtcs(); | ||||
480 | xcb_randr_mode_info_t *modes = resources.modes(); | ||||
481 | | ||||
482 | QVector<Xcb::RandR::CrtcInfo> infos(resources->num_crtcs); | ||||
483 | for (int i = 0; i < resources->num_crtcs; ++i) { | ||||
484 | infos[i] = Xcb::RandR::CrtcInfo(crtcs[i], resources->config_timestamp); | ||||
485 | } | ||||
486 | | ||||
487 | for (int i = 0; i < resources->num_crtcs; ++i) { | ||||
488 | Xcb::RandR::CrtcInfo info(infos.at(i)); | ||||
489 | | ||||
490 | xcb_randr_output_t *outputs = info.outputs(); | ||||
491 | QVector<Xcb::RandR::OutputInfo> outputInfos(outputs ? resources->num_outputs : 0); | ||||
492 | if (outputs) { | ||||
493 | for (int i = 0; i < resources->num_outputs; ++i) { | ||||
494 | outputInfos[i] = Xcb::RandR::OutputInfo(outputs[i], resources->config_timestamp); | ||||
495 | } | ||||
496 | } | ||||
497 | | ||||
498 | float refreshRate = -1.0f; | ||||
499 | for (int j = 0; j < resources->num_modes; ++j) { | ||||
500 | if (info->mode == modes[j].id) { | ||||
501 | if (modes[j].htotal != 0 && modes[j].vtotal != 0) { // BUG 313996 | ||||
502 | // refresh rate calculation - WTF was wikipedia 1998 when I needed it? | ||||
503 | int dotclock = modes[j].dot_clock, | ||||
504 | vtotal = modes[j].vtotal; | ||||
505 | if (modes[j].mode_flags & XCB_RANDR_MODE_FLAG_INTERLACE) | ||||
506 | dotclock *= 2; | ||||
507 | if (modes[j].mode_flags & XCB_RANDR_MODE_FLAG_DOUBLE_SCAN) | ||||
508 | vtotal *= 2; | ||||
509 | refreshRate = dotclock/float(modes[j].htotal*vtotal); | ||||
510 | } | ||||
511 | break; // found mode | ||||
512 | } | ||||
513 | } | ||||
514 | | ||||
515 | const QRect geo = info.rect(); | ||||
516 | if (geo.isValid()) { | ||||
517 | auto *o = new X11Output(this); | ||||
518 | o->setGeometry(geo); | ||||
519 | o->setRefreshRate(refreshRate); | ||||
520 | | ||||
521 | QString name; | ||||
522 | for (int j = 0; j < info->num_outputs; ++j) { | ||||
523 | Xcb::RandR::OutputInfo outputInfo(outputInfos.at(j)); | ||||
524 | if (crtcs[i] == outputInfo->crtc) { | ||||
525 | name = outputInfo.name(); | ||||
526 | break; | ||||
527 | } | ||||
528 | } | ||||
529 | o->setName(name); | ||||
530 | m_outputs << o; | ||||
531 | } | ||||
532 | } | ||||
533 | | ||||
534 | if (m_outputs.isEmpty()) { | ||||
535 | fallback(); | ||||
536 | } | ||||
537 | } | ||||
538 | | ||||
539 | Outputs X11StandalonePlatform::outputs() const | ||||
540 | { | ||||
541 | return m_outputs; | ||||
542 | } | ||||
543 | | ||||
544 | Outputs X11StandalonePlatform::enabledOutputs() const | ||||
545 | { | ||||
546 | return m_outputs; | ||||
547 | } | ||||
548 | | ||||
442 | } | 549 | } |
Coding style nitpick: this include directive should be below line 45, i.e. below