FLTK Window icon for program GNU/ Linux

1,060 views
Skip to first unread message

israel dahl

unread,
Feb 9, 2015, 6:11:19 PM2/9/15
to fltkg...@googlegroups.com
Hi,
I have not been able to find any adequate documentation on this subject.  My program has an icon in the desktop file, and appears as such in the menus, however in taskbars there is no icon for my window.
I have found various disjointed ways of setting the icon, but the documentation gives a very limited and unhelpful description of how to set this.

I have tried numerous ways of doing this with no success.  I am running Ubuntu 12.04, 14.04, 14.10 and have this issue in all the window managers /DE I use.
All FLTK programs are grouped into the same area.  FLUID does not display an icon, nor do my programs.

Any pointers to what I can do to separate my program from other FLTK programs (when windows are grouped) and how I can set the icon would be much appreciated.
A simple function similar to:
my_window->icon("/path/to/programIconName.png");
Would have been nice....
even
my_window->icon(included_xpm_char_array_name);
would have been nice as well.

If there is detailed documentation somewhere please point me to it.  If there is not please explain this for me, and update the documentation as well.

I really appreciate FLTK and it is very full featured and extremely easy to use!  It works extremely well on older machines, as well as newer machines, so thank you so much for this wonderful toolkit!!!!

crocher...@gmail.com

unread,
Feb 9, 2015, 9:55:22 PM2/9/15
to fltkg...@googlegroups.com
Hi Israel,

     this sounds weird to me: I got the window->icon(char ) to work both on 12.04 and 14.04. Maybe you have to insert a call to fl_open_display() first, not sure, but I think it's required (and written somewhere in the doc). Basically, with these 3 lines of code it displays the icon:

fl_open_display();
Pixmap p = XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display), (char *)icon32_bits, icon32_width, icon32_height);
window->icon((char *)p);

Hope it helps.

Vincent

Greg Ercolano

unread,
Feb 9, 2015, 10:14:03 PM2/9/15
to fltkg...@googlegroups.com
On 02/09/15 15:11, israel dahl wrote:
> I have tried numerous ways of doing this with no success. I am running
> Ubuntu 12.04, 14.04, 14.10 and have this issue in all the window managers /DE I use.
> All FLTK programs are grouped into the same area. FLUID does not display an icon,
> nor do my programs.
>
> Any pointers to what I can do to separate my program from other FLTK programs
> (when windows are grouped) and how I can set the icon would be much appreciated.

Yes, see below.

> A simple function similar to:
> my_window->icon("/path/to/programIconName.png");
> Would have been nice....
> even
> my_window->icon(included_xpm_char_array_name);
> would have been nice as well.

That approach I don't believe is possible under linux;
AFAIK neither X windows nor the window manager provide a C/C++
API for apps to set icons.

Besides, such an interface would only set the application's icon
at runtime (e.g for taskbar), not for desktop launchers/aliases/shortcuts
or when browsing.

AFAIK each linux desktop has historically handled this a
little bit differently, with a relatively recent strive to
follow the standard set forth by the FreeDesktop.org folks.

Both Windows and OSX handle this a bit more sanely, where the icon
tracks the executable:

o In windows you /link/ the icon into the executable as an .rc file
o In OSX you package your binary in a ".app" directory that can include icons, docs, etc

For linux, there's something of a standard evolved by freedesktop.org
with ".desktop" files (below), and I believe recent versions of Gnome
and KDE support this, possibly others.

> If there is detailed documentation somewhere please point me to it.

You'll have to look at the desktop-specific docs for your operating system(s).

In general you can usually just right click on the desktop and
use one of the functions to create a launcher for your app,
and associate the icon to it that way. This usually creates
a .desktop text file for you which you can then copy or link to.

This has a nice overview of several including KDE/GNOME/XF
http://xmodulo.com/create-desktop-shortcut-launcher-linux.html
http://stackoverflow.com/questions/119031/how-to-set-my-applications-desktop-icon-for-linux-kde-gnome-etc

