git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows.

From
Alexander Gavrilov <angavrilov@gmail.com>
Date
Nov 2, 2008, 18:59 UTC
Message-ID
<1225652389-22082-7-git-send-email-angavrilov@gmail.com>
In-Reply-To
<1225652389-22082-6-git-send-email-angavrilov@gmail.com>

For some reason, on Windows all transient windows are placed in the upper left corner of the screen. Thus, it is necessary to explicitly position the windows relative to their parent. For simplicity this patch uses the function that is used internally by Tk dialogs.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
	I wrapped the call to tk::PlaceWindow in a
	helper function to minimize the number of
	places to change if something happens to it.
	
	-- Alexander
 gitk |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 5b4eaa2..7d153a3 100755
--- a/gitk
+++ b/gitk
@@ -1739,7 +1739,13 @@ proc removehead {id name} {
     unset headids($name)
 }
 
-proc show_error {w top msg} {
+proc center_window {window origin} {
+    # Use a handy function from Tk. Note that it
+    # calls 'update' to figure out dimensions.
+    tk::PlaceWindow $window widget $origin
+}
+
+proc show_error {w top msg {owner {}}} {
     message $w.m -text $msg -justify center -aspect 400
     pack $w.m -side top -fill x -padx 20 -pady 20
     button $w.ok -text [mc OK] -command "destroy $top"
@@ -1748,6 +1754,9 @@ proc show_error {w top msg} {
     bind $top <Key-Return> "destroy $top"
     bind $top <Key-space>  "destroy $top"
     bind $top <Key-Escape> "destroy $top"
+    if {$owner ne {}} {
+	center_window $top $owner
+    }
     tkwait window $top
 }
 
@@ -1755,7 +1764,7 @@ proc error_popup {msg {owner .}} {
     set w .error
     toplevel $w
     wm transient $w $owner
-    show_error $w $w $msg
+    show_error $w $w $msg $owner
 }
 
 proc confirm_popup {msg {owner .}} {
@@ -1774,6 +1783,7 @@ proc confirm_popup {msg {owner .}} {
     bind $w <Key-Return> "set confirm_ok 1; destroy $w"
     bind $w <Key-space>  "set confirm_ok 1; destroy $w"
     bind $w <Key-Escape> "destroy $w"
+    center_window $w $owner
     tkwait window $w
     return $confirm_ok
 }
@@ -2572,6 +2582,7 @@ Use and redistribute under the terms of the GNU General Public License"] \
     bind $w <Visibility> "focus $w.ok"
     bind $w <Key-Escape> "destroy $w"
     bind $w <Key-Return> "destroy $w"
+    center_window $w .
 }
 
 proc keys {} {
@@ -2635,6 +2646,7 @@ proc keys {} {
     bind $w <Visibility> "focus $w.ok"
     bind $w <Key-Escape> "destroy $w"
     bind $w <Key-Return> "destroy $w"
+    center_window $w .
 }
 
 # Procedures for manipulating the file list window at the
@@ -3687,6 +3699,7 @@ proc vieweditor {top n title} {
     grid columnconfigure $top.buts 1 -weight 1 -uniform a
     grid columnconfigure $top.buts 2 -weight 1 -uniform a
     pack $top.buts -in $top -side top -fill x
+    center_window $top .
     focus $top.t
 }
 
@@ -7950,6 +7963,7 @@ proc mkpatch {} {
     grid columnconfigure $top.buts 1 -weight 1 -uniform a
     grid $top.buts - -pady 10 -sticky ew
     focus $top.fname
+    center_window $top .
 }
 
 proc mkpatchrev {} {
@@ -8024,6 +8038,7 @@ proc mktag {} {
     grid columnconfigure $top.buts 1 -weight 1 -uniform a
     grid $top.buts - -pady 10 -sticky ew
     focus $top.tag
+    center_window $top .
 }
 
 proc domktag {} {
@@ -8131,6 +8146,7 @@ proc writecommit {} {
     grid columnconfigure $top.buts 1 -weight 1 -uniform a
     grid $top.buts - -pady 10 -sticky ew
     focus $top.fname
+    center_window $top .
 }
 
 proc wrcomgo {} {
@@ -8181,6 +8197,7 @@ proc mkbranch {} {
     grid columnconfigure $top.buts 1 -weight 1 -uniform a
     grid $top.buts - -pady 10 -sticky ew
     focus $top.name
+    center_window $top .
 }
 
 proc mkbrgo {top} {
@@ -8341,6 +8358,7 @@ proc resethead {} {
     bind $w <Key-Escape> [list destroy $w]
     pack $w.cancel -side right -fill x -padx 20 -pady 20
     bind $w <Visibility> "grab $w; focus $w"
+    center_window $w .
     tkwait window $w
     if {!$confirm_ok} return
     if {[catch {set fd [open \
@@ -8526,6 +8544,7 @@ proc showrefs {} {
     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
     set reflist {}
     refill_reflist
+    center_window $top .
 }
 
 proc sel_reflist {w x y} {
@@ -9878,6 +9897,7 @@ proc choosefont {font which} {
 	grid columnconfigure $top.buts 1 -weight 1 -uniform a
 	pack $top.buts -side bottom -fill x
 	trace add variable fontparam write chg_fontparam
+	center_window $top $prefstop
     } else {
 	raise $top
 	$top.c itemconf text -text $which
@@ -10060,6 +10080,7 @@ proc doprefs {} {
     grid columnconfigure $top.buts 1 -weight 1 -uniform a
     grid $top.buts - - -pady 10 -sticky ew
     bind $top <Visibility> "focus $top.buts.ok"
+    center_window $top .
 }
 
 proc choose_extdiff {} {
-- 
1.6.0.3.15.gb8d36
Previous: Alexander GavrilovNext: Paul Mackerras
Message 7 of 21 in “Enhance popup dialogs in gitk.”
  1. 0/6 Enhance popup dialogs in gitk.Alexander Gavrilov, Nov 2, 2008
  2. 1/6 gitk: Add Return and Escape bindings to dialogs.Alexander Gavrilov, Nov 2, 2008
  3. 2/6 gitk: Make gitk dialog windows transient.Alexander Gavrilov, Nov 2, 2008
  4. 3/6 gitk: Add accelerators to frequently used menu commands.Alexander Gavrilov, Nov 2, 2008
  5. 4/6 gitk: Make cherry-pick call git-citool on conflicts.Alexander Gavrilov, Nov 2, 2008
  6. 5/6 gitk: Implement a user-friendly Edit View dialog.Alexander Gavrilov, Nov 2, 2008
  7. 6/6 gitk: Explicitly position popup windows.Alexander Gavrilov, Nov 2, 2008
  8. Paul MackerrasNov 7, 2008
  9. Alex RiesenNov 7, 2008
  10. Johannes SixtNov 7, 2008
  11. Alex RiesenNov 9, 2008
  12. Paul MackerrasNov 9, 2008
  13. Alexander GavrilovNov 9, 2008
  14. Paul MackerrasNov 10, 2008
  15. Alexander GavrilovNov 10, 2008
  16. Alexander GavrilovNov 11, 2008
  17. Paul MackerrasNov 7, 2008
  18. Paul MackerrasNov 7, 2008
  19. Alexander GavrilovNov 9, 2008
  20. Paul MackerrasNov 7, 2008
  21. Paul MackerrasNov 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.