mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
xdg: use "usable_area" when positioning view
This commit is contained in:
parent
0eac290d54
commit
22f5073ebd
5 changed files with 34 additions and 35 deletions
|
|
@ -337,7 +337,8 @@ void output_damage_surface(struct output *output, struct wlr_surface *surface,
|
|||
void scale_box(struct wlr_box *box, float scale);
|
||||
void output_manager_init(struct server *server);
|
||||
struct output *output_from_wlr_output(struct server *server, struct wlr_output *wlr_output);
|
||||
struct wlr_box *output_box_from_cursor_coords(struct server *server);
|
||||
struct wlr_box output_usable_area_in_layout_coords(struct output *output);
|
||||
struct wlr_box output_usable_area_from_cursor_coords(struct server *server);
|
||||
|
||||
void damage_all_outputs(struct server *server);
|
||||
void damage_view_whole(struct view *view);
|
||||
|
|
|
|||
19
src/output.c
19
src/output.c
|
|
@ -1002,11 +1002,24 @@ output_from_wlr_output(struct server *server, struct wlr_output *wlr_output)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_box *
|
||||
output_box_from_cursor_coords(struct server *server)
|
||||
struct wlr_box
|
||||
output_usable_area_in_layout_coords(struct output *output)
|
||||
{
|
||||
struct wlr_box box = output->usable_area;
|
||||
double ox = 0, oy = 0;
|
||||
wlr_output_layout_output_coords(output->server->output_layout,
|
||||
output->wlr_output, &ox, &oy);
|
||||
box.x -= ox;
|
||||
box.y -= oy;
|
||||
return box;
|
||||
}
|
||||
|
||||
struct wlr_box
|
||||
output_usable_area_from_cursor_coords(struct server *server)
|
||||
{
|
||||
struct wlr_output *wlr_output;
|
||||
wlr_output = wlr_output_layout_output_at(server->output_layout,
|
||||
server->seat.cursor->x, server->seat.cursor->y);
|
||||
return wlr_output_layout_get_box(server->output_layout, wlr_output);
|
||||
struct output *output = output_from_wlr_output(server, wlr_output);
|
||||
return output_usable_area_in_layout_coords(output);
|
||||
}
|
||||
|
|
|
|||
29
src/view.c
29
src/view.c
|
|
@ -35,19 +35,12 @@ view_unminimize(struct view *view)
|
|||
view->impl->map(view);
|
||||
}
|
||||
|
||||
/*
|
||||
* view_wlr_output - return the output that a view is mostly on
|
||||
*/
|
||||
/* view_wlr_output - return the output that a view is mostly on */
|
||||
static struct wlr_output *
|
||||
view_wlr_output(struct view *view)
|
||||
{
|
||||
struct wlr_output_layout *layout = view->server->output_layout;
|
||||
struct wlr_output *output;
|
||||
|
||||
/* TODO: make this a bit more sophisticated */
|
||||
output = wlr_output_layout_output_at(layout, view->x + view->w / 2,
|
||||
view->y + view->h / 2);
|
||||
return output;
|
||||
return wlr_output_layout_output_at(view->server->output_layout,
|
||||
view->x + view->w / 2, view->y + view->h / 2);
|
||||
}
|
||||
|
||||
static struct output *
|
||||
|
|
@ -73,18 +66,6 @@ view_center(struct view *view)
|
|||
view_move(view, center_x - view->w / 2, center_y - view->h / 2);
|
||||
}
|
||||
|
||||
static struct wlr_box
|
||||
usable_area_in_layout_coords(struct output *output)
|
||||
{
|
||||
struct wlr_box box = output->usable_area;
|
||||
double ox = 0, oy = 0;
|
||||
wlr_output_layout_output_coords(output->server->output_layout,
|
||||
output->wlr_output, &ox, &oy);
|
||||
box.x -= ox;
|
||||
box.y -= oy;
|
||||
return box;
|
||||
}
|
||||
|
||||
void
|
||||
view_maximize(struct view *view, bool maximize)
|
||||
{
|
||||
|
|
@ -99,7 +80,7 @@ view_maximize(struct view *view, bool maximize)
|
|||
view->unmaximized_geometry.height = view->h;
|
||||
|
||||
struct output *output = view_output(view);
|
||||
struct wlr_box box = usable_area_in_layout_coords(output);
|
||||
struct wlr_box box = output_usable_area_in_layout_coords(output);
|
||||
|
||||
if (view->ssd.enabled) {
|
||||
struct border border = ssd_thickness(view);
|
||||
|
|
@ -158,7 +139,7 @@ view_move_to_edge(struct view *view, const char *direction)
|
|||
}
|
||||
struct output *output = view_output(view);
|
||||
struct border border = view_border(view);
|
||||
struct wlr_box usable = usable_area_in_layout_coords(output);
|
||||
struct wlr_box usable = output_usable_area_in_layout_coords(output);
|
||||
|
||||
int x, y;
|
||||
if (!strcasecmp(direction, "left")) {
|
||||
|
|
|
|||
12
src/xdg.c
12
src/xdg.c
|
|
@ -224,12 +224,14 @@ static void
|
|||
position_xdg_toplevel_view(struct view *view)
|
||||
{
|
||||
if (istopmost(view)) {
|
||||
struct wlr_box *box = output_box_from_cursor_coords(view->server);
|
||||
view->x = box->x;
|
||||
view->y = box->y;
|
||||
struct wlr_box box = output_usable_area_from_cursor_coords(view->server);
|
||||
view->x = box.x;
|
||||
view->y = box.y;
|
||||
view->w = view->xdg_surface->geometry.width;
|
||||
view->h = view->xdg_surface->geometry.height;
|
||||
view_center(view);
|
||||
if (view->w && view->h) {
|
||||
view_center(view);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* If child-toplevel-views, we center-align relative to their
|
||||
|
|
@ -263,6 +265,7 @@ xdg_toplevel_view_map(struct view *view)
|
|||
view->margin = ssd_thickness(view);
|
||||
ssd_create(view);
|
||||
}
|
||||
|
||||
update_padding(view);
|
||||
position_xdg_toplevel_view(view);
|
||||
|
||||
|
|
@ -275,6 +278,7 @@ xdg_toplevel_view_map(struct view *view)
|
|||
parent_link) {
|
||||
subsurface_create(view, subsurface);
|
||||
}
|
||||
|
||||
view->been_mapped = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,9 +159,9 @@ map(struct view *view)
|
|||
|
||||
if (!view->been_mapped) {
|
||||
view_maximize(view, false);
|
||||
struct wlr_box *box = output_box_from_cursor_coords(view->server);
|
||||
view->x = box->x;
|
||||
view->y = box->y;
|
||||
struct wlr_box box = output_usable_area_from_cursor_coords(view->server);
|
||||
view->x = box.x;
|
||||
view->y = box.y;
|
||||
view_center(view);
|
||||
view->been_mapped = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue