]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view.c: fix coding style
authorJohan Malm <jgm323@gmail.com>
Fri, 26 Nov 2021 18:49:44 +0000 (18:49 +0000)
committerJohan Malm <jgm323@gmail.com>
Fri, 26 Nov 2021 18:57:25 +0000 (18:57 +0000)
src/view.c

index 784259eacd07527cc0c8b1a039039b414242d2af..31b36966ec26f65c83f54efb394e7e80fff4a426 100644 (file)
@@ -44,15 +44,18 @@ view_min_size(struct view *view, int *w, int *h)
        int min_width = MIN_VIEW_WIDTH;
        int min_height = MIN_VIEW_HEIGHT;
 #if HAVE_XWAYLAND
-       if (view->type == LAB_XWAYLAND_VIEW) {
-               if (view->xwayland_surface->size_hints) {
-                       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_height = view->xwayland_surface->size_hints->min_height;
-                       }
-               }
+       if (view->type != LAB_XWAYLAND_VIEW) {
+               goto out;
+       }
+       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_height = view->xwayland_surface->size_hints->min_height;
+       }
+out:
 #endif
 
        if (w) {
@@ -70,8 +73,8 @@ view_minimize(struct view *view, bool minimized)
                return;
        }
        if (view->toplevel_handle) {
-               wlr_foreign_toplevel_handle_v1_set_minimized(view->toplevel_handle,
-                       minimized);
+               wlr_foreign_toplevel_handle_v1_set_minimized(
+                       view->toplevel_handle, minimized);
        }
        view->minimized = minimized;
        if (minimized) {
@@ -128,8 +131,8 @@ view_maximize(struct view *view, bool maximize)
                view->impl->maximize(view, maximize);
        }
        if (view->toplevel_handle) {
-               wlr_foreign_toplevel_handle_v1_set_maximized(view->toplevel_handle,
-                       maximize);
+               wlr_foreign_toplevel_handle_v1_set_maximized(
+                       view->toplevel_handle, maximize);
        }
        if (maximize) {
                view->unmaximized_geometry.x = view->x;
@@ -371,14 +374,18 @@ static enum view_edge
 view_edge_invert(enum view_edge edge)
 {
        switch (edge) {
-               case VIEW_EDGE_LEFT: return VIEW_EDGE_RIGHT;
-               case VIEW_EDGE_RIGHT: 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_INVALID:
-               default:
-                       return VIEW_EDGE_INVALID;
+       case VIEW_EDGE_LEFT:
+               return VIEW_EDGE_RIGHT;
+       case VIEW_EDGE_RIGHT:
+               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_INVALID:
+       default:
+               return VIEW_EDGE_INVALID;
        }
 }
 
@@ -393,7 +400,7 @@ view_edge_parse(const char *direction)
                return VIEW_EDGE_RIGHT;
        } else if (!strcasecmp(direction, "down")) {
                return VIEW_EDGE_DOWN;
-       } else if (!strcasecmp(direction, "center")) {
+       } else if (!strcasecmp(direction, "center")) {
                return VIEW_EDGE_CENTER;
        } else {
                return VIEW_EDGE_INVALID;
@@ -401,7 +408,8 @@ view_edge_parse(const char *direction)
 }
 
 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 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);
 
-       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. */
-               struct wlr_box usable = output_usable_area_in_layout_coords(output);
+               struct wlr_box usable =
+                       output_usable_area_in_layout_coords(output);
                switch (edge) {
-                       case VIEW_EDGE_LEFT: dst.x -= (usable.width / 2) + 1; break;
-                       case VIEW_EDGE_RIGHT: 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;
+               case VIEW_EDGE_LEFT:
+                       dst.x -= (usable.width / 2) + 1;
+                       break;
+               case VIEW_EDGE_RIGHT:
+                       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 =
-                       output_from_wlr_output(view->server,
-                               wlr_output_layout_output_at(view->server->output_layout, dst.x, dst.y));
+                       output_from_wlr_output(view->server, new_wlr_output);
 
-               if (new_output == output || !new_output || edge == VIEW_EDGE_CENTER) {
+               if (new_output == output || !new_output
+                               || edge == VIEW_EDGE_CENTER) {
                        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);