Commit 4230a0d3 authored by Martin Flöser's avatar Martin Flöser

[effects] Get xcb_connection_t* and rootWindow through EffectsHandler API

So far the effects could just use the connection() and rootWindow()
provided by kwinglobals. Thus an internal detail from KWin core is
accessed directly.

To be more consistent with the rest of the API it's wrapped through the
EffectsHandler and with a convenient method in Effect.

The connection() is provided as xcbConnection() to free the very generic
name connection which could create confusion once we provide a wayland
connection to the Effects.

The rootWindow() is provided as x11RootWindow() to indicate that it is
for the X11 world.

REVIEW: 117597
parent 93e5ebac
......@@ -217,5 +217,11 @@ public:
long unsigned int xrenderBufferPicture() override {
return 0;
}
xcb_connection_t *xcbConnection() const override {
return QX11Info::connection();
}
xcb_window_t x11RootWindow() const override {
return QX11Info::appRootWindow();
}
};
#endif
......@@ -186,6 +186,9 @@ public:
bool makeOpenGLContextCurrent() override;
void doneOpenGLContextCurrent() override;
xcb_connection_t *xcbConnection() const override;
xcb_window_t x11RootWindow() const override;
// internal (used by kwin core or compositing code)
void startPaint();
void grabbedKeyboardEvent(QKeyEvent* e);
......@@ -458,6 +461,17 @@ QList<EffectWindow*> EffectsHandlerImpl::elevatedWindows() const
return elevated_windows;
}
inline
xcb_window_t EffectsHandlerImpl::x11RootWindow() const
{
return rootWindow();
}
inline
xcb_connection_t *EffectsHandlerImpl::xcbConnection() const
{
return connection();
}
inline
EffectWindowGroupImpl::EffectWindowGroupImpl(Group* g)
......
......@@ -38,7 +38,7 @@ static const QByteArray s_slideAtomName = QByteArrayLiteral("_KDE_SLIDE");
GlideEffect::GlideEffect()
{
slideAtom = XCB_ATOM_NONE;
xcb_connection_t *c = connection();
xcb_connection_t *c = xcbConnection();
const auto cookie = xcb_intern_atom(c, false, s_slideAtomName.length(), s_slideAtomName.constData());
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, cookie, nullptr));
if (atom) {
......
......@@ -177,7 +177,7 @@ void KscreenEffect::switchState()
value = 0l;
}
if (value != -1l) {
xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, rootWindow(), m_atom, XCB_ATOM_CARDINAL, 32, 1, &value);
xcb_change_property(xcbConnection(), XCB_PROP_MODE_REPLACE, x11RootWindow(), m_atom, XCB_ATOM_CARDINAL, 32, 1, &value);
}
}
......
......@@ -48,7 +48,7 @@ LogoutEffect::LogoutEffect()
, m_blurShader(NULL)
, m_shadersDir(QStringLiteral("kwin/shaders/1.10/"))
{
xcb_connection_t *c = connection();
xcb_connection_t *c = xcbConnection();
const QByteArray &name = QByteArrayLiteral("_KDE_LOGGING_OUT");
const auto cookie = xcb_intern_atom(c, false, name.length(), name.constData());
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, cookie, nullptr));
......
......@@ -90,7 +90,7 @@ void MagnifierEffect::destroyPixmap()
}
m_picture.reset();
if (m_pixmap != XCB_PIXMAP_NONE) {
xcb_free_pixmap(connection(), m_pixmap);
xcb_free_pixmap(xcbConnection(), m_pixmap);
m_pixmap = XCB_PIXMAP_NONE;
}
#endif
......@@ -196,9 +196,9 @@ void MagnifierEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if (m_pixmap == XCB_PIXMAP_NONE || m_pixmapSize != srcArea.size()) {
destroyPixmap();
m_pixmap = xcb_generate_id(connection());
m_pixmap = xcb_generate_id(xcbConnection());
m_pixmapSize = srcArea.size();
xcb_create_pixmap(connection(), 32, m_pixmap, rootWindow(), m_pixmapSize.width(), m_pixmapSize.height());
xcb_create_pixmap(xcbConnection(), 32, m_pixmap, x11RootWindow(), m_pixmapSize.width(), m_pixmapSize.height());
m_picture.reset(new XRenderPicture(m_pixmap, 32));
}
#define DOUBLE_TO_FIXED(d) ((xcb_render_fixed_t) ((d) * 65536))
......@@ -212,25 +212,25 @@ void MagnifierEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat
DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(1), DOUBLE_TO_FIXED(0),
DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(1)
};
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), 0, *m_picture,
xcb_render_composite(xcbConnection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), 0, *m_picture,
srcArea.x(), srcArea.y(), 0, 0, 0, 0, srcArea.width(), srcArea.height());
xcb_flush(connection());
xcb_flush(xcbConnection());
xform.matrix11 = DOUBLE_TO_FIXED(1.0/zoom);
xform.matrix22 = DOUBLE_TO_FIXED(1.0/zoom);
#undef DOUBLE_TO_FIXED
xcb_render_set_picture_transform(connection(), *m_picture, xform);
xcb_render_set_picture_filter(connection(), *m_picture, 4, const_cast<char*>("good"), 0, NULL);
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_SRC, *m_picture, 0, effects->xrenderBufferPicture(),
xcb_render_set_picture_transform(xcbConnection(), *m_picture, xform);
xcb_render_set_picture_filter(xcbConnection(), *m_picture, 4, const_cast<char*>("good"), 0, NULL);
xcb_render_composite(xcbConnection(), XCB_RENDER_PICT_OP_SRC, *m_picture, 0, effects->xrenderBufferPicture(),
0, 0, 0, 0, area.x(), area.y(), area.width(), area.height() );
xcb_render_set_picture_filter(connection(), *m_picture, 4, const_cast<char*>("fast"), 0, NULL);
xcb_render_set_picture_transform(connection(), *m_picture, identity);
xcb_render_set_picture_filter(xcbConnection(), *m_picture, 4, const_cast<char*>("fast"), 0, NULL);
xcb_render_set_picture_transform(xcbConnection(), *m_picture, identity);
const xcb_rectangle_t rects[4] = {
{ int16_t(area.x()+FRAME_WIDTH), int16_t(area.y()), uint16_t(area.width()-FRAME_WIDTH), uint16_t(FRAME_WIDTH)},
{ int16_t(area.right()-FRAME_WIDTH), int16_t(area.y()+FRAME_WIDTH), uint16_t(FRAME_WIDTH), uint16_t(area.height()-FRAME_WIDTH)},
{ int16_t(area.x()), int16_t(area.bottom()-FRAME_WIDTH), uint16_t(area.width()-FRAME_WIDTH), uint16_t(FRAME_WIDTH)},
{ int16_t(area.x()), int16_t(area.y()), uint16_t(FRAME_WIDTH), uint16_t(area.height()-FRAME_WIDTH)}
};
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(),
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(),
preMultiply(QColor(0,0,0,255)), 4, rects);
#endif
}
......
......@@ -351,7 +351,7 @@ void MouseClickEffect::drawCircleXr(const QColor& color, float cx, float cy, flo
strip << point;
XRenderPicture fill = xRenderFill(color);
xcb_render_tri_strip(connection(), XCB_RENDER_PICT_OP_OVER,
xcb_render_tri_strip(xcbConnection(), XCB_RENDER_PICT_OP_OVER,
fill, effects->xrenderBufferPicture(), 0,
0, 0, strip.count(), strip.constData());
#undef DOUBLE_TO_FIXED
......
......@@ -101,7 +101,7 @@ void MouseMarkEffect::addRect(const QPoint &p1, const QPoint &p2, xcb_rectangle_
rects[i-1].y = p1.y() + i*h/n;
rects[i-1].width = rects[i-1].height = width;
}
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), *c, n - 1, rects);
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), *c, n - 1, rects);
delete [] rects;
r->x = p1.x();
r->y = p1.y();
......@@ -159,7 +159,7 @@ void MouseMarkEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat
for (int j = 0; j < marks[i].count()-1; ++j) {
addRect(marks[i][j], marks[i][j+1], &rects[j], &c);
}
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), c, n, rects);
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), c, n, rects);
delete [] rects;
}
}
......@@ -168,7 +168,7 @@ void MouseMarkEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat
xcb_rectangle_t *rects = new xcb_rectangle_t[n];
for (int i = 0; i < n; ++i)
addRect(drawing[i], drawing[i+1], &rects[i], &c);
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), c, n, rects);
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), c, n, rects);
delete [] rects;
}
}
......
......@@ -112,7 +112,7 @@ void ResizeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Window
xcb_rectangle_t rect = {int16_t(r.x()), int16_t(r.y()), uint16_t(r.width()), uint16_t(r.height())};
rects << rect;
}
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_OVER,
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_OVER,
effects->xrenderBufferPicture(), preMultiply(color, alpha),
rects.count(), rects.constData());
}
......
......@@ -120,7 +120,7 @@ void ScreenEdgeEffect::paintScreen(int mask, QRegion region, ScreenPaintData &da
// nothing
break;
}
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, *(*it)->picture.data(),
xcb_render_composite(xcbConnection(), XCB_RENDER_PICT_OP_OVER, *(*it)->picture.data(),
xRenderBlendPicture(opacity), effects->xrenderBufferPicture(),
0, 0, 0, 0, x, y, width, height);
#endif
......
......@@ -55,16 +55,17 @@ ScreenShotEffect::~ScreenShotEffect()
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
static QImage xPictureToImage(xcb_render_picture_t srcPic, const QRect &geometry, xcb_image_t **xImage)
{
xcb_pixmap_t xpix = xcb_generate_id(connection());
xcb_create_pixmap(connection(), 32, xpix, rootWindow(), geometry.width(), geometry.height());
xcb_connection_t *c = effects->xcbConnection();
xcb_pixmap_t xpix = xcb_generate_id(c);
xcb_create_pixmap(c, 32, xpix, effects->x11RootWindow(), geometry.width(), geometry.height());
XRenderPicture pic(xpix, 32);
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_SRC, srcPic, XCB_RENDER_PICTURE_NONE, pic,
xcb_render_composite(c, XCB_RENDER_PICT_OP_SRC, srcPic, XCB_RENDER_PICTURE_NONE, pic,
geometry.x(), geometry.y(), 0, 0, 0, 0, geometry.width(), geometry.height());
xcb_flush(connection());
*xImage = xcb_image_get(connection(), xpix, 0, 0, geometry.width(), geometry.height(), ~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
xcb_flush(c);
*xImage = xcb_image_get(c, xpix, 0, 0, geometry.width(), geometry.height(), ~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
QImage img((*xImage)->data, (*xImage)->width, (*xImage)->height, (*xImage)->stride, QImage::Format_ARGB32_Premultiplied);
// TODO: byte order might need swapping
xcb_free_pixmap(connection(), xpix);
xcb_free_pixmap(c, xpix);
return img;
}
#endif
......@@ -159,15 +160,15 @@ void ScreenShotEffect::postPaintScreen()
}
const int depth = img.depth();
xcb_pixmap_t xpix = xcb_generate_id(connection());
xcb_create_pixmap(connection(), depth, xpix, rootWindow(), img.width(), img.height());
xcb_pixmap_t xpix = xcb_generate_id(xcbConnection());
xcb_create_pixmap(xcbConnection(), depth, xpix, x11RootWindow(), img.width(), img.height());
xcb_gcontext_t cid = xcb_generate_id(connection());
xcb_create_gc(connection(), cid, xpix, 0, NULL);
xcb_put_image(connection(), XCB_IMAGE_FORMAT_Z_PIXMAP, xpix, cid, img.width(), img.height(),
xcb_gcontext_t cid = xcb_generate_id(xcbConnection());
xcb_create_gc(xcbConnection(), cid, xpix, 0, NULL);
xcb_put_image(xcbConnection(), XCB_IMAGE_FORMAT_Z_PIXMAP, xpix, cid, img.width(), img.height(),
0, 0, 0, depth, img.byteCount(), img.constBits());
xcb_free_gc(connection(), cid);
xcb_flush(connection());
xcb_free_gc(xcbConnection(), cid);
xcb_flush(xcbConnection());
emit screenshotCreated(xpix);
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if (xImage) {
......@@ -301,8 +302,8 @@ void ScreenShotEffect::grabPointerImage(QImage& snapshot, int offsetx, int offse
// Uses the X11_EXTENSIONS_XFIXES_H extension to grab the pointer image, and overlays it onto the snapshot.
{
QScopedPointer<xcb_xfixes_get_cursor_image_reply_t, QScopedPointerPodDeleter> cursor(
xcb_xfixes_get_cursor_image_reply(connection(),
xcb_xfixes_get_cursor_image_unchecked(connection()),
xcb_xfixes_get_cursor_image_reply(xcbConnection(),
xcb_xfixes_get_cursor_image_unchecked(xcbConnection()),
NULL));
if (cursor.isNull())
return;
......
......@@ -164,7 +164,7 @@ void ShowFpsEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if (effects->compositingType() == XRenderCompositing) {
paintXrender(fps);
xcb_flush(connection()); // make sure all rendering is done
xcb_flush(xcbConnection()); // make sure all rendering is done
}
#endif
if (effects->compositingType() == QPainterCompositing) {
......@@ -257,24 +257,24 @@ void ShowFpsEffect::paintGL(int fps)
*/
void ShowFpsEffect::paintXrender(int fps)
{
xcb_pixmap_t pixmap = xcb_generate_id(connection());
xcb_create_pixmap(connection(), 32, pixmap, rootWindow(), FPS_WIDTH, MAX_TIME);
xcb_pixmap_t pixmap = xcb_generate_id(xcbConnection());
xcb_create_pixmap(xcbConnection(), 32, pixmap, x11RootWindow(), FPS_WIDTH, MAX_TIME);
XRenderPicture p(pixmap, 32);
xcb_free_pixmap(connection(), pixmap);
xcb_free_pixmap(xcbConnection(), pixmap);
xcb_render_color_t col;
col.alpha = int(alpha * 0xffff);
col.red = int(alpha * 0xffff); // white
col.green = int(alpha * 0xffff);
col.blue = int(alpha * 0xffff);
xcb_rectangle_t rect = {0, 0, FPS_WIDTH, MAX_TIME};
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, p, col, 1, &rect);
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, p, col, 1, &rect);
col.red = 0; // blue
col.green = 0;
col.blue = int(alpha * 0xffff);
rect.y = MAX_TIME - fps;
rect.width = FPS_WIDTH;
rect.height = fps;
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, p, col, 1, &rect);
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, p, col, 1, &rect);
col.red = 0; // black
col.green = 0;
col.blue = 0;
......@@ -285,8 +285,8 @@ void ShowFpsEffect::paintXrender(int fps)
xcb_rectangle_t rect = {0, int16_t(MAX_TIME - i), uint16_t(FPS_WIDTH), 1};
rects << rect;
}
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, p, col, rects.count(), rects.constData());
xcb_render_composite(connection(), alpha != 1.0 ? XCB_RENDER_PICT_OP_OVER : XCB_RENDER_PICT_OP_SRC, p, XCB_RENDER_PICTURE_NONE,
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, p, col, rects.count(), rects.constData());
xcb_render_composite(xcbConnection(), alpha != 1.0 ? XCB_RENDER_PICT_OP_OVER : XCB_RENDER_PICT_OP_SRC, p, XCB_RENDER_PICTURE_NONE,
effects->xrenderBufferPicture(), 0, 0, 0, 0, x, y, FPS_WIDTH, MAX_TIME);
......@@ -300,7 +300,7 @@ void ShowFpsEffect::paintXrender(int fps)
if (fpsTextRect.isValid()) {
QImage textImg(fpsTextImage(fps));
XRenderPicture textPic(textImg);
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, textPic, XCB_RENDER_PICTURE_NONE,
xcb_render_composite(xcbConnection(), XCB_RENDER_PICT_OP_OVER, textPic, XCB_RENDER_PICTURE_NONE,
effects->xrenderBufferPicture(), 0, 0, 0, 0, fpsTextRect.x(), fpsTextRect.y(), textImg.width(), textImg.height());
effects->addRepaint(fpsTextRect);
}
......@@ -435,17 +435,17 @@ void ShowFpsEffect::paintGraph(int x, int y, QList<int> values, QList<int> lines
}
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if (effects->compositingType() == XRenderCompositing) {
xcb_pixmap_t pixmap = xcb_generate_id(connection());
xcb_create_pixmap(connection(), 32, pixmap, rootWindow(), values.count(), MAX_TIME);
xcb_pixmap_t pixmap = xcb_generate_id(xcbConnection());
xcb_create_pixmap(xcbConnection(), 32, pixmap, x11RootWindow(), values.count(), MAX_TIME);
XRenderPicture p(pixmap, 32);
xcb_free_pixmap(connection(), pixmap);
xcb_free_pixmap(xcbConnection(), pixmap);
xcb_render_color_t col;
col.alpha = int(alpha * 0xffff);
// Draw background
col.red = col.green = col.blue = int(alpha * 0xffff); // white
xcb_rectangle_t rect = {0, 0, uint16_t(values.count()), uint16_t(MAX_TIME)};
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, p, col, 1, &rect);
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, p, col, 1, &rect);
// Then the values
col.red = col.green = col.blue = int(alpha * 0x8000); // grey
......@@ -475,7 +475,7 @@ void ShowFpsEffect::paintGraph(int x, int y, QList<int> values, QList<int> lines
}
}
xcb_rectangle_t rect = {int16_t(values.count() - i), int16_t(MAX_TIME - value), 1, uint16_t(value)};
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, p, col, 1, &rect);
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, p, col, 1, &rect);
}
// Then the lines
......@@ -485,10 +485,10 @@ void ShowFpsEffect::paintGraph(int x, int y, QList<int> values, QList<int> lines
xcb_rectangle_t rect = {0, int16_t(MAX_TIME - h), uint16_t(values.count()), 1};
rects << rect;
}
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, p, col, rects.count(), rects.constData());
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_SRC, p, col, rects.count(), rects.constData());
// Finally render the pixmap onto screen
xcb_render_composite(connection(), alpha != 1.0 ? XCB_RENDER_PICT_OP_OVER : XCB_RENDER_PICT_OP_SRC, p,
xcb_render_composite(xcbConnection(), alpha != 1.0 ? XCB_RENDER_PICT_OP_OVER : XCB_RENDER_PICT_OP_SRC, p,
XCB_RENDER_PICTURE_NONE, effects->xrenderBufferPicture(), 0, 0, 0, 0, x, y, values.count(), MAX_TIME);
}
#endif
......
......@@ -113,7 +113,7 @@ void ShowPaintEffect::paintXrender()
xcb_rectangle_t rect = {int16_t(r.x()), int16_t(r.y()), uint16_t(r.width()), uint16_t(r.height())};
rects << rect;
}
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_OVER, effects->xrenderBufferPicture(), col, rects.count(), rects.constData());
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_OVER, effects->xrenderBufferPicture(), col, rects.count(), rects.constData());
#endif
}
......
......@@ -154,7 +154,7 @@ void SnapHelperEffect::postPaintScreen()
rects[5].width = 4;
rects[5].height = 2*halfHeight - 4;
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_OVER, effects->xrenderBufferPicture(),
xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_OVER, effects->xrenderBufferPicture(),
preMultiply(QColor(128, 128, 128, m_timeline.currentValue()*128)), 6, rects);
}
#endif
......
......@@ -164,10 +164,10 @@ void TrackMouseEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da
DOUBLE_TO_FIXED( 0.0 ), DOUBLE_TO_FIXED( 0.0 ), DOUBLE_TO_FIXED( 1.0 )
};
#undef DOUBLE_TO_FIXED
xcb_render_set_picture_transform(connection(), picture, xform);
xcb_render_set_picture_filter(connection(), picture, 8, "bilinear", 0, NULL);
xcb_render_set_picture_transform(xcbConnection(), picture, xform);
xcb_render_set_picture_filter(xcbConnection(), picture, 8, "bilinear", 0, NULL);
const QRect &rect = m_lastRect[i];
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, picture, XCB_RENDER_PICTURE_NONE,
xcb_render_composite(xcbConnection(), XCB_RENDER_PICT_OP_OVER, picture, XCB_RENDER_PICTURE_NONE,
effects->xrenderBufferPicture(), 0, 0, 0, 0,
rect.x(), rect.y(), rect.width(), rect.height());
}
......
......@@ -154,7 +154,7 @@ void ZoomEffect::showCursor()
{
if (isMouseHidden) {
// show the previously hidden mouse-pointer again and free the loaded texture/picture.
xcb_xfixes_show_cursor(connection(), rootWindow());
xcb_xfixes_show_cursor(xcbConnection(), x11RootWindow());
texture.reset();
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
xrenderPicture.reset();
......@@ -179,7 +179,7 @@ void ZoomEffect::hideCursor()
#endif
}
if (shouldHide) {
xcb_xfixes_hide_cursor(connection(), rootWindow());
xcb_xfixes_hide_cursor(xcbConnection(), x11RootWindow());
isMouseHidden = true;
}
}
......@@ -386,18 +386,18 @@ void ZoomEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(1)
};
if (mousePointer == MousePointerScale) {
xcb_render_set_picture_filter(connection(), *xrenderPicture, 4, const_cast<char*>("good"), 0, NULL);
xcb_render_set_picture_filter(xcbConnection(), *xrenderPicture, 4, const_cast<char*>("good"), 0, NULL);
const xcb_render_transform_t xform = {
DOUBLE_TO_FIXED(1.0 / zoom), DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(0),
DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(1.0 / zoom), DOUBLE_TO_FIXED(0),
DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(1)
};
xcb_render_set_picture_transform(connection(), *xrenderPicture, xform);
xcb_render_set_picture_transform(xcbConnection(), *xrenderPicture, xform);
}
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, *xrenderPicture, XCB_RENDER_PICTURE_NONE,
xcb_render_composite(xcbConnection(), XCB_RENDER_PICT_OP_OVER, *xrenderPicture, XCB_RENDER_PICTURE_NONE,
effects->xrenderBufferPicture(), 0, 0, 0, 0, rect.x(), rect.y(), rect.width(), rect.height());
if (mousePointer == MousePointerScale)
xcb_render_set_picture_transform(connection(), *xrenderPicture, xrenderIdentity);
xcb_render_set_picture_transform(xcbConnection(), *xrenderPicture, xrenderIdentity);
#undef DOUBLE_TO_FIXED
}
#endif
......
......@@ -608,6 +608,16 @@ int Effect::requestedEffectChainPosition() const
return 0;
}
xcb_connection_t *Effect::xcbConnection() const
{
return effects->xcbConnection();
}
xcb_window_t Effect::x11RootWindow() const
{
return effects->x11RootWindow();
}
//****************************************
// EffectFactory
//****************************************
......
......@@ -577,6 +577,10 @@ public:
public Q_SLOTS:
virtual bool borderActivated(ElectricBorder border);
protected:
xcb_connection_t *xcbConnection() const;
xcb_window_t x11RootWindow() const;
};
......@@ -1078,6 +1082,9 @@ public:
*/
virtual void doneOpenGLContextCurrent() = 0;
virtual xcb_connection_t *xcbConnection() const = 0;
virtual xcb_window_t x11RootWindow() const = 0;
/**
* @return @ref KConfigGroup which holds given effect's config options
**/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment