Skip to content

Commit dc3965b

Browse files
committed
wayland: Open content from drag and drop
1 parent d2dae40 commit dc3965b

File tree

6 files changed

+107
-3
lines changed

6 files changed

+107
-3
lines changed

Makefile.common

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

12961296
endif
12971297

1298+
ifeq ($(HAVE_GLIB), 1)
1299+
DEF_FLAGS += $(GLIB_CFLAGS)
1300+
LIBS += $(GLIB_LIBS)
1301+
endif
1302+
12981303
# XML
12991304
OBJ += \
13001305
$(LIBRETRO_COMM_DIR)/formats/xml/rxml.o \

input/common/wayland_common.c

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

21+
#ifdef HAVE_CONFIG_H
22+
#include "../config.h"
23+
#endif
24+
25+
#ifdef HAVE_GLIB
26+
#include <glib.h>
27+
#endif
28+
29+
#include "../../tasks/task_content.h"
30+
#include "../../paths.h"
31+
2132
#include <stdint.h>
2233
#include <string.h>
2334

@@ -1037,9 +1048,8 @@ static void wl_data_device_handle_drop(void *data,
10371048

10381049
/* TODO/FIXME: Convert from file:// URI, Implement file loading
10391050
* Drag and Drop */
1040-
#if 0
1041-
if (wayland_load_content_from_drop(g_filename_from_uri(line, NULL, NULL)))
1042-
RARCH_WARN("----- wayland_load_content_from_drop success\n");
1051+
#ifdef HAVE_GLIB
1052+
path_set(RARCH_PATH_NEXT_CONTENT, g_filename_from_uri(line, NULL, NULL));
10431053
#endif
10441054
}
10451055

paths.h

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum rarch_path_type
5050
RARCH_PATH_NAMES,
5151
RARCH_PATH_CONFIG,
5252
RARCH_PATH_CONTENT,
53+
RARCH_PATH_NEXT_CONTENT,
5354
RARCH_PATH_CONFIG_APPEND,
5455
RARCH_PATH_CONFIG_OVERRIDE,
5556
RARCH_PATH_CORE_OPTIONS,

qb/config.libs.sh

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

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

qb/config.params.sh

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

retroarch.c

