Issue 72484

Summary: Display Display Device Names
Product: Impress Reporter: davidfraser <davidf>
Component: viewingAssignee: AOO issues mailing list <issues>
Status: CONFIRMED --- QA Contact:
Severity: Trivial    
Priority: P3 CC: clippka, issues, openoffice-bugs
Version: OOo 2.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Issue Type: ENHANCEMENT Latest Confirmation in: ---
Developer Difficulty: ---
Attachments:
Description Flags
Python code for quickly enumerating displays none

Description davidfraser 2006-12-12 08:52:48 UTC
In the new Multimonitor dialog on Windows XP, I get an incorrect number of
monitors listed. This is running on my laptop.

If I start OOo with no external monitor attached, the "Multiple monitors"
section of the Slide Show Settings dialog is disabled as expected, indicating
that the number of monitors detected is 1.

If I start OOo with an external monitor attached, and configured to extend my
Windows desktop onto it, the "Multiple monitors" section is enabled, and shows
the following choices:
  - Monitor 1 (primary)
  - Monitor 2
  - Monitor 3
  - All monitors

Monitor 1 and Monitor 2 both select the laptop display and Monitor 3 selects the
external display.

I have confirmed that the Windows GetSystemMetrics(SM_CMONITORS) returns 1 with
no external display, and 2 with an external display, by calling it using the
Python win32 API.

My suspicion was that the resolution is somehow being used to calculate the
number of displays - my laptop display (primary) has resolution 1280x800 and the
external display 1024x768. However testing with a variety of different
resolutions for each display made no difference.

I tried to look at the code in salframe.cxx but it seems the actual number of
monitors is not calculated there (it just uses it to detect whether there is
more than one monitor)
Comment 1 davidfraser 2006-12-12 09:37:03 UTC
Have tested with some Python code to see what EnumDisplayMonitors returns.
It seems that even with no external monitor attached, 2 monitorinfos are
enumerated, one of which is some kind of virtual monitor.

I'll attach Python code for enumerating the displays as a quick test (this
basically mirrors what is done in vcl/win/source/app/salinfo.cxx)

The results are as follows with no external monitor attached:
Monitor 0
  cbSize: 72
  dwFlags: 1
  hMonitor: 65537
  rcMonitor: {'top': 0L, 'right': 1280L, 'bottom': 800L, 'left': 0L}
  rcWork: {'top': 0L, 'right': 1280L, 'bottom': 736L, 'left': 0L}
  szDevice: \\.\DISPLAY1
Monitor 1
  cbSize: 72
  dwFlags: 0
  hMonitor: 65539
  rcMonitor: {'top': 0L, 'right': 1280L, 'bottom': 800L, 'left': 0L}
  rcWork: {'top': 0L, 'right': 1280L, 'bottom': 800L, 'left': 0L}
  szDevice: \\.\DISPLAYV1

It seems that DISPLAYV1 is a mirror driver, from a brief web search. It may be
possible to ignore these by using MONITORINFOEX and checking the name, but I
admit I'm not really sure what the best thing to do here is...
Comment 2 davidfraser 2006-12-12 09:39:26 UTC
Created attachment 41359 [details]
Python code for quickly enumerating displays
Comment 3 wolframgarten 2006-12-12 09:41:56 UTC
Reassigned.
Comment 4 clippka 2006-12-12 14:30:29 UTC
pl, another one for you
Comment 5 clippka 2006-12-12 14:31:03 UTC
reassigning, second try
Comment 6 philipp.lohmann 2006-12-12 17:04:45 UTC
MONITORINFOEX provides no info about whether a monitor is virtual. Fiddling with
the strings will work for you specific mirroring driver (at least until you
update it :-) ), i don't think that is a viable solution. Taking only the first
monitor on specific coordinates is bound to choose the wrong one on half of the
platforms.

So currently i have no solution to this issue.
Comment 7 davidfraser 2006-12-12 20:27:04 UTC
pl: indeed, it seems that what would really help here is to have the name of the
device.
This can be got from EnumDisplayDevices, by using the DeviceString for the
corresponding DeviceName. This could then be displayed (probably in brackets
alongside the Monitor N) and would help to distinguish between things.
Here with some Python code enumerating my drivers:

for devicenum in range(nMonitors):
    device = win32api.EnumDisplayDevices(None, devicenum)
    print device.DeviceName, ":", device.DeviceString

\\.\DISPLAY1 : ATI MOBILITY RADEON Xpress 200 Series
\\.\DISPLAYV1 : Winvnc video hook driver
\\.\DISPLAY2 : ATI MOBILITY RADEON Xpress 200 Series
Comment 8 davidfraser 2006-12-12 20:37:00 UTC
There's also the StateFlags member of the Display Devices enum, and
DISPLAY_DEVICE_MIRRORING_DRIVER indicates whether its a real driver or a
mirroring  driver :-)
Comment 9 philipp.lohmann 2006-12-13 10:48:20 UTC
And how do Monitors and Display devices correspond ? Do you suggest to use
EnumDisplayDevices instead of EnumDisplayMonitors ?
Comment 10 davidfraser 2006-12-13 19:22:41 UTC
EnumDisplayDevices gives the same DeviceName strings as the device names from
EnumDisplayMonitors (when using MONITORINFOEX). So the full solution in my mind
would be to:

1) look up with EnumDisplayMonitors as is currently being done, but use
MONITORINFOEX instead of MONITORINFO
2) for each device string from Enum, look up the Device information using
EnumDisplayDevices
3) Either don't include devices that are marked as MIRROR devices
(preferential), or bump them to the bottom of the list - they're not actually
display devices (as you can see in MSDN if you search for the description)
4) Include the DeviceString in brackets after the Monitor number to help
identify the graphics adapter

