Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 45095

Summary: [hovering] Marker tooltip position wrong for dual monitor setup
Product: [Eclipse Project] JDT Reporter: Simon Arsenault <simon_arsenault>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: andylarder, bogofilter+eclipse.org, coding, eclipse, keinspam, martin.novak, martinae, n.a.edgar, sean_montgomery, steve
Version: 3.0Keywords: helpwanted
Target Milestone: 3.2 RC1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Bug Depends on: 50257, 72374, 135013    
Bug Blocks:    
Attachments:
Description Flags
Patch to allow valid negative coords for tooltips none

Description Simon Arsenault CLA 2003-10-17 09:46:42 EDT
I have a dual monitor setup where my second monitor is located to the left of 
my primary monitor. My start bar is to the left of my primary monitor and 
always visible.

- open an eclipse window with a java perspective and move that window to the 
second monitor.
- open a java file editor (a java file that contains at least one error so that 
there is an error icon marker is the left margin)
- hover the mouse pointer over the error icon marker and wait for the tool tip 
to be displayed.

==> Notice it is displayed to the left of the error icon marker instead of the 
right. If the editor area is on the left side of the perspective, then you 
can't read the tool tip at all.

Not sure if you are using any tooltip support from SWT, but I've reported a 
dual monitor problem for tooltips in bug 45093.
Comment 1 Dani Megert CLA 2003-10-18 09:45:38 EDT
Tom, you are using dual monitor setup. Can you confirm this behavior?
Comment 2 Tom Hofmann CLA 2003-10-20 02:31:47 EDT
Works for me with 200310150800
- eclipse on left or right monitor
- editor at the left most position (except for perspective bar)
-> error tooltip shows to the right
Comment 3 Dani Megert CLA 2003-10-20 03:23:58 EDT
Simon, can you give more details. Which build? What hardware (graphics driver).
Note: Comment 2 is based on IBM desktop, Win2k
Comment 4 Tom Hofmann CLA 2003-10-20 03:29:05 EDT
cannot reproduce this (or bug 45093) on my W2K machine. I am using a Matrox G450
Dual Head with the same configuration (Taskbar positioned vertically at the left
hand side of the left monitor), but also tried others. 

My video driver:

Provider: Matrox Graphics Inc.
Date: 28.9.2001
Version: 5.72.21.0
Comment 5 Simon Arsenault CLA 2003-10-20 10:12:51 EDT
I'm running Windows 2000. I'm seeing this problem with 2.1.1 and also using 3.0 
M3 (I'm using 2.1.1 now that I'm working the business rule tools). I have two 
graphics card. The NVIDIA Vanta for my primary monitor, and ATI RAGE 128 GL 
PCI  card for my secondary monitor.

The key thing about my setup is that my primary monitor is to my right, and my 
secondary monitor is to my left. So coordinate 0,0 is at the top left of my 
primary monitor (right side monitor). Therefore, all the coordinates on my 
secondary monitor will be negative (because its setup to be on the left side).

I got Christophe to come and see the problem I report in bug 45093. He thinks 
it has to do with negative coordinate handling. Maybe the same applies here?

(Note, my task bar is located to the left of my primary monitor which is my 
right monitor, not the left one).
Comment 6 Tom Hofmann CLA 2003-10-21 03:42:55 EDT
I see. 

Relevant code is in AbstractInformationControlManager::updateLocation, which
does not account for negative offsets.
Comment 7 Dani Megert CLA 2004-05-04 07:56:38 EDT
*** Bug 60792 has been marked as a duplicate of this bug. ***
Comment 8 Dani Megert CLA 2004-05-04 07:57:16 EDT
*** Bug 41187 has been marked as a duplicate of this bug. ***
Comment 9 Simon Arsenault CLA 2004-05-04 09:25:26 EDT
can this get fixed for 3.0? It's makes developing code almost impossible on my 
secondary monitor because I cannot hover over the problem marker to see what 
the problem is.
Comment 10 Dani Megert CLA 2004-05-04 10:00:24 EDT
time permitting
Comment 11 Martin Stein CLA 2004-05-14 09:32:15 EDT
On my dual monitor system with the monitor 1 being the laptop screen and 
monitor 2 a real big monitor I run Eclipse M8 on monitor 2.
The hovering tips above the keywords come up okay, but the tooltips over the 
file name tabs (where the file name and the close button for the file window 
is shown) appear on monitor 1.
Comment 12 Dani Megert CLA 2004-06-11 03:45:16 EDT
*** Bug 66587 has been marked as a duplicate of this bug. ***
Comment 13 Kai-Uwe Maetzel CLA 2004-06-25 11:00:04 EDT
Removing target milestone, no further action for 3.0.
Comment 14 Dani Megert CLA 2004-11-01 13:05:44 EST
*** Bug 64000 has been marked as a duplicate of this bug. ***
Comment 15 Dani Megert CLA 2005-05-17 16:53:29 EDT
*** Bug 95616 has been marked as a duplicate of this bug. ***
Comment 16 Dani Megert CLA 2005-05-25 08:27:37 EDT
*** Bug 96592 has been marked as a duplicate of this bug. ***
Comment 17 Dani Megert CLA 2005-06-01 05:33:18 EDT
*** Bug 82991 has been marked as a duplicate of this bug. ***
Comment 18 Dani Megert CLA 2005-06-01 05:33:22 EDT
*** Bug 97560 has been marked as a duplicate of this bug. ***
Comment 19 Sean Montgomery CLA 2005-08-15 10:17:57 EDT
There's been no changes to this bug (except marking other bugs as duplicates of this one, five, for a total 
of eight) since 2004-06-25 when it was noted that nothing would be done for 3.0.  Now 3.1 is out and 3.2 
is being worked on... what exactly *is* the target milestone for this bug?

