Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wayland: Open content from drag and drop #16443

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading