desktop-shell: Replace magic constants with named ones
authorOndřej Majerech <majerech.o@gmail.com>
Thu, 21 Aug 2014 13:47:22 +0000 (15:47 +0200)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Wed, 27 Aug 2014 13:03:49 +0000 (16:03 +0300)
Signed-off-by: Ondřej Majerech <majerech.o@gmail.com>
Reviewed-by: Nils Chr. Brause <nilschrbrause@gmail.com>
desktop-shell/shell.c

index 99f3343..c8a9f01 100644 (file)
@@ -1887,13 +1887,20 @@ surface_resize(struct shell_surface *shsurf,
               struct weston_seat *seat, uint32_t edges)
 {
        struct weston_resize_grab *resize;
+       const unsigned resize_topbottom =
+               WL_SHELL_SURFACE_RESIZE_TOP | WL_SHELL_SURFACE_RESIZE_BOTTOM;
+       const unsigned resize_leftright =
+               WL_SHELL_SURFACE_RESIZE_LEFT | WL_SHELL_SURFACE_RESIZE_RIGHT;
+       const unsigned resize_any = resize_topbottom | resize_leftright;
 
        if (shsurf->grabbed ||
            shsurf->state.fullscreen || shsurf->state.maximized)
                return 0;
 
-       if (edges == 0 || edges > 15 ||
-           (edges & 3) == 3 || (edges & 12) == 12)
+       /* Check for invalid edge combinations. */
+       if (edges == WL_SHELL_SURFACE_RESIZE_NONE || edges > resize_any ||
+           (edges & resize_topbottom) == resize_topbottom ||
+           (edges & resize_leftright) == resize_leftright)
                return 0;
 
        resize = malloc(sizeof *resize);