Bug 1111 - Code completion on "wrong" monitor
Summary: Code completion on "wrong" monitor
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 2.8 beta 3
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
: 910 1279 1305 1487 ()
Depends on:
Reported: 2011-09-28 14:13 UTC by Jonathan Pryor
Modified: 2011-10-18 15:48 UTC (History)
8 users (show)

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

Left Screen (610.17 KB, image/png)
2011-09-28 14:15 UTC, Jonathan Pryor
Right Screen (459.71 KB, image/png)
2011-09-28 14:16 UTC, Jonathan Pryor
potential fix (1.10 KB, patch)
2011-10-06 13:28 UTC, Jeffrey Stedfast
here's the real patch (3.75 KB, patch)
2011-10-06 13:30 UTC, Jeffrey Stedfast
another attempt (3.91 KB, patch)
2011-10-10 13:52 UTC, Jeffrey Stedfast

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:

Description Jonathan Pryor 2011-09-28 14:13:20 UTC
When running on a multi-monitor setup, with MonoDevelop "full-screen" in the right-hand monitor, the code completion window spans the monitor boundary, with most of it on the left monitor.

This makes it very strange to use code completion.
Comment 1 Jonathan Pryor 2011-09-28 14:15:47 UTC
Created attachment 527 [details]
Left Screen

This is my left screen. Notice that it contains the code completion window on the right edge around the middle of the screen.
Comment 2 Jonathan Pryor 2011-09-28 14:16:48 UTC
Created attachment 528 [details]
Right Screen

The MonoDevelop window proper, on the right screen.

Notice that there is a small bit of the completion window showing around the middle of the left edge. The most that you see is a scroll bar.
Comment 3 Mike Krüger 2011-09-29 01:01:17 UTC
It's related to some of the changes from mhutch. I don't know if they're fixed right now.

@mhutch: Can you take a look at these ?
(btw. where did the old gtk based multi monitor code fail ? It has worked for me)
Comment 4 Scott Blomquist (sblom) 2011-10-05 18:21:27 UTC
If I put my MonoDevelop window on my left monitor--I don't see the completion window at all.

In fact, if MonoDevelop is straddling the seam between my monitors, the completion window continues to appear on the seam until at least 340 pixels or so of MonoDevelop are on the left monitor and then the completion windows vanishes (probably being rendered offscreen even more to the left?).
Comment 5 Mikayla Hutchinson [MSFT] 2011-10-05 18:28:14 UTC
I didn't touch that code, but Jeff made some changes related to monitor geometry.
Comment 6 Jonathan Pryor 2011-10-06 11:37:46 UTC
*** Bug 1305 has been marked as a duplicate of this bug. ***
Comment 7 Jeffrey Stedfast 2011-10-06 13:28:35 UTC
Created attachment 627 [details]
potential fix

Can someone with dual monitors apply this patch and test it out? Does it work? If not, what values are printed to the console?

The reason for the GetUsableMonitorGeometry fix in the first place was to try and prevent the completion list from ending up hidden behind the OS X dock (which happens A LOT when using MonoDevelop on smaller screens like a MacBook Air).
Comment 8 Jeffrey Stedfast 2011-10-06 13:30:03 UTC
Created attachment 628 [details]
here's the real patch

sorry, uploaded the wrong patch
Comment 9 Jeffrey Stedfast 2011-10-06 14:49:20 UTC
*** Bug 910 has been marked as a duplicate of this bug. ***
Comment 10 Scott Blomquist (sblom) 2011-10-06 19:33:22 UTC
Doesn't seem to change anything about completion window position for me.

Console output when I have MonoDevelop on my right window (external display, dock and menu bar live here) with my dock hidden (my usual configuration).

MacPlatform Monitor Geometry: Frame = {X=0,Y=0,Width=1920,Height=1080}, VisibleFrame = {X=0,Y=4,Width=1920,Height=1054}

Console output when I unhide my dock.

