[mutter] Add MetaGravity and replace X11 equivalent with it



commit 0dac91cffc539079a1464c4988a362e8462824a8
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Feb 14 09:44:43 2020 +0100

    Add MetaGravity and replace X11 equivalent with it
    
    MetaGravity is an enum, where the values match the X11 macros used for
    gravity, with the exception that `ForgetGravity` was renamed
    `META_GRAVITY_NONE` to have less of a obscure name.
    
    The motivation for this is to rely less on libX11 data types and macros
    in generic code.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/705

 doc/how-constraints-works.txt     |   2 +-
 src/core/boxes-private.h          |   8 +--
 src/core/boxes.c                  |  50 +++++++--------
 src/core/constraints.c            |  48 +++++++-------
 src/core/constraints.h            |   2 +-
 src/core/display-private.h        |   2 +-
 src/core/display.c                |  22 +++----
 src/core/edge-resistance.c        |   2 +-
 src/core/edge-resistance.h        |   2 +-
 src/core/keybindings.c            | 132 ++++++++++++++++++++------------------
 src/core/util.c                   |  44 ++++++-------
 src/core/window-private.h         |   8 +--
 src/core/window.c                 |  54 ++++++++--------
 src/meta/common.h                 |  19 ++++++
 src/meta/util.h                   |   2 +-
 src/tests/boxes-tests.c           |  20 +++---
 src/wayland/meta-window-wayland.c |   4 +-
 src/x11/session.c                 |  44 ++++++-------
 src/x11/session.h                 |   2 +-
 src/x11/window-props.c            |   2 +-
 src/x11/window-x11.c              |  88 +++++++++++++------------
 21 files changed, 294 insertions(+), 263 deletions(-)
---
diff --git a/doc/how-constraints-works.txt b/doc/how-constraints-works.txt
index 327e5fe8e..a6e02f3bc 100644
--- a/doc/how-constraints-works.txt
+++ b/doc/how-constraints-works.txt
@@ -227,7 +227,7 @@ are used for different purposes:
 Examples of where each are used:
 
   - If a window is simultaneously moved and resized to the southeast corner
-    with SouthEastGravity, but it turns out that the window was sized to
+    with META_GRAVITY_SOUTH_EAST, but it turns out that the window was sized to
     something smaller than the minimum size hint, then the size_hints
     constraint should resize the window using the resize_gravity to ensure
     that the southeast corner doesn't move.
diff --git a/src/core/boxes-private.h b/src/core/boxes-private.h
index 152be6e49..7616d6c92 100644
--- a/src/core/boxes-private.h
+++ b/src/core/boxes-private.h
@@ -73,14 +73,14 @@ char* meta_rectangle_edge_list_to_string (
 /* Resize old_rect to the given new_width and new_height, but store the
  * result in rect.  NOTE THAT THIS IS RESIZE ONLY SO IT CANNOT BE USED FOR
  * A MOVERESIZE OPERATION (that simplies the routine a little bit as it
- * means there's no difference between NorthWestGravity and StaticGravity.
- * Also, I lied a little bit--technically, you could use it in a MoveResize
- * operation if you muck with old_rect just right).
+ * means there's no difference between META_GRAVITY_NORTH_WEST and
+ * META_GRAVITY_STATIC. Also, I lied a little bit--technically, you could use
+ * it in a MoveResize operation if you muck with old_rect just right).
  */
 META_EXPORT_TEST
 void meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect,
                                          MetaRectangle       *rect,
-                                         int                  gravity,
+                                         MetaGravity          gravity,
                                          int                  new_width,
                                          int                  new_height);
 
