[mutter/wip/gbsneto/tiling-improvements: 2/9] window: Use auxiliary function to track tile mode
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/gbsneto/tiling-improvements: 2/9] window: Use auxiliary function to track tile mode
- Date: Fri, 16 Jun 2017 00:46:10 +0000 (UTC)
commit 2faf8adf4d478ca686bfec28e95ee2f5f952f1a5
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Jun 11 22:08:57 2017 -0300
window: Use auxiliary function to track tile mode
Now that we must track the previous tile mode, updating
this structure field manually is error-prone and would
consume much more code than it's actually needed, when
this can be delegated to a helper function.
This patch, then, makes all the lines of code that used
to set the tile_mode field use the newly introduced
helper function.
https://bugzilla.gnome.org/show_bug.cgi?id=645153
src/core/keybindings.c | 11 ++++-------
src/core/window-private.h | 2 ++
src/core/window.c | 27 +++++++++++++--------------
3 files changed, 19 insertions(+), 21 deletions(-)
---
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 6e56020..b161e1e 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2034,8 +2034,7 @@ process_mouse_move_resize_grab (MetaDisplay *display,
meta_screen_hide_tile_preview (screen);
/* Restore the original tile mode */
- window->previous_tile_mode = window->tile_mode;
- window->tile_mode = display->grab_tile_mode;
+ meta_window_set_tile_mode (window, display->grab_tile_mode);
window->tile_monitor_number = display->grab_tile_monitor_number;
/* End move or resize and restore to original state. If the
@@ -2996,9 +2995,8 @@ handle_toggle_tiled (MetaDisplay *display,
{
window->tile_monitor_number = window->saved_maximize ? window->monitor->number
: -1;
- window->previous_tile_mode = window->tile_mode;
- window->tile_mode = window->saved_maximize ? META_TILE_MAXIMIZED
- : META_TILE_NONE;
+ meta_window_set_tile_mode (window, window->saved_maximize ? META_TILE_MAXIMIZED
+ : META_TILE_NONE);
if (window->saved_maximize)
meta_window_maximize (window, META_MAXIMIZE_BOTH);
@@ -3008,8 +3006,7 @@ handle_toggle_tiled (MetaDisplay *display,
else if (meta_window_can_tile_side_by_side (window))
{
window->tile_monitor_number = window->monitor->number;
- window->previous_tile_mode = window->tile_mode;
- window->tile_mode = mode;
+ meta_window_set_tile_mode (window, mode);
/* Maximization constraints beat tiling constraints, so if the window
* is maximized, tiling won't have any effect unless we unmaximize it
* horizontally first; rather than calling meta_window_unmaximize(),
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 6305f0e..c993174 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -588,6 +588,8 @@ void meta_window_unmanage (MetaWindow *window,
guint32 timestamp);
void meta_window_queue (MetaWindow *window,
guint queuebits);
+void meta_window_set_tile_mode (MetaWindow *window,
+ MetaTileMode mode);
void meta_window_tile (MetaWindow *window);
void meta_window_maximize_internal (MetaWindow *window,
MetaMaximizeFlags directions,
diff --git a/src/core/window.c b/src/core/window.c
index b56cbfd..bc2fa13 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2727,10 +2727,7 @@ meta_window_maximize (MetaWindow *window,
}
if (maximize_vertically && maximize_horizontally)
- {
- window->previous_tile_mode = window->tile_mode;
- window->tile_mode = META_TILE_MAXIMIZED;
- }
+ meta_window_set_tile_mode (window, META_TILE_MAXIMIZED);
/* if the window hasn't been placed yet, we'll maximize it then
*/
@@ -2750,7 +2747,7 @@ meta_window_maximize (MetaWindow *window,
saved_rect = &window->saved_rect;
window->maximized_vertically = FALSE;
- window->tile_mode = META_TILE_NONE;
+ meta_window_set_tile_mode (window, META_TILE_NONE);
}
meta_window_maximize_internal (window,
@@ -2930,9 +2927,6 @@ meta_window_update_tile_state_internal (MetaWindow *window)
/* Update the horizontal position */
if (window->tile_mode == META_TILE_RIGHT)
window->tile_rect.x = monitor_area.x + monitor_area.width - window->tile_rect.width - borders_width;
-
- /* Track the previous tile mode here, so */
- window->previous_tile_mode = window->tile_mode;
}
void
@@ -2972,6 +2966,14 @@ meta_window_tile (MetaWindow *window)
meta_frame_queue_draw (window->frame);
}
+void
+meta_window_set_tile_mode (MetaWindow *window,
+ MetaTileMode mode)
+{
+ window->previous_tile_mode = window->tile_mode;
+ window->tile_mode = mode;
+}
+
static gboolean
meta_window_can_tile_maximized (MetaWindow *window)
{
@@ -3071,10 +3073,7 @@ meta_window_unmaximize (MetaWindow *window,
meta_window_get_buffer_rect (window, &old_buffer_rect);
if (unmaximize_vertically)
- {
- window->previous_tile_mode = window->tile_mode;
- window->tile_mode = META_TILE_NONE;
- }
+ meta_window_set_tile_mode (window, META_TILE_NONE);
meta_topic (META_DEBUG_WINDOW_OPS,
"Unmaximizing %s%s\n",
@@ -6082,11 +6081,11 @@ update_tile_mode_after_resize (MetaWindow *window,
case META_TILE_LEFT:
case META_TILE_RIGHT:
if (!META_WINDOW_TILED_SIDE_BY_SIDE (window))
- window->tile_mode = META_TILE_NONE;
+ meta_window_set_tile_mode (window, META_TILE_NONE);
break;
case META_TILE_MAXIMIZED:
if (!META_WINDOW_MAXIMIZED (window))
- window->tile_mode = META_TILE_NONE;
+ meta_window_set_tile_mode (window, META_TILE_NONE);
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]