From 21c0134931ef22d6645fc182d7812776e14e369d Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sat, 23 Feb 2019 10:21:27 +0100 Subject: New member function const Fl_Image* Fl_Window::shape() replaces int Fl_Window::is_shaped() The new function allows to get the window's shaping image and delete it after use, if appropriate. --- src/drivers/X11/Fl_X11_Window_Driver.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/drivers/X11/Fl_X11_Window_Driver.cxx') diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index 1d0af72e9..7a75e8188 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -291,6 +291,7 @@ void Fl_X11_Window_Driver::shape_alpha_(Fl_Image* img, int offset) { bitmap->alloc_array = 1; shape_bitmap_(bitmap); shape_data_->todelete_ = bitmap; + shape_data_->shape_ = img; } void Fl_X11_Window_Driver::shape(const Fl_Image* img) { @@ -303,7 +304,10 @@ void Fl_X11_Window_Driver::shape(const Fl_Image* img) { memset(shape_data_, 0, sizeof(shape_data_type)); pWindow->border(false); int d = img->d(); - if (d && img->count() >= 2) shape_pixmap_((Fl_Image*)img); + if (d && img->count() >= 2) { + shape_pixmap_((Fl_Image*)img); + shape_data_->shape_ = (Fl_Image*)img; + } else if (d == 0) shape_bitmap_((Fl_Image*)img); else if (d == 2 || d == 4) shape_alpha_((Fl_Image*)img, d - 1); else if ((d == 1 || d == 3) && img->count() == 1) shape_alpha_((Fl_Image*)img, 0); @@ -333,7 +337,8 @@ void Fl_X11_Window_Driver::combine_mask() float s = Fl::screen_driver()->scale(screen_num()); shape_data_->lw_ = w()*s; shape_data_->lh_ = h()*s; - Fl_Image* temp = shape_data_->shape_->copy(shape_data_->lw_, shape_data_->lh_); + Fl_Image* temp = shape_data_->todelete_ ? shape_data_->todelete_ : shape_data_->shape_; + temp = temp->copy(shape_data_->lw_, shape_data_->lh_); Pixmap pbitmap = XCreateBitmapFromData(fl_display, fl_xid(pWindow), (const char*)*temp->data(), temp->w(), temp->h()); @@ -682,6 +687,9 @@ Fl_X *Fl_X11_Window_Driver::makeWindow() return Fl_X::i(pWindow); } +const Fl_Image* Fl_X11_Window_Driver::shape() { + return shape_data_ ? shape_data_->shape_ : NULL; +} #if USE_XFT -- cgit v1.2.3