Apache OpenOffice (AOO) Bugzilla – Issue 72484
Display Display Device Names
Last modified: 2017-05-20 11:08:33 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)
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...
Created attachment 41359 [details] Python code for quickly enumerating displays
Reassigned.
pl, another one for you
reassigning, second try
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.
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
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 :-)
And how do Monitors and Display devices correspond ? Do you suggest to use EnumDisplayDevices instead of EnumDisplayMonitors ?
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 :-)
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.
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.
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
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?
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 )
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.
retargeted
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?
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 ); }
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
please verify in CWS vcl84
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"
back to pl
Ok, will have another look at it
Target changed.
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.
Reset assigne to the default "issues@openoffice.apache.org".