comparison src/video/x11/SDL_x11shape.c @ 4845:61cb2d20a46f

Fixing bugs introduced into X11 shaping implementation by merge.
author Eli Gottlieb <eligottlieb@gmail.com>
date Tue, 10 Aug 2010 15:45:59 -0400
parents 05d172e92b52
children 4f1573996a65
comparison
equal deleted inserted replaced
4844:c4f5bcaf7572 4845:61cb2d20a46f
18 18
19 Eli Gottlieb 19 Eli Gottlieb
20 eligottlieb@gmail.com 20 eligottlieb@gmail.com
21 */ 21 */
22 22
23 #include <assert.h> 23 #include "SDL_assert.h"
24 #include "SDL_x11video.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 27
28 SDL_Window* 28 SDL_Window*
29 X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { 29 X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
30 return SDL_CreateWindow(title,x,y,w,h,flags); 30 return SDL_CreateWindow(title,x,y,w,h,flags);
31 } 31 }
32 32
33 SDL_WindowShaper* 33 SDL_WindowShaper*
34 X11_CreateShaper(SDL_Window* window) { 34 X11_CreateShaper(SDL_Window* window) {
35 SDL_WindowShaper* result = NULL; 35 SDL_WindowShaper* result = NULL;
36 36
37 #if SDL_VIDEO_DRIVER_X11_XSHAPE 37 #if SDL_VIDEO_DRIVER_X11_XSHAPE
38 if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ 38 if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */
39 result = malloc(sizeof(SDL_WindowShaper)); 39 result = malloc(sizeof(SDL_WindowShaper));
40 result->window = window; 40 result->window = window;
41 result->mode.mode = ShapeModeDefault; 41 result->mode.mode = ShapeModeDefault;
42 result->mode.parameters.binarizationCutoff = 1; 42 result->mode.parameters.binarizationCutoff = 1;
43 result->usershownflag = 0; 43 result->usershownflag = 0;
44 SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData)); 44 SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData));
45 result->driverdata = data; 45 result->driverdata = data;
46 data->bitmapsize = 0; 46 data->bitmapsize = 0;
47 data->bitmap = NULL; 47 data->bitmap = NULL;
48 window->shaper = result; 48 window->shaper = result;
49 int resized_properly = X11_ResizeWindowShape(window); 49 int resized_properly = X11_ResizeWindowShape(window);
50 assert(resized_properly == 0); 50 SDL_assert(resized_properly == 0);
51 } 51 }
52 #endif 52 #endif
53 53
54 return result; 54 return result;
55 } 55 }
56 56
57 int 57 int
58 X11_ResizeWindowShape(SDL_Window* window) { 58 X11_ResizeWindowShape(SDL_Window* window) {
59 SDL_ShapeData* data = window->shaper->driverdata; 59 SDL_ShapeData* data = window->shaper->driverdata;
60 assert(data != NULL); 60 SDL_assert(data != NULL);
61 61
62 unsigned int bitmapsize = window->w / 8; 62 unsigned int bitmapsize = window->w / 8;
63 if(window->w % 8 > 0) 63 if(window->w % 8 > 0)
64 bitmapsize += 1; 64 bitmapsize += 1;
65 bitmapsize *= window->h; 65 bitmapsize *= window->h;
78 window->shaper->usershownflag |= window->flags & SDL_WINDOW_SHOWN; 78 window->shaper->usershownflag |= window->flags & SDL_WINDOW_SHOWN;
79 79
80 return 0; 80 return 0;
81 } 81 }
82 82
83 int 83 int
84 X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { 84 X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
85 if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) 85 if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
86 return -1; 86 return -1;
87 87
88 #if SDL_VIDEO_DRIVER_X11_XSHAPE 88 #if SDL_VIDEO_DRIVER_X11_XSHAPE