summaryrefslogtreecommitdiff
path: root/src/core/screen.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-05-31 16:22:39 +0200
committerStefano Karapetsas <[email protected]>2013-05-31 16:22:39 +0200
commita87157176ca6e01c8c4047999ee584f00b63c11e (patch)
tree80e928a800b4b54f6831a6b38a952014c7f5ae5c /src/core/screen.c
parentcc760e2586cd0f98f8c60382ab8ff1f7373d9c1d (diff)
downloadmarco-a87157176ca6e01c8c4047999ee584f00b63c11e.tar.bz2
marco-a87157176ca6e01c8c4047999ee584f00b63c11e.tar.xz
Implement side-by-side tiling
Patch by Florian Müllner for Metacity https://bugzilla.gnome.org/show_bug.cgi?id=607694 When dragging a window over a screen edge and dropping it there, maximize it vertically and scale it horizontally to cover the corresponding half of the current monitor. Whenever a "hot area" which triggers this behavior is entered, an indication of window's target size is displayed after a short delay to avoid distraction when moving a window between monitors.
Diffstat (limited to 'src/core/screen.c')
-rw-r--r--src/core/screen.c66
1 files changed, 64 insertions, 2 deletions
diff --git a/src/core/screen.c b/src/core/screen.c
index e8fce40a..eefe58f2 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -582,7 +582,10 @@ meta_screen_new (MetaDisplay *display,
screen->xscreen);
screen->tab_popup = NULL;
-
+ screen->tile_preview = NULL;
+
+ screen->tile_preview_timeout_id = 0;
+
screen->stack = meta_stack_new (screen);
meta_prefs_add_listener (prefs_changed_callback, screen);
@@ -691,7 +694,13 @@ meta_screen_free (MetaScreen *screen,
if (screen->xinerama_infos)
g_free (screen->xinerama_infos);
-
+
+ if (screen->tile_preview_timeout_id)
+ g_source_remove (screen->tile_preview_timeout_id);
+
+ if (screen->tile_preview)
+ meta_tile_preview_free (screen->tile_preview);
+
g_free (screen->screen_name);
g_free (screen);
@@ -1451,6 +1460,59 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
/* don't show tab popup, since proper space isn't selected yet */
}
+static gboolean
+meta_screen_tile_preview_update_timeout (gpointer data)
+{
+ MetaScreen *screen = data;
+ MetaWindow *window = screen->display->grab_window;
+ gboolean composited = screen->display->compositor != NULL;
+
+ screen->tile_preview_timeout_id = 0;
+
+ if (!screen->tile_preview)
+ screen->tile_preview = meta_tile_preview_new (screen->number,
+ composited);
+
+ if (window
+ && !META_WINDOW_TILED (window)
+ && window->tile_mode != META_TILE_NONE)
+ {
+ MetaRectangle tile_rect;
+
+ meta_window_get_current_tile_area (window, &tile_rect);
+ meta_tile_preview_show (screen->tile_preview, &tile_rect);
+ }
+ else
+ meta_tile_preview_hide (screen->tile_preview);
+
+ return FALSE;
+}
+
+#define TILE_PREVIEW_TIMEOUT_MS 200
+
+void
+meta_screen_tile_preview_update (MetaScreen *screen,
+ gboolean delay)
+{
+ if (delay)
+ {
+ if (screen->tile_preview_timeout_id > 0)
+ return;
+
+ screen->tile_preview_timeout_id =
+ g_timeout_add (TILE_PREVIEW_TIMEOUT_MS,
+ meta_screen_tile_preview_update_timeout,
+ screen);
+ }
+ else
+ {
+ if (screen->tile_preview_timeout_id > 0)
+ g_source_remove (screen->tile_preview_timeout_id);
+
+ meta_screen_tile_preview_update_timeout ((gpointer)screen);
+ }
+}
+
MetaWindow*
meta_screen_get_mouse_window (MetaScreen *screen,
MetaWindow *not_this_one)