Open
Description
After copying some "data" in another program, so that SDL_HasClipboardData
becomes true, I still get the old clipboard text from SDL_GetClipboardText()
. The clipboard text is not cleared until after I have called SDL_GetClipboardData
.
System:
Debian 11 with the MATE desktop environment (X11).
The Program:
#include <SDL3/SDL.h>
#include <stdbool.h>
void log_clipboard() {
SDL_Log("\tClipboard text: %s", SDL_HasClipboardText() ? SDL_GetClipboardText() : "no clipboard text");
SDL_Log("\tHas clipboard data? %s", SDL_HasClipboardData("image/png") ? "true" : "false");
}
int main(int argc, char *argv[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("", 300, 200, 0);
bool quit = false;
while (!quit) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_V) {
SDL_Log("Before calling SDL_GetClipboardData:");
log_clipboard();
size_t len;
SDL_GetClipboardData("image/png", &len);
SDL_Log("After calling SDL_GetClipboardData:");
log_clipboard();
}
else if (event.type == SDL_EVENT_QUIT) {
quit = true;
}
}
SDL_SetWindowTitle(window, SDL_HasClipboardText() ? SDL_GetClipboardText() : "no clipboard text");
SDL_Delay(20);
}
SDL_Quit();
}
Steps to reproduce the problem:
- Copy "some text".
- Start The Program.
- Copy some "data" in another program (e.g. by selecting part of an image in GIMP or Krita and press Ctrl+C).
- Make sure The Program has focus and press V.
Expected output:
INFO: Before calling SDL_GetClipboardData:
INFO: Clipboard text: no clipboard text
INFO: Has clipboard data? true
INFO: After calling SDL_GetClipboardData:
INFO: Clipboard text: no clipboard text
INFO: Has clipboard data? true
Actual output:
INFO: Before calling SDL_GetClipboardData:
INFO: Clipboard text: some text
INFO: Has clipboard data? true
INFO: After calling SDL_GetClipboardData:
INFO: Clipboard text: no clipboard text
INFO: Has clipboard data? true
Metadata
Metadata
Assignees
Labels
No labels