FLTK logo

STR #925

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 2.0 | Post Text | Post File | SVN ⇄ GIT ]

STR #925

Application:FLTK Library
Status:5 - New
Priority:1 - Request for Enhancement, e.g. asking for a feature
Scope:2 - Specific to an operating system
Subsystem:Unassigned
Summary:Icon fixes in Windows and X
Version:2.0-feature
Created By:syrja
Assigned To:Unassigned
Fix Version:Unassigned
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

Post File ]

No files


Trouble Report Comments:

Post Text ]
Name/Time/Date Text  
 
#1 syrja
06:24 Jun 29, 2005
Following is copy of my message to fltk.general.

I'm not exactly sure how this should be used.
It could be added to FLTK sources somehow, but probably
needs some (binary incompatible?) modifications to icon
handling. Also, Mac programmers with their own icon
problems have probably some comments.

Of course, it could just be added to documentation
for use with application programs.


--------original message------
I just played with application icons in Windows and X. FLTK (both 1.1 and 2.0) seems to have some limitations in those platforms.

First, Windows supports two icon sizes big (32x32) and small (16x16), but FLTK accepts only one icon image. From Fl_win32.cxx we can see that it sets same image to both small and big icon:

wc.hIcon = wc.hIconSm = (HICON)w->icon();

If I follow the icon setting procedure from documentation and set only big icon, Windows automatically scales it smaller for window title bar by dropping every other pixel/scanline and the result can be quite ugly.

Fortunately, this can be fixed in application code by setting both icons manually after the window is shown:

window->show(argc, argv);
HANDLE bigicon = LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(icon_id), IMAGE_ICON, 32, 32, 0);
SendMessage(fl_xid(window), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(bigicon));
HANDLE smallicon = LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(icon_id), IMAGE_ICON, 16, 16, 0);
SendMessage(fl_xid(window), WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(smallicon));

This makes Windows to use correct size icon images without scaling.

Then, in X we have similar problem. Documentation explains how to set pixmap icon for application. In fl_x.cxx it sets the pixmap to XWMHints, but does not set mask:

hints->icon_pixmap = (Pixmap)win->icon();
hints->flags       |= IconPixmapHint;

Again, this can be fixed in application code:

fl_open_display();
Pixmap pixmap, mask;
XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display), foo_xpm, &pixmap, &mask, 0);
window->icon(reinterpret_cast<char*>(pixmap));
window->show(argc, argv);
XWMHints* hints = XGetWMHints(fl_display, fl_xid(window));
hints->flags |= IconMaskHint;
hints->icon_mask = mask;
XSetWMHints(fl_display, fl_xid(window), hints);
XFree(hints);

Now the application icon is displayed correctly with mask.

These are tested with FLTK 1.1.6, Windows XP SP2 and Mandriva Linux LE2005/KDE, but should work with FLTK 2.0 and other Windows and Linux platforms.
 
     

Return to Bugs & Features | Post Text | Post File ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.