After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 108328 - Menus open on wrong monitor during keynav
Menus open on wrong monitor during keynav
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: [obsolete] multihead
2.2.x
Other Linux
: High normal
: ---
Assigned To: Erwann Chenede
gtk-bugs
AP2
Depends on:
Blocks:
 
 
Reported: 2003-03-13 17:50 UTC by Markus Berg
Modified: 2011-02-04 16:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot demonstrating the effect (32.95 KB, image/jpeg)
2003-03-13 18:02 UTC, Markus Berg
  Details
fake Xinerama (1.85 KB, patch)
2003-10-31 22:52 UTC, Matthias Clasen
none Details | Review
fake Xinerama redone (2.39 KB, patch)
2003-11-02 22:54 UTC, Matthias Clasen
none Details | Review
further Xinerama menu problems (66.16 KB, image/png)
2003-11-03 00:35 UTC, Matthias Clasen
  Details
proposed patch (3.82 KB, patch)
2003-11-03 21:39 UTC, Matthias Clasen
none Details | Review

Description Markus Berg 2003-03-13 17:50:18 UTC
When the mouse pointer is on a screen other than the active window, the
application menus open on the same screen as the mouse pointer instead of
in the actual application window.
Comment 1 Markus Berg 2003-03-13 18:02:29 UTC
Created attachment 15000 [details]
Screenshot demonstrating the effect
Comment 2 Owen Taylor 2003-04-02 16:10:51 UTC
Does this happen for all applications?

(This is supposed to work fine, there's code in there
to handle this. So it's probably a really trivial
fix if someone wants to look at it.)
Comment 3 Calum Benson 2003-04-03 13:01:19 UTC
Updating status_whiteboard field to reflect A11Y team's assessment 
of accessibility impact.
Comment 4 Owen Taylor 2003-05-20 15:55:32 UTC
I can't reproduce, though I only have Xnest here to
test with. If someone with a real multihead setup
could investigate, I'd appreciate it.
Comment 5 Markus Berg 2003-05-21 15:07:23 UTC
I've reproduced the problem on several Gnome2 apps, but Mozilla 1.3.1
is unaffected.  gtk+1-applications also appear to be unaffected (I
only have one app to test). 
Comment 6 Havoc Pennington 2003-05-21 16:41:56 UTC
Doesn't happen to me with gnome-terminal, xchat, or epiphany 
(with recent cvs build of gtk/gnome)
Comment 7 Narayana Pattipati 2003-05-30 09:59:00 UTC
I have tried it on a Multihead setup(with two heads) on a Solaris box
with sources based on April 1st HEAD. I could not reproduce the
problem. I tried with many applications like gnome-terminal, gedit,
ggv, xchat.
Comment 8 Calum Benson 2003-06-24 13:38:19 UTC
Markus, have you had the chance to try this with a later build?  Are
you still seeing the problem?  If not, think we'll have to close as
unreproducible...
Comment 9 Markus Berg 2003-06-24 21:19:08 UTC
I've reproduced the problem with GTK 2.2.2, RedHat 9, and GNOME 2.3.3
(apt-get from Nyquist's apt repository).

I only have Xinerama at work, so I'll try a CVS build in the morning.
Comment 10 Owen Taylor 2003-06-24 21:29:24 UTC
Markus - more useful might be a step-by-step-by-step description
of how you are reproducing the problem.
Comment 11 Markus Berg 2003-06-24 21:44:20 UTC
Ah...  right:
1. Start Gnome application foo 
2. Move mouse cursor to other screen
3. <alt><tab> to application foo
4. Open File-menu using keyboard shortcut <alt>f
5. The menu opens on the same screen as the cursor

As you can see in the screenshot I attached, the menu opens as close
to the correct screen as possible, and at the correct y-coordinate. 
Changing the window focus behavior (click, mouse, sloppy) makes no
difference.

Could it be due to a buggy ATI driver?  I'm using SWcursor in XF86Config.
Comment 12 Calum Benson 2003-08-07 16:09:37 UTC
Apologies for spam... marking as GNOMEVER2.3 so it appears on the official GNOME
bug list :)
Comment 13 Kjartan Maraas 2003-10-30 13:33:39 UTC
Is this still behaving the same way?
Comment 14 Owen Taylor 2003-10-30 13:55:53 UTC
It can't really plausibly be the video driver; the video
driver isn't involved here.