+86
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ struct rarch_state
315315
char launch_arguments[4096];
316316
char path_default_shader_preset[PATH_MAX_LENGTH];
317317
char path_content[PATH_MAX_LENGTH];
318+
char path_next_content[PATH_MAX_LENGTH];
318319
char path_libretro[PATH_MAX_LENGTH];
319320
char path_config_file[PATH_MAX_LENGTH];
320321
char path_config_append_file[PATH_MAX_LENGTH];
@@ -2400,6 +2401,8 @@ char *path_get_ptr(enum rarch_path_type type)
24002401
{
24012402
case RARCH_PATH_CONTENT:
24022403
return p_rarch->path_content;
2404+
case RARCH_PATH_NEXT_CONTENT:
2405+
return p_rarch->path_next_content;
24032406
case RARCH_PATH_DEFAULT_SHADER_PRESET:
24042407
return p_rarch->path_default_shader_preset;
24052408
case RARCH_PATH_BASENAME:
@@ -2440,6 +2443,8 @@ const char *path_get(enum rarch_path_type type)
24402443
{
24412444
case RARCH_PATH_CONTENT:
24422445
return p_rarch->path_content;
2446+
case RARCH_PATH_NEXT_CONTENT:
2447+
return p_rarch->path_next_content;
24432448
case RARCH_PATH_DEFAULT_SHADER_PRESET:
24442449
return p_rarch->path_default_shader_preset;
24452450
case RARCH_PATH_CORE_OPTIONS:
@@ -2480,6 +2485,8 @@ size_t path_get_realsize(enum rarch_path_type type)
24802485
{
24812486
case RARCH_PATH_CONTENT:
24822487
return sizeof(p_rarch->path_content);
2488+
case RARCH_PATH_NEXT_CONTENT:
2489+
return sizeof(p_rarch->path_next_content);
24832490
case RARCH_PATH_DEFAULT_SHADER_PRESET:
24842491
return sizeof(p_rarch->path_default_shader_preset);
24852492
case RARCH_PATH_CORE_OPTIONS:
@@ -2548,6 +2555,10 @@ bool path_set(enum rarch_path_type type, const char *path)
25482555
strlcpy(p_rarch->path_content, path,
25492556
sizeof(p_rarch->path_content));
25502557
break;
2558+
case RARCH_PATH_NEXT_CONTENT:
2559+
strlcpy(p_rarch->path_next_content, path,
2560+
sizeof(p_rarch->path_next_content));
2561+
break;
25512562
case RARCH_PATH_NONE:
25522563
break;
25532564
case RARCH_PATH_BASENAME:
@@ -2595,6 +2606,10 @@ bool path_is_empty(enum rarch_path_type type)
25952606
if (string_is_empty(p_rarch->path_content))
25962607
return true;
25972608
break;
2609+
case RARCH_PATH_NEXT_CONTENT:
2610+
if (string_is_empty(p_rarch->path_next_content))
2611+
return true;
2612+
break;
25982613
case RARCH_PATH_CORE:
25992614
if (string_is_empty(p_rarch->path_libretro))
26002615
return true;
@@ -2631,6 +2646,9 @@ void path_clear(enum rarch_path_type type)
26312646
case RARCH_PATH_CONTENT:
26322647
*p_rarch->path_content = '\0';
26332648
break;
2649+
case RARCH_PATH_NEXT_CONTENT:
2650+
*p_rarch->path_next_content = '\0';
2651+
break;
26342652
case RARCH_PATH_CORE_OPTIONS:
26352653
*p_rarch->path_core_options_file = '\0';
26362654
break;
@@ -2660,6 +2678,7 @@ void path_clear(enum rarch_path_type type)
26602678
static void path_clear_all(void)
26612679
{
26622680
path_clear(RARCH_PATH_CONTENT);
2681+
path_clear(RARCH_PATH_NEXT_CONTENT);
26632682
path_clear(RARCH_PATH_CONFIG);
26642683
path_clear(RARCH_PATH_CONFIG_APPEND);
26652684
path_clear(RARCH_PATH_CONFIG_OVERRIDE);
@@ -5785,6 +5804,68 @@ void main_exit(void *args)
57855804
#endif
57865805
}
57875806

5807+
5808+
static bool load_next_content(const char* path)
5809+
{
5810+
core_info_list_t *core_info_list = NULL;
5811+
core_info_get_list(&core_info_list);
5812+
if (core_info_list)
5813+
{
5814+
size_t list_size;
5815+
content_ctx_info_t content_info = { 0 };
5816+
const core_info_t *core_info = NULL;
5817+
core_info_list_get_supported_cores(core_info_list,
5818+
(const char*)path, &core_info, &list_size);
5819+
if (list_size)
5820+
{
5821+
path_set(RARCH_PATH_CONTENT, path);
5822+
5823+
if (!path_is_empty(RARCH_PATH_CONTENT))
5824+
{
5825+
unsigned i;
5826+
core_info_t *current_core = NULL;
5827+
core_info_get_current_core(&current_core);
5828+
5829+
/*we already have path for libretro core */
5830+
for (i = 0; i < list_size; i++)
5831+
{
5832+
const core_info_t *info = (const core_info_t*)&core_info[i];
5833+
5834+
if (string_is_equal(path_get(RARCH_PATH_CORE), info->path))
5835+
{
5836+
/* Our previous core supports the current rom */
5837+
task_push_load_content_with_current_core_from_companion_ui(
5838+
NULL,
5839+
&content_info,
5840+
CORE_TYPE_PLAIN,
5841+
NULL, NULL);
5842+
return true;
5843+
}
5844+
}
5845+
}
5846+
}
5847+
5848+
if (list_size >= 1)
5849+
{
5850+
/*pick core that only exists and is bound to work. Ish. */
5851+
const core_info_t *info = (const core_info_t*)&core_info[0];
5852+
5853+
if (info)
5854+
{
5855+
task_push_load_content_with_new_core_from_companion_ui(
5856+
info->path, NULL, NULL, NULL, NULL, &content_info, NULL, NULL);
5857+
return true;
5858+
}
5859+
}
5860+
else
5861+
{
5862+
RARCH_WARN("There are no core to open %s\n", path);
5863+
}
5864+
}
5865+
5866+
return false;
5867+
}
5868+
57885869
/**
57895870
* main_entry:
57905871
*
@@ -5888,6 +5969,11 @@ int rarch_main(int argc, char *argv[], void *data)
58885969
{
58895970
int ret;
58905971
bool app_exit = false;
5972+
5973+
if (!path_is_empty(RARCH_PATH_NEXT_CONTENT) && !string_is_equal(path_get(RARCH_PATH_CONTENT), path_get(RARCH_PATH_NEXT_CONTENT))) {
5974+
load_next_content(path_get(RARCH_PATH_NEXT_CONTENT));
5975+
}
5976+
58915977
#ifdef HAVE_QT
58925978
ui_companion_qt.application->process_events();
58935979
#endif

0 commit comments

Comments
 (0)