summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/nativepainting/qt_x11_p.h
blob: 66e0aa2cf85500425f3a708ff3939a686841d251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QT_X11_P_H
#define QT_X11_P_H

#define register        /* C++17 deprecated register */
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#undef register

#if QT_CONFIG(xrender)
#  include "qtessellator_p.h"
#  include <X11/extensions/Xrender.h>
#endif

#if QT_CONFIG(fontconfig)
#include <fontconfig/fontconfig.h>
#endif

#if defined(FT_LCD_FILTER_H)
#include FT_LCD_FILTER_H
#endif

#if defined(FC_LCD_FILTER)

#ifndef FC_LCD_FILTER_NONE
#define FC_LCD_FILTER_NONE FC_LCD_NONE
#endif

#ifndef FC_LCD_FILTER_DEFAULT
#define FC_LCD_FILTER_DEFAULT FC_LCD_DEFAULT
#endif

#ifndef FC_LCD_FILTER_LIGHT
#define FC_LCD_FILTER_LIGHT FC_LCD_LIGHT
#endif

#ifndef FC_LCD_FILTER_LEGACY
#define FC_LCD_FILTER_LEGACY FC_LCD_LEGACY
#endif

#endif

QT_BEGIN_NAMESPACE

// rename a couple of X defines to get rid of name clashes
// resolve the conflict between X11's FocusIn and QEvent::FocusIn
enum {
    XFocusOut = FocusOut,
    XFocusIn = FocusIn,
    XKeyPress = KeyPress,
    XKeyRelease = KeyRelease,
    XNone = None,
    XRevertToParent = RevertToParent,
    XGrayScale = GrayScale,
    XCursorShape = CursorShape,
};
#undef FocusOut
#undef FocusIn
#undef KeyPress
#undef KeyRelease
#undef None
#undef RevertToParent
#undef GrayScale
#undef CursorShape

#ifdef FontChange
#undef FontChange
#endif

Q_DECLARE_TYPEINFO(XPoint, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(XRectangle, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(XChar2b, Q_PRIMITIVE_TYPE);
#if QT_CONFIG(xrender)
Q_DECLARE_TYPEINFO(XGlyphElt32, Q_PRIMITIVE_TYPE);
#endif

struct QX11InfoData;

enum DesktopEnvironment {
    DE_UNKNOWN,
    DE_KDE,
    DE_GNOME,
    DE_CDE,
    DE_MEEGO_COMPOSITOR,
    DE_4DWM
};

struct QXcbX11Data {
    Display *display = nullptr;

    // true if Qt is compiled w/ RENDER support and RENDER is supported on the connected Display
    bool use_xrender = false;
    int xrender_major = 0;
    int xrender_version = 0;

    QX11InfoData *screens = nullptr;
    Visual **argbVisuals = nullptr;
    Colormap *argbColormaps = nullptr;
    int screenCount = 0;
    int defaultScreen = 0;

    // options
    int visual_class = 0;
    int visual_id = 0;
    int color_count = 0;
    bool custom_cmap = false;

    // outside visual/colormap
    Visual *visual = nullptr;
    Colormap colormap = 0;

#if QT_CONFIG(xrender)
    enum { solid_fill_count = 16 };
    struct SolidFills {
        XRenderColor color;
        int screen;
        Picture picture;
    } solid_fills[solid_fill_count];
    enum { pattern_fill_count = 16 };
    struct PatternFills {
        XRenderColor color;
        XRenderColor bg_color;
        int screen;
        int style;
        bool opaque;
        Picture picture;
    } pattern_fills[pattern_fill_count];
    Picture getSolidFill(int screen, const QColor &c);
    XRenderColor preMultiply(const QColor &c);
#endif

    bool fc_antialias = true;
    int fc_hint_style = 0;

    DesktopEnvironment desktopEnvironment = DE_GNOME;
};

extern QXcbX11Data *qt_x11Data;
#define X11 qt_x11Data

struct QX11InfoData {
    int screen;
    int dpiX;
    int dpiY;
    int depth;
    int cells;
    Colormap colormap;
    Visual *visual;
    bool defaultColormap;
    bool defaultVisual;
    int subpixel = 0;
};

template <class T>
constexpr inline int lowest_bit(T v) noexcept
{
    int result = qCountTrailingZeroBits(v);
    return ((result >> 3) == sizeof(T)) ? -1 : result;
}

QT_END_NAMESPACE

#endif // QT_X11_P_H