Compare commits

...

8 Commits

Author SHA1 Message Date
Mike Blumenkrantz d589370f08 fix++ 6 years ago
Mike Blumenkrantz 1f28a4ae9b fix++ 6 years ago
Derek Foreman 290098c33e more wip 6 years ago
Derek Foreman 9cd40f0605 WIP stuff 6 years ago
Derek Foreman 24a8b7251a gratuitous fix-up of unused code 6 years ago
Derek Foreman 447f013a50 Fix zoomap incorrectly setting the child object 6 years ago
Derek Foreman 5c95cf4a6e Fix logic inversion in zoomaps 6 years ago
Derek Foreman b591105d8f Add wp_viewporter support 6 years ago
  1. 13
      src/bin/Makefile.mk
  2. 4
      src/bin/e_client.c
  3. 107
      src/bin/e_comp_object.c
  4. 6
      src/bin/e_comp_object.h
  5. 150
      src/bin/e_comp_wl.c
  6. 30
      src/bin/e_comp_wl.h
  7. 3
      src/bin/e_comp_wl_extensions.c
  8. 186
      src/bin/e_comp_wl_scaler.c
  9. 7
      src/bin/e_comp_wl_scaler.h
  10. 179
      src/bin/e_zoomap.c
  11. 7
      src/bin/e_zoomap.h

@ -225,7 +225,8 @@ ENLIGHTENMENTHEADERS += \
src/bin/e_comp_wl_data.h \
src/bin/e_comp_wl_dmabuf.h \
src/bin/e_comp_wl_input.h \
src/bin/e_comp_wl.h
src/bin/e_comp_wl.h \
src/bin/e_comp_wl_scaler.h
endif
enlightenment_gen_src =
@ -431,7 +432,8 @@ src/bin/e_comp_wl_data.c \
src/bin/e_comp_wl_input.c \
src/bin/e_comp_wl_dmabuf.c \
src/bin/e_comp_wl.c \
src/bin/e_comp_wl_extensions.c
src/bin/e_comp_wl_extensions.c \
src/bin/e_comp_wl_scaler.c
enlightenment_gen_src += \
src/bin/generated/linux-dmabuf-unstable-v1-server-protocol.h \
@ -441,7 +443,9 @@ src/bin/generated/session-recovery-server-protocol.h \
src/bin/generated/www-protocol.c \
src/bin/generated/www-server-protocol.h \
src/bin/generated/screenshooter-protocol.c \
src/bin/generated/screenshooter-server-protocol.h
src/bin/generated/screenshooter-server-protocol.h \
src/bin/generated/viewporter-protocol.c \
src/bin/generated/viewporter-server-protocol.h
src/bin/e_comp_wl_extensions.c: \
src/bin/generated/screenshooter-server-protocol.h \
@ -453,6 +457,9 @@ src/bin/e_comp_wl.c: \
src/bin/e_comp_wl_dmabuf.c: \
src/bin/generated/linux-dmabuf-unstable-v1-server-protocol.h
src/bin/e_comp_wl_scaler.c: \
src/bin/generated/viewporter-server-protocol.h
endif
src_bin_enlightenment_CPPFLAGS = $(E_CPPFLAGS) -DE_LOGGING=1 @WAYLAND_CFLAGS@ @WAYLAND_EGL_CFLAGS@ @ECORE_X_CFLAGS@

