Hi, I’m working on a cross-platform tool using GTK.
It works fine on Linux distros and BSD variants.
But on Haiku (R1/beta4), drag-drop events (drag-data-received
) are ignored with the following message.
BHandler w>Tuw: MessageReceived() couldn't understand the message:
BMessage('DATA') {
src_window = (type = 'PNTR')(size = 8)
click_pt = BPoint(x:74, y:368)
TrackerViewToken = (type = 'MSNG')(size = 24)
refs = entry_ref(device=3, directory=2097309, name="license.txt", path="/boot/home/git/tuw/license.txt")
buttons = int32(0x1 or 1)
_drop_point_ = BPoint(x:305, y:163)
_drop_offset_ = BPoint(x:72, y:7)
}
Anyone know how to fix this?
To reproduce the situation, you can run the following commands.
pkgman install meson ninja gtk3_devel
git clone -b unix_support https://github.com/matyalatte/tuw.git
cd tuw
bash shell_scripts/build.sh Debug
cp examples/all_keys/gui_definition.json build/Debug
./build/Debug/Tuw
Then, you can drop a file on the first textbox in the tool’s window.
It should copy the file path into the textbox but it doesn’t.
You can also try libui-ng (a GUI library using GTK.)
libui-ng:master
← szanni:control-drag-destination
opened 04:18PM - 02 Nov 23 UTC
Add text and file drop for all uiControls on all platforms.
This introduces n… ew types:
- uiDragDestination: Holds accepted content types and callbacks
- uiDragContext: Context related to cursor position, supported drag operations and a reference to the dragged data itself
- uiDragData: the actual dragged data
You can then register the drag destination with a uiControl:
`uiControlRegisterDragDestination()`.
The `Drag and drop` documentation included should give you a good overview on the basic workings.
I currently only test `uiLabel` as a drag destination. All other controls *should* work but are untested by me (apart from `uiWindow`).
Any suggestions on how to go about testing all controls? Do a drag destination test for each control within the `qa` tester? Most controls are not tested within yet.
I would personally like to merge the other `qa` tests first to make sure I didn't break anything while refactoring the darwin code.
I believe this should also close/supersede [old PR #378](https://github.com/andlabs/libui/pull/378) as we already have `uiWindowOnContentSizeChanged()` , `uiWindowOnFocusChanged()`, `uiWindowOnClosing()` implemented upstream and file drop support will be provided by this PR.
Fixes #217 - at least the initial request. Custom mime types are not included in this PR, but this should be possible by adding a `uiDragDestinationSetAcceptedStringTypes()` or similar without interfering with the predefined types API, that most people will probably use.
QT for example provides a [conversion utility ](https://doc.qt.io/qt-6/qutimimeconverter.html) to convert from custom mimes to built in types. To me that honestly seems somewhat brittle. My thought are:
Provide a predefined types API via `uiDragDestinationAcceptedTypes`.
Provide a mime type API via `uiDragDestinationAcceptedStringTypes` and filter out the overlapping predefined types.
Reviews welcome. This is a massive change set.
The PR has the same issue on Haiku.
To reproduce the situation, you can run the following command.
pkgman install meson ninja gtk3_devel
git clone -b control-drag-destination https://github.com/szanni/libui-ng.git
cd libui-ng
meson setup build
meson compile -C build
./build/meson-out/qa
Then, you can do the qa test for drag-drop events.(uiDragDestination > 7.Drag Context Drag Data > Step 1
)
The qa test fails with the message about BMessage
.
1 Like
I don’t know if the Wayland compatibility layer that GTK is running on understands drag-and-drop at all. CC @X512 .
X512
February 28, 2024, 8:37pm
3
I have experimental drag & drop support for Haiku Wayland, but I feel it is currently not ready for everyday use. There are various difference between Haiku and Wayland drag&drop behavior.
5 Likes
Thanks for the replies. I didn’t know the wayland layer is WIP. I’ll add a note about it to the document of my tool.