diff --git a/FL/Fl_Window.H b/FL/Fl_Window.H index 58165bffe..317c66247 100644 --- a/FL/Fl_Window.H +++ b/FL/Fl_Window.H @@ -22,6 +22,7 @@ #ifndef Fl_Window_H #define Fl_Window_H +#include #include #include #include @@ -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 diff --git a/FL/Fl_Window_Driver.H b/FL/Fl_Window_Driver.H index cc515e382..4779f4354 100644 --- a/FL/Fl_Window_Driver.H +++ b/FL/Fl_Window_Driver.H @@ -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 diff --git a/FL/mac.H b/FL/mac.H index 0128d1157..da8cf24de 100644 --- a/FL/mac.H +++ b/FL/mac.H @@ -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 diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index 70701bab6..8ab9aaae9 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -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() { diff --git a/src/Fl_Window_iconize.cxx b/src/Fl_Window_iconize.cxx index 93b4fd127..7077d8e0f 100644 --- a/src/Fl_Window_iconize.cxx +++ b/src/Fl_Window_iconize.cxx @@ -16,25 +16,15 @@ // http://www.fltk.org/str.php // -#include +#include #include -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(); } } diff --git a/src/Fl_arg.cxx b/src/Fl_arg.cxx index 02f3da1da..34ba95bb1 100644 --- a/src/Fl_arg.cxx +++ b/src/Fl_arg.cxx @@ -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")) { diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 5a29767ac..ced8928e1 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -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) diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index ef83d833e..72d191617 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -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; diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 9e73011a9..d73a22dba 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -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) { diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H index f3d8a85be..8cce010f6 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H @@ -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 diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H index b1218ab6c..2cae854ef 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H @@ -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); diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx index 4eadbddfd..dd3b64168 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx @@ -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$". // diff --git a/src/drivers/X11/Fl_X11_Window_Driver.H b/src/drivers/X11/Fl_X11_Window_Driver.H index 47272a834..35cee4afd 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.H +++ b/src/drivers/X11/Fl_X11_Window_Driver.H @@ -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); diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index 2daf3f347..2d6782eaf 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -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$". //