Weird set_cursor() bug mixing FLTK and SDL

15 views
Skip to first unread message

Rodolfo Borges

unread,
Sep 10, 2020, 2:53:22 PM9/10/20
to fltk.general
First, the overall situation:

My program main screen uses SDL+OpenGL.
There is a FLTK window at the start that shows a project list, where you can select a project and open the main window. But you can bypass this screen and open the main window directly if you pass the project name on the command line.
Once in the main window, it can eventually call some dialogs that are FLTK windows.

And here's where it gets weird:

The moment I put an Fl_Input widget on one of those dialogs that are called from the SDL window, the program crashes the moment the cursor gets inside the Fl_Input widget.
gdb tells me that it crashes on the FLTK function that changes the cursor.

I'm using FLTK 1.4 master branch, but I tested it with 1.3.5 too, with the same results.

After fighting this bug for two days, I noticed that if I introduce an Fl_Input widget on the first screen *before* the SDL window opens, then it works, and the FLTK dialog that opens after the SDL window works too.
And this led me to the following workaround:

static void ugly_HACK_workaround_fltk_setcursor_bug()
{
    Fl_Window w(10, 10, 20, 20);
    w.show();
    w.cursor (FL_CURSOR_INSERT);
    w.hide();
}

I just call this function at the very start of the program, and the bug is fixed.

Rodolfo Borges

unread,
Sep 10, 2020, 3:42:47 PM9/10/20
to fltk.general
Forgot to mention that this was on Linux.

I just tested it on a Mac, and there was no bug.

Ian MacArthur

unread,
Sep 10, 2020, 4:24:47 PM9/10/20
to fltkg...@googlegroups.com
I think you are going to have to show us more context - perhaps even a minimal, compileable, example that exhibits that fault.

Based on what you have shown, I don’t think I even understand what it is that you are asking here...


Rodolfo

unread,
Sep 10, 2020, 5:20:48 PM9/10/20
to fltkg...@googlegroups.com
On Thu, Sep 10, 2020 at 5:24 PM Ian MacArthur <imaca...@gmail.com> wrote:

I think you are going to have to show us more context - perhaps even a minimal, compileable, example that exhibits that fault.

Based on what you have shown, I don’t think I even understand what it is that you are asking here...

Unfortunately I'm overwhelmed with work right now.
I have to release the first version of the program three weeks from now, and there's much yet to do.
After that I can try and prepare that minimal example.

Manolo

unread,
Sep 11, 2020, 5:58:02 AM9/11/20
to fltk.general
Try calling
       fl_open_display();
early in your program.

Rodolfo

unread,
Sep 12, 2020, 3:09:48 AM9/12/20
to fltkg...@googlegroups.com
I tried, but it didn't work.
Reply all
Reply to author
Forward
0 new messages