diff --git a/src/core/boxes.c b/src/core/boxes.c
index d1f81975f..37d04bb1a 100644
--- a/src/core/boxes.c
+++ b/src/core/boxes.c
@@ -327,7 +327,7 @@ meta_rectangle_contains_rect  (const MetaRectangle *outer_rect,
 void
 meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect,
                                     MetaRectangle       *rect,
-                                    int                  gravity,
+                                    MetaGravity          gravity,
                                     int                  new_width,
                                     int                  new_height)
 {
@@ -342,12 +342,12 @@ meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect,
    * border_width, and old and new client area widths (instead of old total
    * width and new total width) and you come up with the same formulas.
    *
-   * Also, note that the reason we can treat NorthWestGravity and
-   * StaticGravity the same is because we're not given a location at
+   * Also, note that the reason we can treat META_GRAVITY_NORTH_WEST and
+   * META_GRAVITY_STATIC the same is because we're not given a location at
    * which to place the window--the window was already placed
-   * appropriately before.  So, NorthWestGravity for this function
+   * appropriately before.  So, META_GRAVITY_NORTH_WEST for this function
    * means to just leave the upper left corner of the outer window
-   * where it already is, and StaticGravity for this function means to
+   * where it already is, and META_GRAVITY_STATIC for this function means to
    * just leave the upper left corner of the inner window where it
    * already is.  But leaving either of those two corners where they
    * already are will ensure that the other corner is fixed as well
@@ -358,15 +358,15 @@ meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect,
   /* First, the x direction */
   switch (gravity)
     {
-    case NorthWestGravity:
-    case WestGravity:
-    case SouthWestGravity:
+    case META_GRAVITY_NORTH_WEST:
+    case META_GRAVITY_WEST:
+    case META_GRAVITY_SOUTH_WEST:
       rect->x = old_rect->x;
       break;
 
-    case NorthGravity:
-    case CenterGravity:
-    case SouthGravity:
+    case META_GRAVITY_NORTH:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_SOUTH:
       /* FIXME: Needing to adjust new_width kind of sucks, but not doing so
        * would cause drift.
        */
@@ -374,13 +374,13 @@ meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect,
       rect->x = old_rect->x + (old_rect->width - new_width)/2;
       break;
 
-    case NorthEastGravity:
-    case EastGravity:
-    case SouthEastGravity:
+    case META_GRAVITY_NORTH_EAST:
+    case META_GRAVITY_EAST:
+    case META_GRAVITY_SOUTH_EAST:
       rect->x = old_rect->x + (old_rect->width - new_width);
       break;
 
-    case StaticGravity:
+    case META_GRAVITY_STATIC:
     default:
       rect->x = old_rect->x;
       break;
@@ -390,15 +390,15 @@ meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect,
   /* Next, the y direction */
   switch (gravity)
     {
-    case NorthWestGravity:
-    case NorthGravity:
-    case NorthEastGravity:
+    case META_GRAVITY_NORTH_WEST:
+    case META_GRAVITY_NORTH:
+    case META_GRAVITY_NORTH_EAST:
       rect->y = old_rect->y;
       break;
 
-    case WestGravity:
-    case CenterGravity:
-    case EastGravity:
+    case META_GRAVITY_WEST:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_EAST:
       /* FIXME: Needing to adjust new_height kind of sucks, but not doing so
        * would cause drift.
        */
@@ -406,13 +406,13 @@ meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect,
       rect->y = old_rect->y + (old_rect->height - new_height)/2;
       break;
 
-    case SouthWestGravity:
-    case SouthGravity:
-    case SouthEastGravity:
+    case META_GRAVITY_SOUTH_WEST:
+    case META_GRAVITY_SOUTH:
+    case META_GRAVITY_SOUTH_EAST:
       rect->y = old_rect->y + (old_rect->height - new_height);
       break;
 
-    case StaticGravity:
+    case META_GRAVITY_STATIC:
     default:
       rect->y = old_rect->y;
       break;
diff --git a/src/core/constraints.c b/src/core/constraints.c
index 8e5009097..79019b902 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -133,7 +133,7 @@ typedef struct
    * explanation of the differences and similarity between resize_gravity
    * and fixed_directions
    */
-  int                  resize_gravity;
+  MetaGravity          resize_gravity;
   FixedDirections      fixed_directions;
 
   /* work_area_monitor - current monitor region minus struts
@@ -205,7 +205,7 @@ static gboolean constrain_partially_onscreen (MetaWindow         *window,
 static void setup_constraint_info        (ConstraintInfo      *info,
                                           MetaWindow          *window,
                                           MetaMoveResizeFlags  flags,
-                                          int                  resize_gravity,
+                                          MetaGravity          resize_gravity,
                                           const MetaRectangle *orig,
                                           MetaRectangle       *new);
 static void place_window_if_needed       (MetaWindow     *window,
@@ -281,7 +281,7 @@ do_all_constraints (MetaWindow         *window,
 void
 meta_window_constrain (MetaWindow          *window,
                        MetaMoveResizeFlags  flags,
-                       int                  resize_gravity,
+                       MetaGravity          resize_gravity,
                        const MetaRectangle *orig,
                        MetaRectangle       *new,
                        int                 *rel_x,
@@ -336,7 +336,7 @@ static void
 setup_constraint_info (ConstraintInfo      *info,
                        MetaWindow          *window,
                        MetaMoveResizeFlags  flags,
-                       int                  resize_gravity,
+                       MetaGravity          resize_gravity,
                        const MetaRectangle *orig,
                        MetaRectangle       *new)
 {
@@ -1422,19 +1422,19 @@ constrain_aspect_ratio (MetaWindow         *window,
    */
   switch (info->resize_gravity)
     {
-    case WestGravity:
-    case NorthGravity:
-    case SouthGravity:
-    case EastGravity:
+    case META_GRAVITY_WEST:
+    case META_GRAVITY_NORTH:
+    case META_GRAVITY_SOUTH:
+    case META_GRAVITY_EAST:
       fudge = 2;
       break;
 
-    case NorthWestGravity:
-    case SouthWestGravity:
-    case CenterGravity:
-    case NorthEastGravity:
-    case SouthEastGravity:
-    case StaticGravity:
+    case META_GRAVITY_NORTH_WEST:
+    case META_GRAVITY_SOUTH_WEST:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_NORTH_EAST:
+    case META_GRAVITY_SOUTH_EAST:
+    case META_GRAVITY_STATIC:
     default:
       fudge = 1;
       break;
@@ -1454,24 +1454,24 @@ constrain_aspect_ratio (MetaWindow         *window,
 
   switch (info->resize_gravity)
     {
-    case WestGravity:
-    case EastGravity:
+    case META_GRAVITY_WEST:
+    case META_GRAVITY_EAST:
       /* Yeah, I suck for doing implicit rounding -- sue me */
       new_height = CLAMP (new_height, new_width / maxr,  new_width / minr);
       break;
 
-    case NorthGravity:
-    case SouthGravity:
+    case META_GRAVITY_NORTH:
+    case META_GRAVITY_SOUTH:
       /* Yeah, I suck for doing implicit rounding -- sue me */
       new_width  = CLAMP (new_width,  new_height * minr, new_height * maxr);
       break;
 
-    case NorthWestGravity:
-    case SouthWestGravity:
-    case CenterGravity:
-    case NorthEastGravity:
-    case SouthEastGravity:
-    case StaticGravity:
+    case META_GRAVITY_NORTH_WEST:
+    case META_GRAVITY_SOUTH_WEST:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_NORTH_EAST:
+    case META_GRAVITY_SOUTH_EAST:
+    case META_GRAVITY_STATIC:
     default:
       /* Find what width would correspond to new_height, and what height would
        * correspond to new_width */
diff --git a/src/core/constraints.h b/src/core/constraints.h
index 775e95dff..1517aa060 100644
--- a/src/core/constraints.h
+++ b/src/core/constraints.h
@@ -29,7 +29,7 @@
 
 void meta_window_constrain (MetaWindow          *window,
                             MetaMoveResizeFlags  flags,
-                            int                  resize_gravity,
+                            MetaGravity          resize_gravity,
                             const MetaRectangle *orig,
                             MetaRectangle       *new,
                             int                 *rel_x,
diff --git a/src/core/display-private.h b/src/core/display-private.h
index d8064f12e..251e9e2a8 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -343,7 +343,7 @@ void meta_display_ping_window      (MetaWindow  *window,
 void meta_display_pong_for_serial  (MetaDisplay *display,
                                     guint32      serial);
 
-int meta_resize_gravity_from_grab_op (MetaGrabOp op);
+MetaGravity meta_resize_gravity_from_grab_op (MetaGrabOp op);
 
 gboolean meta_grab_op_is_moving   (MetaGrabOp op);
 gboolean meta_grab_op_is_resizing (MetaGrabOp op);
diff --git a/src/core/display.c b/src/core/display.c
index 9a431dd24..a9394ea82 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -2532,48 +2532,48 @@ meta_display_get_tab_current (MetaDisplay   *display,
     return NULL;
 }
 
-int
+MetaGravity
 meta_resize_gravity_from_grab_op (MetaGrabOp op)
 {
-  int gravity;
+  MetaGravity gravity;
 
   gravity = -1;
   switch (op)
     {
     case META_GRAB_OP_RESIZING_SE:
     case META_GRAB_OP_KEYBOARD_RESIZING_SE:
-      gravity = NorthWestGravity;
+      gravity = META_GRAVITY_NORTH_WEST;
       break;
     case META_GRAB_OP_KEYBOARD_RESIZING_S:
     case META_GRAB_OP_RESIZING_S:
-      gravity = NorthGravity;
+      gravity = META_GRAVITY_NORTH;
       break;
     case META_GRAB_OP_KEYBOARD_RESIZING_SW:
     case META_GRAB_OP_RESIZING_SW:
-      gravity = NorthEastGravity;
+      gravity = META_GRAVITY_NORTH_EAST;
       break;
     case META_GRAB_OP_KEYBOARD_RESIZING_N:
     case META_GRAB_OP_RESIZING_N:
-      gravity = SouthGravity;
+      gravity = META_GRAVITY_SOUTH;
       break;
     case META_GRAB_OP_KEYBOARD_RESIZING_NE:
     case META_GRAB_OP_RESIZING_NE:
-      gravity = SouthWestGravity;
+      gravity = META_GRAVITY_SOUTH_WEST;
       break;
     case META_GRAB_OP_KEYBOARD_RESIZING_NW:
     case META_GRAB_OP_RESIZING_NW:
-      gravity = SouthEastGravity;
+      gravity = META_GRAVITY_SOUTH_EAST;
       break;
     case META_GRAB_OP_KEYBOARD_RESIZING_E:
     case META_GRAB_OP_RESIZING_E:
-      gravity = WestGravity;
+      gravity = META_GRAVITY_WEST;
       break;
     case META_GRAB_OP_KEYBOARD_RESIZING_W:
     case META_GRAB_OP_RESIZING_W:
-      gravity = EastGravity;
+      gravity = META_GRAVITY_EAST;
       break;
     case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
-      gravity = CenterGravity;
+      gravity = META_GRAVITY_CENTER;
       break;
     default:
       break;
diff --git a/src/core/edge-resistance.c b/src/core/edge-resistance.c
index fe3c61800..cf23e2604 100644
--- a/src/core/edge-resistance.c
+++ b/src/core/edge-resistance.c
@@ -1255,7 +1255,7 @@ void
 meta_window_edge_resistance_for_resize (MetaWindow  *window,
                                         int         *new_width,
                                         int         *new_height,
-                                        int          gravity,
+                                        MetaGravity  gravity,
                                         GSourceFunc  timeout_func,
                                         gboolean     snap,
                                         gboolean     is_keyboard_op)
diff --git a/src/core/edge-resistance.h b/src/core/edge-resistance.h
index 3904c12e8..c980030c7 100644
--- a/src/core/edge-resistance.h
+++ b/src/core/edge-resistance.h
@@ -33,7 +33,7 @@ void        meta_window_edge_resistance_for_move   (MetaWindow  *window,
 void        meta_window_edge_resistance_for_resize (MetaWindow  *window,
                                                     int         *new_width,
                                                     int         *new_height,
-                                                    int          gravity,
+                                                    MetaGravity  gravity,
                                                     GSourceFunc  timeout_func,
                                                     gboolean     snap,
                                                     gboolean     is_keyboard_op);
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index b86272541..64f392f07 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2625,7 +2625,7 @@ process_keyboard_resize_grab (MetaDisplay     *display,
   int width_inc;
   int width, height;
   gboolean smart_snap;
-  int gravity;
+  MetaGravity gravity;
 
   handled = FALSE;
 
@@ -2697,23 +2697,25 @@ process_keyboard_resize_grab (MetaDisplay     *display,
     case CLUTTER_KEY_KP_Up:
       switch (gravity)
         {
-        case NorthGravity:
-        case NorthWestGravity:
-        case NorthEastGravity:
+        case META_GRAVITY_NORTH:
+        case META_GRAVITY_NORTH_WEST:
+        case META_GRAVITY_NORTH_EAST:
           /* Move bottom edge up */
           height -= height_inc;
           break;
 
-        case SouthGravity:
-        case SouthWestGravity:
-        case SouthEastGravity:
+        case META_GRAVITY_SOUTH:
+        case META_GRAVITY_SOUTH_WEST:
+        case META_GRAVITY_SOUTH_EAST:
           /* Move top edge up */
           height += height_inc;
           break;
 
-        case EastGravity:
-        case WestGravity:
-        case CenterGravity:
+        case META_GRAVITY_EAST:
+        case META_GRAVITY_WEST:
+        case META_GRAVITY_CENTER:
+        case META_GRAVITY_NONE:
+        case META_GRAVITY_STATIC:
           g_assert_not_reached ();
           break;
         }
@@ -2725,23 +2727,25 @@ process_keyboard_resize_grab (MetaDisplay     *display,
     case CLUTTER_KEY_KP_Down:
       switch (gravity)
         {
-        case NorthGravity:
-        case NorthWestGravity:
-        case NorthEastGravity:
+        case META_GRAVITY_NORTH:
+        case META_GRAVITY_NORTH_WEST:
+        case META_GRAVITY_NORTH_EAST:
           /* Move bottom edge down */
           height += height_inc;
           break;
 
-        case SouthGravity:
-        case SouthWestGravity:
-        case SouthEastGravity:
+        case META_GRAVITY_SOUTH:
+        case META_GRAVITY_SOUTH_WEST:
+        case META_GRAVITY_SOUTH_EAST:
           /* Move top edge down */
           height -= height_inc;
           break;
 
-        case EastGravity:
-        case WestGravity:
-        case CenterGravity:
+        case META_GRAVITY_EAST:
+        case META_GRAVITY_WEST:
+        case META_GRAVITY_CENTER:
+        case META_GRAVITY_NONE:
+        case META_GRAVITY_STATIC:
           g_assert_not_reached ();
           break;
         }
@@ -2753,23 +2757,25 @@ process_keyboard_resize_grab (MetaDisplay     *display,
     case CLUTTER_KEY_KP_Left:
       switch (gravity)
         {
-        case EastGravity:
-        case SouthEastGravity:
-        case NorthEastGravity:
+        case META_GRAVITY_EAST:
+        case META_GRAVITY_SOUTH_EAST:
+        case META_GRAVITY_NORTH_EAST:
           /* Move left edge left */
           width += width_inc;
           break;
 
-        case WestGravity:
-        case SouthWestGravity:
-        case NorthWestGravity:
+        case META_GRAVITY_WEST:
+        case META_GRAVITY_SOUTH_WEST:
+        case META_GRAVITY_NORTH_WEST:
           /* Move right edge left */
           width -= width_inc;
           break;
 
-        case NorthGravity:
-        case SouthGravity:
-        case CenterGravity:
+        case META_GRAVITY_NORTH:
+        case META_GRAVITY_SOUTH:
+        case META_GRAVITY_CENTER:
+        case META_GRAVITY_NONE:
+        case META_GRAVITY_STATIC:
           g_assert_not_reached ();
           break;
         }
@@ -2781,23 +2787,25 @@ process_keyboard_resize_grab (MetaDisplay     *display,
     case CLUTTER_KEY_KP_Right:
       switch (gravity)
         {
-        case EastGravity:
-        case SouthEastGravity:
-        case NorthEastGravity:
+        case META_GRAVITY_EAST:
+        case META_GRAVITY_SOUTH_EAST:
+        case META_GRAVITY_NORTH_EAST:
           /* Move left edge right */
           width -= width_inc;
           break;
 
-        case WestGravity:
-        case SouthWestGravity:
-        case NorthWestGravity:
+        case META_GRAVITY_WEST:
+        case META_GRAVITY_SOUTH_WEST:
+        case META_GRAVITY_NORTH_WEST:
           /* Move right edge right */
           width += width_inc;
           break;
 
-        case NorthGravity:
-        case SouthGravity:
-        case CenterGravity:
+        case META_GRAVITY_NORTH:
+        case META_GRAVITY_SOUTH:
+        case META_GRAVITY_CENTER:
+        case META_GRAVITY_NONE:
+        case META_GRAVITY_STATIC:
           g_assert_not_reached ();
           break;
         }
@@ -2940,7 +2948,7 @@ handle_always_on_top (MetaDisplay     *display,
 static void
 handle_move_to_corner_backend (MetaDisplay           *display,
                                MetaWindow            *window,
-                               int                    gravity)
+                               MetaGravity            gravity)
 {
   MetaRectangle work_area;
   MetaRectangle frame_rect;
@@ -2954,18 +2962,18 @@ handle_move_to_corner_backend (MetaDisplay           *display,
 
   switch (gravity)
     {
-    case NorthWestGravity:
-    case WestGravity:
-    case SouthWestGravity:
+    case META_GRAVITY_NORTH_WEST:
+    case META_GRAVITY_WEST:
+    case META_GRAVITY_SOUTH_WEST:
       new_x = work_area.x;
       break;
-    case NorthGravity:
-    case SouthGravity:
+    case META_GRAVITY_NORTH:
+    case META_GRAVITY_SOUTH:
       new_x = frame_rect.x;
       break;
-    case NorthEastGravity:
-    case EastGravity:
-    case SouthEastGravity:
+    case META_GRAVITY_NORTH_EAST:
+    case META_GRAVITY_EAST:
+    case META_GRAVITY_SOUTH_EAST:
       new_x = work_area.x + work_area.width - frame_rect.width;
       break;
     default:
@@ -2974,18 +2982,18 @@ handle_move_to_corner_backend (MetaDisplay           *display,
 
   switch (gravity)
     {
-    case NorthWestGravity:
-    case NorthGravity:
-    case NorthEastGravity:
+    case META_GRAVITY_NORTH_WEST:
+    case META_GRAVITY_NORTH:
+    case META_GRAVITY_NORTH_EAST:
       new_y = work_area.y;
       break;
-    case WestGravity:
-    case EastGravity:
+    case META_GRAVITY_WEST:
+    case META_GRAVITY_EAST:
       new_y = frame_rect.y;
       break;
-    case SouthWestGravity:
-    case SouthGravity:
-    case SouthEastGravity:
+    case META_GRAVITY_SOUTH_WEST:
+    case META_GRAVITY_SOUTH:
+    case META_GRAVITY_SOUTH_EAST:
       new_y = work_area.y + work_area.height - frame_rect.height;
       break;
     default:
@@ -3005,7 +3013,7 @@ handle_move_to_corner_nw  (MetaDisplay     *display,
                            MetaKeyBinding  *binding,
                            gpointer         dummy)
 {
-  handle_move_to_corner_backend (display, window, NorthWestGravity);
+  handle_move_to_corner_backend (display, window, META_GRAVITY_NORTH_WEST);
 }
 
 static void
@@ -3015,7 +3023,7 @@ handle_move_to_corner_ne  (MetaDisplay     *display,
                            MetaKeyBinding  *binding,
                            gpointer         dummy)
 {
-  handle_move_to_corner_backend (display, window, NorthEastGravity);
+  handle_move_to_corner_backend (display, window, META_GRAVITY_NORTH_EAST);
 }
 
 static void
@@ -3025,7 +3033,7 @@ handle_move_to_corner_sw  (MetaDisplay     *display,
                            MetaKeyBinding  *binding,
                            gpointer         dummy)
 {
-  handle_move_to_corner_backend (display, window, SouthWestGravity);
+  handle_move_to_corner_backend (display, window, META_GRAVITY_SOUTH_WEST);
 }
 
 static void
@@ -3035,7 +3043,7 @@ handle_move_to_corner_se  (MetaDisplay     *display,
                            MetaKeyBinding  *binding,
                            gpointer         dummy)
 {
-  handle_move_to_corner_backend (display, window, SouthEastGravity);
+  handle_move_to_corner_backend (display, window, META_GRAVITY_SOUTH_EAST);
 }
 
 static void
@@ -3045,7 +3053,7 @@ handle_move_to_side_n     (MetaDisplay     *display,
                            MetaKeyBinding  *binding,
                            gpointer         dummy)
 {
-  handle_move_to_corner_backend (display, window, NorthGravity);
+  handle_move_to_corner_backend (display, window, META_GRAVITY_NORTH);
 }
 
 static void
@@ -3055,7 +3063,7 @@ handle_move_to_side_s     (MetaDisplay     *display,
                            MetaKeyBinding  *binding,
                            gpointer         dummy)
 {
-  handle_move_to_corner_backend (display, window, SouthGravity);
+  handle_move_to_corner_backend (display, window, META_GRAVITY_SOUTH);
 }
 
 static void
@@ -3065,7 +3073,7 @@ handle_move_to_side_e     (MetaDisplay     *display,
                            MetaKeyBinding  *binding,
                            gpointer         dummy)
 {
-  handle_move_to_corner_backend (display, window, EastGravity);
+  handle_move_to_corner_backend (display, window, META_GRAVITY_EAST);
 }
 
 static void
@@ -3075,7 +3083,7 @@ handle_move_to_side_w     (MetaDisplay     *display,
                            MetaKeyBinding  *binding,
                            gpointer         dummy)
 {
-  handle_move_to_corner_backend (display, window, WestGravity);
+  handle_move_to_corner_backend (display, window, META_GRAVITY_WEST);
 }
 
 static void
diff --git a/src/core/util.c b/src/core/util.c
index 63f1a0502..accd74654 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -527,42 +527,42 @@ meta_unsigned_long_hash  (gconstpointer v)
 }
 
 const char*
-meta_gravity_to_string (int gravity)
+meta_gravity_to_string (MetaGravity gravity)
 {
   switch (gravity)
     {
-    case NorthWestGravity:
-      return "NorthWestGravity";
+    case META_GRAVITY_NORTH_WEST:
+      return "META_GRAVITY_NORTH_WEST";
       break;
-    case NorthGravity:
-      return "NorthGravity";
+    case META_GRAVITY_NORTH:
+      return "META_GRAVITY_NORTH";
       break;
-    case NorthEastGravity:
-      return "NorthEastGravity";
+    case META_GRAVITY_NORTH_EAST:
+      return "META_GRAVITY_NORTH_EAST";
       break;
-    case WestGravity:
-      return "WestGravity";
+    case META_GRAVITY_WEST:
+      return "META_GRAVITY_WEST";
       break;
-    case CenterGravity:
-      return "CenterGravity";
+    case META_GRAVITY_CENTER:
+      return "META_GRAVITY_CENTER";
       break;
-    case EastGravity:
-      return "EastGravity";
+    case META_GRAVITY_EAST:
+      return "META_GRAVITY_EAST";
       break;
-    case SouthWestGravity:
-      return "SouthWestGravity";
+    case META_GRAVITY_SOUTH_WEST:
+      return "META_GRAVITY_SOUTH_WEST";
       break;
-    case SouthGravity:
-      return "SouthGravity";
+    case META_GRAVITY_SOUTH:
+      return "META_GRAVITY_SOUTH";
       break;
-    case SouthEastGravity:
-      return "SouthEastGravity";
+    case META_GRAVITY_SOUTH_EAST:
+      return "META_GRAVITY_SOUTH_EAST";
       break;
-    case StaticGravity:
-      return "StaticGravity";
+    case META_GRAVITY_STATIC:
+      return "META_GRAVITY_STATIC";
       break;
     default:
-      return "NorthWestGravity";
+      return "META_GRAVITY_NORTH_WEST";
       break;
     }
 }
diff --git a/src/core/window-private.h b/src/core/window-private.h
index d88f0eb2d..04216113e 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -566,7 +566,7 @@ struct _MetaWindowClass
                                   MetaGrabOp  op);
   void (*current_workspace_changed) (MetaWindow *window);
   void (*move_resize_internal)   (MetaWindow                *window,
-                                  int                        gravity,
+                                  MetaGravity                gravity,
                                   MetaRectangle              unconstrained_rect,
                                   MetaRectangle              constrained_rect,
                                   int                        rel_x,
@@ -668,7 +668,7 @@ void        meta_window_resize_frame_with_gravity (MetaWindow  *window,
                                                    gboolean     user_op,
                                                    int          w,
                                                    int          h,
-                                                   int          gravity);
+                                                   MetaGravity  gravity);
 
 /* Return whether the window should be currently mapped */
 gboolean    meta_window_should_be_showing   (MetaWindow  *window);
@@ -681,7 +681,7 @@ void        meta_window_update_struts      (MetaWindow  *window);
  * request.
  */
 void        meta_window_get_gravity_position (MetaWindow  *window,
-                                              int          gravity,
+                                              MetaGravity  gravity,
                                               int         *x,
                                               int         *y);
 /* Get geometry for saving in the session; x/y are gravity
@@ -840,7 +840,7 @@ void meta_window_update_resize (MetaWindow *window,
 
 void meta_window_move_resize_internal (MetaWindow          *window,
                                        MetaMoveResizeFlags  flags,
-                                       int                  gravity,
+                                       MetaGravity          gravity,
                                        MetaRectangle        frame_rect);
 
 void meta_window_grab_op_began (MetaWindow *window, MetaGrabOp op);
diff --git a/src/core/window.c b/src/core/window.c
index 612f75974..6573c217e 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2366,7 +2366,7 @@ meta_window_force_placement (MetaWindow *window,
 
   meta_window_move_resize_internal (window,
                                     flags,
-                                    NorthWestGravity,
+                                    META_GRAVITY_NORTH_WEST,
                                     window->unconstrained_rect);
   window->calc_placement = FALSE;
 
@@ -2915,7 +2915,7 @@ meta_window_maximize (MetaWindow        *window,
                                         (META_MOVE_RESIZE_MOVE_ACTION |
                                          META_MOVE_RESIZE_RESIZE_ACTION |
                                          META_MOVE_RESIZE_STATE_CHANGED),
-                                        NorthWestGravity,
+                                        META_GRAVITY_NORTH_WEST,
                                         window->unconstrained_rect);
     }
 }
@@ -3187,7 +3187,7 @@ meta_window_tile (MetaWindow   *window,
                                     (META_MOVE_RESIZE_MOVE_ACTION |
                                      META_MOVE_RESIZE_RESIZE_ACTION |
                                      META_MOVE_RESIZE_STATE_CHANGED),
-                                    NorthWestGravity,
+                                    META_GRAVITY_NORTH_WEST,
                                     window->unconstrained_rect);
 
   if (window->frame)
@@ -3385,7 +3385,7 @@ meta_window_unmaximize (MetaWindow        *window,
                                          META_MOVE_RESIZE_RESIZE_ACTION |
                                          META_MOVE_RESIZE_STATE_CHANGED |
                                          META_MOVE_RESIZE_UNMAXIMIZE),
-                                        NorthWestGravity,
+                                        META_GRAVITY_NORTH_WEST,
                                         target_rect);
 
       /* When we unmaximize, if we're doing a mouse move also we could
@@ -3502,7 +3502,7 @@ meta_window_make_fullscreen (MetaWindow  *window)
                                         (META_MOVE_RESIZE_MOVE_ACTION |
                                          META_MOVE_RESIZE_RESIZE_ACTION |
                                          META_MOVE_RESIZE_STATE_CHANGED),
-                                        NorthWestGravity,
+                                        META_GRAVITY_NORTH_WEST,
                                         window->unconstrained_rect);
     }
 }
@@ -3547,7 +3547,7 @@ meta_window_unmake_fullscreen (MetaWindow  *window)
                                          META_MOVE_RESIZE_RESIZE_ACTION |
                                          META_MOVE_RESIZE_STATE_CHANGED |
                                          META_MOVE_RESIZE_UNFULLSCREEN),
-                                        NorthWestGravity,
+                                        META_GRAVITY_NORTH_WEST,
                                         target_rect);
 
       meta_display_queue_check_fullscreen (window->display);
@@ -3804,7 +3804,7 @@ meta_window_reposition (MetaWindow *window)
   meta_window_move_resize_internal (window,
                                     (META_MOVE_RESIZE_MOVE_ACTION |
                                      META_MOVE_RESIZE_RESIZE_ACTION),
-                                    NorthWestGravity,
+                                    META_GRAVITY_NORTH_WEST,
                                     window->rect);
 }
 
@@ -3975,7 +3975,7 @@ meta_window_update_monitor (MetaWindow                   *window,
 void
 meta_window_move_resize_internal (MetaWindow          *window,
                                   MetaMoveResizeFlags  flags,
-                                  int                  gravity,
+                                  MetaGravity          gravity,
                                   MetaRectangle        frame_rect)
 {
   /* The rectangle here that's passed in *always* in "frame rect"
@@ -4181,7 +4181,7 @@ meta_window_move_frame (MetaWindow *window,
   g_return_if_fail (!window->override_redirect);
 
   flags = (user_op ? META_MOVE_RESIZE_USER_ACTION : 0) | META_MOVE_RESIZE_MOVE_ACTION;
-  meta_window_move_resize_internal (window, flags, NorthWestGravity, rect);
+  meta_window_move_resize_internal (window, flags, META_GRAVITY_NORTH_WEST, rect);
 }
 
 static void
@@ -4214,7 +4214,7 @@ meta_window_move_between_rects (MetaWindow  *window,
                                     move_resize_flags |
                                     META_MOVE_RESIZE_MOVE_ACTION |
                                     META_MOVE_RESIZE_RESIZE_ACTION,
-                                    NorthWestGravity,
+                                    META_GRAVITY_NORTH_WEST,
                                     window->unconstrained_rect);
 }
 
@@ -4245,7 +4245,7 @@ meta_window_move_resize_frame (MetaWindow  *window,
 
   flags = (user_op ? META_MOVE_RESIZE_USER_ACTION : 0) | META_MOVE_RESIZE_MOVE_ACTION | 
META_MOVE_RESIZE_RESIZE_ACTION;
 
-  meta_window_move_resize_internal (window, flags, NorthWestGravity, rect);
+  meta_window_move_resize_internal (window, flags, META_GRAVITY_NORTH_WEST, rect);
 }
 
 /**
@@ -4325,7 +4325,7 @@ meta_window_resize_frame_with_gravity (MetaWindow *window,
                                        gboolean     user_op,
                                        int          w,
                                        int          h,
-                                       int          gravity)
+                                       MetaGravity  gravity)
 {
   MetaMoveResizeFlags flags;
   MetaRectangle rect;
@@ -4399,7 +4399,7 @@ idle_move_resize (gpointer data)
 
 void
 meta_window_get_gravity_position (MetaWindow  *window,
-                                  int          gravity,
+                                  MetaGravity  gravity,
                                   int         *root_x,
                                   int         *root_y)
 {
@@ -4410,7 +4410,7 @@ meta_window_get_gravity_position (MetaWindow  *window,
   w = window->rect.width;
   h = window->rect.height;
 
-  if (gravity == StaticGravity)
+  if (gravity == META_GRAVITY_STATIC)
     {
       frame_extents = window->rect;
       if (window->frame)
@@ -4432,18 +4432,18 @@ meta_window_get_gravity_position (MetaWindow  *window,
 
   switch (gravity)
     {
-    case NorthGravity:
-    case CenterGravity:
-    case SouthGravity:
+    case META_GRAVITY_NORTH:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_SOUTH:
       /* Find center of frame. */
       x += frame_extents.width / 2;
       /* Center client window on that point. */
       x -= w / 2;
       break;
 
-    case SouthEastGravity:
-    case EastGravity:
-    case NorthEastGravity:
+    case META_GRAVITY_SOUTH_EAST:
+    case META_GRAVITY_EAST:
+    case META_GRAVITY_NORTH_EAST:
       /* Find right edge of frame */
       x += frame_extents.width;
       /* Align left edge of client at that point. */
@@ -4455,17 +4455,17 @@ meta_window_get_gravity_position (MetaWindow  *window,
 
   switch (gravity)
     {
-    case WestGravity:
-    case CenterGravity:
-    case EastGravity:
+    case META_GRAVITY_WEST:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_EAST:
       /* Find center of frame. */
       y += frame_extents.height / 2;
       /* Center client window there. */
       y -= h / 2;
       break;
-    case SouthWestGravity:
-    case SouthGravity:
-    case SouthEastGravity:
+    case META_GRAVITY_SOUTH_WEST:
+    case META_GRAVITY_SOUTH:
+    case META_GRAVITY_SOUTH_EAST:
       /* Find south edge of frame */
       y += frame_extents.height;
       /* Place bottom edge of client there */
@@ -6247,7 +6247,7 @@ update_resize (MetaWindow *window,
 {
   int dx, dy;
   int new_w, new_h;
-  int gravity;
+  MetaGravity gravity;
   MetaRectangle old;
   double remaining = 0;
 
diff --git a/src/meta/common.h b/src/meta/common.h
index b282afe27..908dc9337 100644
--- a/src/meta/common.h
+++ b/src/meta/common.h
@@ -529,4 +529,23 @@ typedef enum
   META_LAYER_LAST             = 8
 } MetaStackLayer;
 
+/* MetaGravity: (skip)
+ *
+ * Identical to the corresponding gravity value macros from libX11.
+ */
+typedef enum _MetaGravity
+{
+  META_GRAVITY_NONE = 0,
+  META_GRAVITY_NORTH_WEST = 1,
+  META_GRAVITY_NORTH = 2,
+  META_GRAVITY_NORTH_EAST = 3,
+  META_GRAVITY_WEST = 4,
+  META_GRAVITY_CENTER = 5,
+  META_GRAVITY_EAST = 6,
+  META_GRAVITY_SOUTH_WEST = 7,
+  META_GRAVITY_SOUTH = 8,
+  META_GRAVITY_SOUTH_EAST = 9,
+  META_GRAVITY_STATIC = 10,
+} MetaGravity;
+
 #endif
diff --git a/src/meta/util.h b/src/meta/util.h
index 7c269cf6d..86c53bb7c 100644
--- a/src/meta/util.h
+++ b/src/meta/util.h
@@ -142,7 +142,7 @@ guint meta_unsigned_long_hash  (gconstpointer v);
 META_EXPORT
 const char* meta_frame_type_to_string (MetaFrameType type);
 META_EXPORT
-const char* meta_gravity_to_string (int gravity);
+const char* meta_gravity_to_string (MetaGravity gravity);
 
 META_EXPORT
 char* meta_external_binding_name_for_action (guint keybinding_action);
diff --git a/src/tests/boxes-tests.c b/src/tests/boxes-tests.c
index 7b5bb3e7a..0c27ea77e 100644
--- a/src/tests/boxes-tests.c
+++ b/src/tests/boxes-tests.c
@@ -1221,7 +1221,7 @@ test_gravity_resize (void)
   temp    = meta_rect ( 50,  300,  20,   5);
   meta_rectangle_resize_with_gravity (&oldrect,
                                       &rect,
-                                      NorthWestGravity,
+                                      META_GRAVITY_NORTH_WEST,
                                       20,
                                       5);
   g_assert (meta_rectangle_equal (&rect, &temp));
@@ -1230,7 +1230,7 @@ test_gravity_resize (void)
   temp = meta_rect (165,  300,  20,   5);
   meta_rectangle_resize_with_gravity (&rect,
                                       &rect,
-                                      NorthGravity,
+                                      META_GRAVITY_NORTH,
                                       20,
                                       5);
   g_assert (meta_rectangle_equal (&rect, &temp));
@@ -1239,7 +1239,7 @@ test_gravity_resize (void)
   temp = meta_rect (280,  300,  20,   5);
   meta_rectangle_resize_with_gravity (&rect,
                                       &rect,
-                                      NorthEastGravity,
+                                      META_GRAVITY_NORTH_EAST,
                                       20,
                                       5);
   g_assert (meta_rectangle_equal (&rect, &temp));
@@ -1248,7 +1248,7 @@ test_gravity_resize (void)
   temp = meta_rect ( 50,  695,  50,   5);
   meta_rectangle_resize_with_gravity (&rect,
                                       &rect,
-                                      SouthWestGravity,
+                                      META_GRAVITY_SOUTH_WEST,
                                       50,
                                       5);
   g_assert (meta_rectangle_equal (&rect, &temp));
@@ -1257,7 +1257,7 @@ test_gravity_resize (void)
   temp = meta_rect (150,  695,  50,   5);
   meta_rectangle_resize_with_gravity (&rect,
                                       &rect,
-                                      SouthGravity,
+                                      META_GRAVITY_SOUTH,
                                       50,
                                       5);
   g_assert (meta_rectangle_equal (&rect, &temp));
@@ -1266,7 +1266,7 @@ test_gravity_resize (void)
   temp = meta_rect (250,  695,  50,   5);
   meta_rectangle_resize_with_gravity (&rect,
                                       &rect,
-                                      SouthEastGravity,
+                                      META_GRAVITY_SOUTH_EAST,
                                       50,
                                       5);
   g_assert (meta_rectangle_equal (&rect, &temp));
@@ -1275,7 +1275,7 @@ test_gravity_resize (void)
   temp = meta_rect (167, 1113, 832,  93);
   meta_rectangle_resize_with_gravity (&rect,
                                       &rect,
-                                      WestGravity,
+                                      META_GRAVITY_WEST,
                                       832,
                                       93);
   g_assert (meta_rectangle_equal (&rect, &temp));
@@ -1284,7 +1284,7 @@ test_gravity_resize (void)
   temp = meta_rect (-131, 1113, 833,  93);
   meta_rectangle_resize_with_gravity (&rect,
                                       &rect,
-                                      CenterGravity,
+                                      META_GRAVITY_CENTER,
                                       832,
                                       93);
   g_assert (meta_rectangle_equal (&rect, &temp));
@@ -1293,7 +1293,7 @@ test_gravity_resize (void)
   temp = meta_rect (270,  994, 430, 212);
   meta_rectangle_resize_with_gravity (&rect,
                                       &rect,
-                                      EastGravity,
+                                      META_GRAVITY_EAST,
                                       430,
                                       211);
   g_assert (meta_rectangle_equal (&rect, &temp));
@@ -1302,7 +1302,7 @@ test_gravity_resize (void)
   temp = meta_rect (300, 1000, 430, 211);
   meta_rectangle_resize_with_gravity (&rect,
                                       &rect,
-                                      StaticGravity,
+                                      META_GRAVITY_STATIC,
                                       430,
                                       211);
   g_assert (meta_rectangle_equal (&rect, &temp));
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index cc7f66a92..138ac5410 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -217,7 +217,7 @@ meta_window_wayland_grab_op_ended (MetaWindow *window,
 
 static void
 meta_window_wayland_move_resize_internal (MetaWindow                *window,
-                                          int                        gravity,
+                                          MetaGravity                gravity,
                                           MetaRectangle              unconstrained_rect,
                                           MetaRectangle              constrained_rect,
                                           int                        rel_x,
@@ -815,7 +815,7 @@ meta_window_wayland_finish_move_resize (MetaWindow              *window,
   MetaDisplay *display = window->display;
   int dx, dy;
   int geometry_scale;
-  int gravity;
+  MetaGravity gravity;
   MetaRectangle rect;
   MetaMoveResizeFlags flags;
   MetaWaylandWindowConfiguration *acked_configuration;
diff --git a/src/x11/session.c b/src/x11/session.c
index ee081236d..38929105c 100644
--- a/src/x11/session.c
+++ b/src/x11/session.c
@@ -746,28 +746,28 @@ window_type_from_string (const char *str)
 static int
 window_gravity_from_string (const char *str)
 {
-  if (strcmp (str, "NorthWestGravity") == 0)
-    return NorthWestGravity;
-  else if (strcmp (str, "NorthGravity") == 0)
-    return NorthGravity;
-  else if (strcmp (str, "NorthEastGravity") == 0)
-    return NorthEastGravity;
-  else if (strcmp (str, "WestGravity") == 0)
-    return WestGravity;
-  else if (strcmp (str, "CenterGravity") == 0)
-    return CenterGravity;
-  else if (strcmp (str, "EastGravity") == 0)
-    return EastGravity;
-  else if (strcmp (str, "SouthWestGravity") == 0)
-    return SouthWestGravity;
-  else if (strcmp (str, "SouthGravity") == 0)
-    return SouthGravity;
-  else if (strcmp (str, "SouthEastGravity") == 0)
-    return SouthEastGravity;
-  else if (strcmp (str, "StaticGravity") == 0)
-    return StaticGravity;
+  if (strcmp (str, "META_GRAVITY_NORTH_WEST") == 0)
+    return META_GRAVITY_NORTH_WEST;
+  else if (strcmp (str, "META_GRAVITY_NORTH") == 0)
+    return META_GRAVITY_NORTH;
+  else if (strcmp (str, "META_GRAVITY_NORTH_EAST") == 0)
+    return META_GRAVITY_NORTH_EAST;
+  else if (strcmp (str, "META_GRAVITY_WEST") == 0)
+    return META_GRAVITY_WEST;
+  else if (strcmp (str, "META_GRAVITY_CENTER") == 0)
+    return META_GRAVITY_CENTER;
+  else if (strcmp (str, "META_GRAVITY_EAST") == 0)
+    return META_GRAVITY_EAST;
+  else if (strcmp (str, "META_GRAVITY_SOUTH_WEST") == 0)
+    return META_GRAVITY_SOUTH_WEST;
+  else if (strcmp (str, "META_GRAVITY_SOUTH") == 0)
+    return META_GRAVITY_SOUTH;
+  else if (strcmp (str, "META_GRAVITY_SOUTH_EAST") == 0)
+    return META_GRAVITY_SOUTH_EAST;
+  else if (strcmp (str, "META_GRAVITY_STATIC") == 0)
+    return META_GRAVITY_STATIC;
   else
-    return NorthWestGravity;
+    return META_GRAVITY_NORTH_WEST;
 }
 
 static char*
@@ -1703,7 +1703,7 @@ session_info_new (void)
   info = g_new0 (MetaWindowSessionInfo, 1);
 
   info->type = META_WINDOW_NORMAL;
-  info->gravity = NorthWestGravity;
+  info->gravity = META_GRAVITY_NORTH_WEST;
 
   return info;
 }
diff --git a/src/x11/session.h b/src/x11/session.h
index 86d3489e9..3f9c04a91 100644
--- a/src/x11/session.h
+++ b/src/x11/session.h
@@ -55,7 +55,7 @@ struct _MetaWindowSessionInfo
    * light of gravity. This preserves semantics of the
    * window size/pos, even if fonts/themes change, etc.
    */
-  int gravity;
+  MetaGravity gravity;
   MetaRectangle rect;
   MetaRectangle saved_rect;
   guint on_all_workspaces : 1;
diff --git a/src/x11/window-props.c b/src/x11/window-props.c
index 45a16c4b8..3cad2cd1d 100644
--- a/src/x11/window-props.c
+++ b/src/x11/window-props.c
@@ -1304,7 +1304,7 @@ meta_set_normal_hints (MetaWindow *window,
       meta_topic (META_DEBUG_GEOMETRY,
                   "Window %s doesn't set gravity, using NW\n",
                   window->desc);
-      window->size_hints.win_gravity = NorthWestGravity;
+      window->size_hints.win_gravity = META_GRAVITY_NORTH_WEST;
       window->size_hints.flags |= PWinGravity;
     }
 
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index a546ed089..fcd06f632 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -261,7 +261,7 @@ send_configure_notify (MetaWindow *window)
 static void
 adjust_for_gravity (MetaWindow        *window,
                     gboolean           coords_assume_border,
-                    int                gravity,
+                    MetaGravity        gravity,
                     MetaRectangle     *rect)
 {
   MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
@@ -273,14 +273,14 @@ adjust_for_gravity (MetaWindow        *window,
   MetaFrameBorders borders;
 
   /* We're computing position to pass to window_move, which is
-   * the position of the client window (StaticGravity basically)
+   * the position of the client window (META_GRAVITY_STATIC basically)
    *
    * (see WM spec description of gravity computation, but note that
    * their formulas assume we're honoring the border width, rather
    * than compensating for having turned it off)
    */
 
-  if (gravity == StaticGravity)
+  if (gravity == META_GRAVITY_STATIC)
     return;
 
   if (coords_assume_border)
@@ -296,7 +296,7 @@ adjust_for_gravity (MetaWindow        *window,
   frame_height = child_y + rect->height + borders.visible.bottom;
 
   /* Calculate the the reference point, which is the corner of the
-   * outer window specified by the gravity. So, NorthEastGravity
+   * outer window specified by the gravity. So, META_GRAVITY_NORTH_EAST
    * would have the reference point as the top-right corner of the
    * outer window. */
   ref_x = rect->x;
@@ -304,14 +304,14 @@ adjust_for_gravity (MetaWindow        *window,
 
   switch (gravity)
     {
-    case NorthGravity:
-    case CenterGravity:
-    case SouthGravity:
+    case META_GRAVITY_NORTH:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_SOUTH:
       ref_x += rect->width / 2 + bw;
       break;
-    case NorthEastGravity:
-    case EastGravity:
-    case SouthEastGravity:
+    case META_GRAVITY_NORTH_EAST:
+    case META_GRAVITY_EAST:
+    case META_GRAVITY_SOUTH_EAST:
       ref_x += rect->width + bw * 2;
       break;
     default:
@@ -320,14 +320,14 @@ adjust_for_gravity (MetaWindow        *window,
 
   switch (gravity)
     {
-    case WestGravity:
-    case CenterGravity:
-    case EastGravity:
+    case META_GRAVITY_WEST:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_EAST:
       ref_y += rect->height / 2 + bw;
       break;
-    case SouthWestGravity:
-    case SouthGravity:
-    case SouthEastGravity:
+    case META_GRAVITY_SOUTH_WEST:
+    case META_GRAVITY_SOUTH:
+    case META_GRAVITY_SOUTH_EAST:
       ref_y += rect->height + bw * 2;
       break;
     default:
@@ -342,30 +342,34 @@ adjust_for_gravity (MetaWindow        *window,
 
   switch (gravity)
     {
-    case NorthGravity:
-    case CenterGravity:
-    case SouthGravity:
+    case META_GRAVITY_NORTH:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_SOUTH:
       rect->x -= frame_width / 2;
       break;
-    case NorthEastGravity:
-    case EastGravity:
-    case SouthEastGravity:
+    case META_GRAVITY_NORTH_EAST:
+    case META_GRAVITY_EAST:
+    case META_GRAVITY_SOUTH_EAST:
       rect->x -= frame_width;
       break;
+    default:
+      break;
     }
 
   switch (gravity)
     {
-    case WestGravity:
-    case CenterGravity:
-    case EastGravity:
+    case META_GRAVITY_WEST:
+    case META_GRAVITY_CENTER:
+    case META_GRAVITY_EAST:
       rect->y -= frame_height / 2;
       break;
-    case SouthWestGravity:
-    case SouthGravity:
-    case SouthEastGravity:
+    case META_GRAVITY_SOUTH_WEST:
+    case META_GRAVITY_SOUTH:
+    case META_GRAVITY_SOUTH_EAST:
       rect->y -= frame_height;
       break;
+    default:
+      break;
     }
 
   /* Adjust to get the top-left corner of the inner window. */
@@ -481,7 +485,7 @@ meta_window_apply_session_info (MetaWindow *window,
     {
       MetaRectangle rect;
       MetaMoveResizeFlags flags;
-      int gravity;
+      MetaGravity gravity;
 
       window->placed = TRUE; /* don't do placement algorithms later */
 
@@ -556,7 +560,7 @@ meta_window_x11_manage (MetaWindow *window)
     {
       MetaRectangle rect;
       MetaMoveResizeFlags flags;
-      int gravity = window->size_hints.win_gravity;
+      MetaGravity gravity = window->size_hints.win_gravity;
 
       rect.x = window->size_hints.x;
       rect.y = window->size_hints.y;
@@ -1305,7 +1309,7 @@ meta_window_x11_current_workspace_changed (MetaWindow *window)
 
 static void
 meta_window_x11_move_resize_internal (MetaWindow                *window,
-                                      int                        gravity,
+                                      MetaGravity                gravity,
                                       MetaRectangle              unconstrained_rect,
                                       MetaRectangle              constrained_rect,
                                       int                        rel_x,
@@ -1472,9 +1476,9 @@ meta_window_x11_move_resize_internal (MetaWindow                *window,
    * Mail from Owen subject "Suggestion: Gravity and resizing from the left"
    * http://mail.gnome.org/archives/wm-spec-list/1999-November/msg00088.html
    *
-   * An annoying fact you need to know in this code is that StaticGravity
+   * An annoying fact you need to know in this code is that META_GRAVITY_STATIC
    * does nothing if you _only_ resize or _only_ move the frame;
-   * it must move _and_ resize, otherwise you get NorthWestGravity
+   * it must move _and_ resize, otherwise you get META_GRAVITY_NORTH_WEST
    * behavior. The move and resize must actually occur, it is not
    * enough to set CWX | CWWidth but pass in the current size/pos.
    */
@@ -2442,13 +2446,13 @@ meta_window_same_client (MetaWindow *window,
 }
 
 static void
-meta_window_move_resize_request (MetaWindow *window,
-                                 guint       value_mask,
-                                 int         gravity,
-                                 int         new_x,
-                                 int         new_y,
-                                 int         new_width,
-                                 int         new_height)
+meta_window_move_resize_request (MetaWindow  *window,
+                                 guint        value_mask,
+                                 MetaGravity  gravity,
+                                 int          new_x,
+                                 int          new_y,
+                                 int          new_width,
+                                 int          new_height)
 {
   int x, y, width, height;
   gboolean allow_position_change;
@@ -3220,10 +3224,10 @@ meta_window_x11_client_message (MetaWindow *window,
   else if (event->xclient.message_type ==
            x11_display->atom__NET_MOVERESIZE_WINDOW)
     {
-      int gravity;
+      MetaGravity gravity;
       guint value_mask;
 
-      gravity = (event->xclient.data.l[0] & 0xff);
+      gravity = (MetaGravity) (event->xclient.data.l[0] & 0xff);
       value_mask = (event->xclient.data.l[0] & 0xf00) >> 8;
       /* source = (event->xclient.data.l[0] & 0xf000) >> 12; */
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]