mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-10-01 19:38:34 +00:00
libweston: use weston_coord for weston_view_set_position
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
fff8dbd9b8
commit
244dc963b9
|
@ -84,6 +84,7 @@ show_input_panel_surface(struct input_panel_surface *ipsurf)
|
|||
struct desktop_shell *shell = ipsurf->shell;
|
||||
struct weston_seat *seat;
|
||||
struct weston_surface *focus;
|
||||
struct weston_coord_global pos;
|
||||
float x, y;
|
||||
|
||||
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
|
||||
|
@ -98,7 +99,8 @@ show_input_panel_surface(struct input_panel_surface *ipsurf)
|
|||
ipsurf->output = focus->output;
|
||||
if (calc_input_panel_position(ipsurf, &x, &y))
|
||||
continue;
|
||||
weston_view_set_position(ipsurf->view, x, y);
|
||||
pos.c = weston_coord(x, y);
|
||||
weston_view_set_position(ipsurf->view, pos);
|
||||
}
|
||||
|
||||
weston_layer_entry_insert(&shell->input_panel_layer.view_list,
|
||||
|
@ -190,6 +192,7 @@ input_panel_committed(struct weston_surface *surface,
|
|||
{
|
||||
struct input_panel_surface *ip_surface = surface->committed_private;
|
||||
struct desktop_shell *shell = ip_surface->shell;
|
||||
struct weston_coord_global pos;
|
||||
float x, y;
|
||||
|
||||
if (surface->width == 0)
|
||||
|
@ -197,7 +200,8 @@ input_panel_committed(struct weston_surface *surface,
|
|||
|
||||
if (calc_input_panel_position(ip_surface, &x, &y))
|
||||
return;
|
||||
weston_view_set_position(ip_surface->view, x, y);
|
||||
pos.c = weston_coord(x, y);
|
||||
weston_view_set_position(ip_surface->view, pos);
|
||||
|
||||
if (!weston_surface_is_mapped(surface) && shell->showing_input_panels)
|
||||
show_input_panel_surface(ip_surface);
|
||||
|
|
|
@ -975,13 +975,15 @@ touch_move_grab_motion(struct weston_touch_grab *grab,
|
|||
struct weston_surface *es;
|
||||
int dx = wl_fixed_to_int(grab->touch->grab_x + move->dx);
|
||||
int dy = wl_fixed_to_int(grab->touch->grab_y + move->dy);
|
||||
struct weston_coord_global pos;
|
||||
|
||||
if (!shsurf || !shsurf->desktop_surface || !move->active)
|
||||
return;
|
||||
|
||||
es = weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
||||
|
||||
weston_view_set_position(shsurf->view, dx, dy);
|
||||
pos.c = weston_coord(dx, dy);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
|
||||
weston_compositor_schedule_repaint(es->compositor);
|
||||
}
|
||||
|
@ -1105,6 +1107,7 @@ move_grab_motion(struct weston_pointer_grab *grab,
|
|||
struct weston_pointer *pointer = grab->pointer;
|
||||
struct shell_surface *shsurf = move->base.shsurf;
|
||||
struct weston_surface *surface;
|
||||
struct weston_coord_global pos;
|
||||
int cx, cy;
|
||||
|
||||
weston_pointer_move(pointer, event);
|
||||
|
@ -1115,7 +1118,8 @@ move_grab_motion(struct weston_pointer_grab *grab,
|
|||
|
||||
constrain_position(move, &cx, &cy);
|
||||
|
||||
weston_view_set_position(shsurf->view, cx, cy);
|
||||
pos.c = weston_coord(cx, cy);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
|
||||
weston_compositor_schedule_repaint(surface->compositor);
|
||||
}
|
||||
|
@ -1247,9 +1251,9 @@ tablet_tool_move_grab_motion(struct weston_tablet_tool_grab *grab,
|
|||
return;
|
||||
|
||||
es = weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
||||
weston_view_set_position(shsurf->view,
|
||||
pos.c.x + wl_fixed_to_double(move->dx),
|
||||
pos.c.y + wl_fixed_to_double(move->dy));
|
||||
pos.c.x += wl_fixed_to_double(move->dx);
|
||||
pos.c.y += wl_fixed_to_double(move->dy);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
weston_compositor_schedule_repaint(es->compositor);
|
||||
}
|
||||
|
||||
|
@ -1782,9 +1786,7 @@ unset_fullscreen(struct shell_surface *shsurf)
|
|||
shsurf->fullscreen.black_view = NULL;
|
||||
|
||||
if (shsurf->saved_position_valid)
|
||||
weston_view_set_position(shsurf->view,
|
||||
shsurf->saved_pos.c.x,
|
||||
shsurf->saved_pos.c.y);
|
||||
weston_view_set_position(shsurf->view, shsurf->saved_pos);
|
||||
else
|
||||
weston_view_set_initial_position(shsurf->view, shsurf->shell);
|
||||
shsurf->saved_position_valid = false;
|
||||
|
@ -1810,9 +1812,7 @@ unset_maximized(struct shell_surface *shsurf)
|
|||
weston_shell_utils_get_default_output(surface->compositor));
|
||||
|
||||
if (shsurf->saved_position_valid)
|
||||
weston_view_set_position(shsurf->view,
|
||||
shsurf->saved_pos.c.x,
|
||||
shsurf->saved_pos.c.y);
|
||||
weston_view_set_position(shsurf->view, shsurf->saved_pos);
|
||||
else
|
||||
weston_view_set_initial_position(shsurf->view, shsurf->shell);
|
||||
shsurf->saved_position_valid = false;
|
||||
|
@ -1965,9 +1965,12 @@ shell_configure_fullscreen(struct shell_surface *shsurf)
|
|||
&shsurf->view->layer_link);
|
||||
|
||||
if (!shsurf->fullscreen_output) {
|
||||
struct weston_coord_global pos;
|
||||
|
||||
/* If there is no output, there's not much we can do.
|
||||
* Position the window somewhere, whatever. */
|
||||
weston_view_set_position(shsurf->view, 0, 0);
|
||||
pos.c = weston_coord(0, 0);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2259,6 +2262,8 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
|
|||
|
||||
if (shsurf->shell->compositor->state == WESTON_COMPOSITOR_ACTIVE &&
|
||||
shsurf->view->output->power_state == WESTON_OUTPUT_POWER_NORMAL) {
|
||||
struct weston_coord_global pos;
|
||||
|
||||
pixman_region32_fini(&surface->pending.input);
|
||||
pixman_region32_init(&surface->pending.input);
|
||||
pixman_region32_fini(&surface->input);
|
||||
|
@ -2270,9 +2275,8 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
|
|||
* the view */
|
||||
weston_view_set_output(shsurf->wview_anim_fade,
|
||||
shsurf->view->output);
|
||||
weston_view_set_position(shsurf->wview_anim_fade,
|
||||
shsurf->view->geometry.pos_offset.x,
|
||||
shsurf->view->geometry.pos_offset.y);
|
||||
pos.c = shsurf->view->geometry.pos_offset;
|
||||
weston_view_set_position(shsurf->wview_anim_fade, pos);
|
||||
|
||||
weston_layer_entry_insert(&shsurf->view->layer_link,
|
||||
&shsurf->wview_anim_fade->layer_link);
|
||||
|
@ -2295,29 +2299,29 @@ set_maximized_position(struct desktop_shell *shell,
|
|||
{
|
||||
pixman_rectangle32_t area;
|
||||
struct weston_geometry geometry;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
get_output_work_area(shell, shsurf->output, &area);
|
||||
geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
|
||||
|
||||
weston_view_set_position(shsurf->view,
|
||||
area.x - geometry.x,
|
||||
area.y - geometry.y);
|
||||
pos.c = weston_coord(area.x - geometry.x,
|
||||
area.y - geometry.y);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
}
|
||||
|
||||
static void
|
||||
set_position_from_xwayland(struct shell_surface *shsurf)
|
||||
{
|
||||
struct weston_geometry geometry;
|
||||
float x;
|
||||
float y;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
assert(shsurf->xwayland.is_set);
|
||||
|
||||
geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
|
||||
x = shsurf->xwayland.x - geometry.x;
|
||||
y = shsurf->xwayland.y - geometry.y;
|
||||
pos.c = weston_coord(shsurf->xwayland.x - geometry.x,
|
||||
shsurf->xwayland.y - geometry.y);
|
||||
|
||||
weston_view_set_position(shsurf->view, x, y);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
|
||||
#ifdef WM_DEBUG
|
||||
weston_log("%s: XWM %d, %d; geometry %d, %d; view %f, %f\n",
|
||||
|
@ -2491,7 +2495,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
|||
offset.c = weston_coord_sub(to_g.c, from_g.c);
|
||||
pos.c = weston_coord_add(view->geometry.pos_offset, offset.c);
|
||||
|
||||
weston_view_set_position(shsurf->view, pos.c.x, pos.c.y);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
}
|
||||
|
||||
shsurf->last_width = surface->width;
|
||||
|
@ -2857,6 +2861,7 @@ static void
|
|||
configure_static_view(struct weston_view *ev, struct weston_layer *layer, int x, int y)
|
||||
{
|
||||
struct weston_view *v, *next;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
if (!ev->output)
|
||||
return;
|
||||
|
@ -2869,7 +2874,8 @@ configure_static_view(struct weston_view *ev, struct weston_layer *layer, int x,
|
|||
}
|
||||
}
|
||||
|
||||
weston_view_set_position(ev, ev->output->x + x, ev->output->y + y);
|
||||
pos.c = weston_coord(ev->output->x + x, ev->output->y + y);
|
||||
weston_view_set_position(ev, pos);
|
||||
weston_surface_map(ev->surface);
|
||||
ev->is_mapped = true;
|
||||
|
||||
|
@ -3306,6 +3312,7 @@ set_tiled_orientation(struct weston_surface *focus,
|
|||
int width, height;
|
||||
pixman_rectangle32_t area;
|
||||
struct weston_geometry geom;
|
||||
struct weston_coord_global pos;
|
||||
int x, y;
|
||||
|
||||
surface = weston_surface_get_main_surface(focus);
|
||||
|
@ -3336,7 +3343,8 @@ set_tiled_orientation(struct weston_surface *focus,
|
|||
else if (orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM)
|
||||
y += height;
|
||||
|
||||
weston_view_set_position(shsurf->view, x, y);
|
||||
pos.c = weston_coord(x, y);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
weston_desktop_surface_set_size(shsurf->desktop_surface, width, height);
|
||||
weston_desktop_surface_set_orientation(shsurf->desktop_surface, orientation);
|
||||
weston_compositor_schedule_repaint(surface->compositor);
|
||||
|
@ -3544,9 +3552,12 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
|
|||
dposx = rotate->center.x - cposx;
|
||||
dposy = rotate->center.y - cposy;
|
||||
if (dposx != 0.0f || dposy != 0.0f) {
|
||||
weston_view_set_position(shsurf->view,
|
||||
shsurf->view->geometry.pos_offset.x + dposx,
|
||||
shsurf->view->geometry.pos_offset.y + dposy);
|
||||
struct weston_coord_global pos;
|
||||
|
||||
pos.c = shsurf->view->geometry.pos_offset;
|
||||
pos.c.x += dposx;
|
||||
pos.c.y += dposy;
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
}
|
||||
|
||||
/* Repaint implies weston_view_update_transform(), which
|
||||
|
@ -4003,6 +4014,7 @@ shell_fade_create_fade_out_view(struct shell_surface *shsurf,
|
|||
{
|
||||
struct weston_view *view;
|
||||
struct weston_output *woutput;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
view = weston_view_create(surface);
|
||||
if (!view)
|
||||
|
@ -4012,9 +4024,8 @@ shell_fade_create_fade_out_view(struct shell_surface *shsurf,
|
|||
/* set the initial position and output just in case we happen to not
|
||||
* move it around and just destroy it */
|
||||
weston_view_set_output(view, woutput);
|
||||
weston_view_set_position(view,
|
||||
shsurf->view->geometry.pos_offset.x,
|
||||
shsurf->view->geometry.pos_offset.y);
|
||||
pos.c = shsurf->view->geometry.pos_offset;
|
||||
weston_view_set_position(view, pos);
|
||||
view->is_mapped = true;
|
||||
|
||||
return view;
|
||||
|
@ -4223,6 +4234,7 @@ weston_view_set_initial_position(struct weston_view *view,
|
|||
struct weston_output *output, *target_output = NULL;
|
||||
struct weston_seat *seat;
|
||||
pixman_rectangle32_t area;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
/* As a heuristic place the new window on the same output as the
|
||||
* pointer. Falling back to the output containing 0, 0.
|
||||
|
@ -4247,8 +4259,9 @@ weston_view_set_initial_position(struct weston_view *view,
|
|||
}
|
||||
|
||||
if (!target_output) {
|
||||
weston_view_set_position(view, 10 + random() % 400,
|
||||
10 + random() % 400);
|
||||
pos.c = weston_coord(10 + random() % 400,
|
||||
10 + random() % 400);
|
||||
weston_view_set_position(view, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4269,7 +4282,8 @@ weston_view_set_initial_position(struct weston_view *view,
|
|||
if (range_y > 0)
|
||||
y += random() % range_y;
|
||||
|
||||
weston_view_set_position(view, x, y);
|
||||
pos.c = weston_coord(x, y);
|
||||
weston_view_set_position(view, pos);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -4666,13 +4680,16 @@ shell_reposition_view_on_output_change(struct weston_view *view)
|
|||
return;
|
||||
|
||||
if (!visible) {
|
||||
struct weston_coord_global pos;
|
||||
|
||||
first_output = container_of(ec->output_list.next,
|
||||
struct weston_output, link);
|
||||
|
||||
x = first_output->x + first_output->width / 4;
|
||||
y = first_output->y + first_output->height / 4;
|
||||
pos.c = weston_coord(first_output->x, first_output->y);
|
||||
pos.c.x += first_output->width / 4;
|
||||
pos.c.y += first_output->height / 4;
|
||||
|
||||
weston_view_set_position(view, x, y);
|
||||
weston_view_set_position(view, pos);
|
||||
} else {
|
||||
weston_view_geometry_dirty(view);
|
||||
|
||||
|
@ -4812,15 +4829,16 @@ handle_output_move_layer(struct desktop_shell *shell,
|
|||
{
|
||||
struct weston_output *output = data;
|
||||
struct weston_view *view;
|
||||
float x, y;
|
||||
|
||||
wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
|
||||
struct weston_coord_global pos;
|
||||
|
||||
if (view->output != output)
|
||||
continue;
|
||||
|
||||
x = view->geometry.pos_offset.x + output->move_x;
|
||||
y = view->geometry.pos_offset.y + output->move_y;
|
||||
weston_view_set_position(view, x, y);
|
||||
pos.c = weston_coord(output->move_x, output->move_y);
|
||||
pos.c = weston_coord_add(view->geometry.pos_offset, pos.c);
|
||||
weston_view_set_position(view, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,6 @@ restore_output_mode(struct weston_output *output)
|
|||
static void
|
||||
fs_output_scale_view(struct fs_output *fsout, float width, float height)
|
||||
{
|
||||
float x, y;
|
||||
int32_t surf_x, surf_y, surf_width, surf_height;
|
||||
struct weston_matrix *matrix;
|
||||
struct weston_view *view = fsout->view;
|
||||
|
@ -375,10 +374,15 @@ fs_output_scale_view(struct fs_output *fsout, float width, float height)
|
|||
&surf_width, &surf_height);
|
||||
|
||||
if (output->width == surf_width && output->height == surf_height) {
|
||||
weston_view_set_position(view,
|
||||
fsout->output->x - surf_x,
|
||||
fsout->output->y - surf_y);
|
||||
struct weston_coord_global pos;
|
||||
|
||||
pos.c = weston_coord(fsout->output->x, fsout->output->y);
|
||||
pos.c.x -= surf_x;
|
||||
pos.c.y -= surf_y;
|
||||
weston_view_set_position(view, pos);
|
||||
} else {
|
||||
struct weston_coord_global pos;
|
||||
|
||||
matrix = &fsout->transform.matrix;
|
||||
weston_matrix_init(matrix);
|
||||
|
||||
|
@ -388,10 +392,11 @@ fs_output_scale_view(struct fs_output *fsout, float width, float height)
|
|||
wl_list_insert(&fsout->view->geometry.transformation_list,
|
||||
&fsout->transform.link);
|
||||
|
||||
x = output->x + (output->width - width) / 2 - surf_x;
|
||||
y = output->y + (output->height - height) / 2 - surf_y;
|
||||
pos.c = weston_coord(output->x, output->y);
|
||||
pos.c.x += (output->width - width) / 2 - surf_x;
|
||||
pos.c.y += (output->height - height) / 2 - surf_y;
|
||||
|
||||
weston_view_set_position(view, x, y);
|
||||
weston_view_set_position(view, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,6 +410,7 @@ fs_output_configure_simple(struct fs_output *fsout,
|
|||
struct weston_output *output = fsout->output;
|
||||
float output_aspect, surface_aspect;
|
||||
int32_t surf_x, surf_y, surf_width, surf_height;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
if (fsout->pending.surface == configured_surface)
|
||||
fs_output_apply_pending(fsout);
|
||||
|
@ -458,9 +464,10 @@ fs_output_configure_simple(struct fs_output *fsout,
|
|||
break;
|
||||
}
|
||||
|
||||
weston_view_set_position(fsout->curtain->view,
|
||||
fsout->output->x - surf_x,
|
||||
fsout->output->y - surf_y);
|
||||
pos.c = weston_coord(fsout->output->x, fsout->output->y);
|
||||
pos.c.x -= surf_x;
|
||||
pos.c.y -= surf_y;
|
||||
weston_view_set_position(fsout->curtain->view, pos);
|
||||
weston_surface_set_size(fsout->curtain->view->surface,
|
||||
fsout->output->width,
|
||||
fsout->output->height);
|
||||
|
@ -472,6 +479,7 @@ fs_output_configure_for_mode(struct fs_output *fsout,
|
|||
{
|
||||
int32_t surf_x, surf_y, surf_width, surf_height;
|
||||
struct weston_mode mode;
|
||||
struct weston_coord_global pos;
|
||||
int ret;
|
||||
|
||||
if (fsout->pending.surface != configured_surface) {
|
||||
|
@ -536,9 +544,10 @@ fs_output_configure_for_mode(struct fs_output *fsout,
|
|||
|
||||
fs_output_apply_pending(fsout);
|
||||
|
||||
weston_view_set_position(fsout->view,
|
||||
fsout->output->x - surf_x,
|
||||
fsout->output->y - surf_y);
|
||||
pos.c = weston_coord(fsout->output->x, fsout->output->y);
|
||||
pos.c.x -= surf_x;
|
||||
pos.c.y -= surf_y;
|
||||
weston_view_set_position(fsout->view, pos);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -2151,11 +2151,11 @@ weston_view_destroy(struct weston_view *view);
|
|||
|
||||
void
|
||||
weston_view_set_rel_position(struct weston_view *view,
|
||||
float x, float y);
|
||||
struct weston_coord_surface offset);
|
||||
|
||||
void
|
||||
weston_view_set_position(struct weston_view *view,
|
||||
float x, float y);
|
||||
struct weston_coord_global pos);
|
||||
|
||||
void
|
||||
weston_view_set_transform_parent(struct weston_view *view,
|
||||
|
|
|
@ -76,7 +76,7 @@ pointer_move_grab_motion(struct weston_pointer_grab *pointer_grab,
|
|||
struct weston_pointer *pointer = pointer_grab->pointer;
|
||||
struct kiosk_shell_surface *shsurf = shgrab->shsurf;
|
||||
struct weston_surface *surface;
|
||||
int dx, dy;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
weston_pointer_move(pointer, event);
|
||||
|
||||
|
@ -85,10 +85,11 @@ pointer_move_grab_motion(struct weston_pointer_grab *pointer_grab,
|
|||
|
||||
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
||||
|
||||
dx = pointer->pos.c.x + wl_fixed_to_double(shgrab->dx);
|
||||
dy = pointer->pos.c.y + wl_fixed_to_double(shgrab->dy);
|
||||
pos = pointer->pos;
|
||||
pos.c.x += wl_fixed_to_double(shgrab->dx);
|
||||
pos.c.y += wl_fixed_to_double(shgrab->dy);
|
||||
|
||||
weston_view_set_position(shsurf->view, dx, dy);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
|
||||
weston_compositor_schedule_repaint(surface->compositor);
|
||||
}
|
||||
|
@ -162,6 +163,7 @@ touch_move_grab_motion(struct weston_touch_grab *touch_grab,
|
|||
struct weston_touch *touch = touch_grab->touch;
|
||||
struct kiosk_shell_surface *shsurf = shgrab->shsurf;
|
||||
struct weston_surface *surface;
|
||||
struct weston_coord_global pos;
|
||||
int dx, dy;
|
||||
|
||||
if (!shsurf || !shgrab->active)
|
||||
|
@ -172,7 +174,8 @@ touch_move_grab_motion(struct weston_touch_grab *touch_grab,
|
|||
dx = wl_fixed_to_int(touch->grab_x + shgrab->dx);
|
||||
dy = wl_fixed_to_int(touch->grab_y + shgrab->dy);
|
||||
|
||||
weston_view_set_position(shsurf->view, dx, dy);
|
||||
pos.c = weston_coord(dx, dy);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
|
||||
weston_compositor_schedule_repaint(surface->compositor);
|
||||
}
|
||||
|
|
|
@ -781,12 +781,14 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
|||
weston_shell_utils_center_on_output(shsurf->view,
|
||||
shsurf->output);
|
||||
} else {
|
||||
struct weston_coord_global tmp;
|
||||
struct weston_geometry geometry =
|
||||
weston_desktop_surface_get_geometry(desktop_surface);
|
||||
float x = shsurf->xwayland.x - geometry.x;
|
||||
float y = shsurf->xwayland.y - geometry.y;
|
||||
|
||||
weston_view_set_position(shsurf->view, x, y);
|
||||
tmp.c = weston_coord(x, y);
|
||||
weston_view_set_position(shsurf->view, tmp);
|
||||
}
|
||||
|
||||
weston_view_update_transform(shsurf->view);
|
||||
|
@ -822,7 +824,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
|||
pos.c = weston_coord_add(shsurf->view->geometry.pos_offset,
|
||||
offset.c);
|
||||
|
||||
weston_view_set_position(shsurf->view, pos.c.x, pos.c.y);
|
||||
weston_view_set_position(shsurf->view, pos);
|
||||
weston_view_update_transform(shsurf->view);
|
||||
}
|
||||
|
||||
|
@ -1128,23 +1130,26 @@ kiosk_shell_handle_output_moved(struct wl_listener *listener, void *data)
|
|||
container_of(listener, struct kiosk_shell, output_moved_listener);
|
||||
struct weston_output *output = data;
|
||||
struct weston_view *view;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
wl_list_for_each(view, &shell->background_layer.view_list.link,
|
||||
layer_link.link) {
|
||||
if (view->output != output)
|
||||
continue;
|
||||
weston_view_set_position(view,
|
||||
view->geometry.pos_offset.x + output->move_x,
|
||||
view->geometry.pos_offset.y + output->move_y);
|
||||
pos.c = view->geometry.pos_offset;
|
||||
pos.c.x += output->move_x;
|
||||
pos.c.y += output->move_y;
|
||||
weston_view_set_position(view, pos);
|
||||
}
|
||||
|
||||
wl_list_for_each(view, &shell->normal_layer.view_list.link,
|
||||
layer_link.link) {
|
||||
if (view->output != output)
|
||||
continue;
|
||||
weston_view_set_position(view,
|
||||
view->geometry.pos_offset.x + output->move_x,
|
||||
view->geometry.pos_offset.y + output->move_y);
|
||||
pos.c = view->geometry.pos_offset;
|
||||
pos.c.x += output->move_x;
|
||||
pos.c.x += output->move_y;
|
||||
weston_view_set_position(view, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1584,29 +1584,32 @@ weston_surface_damage(struct weston_surface *surface)
|
|||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_view_set_rel_position(struct weston_view *view, float x, float y)
|
||||
weston_view_set_rel_position(struct weston_view *view,
|
||||
struct weston_coord_surface offset)
|
||||
{
|
||||
assert(view->geometry.parent);
|
||||
assert(offset.coordinate_space_id == view->geometry.parent->surface);
|
||||
|
||||
if (view->geometry.pos_offset.x == x &&
|
||||
view->geometry.pos_offset.y == y)
|
||||
if (view->geometry.pos_offset.x == offset.c.x &&
|
||||
view->geometry.pos_offset.y == offset.c.y)
|
||||
return;
|
||||
|
||||
view->geometry.pos_offset = weston_coord(x, y);
|
||||
view->geometry.pos_offset = offset.c;
|
||||
weston_view_geometry_dirty(view);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_view_set_position(struct weston_view *view, float x, float y)
|
||||
weston_view_set_position(struct weston_view *view,
|
||||
struct weston_coord_global pos)
|
||||
{
|
||||
assert(view->surface->committed != subsurface_committed);
|
||||
assert(!view->geometry.parent);
|
||||
|
||||
if (view->geometry.pos_offset.x == x &&
|
||||
view->geometry.pos_offset.y == y)
|
||||
if (view->geometry.pos_offset.x == pos.c.x &&
|
||||
view->geometry.pos_offset.y == pos.c.y)
|
||||
return;
|
||||
|
||||
view->geometry.pos_offset = weston_coord(x, y);
|
||||
view->geometry.pos_offset = pos.c;
|
||||
weston_view_geometry_dirty(view);
|
||||
}
|
||||
|
||||
|
@ -2901,9 +2904,7 @@ view_list_add_subsurface_view(struct weston_compositor *compositor,
|
|||
} else {
|
||||
view = weston_view_create(sub->surface);
|
||||
weston_view_set_transform_parent(view, parent);
|
||||
weston_view_set_rel_position(view,
|
||||
sub->position.offset.c.x,
|
||||
sub->position.offset.c.y);
|
||||
weston_view_set_rel_position(view, sub->position.offset);
|
||||
}
|
||||
|
||||
view->parent_view = parent;
|
||||
|
@ -4524,8 +4525,7 @@ weston_subsurface_parent_commit(struct weston_subsurface *sub,
|
|||
if (sub->position.changed) {
|
||||
wl_list_for_each(view, &sub->surface->views, surface_link)
|
||||
weston_view_set_rel_position(view,
|
||||
sub->position.offset.c.x,
|
||||
sub->position.offset.c.y);
|
||||
sub->position.offset);
|
||||
|
||||
sub->position.changed = false;
|
||||
}
|
||||
|
@ -4546,8 +4546,10 @@ subsurface_committed(struct weston_surface *surface,
|
|||
{
|
||||
struct weston_view *view;
|
||||
|
||||
assert(new_origin.coordinate_space_id == surface);
|
||||
|
||||
wl_list_for_each(view, &surface->views, surface_link) {
|
||||
struct weston_coord_surface tmp = new_origin;
|
||||
struct weston_coord_surface tmp;
|
||||
|
||||
if (!view->geometry.parent) {
|
||||
weston_log_paced(&view->subsurface_parent_log_pacer,
|
||||
|
@ -4556,9 +4558,11 @@ subsurface_committed(struct weston_surface *surface,
|
|||
continue;
|
||||
}
|
||||
|
||||
tmp.c = weston_coord_add(tmp.c,
|
||||
view->geometry.pos_offset);
|
||||
weston_view_set_rel_position(view, tmp.c.x, tmp.c.y);
|
||||
tmp = weston_coord_surface(view->geometry.pos_offset.x,
|
||||
view->geometry.pos_offset.y,
|
||||
view->geometry.parent->surface);
|
||||
tmp.c = weston_coord_add(tmp.c, new_origin.c);
|
||||
weston_view_set_rel_position(view, tmp);
|
||||
}
|
||||
/* No need to check parent mappedness, because if parent is not
|
||||
* mapped, parent is not in a visible layer, so this sub-surface
|
||||
|
@ -4788,7 +4792,9 @@ subsurface_set_position(struct wl_client *client,
|
|||
if (!sub)
|
||||
return;
|
||||
|
||||
sub->position.offset = weston_coord_surface(x, y, sub->surface);
|
||||
assert(sub->parent);
|
||||
|
||||
sub->position.offset = weston_coord_surface(x, y, sub->parent);
|
||||
sub->position.changed = true;
|
||||
}
|
||||
|
||||
|
@ -5048,7 +5054,7 @@ weston_subsurface_create(uint32_t id, struct weston_surface *surface,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
sub->position.offset = weston_coord_surface(0, 0, surface);
|
||||
sub->position.offset = weston_coord_surface(0, 0, parent);
|
||||
|
||||
wl_resource_set_implementation(sub->resource,
|
||||
&subsurface_implementation,
|
||||
|
|
|
@ -415,7 +415,7 @@ drag_surface_configure(struct weston_drag *drag,
|
|||
struct weston_coord_surface new_origin)
|
||||
{
|
||||
struct weston_layer_entry *list;
|
||||
float fx, fy;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
assert((pointer != NULL && touch == NULL) ||
|
||||
(pointer == NULL && touch != NULL));
|
||||
|
@ -440,15 +440,14 @@ drag_surface_configure(struct weston_drag *drag,
|
|||
drag->offset.c = weston_coord_add(drag->offset.c, new_origin.c);
|
||||
|
||||
/* init to 0 for avoiding a compile warning */
|
||||
fx = fy = 0;
|
||||
if (pointer) {
|
||||
fx = pointer->pos.c.x + drag->offset.c.x;
|
||||
fy = pointer->pos.c.y + drag->offset.c.y;
|
||||
} else if (touch) {
|
||||
fx = wl_fixed_to_double(touch->grab_x) + drag->offset.c.x;
|
||||
fy = wl_fixed_to_double(touch->grab_y) + drag->offset.c.y;
|
||||
}
|
||||
weston_view_set_position(drag->icon, fx, fy);
|
||||
pos.c = weston_coord(0, 0);
|
||||
if (pointer)
|
||||
pos = pointer->pos;
|
||||
else if (touch)
|
||||
pos.c = weston_coord_from_fixed(touch->grab_x, touch->grab_y);
|
||||
|
||||
pos.c = weston_coord_add(pos.c, drag->offset.c);
|
||||
weston_view_set_position(drag->icon, pos);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -617,15 +616,15 @@ drag_grab_motion(struct weston_pointer_grab *grab,
|
|||
struct weston_pointer_drag *drag =
|
||||
container_of(grab, struct weston_pointer_drag, grab);
|
||||
struct weston_pointer *pointer = drag->grab.pointer;
|
||||
float fx, fy;
|
||||
uint32_t msecs;
|
||||
|
||||
weston_pointer_move(pointer, event);
|
||||
|
||||
if (drag->base.icon) {
|
||||
fx = pointer->pos.c.x + drag->base.offset.c.x;
|
||||
fy = pointer->pos.c.y + drag->base.offset.c.y;
|
||||
weston_view_set_position(drag->base.icon, fx, fy);
|
||||
struct weston_coord_global pos;
|
||||
|
||||
pos.c = weston_coord_add(pointer->pos.c, drag->base.offset.c);
|
||||
weston_view_set_position(drag->base.icon, pos);
|
||||
weston_view_schedule_repaint(drag->base.icon);
|
||||
}
|
||||
|
||||
|
@ -812,7 +811,6 @@ drag_grab_touch_motion(struct weston_touch_grab *grab,
|
|||
struct weston_touch_drag *touch_drag =
|
||||
container_of(grab, struct weston_touch_drag, grab);
|
||||
struct weston_touch *touch = grab->touch;
|
||||
float fx, fy;
|
||||
uint32_t msecs;
|
||||
|
||||
if (touch_id != touch->grab_touch_id)
|
||||
|
@ -820,11 +818,11 @@ drag_grab_touch_motion(struct weston_touch_grab *grab,
|
|||
|
||||
drag_grab_touch_focus(touch_drag);
|
||||
if (touch_drag->base.icon) {
|
||||
fx = wl_fixed_to_double(touch->grab_x) +
|
||||
touch_drag->base.offset.c.x;
|
||||
fy = wl_fixed_to_double(touch->grab_y) +
|
||||
touch_drag->base.offset.c.y;
|
||||
weston_view_set_position(touch_drag->base.icon, fx, fy);
|
||||
struct weston_coord_global pos;
|
||||
|
||||
pos.c = weston_coord_from_fixed(touch->grab_x, touch->grab_y);
|
||||
pos.c = weston_coord_add(pos.c, touch_drag->base.offset.c);
|
||||
weston_view_set_position(touch_drag->base.icon, pos);
|
||||
weston_view_schedule_repaint(touch_drag->base.icon);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,27 +81,35 @@ static void
|
|||
weston_desktop_surface_update_view_position(struct weston_desktop_surface *surface)
|
||||
{
|
||||
struct weston_desktop_view *view;
|
||||
int32_t x, y;
|
||||
|
||||
x = surface->position.x;
|
||||
y = surface->position.y;
|
||||
|
||||
if (surface->use_geometry) {
|
||||
struct weston_desktop_surface *parent =
|
||||
weston_desktop_surface_get_parent(surface);
|
||||
struct weston_geometry geometry, parent_geometry;
|
||||
struct weston_coord offset;
|
||||
|
||||
offset = weston_coord(surface->position.x, surface->position.y);
|
||||
|
||||
geometry = weston_desktop_surface_get_geometry(surface);
|
||||
parent_geometry = weston_desktop_surface_get_geometry(parent);
|
||||
|
||||
x += parent_geometry.x - geometry.x;
|
||||
y += parent_geometry.y - geometry.y;
|
||||
offset.x += parent_geometry.x - geometry.x;
|
||||
offset.y += parent_geometry.y - geometry.y;
|
||||
wl_list_for_each(view, &surface->view_list, link) {
|
||||
struct weston_view *wv = view->view;
|
||||
struct weston_coord_surface surf_offset;
|
||||
|
||||
surf_offset.c = offset;
|
||||
surf_offset.coordinate_space_id = wv->geometry.parent->surface;
|
||||
weston_view_set_rel_position(wv, surf_offset);
|
||||
}
|
||||
} else {
|
||||
struct weston_coord_global pos;
|
||||
|
||||
pos.c = weston_coord(surface->position.x, surface->position.y);
|
||||
|
||||
wl_list_for_each(view, &surface->view_list, link)
|
||||
weston_view_set_rel_position(view->view, x, y);
|
||||
} else {
|
||||
wl_list_for_each(view, &surface->view_list, link)
|
||||
weston_view_set_position(view->view, x, y);
|
||||
weston_view_set_position(view->view, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -354,9 +354,12 @@ set_fullscreen(struct weston_desktop_xwayland_surface *surface,
|
|||
static void
|
||||
set_xwayland(struct weston_desktop_xwayland_surface *surface, int x, int y)
|
||||
{
|
||||
struct weston_coord_global pos;
|
||||
|
||||
pos.c = weston_coord(x, y);
|
||||
weston_desktop_xwayland_surface_change_state(surface, XWAYLAND, NULL,
|
||||
x, y);
|
||||
weston_view_set_position(surface->view, x, y);
|
||||
weston_view_set_position(surface->view, pos);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -1863,9 +1863,10 @@ weston_tablet_tool_cursor_move(struct weston_tablet_tool *tool,
|
|||
tool->pos = pos;
|
||||
|
||||
if (tool->sprite) {
|
||||
weston_view_set_position(tool->sprite,
|
||||
pos.c.x - tool->hotspot.c.x,
|
||||
pos.c.y - tool->hotspot.c.y);
|
||||
struct weston_coord_global hotspot;
|
||||
|
||||
hotspot.c = weston_coord_sub(pos.c, tool->hotspot.c);
|
||||
weston_view_set_position(tool->sprite, hotspot);
|
||||
weston_view_schedule_repaint(tool->sprite);
|
||||
}
|
||||
}
|
||||
|
@ -2197,9 +2198,9 @@ weston_pointer_move_to(struct weston_pointer *pointer,
|
|||
pointer->pos = pos;
|
||||
|
||||
if (pointer->sprite) {
|
||||
weston_view_set_position(pointer->sprite,
|
||||
pos.c.x - pointer->hotspot.c.x,
|
||||
pos.c.y - pointer->hotspot.c.y);
|
||||
pos.c = weston_coord_sub(pointer->pos.c,
|
||||
pointer->hotspot.c);
|
||||
weston_view_set_position(pointer->sprite, pos);
|
||||
weston_view_schedule_repaint(pointer->sprite);
|
||||
}
|
||||
|
||||
|
@ -3241,7 +3242,7 @@ tablet_tool_cursor_surface_committed(struct weston_surface *es,
|
|||
tool->hotspot.c = weston_coord_sub(tool->hotspot.c, new_origin.c);
|
||||
pos.c = weston_coord_sub(tool->pos.c, tool->hotspot.c);
|
||||
|
||||
weston_view_set_position(tool->sprite, pos.c.x, pos.c.y);
|
||||
weston_view_set_position(tool->sprite, pos);
|
||||
|
||||
empty_region(&es->pending.input);
|
||||
empty_region(&es->input);
|
||||
|
@ -3537,7 +3538,7 @@ pointer_cursor_surface_committed(struct weston_surface *es,
|
|||
new_origin.c);
|
||||
pos.c = weston_coord_sub(pointer->pos.c, pointer->hotspot.c);
|
||||
|
||||
weston_view_set_position(pointer->sprite, pos.c.x, pos.c.y);
|
||||
weston_view_set_position(pointer->sprite, pos);
|
||||
|
||||
empty_region(&es->pending.input);
|
||||
empty_region(&es->input);
|
||||
|
|
|
@ -130,20 +130,22 @@ weston_shell_utils_center_on_output(struct weston_view *view,
|
|||
struct weston_output *output)
|
||||
{
|
||||
int32_t surf_x, surf_y, width, height;
|
||||
float x, y;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
if (!output) {
|
||||
weston_view_set_position(view, 0, 0);
|
||||
pos.c = weston_coord(0, 0);
|
||||
weston_view_set_position(view, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
weston_shell_utils_subsurfaces_boundingbox(view->surface, &surf_x,
|
||||
&surf_y, &width, &height);
|
||||
|
||||
x = output->x + (output->width - width) / 2 - surf_x / 2;
|
||||
y = output->y + (output->height - height) / 2 - surf_y / 2;
|
||||
pos.c = weston_coord(output->x, output->y);
|
||||
pos.c.x += (output->width - width) / 2 - surf_x / 2;
|
||||
pos.c.y += (output->height - height) / 2 - surf_y / 2;
|
||||
|
||||
weston_view_set_position(view, x, y);
|
||||
weston_view_set_position(view, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,6 +179,7 @@ weston_shell_utils_curtain_create(struct weston_compositor *compositor,
|
|||
struct weston_surface *surface = NULL;
|
||||
struct weston_buffer_reference *buffer_ref;
|
||||
struct weston_view *view;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
curtain = zalloc(sizeof(*curtain));
|
||||
if (curtain == NULL)
|
||||
|
@ -218,7 +221,8 @@ weston_shell_utils_curtain_create(struct weston_compositor *compositor,
|
|||
|
||||
weston_surface_map(surface);
|
||||
|
||||
weston_view_set_position(view, params->x, params->y);
|
||||
pos.c = weston_coord(params->x, params->y);
|
||||
weston_view_set_position(view, pos);
|
||||
|
||||
return curtain;
|
||||
|
||||
|
|
|
@ -181,6 +181,7 @@ map_calibrator(struct weston_touch_calibrator *calibrator)
|
|||
{
|
||||
struct weston_compositor *c = calibrator->compositor;
|
||||
struct weston_touch_device *device = calibrator->device;
|
||||
struct weston_coord_global pos;
|
||||
static const struct weston_touch_device_matrix identity = {
|
||||
.m = { 1, 0, 0, 0, 1, 0}
|
||||
};
|
||||
|
@ -199,9 +200,8 @@ map_calibrator(struct weston_touch_calibrator *calibrator)
|
|||
weston_layer_entry_insert(&c->calibrator_layer.view_list,
|
||||
&calibrator->view->layer_link);
|
||||
|
||||
weston_view_set_position(calibrator->view,
|
||||
calibrator->output->x,
|
||||
calibrator->output->y);
|
||||
pos.c = weston_coord(calibrator->output->x, calibrator->output->y);
|
||||
weston_view_set_position(calibrator->view, pos);
|
||||
calibrator->view->output = calibrator->surface->output;
|
||||
calibrator->view->is_mapped = true;
|
||||
|
||||
|
|
|
@ -60,7 +60,8 @@ PLUGIN_TEST(surface_to_from_global)
|
|||
assert(view);
|
||||
surface->width = 50;
|
||||
surface->height = 50;
|
||||
weston_view_set_position(view, 5, 10);
|
||||
cg.c = weston_coord(5, 10);
|
||||
weston_view_set_position(view, cg);
|
||||
weston_view_update_transform(view);
|
||||
|
||||
cs = weston_coord_surface(33, 22, surface);
|
||||
|
|
|
@ -59,7 +59,8 @@ PLUGIN_TEST(surface_transform)
|
|||
assert(view);
|
||||
surface->width = 200;
|
||||
surface->height = 200;
|
||||
weston_view_set_position(view, 100, 100);
|
||||
coord_g.c = weston_coord(100, 100);
|
||||
weston_view_set_position(view, coord_g);
|
||||
weston_view_update_transform(view);
|
||||
coord_s = weston_coord_surface(20, 20, surface);
|
||||
coord_g = weston_coord_surface_to_global(view, coord_s);
|
||||
|
@ -67,7 +68,8 @@ PLUGIN_TEST(surface_transform)
|
|||
fprintf(stderr, "20,20 maps to %f, %f\n", coord_g.c.x, coord_g.c.y);
|
||||
assert(coord_g.c.x == 120 && coord_g.c.y == 120);
|
||||
|
||||
weston_view_set_position(view, 150, 300);
|
||||
coord_g.c = weston_coord(150, 300);
|
||||
weston_view_set_position(view, coord_g);
|
||||
weston_view_update_transform(view);
|
||||
coord_s = weston_coord_surface(50, 40, surface);
|
||||
coord_g = weston_coord_surface_to_global(view, coord_s);
|
||||
|
|
|
@ -86,6 +86,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
|||
weston_desktop_surface_get_surface(desktop_surface);
|
||||
struct weston_geometry geometry =
|
||||
weston_desktop_surface_get_geometry(desktop_surface);
|
||||
struct weston_coord_global pos;
|
||||
|
||||
assert(dts->view);
|
||||
|
||||
|
@ -94,7 +95,10 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
|||
|
||||
weston_surface_map(surface);
|
||||
weston_layer_entry_insert(&dts->layer.view_list, &dts->view->layer_link);
|
||||
weston_view_set_position(dts->view, 0 - geometry.x, 0 - geometry.y);
|
||||
pos.c = weston_coord(0, 0);
|
||||
pos.c.x -= geometry.x;
|
||||
pos.c.y -= geometry.y;
|
||||
weston_view_set_position(dts->view, pos);
|
||||
weston_view_update_transform(dts->view);
|
||||
dts->view->is_mapped = true;
|
||||
}
|
||||
|
@ -195,6 +199,7 @@ wet_shell_init(struct weston_compositor *ec,
|
|||
.get_label = background_get_label,
|
||||
.surface_private = NULL,
|
||||
};
|
||||
struct weston_coord_global pos;
|
||||
|
||||
dts = zalloc(sizeof *dts);
|
||||
if (!dts)
|
||||
|
@ -221,7 +226,8 @@ wet_shell_init(struct weston_compositor *ec,
|
|||
weston_surface_set_role(dts->background->view->surface,
|
||||
"test-desktop background", NULL, 0);
|
||||
|
||||
weston_view_set_position(dts->background->view, 0, 0);
|
||||
pos.c = weston_coord(0, 0);
|
||||
weston_view_set_position(dts->background->view, pos);
|
||||
weston_layer_entry_insert(&dts->background_layer.view_list,
|
||||
&dts->background->view->layer_link);
|
||||
weston_view_update_transform(dts->background->view);
|
||||
|
|
|
@ -157,13 +157,14 @@ test_surface_committed(struct weston_surface *surface,
|
|||
{
|
||||
struct weston_test_surface *test_surface = surface->committed_private;
|
||||
struct weston_test *test = test_surface->test;
|
||||
struct weston_coord_global pos;
|
||||
|
||||
if (wl_list_empty(&test_surface->view->layer_link.link))
|
||||
weston_layer_entry_insert(&test->layer.view_list,
|
||||
&test_surface->view->layer_link);
|
||||
|
||||
weston_view_set_position(test_surface->view,
|
||||
test_surface->x, test_surface->y);
|
||||
pos.c = weston_coord(test_surface->x, test_surface->y);
|
||||
weston_view_set_position(test_surface->view, pos);
|
||||
|
||||
weston_view_update_transform(test_surface->view);
|
||||
|
||||
|
|
Loading…
Reference in a new issue