From cb2c8d6d7d7c7aa7bce2513e751a758b94fae166 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 5 Jan 2017 04:38:29 +0800 Subject: [PATCH] fix issue in graphics::paste that would show the window when graphics::paste to the invisible window --- source/paint/graphics.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index 2114d69a..201d18a8 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -777,12 +777,22 @@ namespace paint ::ReleaseDC(reinterpret_cast(dst), dc); } #elif defined(NANA_X11) - Display * display = nana::detail::platform_spec::instance().open_display(); + auto & spec = nana::detail::platform_spec::instance(); + + Display * display = spec.open_display(); + + nana::detail::platform_scope_guard lock; + ::XCopyArea(display, impl_->handle->pixmap, reinterpret_cast(dst), impl_->handle->context, sx, sy, width, height, dx, dy); - ::XMapWindow(display, reinterpret_cast(dst)); + XWindowAttributes attr; + spec.set_error_handler(); + ::XGetWindowAttributes(display, reinterpret_cast(dst), &attr); + if(BadWindow != spec.rev_error_handler() && attr.map_state != IsUnmapped) + ::XMapWindow(display, reinterpret_cast(dst)); + ::XFlush(display); #endif }