Bug 2157 - Context menus flaky near left edge of screen
Summary: Context menus flaky near left edge of screen
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: Trunk
Hardware: PC Mac OS
: Normal major
Target Milestone: ---
Assignee: Bugzilla
URL:
: 3259 6055 ()
Depends on:
Blocks:
 
Reported: 2011-11-22 13:34 UTC by Mikayla Hutchinson [MSFT]
Modified: 2013-02-11 06:11 UTC (History)
7 users (show)

Tags: gtk
Is this bug a regression?: ---
Last known good build:


Attachments
patch resolving the issue (3.21 KB, patch)
2012-06-03 09:22 UTC, Kristian Rietveld (inactive)
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Mikayla Hutchinson [MSFT] 2011-11-22 13:34:51 UTC
When context menus are shown near the left edge of the screen, they immediately hide again. The region in which is occurs seems to be dependent on the size of the menu.

This happens with the GTK+ shipped with Mono 2.10.6, and also with the current tip of the GTK 2.24 branch.

It happens with MD's menus and also with the GtkEntry built-in context menu:
http://screencast.com/t/p6TxaW4P9JwP
Comment 1 Mikayla Hutchinson [MSFT] 2011-11-22 14:52:27 UTC
By left edge, I mean top left corner.
Comment 2 Mikayla Hutchinson [MSFT] 2011-11-22 15:05:56 UTC
I committed a workaround for the MD text editor and treeviews - trigger the context menu on ButtonRelease instead of ButtonPress. This workaround is controlled by a boolean variable so can easily be disabled dependent on GTK+ version when it's fixed upstream.

https://github.com/mono/monodevelop/commit/4553a89c7b1620df016d727afa77fb470a6e5564
Comment 3 Michael Natterer 2012-03-02 08:03:07 UTC
I just tried this in various places, a monodevelop built before you opened
this bug, current git testgtk and some places in gimp, and it never happens
to me. Even an artificial case where the entry is right at the top-left
corner of the screen works just fine.

Is this still happening to you? I'm on Lion here btw.
Comment 4 Mikayla Hutchinson [MSFT] 2012-05-16 16:14:52 UTC
Yes, still reproducible with GtkEntry's menu: http://screencast.com/t/GvTijMVxcII
Comment 5 Kristian Rietveld (inactive) 2012-05-26 06:40:18 UTC
I can reproduce this with MonoDevelop and the Mono framework from May 7.  It is indeed very flaky, because sometimes it does work correctly and sometimes it does not work in the same region.  The immediate popdown is triggered by a button release event. gtk_menu_shell_button_release() does a bunch of checks to see whether the menu should NOT be deactivated, my guess is that one of these checks should succeed but not does.

I already verified the ignore_button_release handling in gtkmenu.c does not seem to be affecting the flaky menus.


Interesting, I cannot reproduce this within a gtk+ test program; so I will do a full build of the Mono framework with debugging symbols on my machine to help in debugging this issue.  (I need such a build anyway to see if it helps in getting a grip on the resolver crashes of which the cause still has not been found).
Comment 6 Kristian Rietveld (inactive) 2012-06-03 09:06:38 UTC
I now understand why I could not reproduce this with a standard GTK+ test program: the bug only appears if you use a theme *different* from the default theme.  When I run the standard GTK+ test program with a different theme, the bug does show up.

The bug appears because an EnterNotify event is erroneously created. This happens because the quartz backend was under the impression that a window is first placed at the top left corner before it is moved to its actual position. The EnterNotify event is only created when the mouse pointer is detected to be inside the area where a window just popped up.

So this explains why the bug only occurs in the top left corner; the window is thought to appear in this area first.

The real problem is that the EnterNotify event should never be emitted, because the window never appears in the top left corner first. What happened is the following:

1. In gtk_window_realize() a new window is created. This triggered the logic in GdkQuartzView updateTrackingRect: to emit an EnterNotify event. 
2. In gtk_window_show(), the correct position is set on the window.

So, in fact, the EnterNotify event is emitted too early, when the real position of the window is not yet known. The EnterNotify logic was introduced in:

commit 66207cf13eb7b3837dd9b37dc31bd93c7ca59dfe
Author: Kristian Rietveld <kris@gtk.org>
Date:   Sun Jan 3 15:27:53 2010 +0100

    Improve enter/motion notify semantics


The proposed solution is to delay the emission of this event to the first time the window size is set. We will rely on the fact that either the windowDidMove: or windowDidResize delegates are called after creating a new window to set the initial size. This seems to be the case.

Patch is forthcoming.
Comment 7 Kristian Rietveld (inactive) 2012-06-03 09:22:19 UTC
Created attachment 2014 [details]
patch resolving the issue

The patch.  After this got some testing we will definitely upstream it.
Comment 8 Kristian Rietveld (inactive) 2012-06-03 09:29:31 UTC
For completeness sake: the differences between the usage of different themes can likely be explained by the fact that the menu items are sized differently. This changes the deactivate behavior in gtk_menu_shell_button_release().
Comment 9 Mikayla Hutchinson [MSFT] 2012-06-06 22:03:27 UTC
Landed in bockbuild, thanks!
Comment 10 Kristian Rietveld (inactive) 2012-06-11 15:12:02 UTC
Upstreamed in gtk-2-24.
Comment 11 Mikayla Hutchinson [MSFT] 2012-06-12 15:19:47 UTC
Thanks, replaced the patch in bockbuild with the git version and confirmed the fix with our theme.
Comment 12 Mikayla Hutchinson [MSFT] 2012-07-10 15:08:19 UTC
*** Bug 6055 has been marked as a duplicate of this bug. ***
Comment 13 Mikayla Hutchinson [MSFT] 2012-07-10 15:08:34 UTC
*** Bug 3259 has been marked as a duplicate of this bug. ***
Comment 14 Jatin 2013-02-11 06:11:28 UTC
We have verified this issue with the latest builds:

MFA 4.6.0.32
MD 4.0 - db3ef976e04673c4dc1cdb3b8901753ef462c429
MT 6.2.0.30

This issue does not exists.