summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorOmar Zeidan <[email protected]>2017-12-30 06:45:08 +0100
committerraveit65 <[email protected]>2018-01-15 17:29:48 +0100
commitfc79bd1c4af4bce121a313cc2777b414c838a73c (patch)
tree8400f3cebd8785dde10cbba9f1c0b5b2392f77d7 /src/core
parent7e14f82c4b5e3137bbdc3a4e55dbfe01e5af28c0 (diff)
downloadmarco-fc79bd1c4af4bce121a313cc2777b414c838a73c.tar.bz2
marco-fc79bd1c4af4bce121a313cc2777b414c838a73c.tar.xz
Restructured monitor keybinds and adjust save_rect
Diffstat (limited to 'src/core')
-rw-r--r--src/core/keybindings.c43
-rw-r--r--src/core/window-private.h3
-rw-r--r--src/core/window.c58
3 files changed, 74 insertions, 30 deletions
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 11b8daf4..a141e2c1 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2680,37 +2680,20 @@ handle_move_to_monitor (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- MetaScreenDirection move_direction = binding->handler->data;
- MetaXineramaScreenInfo* current;
- MetaXineramaScreenInfo* neighbour;
- MetaRectangle current_window_rect;
- int new_x;
- int new_y;
+ const MetaScreenDirection move_direction = binding->handler->data;
+ const MetaXineramaScreenInfo* current;
+ const MetaXineramaScreenInfo* neighbour;
-
- current = meta_screen_get_xinerama_for_window(screen, window);
- neighbour = meta_screen_get_xinerama_neighbor(screen, current->number, move_direction);
-
- if(neighbour == NULL ||
- current->number == neighbour->number)
- return;
-
- if(META_WINDOW_TILED (window))
- {
- window->tile_monitor_number = neighbour->number;
- return;
- }
-
- meta_window_get_client_root_coords(window, &current_window_rect);
-
- new_x = current_window_rect.x - current->rect.x + neighbour->rect.x;
- new_y = current_window_rect.y - current->rect.y + neighbour->rect.y;
- /* target_rect.width = window->rect.width; */
- /* target_rect.height = window->rect.height; */
- /* Maybe do some resizing? */
-
- meta_window_move(window, TRUE, new_x, new_y);
-
+ current = meta_screen_get_xinerama_for_window(screen, window);
+ neighbour = meta_screen_get_xinerama_neighbor(screen, current->number, move_direction);
+
+ if(neighbour == NULL ||
+ current->number == neighbour->number)
+ return;
+
+ meta_window_move_to_monitor(window,
+ current,
+ neighbour);
}
static gboolean
diff --git a/src/core/window-private.h b/src/core/window-private.h
index f0832abf..a6b49b4b 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -446,6 +446,9 @@ void meta_window_maximize_internal (MetaWindow *window,
MetaRectangle *saved_rect);
void meta_window_unmaximize (MetaWindow *window,
MetaMaximizeFlags directions);
+void meta_window_move_to_monitor (MetaWindow *window,
+ const MetaXineramaScreenInfo *from_monitor,
+ const MetaXineramaScreenInfo *to_monitor);
void meta_window_make_above (MetaWindow *window);
void meta_window_unmake_above (MetaWindow *window);
void meta_window_shade (MetaWindow *window,
diff --git a/src/core/window.c b/src/core/window.c
index a1e38d3f..b5f9468c 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -114,6 +114,9 @@ static MetaTileMode calculate_tiling_mode(int x,
MetaRectangle work_area,
int shake_threshold);
+static void meta_window_rescale_to_monitor (MetaRectangle *target_rect,
+ const MetaRectangle *from_monitor,
+ const MetaRectangle *to_monitor);
static gboolean update_resize_timeout (gpointer data);
@@ -2863,6 +2866,61 @@ meta_window_unmaximize (MetaWindow *window,
meta_compositor_unmaximize_window (window->display->compositor, window);
}
+
+void
+meta_window_move_to_monitor(MetaWindow *window,
+ const MetaXineramaScreenInfo *from_monitor,
+ const MetaXineramaScreenInfo *to_monitor)
+{
+ MetaRectangle target_rect;
+
+ if(META_WINDOW_TILED (window))
+ {
+ window->tile_monitor_number = to_monitor->number;
+ meta_window_rescale_to_monitor(&window->saved_rect,
+ &from_monitor->rect,
+ &to_monitor->rect);
+ meta_window_tile(window);
+ return;
+ }
+
+ meta_window_get_client_root_coords(window, &target_rect);
+ meta_window_rescale_to_monitor(&target_rect,
+ &from_monitor->rect,
+ &to_monitor->rect);
+
+ meta_window_move_resize(window, TRUE,
+ target_rect.x,
+ target_rect.y,
+ target_rect.width,
+ target_rect.height);
+}
+
+static void meta_window_rescale_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->width *= horizontal_ratio;
+ target_rect->height *= vertical_ratio;
+ target_rect->x *= horizontal_ratio;
+ target_rect->y *= vertical_ratio;
+}
+
+
+
void
meta_window_make_above (MetaWindow *window)
{