mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-24 00:06:10 +00:00
clipboard: SDL_GetPrimarySelectionText() now follows the SDL_GetStringRule.
Reference Issue #10229.
This commit is contained in:
@@ -416,7 +416,7 @@ SDL_DYNAPI_PROC(SDL_PowerState,SDL_GetPowerInfo,(int *a, int *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(char*,SDL_GetPrefPath,(const char *a, const char *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Locale*,SDL_GetPreferredLocales,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetPrimaryDisplay,(void),(),return)
|
||||
SDL_DYNAPI_PROC(char*,SDL_GetPrimarySelectionText,(void),(),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetPrimarySelectionText,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_PropertyType,SDL_GetPropertyType,(SDL_PropertiesID a, const char *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_GetRGB,(Uint32 a, const SDL_PixelFormatDetails *b, const SDL_Palette *c, Uint8 *d, Uint8 *e, Uint8 *f),(a,b,c,d,e,f),)
|
||||
SDL_DYNAPI_PROC(void,SDL_GetRGBA,(Uint32 a, const SDL_PixelFormatDetails *b, const SDL_Palette *c, Uint8 *d, Uint8 *e, Uint8 *f, Uint8 *g),(a,b,c,d,e,f,g),)
|
||||
|
||||
@@ -2264,13 +2264,12 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
|
||||
case SDLK_V:
|
||||
if (withAlt) {
|
||||
/* Alt-V paste awesome text from the primary selection! */
|
||||
char *text = SDL_GetPrimarySelectionText();
|
||||
const char *text = SDL_GetPrimarySelectionText();
|
||||
if (*text) {
|
||||
SDL_Log("Primary selection: %s\n", text);
|
||||
} else {
|
||||
SDL_Log("Primary selection is empty\n");
|
||||
}
|
||||
SDL_free(text);
|
||||
|
||||
} else if (withControl) {
|
||||
if (withShift) {
|
||||
|
||||
@@ -349,7 +349,7 @@ int SDL_SetPrimarySelectionText(const char *text)
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
SDL_free(_this->primary_selection_text);
|
||||
SDL_FreeLater(_this->primary_selection_text); // this pointer might be given to the app by SDL_GetPrimarySelectionText.
|
||||
_this->primary_selection_text = SDL_strdup(text);
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ int SDL_SetPrimarySelectionText(const char *text)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *SDL_GetPrimarySelectionText(void)
|
||||
const char *SDL_GetPrimarySelectionText(void)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
@@ -367,13 +367,13 @@ char *SDL_GetPrimarySelectionText(void)
|
||||
}
|
||||
|
||||
if (_this->GetPrimarySelectionText) {
|
||||
return _this->GetPrimarySelectionText(_this);
|
||||
return SDL_FreeLater(_this->GetPrimarySelectionText(_this)); // returned pointer follows the SDL_GetStringRule
|
||||
} else {
|
||||
const char *text = _this->primary_selection_text;
|
||||
if (!text) {
|
||||
text = "";
|
||||
}
|
||||
return SDL_strdup(text);
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user