mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-26 10:06:42 +08:00
clipboard: Fixes testautomation fails introduced by clipboard changes
This commit is contained in:
committed by
Sam Lantinga
parent
4e0f94ea7d
commit
a2ba5e9052
@@ -245,14 +245,16 @@ static SDL_bool HasClipboardData(SDL_VideoDevice *_this, const char *mime_type)
|
|||||||
SDL_WaylandDataDevice *data_device = NULL;
|
SDL_WaylandDataDevice *data_device = NULL;
|
||||||
|
|
||||||
SDL_bool result = SDL_FALSE;
|
SDL_bool result = SDL_FALSE;
|
||||||
if (_this == NULL || _this->driverdata == NULL) {
|
video_data = _this->driverdata;
|
||||||
SDL_SetError("Video driver uninitialized");
|
if (video_data->input != NULL && video_data->input->data_device != NULL) {
|
||||||
} else {
|
data_device = video_data->input->data_device;
|
||||||
video_data = _this->driverdata;
|
if (data_device->selection_source != NULL) {
|
||||||
if (video_data->input != NULL && video_data->input->data_device != NULL) {
|
size_t length = 0;
|
||||||
data_device = video_data->input->data_device;
|
char *buffer = Wayland_data_source_get_data(data_device->selection_source, &length, mime_type, SDL_TRUE);
|
||||||
result = result ||
|
result = buffer != NULL;
|
||||||
Wayland_data_offer_has_mime(data_device->selection_offer, mime_type);
|
SDL_free(buffer);
|
||||||
|
} else {
|
||||||
|
result = Wayland_data_offer_has_mime(data_device->selection_offer, mime_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -280,9 +282,16 @@ SDL_bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this)
|
|||||||
video_data = _this->driverdata;
|
video_data = _this->driverdata;
|
||||||
if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) {
|
if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) {
|
||||||
primary_selection_device = video_data->input->primary_selection_device;
|
primary_selection_device = video_data->input->primary_selection_device;
|
||||||
result = result ||
|
if (primary_selection_device->selection_source != NULL) {
|
||||||
Wayland_primary_selection_offer_has_mime(
|
size_t length = 0;
|
||||||
primary_selection_device->selection_offer, TEXT_MIME);
|
char *buffer = Wayland_primary_selection_source_get_data(primary_selection_device->selection_source,
|
||||||
|
&length, TEXT_MIME, SDL_TRUE);
|
||||||
|
result = buffer != NULL;
|
||||||
|
SDL_free(buffer);
|
||||||
|
} else {
|
||||||
|
result = Wayland_primary_selection_offer_has_mime(
|
||||||
|
primary_selection_device->selection_offer, TEXT_MIME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, size_
|
|||||||
owner = X11_XGetSelectionOwner(display, selection_type);
|
owner = X11_XGetSelectionOwner(display, selection_type);
|
||||||
if (owner == None) {
|
if (owner == None) {
|
||||||
/* This requires a fallback to ancient X10 cut-buffers. We will just skip those for now */
|
/* This requires a fallback to ancient X10 cut-buffers. We will just skip those for now */
|
||||||
return NULL;
|
data = NULL;
|
||||||
} else if (owner == window) {
|
} else if (owner == window) {
|
||||||
owner = DefaultRootWindow(display);
|
owner = DefaultRootWindow(display);
|
||||||
if (selection_type == XA_PRIMARY) {
|
if (selection_type == XA_PRIMARY) {
|
||||||
@@ -229,6 +229,10 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, size_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nullterminate && data == NULL) {
|
||||||
|
data = strdup("");
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user