@ -2686,6 +2686,7 @@ E_API void
e_client_mouse_wheel(E_Client *ec, Evas_Point *output, E_Binding_Event_Wheel *ev)
{
EINA_SAFETY_ON_NULL_RETURN(ec);
evas_pointer_canvas_xy_get(e_comp->evas, &output->x, &output->y);
if (action_client) return;
ec->mouse.current.mx = output->x;
ec->mouse.current.my = output->y;
@ -2701,6 +2702,7 @@ e_client_mouse_down(E_Client *ec, int button, Evas_Point *output, E_Binding_Even
int player;
EINA_SAFETY_ON_NULL_RETURN(ec);
evas_pointer_canvas_xy_get(e_comp->evas, &output->x, &output->y);
if (action_client || ec->iconic || e_client_util_ignored_get(ec)) return;
if ((button >= 1) && (button <= 3))
{
@ -2773,6 +2775,7 @@ E_API void
e_client_mouse_up(E_Client *ec, int button, Evas_Point *output, E_Binding_Event_Mouse_Button* ev)
{
EINA_SAFETY_ON_NULL_RETURN(ec);
evas_pointer_canvas_xy_get(e_comp->evas, &output->x, &output->y);
if (ec->iconic || e_client_util_ignored_get(ec)) return;
if ((button >= 1) && (button <= 3))
{
@ -2807,6 +2810,7 @@ E_API void
e_client_mouse_move(E_Client *ec, Evas_Point *output)
{
EINA_SAFETY_ON_NULL_RETURN(ec);
evas_pointer_canvas_xy_get(e_comp->evas, &output->x, &output->y);
if (ec->iconic || e_client_util_ignored_get(ec)) return;
ec->mouse.current.mx = output->x;
ec->mouse.current.my = output->y;

@ -443,6 +443,7 @@ _e_comp_object_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj E
Evas_Event_Mouse_Down *ev = event_info;
E_Comp_Object *cw = data;
E_Binding_Event_Mouse_Button ev2;
evas_pointer_canvas_xy_get(e_comp->evas, &ev->canvas.x, &ev->canvas.y);
if (!cw->ec) return;
if (e_client_action_get()) return;
@ -458,6 +459,7 @@ _e_comp_object_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EIN
E_Comp_Object *cw = data;
E_Binding_Event_Mouse_Button ev2;
Eina_Bool acting;
evas_pointer_canvas_xy_get(e_comp->evas, &ev->canvas.x, &ev->canvas.y);
if (!cw->ec) return;
if (e_client_action_get() && (e_client_action_get() != cw->ec)) return;
@ -740,39 +742,22 @@ _e_comp_object_shadow_setup(E_Comp_Object *cw)
/* breaks animation counter */
//if (cw->ec->iconic)
//e_comp_object_signal_emit(cw->smart_obj, "e,action,iconify", "e");
if (!cw->zoomap_disabled)
e_zoomap_child_set(cw->zoomobj, NULL);
if (cw->frame_object)
{
edje_object_part_swallow(cw->frame_object, "e.swallow.client", cw->obj);
edje_object_part_swallow(cw->frame_object, "e.swallow.icon", cw->frame_icon);
if (cw->zoomap_disabled)
edje_object_part_swallow(cw->shobj, "e.swallow.content", cw->frame_object);
else
{
e_zoomap_child_set(cw->zoomobj, cw->frame_object);
edje_object_part_swallow(cw->shobj, "e.swallow.content", cw->zoomobj);
}
no_shadow = 1;
}
else
{
no_shadow = 1;
if (cw->zoomobj)
{
e_zoomap_child_set(cw->zoomobj, cw->obj);
edje_object_part_swallow(cw->shobj, "e.swallow.content", cw->zoomobj);
}
else
edje_object_part_swallow(cw->shobj, "e.swallow.content", cw->obj);
}
if (cw->input_obj)
evas_object_pass_events_set(cw->obj, 1);
else
evas_object_pass_events_set(cw->obj, 0);
#ifdef BORDER_ZOOMAPS
e_zoomap_child_edje_solid_setup(cw->zoomobj);
#endif
return EINA_TRUE;
}
@ -879,7 +864,7 @@ _e_comp_object_setup(E_Comp_Object *cw)
evas_object_smart_member_add(cw->clip, cw->smart_obj);
cw->effect_obj = edje_object_add(e_comp->evas);
evas_object_move(cw->effect_obj, cw->x, cw->y);
evas_object_clip_set(cw->effect_obj, cw->clip);
evas_object_clip_set(cw->zoomobj ?: cw->effect_obj, cw->clip);
evas_object_smart_member_add(cw->effect_obj, cw->smart_obj);
e_theme_edje_object_set(cw->effect_obj, "base/theme/comp", "e/comp/effects/none");
cw->shobj = edje_object_add(e_comp->evas);
@ -1763,7 +1748,7 @@ _e_comp_intercept_show(void *data, Evas_Object *obj EINA_UNUSED)
evas_object_event_callback_add(cw->obj, EVAS_CALLBACK_MOUSE_OUT, _e_comp_object_internal_mouse_out, cw);
}
#ifdef BORDER_ZOOMAPS
e_comp_object_zoomap_set(o, 1);
e_comp_object_zoomap_set(cw->obj, 1);
#else
cw->zoomap_disabled = 1;
#endif
@ -2306,7 +2291,7 @@ _e_comp_smart_hide(Evas_Object *obj)
cw->visible = 0;
evas_object_hide(cw->clip);
if (cw->input_obj) evas_object_hide(cw->input_obj);
evas_object_hide(cw->effect_obj);
evas_object_hide(cw->zoomobj ?: cw->effect_obj);
if (stopping) return;
if (!cw->ec->input_only)
{
@ -2350,7 +2335,7 @@ _e_comp_smart_show(Evas_Object *obj)
if (cw->frame_object)
edje_object_play_set(cw->frame_object, 1);
}
evas_object_show(cw->effect_obj);
evas_object_show(cw->zoomobj ?: cw->effect_obj);
if (cw->ec->internal_elm_win && (!evas_object_visible_get(cw->ec->internal_elm_win)))
evas_object_show(cw->ec->internal_elm_win);
e_comp_render_queue();
@ -2443,7 +2428,7 @@ _e_comp_smart_move(Evas_Object *obj, int x, int y)
evas_object_move(o, cw->ec->x, cw->ec->x);
cw->agent_updating = 0;
evas_object_move(cw->clip, 0, 0);
evas_object_move(cw->effect_obj, x, y);
evas_object_move(cw->zoomobj ?: cw->effect_obj, x, y);
if (cw->input_obj)
evas_object_geometry_set(cw->input_obj,
cw->x + cw->input_rect.x + (!!cw->frame_object * cw->client_inset.l),
@ -2491,7 +2476,6 @@ _e_comp_smart_resize(Evas_Object *obj, int w, int h)
CRI("CW RSZ: %dx%d || PX: %dx%d", ww, hh, pw, ph);
}
evas_object_resize(cw->effect_obj, w, h);
if (cw->zoomobj) e_zoomap_child_resize(cw->zoomobj, pw, ph);
if (cw->input_obj)
evas_object_geometry_set(cw->input_obj,
cw->x + cw->input_rect.x + (!!cw->frame_object * cw->client_inset.l),
@ -2560,15 +2544,17 @@ e_comp_object_zoomap_set(Evas_Object *obj, Eina_Bool enabled)
{
API_ENTRY;
enabled = !enabled;
if (cw->zoomap_disabled == enabled) return;
if (cw->zoomap_disabled == !enabled) return;
if (enabled)
{
cw->zoomobj = e_zoomap_add(e_comp->evas);
e_zoomap_smooth_set(cw->zoomobj, e_comp_config_get()->smooth_windows);
e_zoomap_child_set(cw->zoomobj, cw->ec ? cw->frame_object : cw->obj);
// e_zoomap_child_set(cw->zoomobj, cw->frame_object ? cw->frame_object : cw->obj);
e_zoomap_child_set(cw->zoomobj, cw->effect_obj);
edje_object_part_swallow(cw->shobj, "e.swallow.content", cw->zoomobj);
e_zoomap_child_edje_solid_setup(cw->zoomobj);
evas_object_smart_member_add(cw->zoomobj, cw->smart_obj);
evas_object_clip_set(cw->zoomobj, cw->clip);
if (cw->ec->override)
evas_object_name_set(cw->zoomobj, "cw->zoomobj::WINDOW");
else if (!cw->ec->input_only)
@ -2576,11 +2562,54 @@ e_comp_object_zoomap_set(Evas_Object *obj, Eina_Bool enabled)
}
else
{
edje_object_part_unswallow(cw->shobj, cw->zoomobj);
e_zoomap_child_set(cw->zoomap, NULL);
E_FREE_FUNC(cw->zoomobj, evas_object_del);
edje_object_part_swallow(cw->shobj, "e.swallow.content", cw->ec ? cw->frame_object : cw->obj);
evas_object_smart_member_add(cw->effect_obj, cw->smart_obj);
evas_object_clip_set(cw->effect_obj, cw->clip);
}
cw->zoomap_disabled = enabled;
cw->zoomap_disabled = !enabled;
}
E_API void
e_comp_object_viewport_source_set(Evas_Object *obj, int src_x, int src_y, int src_width, int src_height)
{
API_ENTRY;
e_zoomap_viewport_source_set(cw->zoomobj, src_x, src_y, src_width, src_height);
}
E_API void
e_comp_object_viewport_destination_set(Evas_Object *obj, int width, int height)
{
API_ENTRY;
e_zoomap_viewport_destination_set(cw->zoomobj, width, height);
}
E_API void
e_comp_object_viewport_set(Evas_Object *obj, Eina_Bool enabled)
{
API_ENTRY;
e_zoomap_commit(cw->zoomobj);
}
E_API void
e_comp_object_scale_set(Evas_Object *obj, int32_t scale)
{
API_ENTRY;
e_zoomap_scale_set(cw->zoomobj, scale);
e_zoomap_commit(cw->zoomobj);
}
E_API void
e_comp_object_transform_set(Evas_Object *obj, uint32_t transform)
{
API_ENTRY;
e_zoomap_transform_set(cw->zoomobj, transform);
e_zoomap_commit(cw->zoomobj);
}
E_API Eina_Bool
@ -3867,6 +3896,26 @@ e_comp_object_dirty(Evas_Object *obj)
e_comp_object_render(obj);
}
E_API void
e_comp_object_map_set(Evas_Object *obj, Evas_Map *map)
{
Eina_List *l;
Evas_Object *o;
API_ENTRY;
evas_object_map_set(obj, map);
evas_object_map_enable_set(obj, map ? EINA_TRUE : EINA_FALSE);
EINA_LIST_FOREACH(cw->obj_mirror, l, o)
{
Evas_Map *map2 = evas_map_dup(map);
evas_object_map_set(o, map2);
evas_object_map_enable_set(o, map2 ? EINA_TRUE : EINA_FALSE);
evas_map_free(map2);
}
}
E_API Eina_Bool
e_comp_object_render(Evas_Object *obj)
{

@ -91,6 +91,12 @@ E_API Eina_Bool e_comp_object_effect_start(Evas_Object *obj, Edje_Signal_Cb end_
E_API Eina_Bool e_comp_object_effect_stop(Evas_Object *obj, Edje_Signal_Cb end_cb);
E_API E_Comp_Object_Mover *e_comp_object_effect_mover_add(int pri, const char *sig, E_Comp_Object_Mover_Cb provider, const void *data);
E_API void e_comp_object_effect_mover_del(E_Comp_Object_Mover *prov);
E_API void e_comp_object_map_set(Evas_Object *obj, Evas_Map *map);
E_API void e_comp_object_viewport_source_set(Evas_Object *obj, int src_x, int src_y, int src_width, int src_height);
E_API void e_comp_object_viewport_destination_set(Evas_Object *obj, int width, int height);
E_API void e_comp_object_viewport_set(Evas_Object *obj, Eina_Bool enabled);
E_API void e_comp_object_scale_set(Evas_Object *obj, int32_t scale);
E_API void e_comp_object_transform_set(Evas_Object *obj, uint32_t transform);
#endif
#endif

@ -1247,6 +1247,12 @@ _e_comp_wl_surface_state_init(E_Comp_Wl_Surface_State *state, int w, int h)
state->opaque = eina_tiler_new(w, h);
eina_tiler_tile_size_set(state->opaque, 1, 1);
state->transform = WL_OUTPUT_TRANSFORM_NORMAL;
state->scale = 1;
state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
state->buffer_viewport.surface.width = -1;
state->buffer_viewport.changed = 0;
}
static void
@ -1299,6 +1305,93 @@ _e_comp_wl_surface_state_attach(E_Client *ec, E_Comp_Wl_Surface_State *state)
e_pixmap_refresh(ec->pixmap);
}
static void
_e_comp_wl_map_size_cal_from_viewport(E_Client *ec, int32_t bw, int32_t bh, int32_t *ow, int32_t *oh)
{
E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
int32_t width, height;
width = bw;
height = bh;
if (width != 0 && vp->surface.width != -1)
{
*ow = vp->surface.width;
*oh = vp->surface.height;
return;
}
if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1))
{
int32_t w = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_width);
int32_t h = wl_fixed_to_int(wl_fixed_from_int(1) - 1 + vp->buffer.src_height);
*ow = w ?: 1;
*oh = h ?: 1;
return;
}
*ow = width;
*oh = height;
}
/*
static void
_e_comp_wl_map_apply(E_Client *ec)
{
E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
Evas_Map *map;
int x1, y1, x2, y2, x, y;
int32_t w, h, vw, vh;
_e_comp_wl_map_size_cal_from_buffer(ec, &w, &h);
_e_comp_wl_map_size_cal_from_viewport(ec, w, h, &vw, &vh);
map = evas_map_new(4);
evas_map_util_points_populate_from_geometry(map,
ec->x, ec->y,
vw, vh, 0);
if (vp->buffer.src_width == wl_fixed_from_int(-1))
{
x1 = 0.0;
y1 = 0.0;
x2 = w;
y2 = h;
}
else
{
x1 = wl_fixed_to_int(vp->buffer.src_x);
y1 = wl_fixed_to_int(vp->buffer.src_y);
x2 = wl_fixed_to_int(vp->buffer.src_x + vp->buffer.src_width);
y2 = wl_fixed_to_int(vp->buffer.src_y + vp->buffer.src_height);
}
_e_comp_wl_map_transform(w, h,
vp->buffer.transform, vp->buffer.scale,
x1, y1, &x, &y);
evas_map_point_image_uv_set(map, 0, x, y);
_e_comp_wl_map_transform(w, h,
vp->buffer.transform, vp->buffer.scale,
x2, y1, &x, &y);
evas_map_point_image_uv_set(map, 1, x, y);
_e_comp_wl_map_transform(w, h,
vp->buffer.transform, vp->buffer.scale,
x2, y2, &x, &y);
evas_map_point_image_uv_set(map, 2, x, y);
_e_comp_wl_map_transform(w, h,
vp->buffer.transform, vp->buffer.scale,
x1, y2, &x, &y);
evas_map_point_image_uv_set(map, 3, x, y);
e_comp_object_map_set(ec->frame, map);
evas_map_free(map);
}
*/
static void
_e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
{
@ -1322,6 +1415,8 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
e_client_unignore(ec);
}
ec->comp_data->scaler.buffer_viewport = state->buffer_viewport;
if (state->new_attach)
_e_comp_wl_surface_state_attach(ec, state);
@ -1470,6 +1565,38 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
}
}
if (e_pixmap_usable_get(ec->pixmap))
{
if (state->scale > 1 && state->scale != ec->comp_data->scale)
{
ec->comp_data->scale = state->scale;
e_comp_object_zoomap_set(ec->frame, 1);
e_comp_object_scale_set(ec->frame, state->scale);
}
if (state->transform && state->transform != ec->comp_data->transform)
{
ec->comp_data->transform = state->transform;
e_comp_object_zoomap_set(ec->frame, 1);
e_comp_object_transform_set(ec->frame, state->transform);
}
}
if (e_pixmap_usable_get(ec->pixmap) && state->buffer_viewport.changed)
{
E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
e_comp_object_zoomap_set(ec->frame, 1);
e_comp_object_viewport_source_set(ec->frame,
wl_fixed_to_int(vp->buffer.src_x),
wl_fixed_to_int(vp->buffer.src_y),
wl_fixed_to_int(vp->buffer.src_width),
wl_fixed_to_int(vp->buffer.src_height));
e_comp_object_viewport_destination_set(ec->frame,
vp->surface.width,
vp->surface.height);
e_comp_object_viewport_set(ec->frame, 1);
state->buffer_viewport.changed = 0;
}
state->sx = 0;
state->sy = 0;
state->new_attach = EINA_FALSE;
@ -1717,15 +1844,25 @@ _e_comp_wl_surface_cb_commit(struct wl_client *client EINA_UNUSED, struct wl_res
}
static void
_e_comp_wl_surface_cb_buffer_transform_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, int32_t transform EINA_UNUSED)
_e_comp_wl_surface_cb_buffer_transform_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, int32_t transform)
{
/* DBG("Surface Buffer Transform: %d", wl_resource_get_id(resource)); */
E_Client *ec;
if (!(ec = wl_resource_get_user_data(resource))) return;
if (e_object_is_del(E_OBJECT(ec))) return;
ec->comp_data->pending.transform = transform;
}
static void
_e_comp_wl_surface_cb_buffer_scale_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, int32_t scale EINA_UNUSED)
_e_comp_wl_surface_cb_buffer_scale_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, int32_t scale)
{
/* DBG("Surface Buffer Scale: %d", wl_resource_get_id(resource)); */
E_Client *ec;
if (!(ec = wl_resource_get_user_data(resource))) return;
if (e_object_is_del(E_OBJECT(ec))) return;
ec->comp_data->pending.scale = scale;
}
static const struct wl_surface_interface _e_surface_interface =
@ -2420,6 +2557,11 @@ _e_comp_wl_client_cb_new(void *data EINA_UNUSED, E_Client *ec)
/* set initial client data properties */
ec->comp_data->mapped = EINA_FALSE;
ec->comp_data->transform = WL_OUTPUT_TRANSFORM_NORMAL;
ec->comp_data->scale = 1;
ec->comp_data->scaler.buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
ec->comp_data->scaler.buffer_viewport.surface.width = -1;
/* add this client to the hash */
/* eina_hash_add(clients_win_hash, &win, ec); */
}

