Evan Laforge
unread,Feb 25, 2026, 9:59:55 AM (7 days ago) Feb 25Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to fltkg...@googlegroups.com
After upgrading to OSX 15.7, my app would no longer come to front and
get focus when launched. After some experimentation, I discovered
this was due to calling Fl::lock() and Fl::wait() before creating any
windows. I was able to work around by putting in some extra logic to
not call Fl::wait() until after the first window has been created.
I think this is a change in OSX, not fltk. I'll include a simplified
version that demonstrates the problem. Call with no args and it
should come to front when launched as expected. Call with an arg and
it should launch, but in the background. I assume it's something
where fltk initializes with the OS somehow before creating the window,
which somehow misses the OS's "bring to front" window.
Or could it be I'm using fltk in an unexpected way? The repro is
contrived, but in the real app, the structure that the main thread is
like:
Fl::lock();
for (;;) {
Fl::wait();
actions = get_queue();
run(actions);
}
Event loop thread:
for (;;) {
action = event_logic();
put_queue(action);
Fl::awake();
}
I wound up modifying the main thread like:
Fl::lock();
wait_for_queue();
actions = get_queue();
run(actions);
for (;;) {
Fl::wait();
actions = get_queue();
run(actions);
}
This fixes it, but it's a bit more complicated and it might take
others a while to figure it out, as with me! Here's the reproduction:
#include <iostream>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.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);
}
Fl_Box box;
};
int main(int argc, char **argv)
{
if (argc > 1) {
std::cout << "lock\n";
Fl::lock();
Fl::wait(0.01);
}
Bug win(200, 200, 200, 200);
std::cout << "show\n";
win.show();
while (Fl::wait())
;
return 0;
}