diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11c47b208d..1269eaff59 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -176,7 +176,7 @@ qt4_add_dbus_interface( kwin_KDEINIT_SRCS
qt4_add_resources( kwin_KDEINIT_SRCS resources.qrc )
-set(kwinLibs ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTDECLARATIVE_LIBRARY} ${KDECLARATIVE_LIBRARIES} kdecorations kwineffects ${X11_LIBRARIES} ${X11_Xrandr_LIB} ${X11_Xcomposite_LIB} ${X11_Xdamage_LIB} ${X11_Xrender_LIB} ${X11_Xfixes_LIB} ${XCB_XCB_LIBRARIES} ${X11_XCB_LIBRARIES} ${XCB_XFIXES_LIBRARIES} ${XCB_DAMAGE_LIBRARIES})
+set(kwinLibs ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTDECLARATIVE_LIBRARY} ${KDECLARATIVE_LIBRARIES} kdecorations kwineffects ${X11_LIBRARIES} ${X11_Xrandr_LIB} ${X11_Xcomposite_LIB} ${X11_Xdamage_LIB} ${X11_Xrender_LIB} ${X11_Xfixes_LIB} ${XCB_XCB_LIBRARIES} ${X11_XCB_LIBRARIES} ${XCB_XFIXES_LIBRARIES} ${XCB_DAMAGE_LIBRARIES} ${XCB_COMPOSITE_LIBRARIES})
find_library(XF86VM_LIBRARY Xxf86vm)
if (XF86VM_LIBRARY)
diff --git a/composite.cpp b/composite.cpp
index 0d8c909a31..24dba37877 100644
--- a/composite.cpp
+++ b/composite.cpp
@@ -69,13 +69,13 @@ along with this program. If not, see .
#include
#include
#include
-#include
#include
#include
#include
+#include
#include
namespace KWin
@@ -886,33 +886,45 @@ void Toplevel::finishCompositing()
void Toplevel::discardWindowPixmap()
{
addDamageFull();
- if (window_pix == None)
+ if (window_pix == XCB_PIXMAP_NONE)
return;
- XFreePixmap(display(), window_pix);
- window_pix = None;
+ xcb_free_pixmap(connection(), window_pix);
+ window_pix = XCB_PIXMAP_NONE;
if (effectWindow() != NULL && effectWindow()->sceneWindow() != NULL)
effectWindow()->sceneWindow()->pixmapDiscarded();
}
-Pixmap Toplevel::createWindowPixmap()
+xcb_pixmap_t Toplevel::createWindowPixmap()
{
assert(compositing());
if (unredirected())
- return None;
- grabXServer();
- KXErrorHandler err;
- Pixmap pix = XCompositeNameWindowPixmap(display(), frameId());
+ return XCB_PIXMAP_NONE;
+ XServerGrabber grabber();
+ xcb_pixmap_t pix = xcb_generate_id(connection());
+ xcb_void_cookie_t namePixmapCookie = xcb_composite_name_window_pixmap_checked(connection(), frameId(), pix);
+ xcb_get_window_attributes_cookie_t attribsCookie = xcb_get_window_attributes(connection(), frameId());
+ xcb_get_geometry_cookie_t geometryCookie = xcb_get_geometry(connection(), frameId());
+ if (xcb_generic_error_t *error = xcb_request_check(connection(), namePixmapCookie)) {
+ kDebug(1212) << "Creating window pixmap failed: " << error->error_code;
+ free(error);
+ return XCB_PIXMAP_NONE;
+ }
// check that the received pixmap is valid and actually matches what we
// know about the window (i.e. size)
- XWindowAttributes attrs;
- if (!XGetWindowAttributes(display(), frameId(), &attrs)
- || err.error(false)
- || attrs.width != width() || attrs.height != height() || attrs.map_state != IsViewable) {
+ ScopedCPointer error;
+ ScopedCPointer attribs(xcb_get_window_attributes_reply(connection(), attribsCookie, &error));
+ if (!error.isNull() || attribs.isNull() || attribs->map_state != XCB_MAP_STATE_VIEWABLE) {
kDebug(1212) << "Creating window pixmap failed: " << this;
- XFreePixmap(display(), pix);
- pix = None;
+ xcb_free_pixmap(connection(), pix);
+ return XCB_PIXMAP_NONE;
+ }
+ ScopedCPointer geometry(xcb_get_geometry_reply(connection(), geometryCookie, &error));
+ if (!error.isNull() || geometry.isNull() ||
+ geometry->width != width() || geometry->height != height()) {
+ kDebug(1212) << "Creating window pixmap failed: " << this;
+ xcb_free_pixmap(connection(), pix);
+ return XCB_PIXMAP_NONE;
}
- ungrabXServer();
return pix;
}
diff --git a/toplevel.h b/toplevel.h
index 371490891e..a8c76977d6 100644
--- a/toplevel.h
+++ b/toplevel.h
@@ -329,7 +329,7 @@ protected:
void detectShape(Window id);
virtual void propertyNotifyEvent(XPropertyEvent* e);
virtual void damageNotifyEvent(XDamageNotifyEvent* e);
- Pixmap createWindowPixmap();
+ xcb_pixmap_t createWindowPixmap();
void discardWindowPixmap();
void addDamageFull();
void getWmClientLeader();