@ -43,6 +43,7 @@
})
typedef struct _E_Comp_Wl_Buffer E_Comp_Wl_Buffer;
typedef struct _E_Comp_Wl_Buffer_Viewport E_Comp_Wl_Buffer_Viewport;
typedef struct _E_Comp_Wl_Subsurf_Data E_Comp_Wl_Subsurf_Data;
typedef struct _E_Comp_Wl_Surface_State E_Comp_Wl_Surface_State;
typedef struct _E_Comp_Wl_Client_Data E_Comp_Wl_Client_Data;
@ -64,6 +65,23 @@ struct _E_Comp_Wl_Buffer
uint32_t busy;
};
struct _E_Comp_Wl_Buffer_Viewport {
struct
{
/* If src_width != wl_fixed_from_int(-1), then and only then src_* are used. */
wl_fixed_t src_x, src_y;
wl_fixed_t src_width, src_height;
} buffer;
struct
{
/* If width == -1, the size is inferred from the buffer. */
int32_t width, height;
} surface;
int changed;
};
struct _E_Comp_Wl_Surface_State
{
int sx, sy;
@ -72,6 +90,9 @@ struct _E_Comp_Wl_Surface_State
struct wl_listener buffer_destroy_listener;
Eina_List *damages, *frames;
Eina_Tiler *input, *opaque;
uint32_t transform;
int32_t scale;
E_Comp_Wl_Buffer_Viewport buffer_viewport;
Eina_Bool new_attach : 1;
Eina_Bool has_data : 1;
};
@ -309,6 +330,15 @@ struct _E_Comp_Wl_Client_Data
int32_t x, y;
} popup;
uint32_t transform;
int32_t scale;
struct
{
struct wl_resource *viewport;
E_Comp_Wl_Buffer_Viewport buffer_viewport;
} scaler;
int32_t on_outputs; /* Bitfield of the outputs this client is present on */
E_Maximize max;

