Bug 8481 - Debug value tooltips very often appear at the top-left corner of the screen instead of near the element to inspect
Summary: Debug value tooltips very often appear at the top-left corner of the screen i...
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 4.1
Hardware: PC Linux
: Low normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2012-11-17 22:13 UTC by Andres G. Aragoneses
Modified: 2013-02-28 10:52 UTC (History)
1 user (show)

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

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 Andres G. Aragoneses 2012-11-17 22:13:03 UTC
Since some time ago I've noticed this regression in MonoDevelop: when debugging, if I want to inspect the value of a variable|field|parameter|etc, I would put my mouse pointer over it, and the debug value window would appear much farther than where I expected: in the top-left corner of the screen.

This is annoying because it prevents me to go inside and inspect the element more (for example, the values of its properties, if it's an object).

Today I decided to put some debug statements in MonoDevelop's code to figure out what's happening, so I added them this way:

diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs
index f8f0888..3fea44d 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs
@@ -211,18 +218,36 @@ namespace MonoDevelop.SourceEditor
		protected override void OnSizeAllocated (Gdk.Rectangle allocation)
		{
			const int edgeGap = 2;
			int oldY, x, y;
			
 			this.GetPosition (out x, out y);

+			Console.WriteLine ("____________DebugValueWindow OnSizeAllocated x:{0} y:{1}", x, y);
 			oldY = y;
 			
 			Gdk.Rectangle geometry = DesktopService.GetUsableMonitorGeometry (Screen, Screen.GetMonitorAtPoint (x, y));
 			if (allocation.Height <= geometry.Height && y + allocation.Height >= geometry.Y + geometry.Height - edgeGap)
 				y = geometry.Top + (geometry.Height - allocation.Height - edgeGap);
 			if (y < geometry.Top + edgeGap)
 				y = geometry.Top + edgeGap;
 			
-			if (y != oldY)
+			if (y != oldY) {
+				Console.WriteLine ("____________DebugValueWindow OnSizeAllocated going to move to x:{0} y:{1}", x, y);
 				Move (x, y);
+			}
 			
 			base.OnSizeAllocated (allocation);


With this, I noticed two different kind of the behaviours:
a) when the tooltip window is positioned correctly, it would print this kind of thing:
____________DebugValueWindow OnSizeAllocated x:817 y:356
____________DebugValueWindow OnSizeAllocated x:817 y:356
____________DebugValueWindow OnSizeAllocated x:817 y:356
____________DebugValueWindow OnSizeAllocated x:817 y:356

b) However, if the tooltip didn't get positioned correctly (when it appeared in the top-left corner), it would print:
____________DebugValueWindow OnSizeAllocated x:819 y:357
____________DebugValueWindow OnSizeAllocated x:819 y:357
____________DebugValueWindow OnSizeAllocated x:0 y:0
____________DebugValueWindow OnSizeAllocated going to move to x:0 y:2

So then I decided to print the stacktrace when x and y was 0, to find out what caused the launch of OnSizeAllocated with those coordinates:

diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs
index f8f0888..3fea44d 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs
@@ -211,18 +218,36 @@ namespace MonoDevelop.SourceEditor
		protected override void OnSizeAllocated (Gdk.Rectangle allocation)
		{
			const int edgeGap = 2;
			int oldY, x, y;
			
 			this.GetPosition (out x, out y);

+			Console.WriteLine ("____________DebugValueWindow OnSizeAllocated x:{0} y:{1}", x, y);
+			if (x == 0 && y == 0)
+				Console.WriteLine ("____going to print stacktrace:" + Environment.StackTrace);
 			oldY = y;



And this is the result, which doesn't yield lots of info sadly:

   at MonoDevelop.SourceEditor.DebugValueWindow.OnSizeAllocated(Rectangle allocation) in /home/andres1210/Code/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs:line 221
   at Gtk.Widget.sizeallocated_cb(IntPtr widget, IntPtr allocation)
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at MonoDevelop.Ide.IdeApp.Run() in /home/andres1210/Code/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs:line 391
   at MonoDevelop.Ide.IdeStartup.Run(MonoDevelop.Ide.MonoDevelopOptions options) in /home/andres1210/Code/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:line 272
   at MonoDevelop.Ide.IdeStartup.Main(System.String[] args) in /home/andres1210/Code/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:line 507
   at MonoDevelop.Startup.MonoDevelopMain.Main(System.String[] args) in /home/andres1210/Code/monodevelop/main/src/core/MonoDevelop.Startup/MonoDevelop.Startup/MonoDevelopMain.cs:line 16


So I decided to cook a small patch that would just fix the problem for myself, even though it's very hacky and I don't know what I'm doing:


diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs
index f8f0888..3fea44d 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs
@@ -204,6 +209,8 @@ namespace MonoDevelop.SourceEditor
 				sw.WidthRequest = -1;
 			}
 		}
