Rewrite Fl_Window::iconize() under the driver model.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11411 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-03-23 18:00:37 +00:00
parent e3ee1e7b81
commit fdaad858ba
14 changed files with 31 additions and 29 deletions

View File

@ -22,6 +22,7 @@
#ifndef Fl_Window_H
#define Fl_Window_H
#include <FL/Fl.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Bitmap.H>
#include <stdlib.h>
@ -54,6 +55,7 @@ class Fl_Double_Window;
class FL_EXPORT Fl_Window : public Fl_Group {
static char *default_xclass_;
static char show_iconic_; // 1 means create next window in iconic form
int no_fullscreen_x;
int no_fullscreen_y;
@ -64,6 +66,7 @@ class FL_EXPORT Fl_Window : public Fl_Group {
int fullscreen_screen_left;
int fullscreen_screen_right;
friend int Fl::arg(int argc, char **argv, int &i);
friend class Fl_X;
friend class Fl_Window_Driver;
Fl_X *i; // points at the system-specific stuff, but exists only after the window is mapped

View File

@ -95,6 +95,7 @@ public:
virtual void fullscreen_off(int X, int Y, int W, int H) {}
virtual void use_border();
virtual void size_range();
virtual void iconize() {}
// --- window shape stuff
void shape_pixmap_(Fl_Image* pixmap); // TODO: check

View File

@ -177,7 +177,6 @@ public:
static void GLcontext_makecurrent(NSOpenGLContext*);
static void GL_cleardrawable(void);
void destroy(void);
void collapse(void);
WindowRef window_ref(void); // useless with cocoa GL windows
void set_key_window(void);
// OS X doesn't have per window icons

View File

@ -33,6 +33,8 @@
char *Fl_Window::default_xclass_ = 0L;
char Fl_Window::show_iconic_ = 0;
Fl_Window *Fl_Window::current_;
void Fl_Window::_Fl_Window() {

View File

@ -16,25 +16,15 @@
// http://www.fltk.org/str.php
//
#include <FL/x.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Window_Driver.H>
extern char fl_show_iconic; // in Fl_x.cxx
void Fl_Window::iconize() {
if (!shown()) {
fl_show_iconic = 1;
show_iconic_ = 1;
show();
} else {
#ifdef WIN32
ShowWindow(i->xid, SW_SHOWMINNOACTIVE);
#elif defined(__APPLE__) // PORTME: Fl_Window_Driver - platform window driver
i->collapse();
#elif defined(FL_PORTING)
# pragma message "FL_PORTING: add code to iconify a window"
#else
XIconifyWindow(fl_display, i->xid, fl_screen);
#endif
pWindowDriver->iconize();
}
}

View File

@ -53,7 +53,6 @@ static int fl_match(const char *a, const char *s, int atleast = 1) {
}
// flags set by previously parsed arguments:
extern char fl_show_iconic; // in Fl_x.cxx
static char arg_called;
static char return_i;
static const char *name;
@ -148,7 +147,7 @@ int Fl::arg(int argc, char **argv, int &i) {
s++; // point after the dash
if (fl_match(s, "iconic")) {
fl_show_iconic = 1;
Fl_Window::show_iconic_ = 1;
i++;
return 1;
} else if (fl_match(s, "kbd")) {

View File

@ -91,8 +91,6 @@ int fl_mac_os_version = Fl_X::calc_mac_os_version(); // the version number of t
// public variables
void *fl_capture = 0; // (NSWindow*) we need this to compensate for a missing(?) mouse capture
bool fl_show_iconic; // true if called from iconize() - shows the next created window in collapsed state
//int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR
Window fl_window;
// forward declarations of variables in this file
@ -2882,11 +2880,11 @@ void Fl_X::make(Fl_Window* w)
NSUInteger winstyle;
if (w->parent()) {
w->border(0);
fl_show_iconic = 0;
Fl_Window::show_iconic_ = 0;
}
if (w->border()) winstyle = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask;
else winstyle = NSBorderlessWindowMask;
if (fl_show_iconic && !w->parent()) { // prevent window from being out of work area when created iconized
if (Fl_Window::show_iconic_ && !w->parent()) { // prevent window from being out of work area when created iconized
int sx, sy, sw, sh;
Fl::screen_work_area (sx, sy, sw, sh, w->x(), w->y());
if (w->x() < sx) w->x(sx);
@ -3047,8 +3045,8 @@ void Fl_X::make(Fl_Window* w)
w->set_visible();
if ( w->border() || (!w->modal() && !w->tooltip_window()) ) Fl::handle(FL_FOCUS, w);
[cw setDelegate:[FLWindowDelegate singleInstance]];
if (fl_show_iconic) {
fl_show_iconic = 0;
if (Fl_Window::show_iconic_) {
Fl_Window::show_iconic_ = 0;
w->handle(FL_SHOW); // create subwindows if any
[cw recursivelySendToSubwindows:@selector(display)]; // draw the window and its subwindows before its icon is computed
[cw miniaturize:nil];
@ -3560,8 +3558,8 @@ Fl_Region Fl_X::intersect_region_and_rect(Fl_Region current, int x,int y,int w,
return outr;
}
void Fl_X::collapse() {
[xid miniaturize:nil];
void Fl_Cocoa_Window_Driver::iconize() {
[fl_xid(pWindow) miniaturize:nil];
}
static NSImage *CGBitmapContextToNSImage(CGContextRef c)

View File

@ -1643,7 +1643,6 @@ private:
void fl_fix_focus(); // in Fl.cxx
char fl_show_iconic; // hack for Fl_Window::iconic()
// int fl_background_pixel = -1; // color to use for background
UINT fl_wake_msg = 0;
int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR
@ -1846,7 +1845,7 @@ Fl_X* Fl_X::make(Fl_Window* w) {
fl_clipboard_notify_target(x->xid);
x->wait_for_expose = 1;
if (fl_show_iconic) {showit = 0; fl_show_iconic = 0;}
if (Fl_Window::show_iconic_) {showit = 0; Fl_Window::show_iconic_ = 0;}
if (showit) {
w->set_visible();
int old_event = Fl::e_number;

View File

@ -2313,7 +2313,6 @@ Fl_X* Fl_X::set_xid(Fl_Window* win, Window winxid) {
// normally. The global variables like fl_show_iconic are so that
// subclasses of *that* class may change the behavior...
char fl_show_iconic; // hack for iconize()
int fl_background_pixel = -1; // hack to speed up bg box drawing
int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR
@ -2527,10 +2526,10 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
XWMHints *hints = XAllocWMHints();
hints->input = True;
hints->flags = InputHint;
if (fl_show_iconic) {
if (Fl_Window::show_iconic_) {
hints->flags |= StateHint;
hints->initial_state = IconicState;
fl_show_iconic = 0;
Fl_Window::show_iconic_ = 0;
showit = 0;
}
if (((Fl_X11_Window_Driver*)win->pWindowDriver)->icon_->legacy_icon) {

View File

@ -83,6 +83,7 @@ public:
virtual void fullscreen_on();
virtual void fullscreen_off(int X, int Y, int W, int H);
virtual void size_range();
virtual void iconize();
virtual void shape(const Fl_Image* img);
// that one is implemented in Fl_Cocoa.mm because it uses Objective-c

View File

@ -87,6 +87,7 @@ public:
virtual void unmap();
virtual void fullscreen_on();
virtual void fullscreen_off(int X, int Y, int W, int H);
virtual void iconize();
virtual void shape(const Fl_Image* img);
virtual void icons(const Fl_RGB_Image *icons[], int count);

View File

@ -608,6 +608,11 @@ void Fl_WinAPI_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
Fl::handle(FL_FULLSCREEN, pWindow);
}
void Fl_WinAPI_Window_Driver::iconize() {
ShowWindow(fl_xid(pWindow), SW_SHOWMINNOACTIVE);
}
//
// End of "$Id$".
//

View File

@ -98,6 +98,7 @@ public:
virtual void fullscreen_off(int X, int Y, int W, int H);
virtual void use_border();
virtual void size_range();
virtual void iconize();
virtual void shape(const Fl_Image* img);
virtual void icons(const Fl_RGB_Image *icons[], int count);

View File

@ -504,6 +504,10 @@ void Fl_X11_Window_Driver::size_range() {
if (pWindow->shown()) Fl_X::i(pWindow)->sendxjunk();
}
void Fl_X11_Window_Driver::iconize() {
XIconifyWindow(fl_display, fl_xid(pWindow), fl_screen);
}
//
// End of "$Id$".
//