| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 4 |
|
| 5 |
#ifndef QXCBSCREEN_H |
| 6 |
#define QXCBSCREEN_H |
| 7 |
|
| 8 |
#include <qpa/qplatformscreen.h> |
| 9 |
#include <QtCore/QString> |
| 10 |
|
| 11 |
#include <xcb/xcb.h> |
| 12 |
#include <xcb/randr.h> |
| 13 |
|
| 14 |
#include "qxcbobject.h" |
| 15 |
#include "qxcbscreen.h" |
| 16 |
|
| 17 |
#include <private/qfontengine_p.h> |
| 18 |
|
| 19 |
QT_BEGIN_NAMESPACE |
| 20 |
|
| 21 |
class QXcbConnection; |
| 22 |
class QXcbCursor; |
| 23 |
class QXcbXSettings; |
| 24 |
#ifndef QT_NO_DEBUG_STREAM |
| 25 |
class QDebug; |
| 26 |
#endif |
| 27 |
|
| 28 |
class QXcbVirtualDesktop : public QXcbObject |
| 29 |
{ |
| 30 |
public: |
| 31 |
QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t *screen, int number); |
| 32 |
~QXcbVirtualDesktop(); |
| 33 |
|
| 34 |
xcb_screen_t *screen() const { return m_screen; } |
| 35 |
int number() const { return m_number; } |
| 36 |
QSize size() const { return QSize(m_screen->width_in_pixels, m_screen->height_in_pixels); } |
| 37 |
QSize physicalSize() const { return QSize(m_screen->width_in_millimeters, m_screen->height_in_millimeters); } |
| 38 |
|
| 39 |
QXcbXSettings *xSettings() const; |
| 40 |
|
| 41 |
private: |
| 42 |
xcb_screen_t *m_screen; |
| 43 |
int m_number; |
| 44 |
|
| 45 |
QXcbXSettings *m_xSettings; |
| 46 |
}; |
| 47 |
|
| 48 |
class Q_XCB_EXPORT QXcbScreen : public QXcbObject, public QPlatformScreen |
| 49 |
{ |
| 50 |
public: |
| 51 |
QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDesktop, |
| 52 |
xcb_randr_output_t outputId, xcb_randr_get_output_info_reply_t *output, |
| 53 |
QString outputName); |
| 54 |
~QXcbScreen(); |
| 55 |
|
| 56 |
QPixmap grabWindow(WId window, int x, int y, int width, int height) const Q_DECL_OVERRIDE; |
| 57 |
|
| 58 |
QWindow *topLevelAt(const QPoint &point) const Q_DECL_OVERRIDE; |
| 59 |
|
| 60 |
QRect geometry() const Q_DECL_OVERRIDE { return m_geometry; } |
| 61 |
QRect nativeGeometry() const { return m_nativeGeometry; } |
| 62 |
QRect availableGeometry() const Q_DECL_OVERRIDE {return m_availableGeometry;} |
| 63 |
int depth() const Q_DECL_OVERRIDE { return screen()->root_depth; } |
| 64 |
QImage::Format format() const Q_DECL_OVERRIDE; |
| 65 |
QSizeF physicalSize() const Q_DECL_OVERRIDE { return m_sizeMillimeters; } |
| 66 |
QSize virtualSize() const { return m_virtualSize; } |
| 67 |
QSizeF physicalVirtualSize() const { return m_virtualSizeMillimeters; } |
| 68 |
QDpi virtualDpi() const; |
| 69 |
QDpi logicalDpi() const Q_DECL_OVERRIDE; |
| 70 |
qreal devicePixelRatio() const Q_DECL_OVERRIDE; |
| 71 |
QPlatformCursor *cursor() const Q_DECL_OVERRIDE; |
| 72 |
qreal refreshRate() const Q_DECL_OVERRIDE { return m_refreshRate; } |
| 73 |
Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE { return m_orientation; } |
| 74 |
QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE { return m_siblings; } |
| 75 |
void setVirtualSiblings(QList<QPlatformScreen *> sl) { m_siblings = sl; } |
| 76 |
void removeVirtualSibling(QPlatformScreen *s) { m_siblings.removeOne(s); } |
| 77 |
void addVirtualSibling(QPlatformScreen *s) { ((QXcbScreen *) s)->isPrimary() ? m_siblings.prepend(s) : m_siblings.append(s); } |
| 78 |
|
| 79 |
void setPrimary(bool primary) { m_primary = primary; } |
| 80 |
bool isPrimary() const { return m_primary; } |
| 81 |
|
| 82 |
int screenNumber() const { return m_virtualDesktop->number(); } |
| 83 |
|
| 84 |
xcb_screen_t *screen() const { return m_virtualDesktop->screen(); } |
| 85 |
xcb_window_t root() const { return screen()->root; } |
| 86 |
xcb_randr_output_t output() const { return m_output; } |
| 87 |
xcb_randr_crtc_t crtc() const { return m_crtc; } |
| 88 |
xcb_randr_mode_t mode() const { return m_mode; } |
| 89 |
|
| 90 |
void windowShown(QXcbWindow *window); |
| 91 |
QString windowManagerName() const { return m_windowManagerName; } |
| 92 |
bool syncRequestSupported() const { return m_syncRequestSupported; } |
| 93 |
|
| 94 |
const xcb_visualtype_t *visualForId(xcb_visualid_t) const; |
| 95 |
quint8 depthOfVisual(xcb_visualid_t) const; |
| 96 |
|
| 97 |
QString name() const Q_DECL_OVERRIDE { return m_outputName; } |
| 98 |
|
| 99 |
void handleScreenChange(xcb_randr_screen_change_notify_event_t *change_event); |
| 100 |
void updateGeometry(const QRect &geom, uint8_t rotation); |
| 101 |
void updateGeometry(xcb_timestamp_t timestamp = XCB_TIME_CURRENT_TIME); |
| 102 |
void updateRefreshRate(xcb_randr_mode_t mode); |
| 103 |
|
| 104 |
void readXResources(); |
| 105 |
|
| 106 |
QFontEngine::HintStyle hintStyle() const { return m_hintStyle; } |
| 107 |
bool noFontHinting() const { return m_noFontHinting; } |
| 108 |
QFontEngine::SubpixelAntialiasingType subpixelType() const { return m_subpixelType; } |
| 109 |
int antialiasingEnabled() const { return m_antialiasingEnabled; } |
| 110 |
|
| 111 |
QXcbXSettings *xSettings() const; |
| 112 |
|
| 113 |
QPoint mapToNative(const QPoint &pos) const; |
| 114 |
QPoint mapFromNative(const QPoint &pos) const; |
| 115 |
QPointF mapToNative(const QPointF &pos) const; |
| 116 |
QPointF mapFromNative(const QPointF &pos) const; |
| 117 |
QRect mapToNative(const QRect &rect) const; |
| 118 |
QRect mapFromNative(const QRect &rect) const; |
| 119 |
|
| 120 |
private: |
| 121 |
static bool xResource(const QByteArray &identifier, |
| 122 |
const QByteArray &expectedIdentifier, |
| 123 |
QByteArray &stringValue); |
| 124 |
void sendStartupMessage(const QByteArray &message) const; |
| 125 |
|
| 126 |
QXcbVirtualDesktop *m_virtualDesktop; |
| 127 |
xcb_randr_output_t m_output; |
| 128 |
xcb_randr_crtc_t m_crtc; |
| 129 |
xcb_randr_mode_t m_mode; |
| 130 |
bool m_primary; |
| 131 |
uint8_t m_rotation; |
| 132 |
|
| 133 |
QString m_outputName; |
| 134 |
QSizeF m_outputSizeMillimeters; |
| 135 |
QSizeF m_sizeMillimeters; |
| 136 |
QRect m_geometry; |
| 137 |
QRect m_nativeGeometry; |
| 138 |
QRect m_availableGeometry; |
| 139 |
QSize m_virtualSize; |
| 140 |
QSizeF m_virtualSizeMillimeters; |
| 141 |
QList<QPlatformScreen *> m_siblings; |
| 142 |
Qt::ScreenOrientation m_orientation; |
| 143 |
QString m_windowManagerName; |
| 144 |
bool m_syncRequestSupported; |
| 145 |
QMap<xcb_visualid_t, xcb_visualtype_t> m_visuals; |
| 146 |
QMap<xcb_visualid_t, quint8> m_visualDepths; |
| 147 |
QXcbCursor *m_cursor; |
| 148 |
int m_refreshRate; |
| 149 |
int m_forcedDpi; |
| 150 |
int m_devicePixelRatio; |
| 151 |
QFontEngine::HintStyle m_hintStyle; |
| 152 |
bool m_noFontHinting; |
| 153 |
QFontEngine::SubpixelAntialiasingType m_subpixelType; |
| 154 |
int m_antialiasingEnabled; |
| 155 |
}; |
| 156 |
|
| 157 |
#ifndef QT_NO_DEBUG_STREAM |
| 158 |
Q_GUI_EXPORT QDebug operator<<(QDebug, const QXcbScreen *); |
| 159 |
#endif |
| 160 |
|
| 161 |
QT_END_NAMESPACE |
| 162 |
|
| 163 |
#endif |