+
+		int? initialX, initialY;
 		
 		protected override void OnSizeAllocated (Gdk.Rectangle allocation)
 		{
@@ -211,18 +218,36 @@ namespace MonoDevelop.SourceEditor
			const int edgeGap = 2;
 			int oldY, x, y;
 			
 			this.GetPosition (out x, out y);
+			bool readjust = false;
+			if (initialX == null || initialY == null) {
+				initialX = x;
+				initialY = y;
+			} else {
+				if (x == 0 && y == 0)
+					readjust = true;
+			}
 			oldY = y;
 			
 			Gdk.Rectangle geometry = DesktopService.GetUsableMonitorGeometry (Screen, Screen.GetMonitorAtPoint (x, y));
 			if (allocation.Height <= geometry.Height && y + allocation.Height >= geometry.Y + geometry.Height - edgeGap)
 				y = geometry.Top + (geometry.Height - allocation.Height - edgeGap);
 			if (y < geometry.Top + edgeGap)
 				y = geometry.Top + edgeGap;
 			
			if (y != oldY)
 				Move (x, y);
 			
 			base.OnSizeAllocated (allocation);
+
+			if (readjust)
+				Move (initialX.Value, initialY.Value);
 		}
 	}


This works, because it readjusts the bad pattern I just saw.

Any help on how to fix this properly will be appreciated. For now I'll just use my patch.
Thanks
Comment 1 Mike Krüger 2012-11-26 04:02:34 UTC
Which version of monodevelop are you using ?
Comment 2 Andres G. Aragoneses 2012-11-26 05:02:36 UTC
What I specified in the bug: master (well, it's labeled as "trunk", you guys should rename that)
Comment 3 Mike Krüger 2012-11-26 05:55:43 UTC
ok which os ?
Comment 4 Andres G. Aragoneses 2012-11-26 05:56:36 UTC
standard Ubuntu 12.10 64bits
Comment 6 Andres G. Aragoneses 2012-11-28 17:52:55 UTC
What do you mean? AFAICT that branch was public, but it is not anymore. It has been even removed from the public github repo.
Comment 7 Andres G. Aragoneses 2013-02-28 07:31:26 UTC
Hey Mike, did you just try to fix this bug? :) https://github.com/mono/monodevelop/commit/620fd4f9781680355d1ee15513c5f154e6ba8b1a 

It didn't fix it for me though :(
Comment 8 Mike Krüger 2013-02-28 09:48:35 UTC
Has nothing to do with that part of the code.
Comment 9 Mike Krüger 2013-02-28 10:14:35 UTC
They should work now :)

Atm I work under ubuntu - a good opportunity to fix that.
Comment 10 Andres G. Aragoneses 2013-02-28 10:52:22 UTC
(In reply to comment #8)
> Has nothing to do with that part of the code.

Oh of course! I should know that given that I cooked a workaround patch that I explained in comment#0 !  I guess I forgot :)

(In reply to comment #9)
> They should work now :)

Of course they do! Thanks so much.

(Sadly I've seen the fix and it's another not-cross-platform solution, meh! you should tell the lanedo guys to fix it ;-) )