Fix drag targets and force X11 backend for embedded mpv

This commit is contained in:
Stu 2025-12-13 22:24:07 -05:00
parent bec66816df
commit 4d33e1ec71
2 changed files with 18 additions and 6 deletions

View File

@ -236,6 +236,7 @@ func getWindowID(w *gdk.Window) uint64 {
if w == nil {
return 0
}
// gdk_x11_window_get_xid only works on X11; return 0 on other backends.
return uint64(gdkWindowGetXID(w))
}
@ -267,7 +268,8 @@ func preferDark() {
func setupDragDest(p *pane, win *gtk.Window) {
// Accept URI drops
p.area.DragDestSet(gtk.DEST_DEFAULT_ALL, []gtk.TargetEntry{gtk.TargetEntry{}} /* dummy */, gdk.ACTION_COPY)
target := gtk.TargetEntryNew("text/uri-list", gtk.TARGET_OTHER_APP, 0)
p.area.DragDestSet(gtk.DEST_DEFAULT_ALL, []gtk.TargetEntry{*target}, gdk.ACTION_COPY)
p.area.Connect("drag-data-received", func(_ *gtk.DrawingArea, ctx *gdk.DragContext, x, y int, data *gtk.SelectionData, info uint, t uint32) {
uris := data.GetURIs()
if len(uris) == 0 {

View File

@ -4,13 +4,27 @@
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BUILD_OUTPUT="$PROJECT_ROOT/vt_player"
GTK_ENTRY="$PROJECT_ROOT/cmd/gtkplayer"
echo "════════════════════════════════════════════════════════════════"
echo " VT Player - Run Script"
echo "════════════════════════════════════════════════════════════════"
echo ""
# Check if binary exists
# If a GTK entry exists, run it directly (uses mpv embedded)
if [ -d "$GTK_ENTRY" ]; then
echo "🚀 Starting VT Player (GTK/mpv)..."
echo "════════════════════════════════════════════════════════════════"
echo ""
export GDK_BACKEND=x11
export GOCACHE="$PROJECT_ROOT/.cache/go-build"
export GOMODCACHE="$PROJECT_ROOT/.cache/go-mod"
GOCACHE="$GOCACHE" GOMODCACHE="$GOMODCACHE" \
go run "$GTK_ENTRY"
exit $?
fi
# Fallback to legacy binary
if [ ! -f "$BUILD_OUTPUT" ]; then
echo "⚠️ Binary not found. Building..."
echo ""
@ -18,7 +32,6 @@ if [ ! -f "$BUILD_OUTPUT" ]; then
echo ""
fi
# Verify binary exists
if [ ! -f "$BUILD_OUTPUT" ]; then
echo "❌ ERROR: Build failed, cannot run."
exit 1
@ -28,12 +41,9 @@ echo "🚀 Starting VT Player..."
echo "════════════════════════════════════════════════════════════════"
echo ""
# Optional software rendering fallback:
# Default to software (avoid GLX errors); set VTPLAYER_HW=1 to force hardware.
if [ "$VTPLAYER_HW" != "1" ]; then
export FYNE_SW_CANVAS=1
export LIBGL_ALWAYS_SOFTWARE=1
fi
# Run the application
"$BUILD_OUTPUT" "$@"