From be20f7d96c4bc2d4c9a9f5dc6dbc754d0aafa881 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 4 Aug 2017 16:17:53 -0400 Subject: [PATCH] efl-wl: support min/max hinting @feature --- src/lib/efl_wl/Efl_Wl.h | 8 ++++++++ src/lib/efl_wl/efl_wl.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/lib/efl_wl/Efl_Wl.h b/src/lib/efl_wl/Efl_Wl.h index 51bcc43..8b28309 100644 --- a/src/lib/efl_wl/Efl_Wl.h +++ b/src/lib/efl_wl/Efl_Wl.h @@ -114,6 +114,14 @@ EAPI void efl_wl_scale_set(Evas_Object *obj, double scale); * @param set Whether to enable aspect setting */ EAPI void efl_wl_aspect_set(Evas_Object *obj, Eina_Bool set); + +/** + * Transfer min/max hints from top-most surface onto the efl_wl object + * + * @param obj The compositor widget + * @param set Whether to enable min/max setting + */ +EAPI void efl_wl_minmax_set(Evas_Object *obj, Eina_Bool set); #endif #endif diff --git a/src/lib/efl_wl/efl_wl.c b/src/lib/efl_wl/efl_wl.c index 2a78282..575012e 100644 --- a/src/lib/efl_wl/efl_wl.c +++ b/src/lib/efl_wl/efl_wl.c @@ -144,6 +144,7 @@ typedef struct Comp Eina_Bool x11_selection : 1; Eina_Bool rtl : 1; Eina_Bool aspect : 1; + Eina_Bool minmax : 1; } Comp; typedef struct Comp_Data_Device_Source Comp_Data_Device_Source; @@ -1168,6 +1169,19 @@ shell_surface_activate_recurse(Comp_Surface *cs) } static void +shell_surface_minmax_update(Comp_Surface *cs) +{ + int w, h; + + if (!cs) return; + if (!cs->c->minmax) return; + evas_object_size_hint_min_get(cs->obj, &w, &h); + evas_object_size_hint_min_set(cs->c->obj, w, h); + evas_object_size_hint_max_get(cs->obj, &w, &h); + evas_object_size_hint_max_set(cs->c->obj, w, h); +} + +static void shell_surface_aspect_update(Comp_Surface *cs) { Evas_Aspect_Control aspect; @@ -1225,6 +1239,7 @@ shell_surface_send_configure(Comp_Surface *cs) if (ccs->shell.surface && ccs->role && ccs->shell.popup) ccs->shell.activated = cs->shell.activated; shell_surface_aspect_update(cs); + shell_surface_minmax_update(cs); } else shell_surface_deactivate_recurse(cs); @@ -3080,10 +3095,25 @@ static void shell_surface_toplevel_move(){} static void shell_surface_toplevel_resize(){} + static void -shell_surface_toplevel_set_max_size(){} +shell_surface_toplevel_set_max_size(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t w, int32_t h) +{ + Comp_Surface *cs = wl_resource_get_user_data(resource); + evas_object_size_hint_max_set(cs->obj, w, h); + if (cs == cs->c->active_surface) + shell_surface_minmax_update(cs); +} + static void -shell_surface_toplevel_set_min_size(){} +shell_surface_toplevel_set_min_size(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t w, int32_t h) +{ + Comp_Surface *cs = wl_resource_get_user_data(resource); + evas_object_size_hint_min_set(cs->obj, w, h); + if (cs == cs->c->active_surface) + shell_surface_minmax_update(cs); +} + static void shell_surface_toplevel_set_maximized(){} static void @@ -5373,3 +5403,20 @@ efl_wl_aspect_set(Evas_Object *obj, Eina_Bool set) else evas_object_size_hint_aspect_set(obj, EVAS_ASPECT_CONTROL_NONE, 0, 0); } + +void +efl_wl_minmax_set(Evas_Object *obj, Eina_Bool set) +{ + Comp *c; + + if (!eina_streq(evas_object_type_get(obj), "comp")) abort(); + c = evas_object_smart_data_get(obj); + c->minmax = !!set; + if (c->minmax) + shell_surface_minmax_update(c->active_surface); + else + { + evas_object_size_hint_min_set(obj, 0, 0); + evas_object_size_hint_max_set(obj, -1, -1); + } +} -- 2.7.4