comparison src/video/SDL_video.c @ 2967:e4a469d6ddab

Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 02 Jan 2009 17:39:48 +0000
parents 1fcc36adc73d
children 0b160c970b7e
comparison
equal deleted inserted replaced
2966:c1e3621ba959 2967:e4a469d6ddab
961 961
962 if (!window) { 962 if (!window) {
963 return NULL; 963 return NULL;
964 } 964 }
965 return window->title; 965 return window->title;
966 }
967
968 void
969 SDL_SetWindowIcon(SDL_WindowID windowID, SDL_Surface * icon)
970 {
971 SDL_Window *window = SDL_GetWindowFromID(windowID);
972
973 if (!window) {
974 return;
975 }
976 if (_this->SetWindowIcon) {
977 _this->SetWindowIcon(_this, window, icon);
978 }
966 } 979 }
967 980
968 void 981 void
969 SDL_SetWindowData(SDL_WindowID windowID, void *userdata) 982 SDL_SetWindowData(SDL_WindowID windowID, void *userdata)
970 { 983 {
1588 } else { 1601 } else {
1589 SDL_UpdateTexture(textureID, NULL, surface->pixels, 1602 SDL_UpdateTexture(textureID, NULL, surface->pixels,
1590 surface->pitch); 1603 surface->pitch);
1591 } 1604 }
1592 } else { 1605 } else {
1593 SDL_PixelFormat *dst_fmt; 1606 SDL_PixelFormat dst_fmt;
1594 SDL_Surface *dst = NULL; 1607 SDL_Surface *dst = NULL;
1595 1608
1596 /* Set up a destination surface for the texture update */ 1609 /* Set up a destination surface for the texture update */
1597 dst_fmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); 1610 SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask);
1598 if (dst_fmt) { 1611 if (SDL_ISPIXELFORMAT_INDEXED(format)) {
1599 if (SDL_ISPIXELFORMAT_INDEXED(format)) { 1612 dst_fmt.palette =
1600 dst_fmt->palette = 1613 SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
1601 SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format))); 1614 if (dst_fmt.palette) {
1602 if (dst_fmt->palette) { 1615 /*
1603 /* 1616 * FIXME: Should we try to copy
1604 * FIXME: Should we try to copy 1617 * fmt->palette?
1605 * fmt->palette? 1618 */
1606 */ 1619 SDL_DitherColors(dst_fmt.palette->colors,
1607 SDL_DitherColors(dst_fmt->palette->colors, 1620 SDL_BITSPERPIXEL(format));
1608 SDL_BITSPERPIXEL(format));
1609 }
1610 } 1621 }
1611 dst = SDL_ConvertSurface(surface, dst_fmt, 0); 1622 }
1612 if (dst) { 1623 dst = SDL_ConvertSurface(surface, &dst_fmt, 0);
1613 SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch); 1624 if (dst) {
1614 SDL_FreeSurface(dst); 1625 SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
1615 } 1626 SDL_FreeSurface(dst);
1616 if (dst_fmt->palette) { 1627 }
1617 SDL_FreePalette(dst_fmt->palette); 1628 if (dst_fmt.palette) {
1618 } 1629 SDL_FreePalette(dst_fmt.palette);
1619 SDL_FreeFormat(dst_fmt);
1620 } 1630 }
1621 if (!dst) { 1631 if (!dst) {
1622 SDL_DestroyTexture(textureID); 1632 SDL_DestroyTexture(textureID);
1623 return 0; 1633 return 0;
1624 } 1634 }