@ -6,6 +6,7 @@
#include "screenshooter-server-protocol.h"
#include "session-recovery-server-protocol.h"
#include "www-server-protocol.h"
#include "e_comp_wl_scaler.h"
static void
_e_comp_wl_extensions_client_move_begin(void *d EINA_UNUSED, E_Client *ec)
@ -280,6 +281,8 @@ e_comp_wl_extensions_init(void)
GLOBAL_CREATE_OR_RETURN(screenshooter, zwp_screenshooter_interface, 1);
GLOBAL_CREATE_OR_RETURN(www, www_interface, 1);
e_scaler_init();
ecore_event_handler_add(ECORE_WL2_EVENT_SYNC_DONE, _dmabuf_add, NULL);
e_client_hook_add(E_CLIENT_HOOK_MOVE_BEGIN, _e_comp_wl_extensions_client_move_begin, NULL);

@ -0,0 +1,186 @@
#define E_COMP_WL
#include "e.h"
#include "viewporter-server-protocol.h"
static void
_e_viewport_destroy(struct wl_resource *resource)
{
E_Client *ec = wl_resource_get_user_data(resource);
E_Comp_Client_Data *cdata;
if (e_object_is_del(E_OBJECT(ec))) return;
EINA_SAFETY_ON_NULL_RETURN(cdata = ec->comp_data);
EINA_SAFETY_ON_NULL_RETURN(cdata->scaler.viewport);
cdata->scaler.viewport = NULL;
cdata->pending.buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
cdata->pending.buffer_viewport.surface.width = -1;
cdata->pending.buffer_viewport.changed = 1;
}
static void
_e_viewport_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
{
wl_resource_destroy(resource);
}
static void
_e_viewport_cb_set_source(struct wl_client *client EINA_UNUSED,
struct wl_resource *resource,
wl_fixed_t src_x,
wl_fixed_t src_y,
wl_fixed_t src_width,
wl_fixed_t src_height)
{
E_Client *ec = wl_resource_get_user_data(resource);
E_Comp_Client_Data *cdata;
if (e_object_is_del(E_OBJECT(ec))) return;
EINA_SAFETY_ON_NULL_RETURN(cdata = ec->comp_data);
EINA_SAFETY_ON_NULL_RETURN(cdata->scaler.viewport);
if (src_width == wl_fixed_from_int(-1) && src_height == wl_fixed_from_int(-1))
{
/* unset source size */
cdata->pending.buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
cdata->pending.buffer_viewport.changed = 1;
return;
}
if (src_width <= 0 || src_height <= 0)
{
wl_resource_post_error(resource,
WP_VIEWPORT_ERROR_BAD_VALUE,
"source size must be positive (%fx%f)",
wl_fixed_to_double(src_width),
wl_fixed_to_double(src_height));
return;
}
cdata->pending.buffer_viewport.buffer.src_x = src_x;
cdata->pending.buffer_viewport.buffer.src_y = src_y;
cdata->pending.buffer_viewport.buffer.src_width = src_width;
cdata->pending.buffer_viewport.buffer.src_height = src_height;
cdata->pending.buffer_viewport.changed = 1;
}
static void
_e_viewport_cb_set_destination(struct wl_client *client EINA_UNUSED,
struct wl_resource *resource,
int32_t dst_width,
int32_t dst_height)
{
E_Client *ec = wl_resource_get_user_data(resource);
E_Comp_Client_Data *cdata;
if (e_object_is_del(E_OBJECT(ec))) return;
EINA_SAFETY_ON_NULL_RETURN(cdata = ec->comp_data);
EINA_SAFETY_ON_NULL_RETURN(cdata->scaler.viewport);
if (dst_width == -1 && dst_height == -1)
{
/* unset destination size */
cdata->pending.buffer_viewport.surface.width = -1;
cdata->pending.buffer_viewport.changed = 1;
return;
}
if (dst_width <= 0 || dst_height <= 0)
{
wl_resource_post_error(resource,
WP_VIEWPORT_ERROR_BAD_VALUE,
"destination size must be positive (%dx%d)",
dst_width, dst_height);
return;
}
cdata->pending.buffer_viewport.surface.width = dst_width;
cdata->pending.buffer_viewport.surface.height = dst_height;
cdata->pending.buffer_viewport.changed = 1;
}
static const struct wp_viewport_interface _e_viewport_interface = {
_e_viewport_cb_destroy,
_e_viewport_cb_set_source,
_e_viewport_cb_set_destination
};
static void
_e_scaler_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
{
wl_resource_destroy(resource);
}
static void
_e_scaler_cb_get_viewport(struct wl_client *client EINA_UNUSED, struct wl_resource *scaler, uint32_t id, struct wl_resource *surface_resource)
{
int version = wl_resource_get_version(scaler);
E_Client *ec;
struct wl_resource *res;
E_Comp_Client_Data *cdata;
if (!(ec = wl_resource_get_user_data(surface_resource))) return;
if (e_object_is_del(E_OBJECT(ec))) return;
if (!(cdata = ec->comp_data)) return;
if (cdata->scaler.viewport)
{
wl_resource_post_error(scaler,
WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS,
"a viewport for that surface already exists");
return;
}
res = wl_resource_create(client, &wp_viewport_interface, version, id);
if (res == NULL)
{
wl_client_post_no_memory(client);
return;
}
cdata->scaler.viewport = res;
wl_resource_set_implementation(res, &_e_viewport_interface, ec, _e_viewport_destroy);
}
static const struct wp_viewporter_interface _e_scaler_interface =
{
_e_scaler_cb_destroy,
_e_scaler_cb_get_viewport
};
static void
_e_scaler_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
{
struct wl_resource *res;
if (!(res = wl_resource_create(client, &wp_viewporter_interface, MIN(version, 2), id)))
{
ERR("Could not create scaler resource: %m");
wl_client_post_no_memory(client);
return;
}
wl_resource_set_implementation(res, &_e_scaler_interface, NULL, NULL);
}
Eina_Bool
e_scaler_init(void)
{
E_Comp_Wl_Data *cdata;
if (!e_comp) return EINA_FALSE;
if (!(cdata = e_comp->wl_comp_data)) return EINA_FALSE;
if (!cdata->wl.disp) return EINA_FALSE;
/* try to add scaler to wayland globals */
if (!wl_global_create(cdata->wl.disp, &wp_viewporter_interface, 1,
cdata, _e_scaler_cb_bind))
{
ERR("Could not add scaler to wayland globals: %m");
return EINA_FALSE;
}
return EINA_TRUE;
}