MacPlatform Monitor Geometry: Frame = {X=0,Y=0,Width=1920,Height=1080}, VisibleFrame = {X=0,Y=91,Width=1920,Height=967}

Console output when I put MonoDevelop more than about 1/3 on my left display (laptop's internal display, dock and menu bar on external display to the right).

MacPlatform Monitor Geometry: Frame = {X=-1680,Y=30,Width=1680,Height=1050}, VisibleFrame = {X=-1680,Y=30,Width=1680,Height=1050}
Comment 11 Mikayla Hutchinson [MSFT] 2011-10-06 20:15:38 UTC
*** Bug 1279 has been marked as a duplicate of this bug. ***
Comment 12 Jeffrey Stedfast 2011-10-10 13:52:52 UTC
Created attachment 662 [details]
another attempt

How about this patch? Does this work any better?
Comment 13 Scott Blomquist (sblom) 2011-10-10 15:16:13 UTC
New patch didn't affect my experience, either. My particular problem is with X, not with Y, and it doesn't involve the dock at all.

Meanwhile, I've traced the culprit to logic that's sprinkled into about a dozen places. It often takes the form:

    if (x + w >= geometry.Right)
        x = geometry.Right - w;

It looks to me like that code is trying to handle the case where the flop-down would overrun the right edge of a display. I can confirm that entirely commenting out instances like the example above causes my dropdowns to appear in mostly sane places (sometimes overrunning the right edge of a display).

I've neglected many other cases of similar logic that probably also need fixed.

You can take a look at my changes here: https://github.com/sblom/monodevelop/commit/f90b0465fb80db8d34fa9a29079f228897a53426

I don't understand this code, or its history, well enough to feel confident that my changes don't have unintended side effects, especially on platforms other than Mac. But I've tested that my changes fully resolved my specific problems in both multimon (either left or right display) and singlemon cases.
Comment 14 Jeffrey Stedfast 2011-10-10 15:34:51 UTC
Thanks Scott. I was afraid it might be something like that. I was hoping that the fix would be limited to my GetUsableMonitorGeometry() methods since supposedly this wasn't an issue when it just used GetMonitorGeometry() (which afaict just returned the 'frame' value).
Comment 15 Jeffrey Stedfast 2011-10-10 16:59:58 UTC
It's starting to look like the code to position these windows could never have worked. Are people *sure* it worked on MonoDevelop 2.6 and older?
Comment 16 Jeffrey Stedfast 2011-10-10 17:28:17 UTC
since most of the code does:

if (x + w > geometry.Right)
    x = geometry.Right - w;

I made the code get the monitor at x + w rather than at x.

For the places that do:

if (x + w > geometry.Right)
    x = geometry.Right - w;
if (x < geometry.Left)
   x = geometry.Left;

I changed the code to get the geometry at x and at x+w and used the appropriate geometry in both tests.
Comment 17 Jeffrey Stedfast 2011-10-10 17:30:52 UTC
That being said, the positioning logic all throughout MonoDevelop makes a lot of incorrect assumptions in the multi-monitor case and will require a MonoDevelop author to fix them (i.e. not me)
Comment 18 Mikayla Hutchinson [MSFT] 2011-10-13 21:29:04 UTC
*** Bug 1487 has been marked as a duplicate of this bug. ***
Comment 19 Jeffrey Stedfast 2011-10-18 11:52:09 UTC
Fixed in git master.

The problem was that the Gdk.Rectangles I was returning in GetUsableMonitorGeometry were relative to monitor 0 instead of being absolute offsets.

So basically, if Monitor1 is to the left of Monitor0, this bug would occur.
Comment 20 Ian 2011-10-18 12:56:40 UTC
How do we get the newest build?
Comment 21 Jeffrey Stedfast 2011-10-18 15:48:29 UTC
Ian: I suspect we'll be making a 2.8.2 release soon. Until then, I've uploaded a build to http://files.xamarin.com/~jeff/MonoDevelop-2.8.1js1.dmg