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
}
@@ -25...
Is there any reason to call tk::PlaceWindow under Linux or MacOS?
If not I'd rather add an if statement so we only call it on Windows.Paul.
--
I checked it on MacOS, and there the consequences of wm transient are
even worse that on Windows, so scrap this patch -- I'll redo it to fix
both cases.Alexander
--
I don't know about MacOS, but in Linux it does seem unnecessary, so:
--- >8 ---
Subject: [PATCH] gitk: Explicitly position popup windows.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>
---
gitk | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)diff --git a/gitk b/gitk
index 1363d20..d72412c 100755
--- a/gitk
+++ b/gitk
@@ -1739,7 +1739,17 @@ proc removehead {id name} {
unset headids($name)
}-proc show_error {w top msg} {
+proc center_window {window origin} {
+ # Let platforms with a real window manager
+ # deal with it on their own
+ if {$::tcl_platform(platform) ne {windows}} return
+
+ # 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 +1758,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 +1768,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 +1787,7 @@ proc confirm_popup {msg {owner .}} {
bind $w <Key-Return> "set confirm_ok 1; destroy $w"
bind $w <Key-space> "set confirm_ok 1; destro...
Any particular reason why you used $tcl_platform(platform) rather than
if {[tk windowingsystem] != "win32"} like we do elsewhere in gitk?Paul.
--
I use Linux at home (using a VirtualBox to compile msysgit when I need
to), and Windows at work.Actually, since last Thursday I also have to use MacOS at work for
some things, but I haven't figured out anything beyond the bareNo partucular reason, I simply copied that from git-gui.
Alexander.
--
Yes, please. I rather like the smart placement in compiz.
--
Do you mean "please add the if statement", i.e. don't call
tk::PlaceWindow under Linux? Like Johannes Sixt, I find your request
ambiguous. :)Paul.
--
Just out of curiosity because I don't use compiz: Did you mean
"Yes, please call tk::PlaceWindow on Linux"
or
"Yes, please add the if statement"
? ;)-- Hannes
--
That one. So PlaceWindow is NOT called.
--
| David Miller | Re: Slow DOWN, please!!! |
| Greg Kroah-Hartman | [PATCH 013/196] Documentation: Replace obsolete "driverfs" with "sysfs". |
| James Bottomley | Re: Integration of SCST in the mainstream Linux kernel |
| Jeff Garzik | Re: [RFC] Heads up on sys_fallocate() |
git: | |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Linus Torvalds | Re: [GIT]: Networking |
| Andrew Morton | Re: [BUG] New Kernel Bugs |
