зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1710344 [Wayland] Make D&D work with popups, r=emilio
Right now D&D on popups are not possible due to https://gitlab.gnome.org/GNOME/gtk/-/issues/4437 and wrong event handling. To fix that we do in this patch: - Listen for D&D events on mShell instead of on mContainer as we're getting D&D events there. - Compensate https://gitlab.gnome.org/GNOME/gtk/-/issues/4437 and add window position to D&D coordinates reported by D&D handlers. Differential Revision: https://phabricator.services.mozilla.com/D131052
This commit is contained in:
Родитель
553c13cf24
Коммит
0de6c9cb94
|
@ -5731,6 +5731,17 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
|
|||
G_CALLBACK(screen_composited_changed_cb), nullptr);
|
||||
}
|
||||
|
||||
gtk_drag_dest_set((GtkWidget*)mShell, (GtkDestDefaults)0, nullptr, 0,
|
||||
(GdkDragAction)0);
|
||||
g_signal_connect(mShell, "drag_motion", G_CALLBACK(drag_motion_event_cb),
|
||||
nullptr);
|
||||
g_signal_connect(mShell, "drag_leave", G_CALLBACK(drag_leave_event_cb),
|
||||
nullptr);
|
||||
g_signal_connect(mShell, "drag_drop", G_CALLBACK(drag_drop_event_cb),
|
||||
nullptr);
|
||||
g_signal_connect(mShell, "drag_data_received",
|
||||
G_CALLBACK(drag_data_received_event_cb), nullptr);
|
||||
|
||||
GtkSettings* default_settings = gtk_settings_get_default();
|
||||
g_signal_connect_after(default_settings, "notify::gtk-xft-dpi",
|
||||
G_CALLBACK(settings_xft_dpi_changed_cb), this);
|
||||
|
@ -5757,18 +5768,6 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
|
|||
g_signal_connect(mContainer, "key_release_event",
|
||||
G_CALLBACK(key_release_event_cb), nullptr);
|
||||
|
||||
gtk_drag_dest_set((GtkWidget*)mContainer, (GtkDestDefaults)0, nullptr, 0,
|
||||
(GdkDragAction)0);
|
||||
|
||||
g_signal_connect(mContainer, "drag_motion", G_CALLBACK(drag_motion_event_cb),
|
||||
nullptr);
|
||||
g_signal_connect(mContainer, "drag_leave", G_CALLBACK(drag_leave_event_cb),
|
||||
nullptr);
|
||||
g_signal_connect(mContainer, "drag_drop", G_CALLBACK(drag_drop_event_cb),
|
||||
nullptr);
|
||||
g_signal_connect(mContainer, "drag_data_received",
|
||||
G_CALLBACK(drag_data_received_event_cb), nullptr);
|
||||
|
||||
#ifdef MOZ_X11
|
||||
if (GdkIsX11Display()) {
|
||||
GtkWidget* widgets[] = {GTK_WIDGET(mContainer),
|
||||
|
@ -7934,9 +7933,17 @@ gboolean WindowDragMotionHandler(GtkWidget* aWidget,
|
|||
innerMostWindow = window;
|
||||
}
|
||||
|
||||
LOGDRAG("WindowDragMotionHandler nsWindow %p\n", (void*)innerMostWindow);
|
||||
int tx = 0, ty = 0;
|
||||
// Workaround for Bug 1710344
|
||||
// Caused by Gtk issue https://gitlab.gnome.org/GNOME/gtk/-/issues/4437
|
||||
if (GdkIsWaylandDisplay()) {
|
||||
gdk_window_get_position(innerWindow, &tx, &ty);
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint point = window->GdkPointToDevicePixels({retx, rety});
|
||||
LayoutDeviceIntPoint point =
|
||||
innerMostWindow->GdkPointToDevicePixels({retx + tx, rety + ty});
|
||||
LOGDRAG("WindowDragMotionHandler nsWindow %p coords [%d, %d]\n",
|
||||
innerMostWindow.get(), retx, rety);
|
||||
|
||||
RefPtr<nsDragService> dragService = nsDragService::GetInstance();
|
||||
if (!dragService->ScheduleMotionEvent(innerMostWindow, aDragContext,
|
||||
|
@ -8015,9 +8022,17 @@ gboolean WindowDragDropHandler(GtkWidget* aWidget, GdkDragContext* aDragContext,
|
|||
innerMostWindow = window;
|
||||
}
|
||||
|
||||
LOGDRAG("WindowDragDropHandler nsWindow %p\n", (void*)innerMostWindow);
|
||||
int tx = 0, ty = 0;
|
||||
// Workaround for Bug 1710344
|
||||
// Caused by Gtk issue https://gitlab.gnome.org/GNOME/gtk/-/issues/4437
|
||||
if (GdkIsWaylandDisplay()) {
|
||||
gdk_window_get_position(innerWindow, &tx, &ty);
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint point = window->GdkPointToDevicePixels({retx, rety});
|
||||
LayoutDeviceIntPoint point =
|
||||
window->GdkPointToDevicePixels({retx + tx, rety + ty});
|
||||
LOGDRAG("WindowDragDropHandler nsWindow %p coords [%d,%d]\n",
|
||||
innerMostWindow.get(), retx, rety);
|
||||
|
||||
RefPtr<nsDragService> dragService = nsDragService::GetInstance();
|
||||
return dragService->ScheduleDropEvent(innerMostWindow, aDragContext,
|
||||
|
|
Загрузка…
Ссылка в новой задаче