[gnome-panel/wip/muktupavels/alignment: 6/6] toplevel: use alignment setting for panel positioning




commit 40dc98e31b95560dfda57c57dee97698e373efb1
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Apr 22 12:44:47 2021 +0300

    toplevel: use alignment setting for panel positioning
    
    https://gitlab.gnome.org/GNOME/gnome-panel/-/merge_requests/9

 data/org.gnome.gnome-panel.toplevel.gschema.xml |  30 -
 gnome-panel/panel-layout.c                      |   6 -
 gnome-panel/panel-schemas.h                     |   6 -
 gnome-panel/panel-toplevel.c                    | 861 ++++++------------------
 gnome-panel/panel-toplevel.h                    |   8 -
 5 files changed, 190 insertions(+), 721 deletions(-)
---
diff --git a/data/org.gnome.gnome-panel.toplevel.gschema.xml b/data/org.gnome.gnome-panel.toplevel.gschema.xml
index 0f70e3ccb..9ae70073d 100644
--- a/data/org.gnome.gnome-panel.toplevel.gschema.xml
+++ b/data/org.gnome.gnome-panel.toplevel.gschema.xml
@@ -30,36 +30,6 @@
       <summary>Panel size</summary>
       <description>The height (width for a vertical panel) of the panel. The panel will determine at runtime 
a minimum size based on the font size and other indicators. The maximum size is fixed at one quarter of the 
screen height (or width).</description>
     </key>
