diff options
author | Mike Blumenkrantz <zmike@osg.samsung.com> | 2017-08-04 16:17:53 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@osg.samsung.com> | 2017-08-04 16:15:43 -0400 |
commit | 9a189d29d0ebae79e645101b1fb0fbe5611e5a09 (patch) | |
tree | 830425b058b5f534c4ad4c1541eb5d76b98b1375 /src/lib/efl_wl/efl_wl.c | |
parent | a454c91dbe82d1acd0aa7a05aca16551ffa335d5 (diff) |
wayland: add efl-hints protocol for setting aspect on surfaces
@feature
Diffstat (limited to 'src/lib/efl_wl/efl_wl.c')
-rw-r--r-- | src/lib/efl_wl/efl_wl.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/lib/efl_wl/efl_wl.c b/src/lib/efl_wl/efl_wl.c index 03e1128836..2a78282372 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 | ||
147 | typedef struct Comp_Data_Device_Source Comp_Data_Device_Source; | 149 | typedef struct Comp_Data_Device_Source Comp_Data_Device_Source; |
@@ -1166,6 +1168,18 @@ shell_surface_activate_recurse(Comp_Surface *cs) | |||
1166 | } | 1168 | } |
1167 | 1169 | ||
1168 | static void | 1170 | static void |
1171 | shell_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 | |||
1182 | static void | ||
1169 | shell_surface_send_configure(Comp_Surface *cs) | 1183 | shell_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 | ||
4897 | static void | 4912 | static void |
4913 | hints_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 | |||
4921 | static const struct efl_hints_interface hints_interface = | ||
4922 | { | ||
4923 | hints_set_aspect, | ||
4924 | }; | ||
4925 | |||
4926 | static void | ||
4927 | efl_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 | |||
4938 | static void | ||
4898 | comp_smart_add(Evas_Object *obj) | 4939 | comp_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 | |||
5363 | void | ||
5364 | efl_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 | } | ||