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
This commit is contained in:
Florian Müllner 2011-03-21 12:36:01 +01:00
parent b1725bc18c
commit c5d1d2db62
2 changed files with 44 additions and 0 deletions

View File

@ -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,

View File

@ -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);