[PATCH] desktop-shell: Replace magic constants with named ones
Pekka Paalanen
ppaalanen at gmail.com
Wed Aug 27 06:05:22 PDT 2014
On Mon, 25 Aug 2014 10:47:24 +0200
"Nils Chr. Brause" <nilschrbrause at gmail.com> wrote:
> This looks much more readable to me. Unnamed magic numbers are always
> confusing.
>
> Reviewed-by: Nils Chr. Brause <nilschrbrause at gmail.com>
>
>
>
> On Thu, Aug 21, 2014 at 3:47 PM, Ondřej Majerech <majerech.o at gmail.com>
> wrote:
>
> > Signed-off-by: Ondřej Majerech <majerech.o at gmail.com>
> > ---
> > desktop-shell/shell.c | 11 +++++++++--
> > 1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> > index e3abaad..02e180d 100644
> > --- a/desktop-shell/shell.c
> > +++ b/desktop-shell/shell.c
> > @@ -1884,13 +1884,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);
> > --
> > 2.0.4
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> >
I suppose that is more documentative. Pushed.
Thanks,
pq
More information about the wayland-devel
mailing list