Commit f580b28a authored by Jonas Ådahl's avatar Jonas Ådahl Committed by Florian Müllner

window: Replace placement constrained bool with state

Using an actual state instead of a boolean makes it clearer it's a state
that changes. Eventually we might add more state too.

!496
parent b4f15696
......@@ -818,28 +818,34 @@ constrain_custom_rule (MetaWindow *window,
if (!placement_rule)
return TRUE;
if (window->placement_rule_constrained)
switch (window->placement_state)
{
MetaRectangle parent_buffer_rect;
parent = meta_window_get_transient_for (window);
meta_window_get_frame_rect (parent, &parent_rect);
info->current.x =
parent_rect.x + window->constrained_placement_rule_offset_x;
info->current.y =
parent_rect.y + window->constrained_placement_rule_offset_y;
meta_window_get_buffer_rect (parent, &parent_buffer_rect);
if (!meta_rectangle_overlap (&info->current, &parent_buffer_rect) &&
!meta_rectangle_is_adjacent_to (&info->current, &parent_buffer_rect))
{
g_warning ("Buggy client caused popup to be placed outside of parent "
"window");
info->should_unmanage = TRUE;
return TRUE;
}
return TRUE;
case META_PLACEMENT_STATE_UNCONSTRAINED:
break;
case META_PLACEMENT_STATE_CONSTRAINED:
{
MetaRectangle parent_buffer_rect;
parent = meta_window_get_transient_for (window);
meta_window_get_frame_rect (parent, &parent_rect);
info->current.x =
parent_rect.x + window->constrained_placement_rule_offset_x;
info->current.y =
parent_rect.y + window->constrained_placement_rule_offset_y;
meta_window_get_buffer_rect (parent, &parent_buffer_rect);
if (!meta_rectangle_overlap (&info->current, &parent_buffer_rect) &&
!meta_rectangle_is_adjacent_to (&info->current,
&parent_buffer_rect))
{
g_warning ("Buggy client caused popup to be placed outside of "
"parent window");
info->should_unmanage = TRUE;
return TRUE;
}
return TRUE;
}
}
meta_rectangle_intersect (&info->current, &info->work_area_monitor,
......@@ -923,7 +929,7 @@ constrain_custom_rule (MetaWindow *window,
}
done:
window->placement_rule_constrained = TRUE;
window->placement_state = META_PLACEMENT_STATE_CONSTRAINED;
parent = meta_window_get_transient_for (window);
meta_window_get_frame_rect (parent, &parent_rect);
......
......@@ -142,6 +142,12 @@ typedef struct _MetaPlacementRule
int height;
} MetaPlacementRule;
typedef enum _MetaPlacementState
{
META_PLACEMENT_STATE_UNCONSTRAINED,
META_PLACEMENT_STATE_CONSTRAINED,
} MetaPlacementState;
typedef enum
{
META_EDGE_CONSTRAINT_NONE = 0,
......@@ -524,7 +530,7 @@ struct _MetaWindow
guint bypass_compositor;
MetaPlacementRule *placement_rule;
gboolean placement_rule_constrained;
MetaPlacementState placement_state;
int constrained_placement_rule_offset_x;
int constrained_placement_rule_offset_y;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment