Changing icon mask when window was shown will not work on all window managers/panels; the best way would be to append mask before window was actually shown (e.g. before XMapWindow on X11).
In edelib (EDE library) I added function window_xid_create() which behaves as Fl_X::make_xid() (the code is the same, with small modifications); it accepts callback, fired before window was mapped on the screen. This is useful for number of reasons (like setting window type) and is also explored for setting window icon. Regards, Sanel On 06/06/2012 11:03 AM, MacArthur, Ian (SELEX GALILEO, UK) wrote: > >> There is another problem with X11 icon: >> window.icon((char *)p); does not support transparency. >> The reason is simple: transparency information is carried by the other >> pixmax ,the variable "mask" in your program and it is not transmitted to >> window.icon(). >> To get icon with transparency you have to use Xlib functions: >> XGetWMHints() and XSetWMHints() to get X11 to communicate both pixmap to >> the window manager. >> See the previously posted message fore more details: >> http://fltk.org/newsgroups.php?gfltk.general+v:24241 > > In case anyone finds it useful, here's a snippet of code showing what I > usually do. > > I've used this in a few places, and with a few different WM, and it appears > to do the Right Thing... > > > > // in the headers I have... > > > // Application icon setting > #ifdef WIN32 > # include "media/win32icon.h" > #elif !defined(__APPLE__) /* Not Apple and not win32 - assume Xlib applies */ > # include<X11/xpm.h> > //# include "media/fn-edit-icon.xbm" -- monochrome XBM, not used > # include "media/fn5x64.xpm" > #endif // !WIN32 > > > > > // then in the entry code, just before I show the first window, I have... > > > // Set icon for window before we show it (MacOS uses app bundle for > icon...) > #ifdef WIN32 > main_window->icon((char *)LoadIcon(fl_display, > MAKEINTRESOURCE(IDI_ICON))); > #elif !defined(__APPLE__) > fl_open_display(); // Make sure the display is available before we try > and change it! > Pixmap pixmap, mask; // create pixmaps to hold the icon image and its > mask > // load the XPM and prepare the mask > XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display), > (char**)fn5x64_xpm_data,&pixmap,&mask, 0); > // assign to the fltk main window > // note that the fltk icon handling DOES NOT honour transparency, > // so we fix that AFTER the window is shown (see below) > main_window->icon((char*)pixmap); > #endif // WIN32 > > main_window->show(argc, argv); > > #ifdef WIN32 > // The fltk icon code above only loads the default icon. > // Here, once the window is shown, we can assign > // additional icons, just to make things a bit nicer. > { > HANDLE bigicon = LoadImage(GetModuleHandle(0), > MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 32, 32, 0); > SendMessage(fl_xid(main_window), WM_SETICON, ICON_BIG, (LPARAM)bigicon); > HANDLE smallicon = LoadImage(GetModuleHandle(0), > MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); > SendMessage(fl_xid(main_window), WM_SETICON, ICON_SMALL, > (LPARAM)smallicon); > } > #elif !defined(__APPLE__) /* Not Apple and not win32 - assume Xlib */ > // The fltk icon code doesn't handle XPM transparency well, work around that > here... > { > // read in the current window hints, then modify them to allow icon > transparency > XWMHints* hints = XGetWMHints(fl_display, fl_xid(main_window)); > hints->flags |= IconMaskHint; // ensure transparency mask is enabled for > the XPM icon > hints->icon_mask = mask; // set the transparency mask > XSetWMHints(fl_display, fl_xid(main_window), hints); > XFree(hints); > } > #endif // !WIN32 > > > > > > SELEX Galileo 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. > ******************************************************************** > _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

