Window Icon

Started by psiegel, July 10, 2003, 12:42:33

Previous topic - Next topic

psiegel

Is there any way to set the window icon to something other than the default?  I mean the one that appears in the top left corner of the window's title bar, and in the task bar.  

If not, can I put in a feature request for that?

Paul

princec


tomb

Been awhile since this was requested :cry:

I've taken the liberty to implement this on windows. MacOS port is trivial as it uses awt. I leave it up to someone else to do the linux port.

Anyway, it seems I've gotten this to work on windows. Windows has 2 icon sizes. The big icon is used when alt-tabbing between application, the smal icon is used in the frame caption, and the taskbar. I've added 2 functions: setSmallWindowIcon and setBigWindowIcon. I'd like to keep the 2 functions even if they are not used on Mac or linux. Is more professional than haveing one of the icons scaled.

There is no need for a getMin/MaxSize, as windows and awt will accept icons of any size. It is better to have getRecommendedSmallIconSize and getRecommendedBigIconSize functions to allow the lwjgl application to privede the icons that has the closest fit.

I can post the code here in the forum or I could mail it to someone with cvs access. I don't want to commit to cvs directly as it will take me too long to set up. It would be a good idee if someone that knows windows/c programming has a look at the code, as I'm sure it has bunch of resource leaks in it :oops:

Matzon

awesome!
send it to info@lwjgl.org and I'll take a look at it. We might refactor the code as needed though.

tomb

Quote from: "Matzon"awesome!
send it to info@lwjgl.org and I'll take a look at it. We might refactor the code as needed though.
Sure, do what you like with it. The code is in the mail.

elias4444

If the Mac port is trivial because it uses awt, would the Linux port also not be trivial? Or am I missing something here?

BTW, great job on the Windows icon!  :)
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

tomb

I think linux does all it's own window managment, and do not use awt.

princec

I think Elias has rewritten it all to use AWT now on Linux.

Cas :)

tomb

Did not know about that. I just looked at the 0.96 source.

In that case the linux port will be trivial as well.

elias

Ah, no. Linux Display uses AWT locking to synchronize with AWT because X11 is not multithread safe. The rest of the code is still custom X11 (except AWTGLCanvas support of course)

- elias

kevglass

I was going to look at doing the linux version, but we need to decide on the API. Since each of the platforms require different size icons (16x16 and 24x24 for windows, 16x16 upwards for linux, and preferably huge for MacOS) we need something beautifully generic.

A suggestions:
public class Display {
     public static final int ICON_16 = 1;
     public static final int ICON_24 = 2;
     public static final int ICON_32 = 3;
     public static final int ICON_64 = 4;
     public static final int ICON_128 = 5;

     public static void setIcon(int type,ByteBuffer data) {
             // each Display implementation decides whether it wants to use
             // this icon size or not, if not the default or previously set icon is
             // maintained

             // assumed RGBA8 - if not the implementation is responsible
             // for filtering
     }
}


Kev

Matzon

Why the type then? - if the data is RGBA8 then just check the size of the passed buffer?

kevglass

I was thinking it let people who were using it know what sizes it would be good to provide. But yeah, I see your point.. maybe the javadoc could say enough?

Kev

kevglass

So, what ya reckon? On IRC we've talked about some sort of wrapped object (org.lwjgl.Image?) that holds the byte buffer, validates it and handles conversions for platform specifics.

I've got linux code that seems to work now, so we just need an API :)

Kev

tomb

Lets recap how icons are handled on the different systems and try to come up with a sensible api that enables all the available features, but keeps the api simple.

On windows there are:
-BigIcon, size 32x32, used when alt-tabbing between apps.
-SmalIcon, size 16x16, used in window titlebar and taskbar.
The image used can be of any reasonable size (think there is limit around 4096*4096). The image will be scaled with bilinear filtering to 32x32 or 16x16 by windows. Only tested on windows xp. Don't know if other icons sizes are in use on other windows version/setup.

MacOs:
Because it uses AWT only one icon can be used threw setIconImage(Image image). I assume that the image will be resized by awt to the prefered size on MacOS. Can anyone try to find out what the prefered size of the icon is on MacOS?

Can you give a description of how icons works on linux, kevglass?

I don't see the need for a org.lwjgl.Image class. Just document that the pixels need to be tighly packed and format of the pixel (ARGB or RGBA). Width and height are passed in as arguments to the functions.