+/*
+ Calculate mv_resize->moveresize_orig_x and mv_resize->moveresize_orig_y
+ so that calling XMoveWindow with these coordinates will not move the
+ window.
+ Note that this depends on the WM to implement ICCCM-compliant reference
+ point handling.
+*/
+static void
+calculate_unmoving_origin (MoveResizeData *mv_resize)
+{
+ GdkRectangle rect;
+ gint width, height;
+
+ if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY &&
+ mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC)
+ {
+ gdk_window_get_origin (mv_resize->moveresize_window,
+ &mv_resize->moveresize_orig_x,
+ &mv_resize->moveresize_orig_y);
+ }
+ else
+ {
+ gdk_window_get_frame_extents (mv_resize->moveresize_window, &rect);
+ gdk_window_get_geometry (mv_resize->moveresize_window,
+ NULL, NULL, &width, &height, NULL);
+
+ switch (mv_resize->moveresize_geometry.win_gravity)
+ {
+ case GDK_GRAVITY_NORTH_WEST:
+ mv_resize->moveresize_orig_x = rect.x;
+ mv_resize->moveresize_orig_y = rect.y;
+ break;
+ case GDK_GRAVITY_NORTH:
+ mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
+ mv_resize->moveresize_orig_y = rect.y;
+ break;
+ case GDK_GRAVITY_NORTH_EAST:
+ mv_resize->moveresize_orig_x = rect.x + rect.width - width;
+ mv_resize->moveresize_orig_y = rect.y;
+ break;
+ case GDK_GRAVITY_WEST:
+ mv_resize->moveresize_orig_x = rect.x;
+ mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
+ break;
+ case GDK_GRAVITY_CENTER:
+ mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
+ mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
+ break;
+ case GDK_GRAVITY_EAST:
+ mv_resize->moveresize_orig_x = rect.x + rect.width - width;
+ mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
+ break;
+ case GDK_GRAVITY_SOUTH_WEST:
+ mv_resize->moveresize_orig_x = rect.x;
+ mv_resize->moveresize_orig_y = rect.y + rect.height - height;
+ break;
+ case GDK_GRAVITY_SOUTH:
+ mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
+ mv_resize->moveresize_orig_y = rect.y + rect.height - height;
+ break;
+ case GDK_GRAVITY_SOUTH_EAST:
+ mv_resize->moveresize_orig_x = rect.x + rect.width - width;
+ mv_resize->moveresize_orig_y = rect.y + rect.height - height;
+ break;
+ default:
+ mv_resize->moveresize_orig_x = rect.x;
+ mv_resize->moveresize_orig_y = rect.y;
+ break;
+ }
+ }
+}
+