Bug 1730533 [Linux] Use Drag and Drop popups on Gtk >= 3.24 r=rmader

Differential Revision: https://phabricator.services.mozilla.com/D129494
This commit is contained in:
stransky 2021-11-02 07:34:35 +00:00
parent 74c0beb525
commit 1701b68173

View File

@ -1717,6 +1717,8 @@ void nsDragService::SourceBeginDrag(GdkDragContext* aContext) {
void nsDragService::SetDragIcon(GdkDragContext* aContext) {
if (!mHasImage && !mSelection) return;
LOGDRAGSERVICE(("nsDragService::SetDragIcon()"));
LayoutDeviceIntRect dragRect;
nsPresContext* pc;
RefPtr<SourceSurface> surface;
@ -1734,13 +1736,20 @@ void nsDragService::SetDragIcon(GdkDragContext* aContext) {
// XXX: Disable drag popups on GTK 3.19.4 and above: see bug 1264454.
// Fix this once a new GTK version ships that does not destroy our
// widget in gtk_drag_set_icon_widget.
if (mDragPopup && gtk_check_version(3, 19, 4)) {
// This is fixed in GTK 3.24
// by
// https://gitlab.gnome.org/GNOME/gtk/-/commit/c27c4e2048acb630feb24c31288f802345e99f4c
bool gtk_drag_set_icon_widget_is_working =
gtk_check_version(3, 19, 4) != nullptr ||
gtk_check_version(3, 24, 0) == nullptr;
if (mDragPopup && gtk_drag_set_icon_widget_is_working) {
GtkWidget* gtkWidget = nullptr;
nsIFrame* frame = mDragPopup->GetPrimaryFrame();
if (frame) {
// DrawDrag ensured that this is a popup frame.
nsCOMPtr<nsIWidget> widget = frame->GetNearestWidget();
if (widget) {
LOGDRAGSERVICE((" set drag popup [%p]", widget.get()));
gtkWidget = (GtkWidget*)widget->GetNativeData(NS_NATIVE_SHELLWIDGET);
if (gtkWidget) {
OpenDragPopup();
@ -1753,6 +1762,7 @@ void nsDragService::SetDragIcon(GdkDragContext* aContext) {
GdkPixbuf* dragPixbuf = nsImageToPixbuf::SourceSurfaceToPixbuf(
surface, dragRect.width, dragRect.height);
if (dragPixbuf) {
LOGDRAGSERVICE((" set drag pixbuf"));
gtk_drag_set_icon_pixbuf(aContext, dragPixbuf, offsetX, offsetY);
g_object_unref(dragPixbuf);
}