# [PATCH 0/2] fix resize issues on large screens

5 messages from 2023-07-08 to 2023-07-10. Participants: Georg Müller, Johannes Sixt.
Thread: https://gitlist.dev/t/59967

## Georg Müller, 2023-07-08 10:55

Subject: [PATCH 0/2] fix resize issues on large screens
Message-ID: <20230708105546.2945446-2-georgmueller@gmx.net>
URL: https://gitlist.dev/e/20230708105546.2945446-2-georgmueller%40gmx.net

```
When opening gitk in a multi-monitor setup with different resolutions,
the resize factor causes the first columns of the layout get bigger and
bigger while the other columns (author, date in upper pane, file list in
lower pane) shrink to a minimum size.

The following setup triggers the problem on Fedora 38/Gnome 44:
* primary screen 1 has a FHD resolution (1920x1080)
* secondary screen 2 has a QHD resolution (2560x1440)

Every time gitk opens at screen 2, the resize is triggered and the columns
are shifted 1.33x to the right (2560/1920 = 1.33).
After multiple rounds of closing/opening gitk, the columns are at their
minimum size and the contents are not visible or only a minimum is
visible.

The following patches are two approaches to fix the problem. Maybe the
hard-coded values could be variables, this is a first shot to solve the
problem.

Georg Müller (2):
  gitk: limit factor scaling on resize to widths below 1900px
  gitk: keep author and date colums to a minimal width on resize

 gitk-git/gitk | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

--
2.41.0


```

## Georg Müller, 2023-07-08 10:55

Subject: [PATCH 1/2] gitk: limit factor scaling on resize to widths below 1900px
Message-ID: <20230708105546.2945446-3-georgmueller@gmx.net>
URL: https://gitlist.dev/e/20230708105546.2945446-3-georgmueller%40gmx.net
In-Reply-To: <20230708105546.2945446-2-georgmueller@gmx.net>

```
If old and new width is above 1900, the scaling would result in widening
the author and date column unnecessarily.

Signed-off-by: Georg Müller <georgmueller@gmx.net>
---
 gitk-git/gitk | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index df3ba2ea99..0f229aadd7 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2985,6 +2985,9 @@ proc resizeclistpanes {win w} {
             set s0 [$win sash coord 0]
             set s1 [$win sash coord 1]
         }
+        if {$oldwidth($win) > 1900 && $w > 1900} {
+            return
+        }
         if {$w < 60} {
             set sash0 [expr {int($w/2 - 2)}]
             set sash1 [expr {int($w*5/6 - 2)}]
@@ -3029,6 +3032,9 @@ proc resizecdetpanes {win w} {
         } else {
             set s0 [$win sash coord 0]
         }
+        if {$oldwidth($win) > 1900 && $w > 1900} {
+            return
+        }
         if {$w < 60} {
             set sash0 [expr {int($w*3/4 - 2)}]
         } else {
--
2.41.0


```

## Georg Müller, 2023-07-08 10:55

Subject: [PATCH 2/2] gitk: keep author and date colums to a minimal width on resize
Message-ID: <20230708105546.2945446-4-georgmueller@gmx.net>
URL: https://gitlist.dev/e/20230708105546.2945446-4-georgmueller%40gmx.net
In-Reply-To: <20230708105546.2945446-2-georgmueller@gmx.net>

```
Signed-off-by: Georg Müller <georgmueller@gmx.net>
---
 gitk-git/gitk | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 0f229aadd7..819e059599 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2973,7 +2973,7 @@ proc savestuff {w} {
 }

 proc resizeclistpanes {win w} {
-    global oldwidth oldsash use_ttk
+    global oldwidth oldsash use_ttk charspc
     if {[info exists oldwidth($win)]} {
         if {[info exists oldsash($win)]} {
             set s0 [lindex $oldsash($win) 0]
@@ -3007,7 +3007,16 @@ proc resizeclistpanes {win w} {
                     set sash0 [expr {$sash1 - 20}]
                 }
             }
+            if {$w > 150 * $charspc} {
+                if {$sash1 + (20 * $charspc) > $w} {
+                    set sash1 [expr {$w - (20 * $charspc)}]
+                }
+                if {$sash0 + (30 * $charspc) > $sash1} {
+                    set sash0 [expr {$sash1 - (30 * $charspc)}]
+                }
+            }
         }
+
         if {$use_ttk} {
             $win sashpos 0 $sash0
             $win sashpos 1 $sash1
@@ -3023,7 +3032,7 @@ proc resizeclistpanes {win w} {
 }

 proc resizecdetpanes {win w} {
-    global oldwidth oldsash use_ttk
+    global oldwidth oldsash use_ttk charspc
     if {[info exists oldwidth($win)]} {
         if {[info exists oldsash($win)]} {
             set s0 $oldsash($win)
@@ -3046,6 +3055,11 @@ proc resizecdetpanes {win w} {
             if {$sash0 > $w - 15} {
                 set sash0 [expr {$w - 15}]
             }
+            if {$w > 150 * $charspc} {
+                if {$sash0 + (30 * $charspc) > $w} {
+                    set sash0 [expr {$w - (30 * $charspc)}]
+                }
+            }
         }
         if {$use_ttk} {
             $win sashpos 0 $sash0
--
2.41.0


```