-    <key name="x" type="i">
-      <default>0</default>
-      <summary>X co-ordinate of panel</summary>
-      <description>The location of the panel along the x-axis. This key is only relevant in un-expanded 
mode. In expanded mode this key is ignored and the panel is placed at the screen edge specified by the 
orientation key.</description>
-    </key>
-    <key name="y" type="i">
-      <default>0</default>
-      <summary>Y co-ordinate of panel</summary>
-      <description>The location of the panel along the y-axis. This key is only relevant in un-expanded 
mode. In expanded mode this key is ignored and the panel is placed at the screen edge specified by the 
orientation key.</description>
-    </key>
-    <key name="x-right" type="i">
-      <default>-1</default>
-      <summary>X co-ordinate of panel, starting from the right of the screen</summary>
-      <description>The location of the panel along the x-axis, starting from the right of  the screen. If 
set to -1, the value is ignored and the value of the x key is used. If the value is greater than 0, then the 
value of the x key is ignored. This key is only relevant in un-expanded mode. In expanded mode this key is 
ignored and the panel is placed at the screen edge specified by the orientation key.</description>
-    </key>
-    <key name="y-bottom" type="i">
-      <default>-1</default>
-      <summary>Y co-ordinate of panel, starting from the bottom of the screen</summary>
-      <description>The location of the panel along the y-axis, starting from the bottom of  the screen. If 
set to -1, the value is ignored and the value of the y key is used. If the value is greater than 0, then the 
value of the y key is ignored. This key is only relevant in un-expanded mode. In expanded mode this key is 
ignored and the panel is placed at the screen edge specified by the orientation key.</description>
-    </key>
-    <key name="x-centered" type="b">
-      <default>false</default>
-      <summary>Center panel on x-axis</summary>
-      <description>If true, the x and x_right keys are ignored and the panel is placed at the center of the 
x-axis of the screen. If the panel is resized it will remain at that position - i.e. the panel will grow on 
both sides. If false, the x and x_right keys specify the location of the panel.</description>
-    </key>
-    <key name="y-centered" type="b">
-      <default>false</default>
-      <summary>Center panel on y-axis</summary>
-      <description>If true, the y and y_bottom keys are ignored and the panel is placed at the center of the 
y-axis of the screen. If the panel is resized it will remain at that position - i.e. the panel will grow on 
both sides. If false, the y and y_bottom keys specify the location of the panel.</description>
-    </key>
     <key name="auto-hide" type="b">
       <default>false</default>
       <summary>Automatically hide panel into corner</summary>
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index f7265743b..d7c25c98b 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -92,12 +92,6 @@ static PanelLayoutKeyDefinition panel_layout_toplevel_keys[] = {
         { PANEL_TOPLEVEL_ORIENTATION_KEY,     G_TYPE_STRING   },
         { PANEL_TOPLEVEL_ALIGNMENT_KEY,       G_TYPE_INT      },
         { PANEL_TOPLEVEL_SIZE_KEY,            G_TYPE_INT      },
-        { PANEL_TOPLEVEL_X_KEY,               G_TYPE_INT      },
-        { PANEL_TOPLEVEL_Y_KEY,               G_TYPE_INT      },
-        { PANEL_TOPLEVEL_X_RIGHT_KEY,         G_TYPE_INT      },
-        { PANEL_TOPLEVEL_Y_BOTTOM_KEY,        G_TYPE_INT      },
-        { PANEL_TOPLEVEL_X_CENTERED_KEY,      G_TYPE_BOOLEAN  },
-        { PANEL_TOPLEVEL_Y_CENTERED_KEY,      G_TYPE_BOOLEAN  },
         { PANEL_TOPLEVEL_AUTO_HIDE_KEY,       G_TYPE_BOOLEAN  },
         { PANEL_TOPLEVEL_ENABLE_BUTTONS_KEY,  G_TYPE_BOOLEAN  },
         { PANEL_TOPLEVEL_ENABLE_ARROWS_KEY,   G_TYPE_BOOLEAN  },
diff --git a/gnome-panel/panel-schemas.h b/gnome-panel/panel-schemas.h
index d0ee8dcca..edba65261 100644
--- a/gnome-panel/panel-schemas.h
+++ b/gnome-panel/panel-schemas.h
@@ -40,12 +40,6 @@
 #define PANEL_TOPLEVEL_ORIENTATION_KEY      "orientation"
 #define PANEL_TOPLEVEL_ALIGNMENT_KEY        "alignment"
 #define PANEL_TOPLEVEL_SIZE_KEY             "size"
-#define PANEL_TOPLEVEL_X_KEY                "x"
-#define PANEL_TOPLEVEL_Y_KEY                "y"
-#define PANEL_TOPLEVEL_X_RIGHT_KEY          "x-right"
-#define PANEL_TOPLEVEL_Y_BOTTOM_KEY         "y-bottom"
-#define PANEL_TOPLEVEL_X_CENTERED_KEY       "x-centered"
-#define PANEL_TOPLEVEL_Y_CENTERED_KEY       "y-centered"
 #define PANEL_TOPLEVEL_AUTO_HIDE_KEY        "auto-hide"
 #define PANEL_TOPLEVEL_ENABLE_BUTTONS_KEY   "enable-buttons"
 #define PANEL_TOPLEVEL_ENABLE_ARROWS_KEY    "enable-arrows"
diff --git a/gnome-panel/panel-toplevel.c b/gnome-panel/panel-toplevel.c
index bf4b6fb14..5e99b99a7 100644
--- a/gnome-panel/panel-toplevel.c
+++ b/gnome-panel/panel-toplevel.c
@@ -92,13 +92,6 @@ struct _PanelToplevelPrivate {
        PanelAlignment          alignment;
        int                     size;
 
-       /* relative to the monitor origin */
-       int                     x;
-       int                     y;
-       /* relative to the bottom right corner, -1 to ignore and use x, y*/
-       int                     x_right;
-       int                     y_bottom;
-
        int                     monitor;
        /* this is used when the configured monitor is missing. We keep it so
         * we can move the toplevel to the right monitor when it becomes
@@ -136,10 +129,6 @@ struct _PanelToplevelPrivate {
 
        /* Saved state before for cancelled grab op */
        int                     orig_monitor;
-       int                     orig_x;
-       int                     orig_y;
-       int                     orig_x_right;
-       int                     orig_y_bottom;
        int                     orig_size;
        int                     orig_orientation;
        PanelAlignment          orig_alignment;
@@ -175,10 +164,6 @@ struct _PanelToplevelPrivate {
        /* This is a keyboard initiated grab operation */
        guint                   grab_is_keyboard : 1;
 
-       /* More saved grab op state */
-       guint                   orig_x_centered : 1;
-       guint                   orig_y_centered : 1;
-
        /* flag to see if we have already done geometry updating,
           if not then we're still loading and can ignore many things */
        guint                   updated_geometry_initial : 1;
@@ -208,12 +193,6 @@ enum {
        PROP_ORIENTATION,
        PROP_ALIGNMENT,
        PROP_SIZE,
-       PROP_X,
-       PROP_X_RIGHT,
-       PROP_X_CENTERED,
-       PROP_Y,
-       PROP_Y_BOTTOM,
-       PROP_Y_CENTERED,
        PROP_MONITOR,
        PROP_AUTOHIDE,
        PROP_HIDE_DELAY,
@@ -412,6 +391,118 @@ panel_toplevel_get_monitor_geometry (PanelToplevel *toplevel,
        return screen;
 }
 
+static void
+get_normal_position (PanelToplevel *toplevel,
+                     int           *x,
+                     int           *y)
+{
+       int monitor_x;
+       int monitor_y;
+       int monitor_width;
+       int monitor_height;
+
+       *x = -1;
+       *y = -1;
+
+       panel_toplevel_get_monitor_geometry (toplevel,
+                                            &monitor_x,
+                                            &monitor_y,
+                                            &monitor_width,
+                                            &monitor_height);
+
+       if (toplevel->priv->expand) {
+               switch (toplevel->priv->orientation) {
+                       case PANEL_ORIENTATION_TOP:
+                               *x = monitor_x;
+                               *y = monitor_y;
+                               break;
+                       case PANEL_ORIENTATION_LEFT:
+                               *x = monitor_x;
+                               *y = monitor_y;
+                               break;
+                       case PANEL_ORIENTATION_BOTTOM:
+                               *x = monitor_x;
+                               *y = monitor_y + monitor_height - toplevel->priv->geometry.height;
+                               break;
+                       case PANEL_ORIENTATION_RIGHT:
+                               *x = monitor_x + monitor_width - toplevel->priv->geometry.width;
+                               *y = monitor_y;
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                               break;
+               }
+       } else if (toplevel->priv->alignment == PANEL_ALIGNMENT_START) {
+               switch (toplevel->priv->orientation) {
+                       case PANEL_ORIENTATION_TOP:
+                               *x = monitor_x;
+                               *y = monitor_y;
+                               break;
+                       case PANEL_ORIENTATION_LEFT:
+                               *x = monitor_x;
+                               *y = monitor_y;
+                               break;
+                       case PANEL_ORIENTATION_BOTTOM:
+                               *x = monitor_x;
+                               *y = monitor_y + monitor_height - toplevel->priv->geometry.height;
+                               break;
+                       case PANEL_ORIENTATION_RIGHT:
+                               *x = monitor_x + monitor_width - toplevel->priv->geometry.width;
+                               *y = monitor_y;
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                               break;
+               }
+       } else if (toplevel->priv->alignment == PANEL_ALIGNMENT_CENTER) {
+               switch (toplevel->priv->orientation) {
+                       case PANEL_ORIENTATION_TOP:
+                               *x = monitor_x + monitor_width / 2 - toplevel->priv->geometry.width / 2;
+                               *y = monitor_y;
+                               break;
+                       case PANEL_ORIENTATION_LEFT:
+                               *x = monitor_x;
+                               *y = monitor_y + monitor_height / 2 - toplevel->priv->geometry.height / 2;
+                               break;
+                       case PANEL_ORIENTATION_BOTTOM:
+                               *x = monitor_x + monitor_width / 2 - toplevel->priv->geometry.width / 2;
+                               *y = monitor_y + monitor_height - toplevel->priv->geometry.height;
+                               break;
+                       case PANEL_ORIENTATION_RIGHT:
+                               *x = monitor_x + monitor_width - toplevel->priv->geometry.width;
+                               *y = monitor_y + monitor_height / 2 - toplevel->priv->geometry.height / 2;
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                               break;
+               }
+       } else if (toplevel->priv->alignment == PANEL_ALIGNMENT_END) {
+               switch (toplevel->priv->orientation) {
+                       case PANEL_ORIENTATION_TOP:
+                               *x = monitor_x + monitor_width - toplevel->priv->geometry.width;
+                               *y = monitor_y;
+                               break;
+                       case PANEL_ORIENTATION_LEFT:
+                               *x = monitor_x;
+                               *y = monitor_y + monitor_height - toplevel->priv->geometry.height;
+                               break;
+                       case PANEL_ORIENTATION_BOTTOM:
+                               *x = monitor_x + monitor_width - toplevel->priv->geometry.width;
+                               *y = monitor_y + monitor_height - toplevel->priv->geometry.height;
+                               break;
+                       case PANEL_ORIENTATION_RIGHT:
+                               *x = monitor_x + monitor_width - toplevel->priv->geometry.width;
+                               *y = monitor_y + monitor_height - toplevel->priv->geometry.height;
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                               break;
+               }
+       } else {
+               g_assert_not_reached ();
+       }
+}
+
 static GdkCursorType
 panel_toplevel_grab_op_cursor (PanelToplevel   *toplevel,
                               PanelGrabOpType  grab_op)
@@ -572,12 +663,6 @@ panel_toplevel_begin_grab_op (PanelToplevel   *toplevel,
        toplevel->priv->grab_is_keyboard = grab_keyboard;
 
        toplevel->priv->orig_monitor     = toplevel->priv->monitor;
-       toplevel->priv->orig_x           = toplevel->priv->x;
-       toplevel->priv->orig_x_right     = toplevel->priv->x_right;
-       toplevel->priv->orig_x_centered  = toplevel->priv->x_centered;
-       toplevel->priv->orig_y           = toplevel->priv->y;
-       toplevel->priv->orig_y_bottom    = toplevel->priv->y_bottom;
-       toplevel->priv->orig_y_centered  = toplevel->priv->y_centered;
        toplevel->priv->orig_size        = toplevel->priv->size;
        toplevel->priv->orig_orientation = toplevel->priv->orientation;
        toplevel->priv->orig_alignment   = toplevel->priv->alignment;
@@ -658,14 +743,6 @@ panel_toplevel_cancel_grab_op (PanelToplevel *toplevel,
        panel_toplevel_set_alignment (toplevel, toplevel->priv->orig_alignment);
        panel_toplevel_set_monitor (toplevel, toplevel->priv->orig_monitor);
        panel_toplevel_set_size (toplevel, toplevel->priv->orig_size);
-       panel_toplevel_set_x (toplevel,
-                             toplevel->priv->orig_x,
-                             toplevel->priv->orig_x_right,
-                             toplevel->priv->orig_x_centered);
-       panel_toplevel_set_y (toplevel,
-                             toplevel->priv->orig_y,
-                             toplevel->priv->orig_y_bottom,
-                             toplevel->priv->orig_y_centered);
 }
 
 static void
@@ -674,18 +751,9 @@ panel_toplevel_resize_to_pointer (PanelToplevel *toplevel,
                                  int            y)
 {
        int new_size;
-       int new_x, new_y;
-       int new_x_right, new_y_bottom;
-       int new_x_centered, new_y_centered;
        int monitor_width, monitor_height;
 
        new_size       = toplevel->priv->size;
-       new_x          = toplevel->priv->x;
-       new_y          = toplevel->priv->y;
-       new_x_right    = toplevel->priv->x_right;
-       new_y_bottom   = toplevel->priv->y_bottom;
-       new_x_centered = toplevel->priv->x_centered;
-       new_y_centered = toplevel->priv->y_centered;
 
        panel_toplevel_get_monitor_geometry (toplevel, NULL, NULL, &monitor_width, &monitor_height);
 
@@ -693,36 +761,18 @@ panel_toplevel_resize_to_pointer (PanelToplevel *toplevel,
        case PANEL_GRAB_OP_RESIZE_UP:
                new_size = toplevel->priv->drag_offset_y - y;
                new_size = CLAMP (new_size, 0, monitor_height / 4);
-               new_y -= (new_size - toplevel->priv->size);
-               if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_height / 2)
-                       new_y_bottom = monitor_height - (new_y + new_size);
-               else
-                       new_y_bottom = -1;
                break;
        case PANEL_GRAB_OP_RESIZE_DOWN:
                new_size = y - toplevel->priv->drag_offset_y;
                new_size = CLAMP (new_size, 0, monitor_height / 4);
-               if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_height / 2)
-                       new_y_bottom = monitor_height - (new_y + new_size);
-               else
-                       new_y_bottom = -1;
                break;
        case PANEL_GRAB_OP_RESIZE_LEFT:
                new_size = toplevel->priv->drag_offset_x - x;
                new_size = CLAMP (new_size, 0, monitor_width / 4);
-               new_x -= (new_size - toplevel->priv->size);
-               if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_width / 2)
-                       new_x_right = monitor_width - (new_x + new_size);
-               else
-                       new_x_right = -1;
                break;
        case PANEL_GRAB_OP_RESIZE_RIGHT:
                new_size = x - toplevel->priv->drag_offset_x;
                new_size = CLAMP (new_size, 0, monitor_width / 4);
-               if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_width / 2)
-                       new_x_right = monitor_width - (new_x + new_size);
-               else
-                       new_x_right = -1;
                break;
        case PANEL_GRAB_OP_MOVE:
        case PANEL_GRAB_OP_RESIZE:
@@ -735,8 +785,6 @@ panel_toplevel_resize_to_pointer (PanelToplevel *toplevel,
        if (new_size == 0)
                return;
 
-       panel_toplevel_set_x (toplevel, new_x, new_x_right, new_x_centered);
-       panel_toplevel_set_y (toplevel, new_y, new_y_bottom, new_y_centered);
        panel_toplevel_set_size (toplevel, new_size);
 }
 
@@ -750,6 +798,7 @@ panel_toplevel_calc_new_orientation (PanelToplevel *toplevel,
        GdkScreen        *screen;
        int               hborder, vborder;
        int               monitor;
+       int               monitor_x, monitor_y;
        int               monitor_width, monitor_height;
        int               new_x, new_y;
 
@@ -762,55 +811,57 @@ panel_toplevel_calc_new_orientation (PanelToplevel *toplevel,
        else
                vborder = hborder = (3 * toplevel->priv->geometry.width)  >> 1;
 
-       new_x = pointer_x - panel_multiscreen_x (screen, monitor);
-       new_y = pointer_y - panel_multiscreen_y (screen, monitor);
+       monitor_x = panel_multiscreen_x (screen, monitor);
+       monitor_y = panel_multiscreen_y (screen, monitor);
        monitor_width = panel_multiscreen_width (screen, monitor);
        monitor_height = panel_multiscreen_height (screen, monitor);
+       new_x = pointer_x;
+       new_y = pointer_y;
 
        new_orientation = toplevel->priv->orientation;
 
        switch (toplevel->priv->orientation) {
        case PANEL_ORIENTATION_TOP:
-               if (new_y > (monitor_height - hborder))
+               if (new_y > (monitor_y + monitor_height - hborder))
                        new_orientation = PANEL_ORIENTATION_BOTTOM;
 
-               else if (new_y > hborder) {
-                       if (new_x > (monitor_width - vborder))
+               else if (new_y > monitor_y + hborder) {
+                       if (new_x > (monitor_x + monitor_width - vborder))
                                new_orientation = PANEL_ORIENTATION_RIGHT;
-                       else if (new_x < vborder)
+                       else if (new_x < monitor_x + vborder)
                                new_orientation = PANEL_ORIENTATION_LEFT;
                } 
                break;
        case PANEL_ORIENTATION_BOTTOM:
-               if (new_y < hborder)
+               if (new_y < monitor_y + hborder)
                        new_orientation = PANEL_ORIENTATION_TOP;
 
-               else if (new_y < (monitor_height - hborder)) {
-                       if (new_x > (monitor_width - vborder))
+               else if (new_y < (monitor_y + monitor_height - hborder)) {
+                       if (new_x > (monitor_x + monitor_width - vborder))
                                new_orientation = PANEL_ORIENTATION_RIGHT;
-                       else if (new_x < vborder)
+                       else if (new_x < monitor_x + vborder)
                                new_orientation = PANEL_ORIENTATION_LEFT;
                } 
                break;
        case PANEL_ORIENTATION_LEFT:
-               if (new_x > (monitor_width - vborder))
+               if (new_x > (monitor_x + monitor_width - vborder))
                        new_orientation = PANEL_ORIENTATION_RIGHT;
 
-               else if (new_x > vborder) {
-                       if (new_y > (monitor_height - hborder))
+               else if (new_x > monitor_x + vborder) {
+                       if (new_y > (monitor_y + monitor_height - hborder))
                                new_orientation = PANEL_ORIENTATION_BOTTOM;
-                       else if (new_y < hborder)
+                       else if (new_y < monitor_y + hborder)
                                new_orientation = PANEL_ORIENTATION_TOP;
                } 
                break;
        case PANEL_ORIENTATION_RIGHT:
-               if (new_x < vborder)
+               if (new_x < monitor_x + vborder)
                        new_orientation = PANEL_ORIENTATION_LEFT;
 
-               else if (new_x < (monitor_width - vborder)) {
-                       if (new_y > (monitor_height - hborder))
+               else if (new_x < (monitor_x + monitor_width - vborder)) {
+                       if (new_y > (monitor_y + monitor_height - hborder))
                                new_orientation = PANEL_ORIENTATION_BOTTOM;
-                       else if (new_y < hborder)
+                       else if (new_y < monitor_y + hborder)
                                new_orientation = PANEL_ORIENTATION_TOP;
                }
                break;
@@ -830,12 +881,12 @@ panel_toplevel_move_to (PanelToplevel *toplevel,
 {
        GdkScreen        *screen;
        PanelOrientation  new_orientation;
-       gboolean          x_centered, y_centered;
+       PanelAlignment    new_alignment;
        int               monitor_x, monitor_y;
        int               monitor_width, monitor_height;
        int               width, height;
        int               new_monitor;
-       int               x, y, x_right, y_bottom;
+       int               x, y;
        int               snap_tolerance;
 
        screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
@@ -857,8 +908,6 @@ panel_toplevel_move_to (PanelToplevel *toplevel,
        x = new_x - monitor_x;
        y = new_y - monitor_y;
 
-       new_orientation = toplevel->priv->orientation;
-
        if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK) {
                if (x <= snap_tolerance &&
                    y > snap_tolerance &&
@@ -889,54 +938,27 @@ panel_toplevel_move_to (PanelToplevel *toplevel,
                }
        }
 
-       x_right = toplevel->priv->x_right;
-       y_bottom = toplevel->priv->y_bottom;
-
-       x_centered = toplevel->priv->x_centered;
-       y_centered = toplevel->priv->y_centered;
-
        if (new_orientation & PANEL_HORIZONTAL_MASK) {
-               x_centered = abs (x - ((monitor_width - width) / 2)) <= snap_tolerance;
-               y_centered = FALSE;
-
-               if (x_centered) {
-                       x = (monitor_width - width) / 2;
+               if (abs (x - ((monitor_width - width) / 2)) <= snap_tolerance) {
+                       new_alignment = PANEL_ALIGNMENT_CENTER;
                } else if ((x + width / 2) > monitor_width / 2) {
-                       x_right = monitor_width - (x + width);
-               } else {
-                       x_right = -1;
-               }
-
-               if ((y + height / 2) > monitor_height / 2) {
-                       y_bottom = 0;
+                       new_alignment = PANEL_ALIGNMENT_END;
                } else {
-                       y_bottom = -1;
-                       y = 0;
+                       new_alignment = PANEL_ALIGNMENT_START;
                }
        } else {
-               x_centered = FALSE;
-               y_centered = abs (y - ((monitor_height - height) / 2)) <= snap_tolerance;
-
-               if ((x + width / 2) > monitor_width / 2) {
-                       x_right = 0;
-               } else {
-                       x_right = -1;
-                       x = 0;
-               }
-
-               if (y_centered) {
-                       y = (monitor_height - height) / 2;
+               if (abs (y - ((monitor_height - height) / 2)) <= snap_tolerance) {
+                       new_alignment = PANEL_ALIGNMENT_CENTER;
                } else if ((y + height / 2) > monitor_height / 2) {
-                       y_bottom = monitor_height - (y + height);
+                       new_alignment = PANEL_ALIGNMENT_END;
                } else {
-                       y_bottom = -1;
+                       new_alignment = PANEL_ALIGNMENT_START;
                }
        }
 
        panel_toplevel_set_monitor (toplevel, new_monitor);
        panel_toplevel_set_orientation (toplevel, new_orientation);
-       panel_toplevel_set_x (toplevel, x, x_right, x_centered);
-       panel_toplevel_set_y (toplevel, y, y_bottom, y_centered);
+       panel_toplevel_set_alignment (toplevel, new_alignment);
 }
 
 static void
@@ -1387,7 +1409,6 @@ static gboolean
 panel_toplevel_update_struts (PanelToplevel *toplevel, gboolean end_of_animation)
 {
        PanelOrientation  orientation;
-       GdkScreen        *screen;
        gboolean          geometry_changed = FALSE;
        int               strut, strut_start, strut_end;
        int               x, y, width, height;
@@ -1411,17 +1432,15 @@ panel_toplevel_update_struts (PanelToplevel *toplevel, gboolean end_of_animation
                        panel_toplevel_calculate_animation_end_geometry (toplevel);
        }
 
-       screen = panel_toplevel_get_monitor_geometry (toplevel,
-                                                     &monitor_x,
-                                                     &monitor_y,
-                                                     &monitor_width,
-                                                     &monitor_height);
+       panel_toplevel_get_monitor_geometry (toplevel,
+                                            &monitor_x,
+                                            &monitor_y,
+                                            &monitor_width,
+                                            &monitor_height);
 
        if (end_of_animation) {
                x = toplevel->priv->animation_end_x;
                y = toplevel->priv->animation_end_y;
-               x += panel_multiscreen_x (screen, toplevel->priv->monitor);
-               y += panel_multiscreen_y (screen, toplevel->priv->monitor);
                width = toplevel->priv->geometry.width;
                height = toplevel->priv->geometry.height;
        } else {
@@ -1496,31 +1515,35 @@ panel_toplevel_construct_description (PanelToplevel *toplevel)
 {
        int orientation, type;
 
-       static const char *description[4][3] = {
+       static const char *description[4][4] = {
                {
        /* translators: these string will be shown in MetaCity's switch window
         * popup when you pass the focus to a panel */
                        N_("Top Expanded Edge Panel"),
                        N_("Top Centered Panel"),
-                       N_("Top Edge Panel"),
+                       N_("Top Start Panel"),
+                       N_("Top End Panel")
                },
                
                {
                        N_("Bottom Expanded Edge Panel"),
-                       N_("Bottom Centered Panel"),
-                       N_("Bottom Edge Panel"),
+                       N_("Bottom Centered Panel"),
+                       N_("Bottom Start Panel"),
+                       N_("Bottom End Panel")
                },
 
                {
                        N_("Left Expanded Edge Panel"),
                        N_("Left Centered Panel"),
-                       N_("Left Edge Panel"),
+                       N_("Left Start Panel"),
+                       N_("Left End Panel")
                },
 
                {
                        N_("Right Expanded Edge Panel"),
                        N_("Right Centered Panel"),
-                       N_("Right Edge Panel"),
+                       N_("Right Start Panel"),
+                       N_("Right End Panel")
                },
        };
 
@@ -1545,11 +1568,14 @@ panel_toplevel_construct_description (PanelToplevel *toplevel)
 
        if (toplevel->priv->expand)
                type = 0;
-       else if (toplevel->priv->x_centered ||
-                toplevel->priv->y_centered)
+       else if (toplevel->priv->alignment == PANEL_ALIGNMENT_CENTER)
                type = 1;
-       else
+       else if (toplevel->priv->alignment == PANEL_ALIGNMENT_START)
                type = 2;
+       else if (toplevel->priv->alignment == PANEL_ALIGNMENT_END)
+               type = 3;
+       else
+               g_assert_not_reached ();
        
        return description[orientation][type];
 }
@@ -1585,39 +1611,20 @@ panel_toplevel_update_normal_position (PanelToplevel *toplevel,
                                       int           *x,
                                       int           *y)
 {
+       int        monitor_x, monitor_y;
        int        monitor_width, monitor_height;
        int        width, height;
-       int        snap_tolerance;
 
        g_assert (x != NULL && y != NULL);
 
        panel_toplevel_get_monitor_geometry (
-                       toplevel, NULL, NULL, &monitor_width, &monitor_height);
+                       toplevel, &monitor_x, &monitor_y, &monitor_width, &monitor_height);
 
        width  = toplevel->priv->original_width;
        height = toplevel->priv->original_height;
-       snap_tolerance = toplevel->priv->snap_tolerance;
-
-       *x = CLAMP (*x, 0, monitor_width  - width);
-       *y = CLAMP (*y, 0, monitor_height - height);
 
-       if (toplevel->priv->x <= snap_tolerance &&
-           toplevel->priv->x_right == -1 &&
-           !toplevel->priv->x_centered)
-               *x = 0;
-       else if (toplevel->priv->x_right != -1 &&
-                toplevel->priv->x_right <= snap_tolerance &&
-                !toplevel->priv->x_centered)
-               *x = monitor_width - width;
-
-       if (toplevel->priv->y <= snap_tolerance &&
-           toplevel->priv->y_bottom == -1 &&
-           !toplevel->priv->y_centered)
-               *y = 0;
-       else if (toplevel->priv->y_bottom != -1 &&
-                toplevel->priv->y_bottom <= snap_tolerance &&
-                !toplevel->priv->y_centered)
-               *y = monitor_height - height;
+       *x = CLAMP (*x, monitor_x, monitor_x + monitor_width  - width);
+       *y = CLAMP (*y, monitor_y, monitor_y + monitor_height - height);
 }
 
 static void
@@ -1627,18 +1634,17 @@ panel_toplevel_update_auto_hide_position (PanelToplevel *toplevel,
                                          gboolean       for_end_position)
 {
        int width, height;
+       int monitor_x, monitor_y;
        int monitor_width, monitor_height;
        int auto_hide_size;
-       int snap_tolerance;
 
        g_assert (x != NULL && y != NULL);
 
        panel_toplevel_get_monitor_geometry (
-                       toplevel, NULL, NULL, &monitor_width, &monitor_height);
+                       toplevel, &monitor_x, &monitor_y, &monitor_width, &monitor_height);
 
        width  = toplevel->priv->original_width;
        height = toplevel->priv->original_height;
-       snap_tolerance = toplevel->priv->snap_tolerance;
 
        /* For the initial animation, we animate from outside the screen, and
         * so we don't want the toplevel to be visible at all. But when the
@@ -1652,41 +1658,21 @@ panel_toplevel_update_auto_hide_position (PanelToplevel *toplevel,
 
        switch (toplevel->priv->orientation) {
        case PANEL_ORIENTATION_TOP:
-               *y = - (height - auto_hide_size);
+               *y = monitor_y - (height - auto_hide_size);
                break;
        case PANEL_ORIENTATION_BOTTOM:
-               *y = monitor_height - auto_hide_size;
+               *y = monitor_y + monitor_height - auto_hide_size;
                break;
        case PANEL_ORIENTATION_LEFT:
-               *x = - (width - auto_hide_size);
+               *x = monitor_x - (width - auto_hide_size);
                break;
        case PANEL_ORIENTATION_RIGHT:
-               *x = monitor_width - auto_hide_size;
+               *x = monitor_x + monitor_width - auto_hide_size;
                break;
        default:
                g_assert_not_reached ();
                break;
        }
-
-       if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK) {
-               if (toplevel->priv->x <= snap_tolerance &&
-                   toplevel->priv->x_right == -1 &&
-                   !toplevel->priv->x_centered)
-                       *x = 0;
-               else if (toplevel->priv->x_right != -1 &&
-                        toplevel->priv->x_right <= snap_tolerance &&
-                        !toplevel->priv->x_centered)
-                       *x = monitor_width - width;
-       } else /* if (toplevel->priv->orientation & PANEL_VERTICAL_MASK) */ {
-               if (toplevel->priv->y <= snap_tolerance &&
-                   toplevel->priv->y_bottom == -1 &&
-                   !toplevel->priv->y_centered)
-                       *y = 0;
-               else if (toplevel->priv->y_bottom != -1 &&
-                        toplevel->priv->y_bottom <= snap_tolerance &&
-                        !toplevel->priv->y_centered)
-                       *y = monitor_height - height;
-       }
 }
 
 /* FIXME: this is wrong for Xinerama. In the Xinerama case
@@ -1701,6 +1687,7 @@ panel_toplevel_update_hidden_position (PanelToplevel *toplevel,
 {
        int width, height;
        int min_hide_size;
+       int monitor_x, monitor_y;
        int monitor_height, monitor_width;
        GtkAllocation hide_allocation;
 
@@ -1712,7 +1699,7 @@ panel_toplevel_update_hidden_position (PanelToplevel *toplevel,
                  toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT);
 
        panel_toplevel_get_monitor_geometry (
-                       toplevel, NULL, NULL, &monitor_width, &monitor_height);
+                       toplevel, &monitor_x, &monitor_y, &monitor_width, &monitor_height);
 
        width  = toplevel->priv->original_width;
        height = toplevel->priv->original_height;
@@ -1729,7 +1716,7 @@ panel_toplevel_update_hidden_position (PanelToplevel *toplevel,
        case PANEL_STATE_HIDDEN_DOWN:
                gtk_widget_get_allocation (toplevel->priv->hide_button_top,
                                           &hide_allocation);
-               *y = monitor_height - MAX (hide_allocation.height, min_hide_size);
+               *y = monitor_y + monitor_height - MAX (hide_allocation.height, min_hide_size);
                break;
        case PANEL_STATE_HIDDEN_LEFT:
                gtk_widget_get_allocation (toplevel->priv->hide_button_right,
@@ -1739,7 +1726,7 @@ panel_toplevel_update_hidden_position (PanelToplevel *toplevel,
        case PANEL_STATE_HIDDEN_RIGHT:
                gtk_widget_get_allocation (toplevel->priv->hide_button_left,
                                           &hide_allocation);
-               *x = monitor_width - MAX (hide_allocation.width, min_hide_size);
+               *x = monitor_x + monitor_width - MAX (hide_allocation.width, min_hide_size);
                break;
        case PANEL_STATE_NORMAL:
        case PANEL_STATE_AUTO_HIDDEN:
@@ -1787,25 +1774,18 @@ get_delta (int    src,
 static void
 panel_toplevel_update_animating_position (PanelToplevel *toplevel)
 {
-       GdkScreen *screen;
        gint64     time_val;
        int        deltax, deltay;
-       int        monitor_offset_x, monitor_offset_y;
 
        time_val = g_get_real_time ();
 
-       screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
-
-       monitor_offset_x = panel_multiscreen_x (screen, toplevel->priv->monitor);
-       monitor_offset_y = panel_multiscreen_y (screen, toplevel->priv->monitor);
-
-       deltax = get_delta (toplevel->priv->geometry.x - monitor_offset_x,
+       deltax = get_delta (toplevel->priv->geometry.x,
                            toplevel->priv->animation_end_x,
                            toplevel->priv->animation_start_time,
                            toplevel->priv->animation_end_time,
                            time_val);
 
-       deltay = get_delta (toplevel->priv->geometry.y - monitor_offset_y,
+       deltay = get_delta (toplevel->priv->geometry.y,
                            toplevel->priv->animation_end_y,
                            toplevel->priv->animation_start_time,
                            toplevel->priv->animation_end_time,
@@ -1814,8 +1794,8 @@ panel_toplevel_update_animating_position (PanelToplevel *toplevel)
        toplevel->priv->geometry.x += deltax;
        toplevel->priv->geometry.y += deltay;
 
-       if (toplevel->priv->geometry.x - monitor_offset_x == toplevel->priv->animation_end_x &&
-           toplevel->priv->geometry.y - monitor_offset_y == toplevel->priv->animation_end_y) {
+       if (toplevel->priv->geometry.x == toplevel->priv->animation_end_x &&
+           toplevel->priv->geometry.y == toplevel->priv->animation_end_y) {
                toplevel->priv->animating = FALSE;
                /* Note: it's important to set initial_animation_done to TRUE
                 * as soon as possible (hence, here) since we don't want to
@@ -1829,117 +1809,17 @@ panel_toplevel_update_animating_position (PanelToplevel *toplevel)
        }
 }
 
-static void
-panel_toplevel_update_expanded_position (PanelToplevel *toplevel)
-{
-       GdkScreen *screen;
-       int        monitor_width, monitor_height;
-       int        monitor_x, monitor_y;
-       int        x, y;
-       int        x_right, y_bottom;
-       int        monitor;
-
-       if (!toplevel->priv->expand)
-               return;
-
-       screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
-
-       panel_toplevel_get_monitor_geometry (toplevel, &monitor_x, &monitor_y,
-                                            &monitor_width, &monitor_height);
-
-       x = -1;
-       y = -1;
-       x_right = -1;
-       y_bottom = -1;
-
-       switch (toplevel->priv->orientation) {
-       case PANEL_ORIENTATION_TOP:
-               x = monitor_x;
-               y = monitor_y;
-               break;
-       case PANEL_ORIENTATION_LEFT:
-               x = monitor_x;
-               y = monitor_y;
-               break;
-       case PANEL_ORIENTATION_BOTTOM:
-               x = monitor_x;
-               y = monitor_y + monitor_height - toplevel->priv->geometry.height;
-               y_bottom = 0;
-               break;
-       case PANEL_ORIENTATION_RIGHT:
-               x = monitor_x + monitor_width - toplevel->priv->geometry.width;
-               y = monitor_y;
-               x_right = 0;
-               break;
-       default:
-               g_assert_not_reached ();
-               break;
-       }
-
-       monitor = panel_multiscreen_get_monitor_at_point (x, y);
-
-       panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE);
-
-       x -= panel_multiscreen_x (screen, monitor);
-       y -= panel_multiscreen_y (screen, monitor);
-
-       g_object_freeze_notify (G_OBJECT (toplevel));
-
-       if (toplevel->priv->x != x) {
-               toplevel->priv->x = x;
-               g_object_notify (G_OBJECT (toplevel), "x");
-       }
-
-       if (toplevel->priv->y != y) {
-               toplevel->priv->y = y;
-               g_object_notify (G_OBJECT (toplevel), "y");
-       }
-
-       if (toplevel->priv->x_right != x_right) {
-               toplevel->priv->x_right = x_right;
-               g_object_notify (G_OBJECT (toplevel), "x_right");
-       }
-
-       if (toplevel->priv->y_bottom != y_bottom) {
-               toplevel->priv->y_bottom = y_bottom;
-               g_object_notify (G_OBJECT (toplevel), "y_bottom");
-       }
-
-       g_object_thaw_notify (G_OBJECT (toplevel));
-}
-
 static void
 panel_toplevel_update_position (PanelToplevel *toplevel)
 {
        int        x, y;
-       int        monitor_width, monitor_height;
-       GdkScreen *screen;
-
-       panel_toplevel_get_monitor_geometry (
-                       toplevel, NULL, NULL, &monitor_width, &monitor_height);
 
        if (toplevel->priv->animating) {
                panel_toplevel_update_animating_position (toplevel);
                return;
        }
 
-       panel_toplevel_update_expanded_position (toplevel);
-
-       if (toplevel->priv->x_right == -1)
-               x = toplevel->priv->x;
-       else
-               x = monitor_width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
-       if (toplevel->priv->y_bottom == -1)
-               y = toplevel->priv->y;
-       else
-               y = monitor_height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
-
-       if (!toplevel->priv->expand) {
-               if (toplevel->priv->x_centered)
-                       x = (monitor_width - toplevel->priv->geometry.width) / 2;
-               if (toplevel->priv->y_centered)
-                       y = (monitor_height - toplevel->priv->geometry.height) / 2;
-       }
+       get_normal_position (toplevel, &x, &y);
 
        if (toplevel->priv->state == PANEL_STATE_NORMAL)
                panel_toplevel_update_normal_position (toplevel, &x, &y);
@@ -1950,10 +1830,6 @@ panel_toplevel_update_position (PanelToplevel *toplevel)
        else 
                panel_toplevel_update_hidden_position (toplevel, &x, &y);
 
-       screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
-       x += panel_multiscreen_x (screen, toplevel->priv->monitor);
-       y += panel_multiscreen_y (screen, toplevel->priv->monitor);
-
        toplevel->priv->geometry.x = x;
        toplevel->priv->geometry.y = y;
 }
@@ -2729,23 +2605,9 @@ panel_toplevel_get_animation_time (PanelToplevel *toplevel)
 static void
 panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel)
 {
-       int        monitor_width, monitor_height;
-
-       toplevel->priv->animation_end_x      = toplevel->priv->x;
-       toplevel->priv->animation_end_y      = toplevel->priv->y;
-
-       panel_toplevel_get_monitor_geometry (
-                               toplevel, NULL, NULL, &monitor_width, &monitor_height);
-
-       if (!toplevel->priv->expand) {
-
-               if (toplevel->priv->x_centered)
-                       toplevel->priv->animation_end_x =
-                               (monitor_width - toplevel->priv->geometry.width) / 2;
-               if (toplevel->priv->y_centered)
-                       toplevel->priv->animation_end_y =
-                               (monitor_height - toplevel->priv->geometry.height) / 2;
-       }
+       get_normal_position (toplevel,
+                            &toplevel->priv->animation_end_x,
+                            &toplevel->priv->animation_end_y);
 
        /* we consider the toplevels which are in the initial animation stage
         * as in a normal state */
@@ -2770,7 +2632,6 @@ panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel)
 static void
 panel_toplevel_start_animation (PanelToplevel *toplevel)
 {
-       GdkScreen      *screen;
        GtkRequisition  requisition;
        int             deltax, deltay;
        int             cur_x = -1, cur_y = -1;
@@ -2790,11 +2651,6 @@ panel_toplevel_start_animation (PanelToplevel *toplevel)
 
        gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel)), &cur_x, &cur_y);
 
-       screen = gtk_widget_get_screen (GTK_WIDGET (toplevel));
-
-       cur_x -= panel_multiscreen_x (screen, toplevel->priv->monitor);
-       cur_y -= panel_multiscreen_y (screen, toplevel->priv->monitor);
-
        deltax = toplevel->priv->animation_end_x - cur_x;
        deltay = toplevel->priv->animation_end_y - cur_y;
 
@@ -3284,42 +3140,6 @@ panel_toplevel_set_property (GObject      *object,
        case PROP_SIZE:
                panel_toplevel_set_size (toplevel, g_value_get_int (value));
                break;
-       case PROP_X:
-               panel_toplevel_set_x (toplevel,
-                                     g_value_get_int (value),
-                                     toplevel->priv->x_right,
-                                     toplevel->priv->x_centered);
-               break;
-       case PROP_X_RIGHT:
-               panel_toplevel_set_x (toplevel,
-                                     toplevel->priv->x,
-                                     g_value_get_int (value),
-                                     toplevel->priv->x_centered);
-               break;
-       case PROP_X_CENTERED:
-               panel_toplevel_set_x (toplevel,
-                                     toplevel->priv->x,
-                                     toplevel->priv->x_right,
-                                     g_value_get_boolean (value));
-               break;
-       case PROP_Y:
-               panel_toplevel_set_y (toplevel,
-                                     g_value_get_int (value),
-                                     toplevel->priv->y_bottom,
-                                     toplevel->priv->y_centered);
-               break;
-       case PROP_Y_BOTTOM:
-               panel_toplevel_set_y (toplevel,
-                                     toplevel->priv->y,
-                                     g_value_get_int (value),
-                                     toplevel->priv->y_centered);
-               break;
-       case PROP_Y_CENTERED:
-               panel_toplevel_set_y (toplevel,
-                                     toplevel->priv->y,
-                                     toplevel->priv->y_bottom,
-                                     g_value_get_boolean (value));
-               break;
        case PROP_MONITOR:
                panel_toplevel_set_monitor (toplevel, g_value_get_int (value));
                break;
@@ -3384,24 +3204,6 @@ panel_toplevel_get_property (GObject    *object,
        case PROP_SIZE:
                g_value_set_int (value, toplevel->priv->size);
                break;
-       case PROP_X:
-               g_value_set_int (value, toplevel->priv->x);
-               break;
-       case PROP_X_RIGHT:
-               g_value_set_int (value, toplevel->priv->x_right);
-               break;
-       case PROP_X_CENTERED:
-               g_value_set_boolean (value, toplevel->priv->x_centered);
-               break;
-       case PROP_Y:
-               g_value_set_int (value, toplevel->priv->y);
-               break;
-       case PROP_Y_BOTTOM:
-               g_value_set_int (value, toplevel->priv->y_bottom);
-               break;
-       case PROP_Y_CENTERED:
-               g_value_set_boolean (value, toplevel->priv->y_centered);
-               break;
        case PROP_MONITOR:
                g_value_set_int (value, toplevel->priv->monitor);
                break;
@@ -3598,75 +3400,6 @@ panel_toplevel_class_init (PanelToplevelClass *klass)
                        DEFAULT_SIZE,
                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
-
-       g_object_class_install_property (
-               gobject_class,
-               PROP_X,
-               g_param_spec_int (
-                       "x",
-                       "X position",
-                       "The X position of the panel",
-                       0,
-                       G_MAXINT,
-                       0,
-                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (
-               gobject_class,
-               PROP_X_RIGHT,
-               g_param_spec_int (
-                       "x-right",
-                       "X position, from the right",
-                       "The X position of the panel, starting from the right of the screen",
-                       -1,
-                       G_MAXINT,
-                       -1,
-                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (
-               gobject_class,
-               PROP_X_CENTERED,
-               g_param_spec_boolean (
-                       "x-centered",
-                       "X centered",
-                       "The x co-ordinate is relative to center screen",
-                       FALSE,
-                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (
-               gobject_class,
-               PROP_Y,
-               g_param_spec_int (
-                       "y",
-                       "Y position",
-                       "The Y position of the panel",
-                       0,
-                       G_MAXINT,
-                       0,
-                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (
-               gobject_class,
-               PROP_Y_BOTTOM,
-               g_param_spec_int (
-                       "y-bottom",
-                       "Y position, from the bottom",
-                       "The Y position of the panel, starting from the bottom of the screen",
-                       -1,
-                       G_MAXINT,
-                       -1,
-                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (
-               gobject_class,
-               PROP_Y_CENTERED,
-               g_param_spec_boolean (
-                       "y-centered",
-                       "Y centered",
-                       "The y co-ordinate is relative to center screen",
-                       FALSE,
-                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
        g_object_class_install_property (
                gobject_class,
                PROP_MONITOR,
@@ -3920,10 +3653,6 @@ panel_toplevel_init (PanelToplevel *toplevel)
        toplevel->priv->orientation     = PANEL_ORIENTATION_BOTTOM;
        toplevel->priv->alignment       = PANEL_ALIGNMENT_CENTER;
        toplevel->priv->size            = DEFAULT_SIZE;
-       toplevel->priv->x               = 0;
-       toplevel->priv->y               = 0;
-       toplevel->priv->x_right         = -1;
-       toplevel->priv->y_bottom        = -1;
        toplevel->priv->monitor         = 0;
        toplevel->priv->configured_monitor = -1;
        toplevel->priv->hide_delay      = DEFAULT_HIDE_DELAY;
@@ -4028,18 +3757,8 @@ panel_toplevel_position_is_writable (PanelToplevel *toplevel)
        if (panel_toplevel_get_expand (toplevel))
                return TRUE;
 
-       return (g_settings_is_writable (toplevel->priv->settings,
-                                       PANEL_TOPLEVEL_X_KEY) &&
-               g_settings_is_writable (toplevel->priv->settings,
-                                       PANEL_TOPLEVEL_Y_KEY) &&
-               g_settings_is_writable (toplevel->priv->settings,
-                                       PANEL_TOPLEVEL_X_RIGHT_KEY) &&
-               g_settings_is_writable (toplevel->priv->settings,
-                                       PANEL_TOPLEVEL_Y_BOTTOM_KEY) &&
-               g_settings_is_writable (toplevel->priv->settings,
-                                       PANEL_TOPLEVEL_X_CENTERED_KEY) &&
-               g_settings_is_writable (toplevel->priv->settings,
-                                       PANEL_TOPLEVEL_Y_CENTERED_KEY));
+       return g_settings_is_writable (toplevel->priv->settings,
+                                      PANEL_TOPLEVEL_ALIGNMENT_KEY);
 }
 
 static gboolean
@@ -4092,42 +3811,6 @@ panel_toplevel_bind_gsettings (PanelToplevel *toplevel)
                         "alignment",
                         G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
 
-       g_settings_bind (toplevel->priv->delayed_settings,
-                        PANEL_TOPLEVEL_X_KEY,
-                        toplevel,
-                        "x",
-                        G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
-
-       g_settings_bind (toplevel->priv->delayed_settings,
-                        PANEL_TOPLEVEL_X_RIGHT_KEY,
-                        toplevel,
-                        "x-right",
-                        G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
-
-       g_settings_bind (toplevel->priv->delayed_settings,
-                        PANEL_TOPLEVEL_X_CENTERED_KEY,
-                        toplevel,
-                        "x-centered",
-                        G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
-
-       g_settings_bind (toplevel->priv->delayed_settings,
-                        PANEL_TOPLEVEL_Y_KEY,
-                        toplevel,
-                        "y",
-                        G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
-
-       g_settings_bind (toplevel->priv->delayed_settings,
-                        PANEL_TOPLEVEL_Y_BOTTOM_KEY,
-                        toplevel,
-                        "y-bottom",
-                        G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
-
-       g_settings_bind (toplevel->priv->delayed_settings,
-                        PANEL_TOPLEVEL_Y_CENTERED_KEY,
-                        toplevel,
-                        "y-centered",
-                        G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
-
        /* Normal settings */
 
        g_settings_bind (toplevel->priv->settings,
@@ -4307,23 +3990,7 @@ panel_toplevel_set_expand (PanelToplevel *toplevel,
 
        if (!toplevel->priv->expand &&
            toplevel->priv->updated_geometry_initial) {
-               switch (toplevel->priv->orientation) {
-               case PANEL_ORIENTATION_TOP:
-                       panel_toplevel_set_x (toplevel, 0, -1, TRUE);
-                       break;
-               case PANEL_ORIENTATION_BOTTOM:
-                       panel_toplevel_set_x (toplevel, 0, 0, TRUE);
-                       break;
-               case PANEL_ORIENTATION_LEFT:
-                       panel_toplevel_set_y (toplevel, 0, -1, TRUE);
-                       break;
-               case PANEL_ORIENTATION_RIGHT:
-                       panel_toplevel_set_y (toplevel, 0, 0, TRUE);
-                       break;
-               default:
-                       g_assert_not_reached ();
-                       break;
-               }
+               panel_toplevel_set_alignment (toplevel, PANEL_ALIGNMENT_CENTER);
        }
 
        gtk_widget_queue_resize (GTK_WIDGET (toplevel));
@@ -4345,10 +4012,6 @@ void
 panel_toplevel_set_orientation (PanelToplevel    *toplevel,
                                PanelOrientation  orientation)
 {
-       gboolean   rotate;
-       int        monitor_width;
-       int        monitor_height;
-
        g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel));
 
        if (toplevel->priv->orientation == orientation)
@@ -4356,70 +4019,6 @@ panel_toplevel_set_orientation (PanelToplevel    *toplevel,
 
        g_object_freeze_notify (G_OBJECT (toplevel));
 
-       panel_toplevel_get_monitor_geometry (
-               toplevel, NULL, NULL, &monitor_width, &monitor_height);
-
-       /* Un-snap from center if no longer along screen edge */
-       if (toplevel->priv->x_centered &&
-           (orientation & PANEL_VERTICAL_MASK)) {
-               toplevel->priv->x_centered = FALSE;
-               toplevel->priv->x = (monitor_width - toplevel->priv->geometry.width) / 2;
-               g_object_notify (G_OBJECT (toplevel), "x");
-               g_object_notify (G_OBJECT (toplevel), "x-centered");
-
-               if (toplevel->priv->x_right != -1) {
-                       toplevel->priv->x_right = -1;
-                       g_object_notify (G_OBJECT (toplevel), "x-right");
-               }
-       }
-
-       if (toplevel->priv->y_centered &&
-           (orientation & PANEL_HORIZONTAL_MASK)) {
-               toplevel->priv->y_centered = FALSE;
-               toplevel->priv->y = (monitor_height - toplevel->priv->geometry.height) / 2;
-               g_object_notify (G_OBJECT (toplevel), "y");
-               g_object_notify (G_OBJECT (toplevel), "y-centered");
-
-               if (toplevel->priv->y_bottom != -1) {
-                       toplevel->priv->y_bottom = -1;
-                       g_object_notify (G_OBJECT (toplevel), "y-bottom");
-               }
-       }
-
-       rotate = FALSE;
-       if ((orientation & PANEL_HORIZONTAL_MASK) &&
-           (toplevel->priv->orientation & PANEL_VERTICAL_MASK))
-               rotate = TRUE;
-       else if ((orientation & PANEL_VERTICAL_MASK) &&
-                (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK))
-               rotate = TRUE;
-
-       if (rotate &&
-           !toplevel->priv->expand &&
-           toplevel->priv->updated_geometry_initial) {
-               switch (orientation) {
-               case PANEL_ORIENTATION_TOP:
-                       panel_toplevel_set_x (toplevel, 0, -1, TRUE);
-                       panel_toplevel_set_y (toplevel, 0, -1, FALSE);
-                       break;
-               case PANEL_ORIENTATION_BOTTOM:
-                       panel_toplevel_set_x (toplevel, 0, 0, TRUE);
-                       panel_toplevel_set_y (toplevel, 0, 0, FALSE);
-                       break;
-               case PANEL_ORIENTATION_LEFT:
-                       panel_toplevel_set_x (toplevel, 0, -1, FALSE);
-                       panel_toplevel_set_y (toplevel, 0, -1, TRUE);
-                       break;
-               case PANEL_ORIENTATION_RIGHT:
-                       panel_toplevel_set_x (toplevel, 0, 0, FALSE);
-                       panel_toplevel_set_y (toplevel, 0, 0, TRUE);
-                       break;
-               default:
-                       g_assert_not_reached ();
-                       break;
-               }
-       }
-
        toplevel->priv->orientation = orientation;
        update_style_classes (toplevel);
 
@@ -4529,86 +4128,6 @@ panel_toplevel_set_auto_hide_size (PanelToplevel *toplevel,
        g_object_notify (G_OBJECT (toplevel), "auto-hide-size");
 }
 
-void
-panel_toplevel_set_x (PanelToplevel *toplevel,
-                     int            x,
-                     int            x_right,
-                     gboolean       x_centered)
-{
-       gboolean changed = FALSE;
-
-       g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel));
-
-       x_centered = x_centered != FALSE;
-
-       g_object_freeze_notify (G_OBJECT (toplevel));
-
-       if (toplevel->priv->x != x) {
-               toplevel->priv->x = x;
-               changed = TRUE;
-               g_object_notify (G_OBJECT (toplevel), "x");
-       }
-
-       if (toplevel->priv->x_right != x_right) {
-               toplevel->priv->x_right = x_right;
-               changed = TRUE;
-               g_object_notify (G_OBJECT (toplevel), "x-right");
-       }
-
-       if (toplevel->priv->x_centered != x_centered) {
-               toplevel->priv->x_centered = x_centered;
-               changed = TRUE;
-               g_object_notify (G_OBJECT (toplevel), "x-centered");
-       }
-
-       if (changed) {
-               panel_toplevel_apply_delayed_settings_queue (toplevel);
-               gtk_widget_queue_resize (GTK_WIDGET (toplevel));
-       }
-
-       g_object_thaw_notify (G_OBJECT (toplevel));
-}
-
-void
-panel_toplevel_set_y (PanelToplevel *toplevel,
-                     int            y,
-                     int            y_bottom,
-                     gboolean       y_centered)
-{
-       gboolean changed = FALSE;
-
-       g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel));
-
-       y_centered = y_centered != FALSE;
-
-       g_object_freeze_notify (G_OBJECT (toplevel));
-
-       if (toplevel->priv->y != y) {
-               toplevel->priv->y = y;
-               changed = TRUE;
-               g_object_notify (G_OBJECT (toplevel), "y");
-       }
-
-       if (toplevel->priv->y_bottom != y_bottom) {
-               toplevel->priv->y_bottom = y_bottom;
-               changed = TRUE;
-               g_object_notify (G_OBJECT (toplevel), "y-bottom");
-       }
-
-       if (toplevel->priv->y_centered != y_centered) {
-               toplevel->priv->y_centered = y_centered;
-               changed = TRUE;
-               g_object_notify (G_OBJECT (toplevel), "y-centered");
-       }
-
-       if (changed) {
-               panel_toplevel_apply_delayed_settings_queue (toplevel);
-               gtk_widget_queue_resize (GTK_WIDGET (toplevel));
-       }
-
-       g_object_thaw_notify (G_OBJECT (toplevel));
-}
-
 /**
  * panel_toplevel_set_monitor_internal:
  *
diff --git a/gnome-panel/panel-toplevel.h b/gnome-panel/panel-toplevel.h
index e2691e8d1..584ff94ab 100644
--- a/gnome-panel/panel-toplevel.h
+++ b/gnome-panel/panel-toplevel.h
@@ -93,14 +93,6 @@ void                 panel_toplevel_set_monitor            (PanelToplevel
 int                  panel_toplevel_get_monitor            (PanelToplevel       *toplevel);
 void                 panel_toplevel_set_auto_hide_size     (PanelToplevel       *toplevel,
                                                            int                  autohide_size);
-void                 panel_toplevel_set_x                  (PanelToplevel       *toplevel,
-                                                           int                  x,
-                                                           int                  x_right,
-                                                           gboolean             x_centered);
-void                 panel_toplevel_set_y                  (PanelToplevel       *toplevel,
-                                                           int                  y,
-                                                           int                  y_bottom,
-                                                           gboolean             y_centered);
 
 gboolean             panel_toplevel_get_is_hidden          (PanelToplevel       *toplevel);
 


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