Here's some info from a book on wxwidgets that is probably just as
relevant to FLTK (wxwidgets has the same issue):
https://books.google.com/books?id=CyMsvtgnq0QC&pg=PA534&lpg=PA534&dq=linux+wxwidgets+desktop+icons&source=bl&ots=SU6wl5Kmwi&sig=q_RXzTcg6FGgSixBuRG6LoSQ3QM&hl=en&sa=X&ei=iVHZVIAowvnJBM6agugL&ved=0CEkQ6AEwCw#v=onepage&q=linux%20wxwidgets%20desktop%20icons&f=false

The <Appname>.desktop standard put forth by freedesktop.org is here:
http://standards.freedesktop.org/desktop-entry-spec/latest/index.html

And there's some ubuntu specific docs here:
http://askubuntu.com/questions/64222/how-can-i-create-launchers-on-my-desktop
http://askubuntu.com/questions/142159/desktop-shortcut-to-create-a-new-desktop-shortcut-doesnt-do-anything

..but as described above, usually just right clicking on the desktop
and creating a launcher (or whatever your window manager calls it)
is a simple way to go about it.

Greg Ercolano

unread,
Feb 9, 2015, 11:12:32 PM2/9/15
to fltkg...@googlegroups.com
On 02/09/15 19:13, Greg Ercolano wrote:
> On 02/09/15 15:11, israel dahl wrote:
>> I have tried numerous ways of doing this with no success. I am running
>> Ubuntu 12.04, 14.04, 14.10 and have this issue in all the window managers /DE I use.
>> All FLTK programs are grouped into the same area. FLUID does not display an icon,
>> nor do my programs.

Oh, and perhaps I'm not sure if you meant for desktop/browse icons
(what my last post was about) or the window manager titlebar + taskbar icons.

If you mean the latter, then yes, yourwin->icon() should work,
as these are runtime items.

The technique I like to use is to make a 16x16 xpm image (e.g. in gimp)
so that I can #include the image into the source code, so that it doesn't
have to be lying around on disk in a specific place, and assign it
as the icon. Example:

..
#include <FL/Fl_Pixmap.H>
#include <FL/Fl_RGB_Image.H>
#include "../xpms/yourapp-16x16.xpm"
..
int main() {
..
Fl_Pixmap yourapp_16x16_icon(yourapp_16x16_xpm);
Fl_RGB_Image yourapp_icon(&yourapp_16x16_icon, Fl_Color(0));
yourwin->icon(&yourapp_icon);
yourwin->xclass("yourapp");
yourwin->show();
..

There may be a more direct way to do this without the intermediate
Fl_Pixmap, I'm not sure, kinda in a rush at the moment.

Just be sure the pixmap and rgbimage instances don't get destroyed
(go out of scope) before the program ends. Use 'new' and pointers if need be.
In the case above they're declared in main() so they won't go out of scope
while the program runs.


Edzard Egberts

unread,
Feb 10, 2015, 2:26:40 AM2/10/15
to 'ed' via fltk.general
> even
> my_window->icon(included_xpm_char_array_name);
> would have been nice as well.

#include <FL/Fl.H>
#include <FL/Fl_Window.H>

#include <FL/x.H>
#include <X11/xpm.h>
#include "icon.xpm"
// The icon must be named by opening the xpm with an text editor:
// static const char * pIcon_Xpm[] = {
// "48 48 981 2", => size should be 48x48

char* Get_Fl_Icon(char const* const* pIcon= 0)
{ // Set icon for Linux:
// This function must be initialised once by assigning an icon with
parameter pIcon.
// For sequential setting of icon to subwindows, this function can be
called several
// times without assigning an icon every time.
static Pixmap p= 0; // static store of assigned icon
static Pixmap mask;
if (!p && pIcon)
{ // assign icon once
fl_open_display();
XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
(char**) pIcon, &p, &mask, 0);
}
return (char*) p;
}

