From c2dcb634911140bf681827b06afd93bdb488d6eb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 21 Jan 2010 06:21:52 +0000 Subject: [PATCH] Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance. --- README.iphoneos | 8 +- Xcode-iPhoneOS/Demos/src/accelerometer.c | 28 +- Xcode-iPhoneOS/Demos/src/fireworks.c | 7 +- Xcode-iPhoneOS/Demos/src/happy.c | 18 +- Xcode-iPhoneOS/Demos/src/keyboard.c | 37 +- Xcode-iPhoneOS/Demos/src/mixer.c | 6 +- Xcode-iPhoneOS/Demos/src/rectangles.c | 8 +- Xcode-iPhoneOS/Demos/src/touch.c | 20 +- include/SDL_compat.h | 2 + include/SDL_events.h | 16 +- include/SDL_mouse.h | 6 +- include/SDL_syswm.h | 2 +- include/SDL_video.h | 156 +++--- src/SDL_assert.c | 2 +- src/SDL_compat.c | 36 +- src/events/SDL_keyboard.c | 10 +- src/events/SDL_keyboard_c.h | 4 +- src/events/SDL_mouse.c | 23 +- src/events/SDL_mouse_c.h | 6 +- src/events/SDL_windowevents.c | 6 +- src/events/SDL_windowevents_c.h | 2 +- src/video/SDL_gamma.c | 4 +- src/video/SDL_renderer_gl.c | 16 +- src/video/SDL_renderer_gles.c | 4 +- src/video/SDL_renderer_sw.c | 12 +- src/video/SDL_sysvideo.h | 35 +- src/video/SDL_video.c | 660 ++++++++--------------- src/video/cocoa/SDL_cocoamouse.m | 6 +- src/video/cocoa/SDL_cocoaopengl.m | 2 +- src/video/cocoa/SDL_cocoawindow.h | 4 +- src/video/cocoa/SDL_cocoawindow.m | 36 +- src/video/directfb/SDL_DirectFB_WM.c | 2 +- src/video/directfb/SDL_DirectFB_events.c | 42 +- src/video/directfb/SDL_DirectFB_mouse.c | 16 +- src/video/directfb/SDL_DirectFB_render.c | 8 +- src/video/directfb/SDL_DirectFB_window.c | 2 +- src/video/directfb/SDL_DirectFB_window.h | 2 +- src/video/dummy/SDL_nullrender.c | 18 +- src/video/nds/SDL_ndsrender.c | 14 +- src/video/pandora/SDL_pandora.c | 4 +- src/video/photon/SDL_photon.c | 44 +- src/video/photon/SDL_photon_input.c | 32 +- src/video/photon/SDL_photon_render.c | 10 +- src/video/ps3/SDL_ps3render.c | 8 +- src/video/qnxgf/SDL_gf_input.c | 14 +- src/video/qnxgf/SDL_gf_render.c | 8 +- src/video/qnxgf/SDL_qnxgf.c | 10 +- src/video/uikit/SDL_uikitappdelegate.h | 8 +- src/video/uikit/SDL_uikitappdelegate.m | 12 +- src/video/uikit/SDL_uikitkeyboard.h | 9 +- src/video/uikit/SDL_uikitview.m | 26 +- src/video/uikit/SDL_uikitwindow.h | 2 +- src/video/uikit/SDL_uikitwindow.m | 107 ++-- src/video/win32/SDL_ceddrawrender.c | 14 +- src/video/win32/SDL_d3drender.c | 16 +- src/video/win32/SDL_gapirender.c | 4 +- src/video/win32/SDL_gdirender.c | 24 +- src/video/win32/SDL_win32events.c | 41 +- src/video/win32/SDL_win32window.c | 10 +- src/video/win32/SDL_win32window.h | 2 +- src/video/x11/SDL_x11events.c | 26 +- src/video/x11/SDL_x11opengl.c | 11 +- src/video/x11/SDL_x11render.c | 44 +- src/video/x11/SDL_x11window.c | 50 +- src/video/x11/SDL_x11window.h | 4 +- test/automated/render/render.c | 36 +- test/common.c | 2 +- test/common.h | 2 +- test/testdraw2.c | 8 +- test/testintersections.c | 12 +- test/testnative.c | 12 +- test/testsprite2.c | 8 +- test/testspriteminimal.c | 6 +- 73 files changed, 849 insertions(+), 1063 deletions(-) diff --git a/README.iphoneos b/README.iphoneos index 6bf9715e3..e05c28ad7 100644 --- a/README.iphoneos +++ b/README.iphoneos @@ -67,13 +67,13 @@ Notes -- Keyboard SDL for iPhone contains several additional functions related to keyboard visibility. These functions are not part of the SDL standard API, but are necessary for revealing and hiding the iPhone's virtual onscreen keyboard. You can use them in your own applications by including a copy of the SDL_uikitkeyboard.h header (located in src/video/uikit) in your project. -int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) +int SDL_iPhoneKeyboardShow(SDL_Window * window) -- reveals the onscreen keyboard. Returns 0 on success and -1 on error. -int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) +int SDL_iPhoneKeyboardHide(SDL_Window * window) -- hides the onscreen keyboard. Returns 0 on success and -1 on error. -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) -- returns whether or not the onscreen keyboard is currently visible. -int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) +int SDL_iPhoneKeyboardToggle(SDL_Window * window) -- toggles the visibility of the onscreen keyboard. Returns 0 on success and -1 on error. ============================================================================== diff --git a/Xcode-iPhoneOS/Demos/src/accelerometer.c b/Xcode-iPhoneOS/Demos/src/accelerometer.c index 7d980263a..ccdcd2c21 100644 --- a/Xcode-iPhoneOS/Demos/src/accelerometer.c +++ b/Xcode-iPhoneOS/Demos/src/accelerometer.c @@ -27,8 +27,8 @@ static struct SDL_Rect rect; /* (drawn) position and size of ship */ } ship; -static SDL_TextureID shipID = 0; /* texture for spaceship */ -static SDL_TextureID spaceID = 0; /* texture for space (background */ +static SDL_Texture *ship = 0; /* texture for spaceship */ +static SDL_Texture *space = 0; /* texture for space (background */ void render(void) @@ -97,13 +97,13 @@ render(void) } /* draw the background */ - SDL_RenderCopy(spaceID, NULL, NULL); + SDL_RenderCopy(space, NULL, NULL); /* draw the ship */ ship.rect.x = ship.x; ship.rect.y = ship.y; - SDL_RenderCopy(shipID, NULL, &ship.rect); + SDL_RenderCopy(ship, NULL, &ship.rect); /* update screen */ SDL_RenderPresent(); @@ -141,11 +141,11 @@ initializeTextures() SDL_BlitSurface(bmp_surface, NULL, bmp_surface_rgba, NULL); /* create ship texture from surface */ - shipID = SDL_CreateTextureFromSurface(format, bmp_surface_rgba); - if (shipID == 0) { + ship = SDL_CreateTextureFromSurface(format, bmp_surface_rgba); + if (ship == 0) { fatalError("could not create ship texture"); } - SDL_SetTextureBlendMode(shipID, SDL_BLENDMODE_BLEND); + SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND); /* set the width and height of the ship from the surface dimensions */ ship.rect.w = bmp_surface->w; @@ -160,8 +160,8 @@ initializeTextures() fatalError("could not load space.bmp"); } /* create space texture from surface */ - spaceID = SDL_CreateTextureFromSurface(format, bmp_surface); - if (spaceID == 0) { + space = SDL_CreateTextureFromSurface(format, bmp_surface); + if (space == 0) { fatalError("could not create space texture"); } SDL_FreeSurface(bmp_surface); @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) { - SDL_WindowID windowID; /* ID of main window */ + SDL_Window *window; /* main window */ Uint32 startFrame; /* time frame began to process */ Uint32 endFrame; /* time frame ended processing */ Uint32 delay; /* time to pause waiting to draw next frame */ @@ -186,10 +186,10 @@ main(int argc, char *argv[]) } /* create main window and renderer */ - windowID = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, + window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); - SDL_CreateRenderer(windowID, 0, 0); + SDL_CreateRenderer(window, 0, 0); /* print out some info about joysticks and try to open accelerometer for use */ printf("There are %d joysticks available\n", SDL_NumJoysticks()); @@ -240,8 +240,8 @@ main(int argc, char *argv[]) } /* delete textures */ - SDL_DestroyTexture(shipID); - SDL_DestroyTexture(spaceID); + SDL_DestroyTexture(ship); + SDL_DestroyTexture(space); /* shutdown SDL */ SDL_Quit(); diff --git a/Xcode-iPhoneOS/Demos/src/fireworks.c b/Xcode-iPhoneOS/Demos/src/fireworks.c index e069ee4c4..1b9378cb1 100644 --- a/Xcode-iPhoneOS/Demos/src/fireworks.c +++ b/Xcode-iPhoneOS/Demos/src/fireworks.c @@ -363,8 +363,7 @@ initializeTexture() int main(int argc, char *argv[]) { - - SDL_WindowID windowID; /* ID of main window */ + SDL_Window *window; /* main window */ Uint32 startFrame; /* time frame began to process */ Uint32 endFrame; /* time frame ended processing */ Uint32 delay; /* time to pause waiting to draw next frame */ @@ -389,10 +388,10 @@ main(int argc, char *argv[]) SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); /* create main window and renderer */ - windowID = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, + window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); - SDL_CreateRenderer(windowID, 0, 0); + SDL_CreateRenderer(window, 0, 0); /* load the particle texture */ initializeTexture(); diff --git a/Xcode-iPhoneOS/Demos/src/happy.c b/Xcode-iPhoneOS/Demos/src/happy.c index a77629147..487b4c3c5 100644 --- a/Xcode-iPhoneOS/Demos/src/happy.c +++ b/Xcode-iPhoneOS/Demos/src/happy.c @@ -11,7 +11,7 @@ #define MILLESECONDS_PER_FRAME 16 /* about 60 frames per second */ #define HAPPY_FACE_SIZE 32 /* width and height of happyface (pixels) */ -static SDL_TextureID texture_id = 0; /* reference to texture holding happyface */ +static SDL_Texture *texture = 0; /* reference to texture holding happyface */ static struct { @@ -86,7 +86,7 @@ render(void) } dstRect.x = faces[i].x; dstRect.y = faces[i].y; - SDL_RenderCopy(texture_id, &srcRect, &dstRect); + SDL_RenderCopy(texture, &srcRect, &dstRect); } /* update screen */ SDL_RenderPresent(); @@ -124,11 +124,11 @@ initializeTexture() SDL_BlitSurface(bmp_surface, NULL, bmp_surface_rgba, NULL); /* convert RGBA surface to texture */ - texture_id = SDL_CreateTextureFromSurface(format, bmp_surface_rgba); - if (texture_id == 0) { + texture = SDL_CreateTextureFromSurface(format, bmp_surface_rgba); + if (texture == 0) { fatalError("could not create texture"); } - SDL_SetTextureBlendMode(texture_id, SDL_BLENDMODE_BLEND); + SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); /* free up allocated memory */ SDL_FreeSurface(bmp_surface_rgba); @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) { - SDL_WindowID windowID; + SDL_Window *window; Uint32 startFrame; Uint32 endFrame; Uint32 delay; @@ -149,11 +149,11 @@ main(int argc, char *argv[]) if (SDL_Init(SDL_INIT_VIDEO) < 0) { fatalError("Could not initialize SDL"); } - windowID = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, + window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); - SDL_CreateRenderer(windowID, -1, 0); + SDL_CreateRenderer(window, -1, 0); initializeTexture(); initializeHappyFaces(); @@ -182,7 +182,7 @@ main(int argc, char *argv[]) } /* cleanup */ - SDL_DestroyTexture(texture_id); + SDL_DestroyTexture(texture); /* shutdown SDL */ SDL_Quit(); diff --git a/Xcode-iPhoneOS/Demos/src/keyboard.c b/Xcode-iPhoneOS/Demos/src/keyboard.c index f89544cb5..ccbc25473 100644 --- a/Xcode-iPhoneOS/Demos/src/keyboard.c +++ b/Xcode-iPhoneOS/Demos/src/keyboard.c @@ -10,14 +10,14 @@ #define GLYPH_SIZE_IMAGE 16 /* size of glyphs (characters) in the bitmap font file */ #define GLYPH_SIZE_SCREEN 32 /* size of glyphs (characters) as shown on the screen */ -static SDL_TextureID textureID; /* texture where we'll hold our font */ +static SDL_Texture *texture; /* texture where we'll hold our font */ /* iPhone SDL addition keyboard related function definitions */ -extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_WindowID windowID); -extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_WindowID windowID); -extern DECLSPEC SDL_bool SDLCALL SDL_iPhoneKeyboardIsShown(SDL_WindowID - windowID); -extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_WindowID windowID); +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_Window * window); +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_Window * window); +extern DECLSPEC SDL_bool SDLCALL SDL_iPhoneKeyboardIsShown(SDL_Window * + window); +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_Window * window); /* function declarations */ void cleanup(void); @@ -157,7 +157,7 @@ drawIndex(int index) { GLYPH_SIZE_IMAGE * index, 0, GLYPH_SIZE_IMAGE, GLYPH_SIZE_IMAGE }; SDL_Rect dstRect = { x, y, GLYPH_SIZE_SCREEN, GLYPH_SIZE_SCREEN }; drawBlank(x, y); - SDL_RenderCopy(textureID, &srcRect, &dstRect); + SDL_RenderCopy(texture, &srcRect, &dstRect); } /* draws the cursor icon at the current end position of the text */ @@ -194,8 +194,8 @@ backspace(void) } } -/* this function loads our font into an SDL_Texture and returns the SDL_TextureID */ -SDL_TextureID +/* this function loads our font into an SDL_Texture and returns the SDL_Texture */ +SDL_Texture* loadFont(void) { @@ -218,17 +218,17 @@ loadFont(void) Bmask, Amask); SDL_BlitSurface(surface, NULL, converted, NULL); /* create our texture */ - textureID = + texture = SDL_CreateTextureFromSurface(SDL_PIXELFORMAT_ABGR8888, converted); - if (textureID == 0) { + if (texture == 0) { printf("texture creation failed: %s\n", SDL_GetError()); } else { /* set blend mode for our texture */ - SDL_SetTextureBlendMode(textureID, SDL_BLENDMODE_BLEND); + SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); } SDL_FreeSurface(surface); SDL_FreeSurface(converted); - return textureID; + return texture; } } @@ -237,6 +237,7 @@ main(int argc, char *argv[]) { int index; /* index of last key we pushed in the bitmap font */ + SDL_Window *window; SDL_Event event; /* last event received */ SDLMod mod; /* key modifiers of last key we pushed */ SDL_scancode scancode; /* scancode of last key we pushed */ @@ -245,11 +246,9 @@ main(int argc, char *argv[]) printf("Error initializing SDL: %s", SDL_GetError()); } /* create window */ - SDL_WindowID windowID = - SDL_CreateWindow("iPhone keyboard test", 0, 0, SCREEN_WIDTH, - SCREEN_HEIGHT, 0); + window = SDL_CreateWindow("iPhone keyboard test", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0); /* create renderer */ - SDL_CreateRenderer(windowID, 0, 0); + SDL_CreateRenderer(window, 0, 0); /* load up our font */ loadFont(); @@ -301,7 +300,7 @@ main(int argc, char *argv[]) /* mouse up toggles onscreen keyboard visibility this function is available ONLY on iPhone OS */ - SDL_iPhoneKeyboardToggle(windowID); + SDL_iPhoneKeyboardToggle(window); break; #endif } @@ -314,6 +313,6 @@ main(int argc, char *argv[]) void cleanup(void) { - SDL_DestroyTexture(textureID); + SDL_DestroyTexture(texture); SDL_Quit(); } diff --git a/Xcode-iPhoneOS/Demos/src/mixer.c b/Xcode-iPhoneOS/Demos/src/mixer.c index 2a49d4006..a8a25203f 100644 --- a/Xcode-iPhoneOS/Demos/src/mixer.c +++ b/Xcode-iPhoneOS/Demos/src/mixer.c @@ -274,7 +274,7 @@ main(int argc, char *argv[]) { int done; /* has user tried to quit ? */ - SDL_WindowID windowID; /* our main window */ + SDL_Window *window; /* main window */ SDL_Event event; Uint32 startFrame; /* holds when frame started processing */ Uint32 endFrame; /* holds when frame ended processing */ @@ -283,10 +283,10 @@ main(int argc, char *argv[]) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { fatalError("could not initialize SDL"); } - windowID = + window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS); - SDL_CreateRenderer(windowID, 0, 0); + SDL_CreateRenderer(window, 0, 0); /* initialize the mixer */ SDL_memset(&mixer, 0, sizeof(mixer)); diff --git a/Xcode-iPhoneOS/Demos/src/rectangles.c b/Xcode-iPhoneOS/Demos/src/rectangles.c index 8ded25294..e67d8c8aa 100644 --- a/Xcode-iPhoneOS/Demos/src/rectangles.c +++ b/Xcode-iPhoneOS/Demos/src/rectangles.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) { - SDL_WindowID windowID; + SDL_Window *window; int done; SDL_Event event; @@ -51,13 +51,13 @@ main(int argc, char *argv[]) srand(time(NULL)); /* create window and renderer */ - windowID = + window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN); - if (windowID == 0) { + if (window == 0) { fatalError("Could not initialize Window"); } - if (SDL_CreateRenderer(windowID, -1, 0) != 0) { + if (SDL_CreateRenderer(window, -1, 0) != 0) { fatalError("Could not create renderer"); } diff --git a/Xcode-iPhoneOS/Demos/src/touch.c b/Xcode-iPhoneOS/Demos/src/touch.c index 1103b84f9..b171415d0 100644 --- a/Xcode-iPhoneOS/Demos/src/touch.c +++ b/Xcode-iPhoneOS/Demos/src/touch.c @@ -11,7 +11,7 @@ #define BRUSH_SIZE 32 /* width and height of the brush */ #define PIXELS_PER_ITERATION 5 /* number of pixels between brush blots when forming a line */ -static SDL_TextureID brushID = 0; /* texture for the brush */ +static SDL_Texture *brush = 0; /* texture for the brush */ /* draws a line from (startx, starty) to (startx + dx, starty + dy) @@ -43,7 +43,7 @@ drawLine(float startx, float starty, float dx, float dy) x += dx_prime; y += dy_prime; /* draw brush blot */ - SDL_RenderCopy(brushID, NULL, &dstRect); + SDL_RenderCopy(brush, NULL, &dstRect); } } @@ -58,16 +58,16 @@ initializeTexture() if (bmp_surface == NULL) { fatalError("could not load stroke.bmp"); } - brushID = + brush = SDL_CreateTextureFromSurface(SDL_PIXELFORMAT_ABGR8888, bmp_surface); SDL_FreeSurface(bmp_surface); - if (brushID == 0) { + if (brush == 0) { fatalError("could not create brush texture"); } /* additive blending -- laying strokes on top of eachother makes them brighter */ - SDL_SetTextureBlendMode(brushID, SDL_BLENDMODE_ADD); + SDL_SetTextureBlendMode(brush, SDL_BLENDMODE_ADD); /* set brush color (red) */ - SDL_SetTextureColorMod(brushID, 255, 100, 100); + SDL_SetTextureColorMod(brush, 255, 100, 100); } int @@ -77,7 +77,7 @@ main(int argc, char *argv[]) int x, y, dx, dy; /* mouse location */ Uint8 state; /* mouse (touch) state */ SDL_Event event; - SDL_WindowID windowID; /* main window */ + SDL_Window *window; /* main window */ int done; /* does user want to quit? */ /* initialize SDL */ @@ -86,10 +86,10 @@ main(int argc, char *argv[]) } /* create main window and renderer */ - windowID = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, + window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); - SDL_CreateRenderer(windowID, 0, 0); + SDL_CreateRenderer(window, 0, 0); /*load brush texture */ initializeTexture(); @@ -118,7 +118,7 @@ main(int argc, char *argv[]) } /* cleanup */ - SDL_DestroyTexture(brushID); + SDL_DestroyTexture(brush); SDL_Quit(); return 0; diff --git a/include/SDL_compat.h b/include/SDL_compat.h index e77808d64..a4c9b80dd 100644 --- a/include/SDL_compat.h +++ b/include/SDL_compat.h @@ -295,6 +295,8 @@ extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); +#define SDL_TextureID SDL_Texture* +#define SDL_WindowID SDL_Window* #define SDL_RenderPoint SDL_RenderDrawPoint #define SDL_RenderLine SDL_RenderDrawLine #define SDL_RenderFill(X) (X) ? SDL_RenderFillRect(X) : SDL_RenderClear() diff --git a/include/SDL_events.h b/include/SDL_events.h index f94bece80..c37702cb5 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -127,7 +127,7 @@ typedef enum typedef struct SDL_WindowEvent { Uint8 type; /**< ::SDL_WINDOWEVENT */ - SDL_WindowID windowID; /**< The associated window */ + Uint32 windowID; /**< The associated window */ Uint8 event; /**< ::SDL_WindowEventID */ int data1; /**< event dependent data */ int data2; /**< event dependent data */ @@ -139,7 +139,7 @@ typedef struct SDL_WindowEvent typedef struct SDL_KeyboardEvent { Uint8 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ - SDL_WindowID windowID; /**< The window with keyboard focus, if any */ + Uint32 windowID; /**< The window with keyboard focus, if any */ Uint8 which; /**< The keyboard device index */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ SDL_keysym keysym; /**< The key that was pressed or released */ @@ -165,7 +165,7 @@ typedef struct SDL_TextEditingEvent typedef struct SDL_TextInputEvent { Uint8 type; /**< ::SDL_TEXTINPUT */ - SDL_WindowID windowID; /**< The window with keyboard focus, if any */ + Uint32 windowID; /**< The window with keyboard focus, if any */ Uint8 which; /**< The keyboard device index */ char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ } SDL_TextInputEvent; @@ -176,7 +176,7 @@ typedef struct SDL_TextInputEvent typedef struct SDL_MouseMotionEvent { Uint8 type; /**< ::SDL_MOUSEMOTION */ - SDL_WindowID windowID; /**< The window with mouse focus, if any */ + Uint32 windowID; /**< The window with mouse focus, if any */ Uint8 which; /**< The mouse device index */ Uint8 state; /**< The current button state */ int x; /**< X coordinate, relative to window */ @@ -199,7 +199,7 @@ typedef struct SDL_MouseMotionEvent typedef struct SDL_MouseButtonEvent { Uint8 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ - SDL_WindowID windowID; /**< The window with mouse focus, if any */ + Uint32 windowID; /**< The window with mouse focus, if any */ Uint8 which; /**< The mouse device index */ Uint8 button; /**< The mouse button index */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ @@ -213,7 +213,7 @@ typedef struct SDL_MouseButtonEvent typedef struct SDL_MouseWheelEvent { Uint8 type; /**< ::SDL_MOUSEWHEEL */ - SDL_WindowID windowID; /**< The window with mouse focus, if any */ + Uint32 windowID; /**< The window with mouse focus, if any */ Uint8 which; /**< The mouse device index */ int x; /**< The amount scrolled horizontally */ int y; /**< The amount scrolled vertically */ @@ -284,7 +284,7 @@ typedef struct SDL_QuitEvent typedef struct SDL_UserEvent { Uint8 type; /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */ - SDL_WindowID windowID; /**< The associated window if any*/ + Uint32 windowID; /**< The associated window if any*/ int code; /**< User defined event code */ void *data1; /**< User defined data pointer */ void *data2; /**< User defined data pointer */ @@ -307,7 +307,7 @@ typedef struct SDL_SysWMEvent typedef struct SDL_ProximityEvent { Uint8 type; - SDL_WindowID windowID; /**< The associated window */ + Uint32 windowID; /**< The associated window */ Uint8 which; int cursor; int x; diff --git a/include/SDL_mouse.h b/include/SDL_mouse.h index 388de9cc2..1885c0352 100644 --- a/include/SDL_mouse.h +++ b/include/SDL_mouse.h @@ -75,7 +75,7 @@ extern DECLSPEC int SDLCALL SDL_SelectMouse(int index); /** * \brief Get the window which currently has focus for the specified mouse. */ -extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(int index); +extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocusWindow(int index); /** * \brief Set relative mouse mode for the specified mouse. @@ -126,13 +126,13 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int index, int *x, /** * \brief Moves the currently selected mouse to the given position within the window. * - * \param windowID The window to move the mouse into, or 0 for the current mouse focus + * \param window The window to move the mouse into, or NULL for the current mouse focus * \param x The x coordinate within the window * \param y The y coordinate within the window * * \note This function generates a mouse motion event */ -extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_WindowID windowID, +extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, int x, int y); /** diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index f6a251c33..a1e4ec17f 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -245,7 +245,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo; * if ( SDL_GetWindowWMInfo(&info) ) { ... } * \endcode */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_WindowID windowID, +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, SDL_SysWMinfo * info); diff --git a/include/SDL_video.h b/include/SDL_video.h index f9b39506d..8609a73ac 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -88,7 +88,8 @@ typedef struct * \sa SDL_SetWindowTitle() * \sa SDL_ShowWindow() */ -typedef Uint32 SDL_WindowID; +struct SDL_Window; +typedef struct SDL_Window SDL_Window; /** * \brief The flags on a window @@ -248,7 +249,8 @@ typedef enum /** * \brief An efficient driver-specific representation of pixel data */ -typedef Uint32 SDL_TextureID; +struct SDL_Texture; +typedef struct SDL_Texture SDL_Texture; /** * \brief An opaque handle to an OpenGL context. @@ -449,7 +451,7 @@ extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(const * \sa SDL_GetWindowDisplayMode() * \sa SDL_SetWindowFullscreen() */ -extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_WindowID windowID, +extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode); @@ -460,7 +462,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_WindowID windowID, * \sa SDL_SetWindowDisplayMode() * \sa SDL_SetWindowFullscreen() */ -extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_WindowID windowID, +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode); /** @@ -551,7 +553,7 @@ extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green, * * \sa SDL_DestroyWindow() */ -extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindow(const char *title, +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags); @@ -564,19 +566,29 @@ extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindow(const char *title, * * \sa SDL_DestroyWindow() */ -extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindowFrom(const void *data); +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data); + +/** + * \brief Get the numeric ID of the window, for logging purposes. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window); + +/** + * \brief Get a window from a stored ID, or NULL if it doesn't exist. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); /** * \brief Get the window flags. */ -extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_WindowID windowID); +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window); /** * \brief Set the title of the window, in UTF-8 format. * * \sa SDL_GetWindowTitle() */ -extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_WindowID windowID, +extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, const char *title); /** @@ -584,14 +596,14 @@ extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_WindowID windowID, * * \sa SDL_SetWindowTitle() */ -extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_WindowID windowID); +extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); /** * \brief Set the icon of the window. * * \param icon The icon for the window. */ -extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_WindowID windowID, +extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon); /** @@ -599,7 +611,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_WindowID windowID, * * \sa SDL_GetWindowData() */ -extern DECLSPEC void SDLCALL SDL_SetWindowData(SDL_WindowID windowID, +extern DECLSPEC void SDLCALL SDL_SetWindowData(SDL_Window * window, void *userdata); /** @@ -607,12 +619,12 @@ extern DECLSPEC void SDLCALL SDL_SetWindowData(SDL_WindowID windowID, * * \sa SDL_SetWindowData() */ -extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_WindowID windowID); +extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window); /** * \brief Set the position of the window. * - * \param windowID The window to reposition. + * \param window The window to reposition. * \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or ::SDL_WINDOWPOS_UNDEFINED. * \param y The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or @@ -622,7 +634,7 @@ extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_WindowID windowID); * * \sa SDL_GetWindowPosition() */ -extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_WindowID windowID, +extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, int x, int y); /** @@ -630,7 +642,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_WindowID windowID, * * \sa SDL_SetWindowPosition() */ -extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_WindowID windowID, +extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, int *x, int *y); /** @@ -641,7 +653,7 @@ extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_WindowID windowID, * * \sa SDL_GetWindowSize() */ -extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_WindowID windowID, int w, +extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, int h); /** @@ -649,7 +661,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_WindowID windowID, int w, * * \sa SDL_SetWindowSize() */ -extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_WindowID windowID, int *w, +extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, int *h); /** @@ -657,33 +669,33 @@ extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_WindowID windowID, int *w, * * \sa SDL_HideWindow() */ -extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window); /** * \brief Hide the window. * * \sa SDL_ShowWindow() */ -extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); /** * \brief Raise the window above other windows and set the input focus. */ -extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); /** * \brief Make the window as large as possible. * * \sa SDL_RestoreWindow() */ -extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window); /** * \brief Minimize the window to an iconic representation. * * \sa SDL_RestoreWindow() */ -extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window); /** * \brief Restore the size and position of a minimized or maximized window. @@ -691,7 +703,7 @@ extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_WindowID windowID); * \sa SDL_MaximizeWindow() * \sa SDL_MinimizeWindow() */ -extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); /** * \brief Set the window's fullscreen state. @@ -701,7 +713,7 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_WindowID windowID); * \sa SDL_SetWindowDisplayMode() * \sa SDL_GetWindowDisplayMode() */ -extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_WindowID windowID, +extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, int fullscreen); /** @@ -711,7 +723,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_WindowID windowID, * * \sa SDL_GetWindowGrab() */ -extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_WindowID windowID, +extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, int mode); /** @@ -721,7 +733,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_WindowID windowID, * * \sa SDL_SetWindowGrab() */ -extern DECLSPEC int SDLCALL SDL_GetWindowGrab(SDL_WindowID windowID); +extern DECLSPEC int SDLCALL SDL_GetWindowGrab(SDL_Window * window); /** * \brief Get driver specific information about a window. @@ -729,14 +741,14 @@ extern DECLSPEC int SDLCALL SDL_GetWindowGrab(SDL_WindowID windowID); * \note Include SDL_syswm.h for the declaration of SDL_SysWMinfo. */ struct SDL_SysWMinfo; -extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_WindowID windowID, +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, struct SDL_SysWMinfo *info); /** * \brief Destroy a window. */ -extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); /** * \brief Get the number of 2D rendering drivers available for the current @@ -769,7 +781,7 @@ extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, /** * \brief Create and make active a 2D rendering context for a window. * - * \param windowID The window where rendering is displayed. + * \param window The window where rendering is displayed. * \param index The index of the rendering driver to initialize, or -1 to * initialize the first one supporting the requested flags. * \param flags ::SDL_RendererFlags. @@ -780,7 +792,7 @@ extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, * \sa SDL_GetRendererInfo() * \sa SDL_DestroyRenderer() */ -extern DECLSPEC int SDLCALL SDL_CreateRenderer(SDL_WindowID windowID, +extern DECLSPEC int SDLCALL SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags); /** @@ -789,7 +801,7 @@ extern DECLSPEC int SDLCALL SDL_CreateRenderer(SDL_WindowID windowID, * \return 0 on success, -1 if the selected window doesn't have a * rendering context. */ -extern DECLSPEC int SDLCALL SDL_SelectRenderer(SDL_WindowID windowID); +extern DECLSPEC int SDLCALL SDL_SelectRenderer(SDL_Window * window); /** * \brief Get information about the current rendering context. @@ -811,7 +823,7 @@ extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_RendererInfo * info); * \sa SDL_QueryTexture() * \sa SDL_DestroyTexture() */ -extern DECLSPEC SDL_TextureID SDLCALL SDL_CreateTexture(Uint32 format, +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(Uint32 format, int access, int w, int h); @@ -830,7 +842,7 @@ extern DECLSPEC SDL_TextureID SDLCALL SDL_CreateTexture(Uint32 format, * \sa SDL_QueryTexture() * \sa SDL_DestroyTexture() */ -extern DECLSPEC SDL_TextureID SDLCALL SDL_CreateTextureFromSurface(Uint32 +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface); @@ -838,7 +850,7 @@ extern DECLSPEC SDL_TextureID SDLCALL SDL_CreateTextureFromSurface(Uint32 /** * \brief Query the attributes of a texture * - * \param textureID A texture to be queried. + * \param texture A texture to be queried. * \param format A pointer filled in with the raw format of the texture. The * actual format may differ, but pixel transfers will use this * format. @@ -848,7 +860,7 @@ extern DECLSPEC SDL_TextureID SDLCALL SDL_CreateTextureFromSurface(Uint32 * * \return 0 on success, or -1 if the texture is not valid. */ -extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access, int *w, int *h); @@ -856,7 +868,7 @@ extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_TextureID textureID, * \brief Query the pixels of a texture, if the texture does not need to be * locked for pixel access. * - * \param textureID A texture to be queried, which was created with + * \param texture A texture to be queried, which was created with * ::SDL_TEXTUREACCESS_STREAMING. * \param pixels A pointer filled with a pointer to the pixels for the * texture. @@ -865,13 +877,13 @@ extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_TextureID textureID, * \return 0 on success, or -1 if the texture is not valid, or must be locked * for pixel access. */ -extern DECLSPEC int SDLCALL SDL_QueryTexturePixels(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_QueryTexturePixels(SDL_Texture * texture, void **pixels, int *pitch); /** * \brief Set the color palette of an indexed texture. * - * \param textureID The texture to update. + * \param texture The texture to update. * \param colors The array of RGB color data. * \param firstcolor The first index to update. * \param ncolors The number of palette entries to fill with the color data. @@ -879,7 +891,7 @@ extern DECLSPEC int SDLCALL SDL_QueryTexturePixels(SDL_TextureID textureID, * \return 0 on success, or -1 if the texture is not valid or not an indexed * texture. */ -extern DECLSPEC int SDLCALL SDL_SetTexturePalette(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_SetTexturePalette(SDL_Texture * texture, const SDL_Color * colors, int firstcolor, int ncolors); @@ -887,7 +899,7 @@ extern DECLSPEC int SDLCALL SDL_SetTexturePalette(SDL_TextureID textureID, /** * \brief Get the color palette from an indexed texture if it has one. * - * \param textureID The texture to update. + * \param texture The texture to update. * \param colors The array to fill with RGB color data. * \param firstcolor The first index to retrieve. * \param ncolors The number of palette entries to retrieve. @@ -895,7 +907,7 @@ extern DECLSPEC int SDLCALL SDL_SetTexturePalette(SDL_TextureID textureID, * \return 0 on success, or -1 if the texture is not valid or not an indexed * texture. */ -extern DECLSPEC int SDLCALL SDL_GetTexturePalette(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_GetTexturePalette(SDL_Texture * texture, SDL_Color * colors, int firstcolor, int ncolors); @@ -903,7 +915,7 @@ extern DECLSPEC int SDLCALL SDL_GetTexturePalette(SDL_TextureID textureID, /** * \brief Set an additional color value used in render copy operations. * - * \param textureID The texture to update. + * \param texture The texture to update. * \param r The red source color value multiplied into copy operations. * \param g The green source color value multiplied into copy operations. * \param b The blue source color value multiplied into copy operations. @@ -913,14 +925,14 @@ extern DECLSPEC int SDLCALL SDL_GetTexturePalette(SDL_TextureID textureID, * * \sa SDL_GetTextureColorMod() */ -extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b); /** * \brief Get the additional color value used in render copy operations. * - * \param textureID The texture to query. + * \param texture The texture to query. * \param r A pointer filled in with the source red color value. * \param g A pointer filled in with the source green color value. * \param b A pointer filled in with the source blue color value. @@ -929,14 +941,14 @@ extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_TextureID textureID, * * \sa SDL_SetTextureColorMod() */ -extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, Uint8 * b); /** * \brief Set an additional alpha value used in render copy operations. * - * \param textureID The texture to update. + * \param texture The texture to update. * \param alpha The source alpha value multiplied into copy operations. * * \return 0 on success, or -1 if the texture is not valid or alpha modulation @@ -944,26 +956,26 @@ extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_TextureID textureID, * * \sa SDL_GetTextureAlphaMod() */ -extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha); /** * \brief Get the additional alpha value used in render copy operations. * - * \param textureID The texture to query. + * \param texture The texture to query. * \param alpha A pointer filled in with the source alpha value. * * \return 0 on success, or -1 if the texture is not valid. * * \sa SDL_SetTextureAlphaMod() */ -extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha); /** * \brief Set the blend mode used for texture copy operations. * - * \param textureID The texture to update. + * \param texture The texture to update. * \param blendMode ::SDL_BlendMode to use for texture blending. * * \return 0 on success, or -1 if the texture is not valid or the blend mode is @@ -974,26 +986,26 @@ extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_TextureID textureID, * * \sa SDL_GetTextureBlendMode() */ -extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, int blendMode); /** * \brief Get the blend mode used for texture copy operations. * - * \param textureID The texture to query. + * \param texture The texture to query. * \param blendMode A pointer filled in with the current blend mode. * * \return 0 on success, or -1 if the texture is not valid. * * \sa SDL_SetTextureBlendMode() */ -extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, int *blendMode); /** * \brief Set the scale mode used for texture copy operations. * - * \param textureID The texture to update. + * \param texture The texture to update. * \param scaleMode ::SDL_TextureScaleMode to use for texture scaling. * * \return 0 on success, or -1 if the texture is not valid or the scale mode is @@ -1004,26 +1016,26 @@ extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_TextureID textureID, * * \sa SDL_GetTextureScaleMode() */ -extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture, int scaleMode); /** * \brief Get the scale mode used for texture copy operations. * - * \param textureID The texture to query. + * \param texture The texture to query. * \param scaleMode A pointer filled in with the current scale mode. * * \return 0 on success, or -1 if the texture is not valid. * * \sa SDL_SetTextureScaleMode() */ -extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture, int *scaleMode); /** * \brief Update the given texture rectangle with new pixel data. * - * \param textureID The texture to update + * \param texture The texture to update * \param rect A pointer to the rectangle of pixels to update, or NULL to * update the entire texture. * \param pixels The raw pixel data. @@ -1033,14 +1045,14 @@ extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_TextureID textureID, * * \note This is a fairly slow function. */ -extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); /** * \brief Lock a portion of the texture for pixel access. * - * \param textureID The texture to lock for access, which was created with + * \param texture The texture to lock for access, which was created with * ::SDL_TEXTUREACCESS_STREAMING. * \param rect A pointer to the rectangle to lock for access. If the rect * is NULL, the entire texture will be locked. @@ -1056,7 +1068,7 @@ extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_TextureID textureID, * \sa SDL_DirtyTexture() * \sa SDL_UnlockTexture() */ -extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, int markDirty, void **pixels, int *pitch); @@ -1067,12 +1079,12 @@ extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_TextureID textureID, * \sa SDL_LockTexture() * \sa SDL_DirtyTexture() */ -extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_TextureID textureID); +extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); /** * \brief Mark the specified rectangles of the texture as dirty. * - * \param textureID The texture to mark dirty, which was created with + * \param texture The texture to mark dirty, which was created with * ::SDL_TEXTUREACCESS_STREAMING. * \param numrects The number of rectangles pointed to by rects. * \param rects The pointer to an array of dirty rectangles. @@ -1080,7 +1092,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_TextureID textureID); * \sa SDL_LockTexture() * \sa SDL_UnlockTexture() */ -extern DECLSPEC void SDLCALL SDL_DirtyTexture(SDL_TextureID textureID, +extern DECLSPEC void SDLCALL SDL_DirtyTexture(SDL_Texture * texture, int numrects, const SDL_Rect * rects); @@ -1228,7 +1240,7 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRects(const SDL_Rect ** rect, int coun /** * \brief Copy a portion of the texture to the current rendering target. * - * \param textureID The source texture. + * \param texture The source texture. * \param srcrect A pointer to the source rectangle, or NULL for the entire * texture. * \param dstrect A pointer to the destination rectangle, or NULL for the @@ -1237,7 +1249,7 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRects(const SDL_Rect ** rect, int coun * \return 0 on success, or -1 if there is no rendering context current, or the * driver doesn't support the requested operation. */ -extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_TextureID textureID, +extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect); @@ -1289,7 +1301,7 @@ extern DECLSPEC void SDLCALL SDL_RenderPresent(void); * \sa SDL_CreateTexture() * \sa SDL_CreateTextureFromSurface() */ -extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_TextureID textureID); +extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); /** * \brief Destroy the rendering context for a window and free associated @@ -1297,7 +1309,7 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_TextureID textureID); * * \sa SDL_CreateRenderer() */ -extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Window * window); /** * \brief Returns whether the screensaver is currently enabled (default off). @@ -1384,15 +1396,15 @@ extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); * * \sa SDL_GL_DeleteContext() */ -extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_WindowID - windowID); +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * + window); /** * \brief Set up an OpenGL context for rendering into an OpenGL window. * * \note The context must have been created with a compatible window. */ -extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_WindowID windowID, +extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext context); /** @@ -1422,7 +1434,7 @@ extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void); * \brief Swap the OpenGL buffers for the window, if double-buffering is * supported. */ -extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); /** * \brief Delete an OpenGL context. diff --git a/src/SDL_assert.c b/src/SDL_assert.c index b46b0b756..5967ceaf7 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -265,7 +265,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) { const char *envr; SDL_assert_state state = SDL_ASSERTION_ABORT; - SDL_WindowID window; + SDL_Window *window; (void) userdata; /* unused in default handler. */ diff --git a/src/SDL_compat.c b/src/SDL_compat.c index 5d0165c8f..3ab86a121 100644 --- a/src/SDL_compat.c +++ b/src/SDL_compat.c @@ -30,9 +30,9 @@ #include "video/SDL_pixels_c.h" #include "video/SDL_yuv_sw_c.h" -static SDL_WindowID SDL_VideoWindow = 0; +static SDL_Window *SDL_VideoWindow = NULL; static SDL_RendererInfo SDL_VideoRendererInfo; -static SDL_TextureID SDL_VideoTexture = 0; +static SDL_Texture *SDL_VideoTexture = NULL; static SDL_Surface *SDL_VideoSurface = NULL; static SDL_Surface *SDL_ShadowSurface = NULL; static SDL_Surface *SDL_PublicSurface = NULL; @@ -294,7 +294,7 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event) button = SDL_BUTTON_WHEELDOWN; } - fake.button.which = event->wheel.windowID; + fake.button.which = event->wheel.which; fake.button.button = button; fake.button.x = x; fake.button.y = y; @@ -357,7 +357,7 @@ GetEnvironmentWindowPosition(int w, int h, int *x, int *y) } static SDL_Surface * -CreateVideoSurface(SDL_TextureID textureID) +CreateVideoSurface(SDL_Texture * texture) { SDL_Surface *surface; Uint32 format; @@ -367,7 +367,7 @@ CreateVideoSurface(SDL_TextureID textureID) void *pixels; int pitch; - if (SDL_QueryTexture(textureID, &format, NULL, &w, &h) < 0) { + if (SDL_QueryTexture(texture, &format, NULL, &w, &h) < 0) { return NULL; } @@ -377,7 +377,7 @@ CreateVideoSurface(SDL_TextureID textureID) return NULL; } - if (SDL_QueryTexturePixels(textureID, &pixels, &pitch) == 0) { + if (SDL_QueryTexturePixels(texture, &pixels, &pitch) == 0) { surface = SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, Gmask, Bmask, Amask); @@ -1504,7 +1504,7 @@ struct private_yuvhwdata SDL_SW_YUVTexture *sw; - SDL_TextureID textureID; + SDL_Texture *texture; Uint32 texture_format; }; @@ -1585,9 +1585,9 @@ SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display) break; } - overlay->hwdata->textureID = + overlay->hwdata->texture = SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h); - if (overlay->hwdata->textureID) { + if (overlay->hwdata->texture) { overlay->hwdata->sw = NULL; } else { SDL_DisplayMode current_mode; @@ -1601,11 +1601,11 @@ SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display) /* Create a supported RGB format texture for display */ SDL_GetCurrentDisplayMode(¤t_mode); texture_format = current_mode.format; - overlay->hwdata->textureID = + overlay->hwdata->texture = SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h); } - if (!overlay->hwdata->textureID) { + if (!overlay->hwdata->texture) { SDL_FreeYUVOverlay(overlay); return NULL; } @@ -1631,7 +1631,7 @@ SDL_LockYUVOverlay(SDL_Overlay * overlay) } } else { if (SDL_LockTexture - (overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) + (overlay->hwdata->texture, NULL, 1, &pixels, &pitch) < 0) { return -1; } @@ -1666,7 +1666,7 @@ SDL_UnlockYUVOverlay(SDL_Overlay * overlay) void *pixels; int pitch; if (SDL_LockTexture - (overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) == 0) { + (overlay->hwdata->texture, NULL, 1, &pixels, &pitch) == 0) { SDL_Rect srcrect; srcrect.x = 0; @@ -1676,10 +1676,10 @@ SDL_UnlockYUVOverlay(SDL_Overlay * overlay) SDL_SW_CopyYUVToRGB(overlay->hwdata->sw, &srcrect, overlay->hwdata->texture_format, overlay->w, overlay->h, pixels, pitch); - SDL_UnlockTexture(overlay->hwdata->textureID); + SDL_UnlockTexture(overlay->hwdata->texture); } } else { - SDL_UnlockTexture(overlay->hwdata->textureID); + SDL_UnlockTexture(overlay->hwdata->texture); } } @@ -1690,7 +1690,7 @@ SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) SDL_SetError("Passed a NULL overlay or dstrect"); return -1; } - if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect) < 0) { + if (SDL_RenderCopy(overlay->hwdata->texture, NULL, dstrect) < 0) { return -1; } SDL_RenderPresent(); @@ -1704,8 +1704,8 @@ SDL_FreeYUVOverlay(SDL_Overlay * overlay) return; } if (overlay->hwdata) { - if (overlay->hwdata->textureID) { - SDL_DestroyTexture(overlay->hwdata->textureID); + if (overlay->hwdata->texture) { + SDL_DestroyTexture(overlay->hwdata->texture); } SDL_free(overlay->hwdata); } diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 5a50cd9e3..4b92c971b 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -646,7 +646,7 @@ SDL_SetScancodeName(SDL_scancode scancode, const char *name) } void -SDL_SetKeyboardFocus(int index, SDL_WindowID windowID) +SDL_SetKeyboardFocus(int index, SDL_Window * window) { SDL_Keyboard *keyboard = SDL_GetKeyboard(index); int i; @@ -657,7 +657,7 @@ SDL_SetKeyboardFocus(int index, SDL_WindowID windowID) } /* See if the current window has lost focus */ - if (keyboard->focus && keyboard->focus != windowID) { + if (keyboard->focus && keyboard->focus != window) { focus = SDL_FALSE; for (i = 0; i < SDL_num_keyboards; ++i) { if (i != index) { @@ -674,7 +674,7 @@ SDL_SetKeyboardFocus(int index, SDL_WindowID windowID) } } - keyboard->focus = windowID; + keyboard->focus = window; if (keyboard->focus) { SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED, @@ -809,7 +809,7 @@ SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode) event.key.keysym.sym = keyboard->keymap[scancode]; event.key.keysym.mod = modstate; event.key.keysym.unicode = 0; - event.key.windowID = keyboard->focus; + event.key.windowID = keyboard->focus->id; posted = (SDL_PushEvent(&event) > 0); } return (posted); @@ -832,7 +832,7 @@ SDL_SendKeyboardText(int index, const char *text) event.text.type = SDL_TEXTINPUT; event.text.which = (Uint8) index; SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text)); - event.text.windowID = keyboard->focus; + event.text.windowID = keyboard->focus->id; posted = (SDL_PushEvent(&event) > 0); } return (posted); diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h index a067494ef..9f13c2460 100644 --- a/src/events/SDL_keyboard_c.h +++ b/src/events/SDL_keyboard_c.h @@ -35,7 +35,7 @@ struct SDL_Keyboard void (*FreeKeyboard) (SDL_Keyboard * keyboard); /* Data common to all keyboards */ - SDL_WindowID focus; + SDL_Window *focus; Uint16 modstate; Uint8 keystate[SDL_NUM_SCANCODES]; SDLKey keymap[SDL_NUM_SCANCODES]; @@ -73,7 +73,7 @@ extern void SDL_SetKeymap(int index, int start, SDLKey * keys, int length); extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name); /* Set the keyboard focus window */ -extern void SDL_SetKeyboardFocus(int index, SDL_WindowID windowID); +extern void SDL_SetKeyboardFocus(int index, SDL_Window * window); /* Send a keyboard event for a keyboard at an index */ extern int SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode); diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 13ef7cadc..5fdfee7b6 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -26,6 +26,7 @@ #include "SDL_events.h" #include "SDL_events_c.h" #include "default_cursor.h" +#include "../video/SDL_sysvideo.h" static int SDL_num_mice = 0; @@ -190,7 +191,7 @@ SDL_SelectMouse(int index) return SDL_current_mouse; } -SDL_WindowID +SDL_Window * SDL_GetMouseFocusWindow(int index) { SDL_Mouse *mouse = SDL_GetMouse(index); @@ -302,14 +303,14 @@ SDL_GetRelativeMouseState(int index, int *x, int *y) } void -SDL_SetMouseFocus(int id, SDL_WindowID windowID) +SDL_SetMouseFocus(int id, SDL_Window * window) { int index = SDL_GetMouseIndexId(id); SDL_Mouse *mouse = SDL_GetMouse(index); int i; SDL_bool focus; - if (!mouse || (mouse->focus == windowID)) { + if (!mouse || (mouse->focus == window)) { return; } @@ -331,7 +332,7 @@ SDL_SetMouseFocus(int id, SDL_WindowID windowID) } } - mouse->focus = windowID; + mouse->focus = window; if (mouse->focus) { focus = SDL_FALSE; @@ -372,7 +373,7 @@ SDL_SendProximity(int id, int x, int y, int type) event.proximity.cursor = mouse->current_end; event.proximity.type = type; /* FIXME: is this right? */ - event.proximity.windowID = mouse->focus; + event.proximity.windowID = mouse->focus->id; posted = (SDL_PushEvent(&event) > 0); if (type == SDL_PROXIMITYIN) { mouse->proximity = SDL_TRUE; @@ -478,7 +479,7 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure) event.motion.cursor = mouse->current_end; event.motion.xrel = xrel; event.motion.yrel = yrel; - event.motion.windowID = mouse->focus; + event.motion.windowID = mouse->focus->id; posted = (SDL_PushEvent(&event) > 0); } mouse->last_x = mouse->x; @@ -531,7 +532,7 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button) event.button.button = button; event.button.x = mouse->x; event.button.y = mouse->y; - event.button.windowID = mouse->focus; + event.button.windowID = mouse->focus->id; posted = (SDL_PushEvent(&event) > 0); } return posted; @@ -555,14 +556,14 @@ SDL_SendMouseWheel(int index, int x, int y) event.wheel.which = (Uint8) index; event.wheel.x = x; event.wheel.y = y; - event.wheel.windowID = mouse->focus; + event.wheel.windowID = mouse->focus->id; posted = (SDL_PushEvent(&event) > 0); } return posted; } void -SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y) +SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); @@ -571,9 +572,9 @@ SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y) } if (mouse->WarpMouse) { - mouse->WarpMouse(mouse, windowID, x, y); + mouse->WarpMouse(mouse, window, x, y); } else { - SDL_SetMouseFocus(SDL_current_mouse, windowID); + SDL_SetMouseFocus(SDL_current_mouse, window); SDL_SendMouseMotion(SDL_current_mouse, 0, x, y, 0); } } diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 7ae752eaf..89d276388 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -48,7 +48,7 @@ struct SDL_Mouse void (*FreeCursor) (SDL_Cursor * cursor); /* Warp the mouse to (x,y) */ - void (*WarpMouse) (SDL_Mouse * mouse, SDL_WindowID windowID, int x, + void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x, int y); /* Free the mouse when it's time */ @@ -65,7 +65,7 @@ struct SDL_Mouse /* Data common to all mice */ int id; - SDL_WindowID focus; + SDL_Window *focus; int which; int x; int y; @@ -106,7 +106,7 @@ extern void SDL_DelMouse(int index); extern void SDL_ResetMouse(int index); /* Set the mouse focus window */ -extern void SDL_SetMouseFocus(int id, SDL_WindowID windowID); +extern void SDL_SetMouseFocus(int id, SDL_Window * window); /* Send a mouse motion event for a mouse */ extern int SDL_SendMouseMotion(int id, int relative, int x, int y, int z); diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index 2b9dc8ebd..4dbf79390 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -44,13 +44,11 @@ RemovePendingSizeEvents(void * userdata, SDL_Event *event) } int -SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1, +SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, int data2) { int posted; - SDL_Window *window; - window = SDL_GetWindowFromID(windowID); if (!window) { return 0; } @@ -152,7 +150,7 @@ SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1, event.window.event = windowevent; event.window.data1 = data1; event.window.data2 = data2; - event.window.windowID = windowID; + event.window.windowID = window->id; /* Fixes queue overflow with resize events that aren't processed */ if (windowevent == SDL_WINDOWEVENT_RESIZED) { diff --git a/src/events/SDL_windowevents_c.h b/src/events/SDL_windowevents_c.h index eaaec03ad..b0fce274e 100644 --- a/src/events/SDL_windowevents_c.h +++ b/src/events/SDL_windowevents_c.h @@ -24,7 +24,7 @@ #ifndef _SDL_windowevents_c_h #define _SDL_windowevents_c_h -extern int SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, +extern int SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, int data2); #endif /* _SDL_windowevents_c_h */ diff --git a/src/video/SDL_gamma.c b/src/video/SDL_gamma.c index c910fad9c..c257bddac 100644 --- a/src/video/SDL_gamma.c +++ b/src/video/SDL_gamma.c @@ -171,7 +171,7 @@ SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue) SDL_UninitializedVideo(); return -1; } - return SDL_SetGammaRampForDisplay(&SDL_CurrentDisplay, red, green, blue); + return SDL_SetGammaRampForDisplay(SDL_CurrentDisplay, red, green, blue); } int @@ -230,7 +230,7 @@ SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue) SDL_UninitializedVideo(); return -1; } - return SDL_GetGammaRampForDisplay(&SDL_CurrentDisplay, red, green, blue); + return SDL_GetGammaRampForDisplay(SDL_CurrentDisplay, red, green, blue); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_renderer_gl.c b/src/video/SDL_renderer_gl.c index ecafaf843..32088fd6f 100644 --- a/src/video/SDL_renderer_gl.c +++ b/src/video/SDL_renderer_gl.c @@ -321,7 +321,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = GL_DestroyTexture; renderer->DestroyRenderer = GL_DestroyRenderer; renderer->info = GL_RenderDriver.info; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; renderer->info.flags = @@ -332,12 +332,12 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) return NULL; } - data->context = SDL_GL_CreateContext(window->id); + data->context = SDL_GL_CreateContext(window); if (!data->context) { GL_DestroyRenderer(renderer); return NULL; } - if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { + if (SDL_GL_MakeCurrent(window, data->context) < 0) { GL_DestroyRenderer(renderer); return NULL; } @@ -442,9 +442,9 @@ static int GL_ActivateRenderer(SDL_Renderer * renderer) { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; - if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { + if (SDL_GL_MakeCurrent(window, data->context) < 0) { return -1; } if (data->updateSize) { @@ -752,7 +752,7 @@ static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; GL_TextureData *data; GLint internalFormat; GLenum format, type; @@ -1407,7 +1407,7 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 pixel_format, void * pixels, int pitch) { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; GLint internalFormat; GLenum format, type; Uint8 *src, *dst, *tmp; @@ -1454,7 +1454,7 @@ GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 pixel_format, const void * pixels, int pitch) { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; GLint internalFormat; GLenum format, type; Uint8 *src, *dst, *tmp; diff --git a/src/video/SDL_renderer_gles.c b/src/video/SDL_renderer_gles.c index a42829821..007bc864f 100644 --- a/src/video/SDL_renderer_gles.c +++ b/src/video/SDL_renderer_gles.c @@ -332,7 +332,7 @@ GLES_ActivateRenderer(SDL_Renderer * renderer) { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { return -1; @@ -872,7 +872,7 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, if (data->GL_OES_draw_texture_supported && data->useDrawTexture) { /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */ - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; GLint cropRect[4]; cropRect[0] = srcrect->x; cropRect[1] = srcrect->y + srcrect->h; diff --git a/src/video/SDL_renderer_sw.c b/src/video/SDL_renderer_sw.c index 4bd068ac2..ee8cf9d47 100644 --- a/src/video/SDL_renderer_sw.c +++ b/src/video/SDL_renderer_sw.c @@ -201,7 +201,7 @@ Setup_SoftwareRenderer(SDL_Renderer * renderer) SDL_Renderer * SW_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayMode *displayMode = &display->current_mode; SDL_Renderer *renderer; SW_RenderData *data; @@ -243,7 +243,7 @@ SW_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyRenderer = SW_DestroyRenderer; renderer->info.name = SW_RenderDriver.info.name; renderer->info.flags = 0; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; Setup_SoftwareRenderer(renderer); @@ -321,7 +321,7 @@ static int SW_ActivateRenderer(SDL_Renderer * renderer) { SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; int i, n; if (data->renderer && data->renderer->ActivateRenderer) { @@ -794,7 +794,7 @@ SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect) { SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; int status; if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { @@ -928,8 +928,8 @@ static void SW_DestroyRenderer(SDL_Renderer * renderer) { SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; int i; if (data) { diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index a15cd4df6..8348023d6 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -29,8 +29,6 @@ /* The SDL video driver */ -typedef struct SDL_Window SDL_Window; -typedef struct SDL_Texture SDL_Texture; typedef struct SDL_Renderer SDL_Renderer; typedef struct SDL_RenderDriver SDL_RenderDriver; typedef struct SDL_VideoDisplay SDL_VideoDisplay; @@ -39,21 +37,20 @@ typedef struct SDL_VideoDevice SDL_VideoDevice; /* Define the SDL texture structure */ struct SDL_Texture { - Uint32 id; - Uint32 format; /**< The pixel format of the texture */ int access; /**< SDL_TextureAccess */ int w; /**< The width of the texture */ int h; /**< The height of the texture */ int modMode; /**< The texture modulation mode */ - int blendMode; /**< The texture blend mode */ - int scaleMode; /**< The texture scale mode */ - Uint8 r, g, b, a; /**< Texture modulation values */ + int blendMode; /**< The texture blend mode */ + int scaleMode; /**< The texture scale mode */ + Uint8 r, g, b, a; /**< Texture modulation values */ SDL_Renderer *renderer; - void *driverdata; /**< Driver specific texture representation */ + void *driverdata; /**< Driver specific texture representation */ + SDL_Texture *prev; SDL_Texture *next; }; @@ -118,7 +115,10 @@ struct SDL_Renderer SDL_RendererInfo info; /* The window associated with the renderer */ - SDL_WindowID window; + SDL_Window *window; + + /* The list of textures */ + SDL_Texture *textures; Uint8 r, g, b, a; /**< Color for drawing operations values */ int blendMode; /**< The drawing blend mode */ @@ -139,19 +139,21 @@ struct SDL_RenderDriver struct SDL_Window { Uint32 id; - char *title; int x, y; int w, h; Uint32 flags; - int display; + SDL_VideoDisplay *display; SDL_Renderer *renderer; SDL_DisplayMode fullscreen_mode; void *userdata; void *driverdata; + + SDL_Window *prev; + SDL_Window *next; }; #define FULLSCREEN_VISIBLE(W) \ (((W)->flags & SDL_WINDOW_FULLSCREEN) && \ @@ -184,9 +186,6 @@ struct SDL_VideoDisplay SDL_Renderer *current_renderer; - /* The hash list of textures */ - SDL_Texture *textures[64]; - SDL_VideoDevice *device; void *driverdata; @@ -413,8 +412,8 @@ extern VideoBootStrap NDS_bootstrap; extern VideoBootStrap PND_bootstrap; #endif -#define SDL_CurrentDisplay (_this->displays[_this->current_display]) -#define SDL_CurrentRenderer (SDL_CurrentDisplay.current_renderer) +#define SDL_CurrentDisplay (&_this->displays[_this->current_display]) +#define SDL_CurrentRenderer (SDL_CurrentDisplay->current_renderer) extern SDL_VideoDevice *SDL_GetVideoDevice(); extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); @@ -433,8 +432,6 @@ extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver); extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); -extern SDL_Window *SDL_GetWindowFromID(SDL_WindowID windowID); -extern SDL_VideoDisplay *SDL_GetDisplayFromWindow(SDL_Window * window); extern void SDL_OnWindowShown(SDL_Window * window); extern void SDL_OnWindowHidden(SDL_Window * window); @@ -443,7 +440,7 @@ extern void SDL_OnWindowMinimized(SDL_Window * window); extern void SDL_OnWindowRestored(SDL_Window * window); extern void SDL_OnWindowFocusGained(SDL_Window * window); extern void SDL_OnWindowFocusLost(SDL_Window * window); -extern SDL_WindowID SDL_GetFocusWindow(void); +extern SDL_Window * SDL_GetFocusWindow(void); #endif /* _SDL_sysvideo_h */ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index f43361a29..cb63c9f04 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -443,7 +443,7 @@ int SDL_GetNumDisplayModes() { if (_this) { - return SDL_GetNumDisplayModesForDisplay(&SDL_CurrentDisplay); + return SDL_GetNumDisplayModesForDisplay(SDL_CurrentDisplay); } return 0; } @@ -465,7 +465,7 @@ SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayM int SDL_GetDisplayMode(int index, SDL_DisplayMode * mode) { - return SDL_GetDisplayModeForDisplay(&SDL_CurrentDisplay, index, mode); + return SDL_GetDisplayModeForDisplay(SDL_CurrentDisplay, index, mode); } int @@ -484,7 +484,7 @@ SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode) SDL_UninitializedVideo(); return -1; } - return SDL_GetDesktopDisplayModeForDisplay(&SDL_CurrentDisplay, mode); + return SDL_GetDesktopDisplayModeForDisplay(SDL_CurrentDisplay, mode); } int @@ -503,7 +503,7 @@ SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode) SDL_UninitializedVideo(); return -1; } - return SDL_GetCurrentDisplayModeForDisplay(&SDL_CurrentDisplay, mode); + return SDL_GetCurrentDisplayModeForDisplay(SDL_CurrentDisplay, mode); } SDL_DisplayMode * @@ -621,7 +621,7 @@ SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode, SDL_UninitializedVideo(); return NULL; } - return SDL_GetClosestDisplayModeForDisplay(&SDL_CurrentDisplay, mode, closest); + return SDL_GetClosestDisplayModeForDisplay(SDL_CurrentDisplay, mode, closest); } int @@ -702,14 +702,12 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode) SDL_UninitializedVideo(); return -1; } - return SDL_SetDisplayModeForDisplay(&SDL_CurrentDisplay, mode); + return SDL_SetDisplayModeForDisplay(SDL_CurrentDisplay, mode); } int -SDL_SetWindowDisplayMode(SDL_WindowID windowID, const SDL_DisplayMode * mode) +SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return -1; } @@ -723,9 +721,8 @@ SDL_SetWindowDisplayMode(SDL_WindowID windowID, const SDL_DisplayMode * mode) } int -SDL_GetWindowDisplayMode(SDL_WindowID windowID, SDL_DisplayMode * mode) +SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode) { - SDL_Window *window = SDL_GetWindowFromID(windowID); SDL_DisplayMode fullscreen_mode; if (!window) { @@ -740,7 +737,7 @@ SDL_GetWindowDisplayMode(SDL_WindowID windowID, SDL_DisplayMode * mode) fullscreen_mode.h = window->h; } - if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayFromWindow(window), + if (!SDL_GetClosestDisplayModeForDisplay(window->display, &fullscreen_mode, &fullscreen_mode)) { SDL_SetError("Couldn't find display mode match"); @@ -756,7 +753,7 @@ SDL_GetWindowDisplayMode(SDL_WindowID windowID, SDL_DisplayMode * mode) static void SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; int i; /* See if we're already processing a window */ @@ -772,13 +769,13 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt) if (attempt) { /* We just gained some state, try to gain all states */ if (window->flags & SDL_WINDOW_MINIMIZED) { - SDL_RestoreWindow(window->id); + SDL_RestoreWindow(window); } else { - SDL_RaiseWindow(window->id); + SDL_RaiseWindow(window); } } else { /* We just lost some state, try to release all states */ - SDL_MinimizeWindow(window->id); + SDL_MinimizeWindow(window); } } @@ -787,7 +784,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt) for (i = 0; i < display->num_windows; ++i) { SDL_Window *other = &display->windows[i]; if (other != window && FULLSCREEN_VISIBLE(other)) { - SDL_MinimizeWindow(other->id); + SDL_MinimizeWindow(other); } } } @@ -799,7 +796,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt) window = &display->windows[i]; if (FULLSCREEN_VISIBLE(window)) { SDL_DisplayMode fullscreen_mode; - if (SDL_GetWindowDisplayMode(window->id, &fullscreen_mode) == 0) { + if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) { SDL_SetDisplayModeForDisplay(display, &fullscreen_mode); display->fullscreen_window = window; return; @@ -840,7 +837,7 @@ SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors) SDL_UninitializedVideo(); return -1; } - return SDL_SetPaletteForDisplay(&SDL_CurrentDisplay, colors, firstcolor, ncolors); + return SDL_SetPaletteForDisplay(SDL_CurrentDisplay, colors, firstcolor, ncolors); } int @@ -869,10 +866,10 @@ SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors) SDL_UninitializedVideo(); return -1; } - return SDL_GetPaletteForDisplay(&SDL_CurrentDisplay, colors, firstcolor, ncolors); + return SDL_GetPaletteForDisplay(SDL_CurrentDisplay, colors, firstcolor, ncolors); } -SDL_WindowID +SDL_Window * SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) { const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN | @@ -881,112 +878,79 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) SDL_WINDOW_RESIZABLE | SDL_WINDOW_INPUT_GRABBED); SDL_VideoDisplay *display; - SDL_Window window; - int num_windows; - SDL_Window *windows; + SDL_Window *window; if (!_this) { /* Initialize the video system if needed */ if (SDL_VideoInit(NULL, 0) < 0) { - return 0; + return NULL; } } if (flags & SDL_WINDOW_OPENGL) { if (!_this->GL_CreateContext) { SDL_SetError("No OpenGL support in video driver"); - return 0; + return NULL; } SDL_GL_LoadLibrary(NULL); } - SDL_zero(window); - window.id = _this->next_object_id++; - window.x = x; - window.y = y; - window.w = w; - window.h = h; - window.flags = (flags & allowed_flags); - window.display = _this->current_display; + display = SDL_CurrentDisplay; + window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); + window->id = _this->next_object_id++; + window->x = x; + window->y = y; + window->w = w; + window->h = h; + window->flags = (flags & allowed_flags); + window->display = display; + window->next = display->windows; + display->windows = window; - if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) { - if (flags & SDL_WINDOW_OPENGL) { - SDL_GL_UnloadLibrary(); - } - return 0; - } - display = &SDL_CurrentDisplay; - num_windows = display->num_windows; - windows = - SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows)); - if (!windows) { - if (_this->DestroyWindow) { - _this->DestroyWindow(_this, &window); - } - if (flags & SDL_WINDOW_OPENGL) { - SDL_GL_UnloadLibrary(); - } - return 0; + if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) { + SDL_DestroyWindow(window); + return NULL; } - windows[num_windows] = window; - display->windows = windows; - display->num_windows++; if (title) { - SDL_SetWindowTitle(window.id, title); + SDL_SetWindowTitle(window, title); } if (flags & SDL_WINDOW_MAXIMIZED) { - SDL_MaximizeWindow(window.id); + SDL_MaximizeWindow(window); } if (flags & SDL_WINDOW_MINIMIZED) { - SDL_MinimizeWindow(window.id); + SDL_MinimizeWindow(window); } if (flags & SDL_WINDOW_SHOWN) { - SDL_ShowWindow(window.id); + SDL_ShowWindow(window); } - SDL_UpdateWindowGrab(&window); + SDL_UpdateWindowGrab(window); - return window.id; + return window; } -SDL_WindowID +SDL_Window * SDL_CreateWindowFrom(const void *data) { SDL_VideoDisplay *display; - SDL_Window window; - int num_windows; - SDL_Window *windows; + SDL_Window *window; if (!_this) { SDL_UninitializedVideo(); - return (0); + return NULL; } - SDL_zero(window); - window.id = _this->next_object_id++; - window.display = _this->current_display; - window.flags = SDL_WINDOW_FOREIGN; + display = SDL_CurrentDisplay; + window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); + window->id = _this->next_object_id++; + window->flags = SDL_WINDOW_FOREIGN; + window->display = display; + window->next = display->windows; + display->windows = window; if (!_this->CreateWindowFrom || - _this->CreateWindowFrom(_this, &window, data) < 0) { - return 0; - } - /* FIXME: Find out what display this window is actually on... */ - display = &SDL_CurrentDisplay; - num_windows = display->num_windows; - windows = - SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows)); - if (!windows) { - if (_this->DestroyWindow) { - _this->DestroyWindow(_this, &window); - } - if (window.title) { - SDL_free(window.title); - } - return 0; + _this->CreateWindowFrom(_this, window, data) < 0) { + SDL_DestroyWindow(window); + return NULL; } - windows[num_windows] = window; - display->windows = windows; - display->num_windows++; - - return window.id; + return window; } int @@ -1036,94 +1000,75 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags) } if (title) { - SDL_SetWindowTitle(window->id, title); + SDL_SetWindowTitle(window, title); SDL_free(title); } if (flags & SDL_WINDOW_MAXIMIZED) { - SDL_MaximizeWindow(window->id); + SDL_MaximizeWindow(window); } if (flags & SDL_WINDOW_MINIMIZED) { - SDL_MinimizeWindow(window->id); + SDL_MinimizeWindow(window); } if (flags & SDL_WINDOW_SHOWN) { - SDL_ShowWindow(window->id); + SDL_ShowWindow(window); } SDL_UpdateWindowGrab(window); return 0; } -SDL_Window * -SDL_GetWindowFromID(SDL_WindowID windowID) +static __inline__ SDL_Renderer * +SDL_GetCurrentRenderer(SDL_bool create) { - int i, j; - if (!_this) { SDL_UninitializedVideo(); return NULL; } - if (windowID) { - for (i = 0; i < _this->num_displays; ++i) { - SDL_VideoDisplay *display = &_this->displays[i]; - for (j = 0; j < display->num_windows; ++j) { - SDL_Window *window = &display->windows[j]; - if (window->id == windowID) { - return window; - } - } + if (!SDL_CurrentRenderer) { + if (!create) { + SDL_SetError("Use SDL_CreateRenderer() to create a renderer"); + return NULL; } - } else { - /* Just return the first active window */ - for (i = 0; i < _this->num_displays; ++i) { - SDL_VideoDisplay *display = &_this->displays[i]; - for (j = 0; j < display->num_windows; ++j) { - SDL_Window *window = &display->windows[j]; - return window; - } + if (SDL_CreateRenderer(0, -1, 0) < 0) { + return NULL; } } - /* Couldn't find the window with the requested ID */ - SDL_SetError("Invalid window ID"); - return NULL; + return SDL_CurrentRenderer; } -SDL_VideoDisplay * -SDL_GetDisplayFromWindow(SDL_Window * window) +Uint32 +SDL_GetWindowID(SDL_Window * window) { - if (!_this) { - SDL_UninitializedVideo(); - return NULL; - } if (!window) { - return NULL; + return 0; } - return &_this->displays[window->display]; + return window->id; } -static __inline__ SDL_Renderer * -SDL_GetCurrentRenderer(SDL_bool create) +SDL_Window * +SDL_GetWindowFromID(Uint32 id) { + SDL_Window *window; + int i; + if (!_this) { - SDL_UninitializedVideo(); return NULL; } - if (!SDL_CurrentRenderer) { - if (!create) { - SDL_SetError("Use SDL_CreateRenderer() to create a renderer"); - return NULL; - } - if (SDL_CreateRenderer(0, -1, 0) < 0) { - return NULL; + /* FIXME: Should we keep a separate hash table for these? */ + for (i = _this->num_displays; i--;) { + SDL_VideoDisplay *display = &_this->displays[i]; + for (window = display->windows; window; window = window->next) { + if (window->id == id) { + return window; + } } } - return SDL_CurrentRenderer; + return NULL; } Uint32 -SDL_GetWindowFlags(SDL_WindowID windowID) +SDL_GetWindowFlags(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return 0; } @@ -1131,10 +1076,8 @@ SDL_GetWindowFlags(SDL_WindowID windowID) } void -SDL_SetWindowTitle(SDL_WindowID windowID, const char *title) +SDL_SetWindowTitle(SDL_Window * window, const char *title) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window || title == window->title) { return; } @@ -1153,10 +1096,8 @@ SDL_SetWindowTitle(SDL_WindowID windowID, const char *title) } const char * -SDL_GetWindowTitle(SDL_WindowID windowID) +SDL_GetWindowTitle(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return NULL; } @@ -1164,10 +1105,8 @@ SDL_GetWindowTitle(SDL_WindowID windowID) } void -SDL_SetWindowIcon(SDL_WindowID windowID, SDL_Surface * icon) +SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return; } @@ -1177,10 +1116,8 @@ SDL_SetWindowIcon(SDL_WindowID windowID, SDL_Surface * icon) } void -SDL_SetWindowData(SDL_WindowID windowID, void *userdata) +SDL_SetWindowData(SDL_Window * window, void *userdata) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return; } @@ -1188,10 +1125,8 @@ SDL_SetWindowData(SDL_WindowID windowID, void *userdata) } void * -SDL_GetWindowData(SDL_WindowID windowID) +SDL_GetWindowData(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return NULL; } @@ -1199,11 +1134,8 @@ SDL_GetWindowData(SDL_WindowID windowID) } void -SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y) +SDL_SetWindowPosition(SDL_Window * window, int x, int y) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); - if (!window) { return; } @@ -1216,14 +1148,12 @@ SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y) if (_this->SetWindowPosition) { _this->SetWindowPosition(_this, window); } - SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MOVED, x, y); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y); } void -SDL_GetWindowPosition(SDL_WindowID windowID, int *x, int *y) +SDL_GetWindowPosition(SDL_Window * window, int *x, int *y) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return; } @@ -1236,10 +1166,8 @@ SDL_GetWindowPosition(SDL_WindowID windowID, int *x, int *y) } void -SDL_SetWindowSize(SDL_WindowID windowID, int w, int h) +SDL_SetWindowSize(SDL_Window * window, int w, int h) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return; } @@ -1253,10 +1181,8 @@ SDL_SetWindowSize(SDL_WindowID windowID, int w, int h) } void -SDL_GetWindowSize(SDL_WindowID windowID, int *w, int *h) +SDL_GetWindowSize(SDL_Window * window, int *w, int *h) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (window) { if (w) { *w = window->w; @@ -1275,10 +1201,8 @@ SDL_GetWindowSize(SDL_WindowID windowID, int *w, int *h) } void -SDL_ShowWindow(SDL_WindowID windowID) +SDL_ShowWindow(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window || (window->flags & SDL_WINDOW_SHOWN)) { return; } @@ -1286,14 +1210,12 @@ SDL_ShowWindow(SDL_WindowID windowID) if (_this->ShowWindow) { _this->ShowWindow(_this, window); } - SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_SHOWN, 0, 0); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0); } void -SDL_HideWindow(SDL_WindowID windowID) +SDL_HideWindow(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window || !(window->flags & SDL_WINDOW_SHOWN)) { return; } @@ -1301,14 +1223,12 @@ SDL_HideWindow(SDL_WindowID windowID) if (_this->HideWindow) { _this->HideWindow(_this, window); } - SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_HIDDEN, 0, 0); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIDDEN, 0, 0); } void -SDL_RaiseWindow(SDL_WindowID windowID) +SDL_RaiseWindow(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window || !(window->flags & SDL_WINDOW_SHOWN)) { return; } @@ -1316,15 +1236,13 @@ SDL_RaiseWindow(SDL_WindowID windowID) _this->RaiseWindow(_this, window); } else { /* FIXME: What we really want is a way to request focus */ - SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); } } void -SDL_MaximizeWindow(SDL_WindowID windowID) +SDL_MaximizeWindow(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window || (window->flags & SDL_WINDOW_MAXIMIZED)) { return; } @@ -1332,14 +1250,12 @@ SDL_MaximizeWindow(SDL_WindowID windowID) if (_this->MaximizeWindow) { _this->MaximizeWindow(_this, window); } - SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); } void -SDL_MinimizeWindow(SDL_WindowID windowID) +SDL_MinimizeWindow(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window || (window->flags & SDL_WINDOW_MINIMIZED)) { return; } @@ -1347,14 +1263,12 @@ SDL_MinimizeWindow(SDL_WindowID windowID) if (_this->MinimizeWindow) { _this->MinimizeWindow(_this, window); } - SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MINIMIZED, 0, 0); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } void -SDL_RestoreWindow(SDL_WindowID windowID) +SDL_RestoreWindow(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window || !(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) { return; @@ -1363,14 +1277,12 @@ SDL_RestoreWindow(SDL_WindowID windowID) if (_this->RestoreWindow) { _this->RestoreWindow(_this, window); } - SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_RESTORED, 0, 0); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); } int -SDL_SetWindowFullscreen(SDL_WindowID windowID, int fullscreen) +SDL_SetWindowFullscreen(SDL_Window * window, int fullscreen) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return -1; } @@ -1393,10 +1305,8 @@ SDL_SetWindowFullscreen(SDL_WindowID windowID, int fullscreen) } void -SDL_SetWindowGrab(SDL_WindowID windowID, int mode) +SDL_SetWindowGrab(SDL_Window * window, int mode) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window || (!!mode == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) { return; } @@ -1417,10 +1327,8 @@ SDL_UpdateWindowGrab(SDL_Window * window) } int -SDL_GetWindowGrab(SDL_WindowID windowID) +SDL_GetWindowGrab(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return 0; } @@ -1430,7 +1338,7 @@ SDL_GetWindowGrab(SDL_WindowID windowID) void SDL_OnWindowShown(SDL_Window * window) { - SDL_RaiseWindow(window->id); + SDL_RaiseWindow(window); SDL_UpdateFullscreenMode(window, SDL_TRUE); } @@ -1459,14 +1367,14 @@ SDL_OnWindowMinimized(SDL_Window * window) void SDL_OnWindowRestored(SDL_Window * window) { - SDL_RaiseWindow(window->id); + SDL_RaiseWindow(window); SDL_UpdateFullscreenMode(window, SDL_TRUE); } void SDL_OnWindowFocusGained(SDL_Window * window) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; if (display->gamma && _this->SetDisplayGammaRamp) { _this->SetDisplayGammaRamp(_this, display, display->gamma); @@ -1480,12 +1388,12 @@ SDL_OnWindowFocusGained(SDL_Window * window) void SDL_OnWindowFocusLost(SDL_Window * window) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; /* If we're fullscreen on a single-head system and lose focus, minimize */ if ((window->flags & SDL_WINDOW_FULLSCREEN) && _this->num_displays == 1) { - SDL_MinimizeWindow(window->id); + SDL_MinimizeWindow(window); } if (display->gamma && _this->SetDisplayGammaRamp) { @@ -1497,69 +1405,63 @@ SDL_OnWindowFocusLost(SDL_Window * window) } } -SDL_WindowID +SDL_Window * SDL_GetFocusWindow(void) { SDL_VideoDisplay *display; - int i; + SDL_Window *window; if (!_this) { - return 0; + return NULL; } - display = &SDL_CurrentDisplay; - for (i = 0; i < display->num_windows; ++i) { - SDL_Window *window = &display->windows[i]; - + display = SDL_CurrentDisplay; + for (window = display->windows; window; window = window->next) { if (window->flags & SDL_WINDOW_INPUT_FOCUS) { - return window->id; + return window; } } - return 0; + return NULL; } void -SDL_DestroyWindow(SDL_WindowID windowID) +SDL_DestroyWindow(SDL_Window * window) { - int i, j; + SDL_VideoDisplay *display; - if (!_this) { + if (!_this || !window || !window->id) { + SDL_SetError("Invalid window"); return; } - for (i = 0; i < _this->num_displays; ++i) { - SDL_VideoDisplay *display = &_this->displays[i]; - for (j = 0; j < display->num_windows; ++j) { - SDL_Window *window = &display->windows[j]; - if (window->id != windowID) { - continue; - } - if (window->title) { - SDL_free(window->title); - window->title = NULL; - } - if (window->renderer) { - SDL_DestroyRenderer(window->id); - window->renderer = NULL; - } + if (window->title) { + SDL_free(window->title); + } + if (window->renderer) { + SDL_DestroyRenderer(window); + } - /* Restore video mode, etc. */ - SDL_UpdateFullscreenMode(window, SDL_FALSE); + /* Restore video mode, etc. */ + SDL_UpdateFullscreenMode(window, SDL_FALSE); - if (_this->DestroyWindow) { - _this->DestroyWindow(_this, window); - } - if (window->flags & SDL_WINDOW_OPENGL) { - SDL_GL_UnloadLibrary(); - } - if (j != display->num_windows - 1) { - SDL_memcpy(&display->windows[i], - &display->windows[i + 1], - (display->num_windows - i - 1) * sizeof(*window)); - } - --display->num_windows; - return; - } + if (_this->DestroyWindow) { + _this->DestroyWindow(_this, window); + } + if (window->flags & SDL_WINDOW_OPENGL) { + SDL_GL_UnloadLibrary(); + } + + /* Unlink the window from the list */ + display = window->display; + if (window->prev) { + window->prev->next = window->next; + } else { + display->windows = window->next; } + + /* Clear the ID so we know it was destroyed */ + window->id = 0; + + SDL_free(window); } void @@ -1582,7 +1484,7 @@ int SDL_GetNumRenderDrivers(void) { if (_this) { - return SDL_CurrentDisplay.num_render_drivers; + return SDL_CurrentDisplay->num_render_drivers; } return 0; } @@ -1599,22 +1501,20 @@ SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info) SDL_GetNumRenderDrivers() - 1); return -1; } - *info = SDL_CurrentDisplay.render_drivers[index].info; + *info = SDL_CurrentDisplay->render_drivers[index].info; return 0; } int -SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) +SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { - SDL_SetError("Invalid window ID"); + SDL_SetError("Invalid window"); return -1; } /* Free any existing renderer */ - SDL_DestroyRenderer(windowID); + SDL_DestroyRenderer(window); if (index < 0) { char *override = SDL_getenv("SDL_VIDEO_RENDERER"); @@ -1633,7 +1533,7 @@ SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) if (override) { for (index = 0; index < n; ++index) { SDL_RenderDriver *driver = - &SDL_CurrentDisplay.render_drivers[index]; + &SDL_CurrentDisplay->render_drivers[index]; if (SDL_strcasecmp(override, driver->info.name) == 0) { /* Create a new renderer instance */ @@ -1644,7 +1544,7 @@ SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) } else { for (index = 0; index < n; ++index) { SDL_RenderDriver *driver = - &SDL_CurrentDisplay.render_drivers[index]; + &SDL_CurrentDisplay->render_drivers[index]; if ((driver->info.flags & flags) == flags) { /* Create a new renderer instance */ @@ -1667,7 +1567,7 @@ SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) return -1; } /* Create a new renderer instance */ - window->renderer = SDL_CurrentDisplay.render_drivers[index].CreateRenderer(window, flags); + window->renderer = SDL_CurrentDisplay->render_drivers[index].CreateRenderer(window, flags); } if (window->renderer == NULL) { @@ -1675,19 +1575,18 @@ SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) return -1; } - SDL_SelectRenderer(window->id); + SDL_SelectRenderer(window); return 0; } int -SDL_SelectRenderer(SDL_WindowID windowID) +SDL_SelectRenderer(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); SDL_Renderer *renderer; if (!window) { - SDL_SetError("Invalid window ID"); + SDL_SetError("Invalid window"); return -1; } renderer = window->renderer; @@ -1700,7 +1599,7 @@ SDL_SelectRenderer(SDL_WindowID windowID) return -1; } } - SDL_CurrentDisplay.current_renderer = renderer; + SDL_CurrentDisplay->current_renderer = renderer; return 0; } @@ -1715,10 +1614,9 @@ SDL_GetRendererInfo(SDL_RendererInfo * info) return 0; } -SDL_TextureID +SDL_Texture * SDL_CreateTexture(Uint32 format, int access, int w, int h) { - int hash; SDL_Renderer *renderer; SDL_Texture *texture; @@ -1735,7 +1633,6 @@ SDL_CreateTexture(Uint32 format, int access, int w, int h) SDL_OutOfMemory(); return 0; } - texture->id = _this->next_object_id++; texture->format = format; texture->access = access; texture->w = w; @@ -1745,25 +1642,20 @@ SDL_CreateTexture(Uint32 format, int access, int w, int h) texture->b = 255; texture->a = 255; texture->renderer = renderer; + texture->next = renderer->textures; + renderer->textures = texture; if (renderer->CreateTexture(renderer, texture) < 0) { - if (renderer->DestroyTexture) { - renderer->DestroyTexture(renderer, texture); - } - SDL_free(texture); + SDL_DestroyTexture(texture); return 0; } - hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures)); - texture->next = SDL_CurrentDisplay.textures[hash]; - SDL_CurrentDisplay.textures[hash] = texture; - - return texture->id; + return texture; } -SDL_TextureID +SDL_Texture * SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) { - SDL_TextureID textureID; + SDL_Texture *texture; Uint32 requested_format = format; SDL_PixelFormat *fmt; SDL_Renderer *renderer; @@ -1980,29 +1872,29 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) } } - textureID = + texture = SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w, surface->h); - if (!textureID && !requested_format) { + if (!texture && !requested_format) { SDL_DisplayMode desktop_mode; SDL_GetDesktopDisplayMode(&desktop_mode); format = desktop_mode.format; - textureID = + texture = SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w, surface->h); } - if (!textureID) { + if (!texture) { return 0; } if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask && Bmask == fmt->Bmask && Amask == fmt->Amask) { if (SDL_MUSTLOCK(surface)) { SDL_LockSurface(surface); - SDL_UpdateTexture(textureID, NULL, surface->pixels, + SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch); SDL_UnlockSurface(surface); } else { - SDL_UpdateTexture(textureID, NULL, surface->pixels, + SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch); } } else { @@ -2025,14 +1917,14 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) } dst = SDL_ConvertSurface(surface, &dst_fmt, 0); if (dst) { - SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch); + SDL_UpdateTexture(texture, NULL, dst->pixels, dst->pitch); SDL_FreeSurface(dst); } if (dst_fmt.palette) { SDL_FreePalette(dst_fmt.palette); } if (!dst) { - SDL_DestroyTexture(textureID); + SDL_DestroyTexture(texture); return 0; } } @@ -2043,50 +1935,29 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) int scaleMode; SDL_GetSurfaceColorMod(surface, &r, &g, &b); - SDL_SetTextureColorMod(textureID, r, g, b); + SDL_SetTextureColorMod(texture, r, g, b); SDL_GetSurfaceAlphaMod(surface, &a); - SDL_SetTextureAlphaMod(textureID, a); + SDL_SetTextureAlphaMod(texture, a); SDL_GetSurfaceBlendMode(surface, &blendMode); - SDL_SetTextureBlendMode(textureID, blendMode); + SDL_SetTextureBlendMode(texture, blendMode); SDL_GetSurfaceScaleMode(surface, &scaleMode); - SDL_SetTextureScaleMode(textureID, scaleMode); + SDL_SetTextureScaleMode(texture, scaleMode); } if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) { - SDL_SetTexturePalette(textureID, fmt->palette->colors, 0, + SDL_SetTexturePalette(texture, fmt->palette->colors, 0, fmt->palette->ncolors); } - return textureID; -} - -static __inline__ SDL_Texture * -SDL_GetTextureFromID(SDL_TextureID textureID) -{ - int hash; - SDL_Texture *texture; - - if (!_this) { - return NULL; - } - hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures)); - for (texture = SDL_CurrentDisplay.textures[hash]; texture; - texture = texture->next) { - if (texture->id == textureID) { - return texture; - } - } - return NULL; + return texture; } int -SDL_QueryTexture(SDL_TextureID textureID, Uint32 * format, int *access, +SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access, int *w, int *h) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); - if (!texture) { return -1; } @@ -2106,9 +1977,8 @@ SDL_QueryTexture(SDL_TextureID textureID, Uint32 * format, int *access, } int -SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch) +SDL_QueryTexturePixels(SDL_Texture * texture, void **pixels, int *pitch) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2123,10 +1993,9 @@ SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch) } int -SDL_SetTexturePalette(SDL_TextureID textureID, const SDL_Color * colors, +SDL_SetTexturePalette(SDL_Texture * texture, const SDL_Color * colors, int firstcolor, int ncolors) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2142,10 +2011,9 @@ SDL_SetTexturePalette(SDL_TextureID textureID, const SDL_Color * colors, } int -SDL_GetTexturePalette(SDL_TextureID textureID, SDL_Color * colors, +SDL_GetTexturePalette(SDL_Texture * texture, SDL_Color * colors, int firstcolor, int ncolors) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2161,9 +2029,8 @@ SDL_GetTexturePalette(SDL_TextureID textureID, SDL_Color * colors, } int -SDL_SetTextureColorMod(SDL_TextureID textureID, Uint8 r, Uint8 g, Uint8 b) +SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2186,10 +2053,9 @@ SDL_SetTextureColorMod(SDL_TextureID textureID, Uint8 r, Uint8 g, Uint8 b) } int -SDL_GetTextureColorMod(SDL_TextureID textureID, Uint8 * r, Uint8 * g, +SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, Uint8 * b) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2209,9 +2075,8 @@ SDL_GetTextureColorMod(SDL_TextureID textureID, Uint8 * r, Uint8 * g, } int -SDL_SetTextureAlphaMod(SDL_TextureID textureID, Uint8 alpha) +SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2232,10 +2097,8 @@ SDL_SetTextureAlphaMod(SDL_TextureID textureID, Uint8 alpha) } int -SDL_GetTextureAlphaMod(SDL_TextureID textureID, Uint8 * alpha) +SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); - if (!texture) { return -1; } @@ -2246,9 +2109,8 @@ SDL_GetTextureAlphaMod(SDL_TextureID textureID, Uint8 * alpha) } int -SDL_SetTextureBlendMode(SDL_TextureID textureID, int blendMode) +SDL_SetTextureBlendMode(SDL_Texture * texture, int blendMode) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2264,10 +2126,8 @@ SDL_SetTextureBlendMode(SDL_TextureID textureID, int blendMode) } int -SDL_GetTextureBlendMode(SDL_TextureID textureID, int *blendMode) +SDL_GetTextureBlendMode(SDL_Texture * texture, int *blendMode) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); - if (!texture) { return -1; } @@ -2278,9 +2138,8 @@ SDL_GetTextureBlendMode(SDL_TextureID textureID, int *blendMode) } int -SDL_SetTextureScaleMode(SDL_TextureID textureID, int scaleMode) +SDL_SetTextureScaleMode(SDL_Texture * texture, int scaleMode) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2296,10 +2155,8 @@ SDL_SetTextureScaleMode(SDL_TextureID textureID, int scaleMode) } int -SDL_GetTextureScaleMode(SDL_TextureID textureID, int *scaleMode) +SDL_GetTextureScaleMode(SDL_Texture * texture, int *scaleMode) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); - if (!texture) { return -1; } @@ -2310,10 +2167,9 @@ SDL_GetTextureScaleMode(SDL_TextureID textureID, int *scaleMode) } int -SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect, +SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; SDL_Rect full_rect; @@ -2336,10 +2192,9 @@ SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect, } int -SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect * rect, int markDirty, +SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, int markDirty, void **pixels, int *pitch) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; SDL_Rect full_rect; @@ -2367,9 +2222,8 @@ SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect * rect, int markDirty, } void -SDL_UnlockTexture(SDL_TextureID textureID) +SDL_UnlockTexture(SDL_Texture * texture) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2386,10 +2240,9 @@ SDL_UnlockTexture(SDL_TextureID textureID) } void -SDL_DirtyTexture(SDL_TextureID textureID, int numrects, +SDL_DirtyTexture(SDL_Texture * texture, int numrects, const SDL_Rect * rects) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; if (!texture) { @@ -2607,11 +2460,10 @@ SDL_RenderDrawRects(const SDL_Rect ** rects, int count) /* Check for NULL rect, which means fill entire window */ for (i = 0; i < count; ++i) { if (rects[i] == NULL) { - SDL_Window *window; + SDL_Window *window = renderer->window; SDL_Rect full_rect; const SDL_Rect *rect; - window = SDL_GetWindowFromID(renderer->window); full_rect.x = 0; full_rect.y = 0; full_rect.w = window->w; @@ -2654,11 +2506,10 @@ SDL_RenderFillRects(const SDL_Rect ** rects, int count) /* Check for NULL rect, which means fill entire window */ for (i = 0; i < count; ++i) { if (rects[i] == NULL) { - SDL_Window *window; + SDL_Window *window = renderer->window; SDL_Rect full_rect; const SDL_Rect *rect; - window = SDL_GetWindowFromID(renderer->window); full_rect.x = 0; full_rect.y = 0; full_rect.w = window->w; @@ -2671,10 +2522,9 @@ SDL_RenderFillRects(const SDL_Rect ** rects, int count) } int -SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, +SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect) { - SDL_Texture *texture = SDL_GetTextureFromID(textureID); SDL_Renderer *renderer; SDL_Window *window; SDL_Rect real_srcrect; @@ -2696,7 +2546,7 @@ SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, SDL_Unsupported(); return -1; } - window = SDL_GetWindowFromID(renderer->window); + window = renderer->window; real_srcrect.x = 0; real_srcrect.y = 0; @@ -2751,10 +2601,10 @@ SDL_RenderReadPixels(const SDL_Rect * rect, Uint32 format, SDL_Unsupported(); return -1; } - window = SDL_GetWindowFromID(renderer->window); + window = renderer->window; if (!format) { - format = SDL_GetDisplayFromWindow(window)->current_mode.format; + format = window->display->current_mode.format; } real_rect.x = 0; @@ -2769,7 +2619,7 @@ SDL_RenderReadPixels(const SDL_Rect * rect, Uint32 format, pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y); } if (real_rect.x > rect->x) { - Uint32 format = SDL_CurrentDisplay.current_mode.format; + Uint32 format = SDL_CurrentDisplay->current_mode.format; int bpp = SDL_BYTESPERPIXEL(format); pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x); } @@ -2795,10 +2645,10 @@ SDL_RenderWritePixels(const SDL_Rect * rect, Uint32 format, SDL_Unsupported(); return -1; } - window = SDL_GetWindowFromID(renderer->window); + window = renderer->window; if (!format) { - format = SDL_GetDisplayFromWindow(window)->current_mode.format; + format = window->display->current_mode.format; } real_rect.x = 0; @@ -2813,7 +2663,7 @@ SDL_RenderWritePixels(const SDL_Rect * rect, Uint32 format, pixels = (const Uint8 *)pixels + pitch * (real_rect.y - rect->y); } if (real_rect.x > rect->x) { - Uint32 format = SDL_CurrentDisplay.current_mode.format; + Uint32 format = SDL_CurrentDisplay->current_mode.format; int bpp = SDL_BYTESPERPIXEL(format); pixels = (const Uint8 *)pixels + bpp * (real_rect.x - rect->x); } @@ -2836,45 +2686,30 @@ SDL_RenderPresent(void) } void -SDL_DestroyTexture(SDL_TextureID textureID) +SDL_DestroyTexture(SDL_Texture * texture) { - int hash; - SDL_Texture *prev, *texture; SDL_Renderer *renderer; - if (!_this) { - SDL_UninitializedVideo(); + if (!texture || !texture->renderer) { + SDL_SetError("Invalid texture"); return; } - /* Look up the texture in the hash table */ - hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures)); - prev = NULL; - for (texture = SDL_CurrentDisplay.textures[hash]; texture; - prev = texture, texture = texture->next) { - if (texture->id == textureID) { - break; - } - } - if (!texture) { - return; - } - /* Unlink the texture from the list */ - if (prev) { - prev->next = texture->next; + + renderer = texture->renderer; + if (texture->prev) { + texture->prev->next = texture->next; } else { - SDL_CurrentDisplay.textures[hash] = texture->next; + renderer->textures = texture->next; } + texture->renderer = NULL; - /* Free the texture */ - renderer = texture->renderer; renderer->DestroyTexture(renderer, texture); SDL_free(texture); } void -SDL_DestroyRenderer(SDL_WindowID windowID) +SDL_DestroyRenderer(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); SDL_Renderer *renderer; int i; @@ -2885,26 +2720,10 @@ SDL_DestroyRenderer(SDL_WindowID windowID) if (!renderer) { return; } + /* Free existing textures for this renderer */ - for (i = 0; i < SDL_arraysize(SDL_CurrentDisplay.textures); ++i) { - SDL_Texture *texture; - SDL_Texture *prev = NULL; - SDL_Texture *next; - for (texture = SDL_CurrentDisplay.textures[i]; texture; - texture = next) { - next = texture->next; - if (texture->renderer == renderer) { - if (prev) { - prev->next = next; - } else { - SDL_CurrentDisplay.textures[i] = next; - } - renderer->DestroyTexture(renderer, texture); - SDL_free(texture); - } else { - prev = texture; - } - } + while (renderer->textures) { + SDL_DestroyTexture(renderer->textures); } /* Free the renderer instance */ @@ -2912,8 +2731,8 @@ SDL_DestroyRenderer(SDL_WindowID windowID) /* Clear references */ window->renderer = NULL; - if (SDL_CurrentDisplay.current_renderer == renderer) { - SDL_CurrentDisplay.current_renderer = NULL; + if (SDL_CurrentDisplay->current_renderer == renderer) { + SDL_CurrentDisplay->current_renderer = NULL; } } @@ -2971,14 +2790,9 @@ SDL_VideoQuit(void) /* Clean up the system video */ for (i = _this->num_displays; i--;) { SDL_VideoDisplay *display = &_this->displays[i]; - for (j = display->num_windows; j--;) { - SDL_DestroyWindow(display->windows[i].id); + while (display->windows) { + SDL_DestroyWindow(display->windows); } - if (display->windows) { - SDL_free(display->windows); - display->windows = NULL; - } - display->num_windows = 0; if (display->render_drivers) { SDL_free(display->render_drivers); display->render_drivers = NULL; @@ -3383,10 +3197,8 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) } SDL_GLContext -SDL_GL_CreateContext(SDL_WindowID windowID) +SDL_GL_CreateContext(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return NULL; } @@ -3398,10 +3210,8 @@ SDL_GL_CreateContext(SDL_WindowID windowID) } int -SDL_GL_MakeCurrent(SDL_WindowID windowID, SDL_GLContext context) +SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext context) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (window && !(window->flags & SDL_WINDOW_OPENGL)) { SDL_SetError("The specified window isn't an OpenGL window"); return -1; @@ -3443,10 +3253,8 @@ SDL_GL_GetSwapInterval(void) } void -SDL_GL_SwapWindow(SDL_WindowID windowID) +SDL_GL_SwapWindow(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window) { return; } @@ -3567,10 +3375,8 @@ SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) #endif SDL_bool -SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo *info) +SDL_GetWindowWMInfo(SDL_Window * window, struct SDL_SysWMinfo *info) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - if (!window || !_this->GetWindowWMInfo) { return SDL_FALSE; } diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 7cad1253c..1a71840c7 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -76,7 +76,7 @@ if (point.x < 0 || point.x >= candidate->w || point.y < 0 || point.y >= candidate->h) { /* The mouse is out of this fullscreen display */ - if (mouse->focus == candidate->id) { + if (mouse->focus == candidate) { SDL_SetMouseFocus(data->mouse, 0); } } else { @@ -91,8 +91,8 @@ } /* Set the focus appropriately */ - if (mouse->focus != window->id) { - SDL_SetMouseFocus(data->mouse, window->id); + if (mouse->focus != window) { + SDL_SetMouseFocus(data->mouse, window); } switch ([event type]) { diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 41e051d3c..1bb4d7a8d 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -82,7 +82,7 @@ - (CGLContextObj)CGLContextObj; Cocoa_GL_CreateContext(_THIS, SDL_Window * window) { NSAutoreleasePool *pool; - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; NSOpenGLPixelFormatAttribute attr[32]; NSOpenGLPixelFormat *fmt; diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index aeda0779a..ce3085021 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -69,8 +69,8 @@ typedef struct SDL_WindowData SDL_WindowData; struct SDL_WindowData { - SDL_WindowID windowID; - NSWindow *window; + SDL_Window *window; + NSWindow *nswindow; SDL_bool created; CGDirectDisplayID display; Cocoa_WindowListener *listener; diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index e0a6f76d5..29c5acd25 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -86,13 +86,13 @@ - (void)close - (BOOL)windowShouldClose:(id)sender { - SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_CLOSE, 0, 0); + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); return NO; } - (void)windowDidExpose:(NSNotification *)aNotification { - SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_EXPOSED, 0, 0); + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); } - (void)windowDidMove:(NSNotification *)aNotification @@ -102,7 +102,7 @@ - (void)windowDidMove:(NSNotification *)aNotification ConvertNSRect(&rect); x = (int)rect.origin.x; y = (int)rect.origin.y; - SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_MOVED, x, y); + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MOVED, x, y); } - (void)windowDidResize:(NSNotification *)aNotification @@ -111,17 +111,17 @@ - (void)windowDidResize:(NSNotification *)aNotification NSRect rect = [_data->window contentRectForFrameRect:[_data->window frame]]; w = (int)rect.size.width; h = (int)rect.size.height; - SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_RESIZED, w, h); + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESIZED, w, h); } - (void)windowDidMiniaturize:(NSNotification *)aNotification { - SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_MINIMIZED, 0, 0); + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } - (void)windowDidDeminiaturize:(NSNotification *)aNotification { - SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_RESTORED, 0, 0); + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESTORED, 0, 0); } - (void)windowDidBecomeKey:(NSNotification *)aNotification @@ -130,7 +130,7 @@ - (void)windowDidBecomeKey:(NSNotification *)aNotification /* We're going to get keyboard events, since we're key. */ index = _data->videodata->keyboard; - SDL_SetKeyboardFocus(index, _data->windowID); + SDL_SetKeyboardFocus(index, _data->window); } - (void)windowDidResignKey:(NSNotification *)aNotification @@ -141,7 +141,7 @@ - (void)windowDidResignKey:(NSNotification *)aNotification /* Some other window will get mouse events, since we're not key. */ index = _data->videodata->mouse; mouse = SDL_GetMouse(index); - if (mouse->focus == _data->windowID) { + if (mouse->focus == _data->window) { SDL_SetMouseFocus(index, 0); } @@ -152,12 +152,12 @@ - (void)windowDidResignKey:(NSNotification *)aNotification - (void)windowDidHide:(NSNotification *)aNotification { - SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_HIDDEN, 0, 0); + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0); } - (void)windowDidUnhide:(NSNotification *)aNotification { - SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_SHOWN, 0, 0); + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); } - (void)mouseDown:(NSEvent *)theEvent @@ -228,7 +228,7 @@ - (void)otherMouseUp:(NSEvent *)theEvent - (void)mouseMoved:(NSEvent *)theEvent { - SDL_Window *window = SDL_GetWindowFromID(_data->windowID); + SDL_Window *window = _data->window; int index; SDL_Mouse *mouse; NSPoint point; @@ -243,8 +243,8 @@ - (void)mouseMoved:(NSEvent *)theEvent SDL_SetMouseFocus(index, 0); } } else { - if (mouse->focus != _data->windowID) { - SDL_SetMouseFocus(index, _data->windowID); + if (mouse->focus != _data->window) { + SDL_SetMouseFocus(index, _data->window); } SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y, 0); } @@ -298,7 +298,7 @@ - (BOOL)canBecomeMainWindow { NSAutoreleasePool *pool; SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; SDL_WindowData *data; @@ -308,7 +308,7 @@ - (BOOL)canBecomeMainWindow SDL_OutOfMemory(); return -1; } - data->windowID = window->id; + data->window = window; data->window = nswindow; data->created = created; data->display = displaydata->display; @@ -363,7 +363,7 @@ - (BOOL)canBecomeMainWindow if ([nswindow isKeyWindow]) { int index = data->videodata->keyboard; window->flags |= SDL_WINDOW_INPUT_FOCUS; - SDL_SetKeyboardFocus(index, data->windowID); + SDL_SetKeyboardFocus(index, data->window); if (window->flags & SDL_WINDOW_INPUT_GRABBED) { /* FIXME */ @@ -381,7 +381,7 @@ - (BOOL)canBecomeMainWindow { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSWindow *nswindow; - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; NSRect rect; SDL_Rect bounds; unsigned int style; @@ -490,7 +490,7 @@ - (BOOL)canBecomeMainWindow { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window; - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; NSRect rect; SDL_Rect bounds; diff --git a/src/video/directfb/SDL_DirectFB_WM.c b/src/video/directfb/SDL_DirectFB_WM.c index f456fab94..57ee2a71a 100644 --- a/src/video/directfb/SDL_DirectFB_WM.c +++ b/src/video/directfb/SDL_DirectFB_WM.c @@ -196,7 +196,7 @@ void DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window) { SDL_DFB_WINDOWDATA(window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; windata->window->GetPosition(windata->window, &windata->restore.x, &windata->restore.y); diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index 465d44d43..672567467 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -46,7 +46,7 @@ static void DirectFB_InitOSKeymap(_THIS, SDLKey * keypmap, int numkeys); static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button); static void -DirectFB_SetContext(_THIS, SDL_WindowID id) +DirectFB_SetContext(_THIS, SDL_Window *window) { #if (DFB_VERSION_ATLEAST(1,0,0)) /* FIXME: does not work on 1.0/1.2 with radeon driver @@ -55,7 +55,7 @@ DirectFB_SetContext(_THIS, SDL_WindowID id) */ SDL_Window *window = SDL_GetWindowFromID(id); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; int ret; @@ -70,7 +70,7 @@ DirectFB_SetContext(_THIS, SDL_WindowID id) } static void -FocusAllMice(_THIS, SDL_WindowID id) +FocusAllMice(_THIS, SDL_Window *window) { SDL_DFB_DEVICEDATA(_this); int index; @@ -81,7 +81,7 @@ FocusAllMice(_THIS, SDL_WindowID id) static void -FocusAllKeyboards(_THIS, SDL_WindowID id) +FocusAllKeyboards(_THIS, SDL_Window *window) { SDL_DFB_DEVICEDATA(_this); int index; @@ -177,7 +177,7 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags, break; case DWET_MOTION: if (ClientXY(p, &evt->x, &evt->y)) { - SDL_Window *window = SDL_GetWindowFromID(p->sdl_id); + SDL_Window *window = p->window; if (!devdata->use_linux_input) { if (!(flags & SDL_WINDOW_INPUT_GRABBED)) SDL_SendMouseMotion(devdata->mouse_id[0], 0, @@ -193,7 +193,7 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags, } } if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) - SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_ENTER, 0, + SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_ENTER, 0, 0); } break; @@ -218,13 +218,13 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags, break; case DWET_POSITION: if (ClientXY(p, &evt->x, &evt->y)) { - SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_MOVED, + SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_MOVED, evt->x, evt->y); } break; case DWET_POSITION_SIZE: if (ClientXY(p, &evt->x, &evt->y)) { - SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_MOVED, + SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_MOVED, evt->x, evt->y); } /* fall throught */ @@ -234,32 +234,32 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags, evt->h -= (p->theme.top_size + p->theme.bottom_size + p->theme.caption_size); - SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_RESIZED, + SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_RESIZED, evt->w, evt->h); break; case DWET_CLOSE: - SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_CLOSE, 0, 0); + SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_CLOSE, 0, 0); break; case DWET_GOTFOCUS: - DirectFB_SetContext(_this, p->sdl_id); - FocusAllKeyboards(_this, p->sdl_id); - SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_FOCUS_GAINED, + DirectFB_SetContext(_this, p->window); + FocusAllKeyboards(_this, p->window); + SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); break; case DWET_LOSTFOCUS: - SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); + SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); FocusAllKeyboards(_this, 0); break; case DWET_ENTER: /* SDL_DirectFB_ReshowCursor(_this, 0); */ - FocusAllMice(_this, p->sdl_id); + FocusAllMice(_this, p->window); // FIXME: when do we really enter ? if (ClientXY(p, &evt->x, &evt->y)) MotionAllMice(_this, evt->x, evt->y); - SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_ENTER, 0, 0); + SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_ENTER, 0, 0); break; case DWET_LEAVE: - SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_LEAVE, 0, 0); + SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_LEAVE, 0, 0); FocusAllMice(_this, 0); /* SDL_DirectFB_ReshowCursor(_this, 1); */ break; @@ -372,16 +372,16 @@ DirectFB_PumpEventsWindow(_THIS) SDL_DFB_DEVICEDATA(_this); DFB_WindowData *p; DFBInputEvent ievt; - Sint32 /* SDL_WindowID */ grabbed_window; + SDL_Window *grabbed_window; - grabbed_window = -1; + grabbed_window = NULL; for (p = devdata->firstwin; p != NULL; p = p->next) { DFBWindowEvent evt; - SDL_Window *w = SDL_GetWindowFromID(p->sdl_id); + SDL_Window *w = SDL_GetWindowFromID(p->window); if (w->flags & SDL_WINDOW_INPUT_GRABBED) { - grabbed_window = p->sdl_id; + grabbed_window = w; } while (p->eventbuffer->GetEvent(p->eventbuffer, diff --git a/src/video/directfb/SDL_DirectFB_mouse.c b/src/video/directfb/SDL_DirectFB_mouse.c index e859d2a79..07f60d69a 100644 --- a/src/video/directfb/SDL_DirectFB_mouse.c +++ b/src/video/directfb/SDL_DirectFB_mouse.c @@ -31,7 +31,7 @@ static SDL_Cursor *DirectFB_CreateCursor(SDL_Surface * surface, static int DirectFB_ShowCursor(SDL_Cursor * cursor); static void DirectFB_MoveCursor(SDL_Cursor * cursor); static void DirectFB_FreeCursor(SDL_Cursor * cursor); -static void DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID, +static void DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y); static void DirectFB_FreeMouse(SDL_Mouse * mouse); @@ -159,14 +159,13 @@ DirectFB_ShowCursor(SDL_Cursor * cursor) { SDL_DFB_CURSORDATA(cursor); DFBResult ret; - SDL_WindowID wid; + SDL_Window *window; - wid = SDL_GetFocusWindow(); - if (wid <= 0) + window = SDL_GetFocusWindow(); + if (!window) return -1; else { - SDL_Window *window = SDL_GetWindowFromID(wid); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; if (display) { DFB_DisplayData *dispdata = @@ -216,10 +215,9 @@ DirectFB_FreeCursor(SDL_Cursor * cursor) /* Warp the mouse to (x,y) */ static void -DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y) +DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y) { - SDL_Window *window = SDL_GetWindowFromID(windowID); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; DFB_WindowData *windata = (DFB_WindowData *) window->driverdata; DFBResult ret; diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index ee4221404..1c1352ba2 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -280,7 +280,7 @@ SDL_Renderer * DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags) { SDL_DFB_WINDOWDATA(window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_Renderer *renderer = NULL; DirectFB_RenderData *data = NULL; DFBResult ret; @@ -313,7 +313,7 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = DirectFB_DestroyTexture; renderer->DestroyRenderer = DirectFB_DestroyRenderer; renderer->info = DirectFB_RenderDriver.info; - renderer->window = window->id; /* SDL window id */ + renderer->window = window; /* SDL window */ renderer->driverdata = data; renderer->info.flags = @@ -446,7 +446,7 @@ DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture) { SDL_DFB_RENDERERDATA(renderer); SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DFB_DEVICEDATA(display->device); DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; DirectFB_TextureData *data = texture->driverdata; @@ -502,7 +502,7 @@ static int DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DFB_DEVICEDATA(display->device); DirectFB_TextureData *data; DFBResult ret; diff --git a/src/video/directfb/SDL_DirectFB_window.c b/src/video/directfb/SDL_DirectFB_window.c index ae0cb558d..75c14d9b9 100644 --- a/src/video/directfb/SDL_DirectFB_window.c +++ b/src/video/directfb/SDL_DirectFB_window.c @@ -140,7 +140,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window) windata->window->RaiseToTop(windata->window); /* remember parent */ - windata->sdl_id = window->id; + windata->window = window; /* Add to list ... */ diff --git a/src/video/directfb/SDL_DirectFB_window.h b/src/video/directfb/SDL_DirectFB_window.h index df12515ee..175c5774a 100644 --- a/src/video/directfb/SDL_DirectFB_window.h +++ b/src/video/directfb/SDL_DirectFB_window.h @@ -36,7 +36,7 @@ struct _DFB_WindowData IDirectFBWindow *window; DirectFB_GLContext *gl_context; IDirectFBEventBuffer *eventbuffer; - SDL_WindowID sdl_id; + SDL_Window *window; DFB_WindowData *next; Uint8 opacity; DFBRectangle client; diff --git a/src/video/dummy/SDL_nullrender.c b/src/video/dummy/SDL_nullrender.c index dfa1022b0..1973fe48f 100644 --- a/src/video/dummy/SDL_nullrender.c +++ b/src/video/dummy/SDL_nullrender.c @@ -74,7 +74,7 @@ typedef struct SDL_Renderer * SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayMode *displayMode = &display->current_mode; SDL_Renderer *renderer; SDL_DUMMY_RenderData *data; @@ -113,7 +113,7 @@ SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; renderer->info.name = SDL_DUMMY_RenderDriver.info.name; renderer->info.flags = 0; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; Setup_SoftwareRenderer(renderer); @@ -238,8 +238,8 @@ SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, { SDL_DUMMY_RenderData *data = (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { SDL_Surface *target = data->screens[data->current_screen]; @@ -266,8 +266,8 @@ SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, { SDL_DUMMY_RenderData *data = (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; SDL_Surface *screen = data->screens[data->current_screen]; Uint32 screen_format = display->current_mode.format; Uint8 *screen_pixels = (Uint8 *) screen->pixels + @@ -286,8 +286,8 @@ SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, { SDL_DUMMY_RenderData *data = (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; SDL_Surface *screen = data->screens[data->current_screen]; Uint32 screen_format = display->current_mode.format; Uint8 *screen_pixels = (Uint8 *) screen->pixels + @@ -311,7 +311,7 @@ SDL_DUMMY_RenderPresent(SDL_Renderer * renderer) if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) { char file[128]; SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp", - renderer->window, ++frame_number); + renderer->window->id, ++frame_number); SDL_SaveBMP(data->screens[data->current_screen], file); } diff --git a/src/video/nds/SDL_ndsrender.c b/src/video/nds/SDL_ndsrender.c index a24b50ba5..fcf91d53d 100644 --- a/src/video/nds/SDL_ndsrender.c +++ b/src/video/nds/SDL_ndsrender.c @@ -126,7 +126,7 @@ typedef struct SDL_Renderer * NDS_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayMode *displayMode = &display->current_mode; SDL_Renderer *renderer; NDS_RenderData *data; @@ -175,7 +175,7 @@ NDS_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyRenderer = NDS_DestroyRenderer; renderer->info.name = NDS_RenderDriver.info.name; renderer->info.flags = 0; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; renderer->CreateTexture = NDS_CreateTexture; renderer->QueryTexturePixels = NDS_QueryTexturePixels; @@ -490,8 +490,8 @@ NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, { NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; int Bpp = SDL_BYTESPERPIXEL(texture->format); if (txdat->type == NDSTX_BG) { @@ -515,8 +515,8 @@ static void NDS_RenderPresent(SDL_Renderer * renderer) { NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; /* update sprites */ // NDS_OAM_Update(&(data->oam_copy), data->sub); @@ -538,8 +538,6 @@ static void NDS_DestroyRenderer(SDL_Renderer * renderer) { NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); int i; if (data) { diff --git a/src/video/pandora/SDL_pandora.c b/src/video/pandora/SDL_pandora.c index 4547a0a5d..12f80d277 100644 --- a/src/video/pandora/SDL_pandora.c +++ b/src/video/pandora/SDL_pandora.c @@ -417,7 +417,7 @@ PND_gl_createcontext(_THIS, SDL_Window * window) SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; EGLBoolean status; int32_t gfstatus; EGLint configs; @@ -816,7 +816,7 @@ PND_gl_swapwindow(_THIS, SDL_Window * window) SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; if (phdata->egl_initialized != SDL_TRUE) { diff --git a/src/video/photon/SDL_photon.c b/src/video/photon/SDL_photon.c index ffb121b90..62c19caf2 100644 --- a/src/video/photon/SDL_photon.c +++ b/src/video/photon/SDL_photon.c @@ -777,7 +777,7 @@ photon_createwindow(_THIS, SDL_Window * window) { SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; SDL_WindowData *wdata; PhDim_t winsize; PhPoint_t winpos; @@ -997,7 +997,7 @@ photon_createwindow(_THIS, SDL_Window * window) PtFlush(); /* By default last created window got a input focus */ - SDL_SetKeyboardFocus(0, window->id); + SDL_SetKeyboardFocus(0, window); /* Emit focus gained event, because photon is not sending it */ SDL_OnWindowFocusGained(window); @@ -1055,7 +1055,7 @@ photon_setwindowposition(_THIS, SDL_Window * window) { SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; PhPoint_t winpos; int32_t status; @@ -1223,7 +1223,7 @@ photon_destroywindow(_THIS, SDL_Window * window) { SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; int32_t status; @@ -1414,7 +1414,7 @@ photon_gl_createcontext(_THIS, SDL_Window * window) SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; EGLBoolean status; int32_t gfstatus; EGLint configs; @@ -1941,7 +1941,7 @@ photon_gl_swapwindow(_THIS, SDL_Window * window) SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; PhRect_t dst_rect; PhRect_t src_rect; int32_t status; @@ -2050,7 +2050,7 @@ int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; SDL_bool makecurrent=SDL_FALSE; int32_t gfstatus; @@ -2199,10 +2199,10 @@ photon_pumpevents(_THIS) { /* Mouse cursor over handled window */ if (window != NULL) { - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_ENTER, 0, 0); - SDL_SetMouseFocus(0, window->id); + SDL_SetMouseFocus(0, window); } } break; @@ -2210,7 +2210,7 @@ photon_pumpevents(_THIS) { /* Mouse cursor out of handled window */ if (window != NULL) { - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_LEAVE, 0, 0); } @@ -2682,7 +2682,7 @@ photon_pumpevents(_THIS) case Ph_WM_CLOSE: { if (window != NULL) { - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0, 0); } @@ -2695,10 +2695,10 @@ photon_pumpevents(_THIS) if (window != NULL) { PhRegion_t wregion; - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); - SDL_SetKeyboardFocus(0, window->id); + SDL_SetKeyboardFocus(0, window); /* Set window region sensible to mouse motion events */ PhRegionQuery(PtWidgetRid @@ -2712,7 +2712,7 @@ photon_pumpevents(_THIS) &wregion, NULL, NULL); /* If window got a focus, then it is visible */ - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0); } @@ -2722,7 +2722,7 @@ photon_pumpevents(_THIS) if (window != NULL) { PhRegion_t wregion; - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); @@ -2743,7 +2743,7 @@ photon_pumpevents(_THIS) case Ph_WM_MOVE: { if (window != NULL) { - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, wmevent->pos.x, wmevent->pos.y); @@ -2754,7 +2754,7 @@ photon_pumpevents(_THIS) { if (window != NULL) { /* Set new window position after resize */ - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, wmevent->pos.x, wmevent->pos.y); @@ -2766,7 +2766,7 @@ photon_pumpevents(_THIS) } /* Set new window size after resize */ - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, wmevent->size.w, wmevent->size.h); @@ -2777,11 +2777,11 @@ photon_pumpevents(_THIS) { if (window != NULL) { /* Send new window state: minimized */ - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); /* In case window is minimized, then it is hidden */ - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIDDEN, 0, 0); } @@ -2792,7 +2792,7 @@ photon_pumpevents(_THIS) if (window != NULL) { if ((window->flags & SDL_WINDOW_RESIZABLE)==SDL_WINDOW_RESIZABLE) { - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); } @@ -2806,7 +2806,7 @@ photon_pumpevents(_THIS) case Ph_WM_RESTORE: { if (window != NULL) { - SDL_SendWindowEvent(window->id, + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); } diff --git a/src/video/photon/SDL_photon_input.c b/src/video/photon/SDL_photon_input.c index 853851dbb..dbd64af3e 100644 --- a/src/video/photon/SDL_photon_input.c +++ b/src/video/photon/SDL_photon_input.c @@ -38,7 +38,7 @@ SDL_Cursor *photon_createcursor(SDL_Surface * surface, int hot_x, int hot_y); int photon_showcursor(SDL_Cursor * cursor); void photon_movecursor(SDL_Cursor * cursor); void photon_freecursor(SDL_Cursor * cursor); -void photon_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y); +void photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y); void photon_freemouse(SDL_Mouse * mouse); int32_t @@ -228,13 +228,12 @@ photon_showcursor(SDL_Cursor * cursor) SDL_DisplayData *didata; SDL_Window *window; SDL_WindowData *wdata; - SDL_WindowID window_id; PhCursorDef_t *internal_cursor; int32_t status; /* Get current window id */ - window_id = SDL_GetFocusWindow(); - if (window_id <= 0) { + window = SDL_GetFocusWindow(); + if (!window) { SDL_MouseData *mdata = NULL; /* If there is no current window, then someone calls this function */ @@ -264,17 +263,12 @@ photon_showcursor(SDL_Cursor * cursor) } } else { /* Sanity checks */ - window = SDL_GetWindowFromID(window_id); - if (window != NULL) { - display = SDL_GetDisplayFromWindow(window); - if (display != NULL) { - didata = (SDL_DisplayData *) display->driverdata; - if (didata != NULL) { - wdata = (SDL_WindowData *) window->driverdata; - if (wdata == NULL) { - return -1; - } - } else { + display = window->display; + if (display != NULL) { + didata = (SDL_DisplayData *) display->driverdata; + if (didata != NULL) { + wdata = (SDL_WindowData *) window->driverdata; + if (wdata == NULL) { return -1; } } else { @@ -379,7 +373,7 @@ photon_movecursor(SDL_Cursor * cursor) /* Sanity checks */ window = SDL_GetWindowFromID(window_id); if (window != NULL) { - display = SDL_GetDisplayFromWindow(window); + display = window->display; if (display != NULL) { didata = (SDL_DisplayData *) display->driverdata; if (didata != NULL) { @@ -418,19 +412,17 @@ photon_freecursor(SDL_Cursor * cursor) } void -photon_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y) +photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y) { SDL_VideoDisplay *display; SDL_DisplayData *didata; - SDL_Window *window; SDL_WindowData *wdata; int16_t wx; int16_t wy; /* Sanity checks */ - window = SDL_GetWindowFromID(windowID); if (window != NULL) { - display = SDL_GetDisplayFromWindow(window); + display = window->display; if (display != NULL) { didata = (SDL_DisplayData *) display->driverdata; if (didata != NULL) { diff --git a/src/video/photon/SDL_photon_render.c b/src/video/photon/SDL_photon_render.c index f6da261d0..b7dae46e1 100644 --- a/src/video/photon/SDL_photon_render.c +++ b/src/video/photon/SDL_photon_render.c @@ -124,7 +124,7 @@ SDL_RenderDriver photon_renderdriver = { static SDL_Renderer * photon_createrenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_Renderer *renderer = NULL; @@ -171,7 +171,7 @@ photon_createrenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = photon_destroytexture; renderer->DestroyRenderer = photon_destroyrenderer; renderer->info = photon_renderdriver.info; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = rdata; /* Copy direct_mode status */ @@ -298,7 +298,7 @@ static int _photon_recreate_surfaces(SDL_Renderer * renderer) /* Obtain window and display structures */ window=SDL_GetWindowFromID(renderer->window); wdata=(SDL_WindowData*)window->driverdata; - display=SDL_GetDisplayFromWindow(window); + display=window->display; didata=(SDL_DisplayData *) display->driverdata; phdata=(SDL_VideoData *) display->device->driverdata; @@ -723,7 +723,7 @@ photon_displaymodechanged(SDL_Renderer * renderer) { SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; /* Copy direct_mode status */ @@ -738,7 +738,7 @@ photon_createtexture(SDL_Renderer * renderer, SDL_Texture * texture) { SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; SDL_TextureData *tdata = NULL; uint32_t it; diff --git a/src/video/ps3/SDL_ps3render.c b/src/video/ps3/SDL_ps3render.c index b4a93d710..52ea07f71 100644 --- a/src/video/ps3/SDL_ps3render.c +++ b/src/video/ps3/SDL_ps3render.c @@ -133,7 +133,7 @@ SDL_Renderer * SDL_PS3_CreateRenderer(SDL_Window * window, Uint32 flags) { deprintf(1, "+SDL_PS3_CreateRenderer()\n"); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayMode *displayMode = &display->current_mode; SDL_VideoData *devdata = display->device->driverdata; SDL_Renderer *renderer; @@ -179,7 +179,7 @@ SDL_PS3_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyRenderer = SDL_PS3_DestroyRenderer; renderer->info.name = SDL_PS3_RenderDriver.info.name; renderer->info.flags = 0; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; deprintf(1, "window->w = %u\n", window->w); @@ -518,7 +518,7 @@ SDL_PS3_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, SDL_PS3_RenderData *data = (SDL_PS3_RenderData *) renderer->driverdata; SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; PS3_TextureData *txdata = (PS3_TextureData *) texture->driverdata; SDL_VideoData *devdata = display->device->driverdata; @@ -640,7 +640,7 @@ SDL_PS3_RenderPresent(SDL_Renderer * renderer) SDL_PS3_RenderData *data = (SDL_PS3_RenderData *) renderer->driverdata; SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_VideoData *devdata = display->device->driverdata; /* Send the data to the screen */ diff --git a/src/video/qnxgf/SDL_gf_input.c b/src/video/qnxgf/SDL_gf_input.c index e747ad743..156f5758d 100644 --- a/src/video/qnxgf/SDL_gf_input.c +++ b/src/video/qnxgf/SDL_gf_input.c @@ -41,7 +41,7 @@ SDL_Cursor *gf_createcursor(SDL_Surface * surface, int hot_x, int hot_y); int gf_showcursor(SDL_Cursor * cursor); void gf_movecursor(SDL_Cursor * cursor); void gf_freecursor(SDL_Cursor * cursor); -void gf_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y); +void gf_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y); void gf_freemouse(SDL_Mouse * mouse); /* HIDDI interacting functions */ @@ -278,7 +278,7 @@ gf_showcursor(SDL_Cursor * cursor) /* Sanity checks */ window = SDL_GetWindowFromID(window_id); if (window != NULL) { - display = SDL_GetDisplayFromWindow(window); + display = window->display; if (display != NULL) { didata = (SDL_DisplayData *) display->driverdata; if (didata == NULL) { @@ -399,7 +399,7 @@ gf_movecursor(SDL_Cursor * cursor) /* Sanity checks */ window = SDL_GetWindowFromID(window_id); if (window != NULL) { - display = SDL_GetDisplayFromWindow(window); + display = window->display; if (display != NULL) { didata = (SDL_DisplayData *) display->driverdata; if (didata == NULL) { @@ -461,19 +461,17 @@ gf_freecursor(SDL_Cursor * cursor) } void -gf_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y) +gf_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y) { SDL_VideoDisplay *display; SDL_DisplayData *didata; - SDL_Window *window; uint32_t xmax; uint32_t ymax; int32_t status; /* Sanity checks */ - window = SDL_GetWindowFromID(windowID); if (window != NULL) { - display = SDL_GetDisplayFromWindow(window); + display = window->display; if (display != NULL) { didata = (SDL_DisplayData *) display->driverdata; if (didata == NULL) { @@ -495,7 +493,7 @@ gf_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y) } /* Get window size to clamp maximum coordinates */ - SDL_GetWindowSize(windowID, &xmax, &ymax); + SDL_GetWindowSize(window, &xmax, &ymax); if (x >= xmax) { x = xmax - 1; } diff --git a/src/video/qnxgf/SDL_gf_render.c b/src/video/qnxgf/SDL_gf_render.c index 4d4442f32..5e933b38e 100644 --- a/src/video/qnxgf/SDL_gf_render.c +++ b/src/video/qnxgf/SDL_gf_render.c @@ -110,7 +110,7 @@ SDL_RenderDriver gf_renderdriver = { static SDL_Renderer * gf_createrenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_Renderer *renderer = NULL; @@ -162,7 +162,7 @@ gf_createrenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = gf_destroytexture; renderer->DestroyRenderer = gf_destroyrenderer; renderer->info = gf_renderdriver.info; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = rdata; /* Set render acceleration flag in case it is accelerated */ @@ -284,7 +284,7 @@ static int gf_activaterenderer(SDL_Renderer * renderer) { SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(rdata->window); + SDL_VideoDisplay *display = rdata->window->display; SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; /* Setup current surface as visible */ @@ -301,7 +301,7 @@ gf_createtexture(SDL_Renderer * renderer, SDL_Texture * texture) { SDL_RenderData *renderdata = (SDL_RenderData *) renderer->driverdata; SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_TextureData *tdata = NULL; /* Allocate texture driver data */ diff --git a/src/video/qnxgf/SDL_qnxgf.c b/src/video/qnxgf/SDL_qnxgf.c index d8092dca2..6597b1360 100644 --- a/src/video/qnxgf/SDL_qnxgf.c +++ b/src/video/qnxgf/SDL_qnxgf.c @@ -978,7 +978,7 @@ int qnxgf_createwindow(_THIS, SDL_Window * window) { SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; SDL_WindowData *wdata; int32_t status; @@ -1081,8 +1081,8 @@ qnxgf_createwindow(_THIS, SDL_Window * window) hiddi_enable_mouse(); /* By default last created window got a input focus */ - SDL_SetKeyboardFocus(0, window->id); - SDL_SetMouseFocus(0, window->id); + SDL_SetKeyboardFocus(0, window); + SDL_SetMouseFocus(0, window); /* Window has been successfully created */ return 0; @@ -1155,7 +1155,7 @@ qnxgf_destroywindow(_THIS, SDL_Window * window) { SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; if (wdata != NULL) { @@ -1309,7 +1309,7 @@ qnxgf_gl_createcontext(_THIS, SDL_Window * window) SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; EGLBoolean status; int32_t gfstatus; EGLint configs; diff --git a/src/video/uikit/SDL_uikitappdelegate.h b/src/video/uikit/SDL_uikitappdelegate.h index 704b7f81f..fe65c5a39 100644 --- a/src/video/uikit/SDL_uikitappdelegate.h +++ b/src/video/uikit/SDL_uikitappdelegate.h @@ -25,12 +25,12 @@ /* *INDENT-OFF* */ @interface SDLUIKitDelegate:NSObject { - UIWindow *window; - SDL_WindowID windowID; + SDL_Window *window; + UIWindow *uiwindow; } -@property (readwrite, retain) UIWindow *window; -@property (readwrite, assign) SDL_WindowID windowID; +@property (readwrite, assign) SDL_Window *window; +@property (readwrite, retain) UIWindow *uiwindow; +(SDLUIKitDelegate *)sharedAppDelegate; diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index f8ece0faa..865e3d3e4 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -56,7 +56,7 @@ int main(int argc, char **argv) { @implementation SDLUIKitDelegate @synthesize window; -@synthesize windowID; +@synthesize uiwindow; /* convenience method */ +(SDLUIKitDelegate *)sharedAppDelegate { @@ -66,8 +66,8 @@ +(SDLUIKitDelegate *)sharedAppDelegate { - (id)init { self = [super init]; - window = nil; - windowID = 0; + window = NULL; + uiwindow = nil; return self; } @@ -107,19 +107,19 @@ - (void)applicationWillTerminate:(UIApplication *)application { - (void) applicationWillResignActive:(UIApplication*)application { // NSLog(@"%@", NSStringFromSelector(_cmd)); - SDL_SendWindowEvent(self.windowID, SDL_WINDOWEVENT_MINIMIZED, 0, 0); + SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } - (void) applicationDidBecomeActive:(UIApplication*)application { // NSLog(@"%@", NSStringFromSelector(_cmd)); - SDL_SendWindowEvent(self.windowID, SDL_WINDOWEVENT_RESTORED, 0, 0); + SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_RESTORED, 0, 0); } -(void)dealloc { - [window release]; + [uiwindow release]; [super dealloc]; } diff --git a/src/video/uikit/SDL_uikitkeyboard.h b/src/video/uikit/SDL_uikitkeyboard.h index 7ffd32a10..7208b7fdb 100644 --- a/src/video/uikit/SDL_uikitkeyboard.h +++ b/src/video/uikit/SDL_uikitkeyboard.h @@ -23,10 +23,9 @@ #ifndef sdl_uikitkeyboard_h #define sdl_uikitkeyboard_h -extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_WindowID windowID); -extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_WindowID windowID); -extern DECLSPEC SDL_bool SDLCALL SDL_iPhoneKeyboardIsShown(SDL_WindowID - windowID); -extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_WindowID windowID); +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_Window * window); +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_Window * window); +extern DECLSPEC SDL_bool SDLCALL SDL_iPhoneKeyboardIsShown(SDL_Window * window); +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_Window * window); #endif diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index d59fd3ff8..e3dc19ec7 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -272,9 +272,8 @@ - (BOOL)textFieldShouldReturn:(UITextField*)_textField { /* iPhone keyboard addition functions */ #if SDL_IPHONE_KEYBOARD -int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) { +int SDL_iPhoneKeyboardShow(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); SDL_WindowData *data; SDL_uikitview *view; @@ -296,9 +295,8 @@ int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) { } } -int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) { +int SDL_iPhoneKeyboardHide(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); SDL_WindowData *data; SDL_uikitview *view; @@ -320,9 +318,8 @@ int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) { } } -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) { +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); SDL_WindowData *data; SDL_uikitview *view; @@ -343,9 +340,8 @@ SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) { } } -int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) { +int SDL_iPhoneKeyboardToggle(SDL_Window * window) { - SDL_Window *window = SDL_GetWindowFromID(windowID); SDL_WindowData *data; SDL_uikitview *view; @@ -362,11 +358,11 @@ int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) { return -1; } else { - if (SDL_iPhoneKeyboardIsShown(windowID)) { - SDL_iPhoneKeyboardHide(windowID); + if (SDL_iPhoneKeyboardIsShown(window)) { + SDL_iPhoneKeyboardHide(window); } else { - SDL_iPhoneKeyboardShow(windowID); + SDL_iPhoneKeyboardShow(window); } return 0; } @@ -376,21 +372,21 @@ int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) { /* stubs, used if compiled without keyboard support */ -int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) { +int SDL_iPhoneKeyboardShow(SDL_Window * window) { SDL_SetError("Not compiled with keyboard support"); return -1; } -int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) { +int SDL_iPhoneKeyboardHide(SDL_Window * window) { SDL_SetError("Not compiled with keyboard support"); return -1; } -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) { +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { return 0; } -int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) { +int SDL_iPhoneKeyboardToggle(SDL_Window * window) { SDL_SetError("Not compiled with keyboard support"); return -1; } diff --git a/src/video/uikit/SDL_uikitwindow.h b/src/video/uikit/SDL_uikitwindow.h index 92e4b77ed..0a8d75a21 100644 --- a/src/video/uikit/SDL_uikitwindow.h +++ b/src/video/uikit/SDL_uikitwindow.h @@ -36,7 +36,7 @@ extern void UIKit_DestroyWindow(_THIS, SDL_Window * window); struct SDL_WindowData { - SDL_WindowID windowID; + SDL_Window *window; UIWindow *uiwindow; SDL_uikitopenglview *view; }; diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 71d22023e..252b2f5f1 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -41,83 +41,82 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) { SDL_WindowData *data; - + /* Allocate the window data */ data = (SDL_WindowData *)SDL_malloc(sizeof(*data)); if (!data) { SDL_OutOfMemory(); return -1; } - data->windowID = window->id; + data->window = window; data->uiwindow = uiwindow; - data->view = nil; - + data->view = nil; + /* Fill in the SDL window with the window data */ - { + { window->x = 0; window->y = 0; window->w = (int)uiwindow.frame.size.width; window->h = (int)uiwindow.frame.size.height; } - - window->driverdata = data; - - window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */ - window->flags |= SDL_WINDOW_OPENGL; /* window is always OpenGL */ - window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */ - window->flags |= SDL_WINDOW_SHOWN; /* only one window on iPod touch, always shown */ - window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ - - /* SDL_WINDOW_BORDERLESS controls whether status bar is hidden */ - if (window->flags & SDL_WINDOW_BORDERLESS) { - [UIApplication sharedApplication].statusBarHidden = YES; - } - else { - [UIApplication sharedApplication].statusBarHidden = NO; - } - + + window->driverdata = data; + + window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */ + window->flags |= SDL_WINDOW_OPENGL; /* window is always OpenGL */ + window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */ + window->flags |= SDL_WINDOW_SHOWN; /* only one window on iPod touch, always shown */ + window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ + + /* SDL_WINDOW_BORDERLESS controls whether status bar is hidden */ + if (window->flags & SDL_WINDOW_BORDERLESS) { + [UIApplication sharedApplication].statusBarHidden = YES; + } + else { + [UIApplication sharedApplication].statusBarHidden = NO; + } + return 0; - + } int UIKit_CreateWindow(_THIS, SDL_Window *window) { - - /* We currently only handle single window applications on iPhone */ - if (nil != [SDLUIKitDelegate sharedAppDelegate].window) { - SDL_SetError("Window already exists, no multi-window support."); - return -1; - } - - /* ignore the size user requested, and make a fullscreen window */ - UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - - if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) { + + /* We currently only handle single window applications on iPhone */ + if (nil != [SDLUIKitDelegate sharedAppDelegate].window) { + SDL_SetError("Window already exists, no multi-window support."); + return -1; + } + + /* ignore the size user requested, and make a fullscreen window */ + UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + + if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) { [uiwindow release]; return -1; - } - - // This saves the main window in the app delegate so event callbacks can do stuff on the window. - // This assumes a single window application design and needs to be fixed for multiple windows. - [SDLUIKitDelegate sharedAppDelegate].window = uiwindow; - [SDLUIKitDelegate sharedAppDelegate].windowID = window->id; - [uiwindow release]; /* release the window (the app delegate has retained it) */ - - return 1; - + } + + // This saves the main window in the app delegate so event callbacks can do stuff on the window. + // This assumes a single window application design and needs to be fixed for multiple windows. + [SDLUIKitDelegate sharedAppDelegate].window = window; + [SDLUIKitDelegate sharedAppDelegate].uiwindow = uiwindow; + [uiwindow release]; /* release the window (the app delegate has retained it) */ + + return 1; + } void UIKit_DestroyWindow(_THIS, SDL_Window * window) { - /* don't worry, the delegate will automatically release the window */ - - SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - if (data) { - SDL_free( window->driverdata ); - } - - /* this will also destroy the window */ - [SDLUIKitDelegate sharedAppDelegate].window = nil; - [SDLUIKitDelegate sharedAppDelegate].windowID = 0; + /* don't worry, the delegate will automatically release the window */ + + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + if (data) { + SDL_free( window->driverdata ); + } + /* this will also destroy the window */ + [SDLUIKitDelegate sharedAppDelegate].window = NULL; + [SDLUIKitDelegate sharedAppDelegate].uiwindow = nil; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_ceddrawrender.c b/src/video/win32/SDL_ceddrawrender.c index 424a313ee..ccdbb43fa 100644 --- a/src/video/win32/SDL_ceddrawrender.c +++ b/src/video/win32/SDL_ceddrawrender.c @@ -391,7 +391,7 @@ DDRAW_AddRenderDriver(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_RendererInfo *info = &DDRAW_RenderDriver.info; - SDL_DisplayMode *mode = &SDL_CurrentDisplay.desktop_mode; + SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; if (data->ddraw) { int i; @@ -437,7 +437,7 @@ DDRAW_AddRenderDriver(_THIS) SDL_Renderer * DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata; SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; SDL_Renderer *renderer; @@ -479,7 +479,7 @@ DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = DDRAW_DestroyTexture; renderer->DestroyRenderer = DDRAW_DestroyRenderer; renderer->info = DDRAW_RenderDriver.info; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; renderer->info.flags = SDL_RENDERER_ACCELERATED; @@ -568,8 +568,8 @@ DDRAW_DisplayModeChanged(SDL_Renderer * renderer) { //TODO implement /*D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; data->pparams.BackBufferWidth = window->w; data->pparams.BackBufferHeight = window->h; @@ -587,8 +587,8 @@ static int DDRAW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { DDRAW_RenderData *renderdata = (DDRAW_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; Uint32 display_format = display->current_mode.format; DDRAW_TextureData *data; DDSURFACEDESC ddsd; diff --git a/src/video/win32/SDL_d3drender.c b/src/video/win32/SDL_d3drender.c index 83f910c57..3afbaa77f 100644 --- a/src/video/win32/SDL_d3drender.c +++ b/src/video/win32/SDL_d3drender.c @@ -427,7 +427,7 @@ D3D_AddRenderDriver(_THIS) SDL_Renderer * D3D_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata; SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; SDL_Renderer *renderer; @@ -475,7 +475,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = D3D_DestroyTexture; renderer->DestroyRenderer = D3D_DestroyRenderer; renderer->info = D3D_RenderDriver.info; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; renderer->info.flags = SDL_RENDERER_ACCELERATED; @@ -677,8 +677,8 @@ static int D3D_DisplayModeChanged(SDL_Renderer * renderer) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; data->pparams.BackBufferWidth = window->w; data->pparams.BackBufferHeight = window->h; @@ -695,8 +695,8 @@ static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; Uint32 display_format = display->current_mode.format; D3D_TextureData *data; HRESULT result; @@ -1398,8 +1398,8 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 format, void * pixels, int pitch) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; D3DSURFACE_DESC desc; LPDIRECT3DSURFACE9 backBuffer; LPDIRECT3DSURFACE9 surface; diff --git a/src/video/win32/SDL_gapirender.c b/src/video/win32/SDL_gapirender.c index b1af3a90f..257d5282c 100644 --- a/src/video/win32/SDL_gapirender.c +++ b/src/video/win32/SDL_gapirender.c @@ -430,7 +430,7 @@ GetFramebuffer() SDL_Renderer * GAPI_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; SDL_DisplayMode *displayMode = &display->current_mode; SDL_Renderer *renderer; @@ -472,7 +472,7 @@ GAPI_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyRenderer = GAPI_DestroyRenderer; renderer->info.name = GAPI_RenderDriver.info.name; renderer->info.flags = 0; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; /* Gapi provides only a framebuffer so lets use software implementation */ diff --git a/src/video/win32/SDL_gdirender.c b/src/video/win32/SDL_gdirender.c index 07766043f..9df73f891 100644 --- a/src/video/win32/SDL_gdirender.c +++ b/src/video/win32/SDL_gdirender.c @@ -207,7 +207,7 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = GDI_DestroyTexture; renderer->DestroyRenderer = GDI_DestroyRenderer; renderer->info = GDI_RenderDriver.info; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; renderer->info.flags = SDL_RENDERER_ACCELERATED; @@ -274,7 +274,7 @@ static int GDI_DisplayModeChanged(SDL_Renderer * renderer) { GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; int i, n; if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) { @@ -378,8 +378,8 @@ static int GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; GDI_TextureData *data; data = (GDI_TextureData *) SDL_calloc(1, sizeof(*data)); @@ -699,7 +699,7 @@ GDI_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, if (data->makedirty) { /* Get the smallest rectangle that contains everything */ - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_Rect rect; rect.x = 0; @@ -732,7 +732,7 @@ GDI_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, if (data->makedirty) { /* Get the smallest rectangle that contains everything */ - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_Rect clip, rect; clip.x = 0; @@ -787,7 +787,7 @@ GDI_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int i, status = 1; if (data->makedirty) { - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_Rect clip, rect; clip.x = 0; @@ -844,7 +844,7 @@ GDI_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int i, status = 1; if (data->makedirty) { - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_Rect clip, rect; clip.x = 0; @@ -943,8 +943,8 @@ GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 format, void * pixels, int pitch) { GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; struct { HBITMAP hbm; void *pixels; @@ -984,8 +984,8 @@ GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 format, const void * pixels, int pitch) { GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; struct { HBITMAP hbm; void *pixels; diff --git a/src/video/win32/SDL_win32events.c b/src/video/win32/SDL_win32events.c index b6aff45c0..e9b7a66f7 100644 --- a/src/video/win32/SDL_win32events.c +++ b/src/video/win32/SDL_win32events.c @@ -169,11 +169,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SHOWWINDOW: { if (wParam) { - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 0, - 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); } else { - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_HIDDEN, 0, - 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0); } } break; @@ -188,26 +186,25 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) index = data->videodata->keyboard; keyboard = SDL_GetKeyboard(index); if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, - 0, 0); - SDL_SendWindowEvent(data->windowID, + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0); #ifndef _WIN32_WCE /* WinCE misses IsZoomed() */ if (IsZoomed(hwnd)) { - SDL_SendWindowEvent(data->windowID, + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); } #endif - if (keyboard && keyboard->focus != data->windowID) { - SDL_SetKeyboardFocus(index, data->windowID); + if (keyboard && keyboard->focus != data->window) { + SDL_SetKeyboardFocus(index, data->window); } /* FIXME: Update keyboard state */ } else { - if (keyboard && keyboard->focus == data->windowID) { + if (keyboard && keyboard->focus == data->window) { SDL_SetKeyboardFocus(index, 0); } if (minimized) { - SDL_SendWindowEvent(data->windowID, + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } } @@ -272,9 +269,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) GetCursorPos(&point); ScreenToClient(hwnd, &point); - SDL_GetWindowSize(data->windowID, &w, &h); + SDL_GetWindowSize(data->window, &w, &h); if (point.x >= 0 && point.y >= 0 && point.x < w && point.y < h) { - SDL_SetMouseFocus(index, data->windowID); + SDL_SetMouseFocus(index, data->window); } else { SDL_SetMouseFocus(index, 0); /* FIXME: Should we be doing anything else here? */ @@ -330,7 +327,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) for (i = 0; i < SDL_GetNumMice(); ++i) { SDL_Mouse *mouse = SDL_GetMouse(i); - if (mouse->focus == data->windowID) { + if (mouse->focus == data->window) { SDL_SetMouseFocus(i, 0); } } @@ -490,7 +487,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) BOOL menu; /* If we allow resizing, let the resize happen naturally */ - if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_RESIZABLE) { + if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) { returnCode = 0; break; } @@ -501,7 +498,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) y = size.top; /* Calculate current size of our window */ - SDL_GetWindowSize(data->windowID, &w, &h); + SDL_GetWindowSize(data->window, &w, &h); size.top = 0; size.left = 0; size.bottom = h; @@ -551,7 +548,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ClientToScreen(hwnd, (LPPOINT) & rect); ClientToScreen(hwnd, (LPPOINT) & rect + 1); - window_flags = SDL_GetWindowFlags(data->windowID); + window_flags = SDL_GetWindowFlags(data->window); if ((window_flags & SDL_WINDOW_INPUT_GRABBED) && (window_flags & SDL_WINDOW_INPUT_FOCUS)) { ClipCursor(&rect); @@ -559,11 +556,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) x = rect.left; y = rect.top; - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MOVED, x, y); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y); w = rect.right - rect.left; h = rect.bottom - rect.top; - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESIZED, w, + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, w, h); } break; @@ -610,7 +607,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) RECT rect; if (GetUpdateRect(hwnd, &rect, FALSE)) { ValidateRect(hwnd, &rect); - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_EXPOSED, + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); } } @@ -637,7 +634,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_CLOSE: { - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_CLOSE, 0, 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); } returnCode = 0; break; diff --git a/src/video/win32/SDL_win32window.c b/src/video/win32/SDL_win32window.c index da2dc6576..895f6877d 100644 --- a/src/video/win32/SDL_win32window.c +++ b/src/video/win32/SDL_win32window.c @@ -86,7 +86,7 @@ static int SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) { SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_WindowData *data; /* Allocate the window data */ @@ -95,7 +95,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) SDL_OutOfMemory(); return -1; } - data->windowID = window->id; + data->window = window; data->hwnd = hwnd; data->hdc = GetDC(hwnd); data->created = created; @@ -167,7 +167,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) if (GetFocus() == hwnd) { int index = data->videodata->keyboard; window->flags |= SDL_WINDOW_INPUT_FOCUS; - SDL_SetKeyboardFocus(index, data->windowID); + SDL_SetKeyboardFocus(index, data->window); if (window->flags & SDL_WINDOW_INPUT_GRABBED) { RECT rect; @@ -187,7 +187,7 @@ int WIN_CreateWindow(_THIS, SDL_Window * window) { SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; RAWINPUTDEVICE Rid; AXIS TabX, TabY; LOGCONTEXTA lc; @@ -429,7 +429,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) void WIN_SetWindowPosition(_THIS, SDL_Window * window) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; RECT rect; SDL_Rect bounds; diff --git a/src/video/win32/SDL_win32window.h b/src/video/win32/SDL_win32window.h index bfd9670a6..8ad888e33 100644 --- a/src/video/win32/SDL_win32window.h +++ b/src/video/win32/SDL_win32window.h @@ -26,7 +26,7 @@ typedef struct { - SDL_WindowID windowID; + SDL_Window *window; HWND hwnd; HDC hdc; WNDPROC wndproc; diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index ee79f54fb..c88036f34 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -66,7 +66,7 @@ X11_DispatchEvent(_THIS) if (videodata && videodata->windowlist) { for (i = 0; i < videodata->numwindows; ++i) { if ((videodata->windowlist[i] != NULL) && - (videodata->windowlist[i]->window == xevent.xany.window)) { + (videodata->windowlist[i]->xwindow == xevent.xany.window)) { data = videodata->windowlist[i]; break; } @@ -97,7 +97,7 @@ X11_DispatchEvent(_THIS) /* FIXME: Should we reset data for all mice? */ for (i = 0; i < SDL_GetNumMice(); ++i) { SDL_Mouse *mouse = SDL_GetMouse(i); - SDL_SetMouseFocus(mouse->id, data->windowID); + SDL_SetMouseFocus(mouse->id, data->window); } #endif } @@ -132,7 +132,7 @@ X11_DispatchEvent(_THIS) #ifdef DEBUG_XEVENTS printf("FocusIn!\n"); #endif - SDL_SetKeyboardFocus(videodata->keyboard, data->windowID); + SDL_SetKeyboardFocus(videodata->keyboard, data->window); #ifdef X_HAVE_UTF8_STRING if (data->ic) { XSetICFocus(data->ic); @@ -232,9 +232,8 @@ X11_DispatchEvent(_THIS) #ifdef DEBUG_XEVENTS printf("UnmapNotify!\n"); #endif - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_HIDDEN, 0, 0); - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MINIMIZED, 0, - 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } break; @@ -243,9 +242,8 @@ X11_DispatchEvent(_THIS) #ifdef DEBUG_XEVENTS printf("MapNotify!\n"); #endif - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 0, 0); - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESTORED, 0, - 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0); } break; @@ -255,9 +253,9 @@ X11_DispatchEvent(_THIS) printf("ConfigureNotify! (resize: %dx%d)\n", xevent.xconfigure.width, xevent.xconfigure.height); #endif - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MOVED, + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, xevent.xconfigure.x, xevent.xconfigure.y); - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESIZED, + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, xevent.xconfigure.width, xevent.xconfigure.height); } @@ -268,8 +266,7 @@ X11_DispatchEvent(_THIS) if ((xevent.xclient.format == 32) && (xevent.xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) { - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_CLOSE, 0, - 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); } } break; @@ -279,8 +276,7 @@ X11_DispatchEvent(_THIS) #ifdef DEBUG_XEVENTS printf("Expose (count = %d)\n", xevent.xexpose.count); #endif - SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_EXPOSED, 0, - 0); + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); } break; diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index c2bfb971d..57cb12fba 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -221,7 +221,7 @@ static void X11_GL_InitExtensions(_THIS) { Display *display = ((SDL_VideoData *) _this->driverdata)->display; - int screen = ((SDL_DisplayData *) SDL_CurrentDisplay.driverdata)->screen; + int screen = ((SDL_DisplayData *) SDL_CurrentDisplay->driverdata)->screen; XVisualInfo *vinfo; XSetWindowAttributes xattr; Window w; @@ -394,8 +394,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; int screen = - ((SDL_DisplayData *) SDL_GetDisplayFromWindow(window)-> - driverdata)->screen; + ((SDL_DisplayData *) window->display->driverdata)->screen; XWindowAttributes xattr; XVisualInfo v, *vinfo; int n; @@ -403,7 +402,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) /* We do this to create a clean separation between X and GLX errors. */ XSync(display, False); - XGetWindowAttributes(display, data->window, &xattr); + XGetWindowAttributes(display, data->xwindow, &xattr); v.screen = screen; v.visualid = XVisualIDFromVisual(xattr.visual); vinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n); @@ -492,7 +491,7 @@ X11_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { Display *display = ((SDL_VideoData *) _this->driverdata)->display; Window drawable = - (window ? ((SDL_WindowData *) window->driverdata)->window : None); + (window ? ((SDL_WindowData *) window->driverdata)->xwindow : None); GLXContext glx_context = (GLXContext) context; int status; @@ -560,7 +559,7 @@ X11_GL_SwapWindow(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - _this->gl_data->glXSwapBuffers(display, data->window); + _this->gl_data->glXSwapBuffers(display, data->xwindow); } void diff --git a/src/video/x11/SDL_x11render.c b/src/video/x11/SDL_x11render.c index 98cdb993c..75dd95390 100644 --- a/src/video/x11/SDL_x11render.c +++ b/src/video/x11/SDL_x11render.c @@ -93,7 +93,7 @@ typedef struct Visual *visual; int depth; int scanline_pad; - Window window; + Window xwindow; Pixmap pixmaps[3]; int current_pixmap; Drawable drawable; @@ -153,7 +153,7 @@ X11_AddRenderDriver(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_RendererInfo *info = &X11_RenderDriver.info; - SDL_DisplayMode *mode = &SDL_CurrentDisplay.desktop_mode; + SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; int i; info->texture_formats[info->num_texture_formats++] = mode->format; @@ -171,7 +171,7 @@ X11_AddRenderDriver(_THIS) SDL_Renderer * X11_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_VideoDisplay *display = window->display; SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; SDL_Renderer *renderer; @@ -199,7 +199,7 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags) data->visual = displaydata->visual; data->depth = displaydata->depth; data->scanline_pad = displaydata->scanline_pad; - data->window = windowdata->window; + data->xwindow = windowdata->xwindow; renderer->DisplayModeChanged = X11_DisplayModeChanged; renderer->CreateTexture = X11_CreateTexture; @@ -221,7 +221,7 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = X11_DestroyTexture; renderer->DestroyRenderer = X11_DestroyRenderer; renderer->info = X11_RenderDriver.info; - renderer->window = window->id; + renderer->window = window; renderer->driverdata = data; renderer->info.flags = SDL_RENDERER_ACCELERATED; @@ -242,7 +242,7 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags) } for (i = 0; i < n; ++i) { data->pixmaps[i] = - XCreatePixmap(data->display, data->window, window->w, window->h, + XCreatePixmap(data->display, data->xwindow, window->w, window->h, displaydata->depth); if (data->pixmaps[i] == None) { X11_DestroyRenderer(renderer); @@ -254,7 +254,7 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags) data->drawable = data->pixmaps[0]; data->makedirty = SDL_TRUE; } else { - data->drawable = data->window; + data->drawable = data->xwindow; data->makedirty = SDL_FALSE; } data->current_pixmap = 0; @@ -272,7 +272,7 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags) /* Create the drawing context */ gcv.graphics_exposures = False; data->gc = - XCreateGC(data->display, data->window, GCGraphicsExposures, &gcv); + XCreateGC(data->display, data->xwindow, GCGraphicsExposures, &gcv); if (!data->gc) { X11_DestroyRenderer(renderer); SDL_SetError("XCreateGC() failed"); @@ -286,7 +286,7 @@ static int X11_DisplayModeChanged(SDL_Renderer * renderer) { X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; int i, n; if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) { @@ -306,7 +306,7 @@ X11_DisplayModeChanged(SDL_Renderer * renderer) } for (i = 0; i < n; ++i) { data->pixmaps[i] = - XCreatePixmap(data->display, data->window, window->w, window->h, + XCreatePixmap(data->display, data->xwindow, window->w, window->h, data->depth); if (data->pixmaps[i] == None) { SDL_SetError("XCreatePixmap() failed"); @@ -325,8 +325,8 @@ static int X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; X11_TextureData *data; int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1); @@ -425,7 +425,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } } else { data->pixmap = - XCreatePixmap(renderdata->display, renderdata->window, texture->w, + XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, texture->h, renderdata->depth); if (data->pixmap == None) { X11_DestroyTexture(renderer, texture); @@ -607,7 +607,7 @@ X11_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) { X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; unsigned long foreground; XPoint *xpoints, *xpoint; int i, xcount; @@ -657,7 +657,7 @@ X11_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, int count) { X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_Rect clip, rect; unsigned long foreground; XPoint *xpoints, *xpoint; @@ -795,7 +795,7 @@ static int X11_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) { X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_Rect clip, rect; unsigned long foreground; XRectangle *xrects, *xrect; @@ -840,7 +840,7 @@ static int X11_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) { X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); + SDL_Window *window = renderer->window; SDL_Rect clip, rect; unsigned long foreground; XRectangle *xrects, *xrect; @@ -998,8 +998,8 @@ X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 format, void * pixels, int pitch) { X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; Uint32 screen_format = display->current_mode.format; XImage *image; @@ -1019,8 +1019,8 @@ X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 format, const void * pixels, int pitch) { X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); + SDL_Window *window = renderer->window; + SDL_VideoDisplay *display = window->display; Uint32 screen_format = display->current_mode.format; XImage *image; void *image_pixels; @@ -1067,7 +1067,7 @@ X11_RenderPresent(SDL_Renderer * renderer) if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) { for (dirty = data->dirty.list; dirty; dirty = dirty->next) { const SDL_Rect *rect = &dirty->rect; - XCopyArea(data->display, data->drawable, data->window, + XCopyArea(data->display, data->drawable, data->xwindow, data->gc, rect->x, rect->y, rect->w, rect->h, rect->x, rect->y); } diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 933138ea4..2e7275918 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -45,7 +45,7 @@ X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; XWindowAttributes attr; XGetWindowAttributes(data->display, RootWindow(data->display, @@ -75,8 +75,8 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) SDL_OutOfMemory(); return -1; } - data->windowID = window->id; - data->window = w; + data->window = window; + data->xwindow = w; #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { data->ic = @@ -193,7 +193,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) if (GetFocus() == hwnd) { int index = data->videodata->keyboard; window->flags |= SDL_WINDOW_INPUT_FOCUS; - SDL_SetKeyboardFocus(index, data->windowID); + SDL_SetKeyboardFocus(index, data->window); if (window->flags & SDL_WINDOW_INPUT_GRABBED) { RECT rect; @@ -215,7 +215,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; Visual *visual; int depth; XSetWindowAttributes xattr; @@ -782,7 +782,7 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) status = XStringListToTextProperty(&title_locale, 1, &titleprop); SDL_free(title_locale); if (status) { - XSetTextProperty(display, data->window, &titleprop, XA_WM_NAME); + XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME); XFree(titleprop.value); } #ifdef X_HAVE_UTF8_STRING @@ -791,7 +791,7 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) Xutf8TextListToTextProperty(display, (char **) &title, 1, XUTF8StringStyle, &titleprop); if (status == Success) { - XSetTextProperty(display, data->window, &titleprop, + XSetTextProperty(display, data->xwindow, &titleprop, _NET_WM_NAME); XFree(titleprop.value); } @@ -807,7 +807,7 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) status = XStringListToTextProperty(&icon_locale, 1, &iconprop); SDL_free(icon_locale); if (status) { - XSetTextProperty(display, data->window, &iconprop, + XSetTextProperty(display, data->xwindow, &iconprop, XA_WM_ICON_NAME); XFree(iconprop.value); } @@ -817,7 +817,7 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) Xutf8TextListToTextProperty(display, (char **) &icon, 1, XUTF8StringStyle, &iconprop); if (status == Success) { - XSetTextProperty(display, data->window, &iconprop, + XSetTextProperty(display, data->xwindow, &iconprop, _NET_WM_ICON_NAME); XFree(iconprop.value); } @@ -855,13 +855,13 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) propdata[1] = icon->h; SDL_memcpy(&propdata[2], surface->pixels, surface->h * surface->pitch); - XChangeProperty(display, data->window, _NET_WM_ICON, XA_CARDINAL, + XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) propdata, propsize); } SDL_FreeSurface(surface); } else { - XDeleteProperty(display, data->window, _NET_WM_ICON); + XDeleteProperty(display, data->xwindow, _NET_WM_ICON); } } @@ -870,7 +870,7 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; Display *display = data->videodata->display; int x, y; @@ -888,7 +888,7 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) } else { y = window->y; } - XMoveWindow(display, data->window, x, y); + XMoveWindow(display, data->xwindow, x, y); } void @@ -897,7 +897,7 @@ X11_SetWindowSize(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XResizeWindow(display, data->window, window->w, window->h); + XResizeWindow(display, data->xwindow, window->w, window->h); } void @@ -906,7 +906,7 @@ X11_ShowWindow(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XMapRaised(display, data->window); + XMapRaised(display, data->xwindow); } void @@ -915,7 +915,7 @@ X11_HideWindow(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XUnmapWindow(display, data->window); + XUnmapWindow(display, data->xwindow); } void @@ -924,7 +924,7 @@ X11_RaiseWindow(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XRaiseWindow(display, data->window); + XRaiseWindow(display, data->xwindow); } static void @@ -932,7 +932,7 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; + (SDL_DisplayData *) window->display->driverdata; Display *display = data->videodata->display; Atom _NET_WM_STATE = XInternAtom(display, "_NET_WM_STATE", False); Atom _NET_WM_STATE_MAXIMIZED_VERT = @@ -942,7 +942,7 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) XEvent e; e.xany.type = ClientMessage; - e.xany.window = data->window; + e.xany.window = data->xwindow; e.xclient.message_type = _NET_WM_STATE; e.xclient.format = 32; e.xclient.data.l[0] = @@ -986,8 +986,8 @@ X11_SetWindowGrab(_THIS, SDL_Window * window) /* Try to grab the mouse */ for (;;) { int result = - XGrabPointer(display, data->window, True, 0, GrabModeAsync, - GrabModeAsync, data->window, None, CurrentTime); + XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync, + GrabModeAsync, data->xwindow, None, CurrentTime); if (result == GrabSuccess) { break; } @@ -995,10 +995,10 @@ X11_SetWindowGrab(_THIS, SDL_Window * window) } /* Raise the window if we grab the mouse */ - XRaiseWindow(display, data->window); + XRaiseWindow(display, data->xwindow); /* Now grab the keyboard */ - XGrabKeyboard(display, data->window, True, GrabModeAsync, + XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, GrabModeAsync, CurrentTime); } else { XUngrabPointer(display, CurrentTime); @@ -1021,7 +1021,7 @@ X11_DestroyWindow(_THIS, SDL_Window * window) if (windowlist) { for (i = 0; i < numwindows; ++i) { - if (windowlist[i] && (windowlist[i]->windowID == window->id)) { + if (windowlist[i] && (windowlist[i]->window == window)) { windowlist[i] = windowlist[numwindows - 1]; windowlist[numwindows - 1] = NULL; videodata->numwindows--; @@ -1035,7 +1035,7 @@ X11_DestroyWindow(_THIS, SDL_Window * window) } #endif if (data->created) { - XDestroyWindow(display, data->window); + XDestroyWindow(display, data->xwindow); } SDL_free(data); } diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index 5478f6013..417d6576e 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -26,8 +26,8 @@ typedef struct { - SDL_WindowID windowID; - Window window; + SDL_Window *window; + Window xwindow; XIC ic; SDL_bool created; struct SDL_VideoData *videodata; diff --git a/test/automated/render/render.c b/test/automated/render/render.c index 889c6a058..43cded18c 100644 --- a/test/automated/render/render.c +++ b/test/automated/render/render.c @@ -43,7 +43,7 @@ static int render_testPrimitivesBlend (void); static int render_testBlit (void); static int render_testBlitColour (void); static int render_testBlitAlpha (void); -static int render_testBlitBlendMode( SDL_TextureID tface, int mode ); +static int render_testBlitBlendMode( SDL_Texture * tface, int mode ); static int render_testBlitBlend (void); @@ -225,10 +225,10 @@ static int render_hasBlendModes (void) /** * @brief Loads the test face. */ -static SDL_TextureID render_loadTestFace (void) +static SDL_Texture * render_loadTestFace (void) { SDL_Surface *face; - SDL_TextureID tface; + SDL_Texture *tface; /* Create face surface. */ face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, @@ -261,7 +261,7 @@ static int render_hasTexColor (void) { int fail; int ret; - SDL_TextureID tface; + SDL_Texture *tface; Uint8 r, g, b; /* Get test face. */ @@ -296,7 +296,7 @@ static int render_hasTexAlpha (void) { int fail; int ret; - SDL_TextureID tface; + SDL_Texture *tface; Uint8 a; /* Get test face. */ @@ -606,7 +606,7 @@ static int render_testBlit (void) { int ret; SDL_Rect rect; - SDL_TextureID tface; + SDL_Texture *tface; int i, j, ni, nj; /* Clear surface. */ @@ -658,7 +658,7 @@ static int render_testBlitColour (void) { int ret; SDL_Rect rect; - SDL_TextureID tface; + SDL_Texture *tface; int i, j, ni, nj; /* Clear surface. */ @@ -716,7 +716,7 @@ static int render_testBlitAlpha (void) { int ret; SDL_Rect rect; - SDL_TextureID tface; + SDL_Texture *tface; int i, j, ni, nj; /* Clear surface. */ @@ -774,7 +774,7 @@ static int render_testBlitAlpha (void) /** * @brief Tests a blend mode. */ -static int render_testBlitBlendMode( SDL_TextureID tface, int mode ) +static int render_testBlitBlendMode( SDL_Texture * tface, int mode ) { int ret; int i, j, ni, nj; @@ -820,7 +820,7 @@ static int render_testBlitBlend (void) { int ret; SDL_Rect rect; - SDL_TextureID tface; + SDL_Texture *tface; int i, j, ni, nj; int mode; @@ -1004,7 +1004,7 @@ int test_render (void) int ret; const char *driver, *str; char msg[256]; - SDL_WindowID wid; + SDL_Window *w; SDL_RendererInfo renderer; /* Initializes the SDL subsystems. */ @@ -1054,12 +1054,12 @@ int test_render (void) if (SDL_ATassert( "SDL_GetCurrentVideoDriver", SDL_strcmp(driver,str)==0)) goto err_cleanup; /* Create window. */ - wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + w = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 80, 60, SDL_WINDOW_SHOWN ); - if (SDL_ATassert( "SDL_CreateWindow", wid!=0 )) + if (SDL_ATassert( "SDL_CreateWindow", w!=NULL )) goto err_cleanup; /* Check title. */ - str = SDL_GetWindowTitle( wid ); + str = SDL_GetWindowTitle( w ); if (SDL_ATassert( "SDL_GetWindowTitle", SDL_strcmp(msg,str)==0)) goto err_cleanup; /* Get renderers. */ @@ -1072,10 +1072,10 @@ int test_render (void) /* We have to recreate window each time, because opengl and opengles renderers */ /* both add SDL_WINDOW_OPENGL flag for window, that was last used */ - SDL_DestroyWindow(wid); - wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + SDL_DestroyWindow(w); + w = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 80, 60, SDL_WINDOW_SHOWN ); - if (SDL_ATassert( "SDL_CreateWindow", wid!=0 )) + if (SDL_ATassert( "SDL_CreateWindow", w!=NULL )) goto err_cleanup; /* Get renderer info. */ @@ -1089,7 +1089,7 @@ int test_render (void) SDL_ATbegin( msg ); /* Set renderer. */ - ret = SDL_CreateRenderer( wid, j, 0 ); + ret = SDL_CreateRenderer( w, j, 0 ); if (SDL_ATassert( "SDL_CreateRenderer", ret==0 )) goto err_cleanup; diff --git a/test/common.c b/test/common.c index 1cf0b5b28..694fa196c 100644 --- a/test/common.c +++ b/test/common.c @@ -761,7 +761,7 @@ CommonInit(CommonState * state) fullscreen_mode.refresh_rate = state->refresh_rate; state->windows = - (SDL_WindowID *) SDL_malloc(state->num_windows * + (SDL_Window **) SDL_malloc(state->num_windows * sizeof(*state->windows)); if (!state->windows) { fprintf(stderr, "Out of memory!\n"); diff --git a/test/common.h b/test/common.h index ac81b84e3..8aca1f054 100644 --- a/test/common.h +++ b/test/common.h @@ -32,7 +32,7 @@ typedef struct int depth; int refresh_rate; int num_windows; - SDL_WindowID *windows; + SDL_Window **windows; /* Renderer info */ const char *renderdriver; diff --git a/test/testdraw2.c b/test/testdraw2.c index 0b55b7759..437397a0e 100644 --- a/test/testdraw2.c +++ b/test/testdraw2.c @@ -19,7 +19,7 @@ static int current_color = 255; static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE; void -DrawPoints(SDL_WindowID window) +DrawPoints(SDL_Window * window) { int i; int x, y; @@ -64,7 +64,7 @@ DrawPoints(SDL_WindowID window) } void -DrawLines(SDL_WindowID window) +DrawLines(SDL_Window * window) { int i; int x1, y1, x2, y2; @@ -118,7 +118,7 @@ DrawLines(SDL_WindowID window) } void -DrawRects(SDL_WindowID window) +DrawRects(SDL_Window * window) { int i; SDL_Rect rect; @@ -249,7 +249,7 @@ main(int argc, char *argv[]) case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_EXPOSED: - SDL_SelectRenderer(event.window.windowID); + SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID)); SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(); break; diff --git a/test/testintersections.c b/test/testintersections.c index c222210c7..7327e3a02 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -20,7 +20,7 @@ static int current_color = 255; static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE; void -DrawPoints(SDL_WindowID window) +DrawPoints(SDL_Window * window) { int i; int x, y; @@ -86,7 +86,7 @@ add_line(int x1, int y1, int x2, int y2) void -DrawLines(SDL_WindowID window) +DrawLines(SDL_Window * window) { int i; int x1, y1, x2, y2; @@ -139,7 +139,7 @@ add_rect(int x1, int y1, int x2, int y2) } static void -DrawRects(SDL_WindowID window) +DrawRects(SDL_Window * window) { int i; int window_w, window_h; @@ -156,7 +156,7 @@ DrawRects(SDL_WindowID window) } static void -DrawRectLineIntersections(SDL_WindowID window) +DrawRectLineIntersections(SDL_Window * window) { int i, j, window_w, window_h; @@ -186,7 +186,7 @@ DrawRectLineIntersections(SDL_WindowID window) } static void -DrawRectRectIntersections(SDL_WindowID window) +DrawRectRectIntersections(SDL_Window * window) { int i, j; @@ -324,7 +324,7 @@ main(int argc, char *argv[]) case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_EXPOSED: - SDL_SelectRenderer(event.window.windowID); + SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID)); SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(); break; diff --git a/test/testnative.c b/test/testnative.c index 4403afb6b..84017d5fd 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -36,11 +36,11 @@ quit(int rc) exit(rc); } -SDL_TextureID -LoadSprite(SDL_WindowID window, char *file) +SDL_Texture * +LoadSprite(SDL_Window * window, char *file) { SDL_Surface *temp; - SDL_TextureID sprite; + SDL_Texture *sprite; /* Load the sprite image */ temp = SDL_LoadBMP(file); @@ -69,7 +69,7 @@ LoadSprite(SDL_WindowID window, char *file) } void -MoveSprites(SDL_WindowID window, SDL_TextureID sprite) +MoveSprites(SDL_Window * window, SDL_Texture * sprite) { int i, n; int window_w, window_h; @@ -113,8 +113,8 @@ main(int argc, char *argv[]) { int i, done; const char *driver; - SDL_WindowID window; - SDL_TextureID sprite; + SDL_Window *window; + SDL_Texture *sprite; int window_w, window_h; int sprite_w, sprite_h; SDL_Event event; diff --git a/test/testsprite2.c b/test/testsprite2.c index 330dca821..10c201fe4 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -11,7 +11,7 @@ static CommonState *state; static int num_sprites; -static SDL_TextureID *sprites; +static SDL_Texture **sprites; static SDL_bool cycle_color; static SDL_bool cycle_alpha; static int cycle_direction = 1; @@ -98,7 +98,7 @@ LoadSprite(char *file) } void -MoveSprites(SDL_WindowID window, SDL_TextureID sprite) +MoveSprites(SDL_Window * window, SDL_Texture * sprite) { int i, n; int window_w, window_h; @@ -294,7 +294,7 @@ main(int argc, char *argv[]) /* Create the windows, initialize the renderers, and load the textures */ sprites = - (SDL_TextureID *) SDL_malloc(state->num_windows * sizeof(*sprites)); + (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites)); if (!sprites) { fprintf(stderr, "Out of memory!\n"); quit(2); @@ -346,7 +346,7 @@ main(int argc, char *argv[]) case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_EXPOSED: - SDL_SelectRenderer(event.window.windowID); + SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID)); SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(); break; diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 2a8749257..72ecb9d6b 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -12,7 +12,7 @@ #define NUM_SPRITES 100 #define MAX_SPEED 1 -static SDL_TextureID sprite; +static SDL_Texture *sprite; static SDL_Rect positions[NUM_SPRITES]; static SDL_Rect velocities[NUM_SPRITES]; static int sprite_w, sprite_h; @@ -78,7 +78,7 @@ LoadSprite(char *file) } void -MoveSprites(SDL_WindowID window, SDL_TextureID sprite) +MoveSprites(SDL_Window * window, SDL_Texture * sprite) { int i; int window_w = WINDOW_WIDTH; @@ -115,7 +115,7 @@ MoveSprites(SDL_WindowID window, SDL_TextureID sprite) int main(int argc, char *argv[]) { - SDL_WindowID window; + SDL_Window *window; int i, done; SDL_Event event;