fix bug that graphics::make({0, 0}) behaves differently between Windows

and Linux
This commit is contained in:
Jinhao 2017-07-17 22:31:29 +08:00
parent 130ba79705
commit 64dbd2100c
2 changed files with 12 additions and 2 deletions

View File

@ -91,7 +91,11 @@ namespace nana
const void* pixmap() const;
const void* context() const;
void make(const ::nana::size&); ///< Creates a bitmap resource that size is width by height in pixel
/// Creates a graphics/drawable resource
/**
* @param sz The dimension of the graphics to be requested. If sz is empty, it performs as release().
*/
void make(const ::nana::size& sz);
void resize(const ::nana::size&);
void typeface(const font&); ///< Selects a specified font type into the graphics object.
font typeface() const;

View File

@ -291,6 +291,12 @@ namespace paint
{
if(impl_->handle == nullptr || impl_->size != sz)
{
if (sz.empty())
{
release();
return;
}
//The object will be delete while dwptr_ is performing a release.
drawable_type dw = new nana::detail::drawable_impl_type;
//Reuse the old font
@ -342,7 +348,7 @@ namespace paint
Display* disp = spec.open_display();
int screen = DefaultScreen(disp);
Window root = ::XRootWindow(disp, screen);
dw->pixmap = ::XCreatePixmap(disp, root, (sz.width ? sz.width : 1), (sz.height ? sz.height : 1), DefaultDepth(disp, screen));
dw->pixmap = ::XCreatePixmap(disp, root, sz.width, sz.height, DefaultDepth(disp, screen));
dw->context = ::XCreateGC(disp, dw->pixmap, 0, 0);
#if defined(NANA_USE_XFT)
dw->xftdraw = ::XftDrawCreate(disp, dw->pixmap, spec.screen_visual(), spec.colormap());