@matheusbsbs / matheus-bagliano / commits / e7d640086e
Fork 0

gitk: Fix transient windows on Win32 and MacOS

Transient windows cause problems on these platforms: - On Win32 the windows appear in the top left corner of the screen. In order to fix it, this patch causes them to be explicitly centered on their parents by an idle handler. - On MacOS with Tk 8.4 they appear without a title bar. Since it is clearly unacceptable, this patch disables transient on that platform. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Alexander Gavrilov committed Nov 11, 2008 at 23:55 UTC e7d640086e0d3eb332542da287c40262c6eae207
1 file changed +31 -13
gitk
+31 -13
@@ -1739,6 +1739,24 @@ proc removehead {id name} {
1739 unset headids($name)
1740 }
1741
1742 +proc make_transient {window origin} {
1743 + global have_tk85
1744 +
1745 + # In MacOS Tk 8.4 transient appears to work by setting
1746 + # overrideredirect, which is utterly useless, since the
1747 + # windows get no border, and are not even kept above
1748 + # the parent.
1749 + if {!$have_tk85 && [tk windowingsystem] eq {aqua}} return
1750 +
1751 + wm transient $window $origin
1752 +
1753 + # Windows fails to place transient windows normally, so
1754 + # schedule a callback to center them on the parent.
1755 + if {[tk windowingsystem] eq {win32}} {
1756 + after idle [list tk::PlaceWindow $window widget $origin]
1757 + }
1758 +}
1759 +
1760 proc show_error {w top msg} {
1761 message $w.m -text $msg -justify center -aspect 400
1762 pack $w.m -side top -fill x -padx 20 -pady 20
@@ -1754,7 +1772,7 @@ proc show_error {w top msg} {
1772 proc error_popup {msg {owner .}} {
1773 set w .error
1774 toplevel $w
1757 - wm transient $w $owner
1775 + make_transient $w $owner
1776 show_error $w $w $msg
1777 }
1778
@@ -1763,7 +1781,7 @@ proc confirm_popup {msg {owner .}} {
1781 set confirm_ok 0
1782 set w .confirm
1783 toplevel $w
1766 - wm transient $w $owner
1784 + make_transient $w $owner
1785 message $w.m -text $msg -justify center -aspect 400
1786 pack $w.m -side top -fill x -padx 20 -pady 20
1787 button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
@@ -2558,7 +2576,7 @@ proc about {} {
2576 }
2577 toplevel $w
2578 wm title $w [mc "About gitk"]
2561 - wm transient $w .
2579 + make_transient $w .
2580 message $w.m -text [mc "
2581 Gitk - a commit viewer for git
2582
@@ -2587,7 +2605,7 @@ proc keys {} {
2605 }
2606 toplevel $w
2607 wm title $w [mc "Gitk key bindings"]
2590 - wm transient $w .
2608 + make_transient $w .
2609 message $w.m -text "
2610 [mc "Gitk key bindings:"]
2611
@@ -3669,7 +3687,7 @@ proc vieweditor {top n title} {
3687
3688 toplevel $top
3689 wm title $top $title
3672 - wm transient $top .
3690 + make_transient $top .
3691
3692 # View name
3693 frame $top.nfr
@@ -7912,7 +7930,7 @@ proc mkpatch {} {
7930 set patchtop $top
7931 catch {destroy $top}
7932 toplevel $top
7915 - wm transient $top .
7933 + make_transient $top .
7934 label $top.title -text [mc "Generate patch"]
7935 grid $top.title - -pady 10
7936 label $top.from -text [mc "From:"]
@@ -7999,7 +8017,7 @@ proc mktag {} {
8017 set mktagtop $top
8018 catch {destroy $top}
8019 toplevel $top
8002 - wm transient $top .
8020 + make_transient $top .
8021 label $top.title -text [mc "Create tag"]
8022 grid $top.title - -pady 10
8023 label $top.id -text [mc "ID:"]
@@ -8102,7 +8120,7 @@ proc writecommit {} {
8120 set wrcomtop $top
8121 catch {destroy $top}
8122 toplevel $top
8105 - wm transient $top .
8123 + make_transient $top .
8124 label $top.title -text [mc "Write commit to file"]
8125 grid $top.title - -pady 10
8126 label $top.id -text [mc "ID:"]
@@ -8159,7 +8177,7 @@ proc mkbranch {} {
8177 set top .makebranch
8178 catch {destroy $top}
8179 toplevel $top
8162 - wm transient $top .
8180 + make_transient $top .
8181 label $top.title -text [mc "Create new branch"]
8182 grid $top.title - -pady 10
8183 label $top.id -text [mc "ID:"]
@@ -8322,7 +8340,7 @@ proc resethead {} {
8340 set confirm_ok 0
8341 set w ".confirmreset"
8342 toplevel $w
8325 - wm transient $w .
8343 + make_transient $w .
8344 wm title $w [mc "Confirm reset"]
8345 message $w.m -text \
8346 [mc "Reset branch %s to %s?" $mainhead [string range $rowmenuid 0 7]] \
@@ -8502,7 +8520,7 @@ proc showrefs {} {
8520 }
8521 toplevel $top
8522 wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
8505 - wm transient $top .
8523 + make_transient $top .
8524 text $top.list -background $bgcolor -foreground $fgcolor \
8525 -selectbackground $selectbgcolor -font mainfont \
8526 -xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -9844,7 +9862,7 @@ proc choosefont {font which} {
9862 font create sample
9863 eval font config sample [font actual $font]
9864 toplevel $top
9847 - wm transient $top $prefstop
9865 + make_transient $top $prefstop
9866 wm title $top [mc "Gitk font chooser"]
9867 label $top.l -textvariable fontparam(which)
9868 pack $top.l -side top
@@ -9961,7 +9979,7 @@ proc doprefs {} {
9979 }
9980 toplevel $top
9981 wm title $top [mc "Gitk preferences"]
9964 - wm transient $top .
9982 + make_transient $top .
9983 label $top.ldisp -text [mc "Commit list display options"]
9984 grid $top.ldisp - -sticky w -pady 10
9985 label $top.spacer -text " "