src/video/x11/SDL_x11window.c
changeset 2967 e4a469d6ddab
parent 2945 e38423786728
child 2990 502adab079a4
equal deleted inserted replaced
2966:c1e3621ba959 2967:e4a469d6ddab
   644 #endif
   644 #endif
   645     }
   645     }
   646 }
   646 }
   647 
   647 
   648 void
   648 void
       
   649 X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
       
   650 {
       
   651     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
       
   652     Display *display = data->videodata->display;
       
   653     Atom _NET_WM_ICON = XInternAtom(display, "_NET_WM_ICON", False);
       
   654 
       
   655     if (icon) {
       
   656         SDL_PixelFormat format;
       
   657         SDL_Surface *surface;
       
   658         int propsize;
       
   659         Uint32 *propdata;
       
   660 
       
   661         /* Convert the icon to ARGB for modern window managers */
       
   662         SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
       
   663         surface = SDL_ConvertSurface(icon, &format, 0);
       
   664         if (!surface) {
       
   665             return;
       
   666         }
       
   667 
       
   668         /* Set the _NET_WM_ICON property */
       
   669         propsize = 2+(icon->w*icon->h);
       
   670         propdata = SDL_malloc(propsize * sizeof(Uint32));
       
   671         if (propdata) {
       
   672             propdata[0] = icon->w;
       
   673             propdata[1] = icon->h;
       
   674             SDL_memcpy(&propdata[2], surface->pixels, surface->h*surface->pitch);
       
   675             XChangeProperty(display, data->window, _NET_WM_ICON, 
       
   676                             XA_CARDINAL, 32, PropModeReplace,
       
   677                             (unsigned char *) propdata, propsize);
       
   678         }
       
   679         SDL_FreeSurface(surface);
       
   680     } else {
       
   681         XDeleteProperty(display, data->window, _NET_WM_ICON);
       
   682     }
       
   683 }
       
   684 
       
   685 void
   649 X11_SetWindowPosition(_THIS, SDL_Window * window)
   686 X11_SetWindowPosition(_THIS, SDL_Window * window)
   650 {
   687 {
   651     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   688     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   652     SDL_DisplayData *displaydata =
   689     SDL_DisplayData *displaydata =
   653         (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   690         (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;