libweston: Use weston_coord in surface committed handler

I also snuck in a trivial change to drag_surface_configure at the same
time to avoid yet another micro patch.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-02-04 08:02:26 -06:00
parent 5e353d523f
commit 59a0bd99bd
11 changed files with 66 additions and 43 deletions

View File

@ -185,7 +185,8 @@ input_panel_get_label(struct weston_surface *surface, char *buf, size_t len)
}
static void
input_panel_committed(struct weston_surface *surface, int32_t sx, int32_t sy)
input_panel_committed(struct weston_surface *surface,
struct weston_coord_surface new_origin)
{
struct input_panel_surface *ip_surface = surface->committed_private;
struct desktop_shell *shell = ip_surface->shell;

View File

@ -509,7 +509,8 @@ focus_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
/* no-op func for checking focus surface */
static void
focus_surface_committed(struct weston_surface *es, int32_t sx, int32_t sy)
focus_surface_committed(struct weston_surface *es,
struct weston_coord_surface new_origin)
{
}
@ -1620,7 +1621,8 @@ black_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
}
static void
black_surface_committed(struct weston_surface *es, int32_t sx, int32_t sy)
black_surface_committed(struct weston_surface *es,
struct weston_coord_surface new_origin)
{
}
@ -2556,7 +2558,8 @@ background_get_label(struct weston_surface *surface, char *buf, size_t len)
}
static void
background_committed(struct weston_surface *es, int32_t sx, int32_t sy)
background_committed(struct weston_surface *es,
struct weston_coord_surface new_origin)
{
struct desktop_shell *shell = es->committed_private;
struct weston_view *view;
@ -2636,7 +2639,8 @@ panel_get_label(struct weston_surface *surface, char *buf, size_t len)
}
static void
panel_committed(struct weston_surface *es, int32_t sx, int32_t sy)
panel_committed(struct weston_surface *es,
struct weston_coord_surface new_origin)
{
struct desktop_shell *shell = es->committed_private;
struct weston_view *view;
@ -2735,7 +2739,8 @@ lock_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
}
static void
lock_surface_committed(struct weston_surface *surface, int32_t sx, int32_t sy)
lock_surface_committed(struct weston_surface *surface,
struct weston_coord_surface new_origin)
{
struct desktop_shell *shell = surface->committed_private;
struct weston_view *view;

View File

@ -221,7 +221,8 @@ seat_created(struct wl_listener *l, void *data)
}
static void
black_surface_committed(struct weston_surface *es, int32_t sx, int32_t sy)
black_surface_committed(struct weston_surface *es,
struct weston_coord_surface new_origin)
{
}
@ -560,8 +561,8 @@ fs_output_configure(struct fs_output *fsout,
}
static void
configure_presented_surface(struct weston_surface *surface, int32_t sx,
int32_t sy)
configure_presented_surface(struct weston_surface *surface,
struct weston_coord_surface new_origin)
{
configure_presented_surface_internal(surface);
}

View File

