comparison src/video/x11/SDL_x11shape.c @ 4794:e562160a873f

Check configure-defined macro before doing _anything_ with XShape.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 13 Jul 2010 02:43:49 -0400
parents e07cd9e86d7a
children 6f0bc179771c
comparison
equal deleted inserted replaced
4793:cb31d2fdbe61 4794:e562160a873f
19 Eli Gottlieb 19 Eli Gottlieb
20 eligottlieb@gmail.com 20 eligottlieb@gmail.com
21 */ 21 */
22 22
23 #include <assert.h> 23 #include <assert.h>
24 #include <X11/extensions/shape.h> 24 #include "SDL_x11video.h"
25 #include "SDL_x11shape.h" 25 #include "SDL_x11shape.h"
26 #include "SDL_x11window.h" 26 #include "SDL_x11window.h"
27 #include "SDL_x11video.h"
28 27
29 SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) { 28 SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) {
30 SDL_WindowShaper* result = NULL; 29 SDL_WindowShaper* result = NULL;
30
31 #if SDL_VIDEO_DRIVER_X11_XSHAPE
31 if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ 32 if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */
32 result = malloc(sizeof(SDL_WindowShaper)); 33 result = malloc(sizeof(SDL_WindowShaper));
33 result->window = window; 34 result->window = window;
34 result->alphacutoff = 0; 35 result->alphacutoff = 0;
35 result->usershownflag = 0; 36 result->usershownflag = 0;
36 result->driverdata = malloc(sizeof(SDL_ShapeData)); 37 result->driverdata = malloc(sizeof(SDL_ShapeData));
37 window->shaper = result; 38 window->shaper = result;
38 int resized_properly = X11_ResizeWindowShape(window); 39 int resized_properly = X11_ResizeWindowShape(window);
39 assert(resized_properly == 0); 40 assert(resized_properly == 0);
40 } 41 }
42 #endif
41 43
42 return result; 44 return result;
43 } 45 }
44 46
45 int X11_ResizeWindowShape(SDL_Window* window) { 47 int X11_ResizeWindowShape(SDL_Window* window) {
67 } 69 }
68 70
69 int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { 71 int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
70 if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) 72 if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
71 return -1; 73 return -1;
74
75 #if SDL_VIDEO_DRIVER_X11_XSHAPE
72 if(!SDL_ISPIXELFORMAT_ALPHA(SDL_MasksToPixelFormatEnum(shape->format->BitsPerPixel,shape->format->Rmask,shape->format->Gmask,shape->format->Bmask,shape->format->Amask))) 76 if(!SDL_ISPIXELFORMAT_ALPHA(SDL_MasksToPixelFormatEnum(shape->format->BitsPerPixel,shape->format->Rmask,shape->format->Gmask,shape->format->Bmask,shape->format->Amask)))
73 return -2; 77 return -2;
74 if(shape->w != shaper->window->w || shape->h != shaper->window->h) 78 if(shape->w != shaper->window->w || shape->h != shaper->window->h)
75 return -3; 79 return -3;
76 SDL_ShapeData *data = shaper->driverdata; 80 SDL_ShapeData *data = shaper->driverdata;
83 87
84 XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet); 88 XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
85 XSync(windowdata->videodata->display,False); 89 XSync(windowdata->videodata->display,False);
86 90
87 XFreePixmap(windowdata->videodata->display,shapemask); 91 XFreePixmap(windowdata->videodata->display,shapemask);
88 92 #endif
93
89 return 0; 94 return 0;
90 } 95 }