-
Notifications
You must be signed in to change notification settings - Fork 599
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base.fit_widget
hides information from the parent widget
#3531
Comments
While this came up with the overflow layout, the current implementation of diff --git a/spec/wibox/layout/fixed_spec.lua b/spec/wibox/layout/fixed_spec.lua
index a272b7910..ebf868809 100644
--- a/spec/wibox/layout/fixed_spec.lua
+++ b/spec/wibox/layout/fixed_spec.lua
@@ -183,6 +183,29 @@ describe("wibox.layout.fixed", function()
end) -- with spacing
end) -- with widgets
+ describe("with invisible child widget", function()
+ it("skips spacing", function()
+ local first = utils.widget_stub(30, 10)
+ local second = utils.widget_stub(30, 10)
+ local third = utils.widget_stub(30, 15)
+ local spacing_widget = utils.widget_stub(30, 10)
+
+ layout.spacing = 10
+ layout.spacing_widget = spacing_widget
+
+ second.visible = false
+
+ layout:add(first, second, third)
+
+ assert.widget_layout(layout, { 30, 100 }, {
+ p(first, 0, 0, 30, 10),
+ p(spacing_widget, 0, 10, 30, 10),
+ p(third, 0, 20, 30, 15),
+ })
+ assert.widget_fit(layout, { 30, 100 }, { 30, 35 })
+ end)
+ end)
+
describe("emitting signals", function()
local layout_changed
before_each(function() The output of
For |
One potential solution would be to add an additional return value: function mywidget:fit(w, h)
h = math.max(h, 10)
return w, h
end
function base.fit_widget(widget, ...)
if widget.visible == false then
return nil, nil, true
end
return widget:fit(...)
end
local w, h, skip = base.fit_widget(...) If the returned size is greater than the available space, it is up to the layout to decide what that means. The common case would likely be "stop processing more widgets, as I've exhausted the available space". If Update 1: Update 2: |
In the current implementation of I do not think a child widget returning To summarize my thoughts, I agree that a change would need to me made for layouts to be able to distinguish between the first two |
Which is why my proposal includes a dedicated boolean value for that. It might be enough to just return a value greater than what was provided, but I'm currently not sure if that would be free of edge cases.
I guess you mean the right thing, but the wording is a bit off. If it was "desired" space, I would expect |
The docs describe
Yes, some widgets like the imagebox adjust their size based on what's available but it's still up to each widget's implementation to determine its size needs and whether to take into account the available size or not. Something to note is that I thought of a specific case that exemplifies the change in behavior being discussed here. Say we have a fixed layout that is constrained in the direction of the layout and then add several widgets to it. Eventually, a widget is added but there is not enough space for the whole widget to be drawn, so it just takes the remaining available space. When the layout and child widgets are drawn the one that doesn't have enough space will still be drawn, but will be clipped because of the layout size constraint. If instead, the widget that didn't have enough space returned a boolean indicating that, it would not be drawn at all and the layout would not expand to it's absolute max size. The first scenario is what happens in the current implementation and the second would be possible if we made this type of change. I think we should consider whether we want widgets that extend beyond available space to be drawn and clipped or not drawn at all. I suppose the widgets' |
base.fit_widget
encodes too much information into its return valuesbase.fit_widget
hides information from the parent widget
To summarize (or clarify) the problem(and bump it) The current situation is:
Therefore:
There are likely various containers/layouts that have problems with this situation, but the one where it surfaced in #3309 is
Suggested solutionHave
|
I am not against, but there is some tiny risks of breaking some people. While Also, I would prefer the third argument to be an
That will be hard to do in API level 4, but could be enabled for API level 5[1]. Even with the hints, some people might have used this "feature" on purpose in custom widgets. [1] Note that API level 5 does not mean AwesomeWM v5.0, it means "this will be the default for
We need to be careful here. This was submitted(-ish) and reverted a couple time already. They need to be part of
That will be very tricky to do safely. We need to design something which limits the blast radius of such change. Coming from a Qt background, I fully understand why that's better than what we do. And also why size policies + min/max/preferred sizes solve real problems. But how can we make this drop-in without causing an user revolt like the last time we made a change to this API (3.5->4.0 when Maybe adding an optional edit: typo |
That will add the overhead of a table allocation, though. If we do expect a large selection of infrequently used (some profiling on the widget system would be interesting, though) I don't know the history of
That is how awesome/lib/wibox/layout/fixed.lua Lines 64 to 84 in 6ca2fbb
And I'm not aware of a way to change this without having "random widgets displayed", as the comment puts it. We're lacking a separate "consider these widgets for signals, but not for display" results table for But either way, having
I'm not aware of any issues with |
And regardless of what the decision ends up at eventually, it does make sense to put that behind a |
More elaborate description at #3531 (comment).
Extracted from #3309, as this is a more general issue with layouts:
Reworded, the problem is that
base.fit_widget
encodes multiple different things into0, 0
.When spacing is involved, it actually makes a difference whether a widget is
visible = false
and both the widget and the spacing should be skipped, or if the widget only reports0, 0
due to some internal state but should still be shown (or rather, should still be accounted for with spacing) [similar to how spacing is already accounted for when the widget is1, 1
big, which is almost indistinguishable, visually].Similarly, if the layout doesn't have enough space to fit all children, currently the only way a child widget can report "that's not enough space for me" is, again, returning
0, 0
. But that's the condition wherewibox.layout.fixed
shouldbreak
the loop.So there is currently no way for a layout to distinguish between
0, 0
because it isvisible == false
. The layout should skip the widget and keep iterating0, 0
because the remaining space is too small. The layout should stop iteratingCurrent proposal: #3531 (comment)
The text was updated successfully, but these errors were encountered: