view.c: fix coding style

This commit is contained in:
Johan Malm 2021-11-26 18:49:44 +00:00
parent 2bea203430
commit b7c326ec6f

View file

@ -44,15 +44,18 @@ view_min_size(struct view *view, int *w, int *h)
int min_width = MIN_VIEW_WIDTH; int min_width = MIN_VIEW_WIDTH;
int min_height = MIN_VIEW_HEIGHT; int min_height = MIN_VIEW_HEIGHT;
#if HAVE_XWAYLAND #if HAVE_XWAYLAND
if (view->type == LAB_XWAYLAND_VIEW) { if (view->type != LAB_XWAYLAND_VIEW) {
if (view->xwayland_surface->size_hints) { goto out;
if (view->xwayland_surface->size_hints->min_width > 0 || }
view->xwayland_surface->size_hints->min_height > 0) { if (!view->xwayland_surface->size_hints) {
goto out;
}
if (view->xwayland_surface->size_hints->min_width > 0
|| view->xwayland_surface->size_hints->min_height > 0) {
min_width = view->xwayland_surface->size_hints->min_width; min_width = view->xwayland_surface->size_hints->min_width;
min_height = view->xwayland_surface->size_hints->min_height; min_height = view->xwayland_surface->size_hints->min_height;
} }
} out:
}
#endif #endif
if (w) { if (w) {
@ -70,8 +73,8 @@ view_minimize(struct view *view, bool minimized)
return; return;
} }
if (view->toplevel_handle) { if (view->toplevel_handle) {
wlr_foreign_toplevel_handle_v1_set_minimized(view->toplevel_handle, wlr_foreign_toplevel_handle_v1_set_minimized(
minimized); view->toplevel_handle, minimized);
} }
view->minimized = minimized; view->minimized = minimized;
if (minimized) { if (minimized) {
@ -128,8 +131,8 @@ view_maximize(struct view *view, bool maximize)
view->impl->maximize(view, maximize); view->impl->maximize(view, maximize);
} }
if (view->toplevel_handle) { if (view->toplevel_handle) {
wlr_foreign_toplevel_handle_v1_set_maximized(view->toplevel_handle, wlr_foreign_toplevel_handle_v1_set_maximized(
maximize); view->toplevel_handle, maximize);
} }
if (maximize) { if (maximize) {
view->unmaximized_geometry.x = view->x; view->unmaximized_geometry.x = view->x;
@ -371,10 +374,14 @@ static enum view_edge
view_edge_invert(enum view_edge edge) view_edge_invert(enum view_edge edge)
{ {
switch (edge) { switch (edge) {
case VIEW_EDGE_LEFT: return VIEW_EDGE_RIGHT; case VIEW_EDGE_LEFT:
case VIEW_EDGE_RIGHT: return VIEW_EDGE_LEFT; return VIEW_EDGE_RIGHT;
case VIEW_EDGE_UP: return VIEW_EDGE_DOWN; case VIEW_EDGE_RIGHT:
case VIEW_EDGE_DOWN: return VIEW_EDGE_UP; return VIEW_EDGE_LEFT;
case VIEW_EDGE_UP:
return VIEW_EDGE_DOWN;
case VIEW_EDGE_DOWN:
return VIEW_EDGE_UP;
case VIEW_EDGE_CENTER: case VIEW_EDGE_CENTER:
case VIEW_EDGE_INVALID: case VIEW_EDGE_INVALID:
default: default:
@ -401,7 +408,8 @@ view_edge_parse(const char *direction)
} }
static struct wlr_box static struct wlr_box
view_get_edge_snap_box(struct view *view, struct output *output, enum view_edge edge) view_get_edge_snap_box(struct view *view, struct output *output,
enum view_edge edge)
{ {
struct border border = view_border(view); struct border border = view_border(view);
struct wlr_box usable = output_usable_area_in_layout_coords(output); struct wlr_box usable = output_usable_area_in_layout_coords(output);
@ -465,26 +473,40 @@ view_snap_to_edge(struct view *view, const char *direction)
struct wlr_box dst = view_get_edge_snap_box(view, output, edge); struct wlr_box dst = view_get_edge_snap_box(view, output, edge);
if (view->x == dst.x && view->y == dst.y && view->w == dst.width && view->h == dst.height) { if (view->x == dst.x && view->y == dst.y && view->w == dst.width
&& view->h == dst.height) {
/* Move over to the next screen if this is already snapped. */ /* Move over to the next screen if this is already snapped. */
struct wlr_box usable = output_usable_area_in_layout_coords(output); struct wlr_box usable =
output_usable_area_in_layout_coords(output);
switch (edge) { switch (edge) {
case VIEW_EDGE_LEFT: dst.x -= (usable.width / 2) + 1; break; case VIEW_EDGE_LEFT:
case VIEW_EDGE_RIGHT: dst.x += (usable.width / 2) + 1; break; dst.x -= (usable.width / 2) + 1;
case VIEW_EDGE_UP: dst.y -= (usable.height / 2) + 1; break; break;
case VIEW_EDGE_DOWN: dst.y += (usable.height / 2) + 1; break; case VIEW_EDGE_RIGHT:
default: break; dst.x += (usable.width / 2) + 1;
break;
case VIEW_EDGE_UP:
dst.y -= (usable.height / 2) + 1;
break;
case VIEW_EDGE_DOWN:
dst.y += (usable.height / 2) + 1;
break;
default:
break;
} }
struct wlr_output *new_wlr_output = wlr_output_layout_output_at(
view->server->output_layout, dst.x, dst.y);
struct output *new_output = struct output *new_output =
output_from_wlr_output(view->server, output_from_wlr_output(view->server, new_wlr_output);
wlr_output_layout_output_at(view->server->output_layout, dst.x, dst.y));
if (new_output == output || !new_output || edge == VIEW_EDGE_CENTER) { if (new_output == output || !new_output
|| edge == VIEW_EDGE_CENTER) {
return; return;
} }
dst = view_get_edge_snap_box(view, new_output, view_edge_invert(edge)); dst = view_get_edge_snap_box(view, new_output,
view_edge_invert(edge));
} }
view_move_resize(view, dst); view_move_resize(view, dst);