Changeset View
Changeset View
Standalone View
Standalone View
src/server/display.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
50 | #include "xdgforeign_interface.h" | 50 | #include "xdgforeign_interface.h" | ||
51 | #include "xdgshell_v6_interface_p.h" | 51 | #include "xdgshell_v6_interface_p.h" | ||
52 | #include "xdgshell_stable_interface_p.h" | 52 | #include "xdgshell_stable_interface_p.h" | ||
53 | #include "appmenu_interface.h" | 53 | #include "appmenu_interface.h" | ||
54 | #include "server_decoration_palette_interface.h" | 54 | #include "server_decoration_palette_interface.h" | ||
55 | #include "plasmavirtualdesktop_interface.h" | 55 | #include "plasmavirtualdesktop_interface.h" | ||
56 | #include "xdgoutput_interface.h" | 56 | #include "xdgoutput_interface.h" | ||
57 | #include "xdgdecoration_interface.h" | 57 | #include "xdgdecoration_interface.h" | ||
58 | #include "eglstream_controller_interface.h" | ||||
58 | 59 | | |||
59 | #include <QCoreApplication> | 60 | #include <QCoreApplication> | ||
60 | #include <QDebug> | 61 | #include <QDebug> | ||
61 | #include <QAbstractEventDispatcher> | 62 | #include <QAbstractEventDispatcher> | ||
62 | #include <QSocketNotifier> | 63 | #include <QSocketNotifier> | ||
63 | #include <QThread> | 64 | #include <QThread> | ||
65 | #include <QLibrary> | ||||
64 | 66 | | |||
65 | #include <wayland-server.h> | 67 | #include <wayland-server.h> | ||
66 | 68 | | |||
67 | #include <EGL/egl.h> | 69 | #include <EGL/egl.h> | ||
68 | 70 | | |||
69 | namespace KWayland | 71 | namespace KWayland | ||
70 | { | 72 | { | ||
71 | namespace Server | 73 | namespace Server | ||
▲ Show 20 Lines • Show All 437 Lines • ▼ Show 20 Line(s) | |||||
509 | 511 | | |||
510 | XdgDecorationManagerInterface *Display::createXdgDecorationManager(XdgShellInterface *shellInterface, QObject *parent) | 512 | XdgDecorationManagerInterface *Display::createXdgDecorationManager(XdgShellInterface *shellInterface, QObject *parent) | ||
511 | { | 513 | { | ||
512 | auto d = new XdgDecorationManagerInterface(this, shellInterface, parent); | 514 | auto d = new XdgDecorationManagerInterface(this, shellInterface, parent); | ||
513 | connect(this, &Display::aboutToTerminate, d, [d] { delete d; }); | 515 | connect(this, &Display::aboutToTerminate, d, [d] { delete d; }); | ||
514 | return d; | 516 | return d; | ||
515 | } | 517 | } | ||
516 | 518 | | |||
519 | EglStreamControllerInterface *Display::createEglStreamControllerInterface(QObject *parent) | ||||
520 | { | ||||
521 | EglStreamControllerInterface *e = nullptr; | ||||
522 | // libnvidia-egl-wayland.so.1 may not be present on all systems so we load it dynamically | ||||
523 | wl_interface *i = (wl_interface *)QLibrary::resolve(QLatin1String("libnvidia-egl-wayland.so.1"), | ||||
524 | "wl_eglstream_controller_interface"); | ||||
525 | if (i != nullptr) { | ||||
526 | e = new EglStreamControllerInterface(this, i, parent); | ||||
527 | connect(this, &Display::aboutToTerminate, e, [e] { delete e; }); | ||||
528 | } else { | ||||
529 | qCWarning(KWAYLAND_SERVER) << "Unable to load libnvidia-egl-wayland.so.1"; | ||||
romangg: There should be always a non-null object returned. Instead check somewhere before the create… | |||||
530 | } | ||||
531 | | ||||
532 | return e; | ||||
533 | } | ||||
534 | | ||||
517 | void Display::createShm() | 535 | void Display::createShm() | ||
518 | { | 536 | { | ||
519 | Q_ASSERT(d->display); | 537 | Q_ASSERT(d->display); | ||
520 | wl_display_init_shm(d->display); | 538 | wl_display_init_shm(d->display); | ||
521 | } | 539 | } | ||
522 | 540 | | |||
523 | void Display::removeOutput(OutputInterface *output) | 541 | void Display::removeOutput(OutputInterface *output) | ||
524 | { | 542 | { | ||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |
There should be always a non-null object returned. Instead check somewhere before the create call of EglStreamControllerInterface if the library can be loaded. Also this would put the logic and the QLibrary include in the class file and not in display.cpp, what I would prefer.
One could overwrite the Global::create method in the EglStreamControllerInterface child class. From there then call QLibrary::resolve and only if it succeeds the parent create method. Afterwards compositor needs to check Global::isValid.
The control flow would then be in the compositor:
It's unfortunate that the create method is not virtual in Global. We can change this in KF6.