JDK-8211302 : DragAndDrop no longer works with GTK3
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8u202,openjfx11
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2018-09-28
  • Updated: 2022-01-20
  • Resolved: 2019-06-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8u231Fixed openjfx11.0.5Fixed
Related Reports
Blocks :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Linux Mint 19

A DESCRIPTION OF THE PROBLEM :
The startDragAndDrop method no longer works with GTK3

REGRESSION : Last worked in version 10.0.2

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the source code and try to drag from the test button. Nothing is happening...

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The possibility of dragging
ACTUAL -
Nothing is happening.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.TransferMode;
import javafx.stage.Stage;

//Workaround: -Djdk.gtk.version=2
public class Fx11draggError extends Application{

	@Override
	public void start(Stage stage) throws Exception {
		Button button = new Button("test");
		button.setOnDragDetected(e -> {
			ClipboardContent content = new ClipboardContent();
			content.putString("It works");
			button.startDragAndDrop(TransferMode.MOVE).setContent(content);
			e.consume();
		});
		stage.setScene(new Scene(button, 200, 200));
		stage.show();
	}
	
	public static void main(String[] args) {
		launch();
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
use -Djdk.gtk.version=2

FREQUENCY : always



Comments
Changeset: 981cff5755bc Author: tsayao Date: 2019-06-04 14:53 -0700 URL: http://hg.openjdk.java.net/openjfx/jfx-dev/rt/rev/981cff5755bc 8211302: DragAndDrop no longer works with GTK3 Reviewed-by: kcr, pbansal
04-06-2019

PR: https://github.com/javafxports/openjdk-jfx/pull/473
18-05-2019

Thanks for checking. Given the description of the failure, this isn't a surprise to me. The described failure seems more related to the start of a drag operation than the drop operation at the end.
22-04-2019

I tried, but this does not seem to work for me.
22-04-2019

The attached 8211302-drag-drop-done.patch calls gdk_drag_drop_done on GTK 3 if the function exists. [~pbansal] [~psadhukhan] Can one of you test it?
19-04-2019

We can't use GTK 3.20 functions directly or else it will not build or run on earlier versions of GTK 3. Further, in shared code, we can't even assume GTK 3 since it still needs to compile on GTK 2. If this does turn out to be the solution, then we will need to create a wrapper function for it and use dlsym to call it in the gtk3 case (it would just be a no-op in the gtk 2 case). I don't have a system I could test it on (I'm running Ubuntu 16.04 still, which has GTK 3.18), but the same pattern used to call gdk_x11_display_set_window_scale would be used.
19-04-2019

[~pbansal] maybe we need to use gdk_drag_drop_done after the DnD is done https://developer.gnome.org/gdk3/stable/gdk3-Drag-and-Drop.html#gdk-drag-drop-done [introduced in gtk 3.20] I tried --- a/modules/javafx.graphics/src/main/native-glass/gtk/glass_dnd.cpp +++ b/modules/javafx.graphics/src/main/native-glass/gtk/glass_dnd.cpp @@ -821,6 +821,7 @@ if (gdk_drag_context_get_selected_action(get_drag_context())) { gdk_drag_drop(get_drag_context(), GDK_CURRENT_TIME); + gdk_drag_drop_done(get_drag_context(), TRUE); } else { gdk_drag_abort(get_drag_context(), GDK_CURRENT_TIME); /* let the gdk_drag_abort messages handled before finish */ but it seems somewhere in gradle we need to change something as I am getting some build issue rt/modules/javafx.graphics/src/main/native-glass/gtk/glass_dnd.cpp:825:9: error: ‘gdk_drag_drop_done’ was not declared in this scope gdk_drag_drop_done(get_drag_context(), TRUE); ^~~~~~~~~~~~~~~~~~ /export/openjfx/jfx-dev/rt/modules/javafx.graphics/src/main/native-glass/gtk/glass_dnd.cpp:825:9: note: suggested alternative: ‘gdk_drag_drop’ gdk_drag_drop_done(get_drag_context(), TRUE); ^~~~~~~~~~~~~~~~~~
19-04-2019

[~pbansal] [~psrivastava] this is a must-fix to make GTK3 default on JavaFX
15-04-2019

I don't know whether it is the same issue, but I discovered that one of the new unit tests provided with JDK-8211248, DragDropFromSwingComponentInSwingNodeTest, also fails with GTK 3 but works with GTK 2.
08-01-2019

Can someone please reply to my earlier comment and provide necessary clarification?
27-12-2018

I tried this with javafx12 code. Its not very clear as what is supposed to happen with the reproducer, so I am writing what I have seen. With gtk2: If I drag the button and leave outside the java window, I see a dragged.txt with "It works" or the text "It works" comes on terminal. With gtk3: The text comes on terminal as gtk2, but I don't see a dragged.txt. I assume this is whats being referred to DragAndDrop. So accepting this bug. Please clarify if this is not the case.
20-11-2018

This is a glass GTK 3 bug. From FX 11, GTK3 is now the default. In JDK 10 and earlier, GTK 2 was the default. Running JDK 11 with -Djdk.gtk.version=2 will force the use of GTK 2.
01-10-2018