summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Window.H2
-rw-r--r--src/Fl_Screen_Driver.cxx3
-rw-r--r--src/Fl_Window.cxx4
-rw-r--r--src/Fl_Window_Driver.H1
-rw-r--r--src/Fl_cocoa.mm2
-rw-r--r--src/Fl_x.cxx2
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H1
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx9
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H1
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx13
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.H1
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.cxx12
12 files changed, 39 insertions, 12 deletions
diff --git a/FL/Fl_Window.H b/FL/Fl_Window.H
index 9ffe218e8..eacea6f94 100644
--- a/FL/Fl_Window.H
+++ b/FL/Fl_Window.H
@@ -542,7 +542,7 @@ public:
void shape(const Fl_Image* img);
void shape(const Fl_Image& b) ;
- int is_shaped();
+ const Fl_Image *shape();
int screen_num();
};
diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx
index 4255d6444..44c92a5c7 100644
--- a/src/Fl_Screen_Driver.cxx
+++ b/src/Fl_Screen_Driver.cxx
@@ -330,7 +330,7 @@ void Fl_Screen_Driver::rescale_all_windows_from_screen(int screen, float f)
static void del_transient_window(void *data) {
Fl_Window *win = (Fl_Window*)data;
- delete (Fl_RGB_Image*)win->child(0)->user_data();
+ delete (Fl_Image*)win->shape();
Fl::delete_widget(win);
}
@@ -369,7 +369,6 @@ void Fl_Screen_Driver::transient_scale_display(float f, int nscreen)
b->color(Fl_Tooltip::color());
win->end();
win->shape(img);
- b->user_data(img);
win->user_data((void*)&transient_scale_display); // prevent this window from being rescaled later
win->set_output();
win->set_non_modal();
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index 0cde4989d..f664b1fc9 100644
--- a/src/Fl_Window.cxx
+++ b/src/Fl_Window.cxx
@@ -679,8 +679,8 @@ void Fl_Window::shape(const Fl_Image* img) {pWindowDriver->shape(img);}
*/
void Fl_Window::shape(const Fl_Image& img) {pWindowDriver->shape(&img);}
-/** Returns non NULL when the window has been assigned a non-rectangular shape */
-int Fl_Window::is_shaped() {return pWindowDriver->shape_data_ != NULL;}
+/** Returns the image controlling the window shape or NULL */
+const Fl_Image* Fl_Window::shape() {return pWindowDriver->shape();}
//
// End of "$Id$".
diff --git a/src/Fl_Window_Driver.H b/src/Fl_Window_Driver.H
index d1fba2e8d..8bf8a89a8 100644
--- a/src/Fl_Window_Driver.H
+++ b/src/Fl_Window_Driver.H
@@ -127,6 +127,7 @@ public:
// --- window data
virtual int decorated_w() { return w(); } // default, should be overidden by driver
virtual int decorated_h() { return h(); }
+ virtual const Fl_Image* shape() { return NULL; }
// --- window management
virtual void take_focus();
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 223e0bc47..6bbdd731c 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -3131,7 +3131,7 @@ Fl_X* Fl_Cocoa_Window_Driver::makeWindow()
[cw setHasShadow:YES];
[cw setAcceptsMouseMovedEvents:YES];
}
- if (w->is_shaped()) {
+ if (w->shape()) {
[cw setOpaque:NO]; // shaped windows must be non opaque
[cw setBackgroundColor:[NSColor clearColor]]; // and with transparent background color
}
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index 6272f8694..619782af8 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -2607,7 +2607,7 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
}
#endif
- if (win->is_shaped()) {
+ if (win->shape()) {
Fl_X11_Window_Driver::driver(win)->combine_mask();
}
XMapWindow(fl_display, xp->xid);
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
index 70d1dffcf..33a47448c 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
@@ -108,6 +108,7 @@ public:
// --- window data
virtual int decorated_w();
virtual int decorated_h();
+ virtual const Fl_Image* shape();
// --- window management
virtual Fl_X *makeWindow();
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
index 8fd33743d..764744f02 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
@@ -227,7 +227,10 @@ void Fl_Cocoa_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);
@@ -313,6 +316,10 @@ void Fl_Cocoa_Window_Driver::clip_to_rounded_corners(CGContextRef gc, int w, int
CGContextClip(gc);
}
+const Fl_Image* Fl_Cocoa_Window_Driver::shape() {
+ return shape_data_ ? shape_data_->shape_ : NULL;
+}
+
//
// End of "$Id$".
//
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
index 509326727..eabca3522 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
@@ -87,6 +87,7 @@ public:
// --- window data
virtual int decorated_w();
virtual int decorated_h();
+ virtual const Fl_Image* shape();
// --- window management
virtual Fl_X *makeWindow();
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
index 3b6974330..27263b374 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
@@ -179,6 +179,7 @@ void Fl_WinAPI_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_WinAPI_Window_Driver::shape(const Fl_Image* img) {
@@ -191,7 +192,10 @@ void Fl_WinAPI_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);
@@ -285,7 +289,8 @@ void Fl_WinAPI_Window_Driver::draw_begin()
// size of window has changed since last time
shape_data_->lw_ = s*w();
shape_data_->lh_ = s*h();
- 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_);
HRGN region = bitmap2region(temp);
SetWindowRgn(fl_xid(pWindow), region, TRUE); // the system deletes the region when it's no longer needed
delete temp;
@@ -698,6 +703,10 @@ void Fl_WinAPI_Window_Driver::resize_after_screen_change(void *data) {
data_for_resize_window_between_screens_.busy = false;
}
+const Fl_Image* Fl_WinAPI_Window_Driver::shape() {
+ return shape_data_ ? shape_data_->shape_ : NULL;
+}
+
//
// End of "$Id$".
//
diff --git a/src/drivers/X11/Fl_X11_Window_Driver.H b/src/drivers/X11/Fl_X11_Window_Driver.H
index d31940018..0cef4d07f 100644
--- a/src/drivers/X11/Fl_X11_Window_Driver.H
+++ b/src/drivers/X11/Fl_X11_Window_Driver.H
@@ -99,6 +99,7 @@ public:
// --- window data
virtual int decorated_w();
virtual int decorated_h();
+ virtual const Fl_Image* shape();
// --- window management
virtual Fl_X *makeWindow();
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