|
18 | 18 | #define _GNU_SOURCE /* See feature_test_macros(7) */
|
19 | 19 | #endif
|
20 | 20 |
|
| 21 | +#ifdef HAVE_GLIB |
| 22 | +#include <glib.h> |
| 23 | +#endif |
| 24 | +#include "../../tasks/task_content.h" |
| 25 | +#include "../../paths.h" |
| 26 | + |
21 | 27 | #include <stdint.h>
|
22 | 28 | #include <string.h>
|
23 | 29 |
|
@@ -947,6 +953,67 @@ static void wl_data_device_handle_motion(void *data,
|
947 | 953 | struct wl_data_device *data_device, uint32_t time,
|
948 | 954 | wl_fixed_t x, wl_fixed_t y) { }
|
949 | 955 |
|
| 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(¤t_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 | + |
950 | 1017 | static void wl_data_device_handle_drop(void *data,
|
951 | 1018 | struct wl_data_device *data_device)
|
952 | 1019 | {
|
@@ -994,7 +1061,7 @@ static void wl_data_device_handle_drop(void *data,
|
994 | 1061 |
|
995 | 1062 | /* TODO/FIXME: Convert from file:// URI, Implement file loading
|
996 | 1063 | * Drag and Drop */
|
997 |
| -#if 0 |
| 1064 | +#ifdef HAVE_GLIB |
998 | 1065 | if (wayland_load_content_from_drop(g_filename_from_uri(line, NULL, NULL)))
|
999 | 1066 | RARCH_WARN("----- wayland_load_content_from_drop success\n");
|
1000 | 1067 | #endif
|
|
0 commit comments