|
|
I was tracking down a bug and it turned out to be caused when I call
resize() on a window "from the outside" (so it's my program doing it,
rather than the OS doing it via a window drag). On OS X (with fltk
head), it turns out that each call to resize() causes it to be called
twice, reentrantly. I tried it on X11 (with fltk at 3bb34), and the
reentrant call doesn't happen, but resize gets called 4 times.
I'm not sure if this is a bug or not, but it is a bit odd, and it did
cause a bug in my program, which wasn't expecting reentrant calls.
I'm guessing it has to do with how the window system might feel the
need to tweak a resize, for instance on OS X it won't let you overlap
the menu bar. I'm not sure what a more straightforward approach here
would be, perhaps it would be not to call Fl_Window::resize directly,
but to ask the OS to move the window (how though?), and then the
relevant OS-specific driver will then call the resize with the numbers
it approves of.
Here's a short program to demonstrate the behaviour:
#include <iostream>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/fl_draw.H>
#include <FL/Fl.H>
class Bug : public Fl_Window {
public:
Bug(int x, int y, int w, int h) : Fl_Window(x, y, w, h), box(0, 0, w, h)
{
box.box(FL_FLAT_BOX);
box.color(FL_WHITE);
}
void resize(int x, int y, int w, int h) override {
static int nest;
nest++;
std::cout << "resize " << nest << "\n";
Fl_Window::resize(x, y, w, h);
nest--;
}
Fl_Box box;
};
Fl_Window *window;
static void
timeout_func(void *unused)
{
window->resize(0, 0, 200, 200);
}
int main()
{
Bug win(200, 200, 200, 200);
window = &win;
win.show();
Fl::add_timeout(1, timeout_func, nullptr);
Fl::run();
return 0;
}
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/CACbaDy641KqvLMXkzFXo5%3DkN7EbqaB369hhO3umOVyft35JmFQ%40mail.gmail.com.
[ Direct Link to Message ] | |
|
| |