Port create/discardWindowPixmap to XCB
This commit is contained in:
parent
e96ff7a31a
commit
a798a2d3d6
3 changed files with 30 additions and 18 deletions
|
@ -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)
|
||||
|
|
|
@ -69,13 +69,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <kaction.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <klocale.h>
|
||||
#include <kxerrorhandler.h>
|
||||
|
||||
#include <X11/extensions/shape.h>
|
||||
|
||||
#include <X11/extensions/Xcomposite.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
|
||||
#include <xcb/composite.h>
|
||||
#include <xcb/damage.h>
|
||||
|
||||
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<xcb_generic_error_t> error;
|
||||
ScopedCPointer<xcb_get_window_attributes_reply_t> 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<xcb_get_geometry_reply_t> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue