[mutter/wip/fmuellner/contraint-tiling: 12/15] window: Track edge constraints
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/fmuellner/contraint-tiling: 12/15] window: Track edge constraints
- Date: Tue, 3 Oct 2017 18:26:29 +0000 (UTC)
commit 92c2d9fc53d21d894759f067f7ee3de8bbc4767d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Aug 17 00:43:21 2017 -0300
window: Track edge constraints
GTK has the ability to handle client-decorated windows
in such a way that the behavior of these windows must
match the behavior of the current window manager.
In Mutter, windows can be tiled horizontally (and, in
the future, vertically as well), which comes with a few
requirements that the toolkit must supply. Tiled windows
have their borders' behavior changed depending on the
tiled position, and the toolkit must be aware of this
information in order to properly match the window manager
behavior.
In order to provide toolkits with more precise and general
data regarding resizable and constrained edges, this patch
makes MetaWindow track its own edge constraints.
This will later be used by the backends to send information
to the toolkit.
https://bugzilla.gnome.org/show_bug.cgi?id=751857
src/core/window-private.h | 16 ++++++++++-
src/core/window.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 1 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index a4b03ea..df38b2e 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -129,6 +129,13 @@ typedef struct _MetaPlacementRule
int height;
} MetaPlacementRule;
+typedef enum
+{
+ META_EDGE_CONSTRAINT_NONE = 0,
+ META_EDGE_CONSTRAINT_WINDOW = 1,
+ META_EDGE_CONSTRAINT_MONITOR = 2,
+} MetaEdgeConstraint;
+
struct _MetaWindow
{
GObject parent_instance;
@@ -205,10 +212,17 @@ struct _MetaWindow
* that to toggle between normal/tiled or maximized/tiled states. */
guint saved_maximize : 1;
int tile_monitor_number;
- int preferred_output_winsys_id;
+
+ /* 0 - top
+ * 1 - right
+ * 2 - bottom
+ * 3 - left */
+ MetaEdgeConstraint edge_constraints[4];
double tile_hfraction;
+ int preferred_output_winsys_id;
+
/* Whether we're shaded */
guint shaded : 1;
diff --git a/src/core/window.c b/src/core/window.c
index e460171..ed42f26 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -135,6 +135,7 @@ static void set_workspace_state (MetaWindow *window,
static MetaWindow * meta_window_find_tile_match (MetaWindow *window,
MetaTileMode mode);
+static void update_edge_constraints (MetaWindow *window);
/* Idle handlers for the three queues (run with meta_later_add()). The
* "data" parameter in each case will be a GINT_TO_POINTER of the
@@ -2762,6 +2763,9 @@ meta_window_maximize_internal (MetaWindow *window,
window->maximized_vertically =
window->maximized_vertically || maximize_vertically;
+ /* Update the edge constraints */
+ update_edge_constraints (window);;
+
meta_window_recalc_features (window);
set_net_wm_state (window);
@@ -3015,6 +3019,63 @@ meta_window_update_tile_fraction (MetaWindow *window,
meta_window_tile (tile_match, tile_match->tile_mode);
}
+static void
+update_edge_constraints (MetaWindow *window)
+{
+ switch (window->tile_mode)
+ {
+ case META_TILE_NONE:
+ window->edge_constraints[0] = META_EDGE_CONSTRAINT_NONE;
+ window->edge_constraints[1] = META_EDGE_CONSTRAINT_NONE;
+ window->edge_constraints[2] = META_EDGE_CONSTRAINT_NONE;
+ window->edge_constraints[3] = META_EDGE_CONSTRAINT_NONE;
+ break;
+
+ case META_TILE_MAXIMIZED:
+ window->edge_constraints[0] = META_EDGE_CONSTRAINT_MONITOR;
+ window->edge_constraints[1] = META_EDGE_CONSTRAINT_MONITOR;
+ window->edge_constraints[2] = META_EDGE_CONSTRAINT_MONITOR;
+ window->edge_constraints[3] = META_EDGE_CONSTRAINT_MONITOR;
+ break;
+
+ case META_TILE_LEFT:
+ window->edge_constraints[0] = META_EDGE_CONSTRAINT_MONITOR;
+
+ if (window->tile_match)
+ window->edge_constraints[1] = META_EDGE_CONSTRAINT_WINDOW;
+ else
+ window->edge_constraints[1] = META_EDGE_CONSTRAINT_NONE;
+
+ window->edge_constraints[2] = META_EDGE_CONSTRAINT_MONITOR;
+ window->edge_constraints[3] = META_EDGE_CONSTRAINT_MONITOR;
+ break;
+
+ case META_TILE_RIGHT:
+ window->edge_constraints[0] = META_EDGE_CONSTRAINT_MONITOR;
+ window->edge_constraints[1] = META_EDGE_CONSTRAINT_MONITOR;
+ window->edge_constraints[2] = META_EDGE_CONSTRAINT_MONITOR;
+
+ if (window->tile_match)
+ window->edge_constraints[3] = META_EDGE_CONSTRAINT_WINDOW;
+ else
+ window->edge_constraints[3] = META_EDGE_CONSTRAINT_NONE;
+ break;
+ }
+
+ /* h/vmaximize also modify the edge constraints */
+ if (window->maximized_vertically)
+ {
+ window->edge_constraints[0] = META_EDGE_CONSTRAINT_MONITOR;
+ window->edge_constraints[2] = META_EDGE_CONSTRAINT_MONITOR;
+ }
+
+ if (window->maximized_horizontally)
+ {
+ window->edge_constraints[1] = META_EDGE_CONSTRAINT_MONITOR;
+ window->edge_constraints[3] = META_EDGE_CONSTRAINT_MONITOR;
+ }
+}
+
void
meta_window_tile (MetaWindow *window,
MetaTileMode tile_mode)
@@ -3037,6 +3098,9 @@ meta_window_tile (MetaWindow *window,
meta_window_maximize_internal (window, directions, NULL);
meta_screen_update_tile_preview (window->screen, FALSE);
+ /* Setup the edge constraints */
+ update_edge_constraints (window);
+
meta_window_get_frame_rect (window, &old_frame_rect);
meta_window_get_buffer_rect (window, &old_buffer_rect);
@@ -3178,6 +3242,9 @@ meta_window_unmaximize (MetaWindow *window,
window->maximized_vertically =
window->maximized_vertically && !unmaximize_vertically;
+ /* Update the edge constraints */
+ update_edge_constraints (window);
+
/* recalc_features() will eventually clear the cached frame
* extents, but we need the correct frame extents in the code below,
* so invalidate the old frame extents manually up front.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]