[mutter] window.c: add meta_window_move_resize_frame



commit 4fb2fab7f7ca9be826d039ee447cfd532cbe5320
Author: Tim Cuthbertson <tim gfxmonk net>
Date:   Sun Jun 5 11:02:44 2011 +1000

    window.c: add meta_window_move_resize_frame
    
    meta_window_move_resize_frame operates much like
    meta_window_move_resize, but ensures the window
    and its frame (if present) will fit within the
    specified dimensions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=651899

 src/core/window.c |   35 +++++++++++++++++++++++++++++++++++
 src/meta/window.h |    1 +
 2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 3162b66..475d595 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4997,6 +4997,41 @@ meta_window_move_between_rects (MetaWindow  *window,
 }
 
 /**
+ * meta_window_move_resize_frame:
+ * @window: a #MetaWindow
+ * @user_op: bool to indicate whether or not this is a user operation
+ * @root_x_nw: new x
+ * @root_y_nw: new y
+ * @w: desired width
+ * @h: desired height
+ *
+ * Resizes the window so that its outer bounds (including frame)
+ * fit within the given rect
+ */
+void
+meta_window_move_resize_frame (MetaWindow  *window,
+                               gboolean     user_op,
+                               int          root_x_nw,
+                               int          root_y_nw,
+                               int          w,
+                               int          h)
+{
+  if (window->frame)
+    {
+      MetaFrameBorders borders;
+      meta_frame_calc_borders (window->frame, &borders);
+      /* offset by the distance between the origin of the window
+       * and the origin of the enclosing window decorations ( + border)
+       */
+      root_x_nw += borders.visible.left;
+      root_y_nw += borders.visible.top;
+      w -= borders.visible.left + borders.visible.right;
+      h -= borders.visible.top + borders.visible.bottom;
+    }
+  meta_window_move_resize (window, user_op, root_x_nw, root_y_nw, w, h);
+}
+
+/**
  * meta_window_move_to_monitor:
  * @window: a #MetaWindow
  * @monitor: desired monitor index
diff --git a/src/meta/window.h b/src/meta/window.h
index e5ac5b9..832d4b8 100644
--- a/src/meta/window.h
+++ b/src/meta/window.h
@@ -97,6 +97,7 @@ gboolean    meta_window_showing_on_its_workspace (MetaWindow *window);
 
 void meta_window_move(MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw);
 void meta_window_move_frame(MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw);
+void meta_window_move_resize_frame (MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw, int w, int h);
 void meta_window_move_to_monitor (MetaWindow *window, int monitor);
 void meta_window_resize(MetaWindow *window, gboolean user_op, int w, int h);
 



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