git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] gitk: Add option to not save window geometry
@ 2018-02-04 12:27 Rodney Lorrimar
  0 siblings, 0 replies; only message in thread
From: Rodney Lorrimar @ 2018-02-04 12:27 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 3396 bytes --]

Saving and restoring the pane widths is not helpful when running gitk
under a tiling window manager. It often results in the second and
third panes being pushed to the far right of the window at startup.

This change adds a preference to disable the saving of window geometry
-- i.e. window position, size, and pane widths.

Signed-off-by: Rodney Lorrimar <dev@rodney.id.au>
---
 gitk-git/gitk | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index a14d7a16b..c3ef0e824 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2857,6 +2857,7 @@ proc savestuff {w} {
     upvar #0 viewperm current_viewperm
     upvar #0 nextviewnum current_nextviewnum
     upvar #0 use_ttk current_use_ttk
+    upvar #0 geometry current_geometry
 
     if {$stuffsaved} return
     if {![winfo viewable .]} return
@@ -2886,19 +2887,23 @@ proc savestuff {w} {
 	    }
 	}
 
-	puts $f "set geometry(main) [wm geometry .]"
-	puts $f "set geometry(state) [wm state .]"
-	puts $f "set geometry(topwidth) [winfo width .tf]"
-	puts $f "set geometry(topheight) [winfo height .tf]"
-	if {$current_use_ttk} {
-	    puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sashpos 0] 1\""
-	    puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
-	} else {
-	    puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
-	    puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sash coord 1]\""
+	set savegeometry [expr {![info exists current_geometry(save)] || $current_geometry(save)}]
+	puts $f "set geometry(save) $savegeometry"
+	if {$savegeometry} {
+	    puts $f "set geometry(main) [wm geometry .]"
+	    puts $f "set geometry(state) [wm state .]"
+	    puts $f "set geometry(topwidth) [winfo width .tf]"
+	    puts $f "set geometry(topheight) [winfo height .tf]"
+	    if {$current_use_ttk} {
+		puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sashpos 0] 1\""
+		puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
+	    } else {
+		puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
+		puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sash coord 1]\""
+	    }
+	    puts $f "set geometry(botwidth) [winfo width .bleft]"
+	    puts $f "set geometry(botheight) [winfo height .bleft]"
 	}
-	puts $f "set geometry(botwidth) [winfo width .bleft]"
-	puts $f "set geometry(botheight) [winfo height .bleft]"
 
 	array set view_save {}
 	array set views {}
@@ -11488,7 +11493,7 @@ proc create_prefs_page {w} {
 proc prefspage_general {notebook} {
     global NS maxwidth maxgraphpct showneartags showlocalchanges
     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
-    global hideremotes want_ttk have_ttk maxrefs
+    global hideremotes want_ttk have_ttk maxrefs geometry
 
     set page [create_prefs_page $notebook.general]
 
@@ -11549,6 +11554,11 @@ proc prefspage_general {notebook} {
 	${NS}::label $page.ttk_note -text [mc "(currently unavailable)"]
     }
     grid x $page.want_ttk $page.ttk_note -sticky w
+    ${NS}::checkbutton $page.save_geometry -variable geometry(save) \
+	-text [mc "Save/restore window geometry"]
+    ${NS}::label $page.save_geometry_note -text [mc "(disable for tiling WMs)"]
+    grid x $page.save_geometry $page.save_geometry_note -sticky w
+
     return $page
 }
 
-- 
2.16.1

[-- Attachment #2: Screenshot of saved window geometry under xmonad --]
[-- Type: image/png, Size: 27471 bytes --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-04 12:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-04 12:27 [PATCH] gitk: Add option to not save window geometry Rodney Lorrimar

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).