I realize that only two people have voted for this bug, but I don't think most people bother to vote.  
Nevertheless this bug really cuts down on the usefulness of using using multiple monitors - I regularly use 
two monitors, each with an Eclipse window (woot! screen real estate!) and this bug really makes it difficult 
to use.

I suggest that more Eclipse developers/committers be outfitted with multiple monitors to make it easier to 
flush these multiscreen bugs out ;-)
Comment 20 Dani Megert CLA 2005-08-15 12:18:18 EDT
Currently it's not on our plan and hence no target milestone. A high quality
patch will be thankfully accepted.
Comment 21 Michael Dänzer CLA 2005-11-23 10:15:16 EST
Have the more or less same behaviour with a Win XP with a Matrox Millenium G550 HD Dual Monitor Setup. Right monitor is primary, left secondary. If I Have Eclipse on the left monitor, marker tooltips are shown to the right, so in most cases only a part of the text is readable, forcing me to switch often to the Problems view
Comment 22 Sean Montgomery CLA 2006-01-05 15:46:25 EST
Eclipse 3.2M4 running on a dual monitor Mac running OS X 10.4.3 no longer shows this bug - the tooltip is positioned correctly (see bug 95616 for description of how the bug originally appeared on this hardware).  Unfortunately the tooltip disappears a fraction of a second after it is displayed.  No, it's not because I moved the mouse :-P  Moving the mouse a little then stopping (leaving it over the same icon) will force the tooltip to reappear, only to disappear a fraction of a sec later.  Repeat ad nauseum.

The tooptip appears (and remains in sight) correctly on the main monitor (as usual).

So it looks like the bug has been *almost* fixed by work performed on 3.2M4, at least on the Mac.  I haven't tested it under Windows - can any Windows folks confirm/deny?

It's soooo close to being fixed now... maybe some nice person will fix the disappearance issue, and this bug can be laid to rest.
Comment 23 Martin Aeschlimann CLA 2006-01-06 05:18:23 EST
Doesn't seem to be fixed on Windows 20060105-0800. The setup:
Primary monitor is labtop monitor, on the right
Secondary monitor is attached monitor, on the left.

Eclipse on the left: Tooltips on the right edge are put to the rigth monitor, should always be on the same monitor as the mouse pointer.

Also very strange: Tooltips always appear over of the mouse pointer (normally always below the mouse pointer). If there's not enough space on top, the tooltip just flickers.
Comment 24 Sean Montgomery CLA 2006-04-02 20:05:53 EDT
3.2M6 on OS X 10.4.5, dual-monitor setup described at https://bugs.eclipse.org/bugs/show_bug.cgi?id=95616#c0.  The primary (right) monitor shows tooltips correctly, the left (secondary) displays the tooltip for just a moment, as mentioned in https://bugs.eclipse.org/bugs/show_bug.cgi?id=45095#c22.

On closer inspection the tooltip on the left monitor is positioned correctly vertically, but not horizontally.  Instead of the left edge of the tooltip being in column one of the text editor it's up against the left edge of the screen.
Comment 25 Sean Montgomery CLA 2006-04-02 22:46:24 EDT
I've been trying out a number of the bugs listed as duplicates of this one on 3.2M6 on OS X 10.4.5 and I'm noticing that the bugs are still there but that they don't all exhibit the same symptoms.  For example, for a secondary on left, primary on right dual monitor setup:

- Quick Diff popups show up to the left of the line numbers on the left monitor instead of to the right like on the right monitor, potentially getting clipped by the left edge of the left monitor if the editor was maximized.  Note that folded-code popups are similar to the Quick Diff popups, in position and clipping.

- Syntax error marker tooltips used to (pre 3.2M4) show up on the left of the icon, potentially getting clipped by the left edge of the left monitor if the editor was maximized.  In 3.2M4 and higher they aren't clipped, but they disappear after appearing for only a fraction of a second.  They also are positioned too far to the left, see comment 24.

I wasn't able to duplicate bug 97560 as I don't have three monitors.  It mentions a tooltip that shows up in the center of the wrong monitor, which doesn't sound like either of the other two cases above.

Perhaps they shouldn't all be grouped into one bug?  