## Johannes Sixt, 2023-07-10 16:37

Subject: Re: [PATCH 0/2] fix resize issues on large screens
Message-ID: <9a498c81-82b4-d441-6b5d-78ba3043b5a9@kdbg.org>
URL: https://gitlist.dev/e/9a498c81-82b4-d441-6b5d-78ba3043b5a9%40kdbg.org
In-Reply-To: <20230708105546.2945446-2-georgmueller@gmx.net>

```
Am 08.07.23 um 12:55 schrieb Georg Müller:
> When opening gitk in a multi-monitor setup with different resolutions,
> the resize factor causes the first columns of the layout get bigger and
> bigger while the other columns (author, date in upper pane, file list in
> lower pane) shrink to a minimum size.
> 
> The following setup triggers the problem on Fedora 38/Gnome 44:
> * primary screen 1 has a FHD resolution (1920x1080)
> * secondary screen 2 has a QHD resolution (2560x1440)
> 
> Every time gitk opens at screen 2, the resize is triggered and the columns
> are shifted 1.33x to the right (2560/1920 = 1.33).
> After multiple rounds of closing/opening gitk, the columns are at their
> minimum size and the contents are not visible or only a minimum is
> visible.
> 
> The following patches are two approaches to fix the problem. Maybe the
> hard-coded values could be variables, this is a first shot to solve the
> problem.

Since you haven't stated it explicitly, I assume that with "the problem
solved" the resizing does not happen anymore. That's fine, but could be
stated explicitly.

When you say "two approaches", do you mean that the patches are
independent and either one solves the problem? And only one of them
should be taken?

I've not read the code changes (because I don't know a lot of Tcl/Tk).
But I've seen the commit messages of the patches. They are mostly empty.
This cover letter has a pretty good explanation of the problem. Please
copy everything that is relevant for each commit to the commit message,
because the cover letter won't be available in the commit history.

Thanks,
-- Hannes

> 
> Georg Müller (2):
>   gitk: limit factor scaling on resize to widths below 1900px
>   gitk: keep author and date colums to a minimal width on resize
> 
>  gitk-git/gitk | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> --
> 2.41.0
> 
> 


```

## Georg Müller, 2023-07-10 21:04

Subject: Re: [PATCH 0/2] fix resize issues on large screens
Message-ID: <2621e32f-128b-2254-3215-7a6fc69c9064@gmx.net>
URL: https://gitlist.dev/e/2621e32f-128b-2254-3215-7a6fc69c9064%40gmx.net
In-Reply-To: <9a498c81-82b4-d441-6b5d-78ba3043b5a9@kdbg.org>

```

Am 10.07.23 um 18:37 schrieb Johannes Sixt:
> Am 08.07.23 um 12:55 schrieb Georg Müller:
>> When opening gitk in a multi-monitor setup with different resolutions,
>> the resize factor causes the first columns of the layout get bigger and
>> bigger while the other columns (author, date in upper pane, file list in
>> lower pane) shrink to a minimum size.
>>
>> The following setup triggers the problem on Fedora 38/Gnome 44:
>> * primary screen 1 has a FHD resolution (1920x1080)
>> * secondary screen 2 has a QHD resolution (2560x1440)
>>
>> Every time gitk opens at screen 2, the resize is triggered and the columns
>> are shifted 1.33x to the right (2560/1920 = 1.33).
>> After multiple rounds of closing/opening gitk, the columns are at their
>> minimum size and the contents are not visible or only a minimum is
>> visible.
>>
>> The following patches are two approaches to fix the problem. Maybe the
>> hard-coded values could be variables, this is a first shot to solve the
>> problem.
>
> Since you haven't stated it explicitly, I assume that with "the problem
> solved" the resizing does not happen anymore. That's fine, but could be
> stated explicitly.
>
> When you say "two approaches", do you mean that the patches are
> independent and either one solves the problem? And only one of them
> should be taken?
>
> I've not read the code changes (because I don't know a lot of Tcl/Tk).
> But I've seen the commit messages of the patches. They are mostly empty.
> This cover letter has a pretty good explanation of the problem. Please
> copy everything that is relevant for each commit to the commit message,
> because the cover letter won't be available in the commit history.
>
> Thanks,
> -- Hannes

Thank you for your suggestions. I will rephrase the commit messages and
will resend the commits.

In general, the patches are independent and both solve it for me, but
both of them make sense since scaling author and date columns above a
certain resolution does not make sense anymore and having a sane minimum
width if there is enough space for the first column also makes sense.

Best regards,
Georg


>>
>> Georg Müller (2):
>>    gitk: limit factor scaling on resize to widths below 1900px
>>    gitk: keep author and date colums to a minimal width on resize
>>
>>   gitk-git/gitk | 24 ++++++++++++++++++++++--
>>   1 file changed, 22 insertions(+), 2 deletions(-)
>>
>> --
>> 2.41.0
>>
>>
>

```
