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

Bug 494749

Summary: [Win32][HiDPI] Issues with Display.getPrimaryMonitor().getBounds()
Product: [Eclipse Project] Platform Reporter: David Gabor <gabor.david>
Component: SWTAssignee: Niraj Modi <niraj.modi>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: arunkumar.thondapu, ericwill, gabor.david, lshanmug, markus.kell.r, niraj.modi, peter, sravankumarl
Version: 4.6Flags: sravankumarl: review+
lshanmug: review+
markus.kell.r: review+
Target Milestone: 4.6 RC4   
Hardware: PC   
OS: Windows All   
See Also: https://git.eclipse.org/r/74182
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=97abb3ddbca0c44d326e5ceda32c2c37dc41d2aa
Whiteboard:
Bug Depends on:    
Bug Blocks: 479614    

Description David Gabor CLA 2016-05-27 08:11:00 EDT
Configuration:
Windows 10
Two 4k (3840x2160) monitors, configured to be horizontally next to eachother.
Main monitor (on the right side) has zoom level set to 200%
Other monitor (on the left had side)  has zoom level set to 250%

The following values are returned by SWT:

Display.getDefault().getBounds(): Rectangle {-1920, 0, 3840, 1080}
Display.getDefault().getPrimaryMonitor().getBounds(): Rectangle {0, 0, 960, 540}
Display.getDefault().getPrimaryMonitor().getClientArea(): Rectangle {0, 0, 960, 520}

The latter two seem to be very low, I believe it should be twice these values.

I am not sure what is required for the first one, width and height might be correct in that case.
Comment 1 David Gabor CLA 2016-05-30 04:19:07 EDT
Present in 4.6RC2 and 4.6RC3
Comment 2 Sravan Kumar Lakkimsetti CLA 2016-05-31 02:46:08 EDT
In Display#getPrimaryMonitor() api we are adjusting the dimensions to points. but the monitor dimensions are already in points we should not do scaledown. 

I did not looked at the impact of this change yet. But should be fixed in 4.6.1 I believe
Comment 3 Niraj Modi CLA 2016-05-31 07:09:08 EDT
Hi David,
Just a quick check, what's the impact of this bug ?
Does it affecting any of Eclipse epp packages ?
Comment 4 David Gabor CLA 2016-05-31 08:08:42 EDT
(In reply to Niraj Modi from comment #3)
> Hi David,
> Just a quick check, what's the impact of this bug ?
> Does it affecting any of Eclipse epp packages ?

I don't know whether it has any impart on the Eclipse epp packages.

In our application the initial dimensions of some pop-up windows are calculated using the dimensions of Display.getDefault().getPrimaryMonitor().getClientArea().
Comment 5 Niraj Modi CLA 2016-06-01 03:47:40 EDT
Investigated this issue further, can see this issue with Snippet120 which uses Display.getPrimaryMonitor().getBounds() method call.

Root-Cause:
After fix for bug 489528 monitor bounds/clientArea remain in Points:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=c53936dceeaaebf51a17a15fd42cf358c3c2feca 

With above patch AutoScaleDown of Monitor bounds/clientArea in Display.getPrimaryMonitor() method is not more needed(which as initially done considering the monitor bounds/clientArea to be in pixels)
Reverting this unnecessary AutoScaleDown operation fixes the problem.
Comment 6 Eclipse Genie CLA 2016-06-01 03:52:34 EDT
New Gerrit change created: https://git.eclipse.org/r/74182
Comment 8 Markus Keller CLA 2016-06-01 10:28:27 EDT
+1 for RC4.

Tested at 100%, 125%, and 200% on Windows 7 using attachment 262161 [details]. Also verified the various Monitor#getClientArea().
Comment 10 Niraj Modi CLA 2016-06-01 10:46:05 EDT
(In reply to Markus Keller from comment #8)
> +1 for RC4.
> 
> Tested at 100%, 125%, and 200% on Windows 7 using attachment 262161 [details]
> [details]. Also verified the various Monitor#getClientArea().

Thanks Markus/Lakshmi/Sravan for you quick reviews, resolving now.
Comment 11 Niraj Modi CLA 2016-06-02 06:27:08 EDT
Verified fix in I20160601-2000 on Win7 using attachment 262161 [details] and Snippet120.java