I'm afraid I haven't gone to the source code and checked - have the implementations of these JDT specific tooltips/popups been affected by the architecture changes mentioned in bug 72374? 
Comment 26 Dani Megert CLA 2006-04-03 03:27:05 EDT
>I'm afraid I haven't gone to the source code and checked - have the
>implementations of these JDT specific tooltips/popups been affected by the
>architecture changes mentioned in bug 72374? 
No.
Comment 27 Dani Megert CLA 2006-04-03 03:31:29 EDT
*** Bug 134427 has been marked as a duplicate of this bug. ***
Comment 28 Sean Montgomery CLA 2006-04-03 11:15:52 EDT
Addendum to comment 25:  Bug 134427 is visually different from the other bugs mentioned.  It's the only one I've seen that is horizontally correct on the left monitor.  So that's three distinct visual manifestations of 45095 on OS X.
Comment 29 Sean Montgomery CLA 2006-04-04 01:10:35 EDT
Looking at the 3.2M6 source: Tom is correct in comment 6, AbstractInformationControlManager.updateLocation doesn't account for negative offsets.  That method is passed a rectangle representing the display area (the union of the display areas of all monitors) which is used correctly for the most part.  The mistake is in the final predicate for each of the five anchor types, where the (potentially) updated location is checked to see if it is "useful".  Currently the code checks to see if the location (the lower left coord) of the control is on the main screen, i.e. compared to zero:

return (location.x >= 0 && location.y >= 0);

instead of checking to see if it's in the display area:

return location.x >= displayArea.x && location.y >= displayArea.y;

Changing this predicate in the three places it appears in updateLocation should fix things.  As it is now, if you have a popup or tooltip control show up on the secondary monitor in a dual monitor setup, updateLocation will always return false because of the predicate error above.  That forces the calling method, AbstractInformationControlManager.computeInformationControlLocation(), to iterate through all of its fallback anchors, calling updateLocation on each, which fail in turn.  Once it reaches the last fallback anchor it has no choice but to keep it.  That's what gives rise to the multiple visual issues that bothered me so much: the last javadoc popup fallback anchor is above the correct position, the folded-code popup fallback anchor is to the left of the correct position, etc.

Can somebody else take a look to confirm the three-line fix?  

I didn't get a chance to chase down the weird flashing behavior of the syntax error popups (which also affects TODO popups).  I did see why the syntax error/TODO popups are never offscreen, though.  Unlike the javadoc popup (a BrowserInformationControl) and the folded-coded popup (a SourceViewerInformationControl), the syntax error & TODO popups are DefaultInformationControls.  When setVisible(true) is called on BrowserInformationControl and SourceViewerInformationControl they call Shell.setVisible(true) which, well, makes them visible.

DefaultInformationControl, however, aggregates a PopupDialog, so when setVisible(true) is called on a DefaultInformationControl then PopupDialog.open() is invoked, which calls Window.constrainShellSize(), which moves the errant controls back into the visible screen area.

See, the code from bug 72374 was involved here ;-)

Comment 30 Sean Montgomery CLA 2006-04-04 20:48:04 EDT
Created attachment 37700 [details]
Patch to allow valid negative coords for tooltips

updateLocation no longer returns false for valid negative locations.
Comment 31 Sean Montgomery CLA 2006-04-04 22:21:15 EDT
(In reply to comment #29)
> ... Currently the code checks to see if the location (the lower left
> coord) of the control is on the main screen, i.e. compared to zero:
> ...

Sorry, it was late.  Make that "upper left coord" for the location of the control.  The patch in comment 30 is written accordingly.

The patch is simple (only touches org.eclipse.jface.text.AbstractInformationControlManager) but works on everything I tried.  The AbstractInformationControlManager could still be cleaned up a bit, though:

1) updateLocation: If the control location satifies the anchor criterion this method will in some cases reposition the control if it would extend off the right and/or bottom edge of the display area.  If the control location would extend off the left/top edge of the display area, however, the method simply returns false.  It's not clear why.

2) internalShowInformationControl: Resizes the control if it would extend off the right or bottom edge of the display area. Again, it's not clear why the correction isn't made if the left or top edges are involved.

3) internalShowInformationControl: Enforces a maximal size for the control if requested.  Beyond that, plus the partial fixups mentioned in items 1) & 2) none of the other methods in the class handle the edge case of a control that's larger in width and/or height than the display area.

4) computeInformationControlLocation: If updateLocation returns false for all the anchors this method silently uses the last anchor in the fallback anchor array. It might make more sense to let the calling method (internalShowInformationControl) know that a valid location was not found.

Number 4 isn't really a bug, but the other three items could allow a control to be poorly located under some uncommon circumstances.

These items only apply to IInformationControl implementations like SourceViewerInformationControl or BrowserInformationControl that don't delegate to a PopupDialog like DefaultInformationControl.
Comment 32 Dani Megert CLA 2006-04-05 09:56:55 EDT
I've reviewed and released the patch with the following addition to the copyright notice:

 *     Sean Montgomery, smontgomery@mediaspansoftware.com - https://bugs.eclipse.org/bugs/show_bug.cgi?id=45095

We won't address the other problems reported in comment 31 since - as stated correctly - they will go away once the SourceViewerInformationControl and the BrowserInformationControl use the PopupDialog (see bug 72374 and bug 135013).