Skip to content

Commit 5ee7a43

Browse files
committed
wayland: Open content from drag and drop
1 parent c2eddfb commit 5ee7a43

File tree

4 files changed

+75
-1
lines changed

4 files changed

+75
-1
lines changed

Makefile.common

+5
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,11 @@ ifeq ($(HAVE_WAYLAND), 1)
12651265

12661266
endif
12671267

1268+
ifeq (${HAVE_GLIB}, 1)
1269+
DEF_FLAGS += $(GLIB_CFLAGS)
1270+
LIBS += $(GLIB_LIBS)
1271+
endif
1272+
12681273
# XML
12691274
OBJ += \
12701275
$(LIBRETRO_COMM_DIR)/formats/xml/rxml.o \

input/common/wayland_common.c

+68-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#define _GNU_SOURCE /* See feature_test_macros(7) */
1919
#endif
2020

21+
#ifdef HAVE_GLIB
22+
#include <glib.h>
23+
#endif
24+
#include "../../tasks/task_content.h"
25+
#include "../../paths.h"
26+
2127
#include <stdint.h>
2228
#include <string.h>
2329

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

956+
static bool wayland_load_content_from_drop(const char* path)
957+
{
958+
core_info_list_t *core_info_list = NULL;
959+
core_info_get_list(&core_info_list);
960+
if (core_info_list)
961+
{
962+
size_t list_size;
963+
content_ctx_info_t content_info = { 0 };
964+
const core_info_t *core_info = NULL;
965+
core_info_list_get_supported_cores(core_info_list,
966+
(const char*)path, &core_info, &list_size);
967+
if (list_size)
968+
{
969+
path_set(RARCH_PATH_CONTENT, path);
970+
971+
if (!path_is_empty(RARCH_PATH_CONTENT))
972+
{
973+
unsigned i;
974+
core_info_t *current_core = NULL;
975+
core_info_get_current_core(&current_core);
976+
977+
/*we already have path for libretro core */
978+
for (i = 0; i < list_size; i++)
979+
{
980+
const core_info_t *info = (const core_info_t*)&core_info[i];
981+
982+
if (string_is_equal(path_get(RARCH_PATH_CORE), info->path))
983+
{
984+
/* Our previous core supports the current rom */
985+
task_push_load_content_with_current_core_from_companion_ui(
986+
NULL,
987+
&content_info,
988+
CORE_TYPE_PLAIN,
989+
NULL, NULL);
990+
return true;
991+
}
992+
}
993+
}
994+
}
995+
996+
if (list_size >= 1)
997+
{
998+
/*pick core that only exists and is bound to work. Ish. */
999+
const core_info_t *info = (const core_info_t*)&core_info[0];
1000+
1001+
if (info)
1002+
{
1003+
task_push_load_content_with_new_core_from_companion_ui(
1004+
info->path, NULL, NULL, NULL, NULL, &content_info, NULL, NULL);
1005+
return true;
1006+
}
1007+
}
1008+
else
1009+
{
1010+
RARCH_WARN("There are no core to open %s\n", path);
1011+
}
1012+
}
1013+
1014+
return false;
1015+
}
1016+
9501017
static void wl_data_device_handle_drop(void *data,
9511018
struct wl_data_device *data_device)
9521019
{
@@ -994,7 +1061,7 @@ static void wl_data_device_handle_drop(void *data,
9941061

9951062
/* TODO/FIXME: Convert from file:// URI, Implement file loading
9961063
* Drag and Drop */
997-
#if 0
1064+
#ifdef HAVE_GLIB
9981065
if (wayland_load_content_from_drop(g_filename_from_uri(line, NULL, NULL)))
9991066
RARCH_WARN("----- wayland_load_content_from_drop success\n");
10001067
#endif

qb/config.libs.sh

+1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ else
264264
check_lib '' AL -lopenal alcOpenDevice
265265
fi
266266

267+
check_pkgconf GLIB glib-2.0 2.78.0
267268
check_pkgconf RSOUND rsound 1.1
268269
check_pkgconf ROAR libroar 1.0.12
269270
check_val '' JACK -ljack '' jack 0.120.1 '' false

qb/config.params.sh

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ HAVE_WAYLAND=auto # Wayland support
104104
HAVE_LIBDECOR=auto # libdecor support
105105
C89_WAYLAND=no
106106
CXX_WAYLAND=no
107+
HAVE_GLIB=auto # GLib support
107108
HAVE_DYNAMIC_EGL=no # Dynamic library EGL support
108109
HAVE_EGL=auto # EGL context support
109110
HAVE_VG=auto # OpenVG support

0 commit comments

Comments
 (0)