SDL_GetWindowOpacity() directly returns the opacity instead of using an out parameter.

Fixes https://github.com/libsdl-org/SDL/issues/10286
This commit is contained in:
Sam Lantinga
2024-07-16 07:25:48 -07:00
parent 58270ef3f2
commit 027671bedb
5 changed files with 15 additions and 25 deletions

View File

@@ -520,7 +520,7 @@ SDL_DYNAPI_PROC(int,SDL_GetWindowMaximumSize,(SDL_Window *a, int *b, int *c),(a,
SDL_DYNAPI_PROC(int,SDL_GetWindowMinimumSize,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowMouseGrab,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(const SDL_Rect*,SDL_GetWindowMouseRect,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowOpacity,(SDL_Window *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_GetWindowOpacity,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowParent,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(float,SDL_GetWindowPixelDensity,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_PixelFormat,SDL_GetWindowPixelFormat,(SDL_Window *a),(a),return)

View File

@@ -2216,15 +2216,13 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
/* Ctrl-O (or Ctrl-Shift-O) changes window opacity. */
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
float opacity;
if (SDL_GetWindowOpacity(window, &opacity) == 0) {
if (withShift) {
opacity += 0.20f;
} else {
opacity -= 0.20f;
}
SDL_SetWindowOpacity(window, opacity);
float opacity = SDL_GetWindowOpacity(window);
if (withShift) {
opacity += 0.20f;
} else {
opacity -= 0.20f;
}
SDL_SetWindowOpacity(window, opacity);
}
}
break;

View File

@@ -3504,15 +3504,11 @@ int SDL_SetWindowOpacity(SDL_Window *window, float opacity)
return retval;
}
int SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity)
float SDL_GetWindowOpacity(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, -1);
CHECK_WINDOW_MAGIC(window, -1.0f);
if (out_opacity) {
*out_opacity = window->opacity;
}
return 0;
return window->opacity;
}
int SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window)