Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-08-04 15:33:22 +0300
committerCampbell Barton <campbell@blender.org>2022-08-04 15:33:22 +0300
commit727cc426bc723c8757941ce9bf23745ee5f6ab9d (patch)
tree994724ed2ed927b1e869f3cd3fffa53cd36a146b /intern/ghost
parentcdd718dbb242f614a8d8588c4996e7159ba737ea (diff)
Fix drag & drop in Wayland with some applications
Drag & drop worked with GTK3 apps but not QT5 (pcmanfm-qt for eg) as files are separated by '\n' instead of '\r\n'. Resolve by supporting both (follow up to T99737).
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 5eea90015b1..7da8d56ed0d 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -1227,7 +1227,9 @@ static void data_device_handle_drop(void *data, struct wl_data_device * /*wl_dat
if (mime_receive == mime_text_uri) {
static constexpr const char *file_proto = "file://";
- static constexpr const char *crlf = "\r\n";
+ /* NOTE: some applications CRLF (`\r\n`) GTK3 for e.g. & others don't `pcmanfm-qt`.
+ * So support both, once `\n` is found, strip the preceding `\r` if found. */
+ static constexpr const char *lf = "\n";
GHOST_WindowWayland *win = ghost_wl_surface_user_data(surface);
std::vector<std::string> uris;
@@ -1236,12 +1238,16 @@ static void data_device_handle_drop(void *data, struct wl_data_device * /*wl_dat
while (true) {
pos = data.find(file_proto, pos);
const size_t start = pos + sizeof(file_proto) - 1;
- pos = data.find(crlf, pos);
- const size_t end = pos;
+ pos = data.find(lf, pos);
if (pos == std::string::npos) {
break;
}
+ /* Account for 'CRLF' case. */
+ size_t end = pos;
+ if (data[end - 1] == '\r') {
+ end -= 1;
+ }
uris.push_back(data.substr(start, end - start));
CLOG_INFO(LOG, 2, "drop_read_uris pos=%zu, text_uri=\"%s\"", start, uris.back().c_str());
}