mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-08 14:35:59 +01:00
Merge pull request #1416 from kragniz/rootston-use-box
rootston: use box for views position
This commit is contained in:
commit
8cb4df2a30
10 changed files with 91 additions and 92 deletions
|
@ -99,8 +99,8 @@ void view_destroy(struct roots_view *view);
|
|||
void view_activate(struct roots_view *view, bool activate);
|
||||
void view_apply_damage(struct roots_view *view);
|
||||
void view_damage_whole(struct roots_view *view);
|
||||
void view_update_position(struct roots_view *view, double x, double y);
|
||||
void view_update_size(struct roots_view *view, uint32_t width, uint32_t height);
|
||||
void view_update_position(struct roots_view *view, int x, int y);
|
||||
void view_update_size(struct roots_view *view, int width, int height);
|
||||
void view_update_decorated(struct roots_view *view, bool decorated);
|
||||
void view_initial_focus(struct roots_view *view);
|
||||
void view_map(struct roots_view *view, struct wlr_surface *surface);
|
||||
|
|
|
@ -88,8 +88,7 @@ struct roots_view {
|
|||
struct roots_desktop *desktop;
|
||||
struct wl_list link; // roots_desktop::views
|
||||
|
||||
double x, y;
|
||||
uint32_t width, height;
|
||||
struct wlr_box box;
|
||||
float rotation;
|
||||
float alpha;
|
||||
|
||||
|
|
|
@ -190,8 +190,8 @@ void roots_cursor_update_position(struct roots_cursor *cursor,
|
|||
if (view != NULL) {
|
||||
double dx = cursor->cursor->x - cursor->offs_x;
|
||||
double dy = cursor->cursor->y - cursor->offs_y;
|
||||
double x = view->x;
|
||||
double y = view->y;
|
||||
double x = view->box.x;
|
||||
double y = view->box.y;
|
||||
int width = cursor->view_width;
|
||||
int height = cursor->view_height;
|
||||
if (cursor->resize_edges & WLR_EDGE_TOP) {
|
||||
|
@ -220,8 +220,8 @@ void roots_cursor_update_position(struct roots_cursor *cursor,
|
|||
case ROOTS_CURSOR_ROTATE:
|
||||
view = roots_seat_get_focus(seat);
|
||||
if (view != NULL) {
|
||||
int ox = view->x + view->wlr_surface->current.width/2,
|
||||
oy = view->y + view->wlr_surface->current.height/2;
|
||||
int ox = view->box.x + view->wlr_surface->current.width/2,
|
||||
oy = view->box.y + view->wlr_surface->current.height/2;
|
||||
int ux = cursor->offs_x - ox,
|
||||
uy = cursor->offs_y - oy;
|
||||
int vx = cursor->cursor->x - ox,
|
||||
|
@ -322,11 +322,11 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor,
|
|||
double lx2 = lx1 + dx;
|
||||
double ly2 = ly1 + dy;
|
||||
|
||||
double sx1 = lx1 - view->x;
|
||||
double sy1 = ly1 - view->y;
|
||||
double sx1 = lx1 - view->box.x;
|
||||
double sy1 = ly1 - view->box.y;
|
||||
|
||||
double sx2 = lx2 - view->x;
|
||||
double sy2 = ly2 - view->y;
|
||||
double sx2 = lx2 - view->box.x;
|
||||
double sy2 = ly2 - view->box.y;
|
||||
|
||||
double sx2_confined, sy2_confined;
|
||||
if (!wlr_region_confine(&cursor->confine, sx1, sy1, sx2, sy2,
|
||||
|
@ -354,7 +354,7 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor,
|
|||
|
||||
if (cursor->active_constraint &&
|
||||
!pixman_region32_contains_point(&cursor->confine,
|
||||
floor(lx - view->x), floor(ly - view->y), NULL)) {
|
||||
floor(lx - view->box.x), floor(ly - view->box.y), NULL)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ void roots_cursor_handle_tool_axis(struct roots_cursor *cursor,
|
|||
|
||||
if (cursor->active_constraint &&
|
||||
!pixman_region32_contains_point(&cursor->confine,
|
||||
floor(lx - view->x), floor(ly - view->y), NULL)) {
|
||||
floor(lx - view->box.x), floor(ly - view->box.y), NULL)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -598,11 +598,11 @@ void roots_cursor_constrain(struct roots_cursor *cursor,
|
|||
double sx = (boxes[0].x1 + boxes[0].x2) / 2.;
|
||||
double sy = (boxes[0].y1 + boxes[0].y2) / 2.;
|
||||
|
||||
rotate_child_position(&sx, &sy, 0, 0, view->width, view->height,
|
||||
rotate_child_position(&sx, &sy, 0, 0, view->box.width, view->box.height,
|
||||
view->rotation);
|
||||
|
||||
double lx = view->x + sx;
|
||||
double ly = view->y + sy;
|
||||
double lx = view->box.x + sx;
|
||||
double ly = view->box.y + sy;
|
||||
|
||||
wlr_cursor_warp_closest(cursor->cursor, NULL, lx, ly);
|
||||
}
|
||||
|
|
|
@ -48,10 +48,10 @@ struct roots_view *view_create(struct roots_desktop *desktop) {
|
|||
}
|
||||
|
||||
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
|
||||
box->x = view->x;
|
||||
box->y = view->y;
|
||||
box->width = view->width;
|
||||
box->height = view->height;
|
||||
box->x = view->box.x;
|
||||
box->y = view->box.y;
|
||||
box->width = view->box.width;
|
||||
box->height = view->box.height;
|
||||
}
|
||||
|
||||
void view_get_deco_box(const struct roots_view *view, struct wlr_box *box) {
|
||||
|
@ -131,7 +131,7 @@ static void view_update_output(const struct roots_view *view,
|
|||
}
|
||||
|
||||
void view_move(struct roots_view *view, double x, double y) {
|
||||
if (view->x == x && view->y == y) {
|
||||
if (view->box.x == x && view->box.y == y) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,8 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
|||
|
||||
void view_move_resize(struct roots_view *view, double x, double y,
|
||||
uint32_t width, uint32_t height) {
|
||||
bool update_x = x != view->x;
|
||||
bool update_y = y != view->y;
|
||||
bool update_x = x != view->box.x;
|
||||
bool update_y = y != view->box.y;
|
||||
if (!update_x && !update_y) {
|
||||
view_resize(view, width, height);
|
||||
return;
|
||||
|
@ -190,8 +190,8 @@ static struct wlr_output *view_get_output(struct roots_view *view) {
|
|||
|
||||
double output_x, output_y;
|
||||
wlr_output_layout_closest_point(view->desktop->layout, NULL,
|
||||
view->x + (double)view_box.width/2,
|
||||
view->y + (double)view_box.height/2,
|
||||
view->box.x + (double)view_box.width/2,
|
||||
view->box.y + (double)view_box.height/2,
|
||||
&output_x, &output_y);
|
||||
return wlr_output_layout_output_at(view->desktop->layout, output_x,
|
||||
output_y);
|
||||
|
@ -227,11 +227,11 @@ void view_maximize(struct roots_view *view, bool maximized) {
|
|||
|
||||
if (!view->maximized && maximized) {
|
||||
view->maximized = true;
|
||||
view->saved.x = view->x;
|
||||
view->saved.y = view->y;
|
||||
view->saved.x = view->box.x;
|
||||
view->saved.y = view->box.y;
|
||||
view->saved.rotation = view->rotation;
|
||||
view->saved.width = view->width;
|
||||
view->saved.height = view->height;
|
||||
view->saved.width = view->box.width;
|
||||
view->saved.height = view->box.height;
|
||||
|
||||
view_arrange_maximized(view);
|
||||
}
|
||||
|
@ -272,8 +272,8 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen,
|
|||
struct wlr_box view_box;
|
||||
view_get_box(view, &view_box);
|
||||
|
||||
view->saved.x = view->x;
|
||||
view->saved.y = view->y;
|
||||
view->saved.x = view->box.x;
|
||||
view->saved.y = view->box.y;
|
||||
view->saved.rotation = view->rotation;
|
||||
view->saved.width = view_box.width;
|
||||
view->saved.height = view_box.height;
|
||||
|
@ -500,7 +500,7 @@ void view_unmap(struct roots_view *view) {
|
|||
}
|
||||
|
||||
view->wlr_surface = NULL;
|
||||
view->width = view->height = 0;
|
||||
view->box.width = view->box.height = 0;
|
||||
}
|
||||
|
||||
void view_initial_focus(struct roots_view *view) {
|
||||
|
@ -536,25 +536,25 @@ void view_damage_whole(struct roots_view *view) {
|
|||
}
|
||||
}
|
||||
|
||||
void view_update_position(struct roots_view *view, double x, double y) {
|
||||
if (view->x == x && view->y == y) {
|
||||
void view_update_position(struct roots_view *view, int x, int y) {
|
||||
if (view->box.x == x && view->box.y == y) {
|
||||
return;
|
||||
}
|
||||
|
||||
view_damage_whole(view);
|
||||
view->x = x;
|
||||
view->y = y;
|
||||
view->box.x = x;
|
||||
view->box.y = y;
|
||||
view_damage_whole(view);
|
||||
}
|
||||
|
||||
void view_update_size(struct roots_view *view, uint32_t width, uint32_t height) {
|
||||
if (view->width == width && view->height == height) {
|
||||
void view_update_size(struct roots_view *view, int width, int height) {
|
||||
if (view->box.width == width && view->box.height == height) {
|
||||
return;
|
||||
}
|
||||
|
||||
view_damage_whole(view);
|
||||
view->width = width;
|
||||
view->height = height;
|
||||
view->box.width = width;
|
||||
view->box.height = height;
|
||||
view_damage_whole(view);
|
||||
}
|
||||
|
||||
|
@ -585,8 +585,8 @@ static bool view_at(struct roots_view *view, double lx, double ly,
|
|||
return false;
|
||||
}
|
||||
|
||||
double view_sx = lx - view->x;
|
||||
double view_sy = ly - view->y;
|
||||
double view_sx = lx - view->box.x;
|
||||
double view_sy = ly - view->box.y;
|
||||
|
||||
struct wlr_surface_state *state = &view->wlr_surface->current;
|
||||
struct wlr_box box = {
|
||||
|
@ -806,10 +806,10 @@ static void handle_constraint_destroy(struct wl_listener *listener,
|
|||
double sy = wlr_constraint->current.cursor_hint.y;
|
||||
|
||||
struct roots_view *view = seat->cursor->pointer_view->view;
|
||||
rotate_child_position(&sx, &sy, 0, 0, view->width, view->height,
|
||||
rotate_child_position(&sx, &sy, 0, 0, view->box.width, view->box.height,
|
||||
view->rotation);
|
||||
double lx = view->x + sx;
|
||||
double ly = view->y + sy;
|
||||
double lx = view->box.x + sx;
|
||||
double ly = view->box.y + sy;
|
||||
|
||||
wlr_cursor_warp(seat->cursor->cursor, NULL, lx, ly);
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ static void surface_for_each_surface(struct wlr_surface *surface,
|
|||
static void view_for_each_surface(struct roots_view *view,
|
||||
struct layout_data *layout_data, wlr_surface_iterator_func_t iterator,
|
||||
void *user_data) {
|
||||
layout_data->x = view->x;
|
||||
layout_data->y = view->y;
|
||||
layout_data->x = view->box.x;
|
||||
layout_data->y = view->box.y;
|
||||
layout_data->width = view->wlr_surface->current.width;
|
||||
layout_data->height = view->wlr_surface->current.height;
|
||||
layout_data->rotation = view->rotation;
|
||||
|
@ -304,13 +304,13 @@ static void get_decoration_box(struct roots_view *view,
|
|||
|
||||
struct wlr_box deco_box;
|
||||
view_get_deco_box(view, &deco_box);
|
||||
double sx = deco_box.x - view->x;
|
||||
double sy = deco_box.y - view->y;
|
||||
double sx = deco_box.x - view->box.x;
|
||||
double sy = deco_box.y - view->box.y;
|
||||
rotate_child_position(&sx, &sy, deco_box.width, deco_box.height,
|
||||
view->wlr_surface->current.width,
|
||||
view->wlr_surface->current.height, view->rotation);
|
||||
double x = sx + view->x;
|
||||
double y = sy + view->y;
|
||||
double x = sx + view->box.x;
|
||||
double y = sy + view->box.y;
|
||||
|
||||
wlr_output_layout_output_coords(output->desktop->layout, wlr_output, &x, &y);
|
||||
|
||||
|
|
|
@ -1341,8 +1341,8 @@ void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) {
|
|||
cursor->view_x = view->saved.x;
|
||||
cursor->view_y = view->saved.y;
|
||||
} else {
|
||||
cursor->view_x = view->x;
|
||||
cursor->view_y = view->y;
|
||||
cursor->view_x = view->box.x;
|
||||
cursor->view_y = view->box.y;
|
||||
}
|
||||
view_maximize(view, false);
|
||||
wlr_seat_pointer_clear_focus(seat->seat);
|
||||
|
@ -1363,8 +1363,8 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view,
|
|||
cursor->view_width = view->saved.width;
|
||||
cursor->view_height = view->saved.height;
|
||||
} else {
|
||||
cursor->view_x = view->x;
|
||||
cursor->view_y = view->y;
|
||||
cursor->view_x = view->box.x;
|
||||
cursor->view_y = view->box.y;
|
||||
struct wlr_box box;
|
||||
view_get_box(view, &box);
|
||||
cursor->view_width = box.width;
|
||||
|
|
|
@ -162,8 +162,8 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
|||
int height = wlr_surface->current.height;
|
||||
view_update_size(view, width, height);
|
||||
|
||||
double x = view->x;
|
||||
double y = view->y;
|
||||
double x = view->box.x;
|
||||
double y = view->box.y;
|
||||
if (view->pending_move_resize.update_x) {
|
||||
x = view->pending_move_resize.x + view->pending_move_resize.width -
|
||||
width;
|
||||
|
@ -236,8 +236,8 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
view->type = ROOTS_WL_SHELL_VIEW;
|
||||
view->width = surface->surface->current.width;
|
||||
view->height = surface->surface->current.height;
|
||||
view->box.width = surface->surface->current.width;
|
||||
view->box.height = surface->surface->current.height;
|
||||
|
||||
view->wl_shell_surface = surface;
|
||||
view->roots_wl_shell_surface = roots_surface;
|
||||
|
@ -262,8 +262,8 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
if (found) {
|
||||
view_move(view,
|
||||
parent->x + surface->transient_state->x,
|
||||
parent->y + surface->transient_state->y);
|
||||
parent->box.x + surface->transient_state->x,
|
||||
parent->box.y + surface->transient_state->y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ static void popup_unconstrain(struct roots_xdg_popup *popup) {
|
|||
int popup_lx, popup_ly;
|
||||
wlr_xdg_popup_get_toplevel_coords(wlr_popup, wlr_popup->geometry.x,
|
||||
wlr_popup->geometry.y, &popup_lx, &popup_ly);
|
||||
popup_lx += view->x;
|
||||
popup_ly += view->y;
|
||||
popup_lx += view->box.x;
|
||||
popup_ly += view->box.y;
|
||||
|
||||
anchor_lx += popup_lx;
|
||||
anchor_ly += popup_ly;
|
||||
|
@ -95,8 +95,8 @@ static void popup_unconstrain(struct roots_xdg_popup *popup) {
|
|||
// the output box expressed in the coordinate system of the toplevel parent
|
||||
// of the popup
|
||||
struct wlr_box output_toplevel_sx_box = {
|
||||
.x = output->lx - view->x,
|
||||
.y = output->ly - view->y,
|
||||
.x = output->lx - view->box.x,
|
||||
.y = output->ly - view->box.y,
|
||||
.width = width,
|
||||
.height = height
|
||||
};
|
||||
|
@ -193,8 +193,8 @@ static void move_resize(struct roots_view *view, double x, double y,
|
|||
return;
|
||||
}
|
||||
|
||||
bool update_x = x != view->x;
|
||||
bool update_y = y != view->y;
|
||||
bool update_x = x != view->box.x;
|
||||
bool update_y = y != view->box.y;
|
||||
|
||||
uint32_t constrained_width, constrained_height;
|
||||
apply_size_constraints(surface, width, height, &constrained_width,
|
||||
|
@ -345,8 +345,8 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
|||
uint32_t pending_serial =
|
||||
roots_surface->pending_move_resize_configure_serial;
|
||||
if (pending_serial > 0 && pending_serial >= surface->configure_serial) {
|
||||
double x = view->x;
|
||||
double y = view->y;
|
||||
double x = view->box.x;
|
||||
double y = view->box.y;
|
||||
if (view->pending_move_resize.update_x) {
|
||||
x = view->pending_move_resize.x + view->pending_move_resize.width -
|
||||
size.width;
|
||||
|
@ -377,8 +377,8 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_box box;
|
||||
get_size(view, &box);
|
||||
view->width = box.width;
|
||||
view->height = box.height;
|
||||
view->box.width = box.width;
|
||||
view->box.height = box.height;
|
||||
|
||||
view_map(view, view->xdg_surface->surface);
|
||||
view_setup(view);
|
||||
|
|
|
@ -73,8 +73,8 @@ static void popup_unconstrain(struct roots_xdg_popup_v6 *popup) {
|
|||
int popup_lx, popup_ly;
|
||||
wlr_xdg_popup_v6_get_toplevel_coords(wlr_popup, wlr_popup->geometry.x,
|
||||
wlr_popup->geometry.y, &popup_lx, &popup_ly);
|
||||
popup_lx += view->x;
|
||||
popup_ly += view->y;
|
||||
popup_lx += view->box.x;
|
||||
popup_ly += view->box.y;
|
||||
|
||||
anchor_lx += popup_lx;
|
||||
anchor_ly += popup_ly;
|
||||
|
@ -96,8 +96,8 @@ static void popup_unconstrain(struct roots_xdg_popup_v6 *popup) {
|
|||
// the output box expressed in the coordinate system of the toplevel parent
|
||||
// of the popup
|
||||
struct wlr_box output_toplevel_sx_box = {
|
||||
.x = output->lx - view->x,
|
||||
.y = output->ly - view->y,
|
||||
.x = output->lx - view->box.x,
|
||||
.y = output->ly - view->box.y,
|
||||
.width = width,
|
||||
.height = height
|
||||
};
|
||||
|
@ -193,8 +193,8 @@ static void move_resize(struct roots_view *view, double x, double y,
|
|||
return;
|
||||
}
|
||||
|
||||
bool update_x = x != view->x;
|
||||
bool update_y = y != view->y;
|
||||
bool update_x = x != view->box.x;
|
||||
bool update_y = y != view->box.y;
|
||||
|
||||
uint32_t constrained_width, constrained_height;
|
||||
apply_size_constraints(surface, width, height, &constrained_width,
|
||||
|
@ -344,8 +344,8 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
|||
uint32_t pending_serial =
|
||||
roots_surface->pending_move_resize_configure_serial;
|
||||
if (pending_serial > 0 && pending_serial >= surface->configure_serial) {
|
||||
double x = view->x;
|
||||
double y = view->y;
|
||||
double x = view->box.x;
|
||||
double y = view->box.y;
|
||||
if (view->pending_move_resize.update_x) {
|
||||
x = view->pending_move_resize.x + view->pending_move_resize.width -
|
||||
size.width;
|
||||
|
@ -376,8 +376,8 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_box box;
|
||||
get_size(view, &box);
|
||||
view->width = box.width;
|
||||
view->height = box.height;
|
||||
view->box.width = box.width;
|
||||
view->box.height = box.height;
|
||||
|
||||
view_map(view, view->xdg_surface_v6->surface);
|
||||
view_setup(view);
|
||||
|
|
|
@ -64,8 +64,8 @@ static void move_resize(struct roots_view *view, double x, double y,
|
|||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
||||
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
|
||||
|
||||
bool update_x = x != view->x;
|
||||
bool update_y = y != view->y;
|
||||
bool update_x = x != view->box.x;
|
||||
bool update_y = y != view->box.y;
|
||||
|
||||
uint32_t constrained_width, constrained_height;
|
||||
apply_size_constraints(xwayland_surface, width, height, &constrained_width,
|
||||
|
@ -210,8 +210,8 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
|||
int height = wlr_surface->current.height;
|
||||
view_update_size(view, width, height);
|
||||
|
||||
double x = view->x;
|
||||
double y = view->y;
|
||||
double x = view->box.x;
|
||||
double y = view->box.y;
|
||||
if (view->pending_move_resize.update_x) {
|
||||
x = view->pending_move_resize.x + view->pending_move_resize.width -
|
||||
width;
|
||||
|
@ -231,10 +231,10 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
struct wlr_xwayland_surface *surface = data;
|
||||
struct roots_view *view = roots_surface->view;
|
||||
|
||||
view->x = surface->x;
|
||||
view->y = surface->y;
|
||||
view->width = surface->surface->current.width;
|
||||
view->height = surface->surface->current.height;
|
||||
view->box.x = surface->x;
|
||||
view->box.y = surface->y;
|
||||
view->box.width = surface->surface->current.width;
|
||||
view->box.height = surface->surface->current.height;
|
||||
|
||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||
wl_signal_add(&surface->surface->events.commit,
|
||||
|
@ -307,8 +307,8 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
view->type = ROOTS_XWAYLAND_VIEW;
|
||||
view->x = (double)surface->x;
|
||||
view->y = (double)surface->y;
|
||||
view->box.x = surface->x;
|
||||
view->box.y = surface->y;
|
||||
|
||||
view->xwayland_surface = surface;
|
||||
view->roots_xwayland_surface = roots_surface;
|
||||
|
|
Loading…
Reference in a new issue