int main(int argc, char *argv[])
{
Fl_Window win(400, 200, "Icon Window");
win.end();
win.icon(Get_Fl_Icon(pIcon_Xpm)); // Initialise and get Icon
win.show();
// Subwindow.icon(Get_Fl_Icon()); // Don't initialise again for
sequential assign of icon
return Fl::run();
}


Dmitrij K

unread,
Feb 10, 2015, 3:42:03 AM2/10/15
to fltkg...@googlegroups.com
Hey ! very long time ago, I got help from Greg for this case:

[CODE=CPP]
/** Author: Greg Ercolano */

/** Compile your programs with LDFLAGS="$LDFLAGS -lXpm" */

/** set the icon from Xpm char ** data  */
#include <X11/xpm.h>

inline void set_icon(Fl_Window* main, char ** xpm_data){

if( !main ){ return; }
else if( !main->shown() ){ main->show(); }

Pixmap icon_pixmap;
Pixmap icon_mask;

int isXpm = XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display), xpm_data, &icon_pixmap, &icon_mask, NULL );

if(isXpm != XpmSuccess){ return; }

XWMHints hints;

hints.flags = IconPixmapHint | IconMaskHint;
hints.icon_pixmap = icon_pixmap;
hints.icon_mask = icon_mask;

XSetWMHints (fl_display, fl_xid(main), &hints);

hints.flags = 0;
hints.icon_pixmap = 0;
hints.icon_mask = 0;
icon_pixmap = 0;
icon_mask = 0;

}
[/CODE]

israel dahl

unread,
Feb 10, 2015, 8:43:11 AM2/10/15
to fltkg...@googlegroups.com

Yes this is what I am looking for!!
I did know about creating desktop files (or launchers or whatever you want to call them).
This is what I did not understand so well.

I will try this, and post back my results!

Albrecht Schlosser

unread,
Feb 10, 2015, 9:30:41 AM2/10/15
to fltkg...@googlegroups.com
On 10.02.2015 01:26 israel dahl wrote:

> I have tried numerous ways of doing this with no success. I am running
> Ubuntu 12.04, 14.04, 14.10 and have this issue in all the window
> managers /DE I use.
> All FLTK programs are grouped into the same area. FLUID does not
> display an icon, nor do my programs.

Grouping of programs is done by setting the main window's xclass(). The
default for FLTK programs is 'fltk'. I can see icons in the launcher if
I run a program that sets an icon explicitly. Note that fluid currently
doesn't set an icon, so you can't see one.

> Any pointers to what I can do to separate my program from other FLTK
> programs (when windows are grouped) and how I can set the icon would be
> much appreciated.

See comments and example below.

> A simple function similar to:
> my_window->icon("/path/to/programIconName.png");
> Would have been nice....
> even
> my_window->icon(included_xpm_char_array_name);
> would have been nice as well.

In FLTK 1.3.3 we /almost/ have such a simple way to do it. You can make
an icon from any Fl_RGB_Image in a platform-independent way. Older FLTK
versions need platform-dependent code and icon formats to do this.
Others have already pointed you to the 'old way'.

> If there is detailed documentation somewhere please point me to it. If
> there is not please explain this for me, and update the documentation as
> well.

See the different methods of the Fl_Window class in the online docs,
e.g. icon(Fl_RGB_Image) etc.. You can also set default icons for all
subsequently created windows.

http://www.fltk.org/doc-1.3/classFl__Window.html
<http://www.fltk.org/doc-1.3/classFl__Window.html#a508f3acd43f9b365d35897b5ec197dbe>
<http://www.fltk.org/doc-1.3/classFl__Window.html#a2c67d0656099b902c17525dfb9b1ebe5>
<http://www.fltk.org/doc-1.3/classFl__Window.html#aaf849aeb0878174971fdb6dab5388873>
<http://www.fltk.org/doc-1.3/classFl__Window.html#ab26c3813e4c519ea2912c08bb1dcdb72>