@ -1704,10 +1704,11 @@ struct weston_surface {
/*
* If non-NULL, this function will be called on
* wl_surface::commit after a new buffer has been set up for
* this surface. The integer params are the sx and sy
* parameters supplied to wl_surface::attach.
* this surface. The coordinate holds the buffer offset parameters
* supplied to wl_surface::attach or wl_surface::offset.
*/
void (*committed)(struct weston_surface *es, int32_t sx, int32_t sy);
void (*committed)(struct weston_surface *es,
struct weston_coord_surface new_origin);
void *committed_private;
int (*get_label)(struct weston_surface *surface, char *buf, size_t len);

View File

@ -34,7 +34,8 @@ extern "C" {
/* parameter for weston_curtain_create() */
struct weston_curtain_params {
int (*get_label)(struct weston_surface *es, char *buf, size_t len);
void (*surface_committed)(struct weston_surface *es, int32_t sx, int32_t sy);
void (*surface_committed)(struct weston_surface *es,
struct weston_coord_surface new_origin);
void *surface_private;
float r, g, b, a;
int x, y, width, height;

View File

@ -76,7 +76,7 @@ struct ivi_shell_surface
*/
static void
ivi_shell_surface_committed(struct weston_surface *, int32_t, int32_t);
ivi_shell_surface_committed(struct weston_surface *, struct weston_coord_surface);
static struct ivi_shell_surface *
get_ivi_shell_surface(struct weston_surface *surface)
@ -117,7 +117,7 @@ shell_surface_send_configure(struct weston_surface *surface,
static void
ivi_shell_surface_committed(struct weston_surface *surface,
int32_t sx, int32_t sy)
struct weston_coord_surface new_origin)
{
struct ivi_shell_surface *ivisurf = get_ivi_shell_surface(surface);

View File

@ -107,7 +107,8 @@ static char *
weston_output_create_heads_string(struct weston_output *output);
static void
subsurface_committed(struct weston_surface *surface, int32_t dx, int32_t dy);
subsurface_committed(struct weston_surface *surface,
struct weston_coord_surface new_origin);
static void
weston_view_dirty_paint_nodes(struct weston_view *view)
@ -4023,8 +4024,14 @@ weston_surface_commit_state(struct weston_surface *surface,
if (state->newly_attached || state->buffer_viewport.changed ||
state->sx != 0 || state->sy != 0) {
weston_surface_update_size(surface);
if (surface->committed)
surface->committed(surface, state->sx, state->sy);
if (surface->committed) {
struct weston_coord_surface new_origin;
new_origin = weston_coord_surface(state->sx,
state->sy,
surface);
surface->committed(surface, new_origin);
}
}
state->sx = 0;
@ -4526,15 +4533,18 @@ subsurface_get_label(struct weston_surface *surface, char *buf, size_t len)
}
static void
subsurface_committed(struct weston_surface *surface, int32_t dx, int32_t dy)
subsurface_committed(struct weston_surface *surface,
struct weston_coord_surface new_origin)
{
struct weston_view *view;
wl_list_for_each(view, &surface->views, surface_link)
weston_view_set_rel_position(view,
view->geometry.pos_offset.x + dx,
view->geometry.pos_offset.y + dy);
wl_list_for_each(view, &surface->views, surface_link) {
struct weston_coord_surface tmp = new_origin;
tmp.c = weston_coord_add(tmp.c,
view->geometry.pos_offset);
weston_view_set_rel_position(view, tmp.c.x, tmp.c.y);
}
/* No need to check parent mappedness, because if parent is not
* mapped, parent is not in a visible layer, so this sub-surface
* will not be drawn either.

View File

@ -412,7 +412,7 @@ drag_surface_configure(struct weston_drag *drag,
struct weston_pointer *pointer,
struct weston_touch *touch,
struct weston_surface *es,
int32_t sx, int32_t sy)
struct weston_coord_surface new_origin)
{
struct weston_layer_entry *list;
float fx, fy;
@ -435,8 +435,9 @@ drag_surface_configure(struct weston_drag *drag,
drag->icon->is_mapped = true;
}
drag->offset.c.x += sx;
drag->offset.c.y += sy;
assert(drag->offset.coordinate_space_id &&
drag->offset.coordinate_space_id == new_origin.coordinate_space_id);
drag->offset.c = weston_coord_add(drag->offset.c, new_origin.c);
/* init to 0 for avoiding a compile warning */
fx = fy = 0;
@ -459,14 +460,14 @@ pointer_drag_surface_get_label(struct weston_surface *surface,
static void
pointer_drag_surface_committed(struct weston_surface *es,
int32_t sx, int32_t sy)
struct weston_coord_surface new_origin)
{
struct weston_pointer_drag *drag = es->committed_private;
struct weston_pointer *pointer = drag->grab.pointer;
assert(es->committed == pointer_drag_surface_committed);
drag_surface_configure(&drag->base, pointer, NULL, es, sx, sy);
drag_surface_configure(&drag->base, pointer, NULL, es, new_origin);
}
static int
@ -477,14 +478,15 @@ touch_drag_surface_get_label(struct weston_surface *surface,
}
static void
touch_drag_surface_committed(struct weston_surface *es, int32_t sx, int32_t sy)
touch_drag_surface_committed(struct weston_surface *es,
struct weston_coord_surface new_origin)
{
struct weston_touch_drag *drag = es->committed_private;
struct weston_touch *touch = drag->grab.touch;
assert(es->committed == touch_drag_surface_committed);
drag_surface_configure(&drag->base, NULL, touch, es, sx, sy);
drag_surface_configure(&drag->base, NULL, touch, es, new_origin);
}
static void

View File

@ -224,12 +224,12 @@ weston_desktop_surface_resource_destroy(struct wl_resource *resource)
static void
weston_desktop_surface_committed(struct weston_surface *wsurface,
int32_t sx, int32_t sy)
struct weston_coord_surface new_origin)
{
struct weston_desktop_surface *surface = wsurface->committed_private;
surface->buffer_move.x = sx;
surface->buffer_move.y = sy;
surface->buffer_move.x = new_origin.c.x;
surface->buffer_move.y = new_origin.c.y;
}
static void

View File

@ -2691,23 +2691,21 @@ pointer_cursor_surface_get_label(struct weston_surface *surface,
static void
pointer_cursor_surface_committed(struct weston_surface *es,
int32_t dx, int32_t dy)
struct weston_coord_surface new_origin)
{
struct weston_pointer *pointer = es->committed_private;
int x, y;
struct weston_coord_global pos;
if (es->width == 0)
return;
assert(es == pointer->sprite->surface);
pointer->hotspot.c.x -= dx;
pointer->hotspot.c.y -= dy;
pointer->hotspot.c = weston_coord_sub(pointer->hotspot.c,
new_origin.c);
pos.c = weston_coord_sub(pointer->pos.c, pointer->hotspot.c);
x = pointer->pos.c.x - pointer->hotspot.c.x;
y = pointer->pos.c.y - pointer->hotspot.c.y;
weston_view_set_position(pointer->sprite, x, y);
weston_view_set_position(pointer->sprite, pos.c.x, pos.c.y);
empty_region(&es->pending.input);
empty_region(&es->input);
@ -2779,7 +2777,10 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
pointer->hotspot.c = weston_coord(x, y);
if (surface->width != 0) {
pointer_cursor_surface_committed(surface, 0, 0);
struct weston_coord_surface zero;
zero = weston_coord_surface(0, 0, surface);
pointer_cursor_surface_committed(surface, zero);
weston_view_schedule_repaint(pointer->sprite);
}
}

View File

@ -152,7 +152,8 @@ notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
}
static void
test_surface_committed(struct weston_surface *surface, int32_t sx, int32_t sy)
test_surface_committed(struct weston_surface *surface,
struct weston_coord_surface new_origin)
{
struct weston_test_surface *test_surface = surface->committed_private;
struct weston_test *test = test_surface->test;