summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-03-11 07:07:42 +0000
committerManolo Gouy <Manolo>2016-03-11 07:07:42 +0000
commit2952c530b856c5cca973fef34edc5d738fb8c0f7 (patch)
tree2bd14373989d6e0a915c84c3ec8b0a26f831be66 /src/drivers
parent914248bbf04675f2e8096dadae4ffa35e6982293 (diff)
Rewrite capture of window decorations using the window driver approach.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11345 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H2
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H2
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.H1
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.cxx56
4 files changed, 61 insertions, 0 deletions
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
index d8a34fc1b..36be7ee7d 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
@@ -63,6 +63,8 @@ public:
virtual void take_focus();
virtual void shape(const Fl_Image* img);
virtual void draw();
+ // that one is implemented in Fl_Cocoa.mm because it uses Objective-c
+ virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
};
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
index 605a0547c..53c00cad4 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
@@ -73,6 +73,8 @@ public:
virtual void icon(const void * ic);
virtual void free_icons();
void icons(HICON big_icon, HICON small_icon);
+ // this one is implemented in Fl_win32.cxx
+ virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
};
diff --git a/src/drivers/X11/Fl_X11_Window_Driver.H b/src/drivers/X11/Fl_X11_Window_Driver.H
index e4f8862bd..1eb161e0b 100644
--- a/src/drivers/X11/Fl_X11_Window_Driver.H
+++ b/src/drivers/X11/Fl_X11_Window_Driver.H
@@ -73,6 +73,7 @@ public:
virtual const void *icon() const;
virtual void icon(const void * ic);
virtual void free_icons();
+ virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
};
diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx
index d1f377793..32ac787a2 100644
--- a/src/drivers/X11/Fl_X11_Window_Driver.cxx
+++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx
@@ -19,7 +19,9 @@
#include "../../config_lib.h"
#include "Fl_X11_Window_Driver.H"
+#include <FL/Fl_Shared_Image.H>
#include <FL/fl_draw.H>
+#include <FL/Fl.H>
#include <string.h>
#if HAVE_DLFCN_H
#include <dlfcn.h>
@@ -275,6 +277,60 @@ void Fl_X11_Window_Driver::free_icons() {
}
+/* Returns images of the captures of the window title-bar, and the left, bottom and right window borders
+ (or NULL if a particular border is absent).
+ Returned images can be deleted after use. Their depth and size may be platform-dependent.
+ The top and bottom images extend from left of the left border to right of the right border.
+
+ On the X11 platform, this function exploits a feature of fl_read_image() which, when called
+ with negative 4th argument, captures the window decoration.
+ */
+void Fl_X11_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right)
+{
+ Fl_RGB_Image *r_top, *r_left, *r_bottom, *r_right;
+ top = left = bottom = right = NULL;
+ if (pWindow->decorated_h() == pWindow->h()) return;
+ Window from = fl_window;
+ Fl_Surface_Device *previous = Fl_Surface_Device::surface();
+ Fl_Display_Device::display_device()->set_current();
+ pWindow->show();
+ Fl::check();
+ pWindow->make_current();
+ Window root, parent, *children, child_win;
+ unsigned n = 0;
+ int do_it;
+ int wsides, htop;
+ do_it = (XQueryTree(fl_display, fl_window, &root, &parent, &children, &n) != 0 &&
+ XTranslateCoordinates(fl_display, fl_window, parent, 0, 0, &wsides, &htop, &child_win) == True);
+ if (n) XFree(children);
+ if (!do_it) wsides = htop = 0;
+ int hbottom = wsides;
+ fl_window = parent;
+ uchar *rgb;
+ if (htop) {
+ rgb = fl_read_image(NULL, 0, 0, - (pWindow->w() + 2 * wsides), htop);
+ r_top = new Fl_RGB_Image(rgb, pWindow->w() + 2 * wsides, htop, 3);
+ r_top->alloc_array = 1;
+ top = Fl_Shared_Image::get(r_top);
+ }
+ if (wsides) {
+ rgb = fl_read_image(NULL, 0, htop, -wsides, pWindow->h());
+ r_left = new Fl_RGB_Image(rgb, wsides, pWindow->h(), 3);
+ r_left->alloc_array = 1;
+ left = Fl_Shared_Image::get(r_left);
+ rgb = fl_read_image(NULL, pWindow->w() + wsides, htop, -wsides, pWindow->h());
+ r_right = new Fl_RGB_Image(rgb, wsides, pWindow->h(), 3);
+ r_right->alloc_array = 1;
+ right = Fl_Shared_Image::get(r_right);
+ rgb = fl_read_image(NULL, 0, htop + pWindow->h(), -(pWindow->w() + 2*wsides), hbottom);
+ r_bottom = new Fl_RGB_Image(rgb, pWindow->w() + 2*wsides, hbottom, 3);
+ r_bottom->alloc_array = 1;
+ bottom = Fl_Shared_Image::get(r_bottom);
+ }
+ fl_window = from;
+ previous->Fl_Surface_Device::set_current();
+}
+
//
// End of "$Id$".
//