Bug 447074

Summary: Split-view creates uneven views
Product: [Applications] konsole Reporter: nic.christin <nic.christin>
Component: split-viewAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: minor CC: almur.kde
Priority: NOR    
Version: 21.12.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: attachment-25446-0.html
attachment-4483-0.html

Description nic.christin@gmail.com 2021-12-16 13:38:38 UTC
SUMMARY
Split-view creates uneven views when a window is split 2 or more times. The middle views are much smaller than the two outmost views. This is a new behavior. Until recently, splitting a window 2 times resulted in 3 views of equal size.

STEPS TO REPRODUCE
1. Open a new konsole and make it 60 lines tall (for example)
2. Do "Split View Top/Bottom" two times in a row

OBSERVED RESULT
Three views are created. The top and bottom ones are 23 lines tall. The middle one is 13 lines tall.

EXPECTED RESULT
All views should have the same height.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: archlinux
KDE Plasma Version: 5.23.4
KDE Frameworks Version: 5.89.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
This behavior can be recreated consistently with a fresh new konsole. However there are additional oddities when split views are created, resized, closed, and then split views are created again. Then sometime the first new split will result in two views of different sizes.
Comment 1 Alfonso Murolo 2021-12-19 09:51:46 UTC
I can confirm this, I have tried it on my personal machine (Konsole 21.12 on Archlinux) and on Konsole master (22.03.70). I am looking into why this happens. At a certain point I started thinking that maybe this could be intended, but the fact that the first command spilits in exactly half, and subsequent commands don´t, is to me giving away that something is odd.
Comment 2 tcanabrava 2021-12-19 10:20:33 UTC
Created attachment 144670 [details]
attachment-25446-0.html

Subsequent commands splits the *current* container in exactly half.
I understand the request but I think it would be complex to implement
considering that the old behavior you could do only vertical *or*
horizontal splits, not combine them. (so it was easy to just reorganize the
screen dividing the width by the number of splits)

Now we can combine splits, horizontal and vertical, so resizing all panels
is not so straightforward.


Le dim. 19 déc. 2021 à 09:51, Alfonso Murolo <bugzilla_noreply@kde.org> a
écrit :

> https://bugs.kde.org/show_bug.cgi?id=447074
>
> Alfonso Murolo <almur.kde@gmail.com> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>                  CC|                            |almur.kde@gmail.com
>
> --- Comment #1 from Alfonso Murolo <almur.kde@gmail.com> ---
> I can confirm this, I have tried it on my personal machine (Konsole 21.12
> on
> Archlinux) and on Konsole master (22.03.70). I am looking into why this
> happens. At a certain point I started thinking that maybe this could be
> intended, but the fact that the first command spilits in exactly half, and
> subsequent commands don´t, is to me giving away that something is odd.
>
> --
> You are receiving this mail because:
> You are the assignee for the bug.
Comment 3 Alfonso Murolo 2021-12-19 10:38:56 UTC
(In reply to tcanabrava from comment #2)
> Created attachment 144670 [details]
> attachment-25446-0.html
> 
> Subsequent commands splits the *current* container in exactly half.
> I understand the request but I think it would be complex to implement
> considering that the old behavior you could do only vertical *or*
> horizontal splits, not combine them. (so it was easy to just reorganize the
> screen dividing the width by the number of splits)
> 
> Now we can combine splits, horizontal and vertical, so resizing all panels
> is not so straightforward.
> 
> 
> Le dim. 19 déc. 2021 à 09:51, Alfonso Murolo <bugzilla_noreply@kde.org> a
> écrit :
> 
> > https://bugs.kde.org/show_bug.cgi?id=447074
> >
> > Alfonso Murolo <almur.kde@gmail.com> changed:
> >
> >            What    |Removed                     |Added
> >
> > ----------------------------------------------------------------------------
> >                  CC|                            |almur.kde@gmail.com
> >
> > --- Comment #1 from Alfonso Murolo <almur.kde@gmail.com> ---
> > I can confirm this, I have tried it on my personal machine (Konsole 21.12
> > on
> > Archlinux) and on Konsole master (22.03.70). I am looking into why this
> > happens. At a certain point I started thinking that maybe this could be
> > intended, but the fact that the first command spilits in exactly half, and
> > subsequent commands don´t, is to me giving away that something is odd.
> >
> > --
> > You are receiving this mail because:
> > You are the assignee for the bug.

As I am not very familiar with the code of the ViewSplitter, and I chose this issue as the first one ever to look at (:D), please take my words with a grain of salt: it seems from the behaviour however that the sizes of the current container are incorrectly referenced to. 

This results in a failure:
1. Split the views in half top/bottom. Views will be split correctly
2. Kill the bottom view. Now only one view exists, exactly identical to the first
3. Split the view in half top/bottom again. Current container should, intuitively, be exactly the same size of the original container, to be split in half. Observe the failure in splitting in half a second time.
Comment 4 tcanabrava 2021-12-19 12:28:23 UTC
Created attachment 144677 [details]
attachment-4483-0.html

you are correct, there is a bug there, I have never realized it.
Do you want to try to solve it? code *should* not be complex.
if not, I can try later on.


On Sun, Dec 19, 2021 at 10:39 AM Alfonso Murolo <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=447074
>
> --- Comment #3 from Alfonso Murolo <almur.kde@gmail.com> ---
> (In reply to tcanabrava from comment #2)
> > Created attachment 144670 [details]
> > attachment-25446-0.html
> >
> > Subsequent commands splits the *current* container in exactly half.
> > I understand the request but I think it would be complex to implement
> > considering that the old behavior you could do only vertical *or*
> > horizontal splits, not combine them. (so it was easy to just reorganize
> the
> > screen dividing the width by the number of splits)
> >
> > Now we can combine splits, horizontal and vertical, so resizing all
> panels
> > is not so straightforward.
> >
> >
> > Le dim. 19 déc. 2021 à 09:51, Alfonso Murolo <bugzilla_noreply@kde.org>
> a
> > écrit :
> >
> > > https://bugs.kde.org/show_bug.cgi?id=447074
> > >
> > > Alfonso Murolo <almur.kde@gmail.com> changed:
> > >
> > >            What    |Removed                     |Added
> > >
> > >
> ----------------------------------------------------------------------------
> > >                  CC|                            |almur.kde@gmail.com
> > >
> > > --- Comment #1 from Alfonso Murolo <almur.kde@gmail.com> ---
> > > I can confirm this, I have tried it on my personal machine (Konsole
> 21.12
> > > on
> > > Archlinux) and on Konsole master (22.03.70). I am looking into why this
> > > happens. At a certain point I started thinking that maybe this could be
> > > intended, but the fact that the first command spilits in exactly half,
> and
> > > subsequent commands don´t, is to me giving away that something is odd.
> > >
> > > --
> > > You are receiving this mail because:
> > > You are the assignee for the bug.
>
> As I am not very familiar with the code of the ViewSplitter, and I chose
> this
> issue as the first one ever to look at (:D), please take my words with a
> grain
> of salt: it seems from the behaviour however that the sizes of the current
> container are incorrectly referenced to.
>
> This results in a failure:
> 1. Split the views in half top/bottom. Views will be split correctly
> 2. Kill the bottom view. Now only one view exists, exactly identical to the
> first
> 3. Split the view in half top/bottom again. Current container should,
> intuitively, be exactly the same size of the original container, to be
> split in
> half. Observe the failure in splitting in half a second time.
>
> --
> You are receiving this mail because:
> You are the assignee for the bug.
Comment 5 Alfonso Murolo 2021-12-19 12:32:20 UTC
(In reply to tcanabrava from comment #4)
> Created attachment 144677 [details]
> attachment-4483-0.html
> 
> you are correct, there is a bug there, I have never realized it.
> Do you want to try to solve it? code *should* not be complex.
> if not, I can try later on.
> 
> 
> On Sun, Dec 19, 2021 at 10:39 AM Alfonso Murolo <bugzilla_noreply@kde.org>
> wrote:
> 
> > https://bugs.kde.org/show_bug.cgi?id=447074
> >
> > --- Comment #3 from Alfonso Murolo <almur.kde@gmail.com> ---
> > (In reply to tcanabrava from comment #2)
> > > Created attachment 144670 [details]
> > > attachment-25446-0.html
> > >
> > > Subsequent commands splits the *current* container in exactly half.
> > > I understand the request but I think it would be complex to implement
> > > considering that the old behavior you could do only vertical *or*
> > > horizontal splits, not combine them. (so it was easy to just reorganize
> > the
> > > screen dividing the width by the number of splits)
> > >
> > > Now we can combine splits, horizontal and vertical, so resizing all
> > panels
> > > is not so straightforward.
> > >
> > >
> > > Le dim. 19 déc. 2021 à 09:51, Alfonso Murolo <bugzilla_noreply@kde.org>
> > a
> > > écrit :
> > >
> > > > https://bugs.kde.org/show_bug.cgi?id=447074
> > > >
> > > > Alfonso Murolo <almur.kde@gmail.com> changed:
> > > >
> > > >            What    |Removed                     |Added
> > > >
> > > >
> > ----------------------------------------------------------------------------
> > > >                  CC|                            |almur.kde@gmail.com
> > > >
> > > > --- Comment #1 from Alfonso Murolo <almur.kde@gmail.com> ---
> > > > I can confirm this, I have tried it on my personal machine (Konsole
> > 21.12
> > > > on
> > > > Archlinux) and on Konsole master (22.03.70). I am looking into why this
> > > > happens. At a certain point I started thinking that maybe this could be
> > > > intended, but the fact that the first command spilits in exactly half,
> > and
> > > > subsequent commands don´t, is to me giving away that something is odd.
> > > >
> > > > --
> > > > You are receiving this mail because:
> > > > You are the assignee for the bug.
> >
> > As I am not very familiar with the code of the ViewSplitter, and I chose
> > this
> > issue as the first one ever to look at (:D), please take my words with a
> > grain
> > of salt: it seems from the behaviour however that the sizes of the current
> > container are incorrectly referenced to.
> >
> > This results in a failure:
> > 1. Split the views in half top/bottom. Views will be split correctly
> > 2. Kill the bottom view. Now only one view exists, exactly identical to the
> > first
> > 3. Split the view in half top/bottom again. Current container should,
> > intuitively, be exactly the same size of the original container, to be
> > split in
> > half. Observe the failure in splitting in half a second time.
> >
> > --
> > You are receiving this mail because:
> > You are the assignee for the bug.

I´d like to try to fix it. As it is my first issue, it will probably take me a while to figure out how the entire splitter works, but hopefully it shouldn´t be too hard :-)
Comment 6 Bug Janitor Service 2021-12-19 17:04:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/559
Comment 7 Alfonso Murolo 2021-12-19 17:08:33 UTC
(In reply to tcanabrava from comment #4)
> Created attachment 144677 [details]
> attachment-4483-0.html
> 
> you are correct, there is a bug there, I have never realized it.
> Do you want to try to solve it? code *should* not be complex.
> if not, I can try later on.
> 
> 
> On Sun, Dec 19, 2021 at 10:39 AM Alfonso Murolo <bugzilla_noreply@kde.org>
> wrote:
> 
> > https://bugs.kde.org/show_bug.cgi?id=447074
> >
> > --- Comment #3 from Alfonso Murolo <almur.kde@gmail.com> ---
> > (In reply to tcanabrava from comment #2)
> > > Created attachment 144670 [details]
> > > attachment-25446-0.html
> > >
> > > Subsequent commands splits the *current* container in exactly half.
> > > I understand the request but I think it would be complex to implement
> > > considering that the old behavior you could do only vertical *or*
> > > horizontal splits, not combine them. (so it was easy to just reorganize
> > the
> > > screen dividing the width by the number of splits)
> > >
> > > Now we can combine splits, horizontal and vertical, so resizing all
> > panels
> > > is not so straightforward.
> > >
> > >
> > > Le dim. 19 déc. 2021 à 09:51, Alfonso Murolo <bugzilla_noreply@kde.org>
> > a
> > > écrit :
> > >
> > > > https://bugs.kde.org/show_bug.cgi?id=447074
> > > >
> > > > Alfonso Murolo <almur.kde@gmail.com> changed:
> > > >
> > > >            What    |Removed                     |Added
> > > >
> > > >
> > ----------------------------------------------------------------------------
> > > >                  CC|                            |almur.kde@gmail.com
> > > >
> > > > --- Comment #1 from Alfonso Murolo <almur.kde@gmail.com> ---
> > > > I can confirm this, I have tried it on my personal machine (Konsole
> > 21.12
> > > > on
> > > > Archlinux) and on Konsole master (22.03.70). I am looking into why this
> > > > happens. At a certain point I started thinking that maybe this could be
> > > > intended, but the fact that the first command spilits in exactly half,
> > and
> > > > subsequent commands don´t, is to me giving away that something is odd.
> > > >
> > > > --
> > > > You are receiving this mail because:
> > > > You are the assignee for the bug.
> >
> > As I am not very familiar with the code of the ViewSplitter, and I chose
> > this
> > issue as the first one ever to look at (:D), please take my words with a
> > grain
> > of salt: it seems from the behaviour however that the sizes of the current
> > container are incorrectly referenced to.
> >
> > This results in a failure:
> > 1. Split the views in half top/bottom. Views will be split correctly
> > 2. Kill the bottom view. Now only one view exists, exactly identical to the
> > first
> > 3. Split the view in half top/bottom again. Current container should,
> > intuitively, be exactly the same size of the original container, to be
> > split in
> > half. Observe the failure in splitting in half a second time.
> >
> > --
> > You are receiving this mail because:
> > You are the assignee for the bug.

I should have now correctly issued the merge request. Should I also take the assignment of this bug ticket? How is the workflow exactly? Any further guidance about this is welcome!
Comment 8 tcanabrava 2021-12-28 10:58:35 UTC
Git commit 68d9179566828b047162b0dec718f8adf2fc1379 by Tomaz  Canabrava, on behalf of Alfonso Murolo.
Committed on 28/12/2021 at 10:51.
Pushed by tcanabrava into branch 'master'.

ViewSplitter will now consistently create even-spaced splits

ViewSplitter was creating widgets of inconsistent sizes after adding/removing them in Konsole.
This change forces the active splitter to always be updated with the appropriate even-spacing size for the widgets.
As a drawback, manual changes to sizes will be overwritten when a new widget is added if no new splitter needs to be instantiated.

M  +2    -0    src/widgets/ViewSplitter.cpp

https://invent.kde.org/utilities/konsole/commit/68d9179566828b047162b0dec718f8adf2fc1379