OK, here is the problem. I want a 32x32 png image to show up as the window icon, but it doesnt show, only thing there is the default X11 icon. I looked in related forum topics to see if I am doing everything right. I saw that I did everything right, but still my icon doesn't show up. When I ported my game to the Windows OS, my icon showed up. At this point I am not sure if its a SFML problem, I don't know really.
I am running Sabayon x64, which is basically Gentoo.
KDE for graphical desktop.
here is a snippet code.
void Game::start(){
// Create the window
window.create( sf::VideoMode( resolution.x, resolution.y ), "Terra" );
// Set FrameRate
window.setFramerateLimit( framerate );
//window.setVerticalSyncEnabled( true );
// Load images relevent to the window, ex. icon, mouse pointer
widnow_icon.loadFromFile( "./assets/images/icon.png" );
// Set icon
window.setIcon( 32, 32, widnow_icon.getPixelsPtr() );
// Center window
centerWindow();
// Start game loop
mainLoop();
}
Update:
I was looking around to to bypass sfml and go straight to X11. people talked about the setting _NET_WM_ICON property. Complicated stuff. Anyway in the WindowImplX11.cpp setting the title You use
_NET_WM_ICON_NAME which is good, but under the set icon function I don't see _NET_WM_ICON. Well this is complicated, i dont know.
Update:
OK, i had to open Virtualbox with manjaro(arch linux). I notice that the icon showed up. So i guess its just me.
I gotta find out why.
Update:
Ok i tried it using SDL instead of SFML, it works. I don't think anything is wrong with my Xcb since alot of other applications that use Xcb have thier icons show up. Basically I am saying why I have a problem with SFML only.
I read a ticket on sfml github, someone moved from xlib to xbc because xlib was complicated. lol their both complicated. oh well. If any devs are looking at this can you look over the set icon funtion in window x11.cpp? Or anyone else that has gentoo 64 x11 to try setting application icon to see if you get the same problem(virtual box takes too much time for me). I need to know if there is a bug with SFml, or me. Thank you.
ps:
"- Use _NET_WM_ICON to set icon on X11 instead of XSetWMHints."
that was from one of allegro's change logs. Since I saw this 'WMHints hints;' in sfml source I have to wonder of Hinting is a good idea.
------
simple example
#include <SFML/Graphics.hpp>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
sf::Image img;
img.loadFromFile( "./icon.png" );
window.setIcon( 48, 48, img.getPixelsPtr() );
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.display();
}
return EXIT_SUCCESS;
}
g++ -std=c++11 -g -Wall -Wextra -lsfml-graphics -lsfml-window -lsfml-system main.cpp -o test
Update:
Here is my x11 properties on the sfml window
>xprop
_NET_WM_ICON_GEOMETRY(CARDINAL) = 957, 871, 195, 28
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_MOVE, _NET_WM_ACTION_RESIZE, _NET_WM_ACTION_MINIMIZE, _NET_WM_ACTION_SHADE, _NET_WM_ACTION_MAXIMIZE_VERT, _NET_WM_ACTION_MAXIMIZE_HORZ, _NET_WM_ACTION_FULLSCREEN, _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_CLOSE
_KDE_NET_WM_FRAME_STRUT(CARDINAL) = 4, 4, 29, 4
_NET_FRAME_EXTENTS(CARDINAL) = 4, 4, 29, 4
_NET_WM_DESKTOP(CARDINAL) = 0
_KDE_NET_WM_ACTIVITIES(STRING) = "70f90bdb-b0c0-4a98-af00-4ec768ae8664"
WM_STATE(WM_STATE):
window state: Normal
icon window: 0x0
_NET_WM_STATE(ATOM) =
_NET_WM_ICON_NAME(UTF8_STRING) = "Terra"
_NET_WM_NAME(UTF8_STRING) = "Terra"
WM_ICON_NAME(UTF8_STRING) = "Terra"
WM_NAME(UTF8_STRING) = "Terra"
WM_CLASS(STRING) = "Terra", "Terra"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x3, 0x3e, 0x7e, 0x0, 0x0
WM_HINTS(WM_HINTS):
bitmap id # to use for icon: 0x4a3a02f
bitmap id # of mask for icon: 0x4a3a031
WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, _NET_WM_PING
_NET_WM_PID(CARDINAL) = 4410
_KDE_NET_WM_USER_CREATION_TIME(CARDINAL) = 84563198