@ -0,0 +1,7 @@
#ifndef E_COMP_WL_SCALER_H
#define E_COMP_WL_SCALER_H
Eina_Bool e_scaler_init(void);
#endif

@ -8,12 +8,18 @@ typedef struct _E_Smart_Data E_Smart_Data;
struct _E_Smart_Data
{
Evas_Object *smart_obj, *child_obj;
Evas_Object *clip;
Evas_Coord x, y, w, h;
Evas_Coord child_w, child_h;
int32_t scale;
uint32_t transform;
int src_x, src_y, src_w, src_h;
int dst_w, dst_h;
unsigned int recurse;
Eina_Bool solid : 1;
Eina_Bool smooth : 1;
Eina_Bool always : 1;
Eina_Bool viewport : 1;
};
/* local subsystem functions */
@ -36,6 +42,61 @@ static void _e_zoomap_smart_init(void);
static Evas_Smart *_e_smart = NULL;
/* externally accessible functions */
E_API void
e_zoomap_commit(Evas_Object *obj)
{
API_ENTRY return;
_e_zoomap_smart_reconfigure(sd);
}
E_API void
e_zoomap_viewport_source_set(Evas_Object *obj, int x, int y, int w, int h)
{
API_ENTRY return;
fprintf(stderr, "ZOOM: %d %d %d %d\n", x, y, w, h);
sd->src_x = x;
sd->src_y = y;
sd->src_w = w;
sd->src_h = h;
sd->viewport = EINA_TRUE;
}
E_API void
e_zoomap_viewport_destination_set(Evas_Object *obj, int w, int h)
{
API_ENTRY return;
sd->w = w;
sd->h = h;
sd->viewport = EINA_TRUE;
}
E_API void
e_zoomap_viewport_set(Evas_Object *obj, Eina_Bool enabled)
{
API_ENTRY return;
fprintf(stderr, "ZOOM: %d\n", enabled);
sd->viewport = enabled;
}
E_API void
e_zoomap_scale_set(Evas_Object *obj, int32_t scale)
{
API_ENTRY return;
sd->scale = scale;
}
E_API void
e_zoomap_transform_set(Evas_Object *obj, uint32_t transform)
{
API_ENTRY return;
sd->transform = transform;
_e_zoomap_smart_reconfigure(sd);
}
E_API Evas_Object *
e_zoomap_add(Evas *evas)
{
@ -47,6 +108,7 @@ E_API void
e_zoomap_child_set(Evas_Object *obj, Evas_Object *child)
{
API_ENTRY return;
fprintf(stderr, "CHILD SET: %p %p\n", obj, child);
if (child == sd->child_obj) return;
if (sd->child_obj)
{
@ -68,6 +130,7 @@ e_zoomap_child_set(Evas_Object *obj, Evas_Object *child)
evas_object_smart_member_add(sd->child_obj, sd->smart_obj);
evas_object_geometry_get(sd->child_obj, NULL, NULL,
&sd->child_w, &sd->child_h);
fprintf(stderr, "child set: (%p)'s CHILD (%p) SIZE: %d %d\n", obj, sd->child_obj, sd->child_w, sd->child_h);
evas_object_event_callback_add(child, EVAS_CALLBACK_DEL,
_e_zoomap_smart_child_del_hook, sd);
evas_object_event_callback_add(child, EVAS_CALLBACK_RESIZE,
@ -86,6 +149,8 @@ e_zoomap_child_resize(Evas_Object *obj, int w, int h)
{
API_ENTRY return;
evas_object_resize(sd->child_obj, w, h);
fprintf(stderr, "child_resize (%p)'s CHILD (%p) RESIZED... %d %d\n", obj, sd->child_obj, w, h);
//sd->child_w = w; sd->child_h = h;
}
E_API Evas_Object *
@ -189,13 +254,93 @@ _e_zoomap_smart_child_resize_hook(void *data, Evas *e EINA_UNUSED, Evas_Object *
}
}
static void
_e_zoomap_size(E_Smart_Data *sd, int32_t *ow, int32_t *oh)
{
switch (sd->transform)
{
case WL_OUTPUT_TRANSFORM_90:
case WL_OUTPUT_TRANSFORM_270:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
*ow = sd->child_h;
*oh = sd->child_w;
break;
default:
*ow = sd->child_w;
*oh = sd->child_h;
break;
}
if (sd->scale > 1)
{
*ow /= sd->scale;
*oh /= sd->scale;
}
}
static void
_e_zoomap_transform_point(E_Smart_Data *sd, int sx, int sy, int *dx, int *dy)
{
int width, height;
_e_zoomap_size(sd, &width, &height);
switch (sd->transform)
{
case WL_OUTPUT_TRANSFORM_NORMAL:
default:
*dx = sx, *dy = sy;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED:
*dx = width - sx, *dy = sy;
break;
case WL_OUTPUT_TRANSFORM_90:
*dx = height - sy, *dy = sx;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
*dx = height - sy, *dy = width - sx;
break;
case WL_OUTPUT_TRANSFORM_180:
*dx = width - sx, *dy = height - sy;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
*dx = sx, *dy = height - sy;
break;
case WL_OUTPUT_TRANSFORM_270:
*dx = sy, *dy = width - sx;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
*dx = sy, *dy = sx;
break;
}
if (sd->scale > 1)
{
*dx *= sd->scale;
*dy *= sd->scale;
}
fprintf(stderr, "TRANSFORM %d %d rot %d scale %d to %d %d\n", sx, sy, sd->transform, sd->scale, *dx, *dy);
}
static Eina_Bool
_e_zoomap_transformed(E_Smart_Data *sd)
{
if (sd->scale > 1) return EINA_TRUE;
fprintf(stderr, "TRANSFORM (%p): %d\n", sd, sd->transform);
if (sd->transform != 0) return EINA_TRUE;
return EINA_FALSE;
}
static void
_e_zoomap_smart_reconfigure(E_Smart_Data *sd)
{
if (!sd->child_obj) return;
sd->recurse++;
if ((!sd->always) &&
((sd->w == sd->child_w) && (sd->h == sd->child_h)))
((sd->w == sd->child_w) && (sd->h == sd->child_h)) &&
(!_e_zoomap_transformed(sd)))
{
evas_object_map_set(sd->child_obj, NULL);
evas_object_map_enable_set(sd->child_obj, EINA_FALSE);
@ -208,7 +353,8 @@ _e_zoomap_smart_reconfigure(E_Smart_Data *sd)
Evas *e = evas_object_evas_get(sd->child_obj);
Evas_Coord cx = 0, cy = 0;
int r = 0, g = 0, b = 0, a = 0;
int width, height, x, y;
evas_object_geometry_get(sd->child_obj, &cx, &cy, NULL, NULL);
if (sd->recurse != 1)
{
@ -227,12 +373,29 @@ _e_zoomap_smart_reconfigure(E_Smart_Data *sd)
}
evas_object_color_get(sd->child_obj, &r, &g, &b, &a);
m = evas_map_new(4);
evas_map_util_points_populate_from_geometry(m, sd->x, sd->y,
sd->w, sd->h, 0);
evas_map_point_image_uv_set(m, 0, 0, 0);
evas_map_point_image_uv_set(m, 1, sd->child_w, 0);
evas_map_point_image_uv_set(m, 2, sd->child_w, sd->child_h);
evas_map_point_image_uv_set(m, 3, 0, sd->child_h);
_e_zoomap_size(sd, &width, &height);
fprintf(stderr, "PLZ HALP surface at: (%d, %d) buffer:(%d, %d) surface:(%d, %d)\n", sd->x, sd->y, sd->child_w, sd->child_h, width, height);
evas_map_util_points_populate_from_geometry(m, sd->x, sd->y,
width, height, 0);
_e_zoomap_transform_point(sd, 0, 0, &x, &y);
evas_map_point_image_uv_set(m, 0, x, y);
_e_zoomap_transform_point(sd, width, 0, &x, &y);
evas_map_point_image_uv_set(m, 1, x, y);
_e_zoomap_transform_point(sd, width, height, &x, &y);
evas_map_point_image_uv_set(m, 2, x, y);
_e_zoomap_transform_point(sd, 0, height, &x, &y);
evas_map_point_image_uv_set(m, 3, x, y);
/*
evas_map_point_image_uv_set(m, 0, 100, 0);
evas_map_point_image_uv_set(m, 1, 200, 100);
evas_map_point_image_uv_set(m, 2, 100, 200);
evas_map_point_image_uv_set(m, 3, 0, 100);
*/
evas_map_smooth_set(m, sd->smooth);
evas_map_point_color_set(m, 0, r, g, b, a);
evas_map_point_color_set(m, 1, r, g, b, a);

@ -14,5 +14,12 @@ E_API void e_zoomap_always_set (Evas_Object *obj, Eina_Bool always);
E_API Eina_Bool e_zoomap_always_get (Evas_Object *obj);
E_API void e_zoomap_child_resize(Evas_Object *zoomap, int w, int h);
E_API void e_zoomap_child_edje_solid_setup(Evas_Object *obj);
E_API void e_zoomap_viewport_source_set(Evas_Object *obj, int x, int y, int w, int h);
E_API void e_zoomap_viewport_destination_set(Evas_Object *obj, int w, int h);
E_API void e_zoomap_viewport_set(Evas_Object *obj, Eina_Bool enabled);
E_API void e_zoomap_scale_set(Evas_Object *obj, int32_t scale);
E_API void e_zoomap_transform_set(Evas_Object *obj, uint32_t transform);
E_API void e_zoomap_commit(Evas_Object *obj);
#endif
#endif

Loading…
Cancel
Save