summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-02-01 16:31:09 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-02-12 13:08:07 -0500
commitb07c1b51929e964df196b1afe4e5528daceb13d4 (patch)
treec11979ecd726db75adb960cec2f0ad1bf12844cb
parentadc2be188c2c40e4f3faa72e36e599e249aa9dce (diff)
-rw-r--r--src/lib/ecore/ecore_main.c5
-rw-r--r--src/lib/ecore_wl2/Ecore_Wl2.h15
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_display.c100
-rw-r--r--src/lib/elementary/elm_main.c1
4 files changed, 115 insertions, 6 deletions
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index 214f73215e..90d1b9739d 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -1132,11 +1132,6 @@ _ecore_main_loop_begin(Eo *obj, Efl_Loop_Data *pd)
1132{ 1132{
1133 if (obj == ML_OBJ) 1133 if (obj == ML_OBJ)
1134 { 1134 {
1135 if (pd->in_loop > 0)
1136 {
1137 ERR("Beginning main loop() inside an existing main loop");
1138 return;
1139 }
1140#ifdef HAVE_SYSTEMD 1135#ifdef HAVE_SYSTEMD
1141 sd_notify(0, "READY=1"); 1136 sd_notify(0, "READY=1");
1142#endif 1137#endif
diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index 238aaef63b..e778cfa76f 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -513,6 +513,21 @@ EAPI int ecore_wl2_shutdown(void);
513EAPI Ecore_Wl2_Display *ecore_wl2_display_create(const char *name); 513EAPI Ecore_Wl2_Display *ecore_wl2_display_create(const char *name);
514 514
515/** 515/**
516 * Create a new Wayland display
517 *
518 * @brief This function is the same as ecore_wl2_display_create() except
519 * that it calls wl_display_add_socket_fd.
520 *
521 * @param name The display target name to create. If @c NULL, a default
522 * display name will be assigned.
523 * @return The newly created Ecore_Wl2_Display
524 *
525 * @ingroup Ecore_Wl2_Display_Group
526 * @since 1.21
527 */
528EAPI Ecore_Wl2_Display *ecore_wl2_display_manual_create(const char *name);
529
530/**
516 * Destroy an existing Wayland display 531 * Destroy an existing Wayland display
517 * 532 *
518 * @brief This function is typically used by servers to terminate an 533 * @brief This function is typically used by servers to terminate an
diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c
index 4ee8cd6d59..4ca950328c 100644
--- a/src/lib/ecore_wl2/ecore_wl2_display.c
+++ b/src/lib/ecore_wl2/ecore_wl2_display.c
@@ -3,7 +3,8 @@
3#endif 3#endif
4 4
5#include "ecore_wl2_private.h" 5#include "ecore_wl2_private.h"
6 6#include <sys/socket.h>
7#include <sys/un.h>
7#include "linux-dmabuf-unstable-v1-client-protocol.h" 8#include "linux-dmabuf-unstable-v1-client-protocol.h"
8#include "efl-hints-client-protocol.h" 9#include "efl-hints-client-protocol.h"
9 10
@@ -881,6 +882,103 @@ found:
881 return ewd; 882 return ewd;
882} 883}
883 884
885EAPI Ecore_Wl2_Display *
886ecore_wl2_display_manual_create(const char *name)
887{
888 Ecore_Wl2_Display *ewd;
889 struct wl_event_loop *loop;
890 int fd = -1;
891 struct sockaddr_un addr = { .sun_family = AF_LOCAL };
892 socklen_t addrlen;
893 char *rundir;
894
895 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
896
897 if (!_server_displays)
898 _server_displays = eina_hash_string_superfast_new(NULL);
899
900 /* someone wants to create a server with a specific display */
901
902 /* check hash of cached server displays for this name */
903 ewd = eina_hash_find(_server_displays, name);
904 if (ewd) goto found;
905
906 rundir = getenv("XDG_RUNTIME_DIR");
907 EINA_SAFETY_ON_NULL_RETURN_VAL(rundir, NULL);
908 fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
909 EINA_SAFETY_ON_TRUE_RETURN_VAL(fd < 0, NULL);
910 addrlen = snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s", rundir, name) + 1;
911 if (bind(fd, (struct sockaddr*)&addr, addrlen))
912 {
913 close(fd);
914 ERR("bind failed");
915 return NULL;
916 }
917 if (listen(fd, 128))
918 {
919 close(fd);
920 ERR("listen failed");
921 return NULL;
922 }
923
924 /* allocate space for display structure */
925 ewd = calloc(1, sizeof(Ecore_Wl2_Display));
926 if (!ewd)
927 {
928 close(fd);
929 return NULL;
930 }
931
932 ewd->refs++;
933 ewd->pid = getpid();
934
935 /* try to create new wayland display */
936 ewd->wl.display = wl_display_create();
937 if (!ewd->wl.display)
938 {
939 ERR("Could not create wayland display");
940 goto create_err;
941 }
942
943 if (wl_display_add_socket_fd(ewd->wl.display, fd))
944 {
945 ERR("Failed to add display socket");
946 goto socket_err;
947 }
948
949 ewd->name = strdup(name);
950
951 setenv("WAYLAND_DISPLAY", ewd->name, 1);
952 DBG("WAYLAND_DISPLAY: %s", ewd->name);
953
954 loop = wl_display_get_event_loop(ewd->wl.display);
955
956 ewd->fd_hdl =
957 ecore_main_fd_handler_add(wl_event_loop_get_fd(loop),
958 ECORE_FD_READ | ECORE_FD_ERROR,
959 _cb_create_data, ewd, NULL, NULL);
960
961 ecore_main_fd_handler_prepare_callback_set(ewd->fd_hdl,
962 _cb_create_prepare, ewd);
963
964 /* add this new server display to hash */
965 eina_hash_add(_server_displays, ewd->name, ewd);
966
967 return ewd;
968
969socket_err:
970 wl_display_destroy(ewd->wl.display);
971
972create_err:
973 close(fd);
974 free(ewd);
975 return NULL;
976
977found:
978 ewd->refs++;
979 return ewd;
980}
981
884Eina_Bool 982Eina_Bool
885_ecore_wl2_display_sync_get(void) 983_ecore_wl2_display_sync_get(void)
886{ 984{
diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c
index f588c1e95e..ba46f24bb8 100644
--- a/src/lib/elementary/elm_main.c
+++ b/src/lib/elementary/elm_main.c
@@ -1098,6 +1098,7 @@ elm_quicklaunch_fork(int argc,
1098 pid_t child; 1098 pid_t child;
1099 int ret; 1099 int ret;
1100 1100
1101 efl_loop_message_process(efl_loop_main_get(EFL_LOOP_CLASS));
1101 if (!qr_main && !qre_main) 1102 if (!qr_main && !qre_main)
1102 { 1103 {
1103 int i; 1104 int i;