Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8280994: [XWayland] Drag and Drop does not work in java -> wayland app direction #14266

Closed
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,6 +27,7 @@

import java.awt.Component;
import java.awt.Cursor;
import java.awt.Toolkit;
import java.awt.Window;

import java.awt.datatransfer.DataFlavor;
Expand Down Expand Up @@ -392,6 +393,41 @@ private boolean updateSourceAction(int state) {
return true;
}

/**
* Our X11 code expects the drop target window to be a top level window
* and to have the XA_WM_STATE property.
* This is not true when performing drag and drop from XWayland
* to a native Wayland application.
* In this case XWayland creates a dummy window with only one property,
* XdndAware.
*
* @param window to test
* @return true if window has XdndAware property when running under Wayland
*/
private static boolean isXWaylandDndAwareWindow(long window) {
if (Toolkit.getDefaultToolkit() instanceof SunToolkit sunToolkit
azvegint marked this conversation as resolved.
Show resolved Hide resolved
&& !sunToolkit.isRunningOnWayland()) {
return false;
}

WindowPropertyGetter wpg =
new WindowPropertyGetter(window,
XDnDConstants.XA_XdndAware,
0, 1, false,
XConstants.AnyPropertyType);
azvegint marked this conversation as resolved.
Show resolved Hide resolved

try {
int status = wpg.execute(XErrorHandler
.IgnoreBadWindowHandler.getInstance());
azvegint marked this conversation as resolved.
Show resolved Hide resolved

return status == XConstants.Success
&& wpg.getData() != 0
&& wpg.getActualType() == XAtom.XA_ATOM;
azvegint marked this conversation as resolved.
Show resolved Hide resolved
} finally {
wpg.dispose();
}
}

/**
* Returns the client window under the specified root subwindow.
*/
Expand All @@ -408,6 +444,10 @@ private static long findClientWindow(long window) {
}
}

if (isXWaylandDndAwareWindow(window)) {
azvegint marked this conversation as resolved.
Show resolved Hide resolved
return window;
}

return 0;
}

Expand Down