window: Put placement related fields in a anynomous struct
To organize things a bit better, put the fields related to the placement rule state in its own anonymous struct inside MetaWindow. While at it, rename the somewhat oddly named variable that in practice means the current relative window position. https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
This commit is contained in:
parent
d22f947bf5
commit
05e9d6ab9e
@ -490,14 +490,14 @@ place_window_if_needed(MetaWindow *window,
|
|||||||
|
|
||||||
orig_rect = info->orig;
|
orig_rect = info->orig;
|
||||||
|
|
||||||
if (window->placement_rule)
|
if (window->placement.rule)
|
||||||
{
|
{
|
||||||
MetaWindow *parent = meta_window_get_transient_for (window);
|
MetaWindow *parent = meta_window_get_transient_for (window);
|
||||||
MetaRectangle parent_rect;
|
MetaRectangle parent_rect;
|
||||||
int rel_x, rel_y;
|
int rel_x, rel_y;
|
||||||
|
|
||||||
meta_window_process_placement (window,
|
meta_window_process_placement (window,
|
||||||
window->placement_rule,
|
window->placement.rule,
|
||||||
&rel_x, &rel_y);
|
&rel_x, &rel_y);
|
||||||
meta_window_get_frame_rect (parent, &parent_rect);
|
meta_window_get_frame_rect (parent, &parent_rect);
|
||||||
|
|
||||||
@ -831,15 +831,15 @@ constrain_custom_rule (MetaWindow *window,
|
|||||||
parent = meta_window_get_transient_for (window);
|
parent = meta_window_get_transient_for (window);
|
||||||
meta_window_get_frame_rect (parent, &parent_rect);
|
meta_window_get_frame_rect (parent, &parent_rect);
|
||||||
|
|
||||||
switch (window->placement_state)
|
switch (window->placement.state)
|
||||||
{
|
{
|
||||||
case META_PLACEMENT_STATE_UNCONSTRAINED:
|
case META_PLACEMENT_STATE_UNCONSTRAINED:
|
||||||
break;
|
break;
|
||||||
case META_PLACEMENT_STATE_CONSTRAINED:
|
case META_PLACEMENT_STATE_CONSTRAINED:
|
||||||
adjusted_unconstrained.x =
|
adjusted_unconstrained.x =
|
||||||
parent_rect.x + window->constrained_placement_rule_offset_x;
|
parent->rect.x + window->placement.current.rel_x;
|
||||||
adjusted_unconstrained.y =
|
adjusted_unconstrained.y =
|
||||||
parent_rect.y + window->constrained_placement_rule_offset_y;
|
parent->rect.y + window->placement.current.rel_y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,7 +857,7 @@ constrain_custom_rule (MetaWindow *window,
|
|||||||
|
|
||||||
current_rule = *placement_rule;
|
current_rule = *placement_rule;
|
||||||
|
|
||||||
switch (window->placement_state)
|
switch (window->placement.state)
|
||||||
{
|
{
|
||||||
case META_PLACEMENT_STATE_CONSTRAINED:
|
case META_PLACEMENT_STATE_CONSTRAINED:
|
||||||
info->current = adjusted_unconstrained;
|
info->current = adjusted_unconstrained;
|
||||||
@ -965,10 +965,10 @@ constrain_custom_rule (MetaWindow *window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
window->placement_state = META_PLACEMENT_STATE_CONSTRAINED;
|
window->placement.state = META_PLACEMENT_STATE_CONSTRAINED;
|
||||||
|
|
||||||
window->constrained_placement_rule_offset_x = info->current.x - parent_rect.x;
|
window->placement.current.rel_x = info->current.x - parent_rect.x;
|
||||||
window->constrained_placement_rule_offset_y = info->current.y - parent_rect.y;
|
window->placement.current.rel_y = info->current.y - parent_rect.y;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -671,7 +671,7 @@ meta_window_place (MetaWindow *window,
|
|||||||
|
|
||||||
meta_topic (META_DEBUG_PLACEMENT, "Placing window %s\n", window->desc);
|
meta_topic (META_DEBUG_PLACEMENT, "Placing window %s\n", window->desc);
|
||||||
|
|
||||||
g_return_if_fail (!window->placement_rule);
|
g_return_if_fail (!window->placement.rule);
|
||||||
|
|
||||||
switch (window->type)
|
switch (window->type)
|
||||||
{
|
{
|
||||||
|
@ -534,10 +534,15 @@ struct _MetaWindow
|
|||||||
/* Bypass compositor hints */
|
/* Bypass compositor hints */
|
||||||
guint bypass_compositor;
|
guint bypass_compositor;
|
||||||
|
|
||||||
MetaPlacementRule *placement_rule;
|
struct {
|
||||||
MetaPlacementState placement_state;
|
MetaPlacementRule *rule;
|
||||||
int constrained_placement_rule_offset_x;
|
MetaPlacementState state;
|
||||||
int constrained_placement_rule_offset_y;
|
|
||||||
|
struct {
|
||||||
|
int rel_x;
|
||||||
|
int rel_y;
|
||||||
|
} current;
|
||||||
|
} placement;
|
||||||
|
|
||||||
guint unmanage_idle_id;
|
guint unmanage_idle_id;
|
||||||
};
|
};
|
||||||
|
@ -344,7 +344,7 @@ meta_window_finalize (GObject *object)
|
|||||||
g_free (window->gtk_window_object_path);
|
g_free (window->gtk_window_object_path);
|
||||||
g_free (window->gtk_app_menu_object_path);
|
g_free (window->gtk_app_menu_object_path);
|
||||||
g_free (window->gtk_menubar_object_path);
|
g_free (window->gtk_menubar_object_path);
|
||||||
g_free (window->placement_rule);
|
g_free (window->placement.rule);
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_window_parent_class)->finalize (object);
|
G_OBJECT_CLASS (meta_window_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -8523,7 +8523,7 @@ meta_window_emit_size_changed (MetaWindow *window)
|
|||||||
MetaPlacementRule *
|
MetaPlacementRule *
|
||||||
meta_window_get_placement_rule (MetaWindow *window)
|
meta_window_get_placement_rule (MetaWindow *window)
|
||||||
{
|
{
|
||||||
return window->placement_rule;
|
return window->placement.rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -324,7 +324,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
|
|||||||
constrained_rect.height == 1)
|
constrained_rect.height == 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (window->placement_rule)
|
if (window->placement.rule)
|
||||||
{
|
{
|
||||||
MetaWindow *parent = meta_window_get_transient_for (window);
|
MetaWindow *parent = meta_window_get_transient_for (window);
|
||||||
int rel_x, rel_y;
|
int rel_x, rel_y;
|
||||||
@ -913,9 +913,9 @@ void
|
|||||||
meta_window_place_with_placement_rule (MetaWindow *window,
|
meta_window_place_with_placement_rule (MetaWindow *window,
|
||||||
MetaPlacementRule *placement_rule)
|
MetaPlacementRule *placement_rule)
|
||||||
{
|
{
|
||||||
g_clear_pointer (&window->placement_rule, g_free);
|
g_clear_pointer (&window->placement.rule, g_free);
|
||||||
window->placement_rule = g_new0 (MetaPlacementRule, 1);
|
window->placement.rule = g_new0 (MetaPlacementRule, 1);
|
||||||
*window->placement_rule = *placement_rule;
|
*window->placement.rule = *placement_rule;
|
||||||
|
|
||||||
window->unconstrained_rect.width = placement_rule->width;
|
window->unconstrained_rect.width = placement_rule->width;
|
||||||
window->unconstrained_rect.height = placement_rule->height;
|
window->unconstrained_rect.height = placement_rule->height;
|
||||||
|
Loading…
Reference in New Issue
Block a user