Added fix for mozilla bug #1527976 (browser D&D)

This commit is contained in:
Martin Stransky 2020-04-23 11:17:16 +02:00
parent 461eee52cd
commit cdfebbc9a2
2 changed files with 139 additions and 1 deletions

View File

@ -0,0 +1,133 @@
diff --git a/widget/gtk/nsClipboardWayland.cpp b/widget/gtk/nsClipboardWayland.cpp
--- a/widget/gtk/nsClipboardWayland.cpp
+++ b/widget/gtk/nsClipboardWayland.cpp
@@ -538,7 +538,6 @@
}
LOGDRAG(("nsWindow data_device_enter for GtkWidget %p\n", (void*)gtkWidget));
-
dragContext->DropDataEnter(gtkWidget, time, wl_fixed_to_int(x_fixed),
wl_fixed_to_int(y_fixed));
}
@@ -550,6 +549,8 @@
nsWaylandDragContext* dropContext = context->GetDragContext();
WindowDragLeaveHandler(dropContext->GetWidget());
+ LOGDRAG(("nsWindow data_device_leave for GtkWidget %p\n",
+ (void*)dropContext->GetWidget()));
context->ClearDragAndDropDataOffer();
}
@@ -565,6 +566,8 @@
nscoord y = wl_fixed_to_int(y_fixed);
dropContext->DropMotion(time, x, y);
+ LOGDRAG(("nsWindow data_device_motion for GtkWidget %p\n",
+ (void*)dropContext->GetWidget()));
WindowDragMotionHandler(dropContext->GetWidget(), nullptr, dropContext, x, y,
time);
}
@@ -578,6 +581,8 @@
nscoord x, y;
dropContext->GetLastDropInfo(&time, &x, &y);
+ LOGDRAG(("nsWindow data_device_drop GtkWidget %p\n",
+ (void*)dropContext->GetWidget()));
WindowDragDropHandler(dropContext->GetWidget(), nullptr, dropContext, x, y,
time);
}
diff --git a/widget/gtk/nsDragService.cpp b/widget/gtk/nsDragService.cpp
--- a/widget/gtk/nsDragService.cpp
+++ b/widget/gtk/nsDragService.cpp
@@ -45,6 +45,7 @@
#include "nsArrayUtils.h"
#ifdef MOZ_WAYLAND
# include "nsClipboardWayland.h"
+# include "gfxPlatformGtk.h"
#endif
using namespace mozilla;
@@ -59,7 +60,14 @@
// directly) so that this code can be compiled against versions of GTK+ that
// do not have GtkDragResult.
// GtkDragResult is available from GTK+ version 2.12.
-enum { MOZ_GTK_DRAG_RESULT_SUCCESS, MOZ_GTK_DRAG_RESULT_NO_TARGET };
+enum {
+ MOZ_GTK_DRAG_RESULT_SUCCESS,
+ MOZ_GTK_DRAG_RESULT_NO_TARGET,
+ MOZ_GTK_DRAG_RESULT_USER_CANCELLED,
+ MOZ_GTK_DRAG_RESULT_TIMEOUT_EXPIRED,
+ MOZ_GTK_DRAG_RESULT_GRAB_BROKEN,
+ MOZ_GTK_DRAG_RESULT_ERROR
+};
static LazyLogModule sDragLm("nsDragService");
@@ -74,6 +82,7 @@
static const char gTextUriListType[] = "text/uri-list";
static const char gTextPlainUTF8Type[] = "text/plain;charset=utf-8";
static const char gXdndDirectSaveType[] = "XdndDirectSave0";
+static const char gTabDropType[] = "application/x-moz-tabbrowser-tab";
static void invisibleSourceDragBegin(GtkWidget* aWidget,
GdkDragContext* aContext, gpointer aData);
@@ -346,12 +355,10 @@
gtk_window_get_group(GetGtkWindow(mSourceDocument));
gtk_window_group_add_window(window_group, GTK_WINDOW(mHiddenWidget));
-#ifdef MOZ_WIDGET_GTK
// Get device for event source
GdkDisplay* display = gdk_display_get_default();
GdkDeviceManager* device_manager = gdk_display_get_device_manager(display);
event.button.device = gdk_device_manager_get_client_pointer(device_manager);
-#endif
// start our drag.
GdkDragContext* context =
@@ -1252,6 +1259,9 @@
void nsDragService::SourceEndDragSession(GdkDragContext* aContext,
gint aResult) {
+ MOZ_LOG(sDragLm, LogLevel::Debug,
+ ("SourceEndDragSession result %d\n", aResult));
+
// this just releases the list of data items that we provide
mSourceDataItems = nullptr;
@@ -1272,6 +1282,8 @@
gint scale = mozilla::widget::ScreenHelperGTK::GetGTKMonitorScaleFactor();
gdk_display_get_pointer(display, nullptr, &x, &y, nullptr);
SetDragEndPoint(LayoutDeviceIntPoint(x * scale, y * scale));
+ MOZ_LOG(sDragLm, LogLevel::Debug,
+ ("guess drag end point %d %d\n", x * scale, y * scale));
}
}
@@ -1307,7 +1319,25 @@
} else {
dropEffect = DRAGDROP_ACTION_NONE;
- if (aResult != MOZ_GTK_DRAG_RESULT_NO_TARGET) {
+ bool isWaylandTabDrop = false;
+#ifdef MOZ_WAYLAND
+ // Bug 1527976. Wayland protocol does not have any way how to handle
+ // MOZ_GTK_DRAG_RESULT_NO_TARGET drop result so consider all tab
+ // drops as not cancelled on wayland.
+ if (gfxPlatformGtk::GetPlatform()->IsWaylandDisplay() &&
+ aResult == MOZ_GTK_DRAG_RESULT_ERROR) {
+ for (GList* tmp = gdk_drag_context_list_targets(aContext); tmp;
+ tmp = tmp->next) {
+ GdkAtom atom = GDK_POINTER_TO_ATOM(tmp->data);
+ gchar* name = gdk_atom_name(atom);
+ if (name && (strcmp(name, gTabDropType) == 0)) {
+ isWaylandTabDrop = true;
+ break;
+ }
+ }
+ }
+#endif
+ if (aResult != MOZ_GTK_DRAG_RESULT_NO_TARGET && !isWaylandTabDrop) {
mUserCancelled = true;
}
}

View File

@ -118,7 +118,7 @@ ExcludeArch: s390x
Summary: Mozilla Firefox Web browser
Name: firefox
Version: 75.0
Release: 2%{?nss_tag}%{?dist}
Release: 3%{?nss_tag}%{?dist}
URL: https://www.mozilla.org/firefox/
License: MPLv1.1 or GPLv2+ or LGPLv2+
Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz
@ -189,6 +189,7 @@ Patch425: mozilla-1623106.patch
Patch574: firefox-pipewire.patch
Patch576: mozilla-1623060.patch
Patch578: mozilla-1627469.patch
Patch579: browser-tabbar-dad-mzbz1527976.patch
# PGO/LTO patches
Patch600: pgo.patch
@ -398,6 +399,7 @@ This package contains results of tests executed during build.
%patch574 -p1 -b .firefox-pipewire
%patch576 -p1 -b .mozilla-1623060
%patch578 -p1 -b .mozilla-1627469
%patch579 -p1 -b .mozilla-1527976
# PGO patches
%patch600 -p1 -b .pgo
@ -964,6 +966,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
#---------------------------------------------------------------------
%changelog
* Thu Apr 23 2020 Martin Stransky <stransky@redhat.com> - 75.0-3
- Added fix for mozilla bug #1527976 (browser D&D)
* Tue Apr 14 2020 Jan Horak <jhorak@redhat.com> - 75.0-2
- Removed gconf-2.0 build requirement