Skip to content

Commit

Permalink
wayland: Open content from drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinKinloch committed Apr 18, 2024
1 parent c2eddfb commit 5ee7a43
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,11 @@ ifeq ($(HAVE_WAYLAND), 1)

endif

ifeq (${HAVE_GLIB}, 1)
DEF_FLAGS += $(GLIB_CFLAGS)
LIBS += $(GLIB_LIBS)
endif

# XML
OBJ += \
$(LIBRETRO_COMM_DIR)/formats/xml/rxml.o \
Expand Down
69 changes: 68 additions & 1 deletion input/common/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
#define _GNU_SOURCE /* See feature_test_macros(7) */
#endif

#ifdef HAVE_GLIB
#include <glib.h>
#endif
#include "../../tasks/task_content.h"
#include "../../paths.h"

#include <stdint.h>
#include <string.h>

Expand Down Expand Up @@ -947,6 +953,67 @@ static void wl_data_device_handle_motion(void *data,
struct wl_data_device *data_device, uint32_t time,
wl_fixed_t x, wl_fixed_t y) { }

static bool wayland_load_content_from_drop(const char* path)
{
core_info_list_t *core_info_list = NULL;
core_info_get_list(&core_info_list);
if (core_info_list)
{
size_t list_size;
content_ctx_info_t content_info = { 0 };
const core_info_t *core_info = NULL;
core_info_list_get_supported_cores(core_info_list,
(const char*)path, &core_info, &list_size);
if (list_size)
{
path_set(RARCH_PATH_CONTENT, path);

if (!path_is_empty(RARCH_PATH_CONTENT))
{
unsigned i;
core_info_t *current_core = NULL;
core_info_get_current_core(&current_core);

/*we already have path for libretro core */
for (i = 0; i < list_size; i++)
{
const core_info_t *info = (const core_info_t*)&core_info[i];

if (string_is_equal(path_get(RARCH_PATH_CORE), info->path))
{
/* Our previous core supports the current rom */
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
return true;
}
}
}
}

if (list_size >= 1)
{
/*pick core that only exists and is bound to work. Ish. */
const core_info_t *info = (const core_info_t*)&core_info[0];

if (info)
{
task_push_load_content_with_new_core_from_companion_ui(
info->path, NULL, NULL, NULL, NULL, &content_info, NULL, NULL);
return true;
}
}
else
{
RARCH_WARN("There are no core to open %s\n", path);
}
}

return false;
}

static void wl_data_device_handle_drop(void *data,
struct wl_data_device *data_device)
{
Expand Down Expand Up @@ -994,7 +1061,7 @@ static void wl_data_device_handle_drop(void *data,

/* TODO/FIXME: Convert from file:// URI, Implement file loading
* Drag and Drop */
#if 0
#ifdef HAVE_GLIB
if (wayland_load_content_from_drop(g_filename_from_uri(line, NULL, NULL)))
RARCH_WARN("----- wayland_load_content_from_drop success\n");
#endif
Expand Down
1 change: 1 addition & 0 deletions qb/config.libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ else
check_lib '' AL -lopenal alcOpenDevice
fi

check_pkgconf GLIB glib-2.0 2.78.0
check_pkgconf RSOUND rsound 1.1
check_pkgconf ROAR libroar 1.0.12
check_val '' JACK -ljack '' jack 0.120.1 '' false
Expand Down
1 change: 1 addition & 0 deletions qb/config.params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ HAVE_WAYLAND=auto # Wayland support
HAVE_LIBDECOR=auto # libdecor support
C89_WAYLAND=no
CXX_WAYLAND=no
HAVE_GLIB=auto # GLib support
HAVE_DYNAMIC_EGL=no # Dynamic library EGL support
HAVE_EGL=auto # EGL context support
HAVE_VG=auto # OpenVG support
Expand Down

0 comments on commit 5ee7a43

Please sign in to comment.