> I really appreciate FLTK and it is very full featured and extremely easy
> to use! It works extremely well on older machines, as well as newer
> machines, so thank you so much for this wonderful toolkit!!!!

You're welcome.

The following demo program can set arbitrary icons from PNG files.
Compile with 'fltk-config --use-images --compile hello_icon.cxx'.
Run w/o arguments or with one argument (the .png image file). The png
files should have a reasonable size though (e.g. 128x128).
Note that argument parsing is a hack (NOT intended to be used this way).

If you run it w/o arguments it tries to load "hello.png" from the
working directory.

The program is derived from test/hello.cxx. I elided the copyright info
for brevity.

// hello_icon.cxx, derived from FLTK example: test/hello.cxx
// Compile: fltk-config --use-images --compile hello_icon.cxx
// Run: ./hello_icon [icon.png]
// Default icon: "hello.png"

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_PNG_Image.H> // added
#include <FL/fl_ask.H> // added
#include <string.h> // added: strrchr()

int main(int argc, char **argv) {

Fl_Window *window = new Fl_Window(340,180);

// find and load PNG image file (added)

const char *name = (argc > 1) ? argv[1] : "hello.png";
if (argc>1) argc = 1; // BAD HACK !

Fl_PNG_Image *img = new Fl_PNG_Image(name); // load image
if (img->w() == 0 || img->h() == 0) {
fl_message("Can't open icon file '%s'",name);
exit(1);
}

// set icon and xclass

window->icon(img); // set window icon

const char *xc = strrchr(name,'/'); // find file name part
if (!xc) xc = name; // no directory part
window->xclass(xc); // set xclass for grouping

Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD+FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show(argc, argv);
return Fl::run();
}

israel dahl

unread,
Feb 13, 2015, 12:20:30 AM2/13/15
to fltkg...@googlegroups.com
Hi Vincent,
I have tried this, as well as the code of others.
I am fairly new to FLTK, so I may be missing something.

I suppose I should have initially explained I am using C++
My main() calls a base UI which launches 9 other possible sub programs.
Each program is its own class.
So the UI launching program contains your code (currently)

but does not draw the icon image..

I may be missing something very simple, as I have looked at this issue too much :)
I may try this on a very simple program to see if it works well.

israel dahl

unread,
Feb 13, 2015, 12:31:15 AM2/13/15
to fltkg...@googlegroups.com
 Albrecht Schlosser,
Thank you very much for the detailed reply!!

I very much look forward to this much simpler way of drawing icons!

The xclass() option is great, and works very easily, I simply had missed seeing that one before.
Thank you that solves my issue with window grouping.

On Ubuntu 14.10 all the FLTK games are grouped together and do not set icons.  Are those programs supposed to be setting their own icons?
I had begun to wonder if FLTK had this capability.

As another note, it would be extremely handy if FLUID integrated the new icon ability to set the image from the image field (for the Window)

Greg Ercolano

unread,
Feb 13, 2015, 3:52:04 AM2/13/15
to fltkg...@googlegroups.com
On 02/12/15 21:31, israel dahl wrote:
> I very much look forward to this much simpler way of drawing icons!

I posted this small bit of code; I think this qualifies
as "simple".. did this not work?

