5#include <QtCore/qrandom.h>
19 X11->display =
static_cast<Display *>(conn->xlib_display());
41 screen
->dpiY = (DisplayHeight(
X11->display, s) * 254 + heightMM * 5) / (heightMM * 10);
50 X11->use_xrender = conn->hasXRender() && !qEnvironmentVariableIsSet(
"QT_XCB_NATIVE_PAINTING_NO_XRENDER");
53 memset(X11->solid_fills, 0,
sizeof(X11->solid_fills));
54 for (
int i = 0; i < X11->solid_fill_count; ++i)
55 X11->solid_fills[i].screen = -1;
56 memset(X11->pattern_fills, 0,
sizeof(X11->pattern_fills));
57 for (
int i = 0; i < X11->pattern_fill_count; ++i)
58 X11->pattern_fills[i].screen = -1;
64 if (X11->use_xrender) {
67 XRenderPictFormat *format =
68 XRenderFindVisualFormat(X11->display,
69 (Visual *) QXcbX11Info::appVisual(X11->defaultScreen));
72 X11->use_xrender =
false;
80 const int numRects = r.rectCount();
81 const auto input = r.begin();
82 QList<XRectangle> output(numRects);
83 for (
int i = 0; i < numRects; ++i) {
84 const QRect &in = input[i];
85 XRectangle &out = output[i];
86 out.x = qMax(SHRT_MIN, in.x());
87 out.y = qMax(SHRT_MIN, in.y());
88 out.width = qMin((
int)USHRT_MAX, in.width());
89 out.height = qMin((
int)USHRT_MAX, in.height());
145 return d ? d->screen : QXcbX11Info::appScreen();
150 return d ? d->depth : QXcbX11Info::appDepth();
155 return d ? d->colormap : QXcbX11Info::appColormap();
160 return d ? d->visual : QXcbX11Info::appVisual();
168 d->visual = (Visual *) visual;
233#if QT_CONFIG(xrender)
234Picture QXcbX11Data::getSolidFill(
int screen,
const QColor &c)
236 if (!X11->use_xrender)
239 XRenderColor color = preMultiply(c);
240 for (
int i = 0; i < X11->solid_fill_count; ++i) {
241 if (X11->solid_fills[i].screen == screen
242 && X11->solid_fills[i].color.alpha == color.alpha
243 && X11->solid_fills[i].color.red == color.red
244 && X11->solid_fills[i].color.green == color.green
245 && X11->solid_fills[i].color.blue == color.blue)
246 return X11->solid_fills[i].picture;
249 int i = QRandomGenerator::global()->generate() % 16;
251 if (X11->solid_fills[i].screen != screen && X11->solid_fills[i].picture) {
252 XRenderFreePicture (X11->display, X11->solid_fills[i].picture);
253 X11->solid_fills[i].picture = 0;
256 if (!X11->solid_fills[i].picture) {
257 Pixmap pixmap = XCreatePixmap (X11->display, RootWindow (X11->display, screen), 1, 1, 32);
258 XRenderPictureAttributes attrs;
260 X11->solid_fills[i].picture = XRenderCreatePicture (X11->display, pixmap,
261 XRenderFindStandardFormat(X11->display, PictStandardARGB32),
263 XFreePixmap (X11->display, pixmap);
266 X11->solid_fills[i].color = color;
267 X11->solid_fills[i].screen = screen;
268 XRenderFillRectangle (X11->display, PictOpSrc, X11->solid_fills[i].picture, &color, 0, 0, 1, 1);
269 return X11->solid_fills[i].picture;
272XRenderColor QXcbX11Data::preMultiply(
const QColor &c)
275 const uint A = c.alpha(),
279 color.alpha = (A | A << 8);
280 color.red = (R | R << 8) * color.alpha / 0x10000;
281 color.green = (G | G << 8) * color.alpha / 0x10000;
282 color.blue = (B | B << 8) * color.alpha / 0x10000;
static bool appDefaultVisual(int screen=-1)
static QXcbX11Info fromScreen(int screen)
static Colormap appColormap(int screen=-1)
static Window appRootWindow(int screen=-1)
static bool appDefaultColormap(int screen=-1)
static int appDepth(int screen=-1)
void setVisual(void *visual)
static Display * display()
Colormap colormap() const
static int appDpiY(int screen=-1)
QXcbX11Info & operator=(const QXcbX11Info &other)
static int appCells(int screen=-1)
static void * appVisual(int screen=-1)
QXcbX11Info(const QXcbX11Info &other)
static int appDpiX(int screen=-1)
QList< XRectangle > qt_region_to_xrectangles(const QRegion &r)
void qt_xcb_native_x11_info_init(QXcbConnection *conn)