Index: FL/Fl_Window.H
===================================================================
--- FL/Fl_Window.H	(revision 10317)
+++ FL/Fl_Window.H	(working copy)
@@ -424,7 +424,38 @@
     \see Fl_Window::show(int argc, char **argv)
   */
   virtual void show();
+
   /**
+    Like show(), but guarantees that the window has popped up before
+    returning. Currently this only has an effect on X11, as on Windows
+    and Mac show() is already synchronous.
+
+    Note that this will block threads that use Fl::lock() for syncronization
+    for a short time. The delay that can be experienced by this synchronization
+    is platform dependent - under X11 this will be significant, because the
+    system will need a few messages (client-server roundtrips) to display
+    the window.
+
+    This method is intended to be used for displaying splash screens, or
+    having exact control over which window has focus.
+  */
+#if FLTK_ABI_VERSION >= 10303
+  virtual
+#endif
+  void show_sync();
+
+  /**
+    Like show(int, char **), but guarantees that the window has popped up before
+    returning.
+
+    \see show_sync(), show(), show(int, char **)
+  */
+#if FLTK_ABI_VERSION >= 10303
+  virtual
+#endif
+  void show_sync(int argc, char **argv);
+
+  /**
     Removes the window from the screen.  If the window is already hidden or
     has not been shown then this does nothing and is harmless.
   */
Index: src/Fl_cocoa.mm
===================================================================
--- src/Fl_cocoa.mm	(revision 10317)
+++ src/Fl_cocoa.mm	(working copy)
@@ -2813,7 +2813,14 @@
   }
 }
 
+void Fl_Window::show_sync() {
+  show();
+}
 
+void Fl_Window::show_sync(int argc, char **argv) {
+  show(argc, argv);
+}
+
 /*
  * resize a window
  */
Index: src/Fl_win32.cxx
===================================================================
--- src/Fl_win32.cxx	(revision 10317)
+++ src/Fl_win32.cxx	(working copy)
@@ -2451,6 +2451,14 @@
 #endif
 }
 
+void Fl_Window::show_sync() {
+  show();
+}
+
+void Fl_Window::show_sync(int argc, char **argv) {
+  show(argc, argv);
+}
+
 Fl_Window *Fl_Window::current_;
 // the current context
 HDC fl_gc = 0;
Index: src/Fl_x.cxx
===================================================================
--- src/Fl_x.cxx	(revision 10317)
+++ src/Fl_x.cxx	(working copy)
@@ -2913,6 +2913,24 @@
 #endif
 }
 
+void Fl_Window::show_sync() {
+  Fl::lock();
+  show();
+  while (!i || i->wait_for_expose) {
+    Fl::wait();
+  }
+  Fl::unlock();
+}
+
+void Fl_Window::show_sync(int argc, char **argv) {
+  Fl::lock();
+  show(argc, argv);
+  while (!i || i->wait_for_expose) {
+    Fl::wait();
+  }
+  Fl::unlock();
+}
+
 Window fl_window;
 Fl_Window *Fl_Window::current_;
 GC fl_gc;
Index: test
===================================================================
--- test	(revision 10317)
+++ test	(working copy)

Property changes on: test
___________________________________________________________________
Modified: svn:ignore
## -97,6 +97,7 ##
 valuators
 valuators.cxx
 valuators.h
+windowfocus
 *.bck
 *.exe
 *.ilk
Index: test/Makefile
===================================================================
--- test/Makefile	(revision 10317)
+++ test/Makefile	(working copy)
@@ -93,7 +93,8 @@
 	tree.cxx \
 	twowin.cxx \
 	valuators.cxx \
-	utf8.cxx
+	utf8.cxx \
+	windowfocus.cxx
 
 ALL =	\
 	unittests$(EXEEXT) \
@@ -163,7 +164,8 @@
 	twowin$(EXEEXT) \
 	valuators$(EXEEXT) \
 	cairotest$(EXEEXT) \
-	utf8$(EXEEXT) 
+	utf8$(EXEEXT) \
+	windowfocus$(EXEEXT)
 
 
 GLALL = \
Index: test/windowfocus.cxx
===================================================================
--- test/windowfocus.cxx	(revision 0)
+++ test/windowfocus.cxx	(working copy)
@@ -0,0 +1,57 @@
+//
+// Cross-window show_sync() test program for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2014 by Bill Spitzak and others.
+//
+// This library is free software. Distribution and use rights are outlined in
+// the file "COPYING" which should have been included with this file.  If this
+// file is missing or damaged, see the license at:
+//
+//     http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+//     http://www.fltk.org/str.php
+//
+
+#include <FL/Fl.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Double_Window.H>
+#include <FL/Fl_Input.H>
+
+static Fl_Double_Window *win1, *win2;
+static Fl_Input *inp;
+
+static void popup(Fl_Widget *, void *) {
+
+	win2->position(win1->x() + win1->w(), win1->y());
+
+	win2->show_sync();
+	inp->take_focus();
+}
+
+int main() {
+
+	win1 = new Fl_Double_Window(300, 200);
+	win1->label("show_sync() focus test");
+
+	Fl_Box *b = new Fl_Box(10, 10, 280, 130);
+	b->label("Type something to pop the subwindow up. "
+			"The focus should stay on the input, "
+			"and you should be able to continue typing.");
+	b->align(FL_ALIGN_WRAP | FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
+
+	inp = new Fl_Input(10, 150, 150, 25);
+	inp->when(FL_WHEN_CHANGED);
+	inp->callback(popup);
+
+	win1->end();
+
+	win2 = new Fl_Double_Window(300, 200);
+	win2->label("window2");
+	win2->end();
+
+	win1->show();
+
+	return Fl::run();
+}