--- snip
..
#include <FL/Fl_Pixmap.H>
#include <FL/Fl_RGB_Image.H>
#include "../xpms/yourapp-16x16.xpm"
..
int main() {
..
Fl_Pixmap yourapp_16x16_icon(yourapp_16x16_xpm);
Fl_RGB_Image yourapp_icon(&yourapp_16x16_icon, Fl_Color(0));
yourwin->icon(&yourapp_icon);
yourwin->xclass("yourapp");
yourwin->show();
..
--- snip

This takes an inline XPM and assigns it as the window
title icon. Reposting again in case you missed that msg,
as I think that does what you want, without any X calls..

Albrecht Schlosser

unread,
Feb 13, 2015, 10:32:29 AM2/13/15
to fltkg...@googlegroups.com
On 13.02.2015 06:31 israel dahl wrote:
> Albrecht Schlosser,
> Thank you very much for the detailed reply!!

You're welcome.

> I very much look forward to this much simpler way of drawing icons!
>
> The xclass() option is great, and works very easily, I simply had missed
> seeing that one before.
> Thank you that solves my issue with window grouping.

I'm glad I could help.

> On Ubuntu 14.10 all the FLTK games are grouped together and do not set
> icons. Are those programs supposed to be setting their own icons?
> I had begun to wonder if FLTK had this capability.

There are only a few (maybe only one?) that use icons and create full
Mac bundles etc.. For instance the sudoku demo does it, but lacks
setting a specific xclass. The only test program I found that sets an
xclass() is test/clock.cxx - hence all FLTK demo programs except clock
are grouped together in the default 'fltk' group.

I believe we could at least give the full-featured demo programs like
blocks, puzzle, checkers, sudoku, etc. their own xclass() and icons.
Thanks for mentioning this. I'll take a look into it...

> As another note, it would be extremely handy if FLUID integrated the new
> icon ability to set the image from the image field (for the Window)

We certainly can't use the image field, but maybe this could be done
somehow. However I'm not the specialist for fluid, so others may know
better...

Anyway, there are different ways to go for different reasons. Imbedding
an icon is certainly useful, because you don't have to install an extra
image file and find and convert it at runtime. Using an image (file) can
be easier and makes the program smaller. OTOH fluid can convert and
imbed images, so this could probably be done.

crocher...@gmail.com

unread,
Feb 13, 2015, 10:56:58 PM2/13/15
to fltkg...@googlegroups.com
Ok, following this discussion I did a few testings on the different options to display an icon in taskbar/launch panel.

So, on my system:
-Ubuntu 14.04
-Gnome (both fallback and Unity)
-FLTK 1.3.2 (so not the most recent 1.3.3 but the one available on Ubuntu repo)

in summary:


*Greg suggestion (w/o X calls):

icon_pix=new Fl_Pixmap(icon_xpm);
icon_img=new Fl_RGB_Image((uchar *) icon_pix, Fl_Color(0));
window->icon(icon_img);
will not compile, because of second line: Fl_RGB_Image(uchar*, Fl_Color) doesn't exist in my fltk version (maybe added in 1.3.3 ?), so I had to replace by icon_img=new Fl_RGB_Image((uchar *) icon_pix, icon_pix->w(), icon_pix->h(), icon_pix->d(), icon_pix->ld());. At the end I have:

icon_pix=new Fl_Pixmap(icon_xpm);
icon_img=new Fl_RGB_Image((uchar *) icon_pix, icon_pix->w(), icon_pix->h(), icon_pix->d(), icon_pix->ld());
window->icon(icon_img);
Compile fine, but whatever the icon_xpm size is, it doesn't work and show a default icon instead of the loaded one. I did check that the Fl_Pixmap and then Fl_Image are correctly loaded (size is correct...).



*What I was using so far (for xBm images, NOT xPm):

static Pixmap p = XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display), (char *)icon_bits, icon_width, icon_height);
window->icon((char *)p);
Does work well, but for an xBm image and require to link X11 library. And, as opposed to what I was saying, fl_open_display() is not required.



*ed and kdiman suggestion (for xPm images w/ xcall):

static Pixmap p;
Pixmap mask;
XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display), (char **)icon_xpm, &p, &mask, 0);
window->icon((char *)p);
Compile and works well on my system for an xPm image (this is my favourite solution now), but require (as stated by ed) to link with Xpm library. 