I still can't reproduce this with Xnest -scrns 2; it will
have to be debugged by someone who *can* reproduce it.
Comment 15 Matthias Clasen 2003-10-31 22:51:47 UTC
Owen, its a Xinerama problem. Using the following patch to establish a
fake 2x2 Xinerama setup allows me to trivially reproduce the problem.
Maybe a fake Xinerama mode would be a good thing to have available via a 
GDK_DEBUG flag, since Xnest +xinerama will probably remain useless
forever... 
Comment 16 Matthias Clasen 2003-10-31 22:52:28 UTC
Created attachment 21105 [details] [review]
fake Xinerama
Comment 17 Matthias Clasen 2003-10-31 23:13:31 UTC
The problem is the following code in gtk_menu_position() which 
gets run after the user function (which in this case is
gtk_menu_item_position_menu() and does the right thing).
The monitor here is the monitor determined from the pointer.
A possible fix might be to determine the monitor to clamp to
from the position returned by the user function.

  if (push_in)
    {
      menu_height = GTK_WIDGET (menu)->requisition.height;

      if (y + menu_height > monitor.y + monitor.height)
	{
	  scroll_offset -= y + menu_height - (monitor.y + monitor.height);
	  y = (monitor.y + monitor.height) - menu_height;
	}
  
      if (y < monitor.y)
	{
	  scroll_offset += monitor.y - y;
	  y = monitor.y;
	}
    }

  /* FIXME: should this be done in the various position_funcs ? */
  x = CLAMP (x, monitor.x, MAX (monitor.x, monitor.x + monitor.width -
requisition.width));
Comment 18 Matthias Clasen 2003-10-31 23:52:47 UTC
Hmm, determining the monitor from the position returned by the user
function doesn't work, since e.g. gtk_menu_item_position_menu() can
return positions which lie outside the monitor we're interested in 
(e.g. for the taller-than-screen menu example in testgtk). Guessing the
monitor from the coverage of the menu is not guaranteed to give the
right answer either. The only correct solution I can see is to have
the user function return the monitor number, by adding an extra gint*
parameter to GtkMenuPositionFunc. The breakage won't be too bad, since
old user functions can just ignore the extra parameter. What do you
think, Owen ?
Comment 19 Matthias Clasen 2003-11-02 22:54:33 UTC
Created attachment 21144 [details] [review]
fake Xinerama redone
Comment 20 Matthias Clasen 2003-11-02 22:55:19 UTC
I've redone the fake Xinerama stuff, putting the currently unused
multihead debug flag to a good use.
Comment 21 Matthias Clasen 2003-11-03 00:34:22 UTC
Playing with GDK_DEBUG=multihead showed another problem of the menu
positioning code in relation to Xinerama (see attached screenshot). If
you put the menu example from testgtk on the lower left faked Xinerama
monitor, far enough towards the bottom of the screen to make the
"Second menu bar" menu pop up towards the top of the screen, you see
that the menu comes up too small. The further down I move the menu
example, the smaller the menu gets. Things work correctly on the upper
left faced Xinerama monitor, so it must be some interaction between
multihead and the menu positioning/scrolling logic.
Comment 22 Matthias Clasen 2003-11-03 00:35:04 UTC
Created attachment 21146 [details]
further Xinerama menu problems
Comment 23 Owen Taylor 2003-11-03 16:55:10 UTC
DEBUG=MULTIHEAD has a precise meaning, it means

 "Print warnings about usages that are unsafe in the
  presence of multiple windows/screens"

E.g., gdk_event_put() with NULL event->any.window
prints a warning for DEBUG=MULTIHEAD.

If you wanted to add DEBUG=XINERAMA or DEBUG=FAKEXINERAMA,
that would be fine. 

We *cannot* add another parameter to GtkMenuPositionFunc;
source compatibility matters as well as binary compatibility.

I think what I'd prefer is some function along the lines of:

 gtk_menu_set_monitor (GtkMenu *menu, int monitor);

or maybe:

 gtk_menu_set_attach_anchor (GtkMenu, GtkAnchorType anchor);

that you'd call from the GtkMenuPositionFunc.
Comment 24 Matthias Clasen 2003-11-03 19:52:37 UTC
Oops, I was grepping for GDK_DEBUG_MULTIHEAD, overlooking the uses of
the form GDK_NOTE(MULTIHEAD,...), so the multihead debug flag is in
fact used and has a precise meaning. Thats fine, I'll introduce
GDK_DEBUG_XINERAMA. I'll try the gtk_menu_set_monitor() approach for
fixing the actual bug.
Comment 25 Matthias Clasen 2003-11-03 21:38:23 UTC
The following patch implements gtk_menu_set_monitor() and uses it to
fix the original problem of this report. I'm going to open a new bug
to track the problems with scrolling menus and vertical Xinerama.
Comment 26 Matthias Clasen 2003-11-03 21:39:19 UTC
Created attachment 21170 [details] [review]
proposed patch
Comment 27 Owen Taylor 2003-11-11 16:42:51 UTC
Patch comments: 

 - It would seem a little clearer to move the 
   first call to gdk_screen_get_monitor_geometry () inside
   the else {} of 'if (menu->position_func)

 - gtk_menu_set_monitor() docs should have 'see'
   to gdk_screen_get_monitor_geometry(), so that someone
   reading it who wonders 'what the heck is a monitor'
   knows where to look.

 - Minor wording quibble:

   "...since these may be beyond the monitor or 
    even screen boundaries for very long menus"

   Would read better as:

   "...since, for very long menus, these coordinates 
    may extend beyond the monitor boundaries or even
    the screen boundaries"

Other than that, looks fine to commit.
Comment 28 Matthias Clasen 2003-11-12 20:53:38 UTC
Committed with your changes.