Does that make sense? I can provide Python pseudocode if that helps :-)
Comment 11 philipp.lohmann 2006-12-14 10:50:20 UTC
Makes perfect sense. cl: are you fine with the UI string ? We can leave the
mirror devices out of the enumeration also without UI change. Personally I'm not
sure about the strings; the device name (example: "\\.\DISPLAY1" is the only one
that makes a distinction for most users while the device string (example: "ATI
MOBILITY RADEON Xpress 200 Series") is actually human readable, but probably the
same for most people since they usually have only one graphics adaptor with dual
head.
Comment 12 davidfraser 2006-12-14 11:47:19 UTC
pl: Great! I agree The device name is going to be useless for most people and
once mirroring drivers are excluded it would just be a bit nicer and clearer to
display the device string alongside the monitor number - mainly for those with
dual graphics cards.
Comment 13 clippka 2006-12-14 12:04:50 UTC
cl->david, thank you, nice work!
cl->pl, yes I agree with david, removing the mirror devices is enough.
Displaying the graphic device name may only confuse the average user. But please
make sure that we do not remove useful devices. I can life with some
configurations that display a useless monitor, but I can't life with some
configuration where we now hide crucial monitors
Comment 14 davidfraser 2006-12-15 15:01:22 UTC
On the not ignoring real devices, this is what MSDN says about the mirroring flag:

DISPLAY_DEVICE_MIRRORING_DRIVER 	Represents a pseudo device used to mirror
application drawing for remoting or other purposes. An invisible pseudo monitor
is associated with this device. For example, NetMeeting uses it. Note that
GetSystemMetrics(SM_MONITORS) only accounts for visible display monitors.

The other flag which could be of use in some way is less clear:
DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 	The device is part of the desktop.

http://msdn.microsoft.com/library/en-us/gdi/devcons_6ynm.asp?frame=true

Since we are enumerating monitors using GetSystemMetrics(SM_MONITORS) already
this seems fairly clear

It's great to see this moving forward. Any chance to get it in for OOo 2.2?
Comment 15 philipp.lohmann 2006-12-15 15:46:27 UTC
I can get the enumeration issue in as a bug fix. The UI change depends on other
people, too (e.g. online help update); this may be a bit short for 2.2 feature
freeze (see http://wiki.services.openoffice.org/wiki/OOoRelease22 )
Comment 16 philipp.lohmann 2006-12-22 16:34:42 UTC
pl->cl: fixed the mirroring driver problem and reaction to WM_DISPLAYCHANGE with
issue 72472 in CWS vcl71. I also added a new property "ScreenName" to the
display service. Please take over the application UI change.
Comment 17 clippka 2007-09-12 13:36:35 UTC
retargeted
Comment 18 clippka 2007-10-31 17:04:47 UTC
cl->pl: I implemented this on the user interface but to my surprise it shows me
the name of my graphic card for both devices on windows. Can we do better?
Comment 19 clippka 2007-10-31 17:05:34 UTC
cl->cl: here is the code snipet to test in sd/source/ui/dlg/preset.cxx

			const OUString sScreenName( RTL_CONSTASCII_USTRINGPARAM("ScreenName") );

			const String sPlaceHolder( RTL_CONSTASCII_USTRINGPARAM( "%N" ) );
			for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ )
			{
				OUString sName;
				try
				{
					Reference< XPropertySet > xDisplayInfo( xMultiMon->getByIndex( nDisplay ),
UNO_QUERY_THROW );
					xDisplayInfo->getPropertyValue( sScreenName ) >>= sName;
				}
				catch( Exception& )
				{
					DBG_ERROR("SdStartPresentationDlg::InitMonitorSettings(), exception caught!");
				}

				if( sName.getLength() == 0 )
				{
					String sTmp( nDisplay == nPrimaryIndex ? msPrimaryMonitor : msMonitor );
					const String aNumber( String::CreateFromInt32( nDisplay + 1 ) );
					sTmp.SearchAndReplace( sPlaceHolder, aNumber );
					sName = sTmp;
				}

				maLBMonitor.InsertEntry( sName );
			}
Comment 20 philipp.lohmann 2007-11-22 14:08:59 UTC
appending (%n) to the name now in case of duplicates where %n is the number of
the duplicate. Actually something like (Monitor %n) might be better, but that
would need to be translated. Translation for 2.4 however has already started.

fixed in CWS vcl84
Comment 21 philipp.lohmann 2007-12-03 14:26:18 UTC
please verify in CWS vcl84
Comment 22 clippka 2007-12-11 13:36:45 UTC
This currently gives me the display driver name, at least under windows. I would
prefer the monitor name. On most windows installations this would lead to
"driver name (1)" and "driver name (2)" which is no advantage to the current
"primary monitor" and "monitor 2"
Comment 23 clippka 2007-12-11 13:37:36 UTC
back to pl
Comment 24 philipp.lohmann 2007-12-11 13:42:00 UTC
Ok, will have another look at it
Comment 25 wolframgarten 2008-05-23 15:13:42 UTC
Target changed.
Comment 26 philipp.lohmann 2010-05-26 17:24:12 UTC
There does not seem to be an API on Windows to get the "real" monitor name. The
only thing I get is the MONITORINFOEX you get from EnumDisplayMonitors - and
that's basically the graphics adapter name (on Windows XP as well as Windows 7),
even when the proper monitor driver is installed. I have not found another API
to get the "real" name.

So I fear it's that or stay with the current behavior.
Comment 27 Marcus 2017-05-20 11:08:33 UTC
Reset assigne to the default "issues@openoffice.apache.org".