Add Fl_Window::wait_for_expose() and test program (STR #3124).
Also modified .gitignore, svn-properties, Makefile and CMake-Files. Todo: test/twowin.cxx and test/windowfocus.cxx need to be added to ide files (MS VC++ and Xcode). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10339 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
5899b2cc6d
commit
eb1af07952
1
.gitignore
vendored
1
.gitignore
vendored
@ -222,6 +222,7 @@
|
|||||||
/test/valuators
|
/test/valuators
|
||||||
/test/valuators.cxx
|
/test/valuators.cxx
|
||||||
/test/valuators.h
|
/test/valuators.h
|
||||||
|
/test/windowfocus
|
||||||
/test/*.bck
|
/test/*.bck
|
||||||
/test/*.exe
|
/test/*.exe
|
||||||
/test/*.ilk
|
/test/*.ilk
|
||||||
|
@ -486,6 +486,10 @@ public:
|
|||||||
\see virtual void Fl_Window::show()
|
\see virtual void Fl_Window::show()
|
||||||
*/
|
*/
|
||||||
void show(int argc, char **argv);
|
void show(int argc, char **argv);
|
||||||
|
|
||||||
|
// Enables synchronous show(), docs in Fl_Window.cxx
|
||||||
|
void wait_for_expose();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Makes the window completely fill one or more screens, without any
|
Makes the window completely fill one or more screens, without any
|
||||||
window manager border visible. You must use fullscreen_off() to
|
window manager border visible. You must use fullscreen_off() to
|
||||||
|
@ -397,6 +397,58 @@ void Fl_Window::free_icons() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Waits for the window to be fully displayed after calling show().
|
||||||
|
|
||||||
|
Fl_Window::show() is not guaranteed to show and draw the window on
|
||||||
|
all platforms immediately. Instead this is done in the background;
|
||||||
|
particularly on X11 this will take a few messages (client server
|
||||||
|
roundtrips) to display the window.
|
||||||
|
|
||||||
|
Usually this small delay doesn't matter, but in some cases you may
|
||||||
|
want to have the window instantiated and displayed synchronously.
|
||||||
|
|
||||||
|
Currently (as of FLTK 1.3.3) this method only has an effect on X11.
|
||||||
|
On Windows and Mac OS X show() is always synchronous. If you want to
|
||||||
|
write portable code and need this synchronous show() feature, add
|
||||||
|
win->wait_for_expose() on all platforms, FLTK will just do the
|
||||||
|
right thing.
|
||||||
|
|
||||||
|
This method can be used for displaying splash screens before
|
||||||
|
calling Fl::run() or for having exact control over which window
|
||||||
|
has focus after calling show().
|
||||||
|
|
||||||
|
If the window is not shown(), this method does nothing.
|
||||||
|
|
||||||
|
\see virtual void Fl_Window::show()
|
||||||
|
|
||||||
|
Example code for displaying a window before calling Fl::run()
|
||||||
|
|
||||||
|
\code
|
||||||
|
Fl_Double_Window win = new Fl_Double_Window(...);
|
||||||
|
|
||||||
|
// do more window initialization here ...
|
||||||
|
|
||||||
|
win->show(); // show window
|
||||||
|
win->wait_for_expose(); // wait, until displayed
|
||||||
|
Fl::flush(); // make sure everything gets drawn
|
||||||
|
|
||||||
|
// do more initialization work that needs some time here ...
|
||||||
|
|
||||||
|
Fl::run(); // start FLTK event loop
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
Note that the window will not be responsive until the event loop
|
||||||
|
is started with Fl::run().
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Fl_Window::wait_for_expose() {
|
||||||
|
if (!shown()) return;
|
||||||
|
while (!i || i->wait_for_expose) {
|
||||||
|
Fl::wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id$".
|
// End of "$Id$".
|
||||||
//
|
//
|
||||||
|
@ -118,9 +118,11 @@ CREATE_EXAMPLE(threads threads.cxx fltk)
|
|||||||
CREATE_EXAMPLE(tile tile.cxx fltk)
|
CREATE_EXAMPLE(tile tile.cxx fltk)
|
||||||
CREATE_EXAMPLE(tiled_image tiled_image.cxx fltk)
|
CREATE_EXAMPLE(tiled_image tiled_image.cxx fltk)
|
||||||
CREATE_EXAMPLE(tree tree.fl fltk)
|
CREATE_EXAMPLE(tree tree.fl fltk)
|
||||||
|
CREATE_EXAMPLE(twowin twowin.cxx fltk)
|
||||||
CREATE_EXAMPLE(utf8 utf8.cxx fltk)
|
CREATE_EXAMPLE(utf8 utf8.cxx fltk)
|
||||||
CREATE_EXAMPLE(valuators valuators.fl fltk)
|
CREATE_EXAMPLE(valuators valuators.fl fltk)
|
||||||
CREATE_EXAMPLE(unittests unittests.cxx fltk)
|
CREATE_EXAMPLE(unittests unittests.cxx fltk)
|
||||||
|
CREATE_EXAMPLE(windowfocus windowfocus.cxx fltk)
|
||||||
|
|
||||||
# OpenGL demos...
|
# OpenGL demos...
|
||||||
if(OPENGL_FOUND)
|
if(OPENGL_FOUND)
|
||||||
|
@ -93,7 +93,8 @@ CPPFILES =\
|
|||||||
tree.cxx \
|
tree.cxx \
|
||||||
twowin.cxx \
|
twowin.cxx \
|
||||||
valuators.cxx \
|
valuators.cxx \
|
||||||
utf8.cxx
|
utf8.cxx \
|
||||||
|
windowfocus.cxx
|
||||||
|
|
||||||
ALL = \
|
ALL = \
|
||||||
unittests$(EXEEXT) \
|
unittests$(EXEEXT) \
|
||||||
@ -163,7 +164,8 @@ ALL = \
|
|||||||
twowin$(EXEEXT) \
|
twowin$(EXEEXT) \
|
||||||
valuators$(EXEEXT) \
|
valuators$(EXEEXT) \
|
||||||
cairotest$(EXEEXT) \
|
cairotest$(EXEEXT) \
|
||||||
utf8$(EXEEXT)
|
utf8$(EXEEXT) \
|
||||||
|
windowfocus$(EXEEXT)
|
||||||
|
|
||||||
|
|
||||||
GLALL = \
|
GLALL = \
|
||||||
|
58
test/windowfocus.cxx
Normal file
58
test/windowfocus.cxx
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
//
|
||||||
|
// Cross-window show/focus 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();
|
||||||
|
win2->wait_for_expose();
|
||||||
|
inp->take_focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
win1 = new Fl_Double_Window(300, 200);
|
||||||
|
win1->label("show() 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(argc,argv);
|
||||||
|
|
||||||
|
return Fl::run();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user