mirror of
https://github.com/brl/mutter.git
synced 2025-08-09 01:44:41 +00:00
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:
@@ -222,11 +222,12 @@ struct _MetaWindow
|
||||
guint saved_maximize : 1;
|
||||
int tile_monitor_number;
|
||||
|
||||
/* 0 - top
|
||||
* 1 - right
|
||||
* 2 - bottom
|
||||
* 3 - left */
|
||||
MetaEdgeConstraint edge_constraints[4];
|
||||
struct {
|
||||
MetaEdgeConstraint top;
|
||||
MetaEdgeConstraint right;
|
||||
MetaEdgeConstraint bottom;
|
||||
MetaEdgeConstraint left;
|
||||
} edge_constraints;
|
||||
|
||||
double tile_hfraction;
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user