From 9d83b6cafa1228dd32e11e9dd9c3659ecab75bef Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 28 Nov 2010 18:42:31 +0000 Subject: [PATCH] *CtrlCore: ImageX11 fix, DHCtrl fix git-svn-id: svn://ultimatepp.org/upp/trunk@2873 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/ImageX11.cpp | 24 ++++++++++++++---------- uppsrc/CtrlCore/X11DHCtrl.cpp | 3 ++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/uppsrc/CtrlCore/ImageX11.cpp b/uppsrc/CtrlCore/ImageX11.cpp index 9ad746994..3048c1c8c 100644 --- a/uppsrc/CtrlCore/ImageX11.cpp +++ b/uppsrc/CtrlCore/ImageX11.cpp @@ -287,6 +287,8 @@ ImageDraw::operator Image() const { GuiLock __; XImage *xim = XGetImage(Xdisplay, dw, 0, 0, max(size.cx, 1), max(size.cy, 1), AllPlanes, ZPixmap); + if(!xim) + return Null; Visual *v = DefaultVisual(Xdisplay, Xscreenno); RasterFormat fmt; @@ -345,17 +347,19 @@ ImageDraw::operator Image() const } XDestroyImage(xim); if(has_alpha) { - xim = XGetImage(Xdisplay, alpha.dw, 0, 0, size.cx, size.cy, AllPlanes, ZPixmap); - const byte *s = (const byte *)xim->data; - t = ib; - Buffer line(size.cx); - for(int y = 0; y < size.cy; y++) { - fmt.Read(line, s, size.cx, palette); - for(int x = 0; x < size.cx; x++) - (t++)->a = line[x].r; - s += xim->bytes_per_line; + xim = XGetImage(Xdisplay, alpha.dw, 0, 0, max(size.cx, 1), max(size.cy, 1), AllPlanes, ZPixmap); + if(xim) { + const byte *s = (const byte *)xim->data; + t = ib; + Buffer line(size.cx); + for(int y = 0; y < size.cy; y++) { + fmt.Read(line, s, size.cx, palette); + for(int x = 0; x < size.cx; x++) + (t++)->a = line[x].r; + s += xim->bytes_per_line; + } + XDestroyImage(xim); } - XDestroyImage(xim); } Premultiply(ib); return ib; diff --git a/uppsrc/CtrlCore/X11DHCtrl.cpp b/uppsrc/CtrlCore/X11DHCtrl.cpp index c83259261..713952030 100644 --- a/uppsrc/CtrlCore/X11DHCtrl.cpp +++ b/uppsrc/CtrlCore/X11DHCtrl.cpp @@ -155,7 +155,8 @@ bool DHCtrl::Init() ); } else { XReparentWindow(Xdisplay, hwnd, GetParentWindow(), r.left, r.top); - XMoveResizeWindow(Xdisplay, hwnd, r.left, r.top, r.Width(), r.Height()); + XResizeWindow(Xdisplay, hwnd, r.Width(), r.Height()); + XChangeWindowAttributes(Xdisplay, hwnd, ValueMask, &winAttributes); } // Frees VisualInfo