[PATCH 2/4] Fix drop-down menus in the git-gui dialogs.

Subsystems: the rest

STALE3708d

5 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH 2/4] Fix drop-down menus in the git-gui dialogs.

From: Eygene Ryabinkin <hidden>
Date: 2016-06-15 22:43:01

If the drop-down menu (for example "Local Branch" from the dialog
activated by the "Branch/Create..." menu item) is chosen with the
left mouse button, then the pointer is moved off the drop-down menu
while the mouse button is still pressed and then the 'Escape' key
is pressed, the main menu will be broken. Next time when you will
try to select any main menu item, the Tcl/Tk interpreter will spawn
an internal error.

Error was fixed by "grab"bing the drop-down menu windows on their
activation. Now all drop-down menus are disappearing once the mouse
button is depressed, no matter what is the current position of the
mouse pointer.

Signed-off-by: Eygene Ryabinkin <redacted>
---
 git-gui/git-gui.sh |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 8157184..1f3ee05 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -2126,6 +2126,7 @@ proc do_create_branch {} {
 		-font font_ui
 	set lbranchm [eval tk_optionMenu $w.from.head_m create_branch_head \
 		$all_heads]
+	bind $lbranchm <Visibility> "grab $lbranchm"
 	$lbranchm configure -font font_ui
 	$w.from.head_m configure -font font_ui
 	grid $w.from.head_r $w.from.head_m -sticky w
@@ -2140,6 +2141,7 @@ proc do_create_branch {} {
 		set tbranchm [eval tk_optionMenu $w.from.tracking_m \
 			create_branch_trackinghead \
 			$all_trackings]
+		bind $tbranchm <Visibility> "grab $tbranchm"
 		$tbranchm configure -font font_ui
 		$w.from.tracking_m configure -font font_ui
 		grid $w.from.tracking_r $w.from.tracking_m -sticky w
@@ -2155,6 +2157,7 @@ proc do_create_branch {} {
 		set tagsm [eval tk_optionMenu $w.from.tag_m \
 			create_branch_tag \
 			$all_tags]
+		bind $tagsm <Visibility> "grab $tagsm"
 		$tagsm configure -font font_ui
 		$w.from.tag_m configure -font font_ui
 		grid $w.from.tag_r $w.from.tag_m -sticky w
@@ -2353,6 +2356,7 @@ proc do_delete_branch {} {
 	set mergedlocalm [eval tk_optionMenu $w.validate.head_m \
 		delete_branch_head \
 		$all_heads]
+	bind $mergedlocalm <Visibility> "grab $mergedlocalm"
 	$mergedlocalm configure -font font_ui
 	$w.validate.head_m configure -font font_ui
 	grid $w.validate.head_r $w.validate.head_m -sticky w
@@ -2367,6 +2371,7 @@ proc do_delete_branch {} {
 		set mergedtrackm [eval tk_optionMenu $w.validate.tracking_m \
 			delete_branch_trackinghead \
 			$all_trackings]
+		bind $mergedtrackm <Visibility> "grab $mergedtrackm"
 		$mergedtrackm configure -font font_ui
 		$w.validate.tracking_m configure -font font_ui
 		grid $w.validate.tracking_r $w.validate.tracking_m -sticky w
@@ -2744,6 +2749,7 @@ proc do_push_anywhere {} {
 			-font font_ui
 		set remmenu [eval tk_optionMenu $w.dest.remote_m push_remote \
 			$all_remotes]
+		bind $remmenu <Visibility> "grab $remmenu"
 		$remmenu configure -font font_ui
 		$w.dest.remote_m configure -font font_ui
 		grid $w.dest.remote_r $w.dest.remote_m -sticky w
@@ -4713,6 +4719,7 @@ proc do_options {} {
 		set fontmenu [eval tk_optionMenu $w.global.$name.family \
 			global_config_new(gui.$font^^family) \
 			$all_fonts]
+		bind $fontmenu <Visibility> "grab $fontmenu"
 		$w.global.$name.family configure -font font_ui
 		$fontmenu configure -font font_ui
 		spinbox $w.global.$name.size \
-- 
1.5.0.3-dirty

Re: [PATCH 2/4] Fix drop-down menus in the git-gui dialogs.

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:03

git-gui patches should be addressed to me, not Paul.

Eygene Ryabinkin [off-list ref] wrote:
If the drop-down menu (for example "Local Branch" from the dialog
activated by the "Branch/Create..." menu item) is chosen with the
left mouse button, then the pointer is moved off the drop-down menu
while the mouse button is still pressed and then the 'Escape' key
is pressed, the main menu will be broken. Next time when you will
try to select any main menu item, the Tcl/Tk interpreter will spawn
an internal error.

Error was fixed by "grab"bing the drop-down menu windows on their
activation. Now all drop-down menus are disappearing once the mouse
button is depressed, no matter what is the current position of the
mouse pointer.
This fix actually horribly breaks on Mac OS X.  The problem
appears to be that the <Visibility> event on that system doesn't
get delivered until after the menu is destroyed, yet I'm getting
a %s of VisibilityUnobscured in the event handler.  Go figure.

So anyway, I cannot apply this patch as-is, because it breaks
my main development system.  I understand and feel your pain,
but you either need to make this binding apply only on your OS,
or find another way to workaround that Tk bug...
quoted hunk
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 8157184..1f3ee05 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -2126,6 +2126,7 @@ proc do_create_branch {} {
 		-font font_ui
 	set lbranchm [eval tk_optionMenu $w.from.head_m create_branch_head \
 		$all_heads]
+	bind $lbranchm <Visibility> "grab $lbranchm"
 	$lbranchm configure -font font_ui
 	$w.from.head_m configure -font font_ui
 	grid $w.from.head_r $w.from.head_m -sticky w
-- 
Shawn.

Re: [PATCH 2/4] Fix drop-down menus in the git-gui dialogs.

From: Eygene Ryabinkin <hidden>
Date: 2016-06-15 22:43:03

Shawn, good day.

Wed, Apr 04, 2007 at 12:37:09PM -0400, Shawn O. Pearce wrote:
git-gui patches should be addressed to me, not Paul.
Yep, I just messed with the mail addresses, since I was doing patches
both for gitk and git-gui. Sorry for it!
quoted
Error was fixed by "grab"bing the drop-down menu windows on their
activation. Now all drop-down menus are disappearing once the mouse
button is depressed, no matter what is the current position of the
mouse pointer.
This fix actually horribly breaks on Mac OS X.  The problem
appears to be that the <Visibility> event on that system doesn't
get delivered until after the menu is destroyed, yet I'm getting
a %s of VisibilityUnobscured in the event handler.  Go figure.

So anyway, I cannot apply this patch as-is, because it breaks
my main development system.  I understand and feel your pain,
but you either need to make this binding apply only on your OS,
or find another way to workaround that Tk bug...
OK, I will try to find the other workaround, but I have no Mac OS
X at hand (they are a bit expensive to me), so I hope you will find
some time to test the new approaches, if I will come up with any.

Thank you!
-- 
Eygene

Re: [PATCH 2/4] Fix drop-down menus in the git-gui dialogs.

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:03

Eygene Ryabinkin [off-list ref] wrote:
Wed, Apr 04, 2007 at 12:37:09PM -0400, Shawn O. Pearce wrote:
quoted
git-gui patches should be addressed to me, not Paul.
Yep, I just messed with the mail addresses, since I was doing patches
both for gitk and git-gui. Sorry for it!
Not a problem, I just wanted to make sure you were aware that they
should come to me, so that you can leave poor paulus' inbox alone.
;-)
 
quoted
So anyway, I cannot apply this patch as-is, because it breaks
my main development system.  I understand and feel your pain,
but you either need to make this binding apply only on your OS,
or find another way to workaround that Tk bug...
OK, I will try to find the other workaround, but I have no Mac OS
X at hand (they are a bit expensive to me), so I hope you will find
some time to test the new approaches, if I will come up with any.
That's fine.  I'd be happy to retest something.  If I understood your
problem description right, this bug doesn't appear on either Cygwin's
Tcl/Tk implementation or my Mac OS X implementation.  Maybe this
is one of those things that we just have to do conditionally per OS.

If that's the case, maybe we should also consider making our own
local variant of tk_optionMenu (a wrapper of sorts) that sets our
font_ui, and does this grab fix on your platform.

-- 
Shawn.

Re: [PATCH 2/4] Fix drop-down menus in the git-gui dialogs.

From: Eygene Ryabinkin <hidden>
Date: 2016-06-15 22:43:03

Shawn, good day.

Thu, Apr 05, 2007 at 11:32:26AM -0400, Shawn O. Pearce wrote:
quoted
OK, I will try to find the other workaround, but I have no Mac OS
X at hand (they are a bit expensive to me), so I hope you will find
some time to test the new approaches, if I will come up with any.
That's fine.  I'd be happy to retest something.  If I understood your
problem description right, this bug doesn't appear on either Cygwin's
Tcl/Tk implementation or my Mac OS X implementation.  Maybe this
is one of those things that we just have to do conditionally per OS.
I was not tested this under Cygwin. But the wrong list behaviour I
got is appearing only in dialogs. I am not getting this in the gitk:
there are many drop-down menus in the main window. All of them are
disappearing once I depress the mouse button no matter where the
cursor is. So this issue can be dialog-specific, but I believe that
the main window and dialog windows are handled by Tcl/Tk on the
same footing. Thought, I do not 100% sure.
If that's the case, maybe we should also consider making our own
local variant of tk_optionMenu (a wrapper of sorts) that sets our
font_ui, and does this grab fix on your platform.
I think this would be the last hope. I will try to understand the
problem a bit deeper first.

Thank you!
-- 
Eygene
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help