1 /**************************************************************************
3 * eom (external output manager)
5 * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
8 * SooChan Lim <sc1.lim@samsung.com>
9 * Boram Park <boram1288.park@samsung.com>
10 * Changyeon Lee <cyeon.lee@samsung.com>
11 * JunKyeong Kim <jk0430.kim@samsung.com>
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sub license, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
21 * The above copyright notice and this permission notice (including the
22 * next paragraph) shall be included in all copies or substantial portions
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
28 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
29 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
30 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 **************************************************************************/
37 #include "eom_internal.h"
39 #include "eom-wayland.h"
40 #include "eom-private.h"
41 #include "../protocol/eom-client-protocol.h"
42 #include "xdg-shell-client-protocol.h"
43 #include <Ecore_Wayland.h>
45 typedef struct _EomWaylandClientInfo {
47 struct wl_display *display;
48 struct wl_registry *registry;
52 /* eom wayland output list */
53 struct wl_list eom_wl_output_list;
57 } EomWaylandClientInfo;
59 typedef struct _EomWaylandOutput {
61 struct wl_output *output;
63 /* current output data */
66 int32_t physical_width;
67 int32_t physical_height;
68 enum wl_output_subpixel subpixel;
71 enum wl_output_transform transform;
80 /* current eom data */
81 enum wl_eom_type eom_type;
82 enum wl_eom_status eom_status;
83 enum wl_eom_mode eom_mode;
84 enum wl_eom_attribute eom_attribute;
85 enum wl_eom_attribute_state eom_attribute_state;
86 enum wl_eom_error error;
89 EomWaylandClientInfo *client_info;
94 static EomWaylandClientInfo wl_client_info;
95 static int eom_wayland_init;
97 static eom_output_type_e
98 _convert_to_eom_output_type(enum wl_eom_type eom_type)
100 eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
103 case WL_EOM_TYPE_NONE:
104 output_type = EOM_OUTPUT_TYPE_UNKNOWN;
106 case WL_EOM_TYPE_VGA:
107 output_type = EOM_OUTPUT_TYPE_VGA;
109 case WL_EOM_TYPE_DVII:
110 output_type = EOM_OUTPUT_TYPE_DVII;
112 case WL_EOM_TYPE_DVID:
113 output_type = EOM_OUTPUT_TYPE_DVID;
115 case WL_EOM_TYPE_DVIA:
116 output_type = EOM_OUTPUT_TYPE_DVIA;
118 case WL_EOM_TYPE_COMPOSITE:
119 output_type = EOM_OUTPUT_TYPE_COMPOSITE;
121 case WL_EOM_TYPE_SVIDEO:
122 output_type = EOM_OUTPUT_TYPE_SVIDEO;
124 case WL_EOM_TYPE_LVDS:
125 output_type = EOM_OUTPUT_TYPE_LVDS;
127 case WL_EOM_TYPE_COMPONENT:
128 output_type = EOM_OUTPUT_TYPE_COMPONENT;
130 case WL_EOM_TYPE_9PINDIN:
131 output_type = EOM_OUTPUT_TYPE_9PINDIN;
133 case WL_EOM_TYPE_DISPLAYPORT:
134 output_type = EOM_OUTPUT_TYPE_DISPLAYPORT;
136 case WL_EOM_TYPE_HDMIA:
137 output_type = EOM_OUTPUT_TYPE_HDMIA;
139 case WL_EOM_TYPE_HDMIB:
140 output_type = EOM_OUTPUT_TYPE_HDMIB;
143 output_type = EOM_OUTPUT_TYPE_TV;
145 case WL_EOM_TYPE_EDP:
146 output_type = EOM_OUTPUT_TYPE_EDP;
148 case WL_EOM_TYPE_VIRTUAL:
149 output_type = EOM_OUTPUT_TYPE_VIRTUAL;
151 case WL_EOM_TYPE_DSI:
152 output_type = EOM_OUTPUT_TYPE_DSI;
163 static eom_output_mode_e
164 _convert_to_eom_output_mode(enum wl_eom_mode eom_mode)
166 eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
169 case WL_EOM_MODE_NONE:
170 output_mode = EOM_OUTPUT_MODE_NONE;
172 case WL_EOM_MODE_MIRROR:
173 output_mode = EOM_OUTPUT_MODE_MIRROR;
175 case WL_EOM_MODE_PRESENTATION:
176 output_mode = EOM_OUTPUT_MODE_PRESENTATION;
187 static eom_output_attribute_e
188 _convert_to_eom_output_attribute(enum wl_eom_attribute eom_attribute)
190 eom_output_attribute_e output_attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
192 switch (eom_attribute) {
193 case WL_EOM_ATTRIBUTE_NONE:
194 output_attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
196 case WL_EOM_ATTRIBUTE_NORMAL:
197 output_attribute = EOM_OUTPUT_ATTRIBUTE_NORMAL;
199 case WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARE:
200 output_attribute = EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE_SHARE;
202 case WL_EOM_ATTRIBUTE_EXCLUSIVE:
203 output_attribute = EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE;
206 ERR("no attribute.");
210 return output_attribute;
214 static eom_output_attribute_state_e
215 _convert_to_eom_output_attribute_state(
216 enum wl_eom_attribute_state eom_attribute_state)
218 eom_output_attribute_state_e output_attribute_state =
219 EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
221 switch (eom_attribute_state) {
222 case WL_EOM_ATTRIBUTE_STATE_NONE:
223 output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
225 case WL_EOM_ATTRIBUTE_STATE_ACTIVE:
226 output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE;
228 case WL_EOM_ATTRIBUTE_STATE_INACTIVE:
229 output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE;
231 case WL_EOM_ATTRIBUTE_STATE_LOST:
232 output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_LOST;
235 ERR("no attribute state.");
239 return output_attribute_state;
243 static enum wl_eom_attribute
244 _convert_to_wl_eom_attribute(eom_output_attribute_e attr)
246 enum wl_eom_attribute eom_attribute = WL_EOM_ATTRIBUTE_NONE;
249 case EOM_OUTPUT_ATTRIBUTE_NONE:
250 eom_attribute = WL_EOM_ATTRIBUTE_NONE;
252 case EOM_OUTPUT_ATTRIBUTE_NORMAL:
253 eom_attribute = WL_EOM_ATTRIBUTE_NORMAL;
255 case EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE_SHARE:
256 eom_attribute = WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARE;
258 case EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE:
259 eom_attribute = WL_EOM_ATTRIBUTE_EXCLUSIVE;
262 ERR("no wl attribute.");
266 return eom_attribute;
271 _eom_wayland_client_call_notify(EomWaylandOutput *eom_wl_output,
272 eom_output_notify_type_e type)
274 GArray *array = NULL;
275 GValue v = G_VALUE_INIT;
276 int current_pid = getpid();
278 array = g_array_new(FALSE, FALSE, sizeof(GValue));
281 g_value_init(&v, G_TYPE_INT);
282 g_value_set_int(&v, type);
283 array = g_array_append_val(array, v);
287 g_value_init(&v, G_TYPE_INT);
288 g_value_set_int(&v, eom_wl_output->id);
289 array = g_array_append_val(array, v);
293 g_value_init(&v, G_TYPE_INT);
295 _convert_to_eom_output_type(eom_wl_output->eom_type));
296 array = g_array_append_val(array, v);
300 g_value_init(&v, G_TYPE_INT);
302 _convert_to_eom_output_mode(eom_wl_output->eom_mode));
303 array = g_array_append_val(array, v);
307 g_value_init(&v, G_TYPE_INT);
308 g_value_set_int(&v, eom_wl_output->width);
309 array = g_array_append_val(array, v);
313 g_value_init(&v, G_TYPE_INT);
314 g_value_set_int(&v, eom_wl_output->height);
315 array = g_array_append_val(array, v);
319 g_value_init(&v, G_TYPE_INT);
320 g_value_set_int(&v, eom_wl_output->physical_width);
321 array = g_array_append_val(array, v);
325 g_value_init(&v, G_TYPE_INT);
326 g_value_set_int(&v, eom_wl_output->physical_height);
327 array = g_array_append_val(array, v);
331 g_value_init(&v, G_TYPE_INT);
332 g_value_set_int(&v, current_pid);
333 array = g_array_append_val(array, v);
337 g_value_init(&v, G_TYPE_INT);
339 _convert_to_eom_output_attribute(eom_wl_output->eom_attribute));
340 array = g_array_append_val(array, v);
344 g_value_init(&v, G_TYPE_INT);
346 _convert_to_eom_output_attribute_state(
347 eom_wl_output->eom_attribute_state));
348 array = g_array_append_val(array, v);
351 if (eom_wl_output->client_info && eom_wl_output->client_info->func)
352 eom_wl_output->client_info->func(NULL, array);
355 g_array_free(array, FALSE);
359 static EomWaylandOutput *
360 _eom_wayland_client_find_output_from_wl_output(
361 struct wl_list *eom_wl_output_list, int output_id)
363 EomWaylandOutput *eom_wl_output = NULL;
364 EomWaylandOutput *tmp = NULL;
365 EomWaylandOutput *ret = NULL;
367 if (!wl_list_empty(eom_wl_output_list)) {
368 wl_list_for_each_safe(eom_wl_output,
369 tmp, eom_wl_output_list, link) {
370 if (eom_wl_output->id == output_id) {
381 static EomWaylandOutput *
382 _eom_wayland_client_find_output_from_eom_output(
383 struct wl_list *eom_wl_output_list, eom_output_id id)
385 EomWaylandOutput *eom_wl_output = NULL;
386 EomWaylandOutput *tmp = NULL;
387 EomWaylandOutput *ret = NULL;
389 if (!wl_list_empty(eom_wl_output_list)) {
390 wl_list_for_each_safe(eom_wl_output,
391 tmp, eom_wl_output_list, link) {
392 if (eom_wl_output->id == id) {
404 _eom_wl_output_handle_geometry(void *data,
405 struct wl_output *wl_output,
408 int32_t physical_width,
409 int32_t physical_height,
415 EomWaylandOutput *eom_wl_output = (EomWaylandOutput *) data;
417 INFO("wl_output:%p x:%d y:%d phy(w:%d h:%d) p:%d m:%s model:%s t:%d\n",
418 wl_output, x, y, physical_width, physical_height,
419 subpixel, make, model, transform);
421 /* save vaules if it is different before */
422 if (eom_wl_output->x != x)
423 eom_wl_output->x = x;
424 if (eom_wl_output->y != y)
425 eom_wl_output->y = y;
426 if (eom_wl_output->physical_height)
427 eom_wl_output->physical_height = physical_height;
428 if (eom_wl_output->physical_width)
429 eom_wl_output->physical_width = physical_width;
430 if (eom_wl_output->subpixel)
431 eom_wl_output->subpixel = subpixel;
432 if (eom_wl_output->transform)
433 eom_wl_output->transform = transform;
438 _eom_wl_output_handle_mode(void *data,
439 struct wl_output *wl_output,
445 EomWaylandOutput *eom_wl_output = (EomWaylandOutput *) data;
447 INFO("wl_output:%p flags:%d width:%d height:%d refresh:%d\n",
448 wl_output, flags, width, height, refresh);
450 /* save vaules if it is different before */
451 if (eom_wl_output->flags != flags)
452 eom_wl_output->flags = flags;
453 if (eom_wl_output->width != width)
454 eom_wl_output->width = width;
455 if (eom_wl_output->height != height)
456 eom_wl_output->height = height;
457 if (eom_wl_output->refresh != refresh)
458 eom_wl_output->refresh = refresh;
462 _eom_wl_output_handle_done(void *data,
463 struct wl_output *wl_output)
465 INFO("wl_output:%p\n", wl_output);
469 _eom_wl_output_handle_scale(void *data,
470 struct wl_output *wl_output,
473 EomWaylandOutput *eom_wl_output = (EomWaylandOutput *) data;
475 INFO("wl_output:%p factor:%d\n", wl_output, factor);
477 /* save vaules if it is different before */
478 if (eom_wl_output->factor != factor)
479 eom_wl_output->factor = factor;
482 static const struct wl_output_listener eom_wl_output_listener = {
483 _eom_wl_output_handle_geometry,
484 _eom_wl_output_handle_mode,
485 _eom_wl_output_handle_done,
486 _eom_wl_output_handle_scale,
491 _eom_wl_eom_output_count(void *data,
492 struct wl_eom *wl_eom,
495 EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *)data;
496 /*EomWaylandOutput *eom_wl_output = NULL;*/
498 INFO("COUNT - %d", count);
501 INFO("not support external output");
505 eom_client_info->num_outputs = count;
510 _eom_wl_eom_output_info(void *data,
511 struct wl_eom *wl_eom,
522 uint32_t attribute_state,
525 EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *) data;
526 EomWaylandOutput *eom_wl_output = NULL;
528 INFO("INFO - id : %d, type : %d, mode : %d, w : %d, h : %d, w_mm : %d, h_mm : %d, conn : %d\n",
529 output_id, type, mode, w, h, w_mm, h_mm, connection);
531 eom_wl_output = _eom_wayland_client_find_output_from_wl_output(
532 &eom_client_info->eom_wl_output_list, output_id);
534 eom_wl_output->width = w;
535 eom_wl_output->height = h;
536 eom_wl_output->physical_width = w_mm;
537 eom_wl_output->physical_height = h_mm;
539 /* save the output type */
540 if (eom_wl_output->eom_type != type)
541 eom_wl_output->eom_type = type;
543 /* check the connection status and call the notify */
544 if (eom_wl_output->eom_status != connection) {
545 eom_wl_output->eom_status = connection;
547 INFO("INFO send connection: %d", connection);
549 if (connection == WL_EOM_STATUS_CONNECTION)
550 _eom_wayland_client_call_notify(eom_wl_output,
551 EOM_OUTPUT_NOTIFY_ADD);
552 else if (connection == WL_EOM_STATUS_DISCONNECTION)
553 _eom_wayland_client_call_notify(eom_wl_output,
554 EOM_OUTPUT_NOTIFY_REMOVE);
557 /* check the eom mode and call the notify */
558 if (eom_wl_output->eom_mode != mode) {
559 eom_wl_output->eom_mode = mode;
561 INFO("INFO send mode:%d", mode);
563 _eom_wayland_client_call_notify(eom_wl_output,
564 EOM_OUTPUT_NOTIFY_MODE_CHANGED);
570 /* check the eom attribute and call the notify */
571 if ((eom_wl_output->eom_attribute != attribute) ||
572 (eom_wl_output->eom_attribute_state != attribute_state)) {
573 eom_wl_output->eom_attribute = attribute;
574 eom_wl_output->eom_attribute_state = attribute_state;
576 INFO("INFO NEW send attribute:%d", attribute);
577 INFO("INFO NEW send attribute state:%d", attribute_state);
579 _eom_wayland_client_call_notify(eom_wl_output,
580 EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED);
583 eom_wl_output->error = error;
585 /* make external output info */
586 eom_wl_output = calloc(1, sizeof(EomWaylandOutput));
587 if (!eom_wl_output) {
588 ERR("Fail to allocate the eom_output.\n");
592 eom_wl_output->id = output_id;
593 eom_wl_output->eom_type = type;
594 eom_wl_output->eom_mode = mode;
595 eom_wl_output->width = w;
596 eom_wl_output->height = h;
597 eom_wl_output->physical_width = w_mm;
598 eom_wl_output->physical_height = h_mm;
599 eom_wl_output->eom_status = connection;
600 eom_wl_output->client_info = &wl_client_info;
601 eom_wl_output->error = WL_EOM_ERROR_NONE;
603 wl_list_insert(&eom_client_info->eom_wl_output_list, &eom_wl_output->link);
609 _eom_wl_eom_output_type(void *data,
610 struct wl_eom *wl_eom,
615 EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *)data;
616 EomWaylandOutput *eom_wl_output = NULL;
618 INFO("TYPE - id : %d, type : %d, status : %d\n", output_id, type, status);
620 eom_wl_output = _eom_wayland_client_find_output_from_wl_output(
621 &eom_client_info->eom_wl_output_list, output_id);
622 RET_IF_FAIL(eom_wl_output != NULL);
624 /* save the output type */
625 if (eom_wl_output->eom_type != type)
626 eom_wl_output->eom_type = type;
628 /* check the connection status and call the notify */
629 if (eom_wl_output->eom_status != status) {
630 eom_wl_output->eom_status = status;
632 if (status == WL_EOM_STATUS_CONNECTION)
633 _eom_wayland_client_call_notify(eom_wl_output,
634 EOM_OUTPUT_NOTIFY_ADD);
635 else if (status == WL_EOM_STATUS_DISCONNECTION)
636 _eom_wayland_client_call_notify(eom_wl_output,
637 EOM_OUTPUT_NOTIFY_REMOVE);
643 _eom_wl_eom_output_mode(void *data,
644 struct wl_eom *wl_eom,
648 EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *)data;
649 EomWaylandOutput *eom_wl_output = NULL;
651 INFO("MODE - id : %d, mode : %d\n", output_id, mode);
653 eom_wl_output = _eom_wayland_client_find_output_from_wl_output(
654 &eom_client_info->eom_wl_output_list, output_id);
655 RET_IF_FAIL(eom_wl_output != NULL);
657 /* check the eom mode and call the notify */
658 if (eom_wl_output->eom_mode != mode) {
659 eom_wl_output->eom_mode = mode;
661 _eom_wayland_client_call_notify(eom_wl_output,
662 EOM_OUTPUT_NOTIFY_MODE_CHANGED);
668 _eom_wl_eom_output_attribute(void *data,
669 struct wl_eom *wl_eom,
672 uint32_t attribute_state,
675 EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *)data;
676 EomWaylandOutput *eom_wl_output = NULL;
678 INFO("ATTRIBUTE - id : %d, attribute : %d, state : %d\n", output_id, attribute, attribute_state);
680 eom_wl_output = _eom_wayland_client_find_output_from_wl_output(
681 &eom_client_info->eom_wl_output_list, output_id);
682 RET_IF_FAIL(eom_wl_output != NULL);
684 /* check the eom attribute and call the notify */
685 if ((eom_wl_output->eom_attribute != attribute) ||
686 (eom_wl_output->eom_attribute_state != attribute_state)) {
687 eom_wl_output->eom_attribute = attribute;
688 eom_wl_output->eom_attribute_state = attribute_state;
690 _eom_wayland_client_call_notify(eom_wl_output,
691 EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED);
694 eom_wl_output->error = error;
698 _eom_wl_eom_output_set_window(void *data,
699 struct wl_eom *wl_eom,
703 EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *)data;
704 EomWaylandOutput *eom_wl_output = NULL;
706 INFO("SET_WINODW - id : %d, error : %d\n", output_id, error);
708 eom_wl_output = _eom_wayland_client_find_output_from_wl_output(
709 &eom_client_info->eom_wl_output_list, output_id);
710 RET_IF_FAIL(eom_wl_output != NULL);
712 eom_wl_output->error = error;
716 static const struct wl_eom_listener eom_wl_eom_listener = {
717 _eom_wl_eom_output_count,
718 _eom_wl_eom_output_info,
719 _eom_wl_eom_output_type,
720 _eom_wl_eom_output_mode,
721 _eom_wl_eom_output_attribute,
722 _eom_wl_eom_output_set_window,
727 _eom_wl_registry_handle_global(void *data, struct wl_registry *registry,
728 uint32_t name, const char *interface, uint32_t version)
730 EomWaylandClientInfo *ci = (EomWaylandClientInfo *)data;
731 /*EomWaylandOutput *eom_wl_output = NULL;*/
732 struct wl_output *output = NULL;
733 struct wl_eom *eom = NULL;
735 if (strcmp(interface, "wl_output") == 0) {
736 output = wl_registry_bind(registry, name,
737 &wl_output_interface, 1);
739 ERR("Error. fail to bind %s.\n", interface);/*LCOV_EXCL_LINE*/
741 INFO("bind %s.\n", interface);
743 /* create the eom_wl_output */
744 eom_wl_output = calloc(1, sizeof(EomWaylandOutput));
745 if (!eom_wl_output) {
746 ERR("Fail to allocate the eom_output.\n");
750 eom_wl_output->id = ci->num_outputs;
751 eom_wl_output->output = output;
752 wl_list_insert(&ci->eom_wl_output_list,
753 &eom_wl_output->link);
756 wl_output_add_listener(eom_wl_output->output,
757 &eom_wl_output_listener, eom_wl_output);
760 } else if (strcmp(interface, "wl_eom") == 0) {
761 eom = wl_registry_bind(registry, name, &wl_eom_interface, 1);
763 ERR("Error. fail to bind %s.\n", interface);/*LCOV_EXCL_LINE*/
765 INFO("bind %s.\n", interface);/*LCOV_EXCL_LINE*/
770 wl_eom_add_listener(ci->eom, &eom_wl_eom_listener, ci);
773 INFO("Not bind %s.\n", interface);
777 _eom_wl_registry_handle_global_remove(void *data,
778 struct wl_registry *registry, uint32_t name)
783 static const struct wl_registry_listener eom_registry_listener = {
784 _eom_wl_registry_handle_global,
785 _eom_wl_registry_handle_global_remove
789 _eom_wayland_client_initialize()
791 int ecore_count = -1;
793 ecore_count = ecore_wl_init(NULL);
794 RETV_IF_FAIL(ecore_count > 0, false);
796 wl_list_init(&wl_client_info.eom_wl_output_list);
798 wl_client_info.display = ecore_wl_display_get();
799 GOTO_IF_FAIL(wl_client_info.display != NULL, fail);
801 /* get the registry */
802 wl_client_info.registry =
803 wl_display_get_registry(wl_client_info.display);
804 GOTO_IF_FAIL(wl_client_info.registry != NULL, fail);
806 /* get the global objects */
807 wl_registry_add_listener(wl_client_info.registry,
808 &eom_registry_listener, &wl_client_info);
809 wl_display_dispatch(wl_client_info.display);
810 wl_display_roundtrip(wl_client_info.display);
812 /* remove type none eom_wl_outputs */
813 if (!wl_list_empty(&wl_client_info.eom_wl_output_list)) {
814 EomWaylandOutput *eom_wl_output = NULL;
815 EomWaylandOutput *tmp = NULL;
817 wl_list_for_each_safe(eom_wl_output, tmp,
818 &wl_client_info.eom_wl_output_list, link) {
819 if (eom_wl_output->eom_type == WL_EOM_TYPE_NONE) {
820 WARN("[EOM_CLIENT] eom_type is NONE. remove output:%d\n",
822 wl_output_destroy(eom_wl_output->output);
823 wl_list_remove(&eom_wl_output->link);
825 eom_wl_output = NULL;
830 if (wl_client_info.num_outputs == 0)
831 WARN("[EOM_CLIENT] not support external output at this device.\n");
834 if (wl_list_empty(&wl_client_info.eom_wl_output_list))
835 WARN("[EOM_CLIENT] no wl output at this device.\n");
837 INFO("[EOM_CLIENT] wayland client init.");
842 if (wl_client_info.registry) {
843 wl_registry_destroy(wl_client_info.registry);
844 wl_client_info.registry = NULL;
853 _eom_wayland_client_deinitialize()
855 EomWaylandOutput *eom_wl_output = NULL;
856 EomWaylandOutput *tmp = NULL;
858 /* remove all eom_wl_outputs */
859 if (!wl_list_empty(&wl_client_info.eom_wl_output_list)) {
860 wl_list_for_each_safe(eom_wl_output, tmp,
861 &wl_client_info.eom_wl_output_list, link) {
862 if (eom_wl_output->output)
863 wl_output_destroy(eom_wl_output->output);
865 eom_wl_output = NULL;
869 if (wl_client_info.registry) {
870 wl_registry_destroy(wl_client_info.registry);
871 wl_client_info.registry = NULL;
875 INFO("[EOM_CLIENT] wayland client deinit.");
879 eom_wayland_client_init(notify_func func)
883 if (eom_wayland_init)
886 ret = _eom_wayland_client_initialize();
887 GOTO_IF_FAIL(ret != false, fail);
889 wl_client_info.func = func;
891 eom_wayland_init = 1;
899 eom_wayland_client_deinit(GList *cb_info_list)
901 if (!eom_wayland_init)
904 _eom_wayland_client_deinitialize();
906 eom_wayland_init = 0;
908 memset(&wl_client_info, 0x0, sizeof(EomWaylandClientInfo));
912 eom_wayland_client_get_output_ids(void)
914 GArray *array = NULL;
915 GValue v = G_VALUE_INIT;
916 EomWaylandOutput *eom_wl_output = NULL;
917 EomWaylandOutput *tmp = NULL;
919 if (wl_list_empty(&wl_client_info.eom_wl_output_list)) {
920 ERR("error. no outputs.\n");
924 array = g_array_new(FALSE, FALSE, sizeof(GValue));
926 wl_list_for_each_safe(eom_wl_output, tmp,
927 &wl_client_info.eom_wl_output_list, link) {
930 g_value_init(&v, G_TYPE_INT);
931 g_value_set_int(&v, eom_wl_output->id);
932 array = g_array_append_val(array, v);
937 /* returned array will be freed by caller */
943 eom_wayland_client_get_output_info(eom_output_id output_id)
945 GArray *array = NULL;
946 GValue v = G_VALUE_INIT;
947 EomWaylandOutput *eom_wl_output = NULL;
949 eom_wl_output = _eom_wayland_client_find_output_from_eom_output(
950 &wl_client_info.eom_wl_output_list, output_id);
951 RETV_IF_FAIL(eom_wl_output != NULL, NULL);
953 array = g_array_new(FALSE, FALSE, sizeof(GValue));
956 g_value_init(&v, G_TYPE_INT);
957 g_value_set_int(&v, eom_wl_output->id);
958 array = g_array_append_val(array, v);
962 g_value_init(&v, G_TYPE_INT);
963 g_value_set_int(&v, eom_wl_output->eom_type);
964 array = g_array_append_val(array, v);
968 g_value_init(&v, G_TYPE_INT);
969 g_value_set_int(&v, eom_wl_output->eom_mode);
970 array = g_array_append_val(array, v);
974 g_value_init(&v, G_TYPE_INT);
975 g_value_set_int(&v, eom_wl_output->width);
976 array = g_array_append_val(array, v);
980 g_value_init(&v, G_TYPE_INT);
981 g_value_set_int(&v, eom_wl_output->height);
982 array = g_array_append_val(array, v);
986 g_value_init(&v, G_TYPE_INT);
987 g_value_set_int(&v, eom_wl_output->physical_width);
988 array = g_array_append_val(array, v);
992 g_value_init(&v, G_TYPE_INT);
993 g_value_set_int(&v, eom_wl_output->physical_height);
994 array = g_array_append_val(array, v);
998 g_value_init(&v, G_TYPE_INT);
999 g_value_set_int(&v, eom_wl_output->eom_attribute);
1000 array = g_array_append_val(array, v);
1003 /* returned array will be freed by caller */
1009 eom_wayland_client_set_attribute(eom_output_id output_id,
1010 eom_output_attribute_e attr)
1012 GArray *array = NULL;
1013 GValue v = G_VALUE_INIT;
1014 EomWaylandOutput *eom_wl_output = NULL;
1017 eom_wl_output = _eom_wayland_client_find_output_from_eom_output(
1018 &wl_client_info.eom_wl_output_list, output_id);
1019 GOTO_IF_FAIL(eom_wl_output != NULL, fail);
1021 wl_eom_set_attribute(wl_client_info.eom, eom_wl_output->id,
1022 _convert_to_wl_eom_attribute(attr));
1025 * wait for the result of set_attribute.
1026 * this should be the blocking call.
1028 wl_display_dispatch(wl_client_info.display);
1029 wl_display_roundtrip(wl_client_info.display);
1031 if (eom_wl_output->error == WL_EOM_ERROR_NONE)
1034 array = g_array_new(FALSE, FALSE, sizeof(GValue));
1035 g_value_init(&v, G_TYPE_INT);
1036 g_value_set_int(&v, ret);
1037 array = g_array_append_val(array, v);
1040 /* returned array will be freed by caller */
1049 eom_wayland_client_set_window(eom_output_id output_id, Evas_Object *win)
1051 GArray *array = NULL;
1052 GValue v = G_VALUE_INIT;
1053 Ecore_Wl_Window *e_wl_win = NULL;
1054 EomWaylandOutput *eom_wl_output = NULL;
1055 struct wl_shell_surface *shell_surface = NULL;
1056 struct xdg_surface *xdg_shell_surface = NULL;
1059 evas_object_show(win);
1061 e_wl_win = elm_win_wl_window_get(win);
1062 GOTO_IF_FAIL(e_wl_win != NULL, fail);
1064 eom_wl_output = _eom_wayland_client_find_output_from_eom_output(
1065 &wl_client_info.eom_wl_output_list, output_id);
1066 GOTO_IF_FAIL(eom_wl_output != NULL, fail);
1069 elm_win_aux_hint_add(win, "wm.policy.win.user.geometry", "1");
1072 /* set full screen at output */
1073 xdg_shell_surface = ecore_wl_window_xdg_surface_get(e_wl_win);
1074 if (xdg_shell_surface) {
1075 wl_eom_set_xdg_window(wl_client_info.eom, output_id, xdg_shell_surface);
1077 shell_surface = ecore_wl_window_shell_surface_get(e_wl_win);
1078 if (shell_surface) {
1079 wl_eom_set_shell_window(wl_client_info.eom, output_id, shell_surface);
1081 ERR("no wl surface.\n");
1087 * wait for the result of set_window.
1088 * this should be the blocking call.
1090 wl_display_dispatch(wl_client_info.display);
1091 wl_display_roundtrip(wl_client_info.display);
1093 if (eom_wl_output->error == WL_EOM_ERROR_NONE)
1096 array = g_array_new(FALSE, FALSE, sizeof(GValue));
1097 g_value_init(&v, G_TYPE_INT);
1098 g_value_set_int(&v, ret);
1099 array = g_array_append_val(array, v);
1102 /* returned array will be freed by caller */