Plasma-workspace
outputorderwatcher.cpp
30class WaylandOutputOrder : public QWaylandClientExtensionTemplate<WaylandOutputOrder, &QtWayland::kde_output_order_v1::destroy>,
84 connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &OutputOrderWatcher::refresh, Qt::UniqueConnection);
145 // This timer is used to signal only when a qscreen for every output is already created, perhaps by monitoring
158 const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_x11Interface->connection(), &xcb_randr_id);
159 if (!reply || !reply->present) { // SENTRY PLASMA-WORKSPACE-1MMC: XRandr extension is not initialized when using vncserver
168 xcb_intern_atom_unchecked(m_x11Interface->connection(), false, std::char_traits<char>::length(effectName), effectName);
169 xcb_intern_atom_reply_t *atom(xcb_intern_atom_reply(m_x11Interface->connection(), atomCookie, nullptr));
187 ScopedPointer<xcb_randr_get_screen_resources_current_reply_t> reply(xcb_randr_get_screen_resources_current_reply(
189 xcb_randr_get_screen_resources_current(m_x11Interface->connection(), DefaultRootWindow(m_x11Interface->display())),
194 xcb_randr_output_t *randr_outputs = xcb_randr_get_screen_resources_current_outputs(reply.data());
202 if (output == NULL || output->connection == XCB_RANDR_CONNECTION_DISCONNECTED || output->crtc == 0) {
206 auto orderCookie = xcb_randr_get_output_property(m_x11Interface->connection(), randr_outputs[i], m_kdeScreenAtom, XCB_ATOM_ANY, 0, 100, false, false);
209 // If there is even a single screen without _KDE_SCREEN_INDEX info, fall back to alphabetical ordering
215 if (!(orderReply->type == XCB_ATOM_INTEGER && orderReply->format == 32 && orderReply->num_items == 1)) {
232 std::transform(screens.begin(), screens.end(), std::back_inserter(screenNames), [](const QScreen *screen) {
235 const bool isScreenPresent = std::all_of(orderMap.cbegin(), orderMap.cend(), [&screenNames](const auto &pr) {
250 const auto getAllValues = [](const QList<std::pair<uint, QString>> &orderMap) -> QList<QString> {
253 std::transform(orderMap.begin(), orderMap.end(), std::back_inserter(values), [](const auto &pair) {
261 if (const auto pendingOutputs = std::views::values(std::as_const(orderMap)); !std::ranges::equal(pendingOutputs, std::as_const(m_outputOrder))) {
268bool X11OutputOrderWatcher::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result)
272 // we don't have any signal about it, the primary screen changes but we have the same old QScreen* getting recycled
274 // if this slot will be invoked many times, their//second time on will do nothing as name and primaryOutputName will be the same by then
296 // When the ast screen is removed, its qscreen becomes name ":0.0" as the fake screen, but nothing happens really,
316 ScopedPointer<xcb_get_input_focus_reply_t> sync(xcb_get_input_focus_reply(m_x11Interface->connection(), cookie, &error));
325 // Asking for primaryOutputName() before this happened, will return qGuiApp->primaryScreen()->name() anyways, so set it so the outputOrderChanged will
335 connect(outputListManagement, &WaylandOutputOrder::outputOrderChanged, this, [this](const QStringList &order) {
static bool isPlatformX11()
static bool isPlatformWayland()
This class watches for output ordering changes from the relevant backend.
Definition outputorderwatcher.h:28
static OutputOrderWatcher * instance(QObject *parent)
Create the correct OutputOrderWatcher.
Definition outputorderwatcher.cpp:89
QStringList outputOrder() const
Returns the list of outputs in order.
Definition outputorderwatcher.cpp:132
void useFallback(bool fallback, const char *reason=nullptr)
Backend failed, use QScreen based implementaion.
Definition outputorderwatcher.cpp:77
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
void initialize(StandardShortcut id)
void primaryScreenChanged(QScreen *screen)
void screenAdded(QScreen *screen)
void screenRemoved(QScreen *screen)
void append(QList< T > &&value)
iterator begin()
const_iterator cbegin() const const
const_iterator cend() const const
void clear()
reference emplace_back(Args &&... args)
iterator end()
void reserve(qsizetype size)
qsizetype size() const const
QObject(QObject *parent)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
QString fromUtf8(QByteArrayView str)
UniqueConnection
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void timeout()
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:51:10 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:51:10 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.