Skip to content
Commits on Source (6)
......@@ -60,23 +60,24 @@ input_panel_slide_done(struct weston_view_animation *animation, void *data)
}
static int
calc_input_panel_position(struct input_panel_surface *ip_surface, float *x, float*y)
calc_input_panel_position(struct input_panel_surface *ip_surface, struct weston_coord_global *out_pos)
{
struct desktop_shell *shell = ip_surface->shell;
struct weston_coord_global pos;
if (ip_surface->panel) {
struct weston_view *view = get_default_view(shell->text_input.surface);
if (view == NULL)
return -1;
*x = view->geometry.pos_offset.x +
shell->text_input.cursor_rectangle.x2;
*y = view->geometry.pos_offset.y +
shell->text_input.cursor_rectangle.y2;
pos = weston_view_get_pos_offset_global(view);
pos.c.x += shell->text_input.cursor_rectangle.x2;
pos.c.y += shell->text_input.cursor_rectangle.y2;
} else {
*x = ip_surface->output->pos.c.x +
(ip_surface->output->width - ip_surface->surface->width) / 2;
*y = ip_surface->output->pos.c.y +
ip_surface->output->height - ip_surface->surface->height;
pos = ip_surface->output->pos;
pos.c.x += (ip_surface->output->width - ip_surface->surface->width) / 2;
pos.c.y += ip_surface->output->height - ip_surface->surface->height;
}
*out_pos = pos;
return 0;
}
......@@ -87,7 +88,6 @@ show_input_panel_surface(struct input_panel_surface *ipsurf)
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) {
struct weston_keyboard *keyboard =
......@@ -99,9 +99,9 @@ show_input_panel_surface(struct input_panel_surface *ipsurf)
if (!focus)
continue;
ipsurf->output = focus->output;
if (calc_input_panel_position(ipsurf, &x, &y))
if (calc_input_panel_position(ipsurf, &pos))
continue;
pos.c = weston_coord(x, y);
weston_view_set_position(ipsurf->view, pos);
}
......@@ -195,14 +195,13 @@ 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)
return;
if (calc_input_panel_position(ip_surface, &x, &y))
if (calc_input_panel_position(ip_surface, &pos))
return;
pos.c = weston_coord(x, y);
weston_view_set_position(ip_surface->view, pos);
if (!weston_surface_is_mapped(surface) && shell->showing_input_panels)
......
......@@ -170,14 +170,14 @@ struct shell_tablet_tool_grab {
struct weston_move_grab {
struct shell_grab base;
wl_fixed_t dx, dy;
struct weston_coord_global delta;
bool client_initiated;
};
struct weston_touch_move_grab {
struct shell_touch_grab base;
int active;
wl_fixed_t dx, dy;
struct weston_coord_global delta;
};
struct weston_tablet_tool_move_grab {
......@@ -344,7 +344,7 @@ get_panel_size(struct desktop_shell *shell,
view->surface);
b = weston_coord_surface_to_global(view, tmp_s);
a.c = weston_coord_sub(b.c, a.c);
a = weston_coord_global_sub(b, a);
*width = a.c.x;
*height = a.c.y;
}
......@@ -975,15 +975,15 @@ touch_move_grab_motion(struct weston_touch_grab *grab,
struct weston_touch_move_grab *move = (struct weston_touch_move_grab *) grab;
struct shell_surface *shsurf = move->base.shsurf;
struct weston_surface *es;
struct weston_coord_global pos = grab->touch->grab_pos;
struct weston_coord_global pos;
if (!shsurf || !shsurf->desktop_surface || !move->active)
return;
es = weston_desktop_surface_get_surface(shsurf->desktop_surface);
pos.c.x = (int)(pos.c.x + wl_fixed_to_double(move->dx));
pos.c.y = (int)(pos.c.y + wl_fixed_to_double(move->dy));
pos = weston_coord_global_add(grab->touch->grab_pos, move->delta);
pos.c = weston_coord_truncate(pos.c);
weston_view_set_position(shsurf->view, pos);
weston_compositor_schedule_repaint(es->compositor);
......@@ -1017,7 +1017,6 @@ static int
surface_touch_move(struct shell_surface *shsurf, struct weston_touch *touch)
{
struct weston_touch_move_grab *move;
struct weston_coord_global pos;
if (!shsurf)
return -1;
......@@ -1031,10 +1030,9 @@ surface_touch_move(struct shell_surface *shsurf, struct weston_touch *touch)
return -1;
move->active = 1;
pos.c = weston_coord_sub(shsurf->view->geometry.pos_offset,
touch->grab_pos.c);
move->dx = wl_fixed_from_double(pos.c.x);
move->dy = wl_fixed_from_double(pos.c.y);
move->delta = weston_coord_global_sub(
weston_view_get_pos_offset_global(shsurf->view),
touch->grab_pos);
shell_touch_grab_start(&move->base, &touch_move_grab_interface, shsurf,
touch);
......@@ -1076,9 +1074,11 @@ constrain_position(struct weston_move_grab *move, int *cx, int *cy)
const int safety = 50;
pixman_rectangle32_t area;
struct weston_geometry geometry;
struct weston_coord_global c;
x = pointer->pos.c.x + wl_fixed_to_double(move->dx);
y = pointer->pos.c.y + wl_fixed_to_double(move->dy);
c = weston_coord_global_add(pointer->pos, move->delta);
x = c.c.x;
y = c.c.y;
if (shsurf->shell->panel_position ==
WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP) {
......@@ -1167,7 +1167,6 @@ surface_move(struct shell_surface *shsurf, struct weston_pointer *pointer,
bool client_initiated)
{
struct weston_move_grab *move;
struct weston_coord offset;
if (!shsurf)
return -1;
......@@ -1181,10 +1180,9 @@ surface_move(struct shell_surface *shsurf, struct weston_pointer *pointer,
if (!move)
return -1;
offset = weston_coord_sub(shsurf->view->geometry.pos_offset,
pointer->grab_pos.c);
move->dx = wl_fixed_from_double(offset.x);
move->dy = wl_fixed_from_double(offset.y);
move->delta = weston_coord_global_sub(
weston_view_get_pos_offset_global(shsurf->view),
pointer->grab_pos);
move->client_initiated = client_initiated;
weston_desktop_surface_set_orientation(shsurf->desktop_surface,
......@@ -1320,7 +1318,7 @@ static int
surface_tablet_tool_move(struct shell_surface *shsurf, struct weston_tablet_tool *tool)
{
struct weston_tablet_tool_move_grab *move;
struct weston_coord offset;
struct weston_coord_global offset;
if (!shsurf)
return -1;
......@@ -1332,10 +1330,11 @@ surface_tablet_tool_move(struct shell_surface *shsurf, struct weston_tablet_tool
if (!move)
return -1;
offset = weston_coord_sub(shsurf->view->geometry.pos_offset,
tool->grab_pos.c);
move->dx = wl_fixed_from_double(offset.x);
move->dy = wl_fixed_from_double(offset.y);
offset.c = weston_coord_sub(
weston_view_get_pos_offset_global(shsurf->view).c,
tool->grab_pos.c);
move->dx = wl_fixed_from_double(offset.c.x);
move->dy = wl_fixed_from_double(offset.c.y);
shell_tablet_tool_grab_start(&move->base, &tablet_tool_move_grab_interface,
shsurf, tool);
......@@ -2277,7 +2276,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
* the view */
weston_view_set_output(shsurf->wview_anim_fade,
shsurf->view->output);
pos.c = shsurf->view->geometry.pos_offset;
pos = weston_view_get_pos_offset_global(shsurf->view);
weston_view_set_position(shsurf->wview_anim_fade, pos);
weston_layer_entry_insert(&shsurf->view->layer_link,
......@@ -2448,7 +2447,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
if ((shsurf->state.fullscreen || shsurf->state.maximized) &&
!shsurf->saved_position_valid) {
shsurf->saved_pos.c = shsurf->view->geometry.pos_offset;
shsurf->saved_pos = weston_view_get_pos_offset_global(shsurf->view);
shsurf->saved_position_valid = true;
if (!wl_list_empty(&shsurf->rotation.transform.link)) {
......@@ -2494,8 +2493,10 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
from_g = weston_coord_surface_to_global(view, from_s);
to_g = weston_coord_surface_to_global(view, to_s);
offset.c = weston_coord_sub(to_g.c, from_g.c);
pos.c = weston_coord_add(view->geometry.pos_offset, offset.c);
offset = weston_coord_global_sub(to_g, from_g);
pos = weston_coord_global_add(
weston_view_get_pos_offset_global(view),
offset);
weston_view_set_position(shsurf->view, pos);
}
......@@ -3558,7 +3559,7 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
if (dposx != 0.0f || dposy != 0.0f) {
struct weston_coord_global pos;
pos.c = shsurf->view->geometry.pos_offset;
pos = weston_view_get_pos_offset_global(shsurf->view);
pos.c.x += dposx;
pos.c.y += dposy;
weston_view_set_position(shsurf->view, pos);
......@@ -4028,7 +4029,7 @@ 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);
pos.c = shsurf->view->geometry.pos_offset;
pos = weston_view_get_pos_offset_global(shsurf->view);
weston_view_set_position(view, pos);
view->is_mapped = true;
......@@ -4670,7 +4671,7 @@ shell_reposition_view_on_output_change(struct weston_view *view)
wl_list_for_each(output, &ec->output_list, link) {
struct weston_coord_global pos;
pos.c = view->geometry.pos_offset;
pos = weston_view_get_pos_offset_global(view);
if (weston_output_contains_coord(output, pos)) {
visible = 1;
break;
......@@ -4837,8 +4838,9 @@ handle_output_move_layer(struct desktop_shell *shell,
if (view->output != output)
continue;
pos.c = weston_coord_add(view->geometry.pos_offset,
output->move.c);
pos.c = weston_coord_add(
weston_view_get_pos_offset_global(view).c,
output->move.c);
weston_view_set_position(view, pos);
}
}
......
......@@ -2158,6 +2158,12 @@ void
weston_view_set_position(struct weston_view *view,
struct weston_coord_global pos);
struct weston_coord_surface
weston_view_get_pos_offset_rel(struct weston_view *view);
struct weston_coord_global
weston_view_get_pos_offset_global(struct weston_view *view);
void
weston_view_set_transform_parent(struct weston_view *view,
struct weston_view *parent);
......
......@@ -160,12 +160,32 @@ weston_coord_add(struct weston_coord a, struct weston_coord b)
return weston_coord(a.x + b.x, a.y + b.y);
}
static inline struct weston_coord_global __attribute__ ((warn_unused_result))
weston_coord_global_add(struct weston_coord_global a,
struct weston_coord_global b)
{
return (struct weston_coord_global){ .c = weston_coord_add(a.c, b.c) };
}
static inline struct weston_coord __attribute__ ((warn_unused_result))
weston_coord_sub(struct weston_coord a, struct weston_coord b)
{
return weston_coord(a.x - b.x, a.y - b.y);
}
static inline struct weston_coord_global __attribute__ ((warn_unused_result))
weston_coord_global_sub(struct weston_coord_global a,
struct weston_coord_global b)
{
return (struct weston_coord_global){ .c = weston_coord_sub(a.c, b.c) };
}
static inline struct weston_coord __attribute__ ((warn_unused_result))
weston_coord_truncate(struct weston_coord in)
{
return (struct weston_coord){ (int)in.x, (int)in.y };
}
#ifdef __cplusplus
}
#endif
......
......@@ -32,7 +32,7 @@ struct kiosk_shell_grab {
struct weston_pointer_grab pointer_grab;
struct weston_touch_grab touch_grab;
wl_fixed_t dx, dy;
struct weston_coord_global delta;
bool active;
};
......@@ -85,9 +85,7 @@ pointer_move_grab_motion(struct weston_pointer_grab *pointer_grab,
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
pos = pointer->pos;
pos.c.x += wl_fixed_to_double(shgrab->dx);
pos.c.y += wl_fixed_to_double(shgrab->dy);
pos = weston_coord_global_add(pointer->pos, shgrab->delta);
weston_view_set_position(shsurf->view, pos);
......@@ -164,17 +162,14 @@ touch_move_grab_motion(struct weston_touch_grab *touch_grab,
struct kiosk_shell_surface *shsurf = shgrab->shsurf;
struct weston_surface *surface;
struct weston_coord_global pos;
int dx, dy;
if (!shsurf || !shgrab->active)
return;
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
dx = (int)(touch->grab_pos.c.x + wl_fixed_to_double(shgrab->dx));
dy = (int)(touch->grab_pos.c.y + wl_fixed_to_double(shgrab->dy));
pos.c = weston_coord(dx, dy);
pos = weston_coord_global_add(touch->grab_pos, shgrab->delta);
pos.c = weston_coord_truncate(pos.c);
weston_view_set_position(shsurf->view, pos);
weston_compositor_schedule_repaint(surface->compositor);
......@@ -241,7 +236,6 @@ kiosk_shell_grab_start_for_pointer_move(struct kiosk_shell_surface *shsurf,
struct weston_pointer *pointer)
{
struct kiosk_shell_grab *shgrab;
struct weston_coord_global offset;
if (!shsurf)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
......@@ -255,10 +249,9 @@ kiosk_shell_grab_start_for_pointer_move(struct kiosk_shell_surface *shsurf,
if (!shgrab)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
offset.c = weston_coord_sub(shsurf->view->geometry.pos_offset,
pointer->grab_pos.c);
shgrab->dx = wl_fixed_from_double(offset.c.x);
shgrab->dy = wl_fixed_from_double(offset.c.y);
shgrab->delta = weston_coord_global_sub(
weston_view_get_pos_offset_global(shsurf->view),
pointer->grab_pos);
shgrab->active = true;
weston_seat_break_desktop_grabs(pointer->seat);
......@@ -274,7 +267,6 @@ kiosk_shell_grab_start_for_touch_move(struct kiosk_shell_surface *shsurf,
struct weston_touch *touch)
{
struct kiosk_shell_grab *shgrab;
struct weston_coord_global pos;
if (!shsurf)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
......@@ -288,10 +280,9 @@ kiosk_shell_grab_start_for_touch_move(struct kiosk_shell_surface *shsurf,
if (!shgrab)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
pos.c = weston_coord_sub(shsurf->view->geometry.pos_offset,
touch->grab_pos.c);
shgrab->dx = wl_fixed_from_double(pos.c.x);
shgrab->dy = wl_fixed_from_double(pos.c.y);
shgrab->delta = weston_coord_global_sub(
weston_view_get_pos_offset_global(shsurf->view),
touch->grab_pos);
shgrab->active = true;
weston_seat_break_desktop_grabs(touch->seat);
......
......@@ -820,9 +820,10 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
from_g = weston_coord_surface_to_global(shsurf->view, from_s);
to_g = weston_coord_surface_to_global(shsurf->view, to_s);
offset.c = weston_coord_sub(to_g.c, from_g.c);
pos.c = weston_coord_add(shsurf->view->geometry.pos_offset,
offset.c);
offset = weston_coord_global_sub(to_g, from_g);
pos = weston_coord_global_add(
weston_view_get_pos_offset_global(shsurf->view),
offset);
weston_view_set_position(shsurf->view, pos);
weston_view_update_transform(shsurf->view);
......@@ -1138,8 +1139,9 @@ kiosk_shell_handle_output_moved(struct wl_listener *listener, void *data)
if (view->output != output)
continue;
pos.c = weston_coord_add(view->geometry.pos_offset,
output->move.c);
pos.c = weston_coord_add(
weston_view_get_pos_offset_global(view).c,
output->move.c);
weston_view_set_position(view, pos);
}
......@@ -1150,8 +1152,9 @@ kiosk_shell_handle_output_moved(struct wl_listener *listener, void *data)
if (view->output != output)
continue;
pos.c = weston_coord_add(view->geometry.pos_offset,
output->move.c);
pos.c = weston_coord_add(
weston_view_get_pos_offset_global(view).c,
output->move.c);
weston_view_set_position(view, pos);
}
}
......
......@@ -1615,6 +1615,32 @@ weston_view_set_position(struct weston_view *view,
weston_view_geometry_dirty(view);
}
WL_EXPORT struct weston_coord_surface
weston_view_get_pos_offset_rel(struct weston_view *view)
{
struct weston_coord_surface out;
assert(view->geometry.parent);
out.c = view->geometry.pos_offset;
out.coordinate_space_id = view->geometry.parent->surface;
return out;
}
WL_EXPORT struct weston_coord_global
weston_view_get_pos_offset_global(struct weston_view *view)
{
struct weston_coord_global out;
assert(view->surface->committed != subsurface_committed);
assert(!view->geometry.parent);
out.c = view->geometry.pos_offset;
return out;
}
static void
transform_parent_handle_parent_destroy(struct wl_listener *listener,
void *data)
......@@ -4560,9 +4586,7 @@ subsurface_committed(struct weston_surface *surface,
continue;
}
tmp = weston_coord_surface(view->geometry.pos_offset.x,
view->geometry.pos_offset.y,
view->geometry.parent->surface);
tmp = weston_view_get_pos_offset_rel(view);
tmp.c = weston_coord_add(tmp.c, new_origin.c);
weston_view_set_rel_position(view, tmp);
}
......@@ -6472,7 +6496,7 @@ weston_output_set_position(struct weston_output *output,
return;
}
output->move.c = weston_coord_sub(pos.c, output->pos.c);
output->move = weston_coord_global_sub(pos, output->pos);
if (output->move.c.x == 0 && output->move.c.y == 0)
return;
......