window: Make edge constraint code more readable

It relied on indices in arrays determining tile direction and
non-obvious bitmask logic to translate to _GTK_EDGE_CONSTRAINTS. Change
this to explicitly named edge constraints, and clear translation methods
that converts between mutters and GTK+s edge constraint formats.
This commit is contained in:
Jonas Ådahl
2018-10-24 14:24:22 +02:00
parent 5fc07fcc23
commit 640a04d0e4
4 changed files with 107 additions and 49 deletions

View File

@@ -3074,54 +3074,54 @@ 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;
window->edge_constraints.top = META_EDGE_CONSTRAINT_NONE;
window->edge_constraints.right = META_EDGE_CONSTRAINT_NONE;
window->edge_constraints.bottom = META_EDGE_CONSTRAINT_NONE;
window->edge_constraints.left = 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;
window->edge_constraints.top = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.right = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.bottom = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.left = META_EDGE_CONSTRAINT_MONITOR;
break;
case META_TILE_LEFT:
window->edge_constraints[0] = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.top = META_EDGE_CONSTRAINT_MONITOR;
if (window->tile_match)
window->edge_constraints[1] = META_EDGE_CONSTRAINT_WINDOW;
window->edge_constraints.right = META_EDGE_CONSTRAINT_WINDOW;
else
window->edge_constraints[1] = META_EDGE_CONSTRAINT_NONE;
window->edge_constraints.right = META_EDGE_CONSTRAINT_NONE;
window->edge_constraints[2] = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints[3] = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.bottom = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.left = 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;
window->edge_constraints.top = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.right = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.bottom = META_EDGE_CONSTRAINT_MONITOR;
if (window->tile_match)
window->edge_constraints[3] = META_EDGE_CONSTRAINT_WINDOW;
window->edge_constraints.left = META_EDGE_CONSTRAINT_WINDOW;
else
window->edge_constraints[3] = META_EDGE_CONSTRAINT_NONE;
window->edge_constraints.left = 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;
window->edge_constraints.top = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.bottom = META_EDGE_CONSTRAINT_MONITOR;
}
if (window->maximized_horizontally)
{
window->edge_constraints[1] = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints[3] = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.right = META_EDGE_CONSTRAINT_MONITOR;
window->edge_constraints.left = META_EDGE_CONSTRAINT_MONITOR;
}
}