[mutter] Add and export meta_window_move_to_monitor
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Add and export meta_window_move_to_monitor
- Date: Mon, 21 Mar 2011 23:55:52 +0000 (UTC)
commit c5d1d2db62e1ed689692187f4e486084f0c69b84
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Mar 21 12:36:01 2011 +0100
Add and export meta_window_move_to_monitor
This is useful for DnD to another monitor in gnome-shell.
In addition to a normal move it corrects the saved rect for
maximized and fullscreened windows.
https://bugzilla.gnome.org/show_bug.cgi?id=645032
src/core/window.c | 43 +++++++++++++++++++++++++++++++++++++++++++
src/meta/window.h | 1 +
2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 1aa13c5..7f43aa3 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4776,6 +4776,49 @@ meta_window_move_frame (MetaWindow *window,
meta_window_move (window, user_op, x, y);
}
+/**
+ * meta_window_move_to_monitor:
+ * @window: a #MetaWindow
+ * @monitor: desired monitor index
+ *
+ * Moves the window to the monitor with index @monitor, keeping
+ * the relative position of the window's top left corner.
+ */
+void
+meta_window_move_to_monitor (MetaWindow *window,
+ int monitor)
+{
+ MetaRectangle old_area, new_area;
+ int rel_x, rel_y;
+ double scale_x, scale_y;
+
+ if (monitor == window->monitor->number)
+ return;
+
+ meta_window_get_work_area_for_monitor (window,
+ window->monitor->number,
+ &old_area);
+ meta_window_get_work_area_for_monitor (window,
+ monitor,
+ &new_area);
+
+ rel_x = window->user_rect.x - old_area.x;
+ rel_y = window->user_rect.y - old_area.y;
+ scale_x = (double)new_area.width / old_area.width;
+ scale_y = (double)new_area.height / old_area.height;
+
+ window->user_rect.x = new_area.x + rel_x * scale_x;
+ window->user_rect.y = new_area.y + rel_y * scale_y;
+ window->saved_rect.x = window->user_rect.x;
+ window->saved_rect.y = window->user_rect.y;
+
+ meta_window_move_resize (window, FALSE,
+ window->user_rect.x,
+ window->user_rect.y,
+ window->user_rect.width,
+ window->user_rect.height);
+}
+
void
meta_window_move_resize (MetaWindow *window,
gboolean user_op,
diff --git a/src/meta/window.h b/src/meta/window.h
index af5602c..a1c4b75 100644
--- a/src/meta/window.h
+++ b/src/meta/window.h
@@ -95,6 +95,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_to_monitor (MetaWindow *window, int monitor);
void meta_window_resize(MetaWindow *window, gboolean user_op, int w, int h);
void meta_window_set_demands_attention (MetaWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]