I have no idea why Greg option doesn't work, I have tried a couple of "alternatives" to try to get it to work w/o X calls but w/o any success. As said, interestingly, there is no complain at compilation, linking or runtime, but system seems to just not accept the icon and set the default one.

Israel, as Greg stated, for any of the methods, you should anyway be careful that your pixmap doesn't goe out of scope and that you call the icon() before showing the window.

And sorry for not giving the real minimal example but was quicker for me to test that on an existing FLTK program.

Greg Ercolano

unread,
Feb 14, 2015, 3:13:27 AM2/14/15
to fltkg...@googlegroups.com
On 02/13/15 19:56, crocher...@gmail.com wrote:
*Greg suggestion (w/o X calls):
icon_pix=new Fl_Pixmap(icon_xpm);
icon_img=new Fl_RGB_Image((uchar *) icon_pix, Fl_Color(0));
window->icon(icon_img);
will not compile, because of second line: Fl_RGB_Image(uchar*, Fl_Color) doesn't exist in my fltk version (maybe added in 1.3.3 ?)

    Yes, apparently that's new in 1.3.3, added by ossman in svn r10192:

------------------------------------------------------------------------
r10192 | ossman | 2014-06-12 06:28:04 -0700 (Thu, 12 Jun 2014) | 5 lines

Add ability to convert a Fl_Pixmap into a Fl_RGB_Image.
This is very convenient as a lot of other functions only accept
a Fl_RGB_Image. Adding this functionality also required a bit
of spring cleaning in the the drawing routines. STR #2659.
------------------------------------------------------------------------

    1.3.3 was released a few months later on Nov 3 2014. So yes, if you jumped to 1.3.3
    you'd get that feature.

    FWIW, below is a complete "foo.cxx" file example that will display one of the
    fltk xpms I grabbed from the fluid/pixmaps directory, a green square with a double slash,
    in the titlebar of the window, e.g.


    Here's the code:



#include <FL/Fl.H>

#include <FL/Fl_Window.H>
#include <FL/Fl_Pixmap.H>
#include <FL/Fl_RGB_Image.H>
/* XPM */
static const char *flComment_xpm[] = {
  /* width height ncolors chars_per_pixel */
  "16 16 4 1",
  /* colors */
  ". c none",
  "a c #000000",
  "b c #c0e0c0",
  "c c #000000",
  /* pixels */
  "................",
  "................",
  ".aaaaaaaaaaaaaa.",
  ".abbbbbbbbbbbbc.",
  ".abbbbbccbbccbc.",
  ".abbbbccbbccbbc.",
  ".abbbbccbbccbbc.",
  ".abbbccbbccbbbc.",
  ".abbbccbbccbbbc.",
  ".abbccbbccbbbbc.",
  ".abbccbbccbbbbc.",
  ".abccbbccbbbbbc.",
  ".abbbbbbbbbbbbc.",
  ".accccccccccccc.",
  "................",
  "................",
};

int main() {
  Fl_Window *win = new Fl_Window(500,200,"foo");
  Fl_Pixmap foo_16x16_icon(flComment_xpm);
  Fl_RGB_Image foo_icon(&foo_16x16_icon, Fl_Color(0));
  win->icon(&foo_icon);
  win->xclass("foo");
  win->show();
  return(Fl::run());
}

israel dahl

unread,
Feb 14, 2015, 9:12:58 AM2/14/15
to fltkg...@googlegroups.com
Hi everyone,
thank you I will look at these suggestions and test things out.
I think my main issue is going to be scope, so I will have to determine how to load the icon before drawing the window.  I may need to alter the setup of my program in order to do this, since I need to load the icon before the window.

I have not been able (as of yet) to get the icon to set, but now that it has been fully confirmed and explained to me, I will indeed decipher how I need to rework things to accomplish this.

