<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>1129</bug_id>
          
          <creation_ts>2015-02-09 12:15:12 +0100</creation_ts>
          <short_desc>NEWT MonitorDevice on Windows reports wrong physical size [mm]</short_desc>
          <delta_ts>2019-03-29 17:54:45 +0100</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Newt</product>
          <component>windows</component>
          <version>2.3.0</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          
          
          <cf_type>---</cf_type>
          <cf_scm_refs>70faf070f50ea66fd4cc8f5f586614810f378787
559ecad2a2387ba0aa34ce9e35ca8a2c5a31e655
aba21ccaebb2acf20690a77f5c0914f12d736755</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4583</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-02-09 12:15:12 +0100</bug_when>
    <thetext>On MS Windows, NEWT&apos;s MonitorDevice reports the wrong physical size
in millimeter.

Current code uses EnumDisplayDevices for &apos;displayDeviceName&apos;, i.e. monitor name
and the adapter names, then:

static HDC NewtScreen_createDisplayDC(LPCTSTR displayDeviceName) {
    return CreateDC(&quot;DISPLAY&quot;, displayDeviceName, NULL, NULL);
}

...
    HDC hdc = NewtScreen_createDisplayDC(adapterName);
    int widthmm = GetDeviceCaps(hdc, HORZSIZE);
    int heightmm = GetDeviceCaps(hdc, VERTSIZE);
...

^^ will not return reliable and accurate monitor dimension.

+++

One workaround seems to be using registry EDID information:

&lt;http://ofekshilon.com/2011/11/13/reading-monitor-physical-dimensions-or-getting-the-edid-the-right-way/&gt;

+++

Another API seems to be

&lt;https://msdn.microsoft.com/en-us/library/ff553933(v=vs.85).aspx&gt;:

&quot;To get the physical desktop width and physical monitor width, call QueryDisplayConfig. For each DISPLAYCONFIG_MODE_INFO in the returned pModeInfoArray, check the pModeInfoArray[i].sourceMode.width (and height and position) to reconstruct the bounding rect of all the monitors.&quot;

DISPLAYCONFIG_MODE_INFO:
  &lt;https://msdn.microsoft.com/en-us/library/ff553933(v=vs.85).aspx&gt;

+++</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4587</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-02-16 06:24:49 +0100</bug_when>
    <thetext>70faf070f50ea66fd4cc8f5f586614810f378787

NEWT MonitorDevice&apos;s physical size on Windows must be read via EDID
    
    On Windows, one must read the monitor&apos;s EDID data as stored in the registry,
    no &apos;simple&apos; API works otherwise.
    
    The proper way requires utilizing the Windows Setup-API.
    
    This code is inspired by Ofek Shilon&apos;s code and blog post:
       &lt;http://ofekshilon.com/2014/06/19/reading-specific-monitor-dimensions/&gt;
       See: function &apos;NewtEDID_GetMonitorSizeFromEDIDByModelName&apos;
    
    In contrast to Ofek&apos;s code, function &apos;NewtEDID_GetMonitorSizeFromEDIDByDevice&apos;
    uses the proper link from
         DISPLAY_DEVICE.DeviceID -&gt; SP_DEVICE_INTERFACE_DETAIL_DATA.DevicePath,
    where DISPLAY_DEVICE.DeviceID is the monitor&apos;s enumeration via:
         EnumDisplayDevices(adapterName, monitor_idx, &amp;ddMon, EDD_GET_DEVICE_INTERFACE_NAME);
    Hence the path to the registry-entry is well determined instead of just comparing
    the monitor&apos;s model name.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4588</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-02-17 01:16:06 +0100</bug_when>
    <thetext>commit 559ecad2a2387ba0aa34ce9e35ca8a2c5a31e655:

NEWT MonitorDevice:
    
    - Identify cloned devices (fully covered)
      - MonitorDevice gets &apos;isCloned()&apos; to identify whether
        it is a cloned device, i.e. fully covered by another monitor.
        This detection may happen natively but will always performed
        platform agnostic.
    
      - getMainMonitor(..) now exclude &apos;cloned&apos; devices
    
    - Windows: Iterate-over and identify all adapter:monitor
      - Since we also list cloned monitor,
        we need to iterate over all adapter and all it&apos;s monitor-devices.
      - The native monitor-id is now defined as: ( adapter-idx &lt;&lt; 8 ) | monitor-idx.
    
    - Bug 1129 &lt;- listed under this bug entry for convenience</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4624</commentid>
    <comment_count>3</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-03-09 10:48:35 +0100</bug_when>
    <thetext>aba21ccaebb2acf20690a77f5c0914f12d736755

Fix regression of commit 559ecad2a2387ba0aa34ce9e35ca8a2c5a31e655
IDX_MONITOR_DEVICE_VIEWPORT needed to be updated!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>