Under Ubuntu 22.04 any FLTK application appears in the Appmenu as 'FLTK'

35 views
Skip to first unread message

Roberto Panetta

unread,
Jun 15, 2024, 9:53:31 AMJun 15
to fltk.general
Under Ubuntu 22.04 but i think the problem is more general any FLTK application appear in the Appmenu as 'FLTK'

I don't know if there is a correct way to manage it,
I managed to fix this using :

void set_wm_class(Fl_Window *window, const char *res_name, const char *res_class) {
    Display *display = fl_display;  // Get the display used by FLTK
    Window xid = fl_xid(window);    // Get the XID (Window ID) of the FLTK window

    XClassHint *class_hint = XAllocClassHint();
    if (class_hint) {
        //class_hint->res_name = const_cast<char*>(res_name);
        class_hint->res_class = const_cast<char*>(res_class);
        XSetClassHint(display, xid, class_hint);
        XFree(class_hint);
    }
}

and calling it after the window creation with:

 set_wm_class(window, "app-name", "RequiredAppName");


It is still a bit annoying because the application starts as FLTK in the app menu  and then switch to the requested name, plus I'm not sure it is a clean way to fix the problem
Any suggestion?

Roberto Panetta

unread,
Jun 15, 2024, 10:17:30 AMJun 15
to fltk.general
and to add some information:
If I create a flatpak installer or a snap installer with the application, the problem is automatically fixed without using at all the 'set_wm_class' call. I had to use this only when the application is run more directly (as example installing it using a .deb packages or more easily running it directly with a double click on the binary)

Roberto Panetta

unread,
Jun 15, 2024, 10:20:13 AMJun 15
to fltk.general
and No the creation of a proper .desktop file doesn't solve it, it appears correctly with the required name but when you launch it, under the App Menu it is still 'FLTK'. It is packing it in case with flatpak or snapcraft that solves the problem

imm

unread,
Jun 16, 2024, 6:55:58 AMJun 16
to General FLTK
Is this not set by;

Fl_Window::xclass();

And/or

Fl_Window:: default _xclass();  ?

I'm on my phone so can't really check, but I think that it is.

Mind you, on *nix I'd guess that probably only works with X11. Wayland is a whole other weirdness!

--
Ian
From my Fairphone FP3
   

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/6e72989b-b028-465d-aa6c-5ff9807ee21bn%40googlegroups.com.
Message has been deleted

Roberto Panetta

unread,
Jun 16, 2024, 9:27:08 AMJun 16
to fltk.general
Yes it seems it works.
I call

win->default_xclass("Application Name");

after creating the win and before showing it and when running the final binary Ubuntu shows the right name in the App menu

I think has to be considered and do something regarding the fact that under Ubuntu all the application goes under the App menu as 'FLTK'

Or at least say it in the documentation! :)

I tried all the example and it goes in that way. All application are presented in the Ubuntu AppMenu as 'FLTK'

Very unprofessional, the final user could think FLTK is a sort of 'emulator' running 'interpreted apps'
The opposite of what FLTK really is.

I see Flatpack and Snap fixed it too, or probably everything would probably appear as 'Flatpack' or 'Snap' when running containerzed

Manolo

unread,
Jun 16, 2024, 5:26:42 PMJun 16
to fltk.general
Le samedi 15 juin 2024 à 15:53:31 UTC+2, eclet...@gmail.com a écrit :
Under Ubuntu 22.04 but i think the problem is more general any FLTK application appear in the Appmenu as 'FLTK'

That should be fixed with commit 41ffc2c of the FLTK git repo.
The fix requires the app to call Fl_Window::show(int argc, char **argv).
Reply all
Reply to author
Forward
0 new messages