summaryrefslogtreecommitdiff
path: root/src/drivers/X11/Fl_X11_Window_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2019-02-23 10:21:27 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2019-02-23 10:21:27 +0100
commit21c0134931ef22d6645fc182d7812776e14e369d (patch)
tree14e41d62f041a000214442be26aefb33eb911c02 /src/drivers/X11/Fl_X11_Window_Driver.cxx
parentf9255e375cb4751404e33837cdddd6f2d31d96b9 (diff)
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.
Diffstat (limited to 'src/drivers/X11/Fl_X11_Window_Driver.cxx')
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.cxx12
1 files changed, 10 insertions, 2 deletions
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