Skip to content
Commits on Source (9)
......@@ -643,7 +643,7 @@ create_focus_surface(struct weston_compositor *ec,
struct focus_surface *fsurf = NULL;
struct weston_curtain_params curtain_params = {
.r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0,
.x = output->pos.c.x, .y = output->pos.c.y,
.pos = output->pos,
.width = output->width, .height = output->height,
.surface_committed = focus_surface_committed,
.get_label = focus_surface_get_label,
......@@ -982,7 +982,7 @@ surface_keyboard_focus_lost(struct weston_surface *surface)
static void
touch_move_grab_down(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id, wl_fixed_t x, wl_fixed_t y)
int touch_id, struct weston_coord_global c)
{
}
......@@ -1006,7 +1006,7 @@ touch_move_grab_up(struct weston_touch_grab *grab, const struct timespec *time,
static void
touch_move_grab_motion(struct weston_touch_grab *grab,
const struct timespec *time, int touch_id,
wl_fixed_t x, wl_fixed_t y)
struct weston_coord_global unused)
{
struct weston_touch_move_grab *move = (struct weston_touch_move_grab *) grab;
struct shell_surface *shsurf = move->base.shsurf;
......@@ -1093,22 +1093,20 @@ noop_grab_frame(struct weston_pointer_grab *grab)
{
}
static void
constrain_position(struct weston_move_grab *move, int *cx, int *cy)
static struct weston_coord_global
constrain_position(struct weston_move_grab *move)
{
struct shell_surface *shsurf = move->base.shsurf;
struct weston_surface *surface =
weston_desktop_surface_get_surface(shsurf->desktop_surface);
struct weston_pointer *pointer = move->base.grab.pointer;
int x, y, bottom;
int bottom;
const int safety = 50;
pixman_rectangle32_t area;
struct weston_geometry geometry;
struct weston_coord_global c;
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) {
......@@ -1116,18 +1114,17 @@ constrain_position(struct weston_move_grab *move, int *cx, int *cy)
geometry =
weston_desktop_surface_get_geometry(shsurf->desktop_surface);
bottom = y + geometry.height + geometry.y;
bottom = c.c.y + geometry.height + geometry.y;
if (bottom - safety < area.y)
y = area.y + safety - geometry.height
- geometry.y;
c.c.y = area.y + safety - geometry.height
- geometry.y;
if (move->client_initiated &&
y + geometry.y < area.y)
y = area.y - geometry.y;
c.c.y + geometry.y < area.y)
c.c.y = area.y - geometry.y;
}
*cx = x;
*cy = y;
return c;
}
static void
......@@ -1139,15 +1136,12 @@ move_grab_motion(struct weston_pointer_grab *grab,
struct weston_pointer *pointer = grab->pointer;
struct shell_surface *shsurf = move->base.shsurf;
struct weston_coord_global pos;
int cx, cy;
weston_pointer_move(pointer, event);
if (!shsurf || !shsurf->desktop_surface)
return;
constrain_position(move, &cx, &cy);
pos.c = weston_coord(cx, cy);
pos = constrain_position(move);
weston_view_set_position(shsurf->view, pos);
}
......@@ -1923,7 +1917,7 @@ shell_set_view_fullscreen(struct shell_surface *shsurf)
struct weston_output *output = shsurf->fullscreen_output;
struct weston_curtain_params curtain_params = {
.r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0,
.x = output->pos.c.x, .y = output->pos.c.y,
.pos = output->pos,
.width = output->width, .height = output->height,
.surface_committed = black_surface_committed,
.get_label = black_surface_get_label,
......@@ -2263,28 +2257,31 @@ set_maximized_position(struct desktop_shell *shell,
pixman_rectangle32_t area;
struct weston_geometry geometry;
struct weston_coord_global pos;
struct weston_coord_surface offset;
get_output_work_area(shell, shsurf->output, &area);
geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
pos.c = weston_coord(area.x - geometry.x,
area.y - geometry.y);
weston_view_set_position(shsurf->view, pos);
pos.c = weston_coord(area.x, area.y);
offset = weston_coord_surface(-geometry.x, -geometry.y, shsurf->view->surface);
weston_view_set_position_with_offset(shsurf->view, pos, offset);
}
static void
set_position_from_xwayland(struct shell_surface *shsurf)
{
struct weston_geometry geometry;
struct weston_coord_global pos;
struct weston_coord_surface offs;
assert(shsurf->xwayland.is_set);
geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
pos.c = weston_coord(geometry.x, geometry.y);
pos.c = weston_coord_sub(shsurf->xwayland.pos.c, pos.c);
offs = weston_coord_surface(-geometry.x, -geometry.y,
shsurf->view->surface);
weston_view_set_position(shsurf->view, pos);
weston_view_set_position_with_offset(shsurf->view,
shsurf->xwayland.pos,
offs);
#ifdef WM_DEBUG
weston_log("%s: XWM %d, %d; geometry %d, %d; view %f, %f\n",
......@@ -2348,7 +2345,7 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf)
static void
desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
int32_t sx, int32_t sy, void *data)
struct weston_coord_surface buf_offset, void *data)
{
struct shell_surface *shsurf =
weston_desktop_surface_get_user_data(desktop_surface);
......@@ -2390,7 +2387,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
return;
}
if (sx == 0 && sy == 0 &&
if (buf_offset.c.x == 0 && buf_offset.c.y == 0 &&
shsurf->last_width == surface->width &&
shsurf->last_height == surface->height &&
was_fullscreen == shsurf->state.fullscreen &&
......@@ -2429,33 +2426,21 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
set_maximized_position(shell, shsurf);
surface->output = shsurf->output;
} else {
struct weston_coord_surface from_s, to_s;
struct weston_coord_global to_g, from_g;
struct weston_coord_global offset, pos;
from_s = weston_coord_surface(0, 0, view->surface);
struct weston_coord_surface offset = buf_offset;
struct weston_coord_global pos;
if (shsurf->resize_edges) {
sx = 0;
sy = 0;
offset.c.x = 0;
offset.c.y = 0;
}
if (shsurf->resize_edges & WESTON_DESKTOP_SURFACE_EDGE_LEFT)
sx = shsurf->last_width - surface->width;
offset.c.x = shsurf->last_width - surface->width;
if (shsurf->resize_edges & WESTON_DESKTOP_SURFACE_EDGE_TOP)
sy = shsurf->last_height - surface->height;
to_s = weston_coord_surface(sx, sy, view->surface);
from_g = weston_coord_surface_to_global(view, from_s);
to_g = weston_coord_surface_to_global(view, to_s);
offset.c.y = shsurf->last_height - surface->height;
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);
pos = weston_view_get_pos_offset_global(view);
weston_view_set_position_with_offset(shsurf->view, pos, offset);
}
shsurf->last_width = surface->width;
......@@ -2766,12 +2751,12 @@ desktop_surface_pong(struct weston_desktop_client *desktop_client,
static void
desktop_surface_set_xwayland_position(struct weston_desktop_surface *surface,
int32_t x, int32_t y, void *shell_)
struct weston_coord_global pos, void *shell_)
{
struct shell_surface *shsurf =
weston_desktop_surface_get_user_data(surface);
shsurf->xwayland.pos.c = weston_coord(x, y);
shsurf->xwayland.pos = pos;
shsurf->xwayland.is_set = true;
}
......@@ -3912,8 +3897,6 @@ shell_fade_create_view(struct desktop_shell *shell)
struct shell_output *shell_output;
struct weston_curtain_params curtain_params = {
.r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0,
.x = 0, .y = 0,
.width = 8192, .height = 8192,
.surface_committed = black_surface_committed,
.get_label = fade_surface_get_label,
.surface_private = shell,
......@@ -3940,8 +3923,8 @@ shell_fade_create_view(struct desktop_shell *shell)
x2 = MAX(x2, op->pos.c.x + op->width);
y2 = MAX(y2, op->pos.c.y + op->height);
}
curtain_params.x = x1;
curtain_params.y = y1;
curtain_params.pos.c.x = x1;
curtain_params.pos.c.y = y1;
curtain_params.width = x2 - x1;
curtain_params.height = y2 - y1;
curtain = weston_shell_utils_curtain_create(compositor, &curtain_params);
......
......@@ -228,11 +228,11 @@ black_surface_committed(struct weston_surface *es,
static struct weston_curtain *
create_curtain(struct weston_compositor *ec, struct fs_output *fsout,
float x, float y, int w, int h)
struct weston_coord_global pos, int w, int h)
{
struct weston_curtain_params curtain_params = {
.r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0,
.x = x, .y = y, .width = w, .height = h,
.pos = pos, .width = w, .height = h,
.surface_committed = black_surface_committed,
.get_label = NULL,
.surface_private = fsout,
......@@ -324,7 +324,7 @@ fs_output_create(struct fullscreen_shell *shell, struct weston_output *output)
fsout->surface_destroyed.notify = surface_destroyed;
fsout->pending.surface_destroyed.notify = pending_surface_destroyed;
fsout->curtain = create_curtain(shell->compositor, fsout,
output->pos.c.x, output->pos.c.y,
output->pos,
output->width, output->height);
fsout->curtain->view->is_mapped = true;
weston_layer_entry_insert(&shell->layer.view_list,
......
......@@ -68,9 +68,10 @@ struct weston_desktop_api {
void (*surface_removed)(struct weston_desktop_surface *surface,
void *user_data);
void (*committed)(struct weston_desktop_surface *surface,
int32_t sx, int32_t sy, void *user_data);
struct weston_coord_surface buf_offset, void *user_data);
void (*show_window_menu)(struct weston_desktop_surface *surface,
struct weston_seat *seat, int32_t x, int32_t y,
struct weston_seat *seat,
struct weston_coord_surface offset,
void *user_data);
void (*set_parent)(struct weston_desktop_surface *surface,
struct weston_desktop_surface *parent,
......@@ -120,7 +121,7 @@ struct weston_desktop_api {
* This callback can be NULL.
*/
void (*set_xwayland_position)(struct weston_desktop_surface *surface,
int32_t x, int32_t y, void *user_data);
struct weston_coord_global pos, void *user_data);
void (*get_position)(struct weston_desktop_surface *surface,
int32_t *x, int32_t *y,
void *user_data);
......
......@@ -668,16 +668,14 @@ struct weston_touch_grab_interface {
void (*down)(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id,
wl_fixed_t sx,
wl_fixed_t sy);
struct weston_coord_global c);
void (*up)(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id);
void (*motion)(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id,
wl_fixed_t sx,
wl_fixed_t sy);
struct weston_coord_global c);
void (*frame)(struct weston_touch_grab *grab);
void (*cancel)(struct weston_touch_grab *grab);
};
......@@ -1819,10 +1817,8 @@ struct weston_pointer_constraint {
pixman_region32_t region_pending;
bool region_is_pending;
wl_fixed_t hint_x;
wl_fixed_t hint_y;
wl_fixed_t hint_x_pending;
wl_fixed_t hint_y_pending;
struct weston_coord_surface hint;
struct weston_coord_surface hint_pending;
bool hint_is_pending;
struct wl_listener pointer_destroy_listener;
......@@ -2208,6 +2204,11 @@ void
weston_view_set_position(struct weston_view *view,
struct weston_coord_global pos);
void
weston_view_set_position_with_offset(struct weston_view *view,
struct weston_coord_global pos,
struct weston_coord_surface offset);
struct weston_coord_surface
weston_view_get_pos_offset_rel(struct weston_view *view);
......
......@@ -186,6 +186,17 @@ weston_coord_truncate(struct weston_coord in)
return (struct weston_coord){ (int)in.x, (int)in.y };
}
static inline struct weston_coord_surface __attribute__ ((warn_unused_result))
weston_coord_surface_invert(struct weston_coord_surface in)
{
struct weston_coord_surface out = in;
out.c.x = -out.c.x;
out.c.y = -out.c.y;
return out;
}
#ifdef __cplusplus
}
#endif
......
......@@ -36,7 +36,8 @@ struct weston_curtain_params {
struct weston_coord_surface new_origin);
void *surface_private;
float r, g, b, a;
int x, y, width, height;
struct weston_coord_global pos;
int width, height;
bool capture_input;
};
......
......@@ -1712,7 +1712,7 @@ pointer_move_grab_motion(struct weston_pointer_grab *grab,
static void
touch_move_grab_motion(struct weston_touch_grab *grab,
const struct timespec *time, int touch_id,
wl_fixed_t x, wl_fixed_t y)
struct weston_coord_global c)
{
struct touch_move_grab *tch_move_grab = (struct touch_move_grab *)grab;
struct hmi_controller *hmi_ctrl =
......@@ -1748,7 +1748,7 @@ pointer_move_workspace_grab_button(struct weston_pointer_grab *grab,
static void
touch_nope_grab_down(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id, wl_fixed_t sx, wl_fixed_t sy)
int touch_id, struct weston_coord_global c)
{
}
......
......@@ -601,7 +601,7 @@ desktop_surface_removed(struct weston_desktop_surface *surface,
static void
desktop_surface_committed(struct weston_desktop_surface *surface,
int32_t sx, int32_t sy, void *user_data)
struct weston_coord_surface buf_offset, void *user_data)
{
struct ivi_shell_surface *ivisurf = (struct ivi_shell_surface *)
weston_desktop_surface_get_user_data(surface);
......@@ -684,7 +684,7 @@ desktop_surface_minimized_requested(struct weston_desktop_surface *surface,
static void
desktop_surface_set_xwayland_position(struct weston_desktop_surface *surface,
int32_t x, int32_t y, void *user_data)
struct weston_coord_global pos, void *user_data)
{
/* Not supported */
}
......
......@@ -133,7 +133,7 @@ static const struct weston_pointer_grab_interface pointer_move_grab_interface =
static void
touch_move_grab_down(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id, wl_fixed_t x, wl_fixed_t y)
int touch_id, struct weston_coord_global c)
{
}
......@@ -154,7 +154,7 @@ touch_move_grab_up(struct weston_touch_grab *touch_grab,
static void
touch_move_grab_motion(struct weston_touch_grab *touch_grab,
const struct timespec *time, int touch_id,
wl_fixed_t x, wl_fixed_t y)
struct weston_coord_global unused)
{
struct kiosk_shell_grab *shgrab =
container_of(touch_grab, struct kiosk_shell_grab, touch_grab);
......
......@@ -634,8 +634,7 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput)
curtain_params.b = ((bg_color >> 0) & 0xff) / 255.0;
curtain_params.a = 1.0;
curtain_params.x = output->pos.c.x;
curtain_params.y = output->pos.c.y;
curtain_params.pos = output->pos;
curtain_params.width = output->width;
curtain_params.height = output->height;
......@@ -891,7 +890,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
static void
desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
int32_t sx, int32_t sy, void *data)
struct weston_coord_surface buf_offset, void *data)
{
struct kiosk_shell_surface *shsurf =
weston_desktop_surface_get_user_data(desktop_surface);
......@@ -940,14 +939,15 @@ 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_coord_surface offset;
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;
tmp.c = weston_coord(x, y);
weston_view_set_position(shsurf->view, tmp);
offset = weston_coord_surface(-geometry.x, -geometry.y,
shsurf->view->surface);
weston_view_set_position_with_offset(shsurf->view,
shsurf->xwayland.pos,
offset);
}
weston_view_update_transform(shsurf->view);
......@@ -978,24 +978,12 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
WESTON_ACTIVATE_FLAG_NONE);
}
if (!is_fullscreen && (sx != 0 || sy != 0)) {
struct weston_coord_surface from_s, to_s;
struct weston_coord_global from_g, to_g;
struct weston_coord_global offset, pos;
from_s = weston_coord_surface(0, 0,
shsurf->view->surface);
to_s = weston_coord_surface(sx, sy,
shsurf->view->surface);
from_g = weston_coord_surface_to_global(shsurf->view, from_s);
to_g = weston_coord_surface_to_global(shsurf->view, to_s);
offset = weston_coord_global_sub(to_g, from_g);
pos = weston_coord_global_add(
weston_view_get_pos_offset_global(shsurf->view),
offset);
if (!is_fullscreen && (buf_offset.c.x != 0 || buf_offset.c.y != 0)) {
struct weston_coord_global pos;
weston_view_set_position(shsurf->view, pos);
pos = weston_view_get_pos_offset_global(shsurf->view);
weston_view_set_position_with_offset(shsurf->view,
pos, buf_offset);
weston_view_update_transform(shsurf->view);
}
......@@ -1120,13 +1108,12 @@ desktop_surface_pong(struct weston_desktop_client *desktop_client,
static void
desktop_surface_set_xwayland_position(struct weston_desktop_surface *desktop_surface,
int32_t x, int32_t y, void *shell)
struct weston_coord_global pos, void *shell)
{
struct kiosk_shell_surface *shsurf =
weston_desktop_surface_get_user_data(desktop_surface);
shsurf->xwayland.x = x;
shsurf->xwayland.y = y;
shsurf->xwayland.pos = pos;
shsurf->xwayland.is_set = true;
}
......
......@@ -75,8 +75,7 @@ struct kiosk_shell_surface {
struct {
bool is_set;
int32_t x;
int32_t y;
struct weston_coord_global pos;
} xwayland;
bool appid_output_assigned;
......
......@@ -1820,6 +1820,32 @@ weston_view_set_position(struct weston_view *view,
weston_view_geometry_dirty(view);
}
WL_EXPORT void
weston_view_set_position_with_offset(struct weston_view *view,
struct weston_coord_global pos,
struct weston_coord_surface offset)
{
struct weston_coord_global global_offset;
struct weston_coord_surface origin_s;
struct weston_coord_global origin_g, newpos;
assert(view->surface->committed != subsurface_committed);
assert(!view->geometry.parent);
/* We need up to date transform matrices */
weston_view_set_position(view, pos);
weston_view_update_transform(view);
origin_s = weston_coord_surface(0, 0, view->surface);
origin_g = weston_coord_surface_to_global(view, origin_s);
global_offset = weston_coord_surface_to_global(view, offset);
global_offset = weston_coord_global_sub(global_offset, origin_g);
newpos = weston_coord_global_add(weston_view_get_pos_offset_global(view),
global_offset);
weston_view_set_position(view, newpos);
}
WL_EXPORT struct weston_coord_surface
weston_view_get_pos_offset_rel(struct weston_view *view)
{
......
......@@ -446,8 +446,7 @@ drag_surface_configure(struct weston_drag *drag,
else if (touch)
pos = touch->grab_pos;
pos.c = weston_coord_add(pos.c, drag->offset.c);
weston_view_set_position(drag->icon, pos);
weston_view_set_position_with_offset(drag->icon, pos, drag->offset);
}
static int
......@@ -621,10 +620,9 @@ drag_grab_motion(struct weston_pointer_grab *grab,
weston_pointer_move(pointer, event);
if (drag->base.icon) {
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_set_position_with_offset(drag->base.icon,
pointer->pos,
drag->base.offset);
}
if (drag->base.focus_resource) {
......@@ -755,7 +753,7 @@ static const struct weston_pointer_grab_interface pointer_drag_grab_interface =
static void
drag_grab_touch_down(struct weston_touch_grab *grab,
const struct timespec *time, int touch_id,
wl_fixed_t sx, wl_fixed_t sy)
struct weston_coord_global c)
{
}
......@@ -803,7 +801,7 @@ drag_grab_touch_focus(struct weston_touch_drag *drag)
static void
drag_grab_touch_motion(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id, wl_fixed_t x, wl_fixed_t y)
int touch_id, struct weston_coord_global unused)
{
struct weston_touch_drag *touch_drag =
container_of(grab, struct weston_touch_drag, grab);
......@@ -814,13 +812,10 @@ drag_grab_touch_motion(struct weston_touch_grab *grab,
return;
drag_grab_touch_focus(touch_drag);
if (touch_drag->base.icon) {
struct weston_coord_global pos;
pos.c = weston_coord_add(touch_drag->base.offset.c,
touch->grab_pos.c);
weston_view_set_position(touch_drag->base.icon, pos);
}
if (touch_drag->base.icon)
weston_view_set_position_with_offset(touch_drag->base.icon,
touch->grab_pos,
touch_drag->base.offset);
if (touch_drag->base.focus_resource) {
struct weston_coord_surface surf_pos;
......
......@@ -49,12 +49,12 @@ weston_desktop_api_surface_removed(struct weston_desktop *desktop,
void
weston_desktop_api_committed(struct weston_desktop *desktop,
struct weston_desktop_surface *surface,
int32_t sx, int32_t sy);
struct weston_coord_surface buf_offset);
void
weston_desktop_api_show_window_menu(struct weston_desktop *desktop,
struct weston_desktop_surface *surface,
struct weston_seat *seat,
int32_t x, int32_t y);
struct weston_coord_surface offset);
void
weston_desktop_api_set_parent(struct weston_desktop *desktop,
struct weston_desktop_surface *surface,
......@@ -84,7 +84,7 @@ weston_desktop_api_minimized_requested(struct weston_desktop *desktop,
void
weston_desktop_api_set_xwayland_position(struct weston_desktop *desktop,
struct weston_desktop_surface *surface,
int32_t x, int32_t y);
struct weston_coord_global pos);
void
weston_desktop_api_get_position(struct weston_desktop *desktop,
......@@ -108,7 +108,7 @@ struct weston_desktop_surface_implementation {
void (*set_orientation)(struct weston_desktop_surface *surface,
void *user_data, enum weston_top_level_tiled_orientation tiled_orientation);
void (*committed)(struct weston_desktop_surface *surface, void *user_data,
int32_t sx, int32_t sy);
struct weston_coord_surface buf_offset);
void (*update_position)(struct weston_desktop_surface *surface,
void *user_data);
void (*ping)(struct weston_desktop_surface *surface, uint32_t serial,
......@@ -213,7 +213,7 @@ weston_desktop_surface_set_geometry(struct weston_desktop_surface *surface,
void
weston_desktop_surface_set_relative_to(struct weston_desktop_surface *surface,
struct weston_desktop_surface *parent,
int32_t x, int32_t y, bool use_geometry);
struct weston_coord_surface offset, bool use_geometry);
void
weston_desktop_surface_unset_relative_to(struct weston_desktop_surface *surface);
void
......
......@@ -153,20 +153,20 @@ weston_desktop_api_surface_removed(struct weston_desktop *desktop,
void
weston_desktop_api_committed(struct weston_desktop *desktop,
struct weston_desktop_surface *surface,
int32_t sx, int32_t sy)
struct weston_coord_surface buf_offset)
{
if (desktop->api.committed != NULL)
desktop->api.committed(surface, sx, sy, desktop->user_data);
desktop->api.committed(surface, buf_offset, desktop->user_data);
}
void
weston_desktop_api_show_window_menu(struct weston_desktop *desktop,
struct weston_desktop_surface *surface,
struct weston_seat *seat,
int32_t x, int32_t y)
struct weston_coord_surface offset)
{
if (desktop->api.show_window_menu != NULL)
desktop->api.show_window_menu(surface, seat, x, y,
desktop->api.show_window_menu(surface, seat, offset,
desktop->user_data);
}
......@@ -267,10 +267,10 @@ weston_desktop_minimize_supported(struct weston_desktop *desktop)
void
weston_desktop_api_set_xwayland_position(struct weston_desktop *desktop,
struct weston_desktop_surface *surface,
int32_t x, int32_t y)
struct weston_coord_global pos)
{
if (desktop->api.set_xwayland_position != NULL)
desktop->api.set_xwayland_position(surface, x, y,
desktop->api.set_xwayland_position(surface, pos,
desktop->user_data);
}
......
......@@ -190,11 +190,8 @@ static void
weston_desktop_seat_popup_grab_touch_down(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id,
wl_fixed_t sx, wl_fixed_t sy)
struct weston_coord_global pos)
{
struct weston_coord_global pos;
pos.c = weston_coord_from_fixed(sx, sy);
weston_touch_send_down(grab->touch, time, touch_id, pos);
}
......@@ -210,11 +207,8 @@ static void
weston_desktop_seat_popup_grab_touch_motion(struct weston_touch_grab *grab,
const struct timespec *time,
int touch_id,
wl_fixed_t sx, wl_fixed_t sy)
struct weston_coord_global pos)
{
struct weston_coord_global pos;
pos.c = weston_coord_from_fixed(sx, sy);
weston_touch_send_motion(grab->touch, time, touch_id, pos);
}
......
......@@ -189,11 +189,11 @@ weston_desktop_surface_surface_committed(struct wl_listener *listener,
wl_container_of(listener, surface, surface_commit_listener);
struct weston_surface *wsurface = surface->surface;
if (surface->implementation->committed != NULL)
if (surface->implementation->committed != NULL) {
surface->implementation->committed(surface,
surface->implementation_data,
surface->buffer_move.c.x,
surface->buffer_move.c.y);
surface->buffer_move);
}
if (surface->parent != NULL) {
struct weston_desktop_view *view;
......@@ -789,15 +789,14 @@ weston_desktop_surface_set_geometry(struct weston_desktop_surface *surface,
void
weston_desktop_surface_set_relative_to(struct weston_desktop_surface *surface,
struct weston_desktop_surface *parent,
int32_t x, int32_t y, bool use_geometry)
struct weston_coord_surface offset, bool use_geometry)
{
struct weston_desktop_view *view, *parent_view;
struct wl_list *link, *tmp;
assert(parent);
surface->pos_offset.x = x;
surface->pos_offset.y = y;
surface->pos_offset = offset.c;
surface->use_geometry = use_geometry;
if (surface->parent == parent)
......
......@@ -369,6 +369,8 @@ weston_desktop_xdg_toplevel_protocol_show_window_menu(struct wl_client *wl_clien
wl_resource_get_user_data(seat_resource);
struct weston_desktop_xdg_toplevel *toplevel =
weston_desktop_surface_get_implementation_data(dsurface);
struct weston_surface *wsurface;
struct weston_coord_surface offset;
if (!toplevel->base.configured) {
wl_resource_post_error(toplevel->resource,
......@@ -379,9 +381,10 @@ weston_desktop_xdg_toplevel_protocol_show_window_menu(struct wl_client *wl_clien
if (seat == NULL)
return;
wsurface = weston_desktop_surface_get_surface(dsurface);
offset = weston_coord_surface(x, y, wsurface);
weston_desktop_api_show_window_menu(toplevel->base.desktop,
dsurface, seat, x, y);
dsurface, seat, offset);
}
static void
......@@ -643,7 +646,7 @@ weston_desktop_xdg_toplevel_set_size(struct weston_desktop_surface *dsurface,
static void
weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplevel,
int32_t sx, int32_t sy)
struct weston_coord_surface buf_offset)
{
struct weston_surface *wsurface =
weston_desktop_surface_get_surface(toplevel->base.desktop_surface);
......@@ -656,7 +659,7 @@ weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplev
if (!weston_surface_has_content(wsurface)) {
if (weston_surface_is_unmapping(wsurface))
weston_desktop_api_committed(toplevel->base.desktop,
toplevel->base.desktop_surface, sx, sy);
toplevel->base.desktop_surface, buf_offset);
return;
}
......@@ -683,7 +686,7 @@ weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplev
weston_desktop_api_committed(toplevel->base.desktop,
toplevel->base.desktop_surface,
sx, sy);
buf_offset);
}
static void
......@@ -1110,6 +1113,7 @@ weston_desktop_xdg_surface_protocol_get_popup(struct wl_client *wl_client,
weston_desktop_surface_get_implementation_data(parent_surface);
struct weston_desktop_xdg_positioner *positioner =
wl_resource_get_user_data(positioner_resource);
struct weston_coord_surface offset;
/* Checking whether the size and anchor rect both have a positive size
* is enough to verify both have been correctly set */
......@@ -1140,10 +1144,12 @@ weston_desktop_xdg_surface_protocol_get_popup(struct wl_client *wl_client,
dsurface,
parent_surface);
offset = weston_coord_surface(popup->geometry.x,
popup->geometry.y,
popup->parent->surface);
weston_desktop_surface_set_relative_to(popup->base.desktop_surface,
parent_surface,
popup->geometry.x,
popup->geometry.y,
offset,
true);
}
......@@ -1256,7 +1262,7 @@ weston_desktop_xdg_surface_ping(struct weston_desktop_surface *dsurface,
static void
weston_desktop_xdg_surface_committed(struct weston_desktop_surface *dsurface,
void *user_data,
int32_t sx, int32_t sy)
struct weston_coord_surface buf_offset)
{
struct weston_desktop_xdg_surface *surface = user_data;
struct weston_surface *wsurface =
......@@ -1282,7 +1288,8 @@ weston_desktop_xdg_surface_committed(struct weston_desktop_surface *dsurface,
"xdg_surface must have a role");
break;
case WESTON_DESKTOP_XDG_SURFACE_ROLE_TOPLEVEL:
weston_desktop_xdg_toplevel_committed((struct weston_desktop_xdg_toplevel *) surface, sx, sy);
weston_desktop_xdg_toplevel_committed((struct weston_desktop_xdg_toplevel *) surface,
buf_offset);
break;
case WESTON_DESKTOP_XDG_SURFACE_ROLE_POPUP:
weston_desktop_xdg_popup_committed((struct weston_desktop_xdg_popup *) surface);
......
......@@ -418,6 +418,8 @@ weston_desktop_xdg_toplevel_protocol_show_window_menu(struct wl_client *wl_clien
wl_resource_get_user_data(seat_resource);
struct weston_desktop_xdg_toplevel *toplevel =
weston_desktop_surface_get_implementation_data(dsurface);
struct weston_surface *wsurface;
struct weston_coord_surface offset;
if (!toplevel->base.configured) {
wl_resource_post_error(toplevel->resource,
......@@ -429,8 +431,10 @@ weston_desktop_xdg_toplevel_protocol_show_window_menu(struct wl_client *wl_clien
if (seat == NULL)
return;
wsurface = weston_desktop_surface_get_surface(dsurface);
offset = weston_coord_surface(x, y, wsurface);
weston_desktop_api_show_window_menu(toplevel->base.desktop,
dsurface, seat, x, y);
dsurface, seat, offset);
}
static void
......@@ -726,7 +730,7 @@ weston_desktop_xdg_toplevel_set_orientation(struct weston_desktop_surface *surfa
static void
weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplevel,
int32_t sx, int32_t sy)
struct weston_coord_surface buf_offset)
{
struct weston_surface *wsurface =
weston_desktop_surface_get_surface(toplevel->base.desktop_surface);
......@@ -739,7 +743,7 @@ weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplev
if (!weston_surface_has_content(wsurface)) {
if (weston_surface_is_unmapping(wsurface))
weston_desktop_api_committed(toplevel->base.desktop,
toplevel->base.desktop_surface, sx, sy);
toplevel->base.desktop_surface, buf_offset);
return;
}
......@@ -788,7 +792,7 @@ weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplev
weston_desktop_api_committed(toplevel->base.desktop,
toplevel->base.desktop_surface,
sx, sy);
buf_offset);
}
static void
......@@ -1059,12 +1063,15 @@ weston_desktop_xdg_popup_update_position(struct weston_desktop_surface *dsurface
struct weston_desktop_xdg_popup *popup =
weston_desktop_surface_get_implementation_data(dsurface);
struct weston_desktop_surface *parent_dsurface;
struct weston_coord_surface offset;
parent_dsurface = popup->parent->desktop_surface;
offset = weston_coord_surface(popup->geometry.x,
popup->geometry.y,
popup->parent->surface);
weston_desktop_surface_set_relative_to(popup->base.desktop_surface,
parent_dsurface,
popup->geometry.x,
popup->geometry.y,
offset,
true);
}
......@@ -1308,6 +1315,7 @@ weston_desktop_xdg_surface_protocol_get_popup(struct wl_client *wl_client,
struct weston_desktop_xdg_surface *parent;
struct weston_desktop_xdg_positioner *positioner =
wl_resource_get_user_data(positioner_resource);
struct weston_coord_surface offset;
/* Popup parents are allowed to be non-null, but only if a parent is
* specified 'using some other protocol' before committing. Since we
......@@ -1350,10 +1358,12 @@ weston_desktop_xdg_surface_protocol_get_popup(struct wl_client *wl_client,
dsurface,
parent_surface);
offset = weston_coord_surface(popup->geometry.x,
popup->geometry.y,
popup->parent->surface);
weston_desktop_surface_set_relative_to(popup->base.desktop_surface,
parent_surface,
popup->geometry.x,
popup->geometry.y,
offset,
true);
}
......@@ -1466,7 +1476,7 @@ weston_desktop_xdg_surface_ping(struct weston_desktop_surface *dsurface,
static void
weston_desktop_xdg_surface_committed(struct weston_desktop_surface *dsurface,
void *user_data,
int32_t sx, int32_t sy)
struct weston_coord_surface c)
{
struct weston_desktop_xdg_surface *surface = user_data;
struct weston_surface *wsurface =
......@@ -1492,7 +1502,7 @@ weston_desktop_xdg_surface_committed(struct weston_desktop_surface *dsurface,
"xdg_surface must have a role");
break;
case WESTON_DESKTOP_XDG_SURFACE_ROLE_TOPLEVEL:
weston_desktop_xdg_toplevel_committed((struct weston_desktop_xdg_toplevel *) surface, sx, sy);
weston_desktop_xdg_toplevel_committed((struct weston_desktop_xdg_toplevel *) surface, c);
break;
case WESTON_DESKTOP_XDG_SURFACE_ROLE_POPUP:
weston_desktop_xdg_popup_committed((struct weston_desktop_xdg_popup *) surface);
......
......@@ -103,6 +103,9 @@ weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surf
}
if (to_add) {
struct weston_coord_surface zero;
zero = weston_coord_surface(0, 0, wsurface);
weston_desktop_surface_unset_relative_to(surface->surface);
weston_desktop_api_surface_added(surface->desktop,
surface->surface);
......@@ -113,7 +116,7 @@ weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surf
* surface */
weston_desktop_api_committed(surface->desktop,
surface->surface,
0, 0);
zero);
} else if (surface->added) {
weston_desktop_api_surface_removed(surface->desktop,
......@@ -147,18 +150,18 @@ weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surf
psurface = weston_desktop_surface_get_surface(parent);
assert(offset->coordinate_space_id == psurface);
weston_desktop_surface_set_relative_to(surface->surface, parent,
offset->c.x,
offset->c.y, false);
*offset, false);
}
}
static void
weston_desktop_xwayland_surface_committed(struct weston_desktop_surface *dsurface,
void *user_data,
int32_t sx, int32_t sy)
struct weston_coord_surface buf_offset)
{
struct weston_desktop_xwayland_surface *surface = user_data;
struct weston_geometry oldgeom;
struct weston_coord_surface tmp;
assert(dsurface == surface->surface);
surface->committed = true;
......@@ -167,6 +170,7 @@ weston_desktop_xwayland_surface_committed(struct weston_desktop_surface *dsurfac
weston_log("%s: xwayland surface %p\n", __func__, surface);
#endif
tmp = buf_offset;
if (surface->has_next_geometry) {
oldgeom = weston_desktop_surface_get_geometry(surface->surface);
/* If we're transitioning away from fullscreen or maximized
......@@ -175,8 +179,8 @@ weston_desktop_xwayland_surface_committed(struct weston_desktop_surface *dsurfac
* the geometry in those cases.
*/
if (surface->state == surface->prev_state) {
sx -= surface->next_geometry.x - oldgeom.x;
sy -= surface->next_geometry.y - oldgeom.y;
tmp.c.x -= surface->next_geometry.x - oldgeom.x;
tmp.c.y -= surface->next_geometry.y - oldgeom.y;
}
surface->prev_state = surface->state;
......@@ -187,7 +191,7 @@ weston_desktop_xwayland_surface_committed(struct weston_desktop_surface *dsurfac
if (surface->added)
weston_desktop_api_committed(surface->desktop, surface->surface,
sx, sy);
tmp);
/* If we're an override redirect window, the shell has no knowledge of
* our existence, so it won't assign us an output.
......@@ -350,8 +354,7 @@ set_toplevel_with_position(struct weston_desktop_xwayland_surface *surface,
{
set_toplevel(surface);
weston_desktop_api_set_xwayland_position(surface->desktop,
surface->surface,
pos.c.x, pos.c.y);
surface->surface, pos);
}
static void
......