Plasma-workspace
outputorderwatcher.cpp
30class WaylandOutputOrder : public QWaylandClientExtensionTemplate<WaylandOutputOrder, &QtWayland::kde_output_order_v1::destroy>,
81 connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &OutputOrderWatcher::refresh, Qt::UniqueConnection);
142 // This timer is used to signal only when a qscreen for every output is already created, perhaps by monitoring
155 const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_x11Interface->connection(), &xcb_randr_id);
160 xcb_intern_atom_unchecked(m_x11Interface->connection(), false, std::char_traits<char>::length(effectName), effectName);
161 xcb_intern_atom_reply_t *atom(xcb_intern_atom_reply(m_x11Interface->connection(), atomCookie, nullptr));
179 ScopedPointer<xcb_randr_get_screen_resources_current_reply_t> reply(xcb_randr_get_screen_resources_current_reply(
181 xcb_randr_get_screen_resources_current(m_x11Interface->connection(), DefaultRootWindow(m_x11Interface->display())),
186 xcb_randr_output_t *randr_outputs = xcb_randr_get_screen_resources_current_outputs(reply.data());
194 if (output == NULL || output->connection == XCB_RANDR_CONNECTION_DISCONNECTED || output->crtc == 0) {
198 auto orderCookie = xcb_randr_get_output_property(m_x11Interface->connection(), randr_outputs[i], m_kdeScreenAtom, XCB_ATOM_ANY, 0, 100, false, false);
201 // If there is even a single screen without _KDE_SCREEN_INDEX info, fall back to alphabetical ordering
207 if (!(orderReply->type == XCB_ATOM_INTEGER && orderReply->format == 32 && orderReply->num_items == 1)) {
224 std::transform(screens.begin(), screens.end(), std::back_inserter(screenNames), [](const QScreen *screen) {
227 const bool isScreenPresent = std::all_of(orderMap.cbegin(), orderMap.cend(), [&screenNames](const auto &pr) {
242 const auto getAllValues = [](const QList<std::pair<uint, QString>> &orderMap) -> QList<QString> {
245 std::transform(orderMap.begin(), orderMap.end(), std::back_inserter(values), [](const auto &pair) {
253 if (const auto pendingOutputs = std::views::values(std::as_const(orderMap)); !std::ranges::equal(pendingOutputs, std::as_const(m_outputOrder))) {
260bool X11OutputOrderWatcher::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result)
264 // we don't have any signal about it, the primary screen changes but we have the same old QScreen* getting recycled
266 // 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
288 // When the ast screen is removed, its qscreen becomes name ":0.0" as the fake screen, but nothing happens really,
308 ScopedPointer<xcb_get_input_focus_reply_t> sync(xcb_get_input_focus_reply(m_x11Interface->connection(), cookie, &error));
317 // Asking for primaryOutputName() before this happened, will return qGuiApp->primaryScreen()->name() anyways, so set it so the outputOrderChanged will
327 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
void useFallback(bool fallback)
Backend failed, use QScreen based implementaion.
Definition outputorderwatcher.cpp:77
static OutputOrderWatcher * instance(QObject *parent)
Create the correct OutputOrderWatcher.
Definition outputorderwatcher.cpp:86
QStringList outputOrder() const
Returns the list of outputs in order.
Definition outputorderwatcher.cpp:129
KCRASH_EXPORT void initialize()
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
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
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-2024 The KDE developers.
Generated on Fri Dec 20 2024 12:00:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 12:00:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.