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

Previous thread: [PATCH (GITK) v3 0/6] Enhance popup dialogs in gitk. by Alexander Gavrilov on Sunday, November 2, 2008 - 2:59 pm. (11 messages)

Next thread: Git and Media repositories.... by Tim Ansell on Sunday, November 2, 2008 - 3:50 pm. (6 messages)
To: <git@...>
Cc: Paul Mackerras <paulus@...>
Date: Sunday, November 2, 2008 - 2:59 pm

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...

To: Alexander Gavrilov <angavrilov@...>
Cc: <git@...>
Date: Friday, November 7, 2008 - 7:57 am

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.
--

To: Paul Mackerras <paulus@...>
Cc: <git@...>
Date: Tuesday, November 11, 2008 - 7:00 am

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
--

To: Paul Mackerras <paulus@...>
Cc: <git@...>
Date: Sunday, November 9, 2008 - 10:53 am

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...

To: Alexander Gavrilov <angavrilov@...>
Cc: <git@...>
Date: Monday, November 10, 2008 - 7:47 am

Any particular reason why you used $tcl_platform(platform) rather than
if {[tk windowingsystem] != "win32"} like we do elsewhere in gitk?

Paul.
--

To: Paul Mackerras <paulus@...>
Cc: <git@...>
Date: Monday, November 10, 2008 - 8:15 am

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 bare

No partucular reason, I simply copied that from git-gui.

Alexander.
--

To: Paul Mackerras <paulus@...>
Cc: Alexander Gavrilov <angavrilov@...>, <git@...>
Date: Friday, November 7, 2008 - 10:39 am

Yes, please. I rather like the smart placement in compiz.
--

To: Alex Riesen <raa.lkml@...>
Cc: Alexander Gavrilov <angavrilov@...>, <git@...>
Date: Sunday, November 9, 2008 - 7:12 am

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.
--

To: Alex Riesen <raa.lkml@...>
Cc: Alexander Gavrilov <angavrilov@...>, Paul Mackerras <paulus@...>, <git@...>
Date: Friday, November 7, 2008 - 12:37 pm

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

--

To: Johannes Sixt <j.sixt@...>
Cc: Alexander Gavrilov <angavrilov@...>, Paul Mackerras <paulus@...>, <git@...>
Date: Sunday, November 9, 2008 - 6:26 am

That one. So PlaceWindow is NOT called.

--

Previous thread: [PATCH (GITK) v3 0/6] Enhance popup dialogs in gitk. by Alexander Gavrilov on Sunday, November 2, 2008 - 2:59 pm. (11 messages)

Next thread: Git and Media repositories.... by Tim Ansell on Sunday, November 2, 2008 - 3:50 pm. (6 messages)