From 7e14f82c4b5e3137bbdc3a4e55dbfe01e5af28c0 Mon Sep 17 00:00:00 2001 From: Omar Zeidan Date: Sat, 30 Dec 2017 03:52:32 +0100 Subject: Implemented simple shourtcuts to move window to another monitor --- src/50-marco-window-key.xml.in | 16 ++++++++++++++++ src/core/keybindings.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/include/all-keybindings.h | 14 ++++++++++++++ src/org.mate.marco.gschema.xml | 20 ++++++++++++++++++++ 4 files changed, 91 insertions(+) diff --git a/src/50-marco-window-key.xml.in b/src/50-marco-window-key.xml.in index 6d826d5f..217354e6 100644 --- a/src/50-marco-window-key.xml.in +++ b/src/50-marco-window-key.xml.in @@ -129,6 +129,22 @@ name="move-to-center" _description="Move window to center of screen" /> + + + + + + + + rect.height); } + +static void +handle_move_to_monitor (MetaDisplay *display, + MetaScreen *screen, + MetaWindow *window, + XEvent *event, + MetaKeyBinding *binding) +{ + MetaScreenDirection move_direction = binding->handler->data; + MetaXineramaScreenInfo* current; + MetaXineramaScreenInfo* neighbour; + MetaRectangle current_window_rect; + int new_x; + int 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; + + if(META_WINDOW_TILED (window)) + { + window->tile_monitor_number = neighbour->number; + return; + } + + meta_window_get_client_root_coords(window, ¤t_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); + +} + static gboolean process_workspace_switch_grab (MetaDisplay *display, MetaScreen *screen, diff --git a/src/include/all-keybindings.h b/src/include/all-keybindings.h index 2cba3df2..cba8e9fd 100644 --- a/src/include/all-keybindings.h +++ b/src/include/all-keybindings.h @@ -279,6 +279,7 @@ keybind (move-to-corner-sw, handle_move_to_corner_sw, 0, keybind (move-to-corner-se, handle_move_to_corner_se, 0, BINDING_PER_WINDOW) + keybind (move-to-side-n, handle_move_to_side_n, 0, BINDING_PER_WINDOW) keybind (move-to-side-s, handle_move_to_side_s, 0, @@ -290,6 +291,19 @@ keybind (move-to-side-w, handle_move_to_side_w, 0, keybind (move-to-center, handle_move_to_center, 0, BINDING_PER_WINDOW) +keybind (move-to-monitor-n, handle_move_to_monitor, META_SCREEN_UP, + BINDING_PER_WINDOW) +keybind (move-to-monitor-s, handle_move_to_monitor, META_SCREEN_DOWN, + BINDING_PER_WINDOW) +keybind (move-to-monitor-e, handle_move_to_monitor, META_SCREEN_RIGHT, + BINDING_PER_WINDOW) +keybind (move-to-monitor-w, handle_move_to_monitor, META_SCREEN_LEFT, + BINDING_PER_WINDOW) + + + + + keybind (switch-to-workspace-prev, handle_switch_to_workspace, META_MOTION_PREV, 0) diff --git a/src/org.mate.marco.gschema.xml b/src/org.mate.marco.gschema.xml index 70a72337..6632e6b1 100644 --- a/src/org.mate.marco.gschema.xml +++ b/src/org.mate.marco.gschema.xml @@ -948,6 +948,26 @@ Move window to center of screen The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + + 'disabled' + Move window to north (top) monitor + The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + + + 'disabled' + Move window to south (bottom) monitor + The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + + + 'disabled' + Move window to east (right) monitor + The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + + + 'disabled' + Move window to west (left) monitor + The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + -- cgit v1.2.1