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

From: "Shawn O. Pearce" <[email-masked]>
Date: Wed, 4 Apr 2007 12:37:09 -0400

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

Eygene Ryabinkin <[email-masked]> 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...

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