Thank you all very much!!  I am delighted at how helpful and dedicated you all have been to helping me understand the entirety of this issue and all the ways to solve it.

I really appreciate all this help, and again thank you all for FLTK, it is a delight to program with!  Very fast to make small programs, and very robust for larger ones!!

israel dahl

unread,
Jul 21, 2015, 10:28:38 AM7/21/15
to fltkg...@googlegroups.com
Hi all,
this is a late reply to this thread, but I wanted to post the simple way which I solved my issue.

i made a desktop file for my program, for example:
example.desktop

[Desktop Entry]
Name=Example
Icon=example
Exec=example
Terminal=false
Type=Application
Categories=System



Then I simply set my xclass to "example" for each of my windows.  This is easy to do via FLUID, but here is a quick code example (for anyone new to FLTK trying to figure this out)


Fl_Double_Window* ExampleClass::make_window() {
 
{ win =  new Fl_Double_Window(480, 330, "EXAMPLE");
   
/*more code*/
    win
->xclass("example");
 
}
}



It ended up being MUCH more simple than I had been making it...
Thanks again everyone here for pointing me in the right directions :)

MacArthur, Ian (Selex ES, UK)

unread,
Jul 21, 2015, 10:45:23 AM7/21/15
to fltkg...@googlegroups.com
> this is a late reply to this thread, but I wanted to post the
> simple way which I solved my issue.

> i made a desktop file for my program, for example:


Though I'd caution that this will only set an icon on systems using window managers that respect the .desktop files.

The "advantage" of (also) setting the icon programmatically in your code at runtime using the old Xlib calls is that even legacy systems, or window managers that do not know what a .desktop file is for, will still show some sort of icon...




Selex ES Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

israel dahl

unread,
Jul 21, 2015, 10:56:34 AM7/21/15
to fltkg...@googlegroups.com, ian.ma...@selex-es.com
Not entirely.
JWM respects this... as long as I include those icon paths (for the icons) in my jwmrc.

So, it seems that as long as the icon path is included in the Window Manager's search paths and the xclass is set to the icon name, it should find it if the window manager searches for icons based on the xclass name.

So, this *might* work in other window managers as well if they do a similar search for the window's icon

Karl Harbinger

unread,
Jun 29, 2016, 2:12:26 AM6/29/16
to fltk.general
That worked for me:
Fl_Pixmap win_pixmap(icon_xpm);
Fl_RGB_Image win_icon(&win_pixmap, Fl_Color(0));
win
->icon(&win_icon);

But is it also possible to set an icon for windows from these "convenient functions" like fl_message() or fl_file_chooser() in a similar way?

Albrecht Schlosser

unread,
Jul 11, 2016, 7:48:45 AM7/11/16
to fltkg...@googlegroups.com
On 29.06.2016 08:12 Karl Harbinger wrote:
> That worked for me:
> |
> Fl_Pixmapwin_pixmap(icon_xpm);
> Fl_RGB_Imagewin_icon(&win_pixmap,Fl_Color(0));
> win->icon(&win_icon);
> |
>
> But is it also possible to set an icon for windows from these
> "convenient functions" like fl_message() or fl_file_chooser() in a
> similar way?

As Ian mentioned, most WM's don't show an icon for modal windows, and
modal windows are usually not shown in the taskbar.

My tests showed however that metacity and xfce (and, as you mentioned,
unity) do show icons in modal windows, and these modal windows show up
in the task bar as well.

Currently (in FLTK 1.3) you can't set a window icon for the modal
dialogs specifically, but you can set a global default icon for all
windows. In my tests this worked for the FLTK convenience dialogs: just call

Fl_Window::default_icon(&win_icon);

instead of setting the icon for a window as in your example above. That
should do the trick. If you need to change the icon for a particular
dialog only, then you may change the default icon before you fire that
dialog, and you may want to change (reset) it after the dialog returns.

Reply all
Reply to author
Forward
0 new messages