Blob Blame History Raw
diff -up fltk-1.3.x-r9671/src/Fl_cocoa.mm.modal fltk-1.3.x-r9671/src/Fl_cocoa.mm
--- fltk-1.3.x-r9671/src/Fl_cocoa.mm.modal	2013-08-21 15:37:44.719365974 -0500
+++ fltk-1.3.x-r9671/src/Fl_cocoa.mm	2013-08-21 15:37:44.741365748 -0500
@@ -661,12 +661,9 @@ void Fl::remove_timeout(Fl_Timeout_Handl
     return NO;	// prevent the caption to be redrawn as active on click
 		//  when another modal window is currently the key win
 
-  return !(w->tooltip_window() || w->menu_window());
+  return !w->tooltip_window();
 }
 
-// TODO see if we really need a canBecomeMainWindow ...
-#if 0
-
 - (BOOL)canBecomeMainWindow
 {
   if (Fl::modal_ && (Fl::modal_ != w))
@@ -675,7 +672,6 @@ void Fl::remove_timeout(Fl_Timeout_Handl
 
   return !(w->tooltip_window() || w->menu_window());
 }
-#endif
 
 @end
 
diff -up fltk-1.3.x-r9671/src/Fl_win32.cxx.modal fltk-1.3.x-r9671/src/Fl_win32.cxx
--- fltk-1.3.x-r9671/src/Fl_win32.cxx.modal	2013-08-21 15:37:44.721365954 -0500
+++ fltk-1.3.x-r9671/src/Fl_win32.cxx	2013-08-21 15:37:44.742365738 -0500
@@ -942,6 +942,10 @@ static LRESULT CALLBACK WndProc(HWND hWn
     break;
 
   case WM_SETFOCUS:
+    if ((Fl::modal_) && (Fl::modal_ != window)) {
+      SetFocus(fl_xid(Fl::modal_));
+      return 0;
+    }
     Fl::handle(FL_FOCUS, window);
     break;
 
@@ -1668,6 +1672,11 @@ Fl_X* Fl_X::make(Fl_Window* w) {
     Fl::e_number = old_event;
     w->redraw(); // force draw to happen
   }
+
+  // Needs to be done before ShowWindow() to get the correct behaviour
+  // when we get WM_SETFOCUS.
+  if (w->modal()) {Fl::modal_ = w; fl_fix_focus();}
+
   // If we've captured the mouse, we dont want to activate any
   // other windows from the code, or we lose the capture.
   ShowWindow(x->xid, !showit ? SW_SHOWMINNOACTIVE :
@@ -1685,7 +1694,6 @@ Fl_X* Fl_X::make(Fl_Window* w) {
     }
   }
 
-  if (w->modal()) {Fl::modal_ = w; fl_fix_focus();}
   return x;
 }
 
diff -up fltk-1.3.x-r9671/src/Fl_x.cxx.modal fltk-1.3.x-r9671/src/Fl_x.cxx
--- fltk-1.3.x-r9671/src/Fl_x.cxx.modal	2013-08-21 15:37:44.732365841 -0500
+++ fltk-1.3.x-r9671/src/Fl_x.cxx	2013-08-21 15:37:44.742365738 -0500
@@ -2100,6 +2100,12 @@ void Fl_X::make_xid(Fl_Window* win, XVis
       while (wp->parent()) wp = wp->window();
       XSetTransientForHint(fl_display, xp->xid, fl_xid(wp));
       if (!wp->visible()) showit = 0; // guess that wm will not show it
+      if (win->modal()) {
+        Atom net_wm_state = XInternAtom (fl_display, "_NET_WM_STATE", 0);
+        Atom net_wm_state_skip_taskbar = XInternAtom (fl_display, "_NET_WM_STATE_MODAL", 0);
+        XChangeProperty (fl_display, xp->xid, net_wm_state, XA_ATOM, 32,
+            PropModeAppend, (unsigned char*) &net_wm_state_skip_taskbar, 1);
+      }
     }
 
     // Make sure that borderless windows do not show in the task bar