File indexing completed on 2024-03-24 17:07:40
0001 /* 0002 * SPDX-FileCopyrightText: 2012, 2013 Daniel Vrátil <dvratil@redhat.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #ifndef XRANDRX11HELPER_H 0008 #define XRANDRX11HELPER_H 0009 0010 #include <QAbstractNativeEventFilter> 0011 #include <QLoggingCategory> 0012 #include <QObject> 0013 #include <QRect> 0014 0015 #include <xcb/randr.h> 0016 #include <xcb/xcb.h> 0017 0018 class XCBEventListener : public QObject, public QAbstractNativeEventFilter 0019 { 0020 Q_OBJECT 0021 0022 public: 0023 XCBEventListener(); 0024 ~XCBEventListener() override; 0025 0026 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0027 bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override; 0028 #else 0029 bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override; 0030 #endif 0031 0032 Q_SIGNALS: 0033 /* Emitted when only XRandR 1.1 or older is available */ 0034 void screenChanged(xcb_randr_rotation_t rotation, const QSize &sizePx, const QSize &sizeMm); 0035 void outputsChanged(); 0036 0037 /* Emitted only when XRandR 1.2 or newer is available */ 0038 void crtcChanged(xcb_randr_crtc_t crtc, xcb_randr_mode_t mode, xcb_randr_rotation_t rotation, const QRect &geom, xcb_timestamp_t timestamp); 0039 void outputChanged(xcb_randr_output_t output, xcb_randr_crtc_t crtc, xcb_randr_mode_t mode, xcb_randr_connection_t connection); 0040 void outputPropertyChanged(xcb_randr_output_t output); 0041 0042 private: 0043 QString rotationToString(xcb_randr_rotation_t rotation); 0044 QString connectionToString(xcb_randr_connection_t connection); 0045 void handleScreenChange(xcb_generic_event_t *e); 0046 void handleXRandRNotify(xcb_generic_event_t *e); 0047 0048 protected: 0049 bool m_isRandrPresent; 0050 bool m_event11; 0051 uint8_t m_randrBase; 0052 uint8_t m_randrErrorBase; 0053 uint8_t m_majorOpcode; 0054 uint32_t m_versionMajor; 0055 uint32_t m_versionMinor; 0056 0057 uint32_t m_window; 0058 }; 0059 0060 Q_DECLARE_LOGGING_CATEGORY(KSCREEN_XCB_HELPER) 0061 #endif // XRANDRX11HELPER_H