summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/window.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/core/window.c b/src/core/window.c
index b5f9468c..3f6314d6 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -114,7 +114,7 @@ static MetaTileMode calculate_tiling_mode(int x,
MetaRectangle work_area,
int shake_threshold);
-static void meta_window_rescale_to_monitor (MetaRectangle *target_rect,
+static void meta_window_transform_to_monitor (MetaRectangle *target_rect,
const MetaRectangle *from_monitor,
const MetaRectangle *to_monitor);
@@ -2877,15 +2877,23 @@ meta_window_move_to_monitor(MetaWindow *window,
if(META_WINDOW_TILED (window))
{
window->tile_monitor_number = to_monitor->number;
- meta_window_rescale_to_monitor(&window->saved_rect,
+
+ /* Transform user_rect and saved_rect to the other monitor */
+ meta_window_transform_to_monitor(&window->saved_rect,
+ &from_monitor->rect,
+ &to_monitor->rect);
+ meta_window_transform_to_monitor(&window->user_rect,
&from_monitor->rect,
&to_monitor->rect);
+
meta_window_tile(window);
return;
}
-
+
+ /* Normally, just transform the window itself */
meta_window_get_client_root_coords(window, &target_rect);
- meta_window_rescale_to_monitor(&target_rect,
+
+ meta_window_transform_to_monitor(&target_rect,
&from_monitor->rect,
&to_monitor->rect);
@@ -2896,27 +2904,27 @@ meta_window_move_to_monitor(MetaWindow *window,
target_rect.height);
}
-static void meta_window_rescale_to_monitor(MetaRectangle *target_rect,
+static void meta_window_transform_to_monitor(MetaRectangle *target_rect,
const MetaRectangle *from_monitor,
const MetaRectangle *to_monitor)
{
double horizontal_ratio;
double vertical_ratio;
- target_rect->x += to_monitor->x - from_monitor->x;
- target_rect->y += to_monitor->y - from_monitor->y;
-
- if(from_monitor->width == to_monitor->width &&
- from_monitor->height == to_monitor->height)
- return;
-
horizontal_ratio = (double)to_monitor->width / from_monitor->width;
vertical_ratio = (double)to_monitor->height / from_monitor->height;
+ target_rect->x -= from_monitor->x;
+ target_rect->y -= from_monitor->y;
+
target_rect->width *= horizontal_ratio;
target_rect->height *= vertical_ratio;
target_rect->x *= horizontal_ratio;
target_rect->y *= vertical_ratio;
+
+ target_rect->x += to_monitor->x;
+ target_rect->y += to_monitor->y;
+
}