From 81e7c10a73d887161afd1e6d96af5861bba6ed2b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 27 Oct 2021 15:40:20 +0300 Subject: [PATCH] Emit DataOfferInterface::dragAndDropActionsChanged() only if dnd actions change With some apps, firefox specifically, it's possible to enter a dnd positive feedback loop, e.g. * kwin sends wl_data_offer::action event * the app reacts to it and calls wl_data_offer::set_actions() with the same actions * kwin re-sends the wl_data_offer::action event because DataOfferInterface::dragAndDropActionsChanged() has been emitted * the app calls wl_data_offer::set_actions() again, and so on... This should make D&D in Firefox more responsive. --- src/wayland/dataoffer_interface.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wayland/dataoffer_interface.cpp b/src/wayland/dataoffer_interface.cpp index ce9db22398..ed68217251 100644 --- a/src/wayland/dataoffer_interface.cpp +++ b/src/wayland/dataoffer_interface.cpp @@ -119,9 +119,11 @@ void DataOfferInterfacePrivate::data_offer_set_actions(Resource *resource, uint3 preferredAction = DataDeviceManagerInterface::DnDAction::Ask; } - supportedDnDActions = supportedActions; - preferredDnDAction = preferredAction; - Q_EMIT q->dragAndDropActionsChanged(); + if (supportedDnDActions != supportedActions || preferredDnDAction != preferredAction) { + supportedDnDActions = supportedActions; + preferredDnDAction = preferredAction; + Q_EMIT q->dragAndDropActionsChanged(); + } } void DataOfferInterface::sendSourceActions()