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
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-10-28 02:46:39 +0300
committerCampbell Barton <campbell@blender.org>2022-10-28 03:15:25 +0300
commit00533de7d53d389931b1e310027bb329f342d2ca (patch)
tree367d285582962c9b9072c9b52b5dbe494bc9f8a0 /intern
parentd488a87d7015cc5303e7bea46b40fad467594f1c (diff)
Cleanup: move GWL_DataOffer in_use to the 'dnd' struct
It wasn't clear that this is only used for drag & drop, also don't use an atomic type as all access is guarded by the drag & drop mutex.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 49bed2f9c0e..9151cfa008d 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -360,10 +360,14 @@ struct GWL_TabletTool {
struct GWL_DataOffer {
struct wl_data_offer *id = nullptr;
std::unordered_set<std::string> types;
- std::atomic<bool> in_use = false;
struct {
/**
+ * Prevents freeing after #wl_data_device_listener.leave,
+ * before #wl_data_device_listener.drop.
+ */
+ bool in_use = false;
+ /**
* Bit-mask with available drop options.
* #WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY, #WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE.. etc.
* The application that initializes the drag may set these depending on modifiers held
@@ -564,7 +568,6 @@ static void gwl_xdg_decor_system_destroy(struct GWL_Display *display, GWL_XDG_De
struct GWL_PrimarySelection_DataOffer {
struct zwp_primary_selection_offer_v1 *id = nullptr;
- std::atomic<bool> in_use = false;
std::unordered_set<std::string> types;
};
@@ -1672,7 +1675,8 @@ static char *read_buffer_from_data_offer(GWL_DataOffer *data_offer,
wl_data_offer_receive(data_offer->id, mime_receive, pipefd[1]);
close(pipefd[1]);
- data_offer->in_use.store(false);
+ /* Only for DND (A no-op to disable for clipboard data-offer). */
+ data_offer->dnd.in_use = false;
if (mutex) {
mutex->unlock();
@@ -1701,8 +1705,6 @@ static char *read_buffer_from_primary_selection_offer(GWL_PrimarySelection_DataO
zwp_primary_selection_offer_v1_receive(data_offer->id, mime_receive, pipefd[1]);
close(pipefd[1]);
- data_offer->in_use.store(false);
-
if (mutex) {
mutex->unlock();
}
@@ -1897,7 +1899,7 @@ static void data_device_handle_enter(void *data,
seat->data_offer_dnd = static_cast<GWL_DataOffer *>(wl_data_offer_get_user_data(id));
GWL_DataOffer *data_offer = seat->data_offer_dnd;
- data_offer->in_use.store(true);
+ data_offer->dnd.in_use = true;
data_offer->dnd.xy[0] = x;
data_offer->dnd.xy[1] = y;
@@ -1924,7 +1926,7 @@ static void data_device_handle_leave(void *data, struct wl_data_device * /*wl_da
dnd_events(seat, GHOST_kEventDraggingExited);
seat->wl_surface_focus_dnd = nullptr;
- if (seat->data_offer_dnd && !seat->data_offer_dnd->in_use.load()) {
+ if (seat->data_offer_dnd && !seat->data_offer_dnd->dnd.in_use) {
wl_data_offer_destroy(seat->data_offer_dnd->id);
delete seat->data_offer_dnd;
seat->data_offer_dnd = nullptr;