summaryrefslogtreecommitdiff
path: root/src/lib/efl_wl/efl_wl.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-08-11 18:43:15 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-08-11 18:43:13 -0400
commit2d1e5da35dcbe0c913ec19170dd59fa9f2f378cc (patch)
treede27b9540f89ab35761319dcbc20e6d519dbf028 /src/lib/efl_wl/efl_wl.c
parentdc250e6101c7794d3923eb33f978580e0363142e (diff)
efl-wl: add functionality for extracting surfaces for external use
@feature
Diffstat (limited to 'src/lib/efl_wl/efl_wl.c')
-rw-r--r--src/lib/efl_wl/efl_wl.c86
1 files changed, 79 insertions, 7 deletions
diff --git a/src/lib/efl_wl/efl_wl.c b/src/lib/efl_wl/efl_wl.c
index 5c4fb32c04..213d295a66 100644
--- a/src/lib/efl_wl/efl_wl.c
+++ b/src/lib/efl_wl/efl_wl.c
@@ -325,6 +325,7 @@ struct Comp_Surface
325 Eina_Bool post_render_queue : 1; 325 Eina_Bool post_render_queue : 1;
326 Eina_Bool dead : 1; 326 Eina_Bool dead : 1;
327 Eina_Bool commit : 1; 327 Eina_Bool commit : 1;
328 Eina_Bool extracted : 1;
328}; 329};
329 330
330struct Comp_Subsurface 331struct Comp_Subsurface
@@ -463,19 +464,22 @@ static inline void
463comp_surface_reparent(Comp_Surface *cs, Comp_Surface *pcs) 464comp_surface_reparent(Comp_Surface *cs, Comp_Surface *pcs)
464{ 465{
465 if (cs->parent == pcs) return; 466 if (cs->parent == pcs) return;
466 evas_object_smart_member_del(cs->obj); 467 if (!cs->extracted)
468 evas_object_smart_member_del(cs->obj);
467 if (cs->parent) 469 if (cs->parent)
468 cs->parent->children = eina_inlist_remove(cs->parent->children, EINA_INLIST_GET(cs)); 470 cs->parent->children = eina_inlist_remove(cs->parent->children, EINA_INLIST_GET(cs));
469 if (pcs) 471 if (pcs)
470 { 472 {
471 cs->c->surfaces = eina_inlist_remove(cs->c->surfaces, EINA_INLIST_GET(cs)); 473 cs->c->surfaces = eina_inlist_remove(cs->c->surfaces, EINA_INLIST_GET(cs));
472 cs->c->surfaces_count--; 474 cs->c->surfaces_count--;
473 evas_object_smart_member_add(cs->obj, pcs->obj); 475 if (!cs->extracted)
476 evas_object_smart_member_add(cs->obj, pcs->obj);
474 pcs->children = eina_inlist_append(pcs->children, EINA_INLIST_GET(cs)); 477 pcs->children = eina_inlist_append(pcs->children, EINA_INLIST_GET(cs));
475 } 478 }
476 else 479 else
477 { 480 {
478 evas_object_smart_member_add(cs->obj, cs->c->obj); 481 if (!cs->extracted)
482 evas_object_smart_member_add(cs->obj, cs->c->obj);
479 cs->c->surfaces = eina_inlist_append(cs->c->surfaces, EINA_INLIST_GET(cs)); 483 cs->c->surfaces = eina_inlist_append(cs->c->surfaces, EINA_INLIST_GET(cs));
480 cs->c->surfaces_count++; 484 cs->c->surfaces_count++;
481 } 485 }
@@ -1175,6 +1179,7 @@ shell_surface_minmax_update(Comp_Surface *cs)
1175 1179
1176 if (!cs) return; 1180 if (!cs) return;
1177 if (!cs->c->minmax) return; 1181 if (!cs->c->minmax) return;
1182 if (cs->extracted) return;
1178 evas_object_size_hint_min_get(cs->obj, &w, &h); 1183 evas_object_size_hint_min_get(cs->obj, &w, &h);
1179 evas_object_size_hint_min_set(cs->c->obj, w, h); 1184 evas_object_size_hint_min_set(cs->c->obj, w, h);
1180 evas_object_size_hint_max_get(cs->obj, &w, &h); 1185 evas_object_size_hint_max_get(cs->obj, &w, &h);
@@ -1189,6 +1194,7 @@ shell_surface_aspect_update(Comp_Surface *cs)
1189 1194
1190 if (!cs) return; 1195 if (!cs) return;
1191 if (!cs->c->aspect) return; 1196 if (!cs->c->aspect) return;
1197 if (cs->extracted) return;
1192 evas_object_size_hint_aspect_get(cs->obj, &aspect, &w, &h); 1198 evas_object_size_hint_aspect_get(cs->obj, &aspect, &w, &h);
1193 evas_object_size_hint_aspect_set(cs->c->obj, aspect, w, h); 1199 evas_object_size_hint_aspect_set(cs->c->obj, aspect, w, h);
1194} 1200}
@@ -1218,7 +1224,8 @@ shell_surface_send_configure(Comp_Surface *cs)
1218 { 1224 {
1219 s = wl_array_add(&states, sizeof(uint32_t)); 1225 s = wl_array_add(&states, sizeof(uint32_t));
1220 *s = ZXDG_TOPLEVEL_V6_STATE_ACTIVATED; 1226 *s = ZXDG_TOPLEVEL_V6_STATE_ACTIVATED;
1221 evas_object_raise(cs->obj); 1227 if (!cs->extracted)
1228 evas_object_raise(cs->obj);
1222 if (cs->parent) 1229 if (cs->parent)
1223 cs->parent->children = eina_inlist_demote(cs->parent->children, EINA_INLIST_GET(cs)); 1230 cs->parent->children = eina_inlist_demote(cs->parent->children, EINA_INLIST_GET(cs));
1224 else 1231 else
@@ -1226,7 +1233,10 @@ shell_surface_send_configure(Comp_Surface *cs)
1226 shell_surface_activate_recurse(cs); 1233 shell_surface_activate_recurse(cs);
1227 } 1234 }
1228 serial = wl_display_next_serial(cs->c->display); 1235 serial = wl_display_next_serial(cs->c->display);
1229 evas_object_geometry_get(cs->c->clip, NULL, NULL, &w, &h); 1236 if (cs->extracted)
1237 evas_object_geometry_get(cs->obj, NULL, NULL, &w, &h);
1238 else
1239 evas_object_geometry_get(cs->c->clip, NULL, NULL, &w, &h);
1230 zxdg_toplevel_v6_send_configure(cs->role, w, h, &states); 1240 zxdg_toplevel_v6_send_configure(cs->role, w, h, &states);
1231 zxdg_surface_v6_send_configure(cs->shell.surface, serial); 1241 zxdg_surface_v6_send_configure(cs->shell.surface, serial);
1232 wl_array_release(&states); 1242 wl_array_release(&states);
@@ -1398,6 +1408,11 @@ comp_surface_commit_state(Comp_Surface *cs, Comp_Buffer_State *state)
1398 { 1408 {
1399 evas_object_move(cs->img, x + buffer->x, y + buffer->y); 1409 evas_object_move(cs->img, x + buffer->x, y + buffer->y);
1400 evas_object_resize(cs->obj, buffer->w, buffer->h); 1410 evas_object_resize(cs->obj, buffer->w, buffer->h);
1411 if (cs->shell.popup)
1412 {
1413 evas_object_size_hint_min_set(cs->obj, buffer->w, buffer->h);
1414 evas_object_size_hint_max_set(cs->obj, buffer->w, buffer->h);
1415 }
1401 } 1416 }
1402 else if (cs->shell.new) 1417 else if (cs->shell.new)
1403 shell_surface_init(cs); 1418 shell_surface_init(cs);
@@ -2349,7 +2364,7 @@ comp_surface_smart_hide(Evas_Object *obj)
2349 if (!evas_object_visible_get(lcs->obj)) continue; 2364 if (!evas_object_visible_get(lcs->obj)) continue;
2350 if ((!lcs->shell.surface) || (!lcs->role)) continue; 2365 if ((!lcs->shell.surface) || (!lcs->role)) continue;
2351 lcs->shell.activated = 1; 2366 lcs->shell.activated = 1;
2352 if (lcs->shell.popup) 2367 if (lcs->shell.popup && (!lcs->extracted))
2353 evas_object_raise(lcs->obj); 2368 evas_object_raise(lcs->obj);
2354 else 2369 else
2355 shell_surface_send_configure(lcs); 2370 shell_surface_send_configure(lcs);
@@ -3071,6 +3086,7 @@ shell_surface_toplevel_set_parent(struct wl_client *client EINA_UNUSED, struct w
3071 if (parent_resource) pcs = wl_resource_get_user_data(parent_resource); 3086 if (parent_resource) pcs = wl_resource_get_user_data(parent_resource);
3072 3087
3073 comp_surface_reparent(cs, pcs); 3088 comp_surface_reparent(cs, pcs);
3089 evas_object_smart_callback_call(cs->c->obj, "child_added", cs->obj);
3074} 3090}
3075 3091
3076static void 3092static void
@@ -3256,6 +3272,7 @@ shell_surface_popup_create(struct wl_client *client, struct wl_resource *resourc
3256 comp_surface_reparent(cs, wl_resource_get_user_data(parent_resource)); 3272 comp_surface_reparent(cs, wl_resource_get_user_data(parent_resource));
3257 cs->shell.positioner = wl_resource_get_user_data(positioner_resource); 3273 cs->shell.positioner = wl_resource_get_user_data(positioner_resource);
3258 _apply_positioner(cs, cs->shell.positioner); 3274 _apply_positioner(cs, cs->shell.positioner);
3275 evas_object_smart_callback_call(cs->c->obj, "popup_added", cs->obj);
3259} 3276}
3260 3277
3261static void 3278static void
@@ -5135,7 +5152,7 @@ comp_smart_resize(Evas_Object *obj, int w, int h)
5135 output_resize(c, res); 5152 output_resize(c, res);
5136 //fprintf(stderr, "COMP %dx%d\n", w, h); 5153 //fprintf(stderr, "COMP %dx%d\n", w, h);
5137 EINA_INLIST_FOREACH(c->surfaces, cs) 5154 EINA_INLIST_FOREACH(c->surfaces, cs)
5138 if (cs->shell.surface && cs->role) 5155 if (cs->shell.surface && cs->role && (!cs->extracted))
5139 shell_surface_send_configure(cs); 5156 shell_surface_send_configure(cs);
5140} 5157}
5141 5158
@@ -5457,3 +5474,58 @@ efl_wl_global_add(Evas_Object *obj, const void *interface, uint32_t version, voi
5457 c = evas_object_smart_data_get(obj); 5474 c = evas_object_smart_data_get(obj);
5458 return wl_global_create(c->display, interface, version, data, bind_cb); 5475 return wl_global_create(c->display, interface, version, data, bind_cb);
5459} 5476}
5477
5478static void
5479extracted_focus(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
5480{
5481 Comp_Surface *cs = data;
5482
5483 if (cs->dead) return;
5484 if (!cs->shell.popup)
5485 {
5486 cs->shell.activated = 1;
5487 shell_surface_send_configure(data);
5488 }
5489 evas_object_focus_set(cs->c->obj, 1);
5490}
5491
5492static void
5493extracted_unfocus(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
5494{
5495 Comp_Surface *cs = data;
5496 Evas_Object *focus;
5497
5498 if (cs->dead) return;
5499 focus = evas_focus_get(cs->c->evas);
5500 if ((!focus) || (focus == cs->c->obj)) return;
5501 cs->shell.activated = 0;
5502 shell_surface_send_configure(data);
5503}
5504
5505static void
5506extracted_changed(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
5507{
5508 Comp_Surface *cs = data;
5509
5510 if (cs->dead) return;
5511 shell_surface_send_configure(data);
5512}
5513
5514EAPI Eina_Bool
5515efl_wl_surface_extract(Evas_Object *surface)
5516{
5517 Comp_Surface *cs;
5518 if (!eina_streq(evas_object_type_get(surface), "comp_surface")) abort();
5519 cs = evas_object_smart_data_get(surface);
5520 EINA_SAFETY_ON_TRUE_RETURN_VAL(cs->extracted, EINA_FALSE);
5521 EINA_SAFETY_ON_TRUE_RETURN_VAL(cs->dead, EINA_FALSE);
5522 cs->extracted = 1;
5523 if (!cs->shell.popup)
5524 {
5525 evas_object_event_callback_add(cs->obj, EVAS_CALLBACK_RESIZE, extracted_changed, cs);
5526 evas_object_event_callback_add(cs->obj, EVAS_CALLBACK_FOCUS_OUT, extracted_unfocus, cs);
5527 }
5528 evas_object_event_callback_add(cs->obj, EVAS_CALLBACK_FOCUS_IN, extracted_focus, cs);
5529 evas_object_smart_member_del(surface);
5530 return EINA_TRUE;
5531}