elementary / elementary/stylesheet

GtkPaned causes failed assertion inside _gtk_widget_get_preferred_size_for_size()

Open
#328 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
SCSS
Stars
315
Forks
67
Avg merge
44m
Merged PRs (30d)
1

Description

When having a window of a requested size, containing a GtkPaned, with a shrinkable child, there is a failed assert because elementary's separator is 1px wide. The error is the following:

Gtk-CRITICAL **: _gtk_widget_get_preferred_size_for_size: assertion 'size >= -1' failed

I think this is a bug in GTK where it tries to get the separator's width in the wrong orientation. Because child2 is shrinkable, GTK computes the minimum window's width as:

min_width = child1_width + separator_width

Then it tries to get the height of the window based on `min_width` but using the wrong orientation for the separator width. In the process, child2's width should be 0:

child2_width = min_width - child1_width - separator_width

But now `separator_width` is not 1 but 5 (this 5 comes from a legacy default before there were `min-width` properties in GTK's CSS). Which makes `child2_width = -4` causing the failed assert.

We can fix this in elementary's stylesheet by replicating the size properties of the separator along the other orientation like so:

```diff
paned.horizontal > separator {
background-image:
linear-gradient(
to right,
@menu_separator 1px,
@menu_separator_shadow 1px,
@menu_separator_shadow 2px,
transparent 2px
);
margin-right: -7px;
min-width: 8px;
+ margin-top: -7px;
+ min-height: 8px;
}
```

I'm not sure if we should add this fix, or rather wait for it to be fixed upstream.

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/57881017-gtkpaned-causes-failed-assertion-inside-_gtk_widget_get_preferred_size_for_size?utm_campaign=plugin&utm_content=tracker%2F45189256&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F45189256&utm_medium=issues&utm_source=github).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.