From 680c173947c5ff001b9fa780b39b39c21a31c884 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 5 May 2011 20:41:01 +0100 Subject: [PATCH] framebuffer: in onscreen_x11_get_xid return foreign xids If a foreign xid has been set on a CoglOnscreen then cogl_onscreen_x11_get_window_xid doesn't need to defer to the winsys to get the underlying window xid. This also means it's possible to read back the xid before the framebuffer is allocated which fixes a crash in the x11-foreign example app. --- cogl/cogl-framebuffer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index daf817ab2..e4656f624 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -1641,9 +1641,14 @@ guint32 cogl_onscreen_x11_get_window_xid (CoglOnscreen *onscreen) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); - const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer); - return winsys->onscreen_x11_get_window_xid (onscreen); + if (onscreen->foreign_xid) + return onscreen->foreign_xid; + else + { + const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer); + return winsys->onscreen_x11_get_window_xid (onscreen); + } } guint32