summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-08-04 16:17:53 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-08-04 16:15:43 -0400
commit9a189d29d0ebae79e645101b1fb0fbe5611e5a09 (patch)
tree830425b058b5f534c4ad4c1541eb5d76b98b1375
parenta454c91dbe82d1acd0aa7a05aca16551ffa335d5 (diff)
wayland: add efl-hints protocol for setting aspect on surfaces
@feature
-rw-r--r--src/Makefile_Ecore_Wl2.am8
-rw-r--r--src/Makefile_Wayland_Protocols.am1
-rw-r--r--src/Makefile_efl_wl.am4
-rw-r--r--src/lib/ecore_wl2/Ecore_Wl2.h7
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_display.c12
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_private.h8
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_window.c21
-rw-r--r--src/lib/efl_wl/Efl_Wl.h8
-rw-r--r--src/lib/efl_wl/efl_wl.c56
-rw-r--r--src/wayland_protocol/efl-hints.xml19
10 files changed, 141 insertions, 3 deletions
diff --git a/src/Makefile_Ecore_Wl2.am b/src/Makefile_Ecore_Wl2.am
index 7f3eb2f..0047c36 100644
--- a/src/Makefile_Ecore_Wl2.am
+++ b/src/Makefile_Ecore_Wl2.am
@@ -33,7 +33,9 @@ lib/ecore_wl2/linux-dmabuf-unstable-v1-client-protocol.h \
33lib/ecore_wl2/xdg-shell-unstable-v6-client-protocol.h \ 33lib/ecore_wl2/xdg-shell-unstable-v6-client-protocol.h \
34lib/ecore_wl2/xdg-shell-unstable-v6-protocol.c \ 34lib/ecore_wl2/xdg-shell-unstable-v6-protocol.c \
35lib/ecore_wl2/text-input-unstable-v1-client-protocol.h \ 35lib/ecore_wl2/text-input-unstable-v1-client-protocol.h \
36lib/ecore_wl2/text-input-unstable-v1-protocol.c 36lib/ecore_wl2/text-input-unstable-v1-protocol.c \
37lib/ecore_wl2/efl-hints-client-protocol.h \
38lib/ecore_wl2/efl-hints-protocol.c
37 39
38lib_ecore_wl2_libecore_wl2_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_WL2_CFLAGS@ 40lib_ecore_wl2_libecore_wl2_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_WL2_CFLAGS@
39lib_ecore_wl2_libecore_wl2_la_LIBADD = @ECORE_WL2_LIBS@ 41lib_ecore_wl2_libecore_wl2_la_LIBADD = @ECORE_WL2_LIBS@
@@ -56,6 +58,8 @@ lib/ecore_wl2/efl-aux-hints-client-protocol.h \
56 lib/ecore_wl2/session-recovery-protocol.c \ 58 lib/ecore_wl2/session-recovery-protocol.c \
57 lib/ecore_wl2/session-recovery-client-protocol.h \ 59 lib/ecore_wl2/session-recovery-client-protocol.h \
58 lib/ecore_wl2/text-input-unstable-v1-client-protocol.h \ 60 lib/ecore_wl2/text-input-unstable-v1-client-protocol.h \
59 lib/ecore_wl2/text-input-unstable-v1-protocol.c 61 lib/ecore_wl2/text-input-unstable-v1-protocol.c \
62lib/ecore_wl2/efl-hints-client-protocol.h \
63lib/ecore_wl2/efl-hints-protocol.c
60 64
61endif 65endif
diff --git a/src/Makefile_Wayland_Protocols.am b/src/Makefile_Wayland_Protocols.am
index b96cce9..1bbfe20 100644
--- a/src/Makefile_Wayland_Protocols.am
+++ b/src/Makefile_Wayland_Protocols.am
@@ -1,5 +1,6 @@
1EXTRA_DIST2 += \ 1EXTRA_DIST2 += \
2wayland_protocol/efl-aux-hints.xml \ 2wayland_protocol/efl-aux-hints.xml \
3wayland_protocol/efl-hints.xml \
3wayland_protocol/session-recovery.xml \ 4wayland_protocol/session-recovery.xml \
4wayland_protocol/teamwork.xml \ 5wayland_protocol/teamwork.xml \
5wayland_protocol/www.xml 6wayland_protocol/www.xml
diff --git a/src/Makefile_efl_wl.am b/src/Makefile_efl_wl.am
index aae58ff..ac3c00d 100644
--- a/src/Makefile_efl_wl.am
+++ b/src/Makefile_efl_wl.am
@@ -15,7 +15,9 @@ nodist_lib_efl_wl_libefl_wl_la_SOURCES = \
15lib/efl_wl/linux-dmabuf-unstable-v1-protocol.c \ 15lib/efl_wl/linux-dmabuf-unstable-v1-protocol.c \
16lib/efl_wl/linux-dmabuf-unstable-v1-server-protocol.h \ 16lib/efl_wl/linux-dmabuf-unstable-v1-server-protocol.h \
17lib/efl_wl/xdg-shell-unstable-v6-protocol.c \ 17lib/efl_wl/xdg-shell-unstable-v6-protocol.c \
18lib/efl_wl/xdg-shell-unstable-v6-server-protocol.h 18lib/efl_wl/xdg-shell-unstable-v6-server-protocol.h \
19lib/efl_wl/efl-hints-protocol.c \
20lib/efl_wl/efl-hints-server-protocol.h
19 21
20lib_efl_wl_libefl_wl_la_CPPFLAGS = -I$(top_builddir)/lib/efl @EFL_WL_CFLAGS@ 22lib_efl_wl_libefl_wl_la_CPPFLAGS = -I$(top_builddir)/lib/efl @EFL_WL_CFLAGS@
21lib_efl_wl_libefl_wl_la_LIBADD = @EFL_WL_LIBS@ 23lib_efl_wl_libefl_wl_la_LIBADD = @EFL_WL_LIBS@
diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index 81084e1..eab1bfe 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -737,6 +737,13 @@ EAPI struct wl_surface *ecore_wl2_window_surface_get(Ecore_Wl2_Window *window);
737EAPI int ecore_wl2_window_surface_id_get(Ecore_Wl2_Window *window); 737EAPI int ecore_wl2_window_surface_id_get(Ecore_Wl2_Window *window);
738 738
739/** 739/**
740 * @see evas_object_size_hint_aspect_set
741 * @ingroup Ecore_Wl2_Window_Group
742 * @since 1.21
743 */
744EAPI void ecore_wl2_window_aspect_set(Ecore_Wl2_Window *window, int w, int h, unsigned int aspect);
745
746/**
740 * Show a given Ecore_Wl2_Window 747 * Show a given Ecore_Wl2_Window
741 * 748 *
742 * @param window The Ecore_Wl2_Window to show 749 * @param window The Ecore_Wl2_Window to show
diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c
index 48c62e5..63c79f9 100644
--- a/src/lib/ecore_wl2/ecore_wl2_display.c
+++ b/src/lib/ecore_wl2/ecore_wl2_display.c
@@ -5,6 +5,7 @@
5#include "ecore_wl2_private.h" 5#include "ecore_wl2_private.h"
6 6
7#include "linux-dmabuf-unstable-v1-client-protocol.h" 7#include "linux-dmabuf-unstable-v1-client-protocol.h"
8#include "efl-hints-client-protocol.h"
8 9
9static Eina_Hash *_server_displays = NULL; 10static Eina_Hash *_server_displays = NULL;
10static Eina_Hash *_client_displays = NULL; 11static Eina_Hash *_client_displays = NULL;
@@ -336,6 +337,16 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
336 _ecore_wl2_output_add(ewd, id); 337 _ecore_wl2_output_add(ewd, id);
337 else if (!strcmp(interface, "wl_seat")) 338 else if (!strcmp(interface, "wl_seat"))
338 _ecore_wl2_input_add(ewd, id, version); 339 _ecore_wl2_input_add(ewd, id, version);
340 else if (!strcmp(interface, "efl_hints"))
341 {
342 Ecore_Wl2_Window *window;
343
344 ewd->wl.efl_hints = wl_registry_bind(registry, id, &efl_hints_interface, 1);
345 EINA_INLIST_FOREACH(ewd->windows, window)
346 if (window->zxdg_toplevel && window->aspect.set)
347 efl_hints_set_aspect(window->display->wl.efl_hints, window->zxdg_toplevel,
348 window->aspect.w, window->aspect.h, window->aspect.aspect);
349 }
339 350
340event: 351event:
341 /* allocate space for event structure */ 352 /* allocate space for event structure */
@@ -437,6 +448,7 @@ _ecore_wl2_display_globals_cleanup(Ecore_Wl2_Display *ewd)
437 if (ewd->wl.subcompositor) wl_subcompositor_destroy(ewd->wl.subcompositor); 448 if (ewd->wl.subcompositor) wl_subcompositor_destroy(ewd->wl.subcompositor);
438 if (ewd->wl.dmabuf) zwp_linux_dmabuf_v1_destroy(ewd->wl.dmabuf); 449 if (ewd->wl.dmabuf) zwp_linux_dmabuf_v1_destroy(ewd->wl.dmabuf);
439 if (ewd->wl.efl_aux_hints) efl_aux_hints_destroy(ewd->wl.efl_aux_hints); 450 if (ewd->wl.efl_aux_hints) efl_aux_hints_destroy(ewd->wl.efl_aux_hints);
451 if (ewd->wl.efl_hints) efl_hints_destroy(ewd->wl.efl_hints);
440 452
441 if (ewd->wl.registry) wl_registry_destroy(ewd->wl.registry); 453 if (ewd->wl.registry) wl_registry_destroy(ewd->wl.registry);
442} 454}
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h
index 3569db9..e857bbd 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -96,6 +96,7 @@ struct _Ecore_Wl2_Display
96 struct zwp_e_session_recovery *session_recovery; 96 struct zwp_e_session_recovery *session_recovery;
97 struct efl_aux_hints *efl_aux_hints; 97 struct efl_aux_hints *efl_aux_hints;
98 struct zwp_teamwork *teamwork; 98 struct zwp_teamwork *teamwork;
99 struct efl_hints *efl_hints;
99 int compositor_version; 100 int compositor_version;
100 } wl; 101 } wl;
101 102
@@ -180,6 +181,13 @@ struct _Ecore_Wl2_Window
180 181
181 Ecore_Wl2_Window_Type type; 182 Ecore_Wl2_Window_Type type;
182 183
184 struct
185 {
186 int w, h;
187 unsigned int aspect;
188 Eina_Bool set : 1;
189 } aspect;
190
183 Eina_Inlist *subsurfs; 191 Eina_Inlist *subsurfs;
184 Eina_List *supported_aux_hints; 192 Eina_List *supported_aux_hints;
185 193
diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c
index 78f6129..bb5196f 100644
--- a/src/lib/ecore_wl2/ecore_wl2_window.c
+++ b/src/lib/ecore_wl2/ecore_wl2_window.c
@@ -3,6 +3,7 @@
3#endif 3#endif
4 4
5#include "ecore_wl2_private.h" 5#include "ecore_wl2_private.h"
6#include "efl-hints-client-protocol.h"
6 7
7void 8void
8_ecore_wl2_window_semi_free(Ecore_Wl2_Window *window) 9_ecore_wl2_window_semi_free(Ecore_Wl2_Window *window)
@@ -472,6 +473,9 @@ _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window)
472 473
473 if (window->fullscreen) 474 if (window->fullscreen)
474 zxdg_toplevel_v6_set_fullscreen(window->zxdg_toplevel, NULL); 475 zxdg_toplevel_v6_set_fullscreen(window->zxdg_toplevel, NULL);
476 if (window->aspect.set && window->display->wl.efl_hints)
477 efl_hints_set_aspect(window->display->wl.efl_hints, window->zxdg_toplevel,
478 window->aspect.w, window->aspect.h, window->aspect.aspect);
475 479
476 wl_surface_commit(window->surface); 480 wl_surface_commit(window->surface);
477 } 481 }
@@ -1535,3 +1539,20 @@ ecore_wl2_window_floating_mode_get(Ecore_Wl2_Window *window)
1535 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE); 1539 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE);
1536 return window->floating; 1540 return window->floating;
1537} 1541}
1542
1543EAPI void
1544ecore_wl2_window_aspect_set(Ecore_Wl2_Window *window, int w, int h, unsigned int aspect)
1545{
1546 EINA_SAFETY_ON_NULL_RETURN(window);
1547 EINA_SAFETY_ON_TRUE_RETURN(w < 1);
1548 EINA_SAFETY_ON_TRUE_RETURN(h < 1);
1549 if ((window->aspect.aspect == aspect) &&
1550 (window->aspect.w == w) &&
1551 (window->aspect.h == h)) return;
1552 window->aspect.w = w;
1553 window->aspect.h = h;
1554 window->aspect.aspect = aspect;
1555 window->aspect.set = 1;
1556 if (window->display->wl.efl_hints && window->zxdg_toplevel)
1557 efl_hints_set_aspect(window->display->wl.efl_hints, window->zxdg_toplevel, w, h, aspect);
1558}
diff --git a/src/lib/efl_wl/Efl_Wl.h b/src/lib/efl_wl/Efl_Wl.h
index 2de79e2..51bcc43 100644
--- a/src/lib/efl_wl/Efl_Wl.h
+++ b/src/lib/efl_wl/Efl_Wl.h
@@ -106,6 +106,14 @@ EAPI void efl_wl_rotate(Evas_Object *obj, Efl_Wl_Rotation rot, Eina_Bool rtl);
106 * @param scale The scale factor to set 106 * @param scale The scale factor to set
107 */ 107 */
108EAPI void efl_wl_scale_set(Evas_Object *obj, double scale); 108EAPI void efl_wl_scale_set(Evas_Object *obj, double scale);
109
110/**
111 * Transfer aspect hints from top-most surface onto the efl_wl object
112 *
113 * @param obj The compositor widget
114 * @param set Whether to enable aspect setting
115 */
116EAPI void efl_wl_aspect_set(Evas_Object *obj, Eina_Bool set);
109#endif 117#endif
110 118
111#endif 119#endif
diff --git a/src/lib/efl_wl/efl_wl.c b/src/lib/efl_wl/efl_wl.c
index 03e1128..2a78282 100644
--- a/src/lib/efl_wl/efl_wl.c
+++ b/src/lib/efl_wl/efl_wl.c
@@ -16,6 +16,7 @@
16 16
17#include <wayland-server.h> 17#include <wayland-server.h>
18#include "xdg-shell-unstable-v6-server-protocol.h" 18#include "xdg-shell-unstable-v6-server-protocol.h"
19#include "efl-hints-server-protocol.h"
19#include "dmabuf.h" 20#include "dmabuf.h"
20 21
21#include "Ecore_Evas.h" 22#include "Ecore_Evas.h"
@@ -142,6 +143,7 @@ typedef struct Comp
142 Eina_Bool data_device_proxy : 1; 143 Eina_Bool data_device_proxy : 1;
143 Eina_Bool x11_selection : 1; 144 Eina_Bool x11_selection : 1;
144 Eina_Bool rtl : 1; 145 Eina_Bool rtl : 1;
146 Eina_Bool aspect : 1;
145} Comp; 147} Comp;
146 148
147typedef struct Comp_Data_Device_Source Comp_Data_Device_Source; 149typedef struct Comp_Data_Device_Source Comp_Data_Device_Source;
@@ -1166,6 +1168,18 @@ shell_surface_activate_recurse(Comp_Surface *cs)
1166} 1168}
1167 1169
1168static void 1170static void
1171shell_surface_aspect_update(Comp_Surface *cs)
1172{
1173 Evas_Aspect_Control aspect;
1174 int w, h;
1175
1176 if (!cs) return;
1177 if (!cs->c->aspect) return;
1178 evas_object_size_hint_aspect_get(cs->obj, &aspect, &w, &h);
1179 evas_object_size_hint_aspect_set(cs->c->obj, aspect, w, h);
1180}
1181
1182static void
1169shell_surface_send_configure(Comp_Surface *cs) 1183shell_surface_send_configure(Comp_Surface *cs)
1170{ 1184{
1171 uint32_t serial, *s; 1185 uint32_t serial, *s;
@@ -1210,6 +1224,7 @@ shell_surface_send_configure(Comp_Surface *cs)
1210 EINA_INLIST_FOREACH(cs->children, ccs) 1224 EINA_INLIST_FOREACH(cs->children, ccs)
1211 if (ccs->shell.surface && ccs->role && ccs->shell.popup) 1225 if (ccs->shell.surface && ccs->role && ccs->shell.popup)
1212 ccs->shell.activated = cs->shell.activated; 1226 ccs->shell.activated = cs->shell.activated;
1227 shell_surface_aspect_update(cs);
1213 } 1228 }
1214 else 1229 else
1215 shell_surface_deactivate_recurse(cs); 1230 shell_surface_deactivate_recurse(cs);
@@ -4895,6 +4910,32 @@ EFL_CALLBACKS_ARRAY_DEFINE(comp_device_cbs,
4895 { EFL_CANVAS_EVENT_DEVICE_REMOVED, comp_device_del }); 4910 { EFL_CANVAS_EVENT_DEVICE_REMOVED, comp_device_del });
4896 4911
4897static void 4912static void
4913hints_set_aspect(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface, uint32_t width, uint32_t height, uint32_t aspect)
4914{
4915 Comp_Surface *cs = wl_resource_get_user_data(surface);
4916 evas_object_size_hint_aspect_set(cs->obj, aspect, width, height);
4917 if (cs == cs->c->active_surface)
4918 shell_surface_aspect_update(cs);
4919}
4920
4921static const struct efl_hints_interface hints_interface =
4922{
4923 hints_set_aspect,
4924};
4925
4926static void
4927efl_hints_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
4928{
4929 struct wl_resource *res;
4930
4931 if (!client_allowed_check(data, client)) return;
4932 res = wl_resource_create(client, &efl_hints_interface, version, id);
4933 wl_resource_set_implementation(res, &hints_interface, data, NULL);
4934}
4935
4936
4937
4938static void
4898comp_smart_add(Evas_Object *obj) 4939comp_smart_add(Evas_Object *obj)
4899{ 4940{
4900 Comp *c; 4941 Comp *c;
@@ -4930,6 +4971,7 @@ comp_smart_add(Evas_Object *obj)
4930 wl_global_create(c->display, &wl_output_interface, 2, c, output_bind); 4971 wl_global_create(c->display, &wl_output_interface, 2, c, output_bind);
4931 wl_global_create(c->display, &zxdg_shell_v6_interface, 1, c, shell_bind); 4972 wl_global_create(c->display, &zxdg_shell_v6_interface, 1, c, shell_bind);
4932 wl_global_create(c->display, &wl_data_device_manager_interface, 3, c, data_device_manager_bind); 4973 wl_global_create(c->display, &wl_data_device_manager_interface, 3, c, data_device_manager_bind);
4974 wl_global_create(c->display, &efl_hints_interface, 1, c, efl_hints_bind);
4933 wl_display_init_shm(c->display); 4975 wl_display_init_shm(c->display);
4934 4976
4935 if (env) 4977 if (env)
@@ -5317,3 +5359,17 @@ efl_wl_scale_set(Evas_Object *obj, double scale)
5317 if (wl_resource_get_version(res) >= WL_OUTPUT_SCALE_SINCE_VERSION) 5359 if (wl_resource_get_version(res) >= WL_OUTPUT_SCALE_SINCE_VERSION)
5318 wl_output_send_scale(res, lround(c->scale)); 5360 wl_output_send_scale(res, lround(c->scale));
5319} 5361}
5362
5363void
5364efl_wl_aspect_set(Evas_Object *obj, Eina_Bool set)
5365{
5366 Comp *c;
5367
5368 if (!eina_streq(evas_object_type_get(obj), "comp")) abort();
5369 c = evas_object_smart_data_get(obj);
5370 c->aspect = !!set;
5371 if (c->aspect)
5372 shell_surface_aspect_update(c->active_surface);
5373 else
5374 evas_object_size_hint_aspect_set(obj, EVAS_ASPECT_CONTROL_NONE, 0, 0);
5375}
diff --git a/src/wayland_protocol/efl-hints.xml b/src/wayland_protocol/efl-hints.xml
new file mode 100644
index 0000000..51689d7
--- /dev/null
+++ b/src/wayland_protocol/efl-hints.xml
@@ -0,0 +1,19 @@
1<protocol name="efl_hints">
2
3 <interface name="efl_hints" version="1">
4 <enum name="aspect">
5 <entry name="none" value="0"/>
6 <entry name="neither" value="1"/>
7 <entry name="horizontal" value="2"/>
8 <entry name="vertical" value="3"/>
9 <entry name="both" value="4"/>
10 </enum>
11 <request name="set_aspect">
12 <arg name="surface" type="object" interface="zxdg_toplevel_v6"/>
13 <arg name="width" type="uint"/>
14 <arg name="height" type="uint"/>
15 <arg name="aspect" type="uint" enum="aspect"/>
16 </request>
17 </interface>
18
19</protocol>