Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling displays does not work #12

Open
novacto3 opened this issue Jun 15, 2020 · 11 comments
Open

Enabling displays does not work #12

novacto3 opened this issue Jun 15, 2020 · 11 comments
Assignees
Labels

Comments

@novacto3
Copy link

novacto3 commented Jun 15, 2020

Hello,

I tried to use the new version of Your library and it seems that enabling displays stopped working.
The sample throws an exception for "DeviceContext: Enable All" in

var validSetting = display.DisplayScreen.GetPreferredSetting();

because display.DisplayScreen is null. I tried to enable displays in my code via API call but it did not work either.

@falahati
Copy link
Owner

falahati commented Jun 15, 2020

Hey,

This is the master branch, right? Since the latest release and the NuGet package don't have the DisplayScreen class yet.

I will take a look at that. Thanks for reporting.

@falahati falahati self-assigned this Jun 15, 2020
@falahati falahati added the bug label Jun 15, 2020
@novacto3
Copy link
Author

Yes, sorry for not specifying that. Let me know if I can be of any help with this.

@novacto3
Copy link
Author

I checked the v1.3.0.13 release and it does not work either. No exception is raised, but the disabled display is not enabled. In v1.2.0.2 it works fine.

@falahati
Copy link
Owner

falahati commented Jun 15, 2020

What you are trying to do? The DriverContext API is a legacy and might not work as expected. Especially if you are trying to enable a device that was connected to a display source or if it was in a clone group. You simply can't do much.

I suggest using classes inside the DisplayConfig namespace. Find your physical device using the PathDisplayTarget and create a logical desktop corresponding to using the PathDisplaySource class then wire them all together and apply the configuration using the PathInfo class.

I gave more descriptive information in the following issues:
falahati/NvAPIWrapper#8 (comment)
falahati/NvAPIWrapper#26 (comment)

@novacto3
Copy link
Author

I have a display that is "disconnected" (in the terminology of Windows display settings) - it is connected, but disabled. Calling
display.Enable(new WindowsDisplayAPI.DisplaySetting(display.GetPreferedSetting()));
in previous versions of Your library started the display (that is the desired state for me). This functionality is not present in the latest release. Is it a bug or a feature? :-)

@falahati
Copy link
Owner

I don't think I change anything related to this with the last release, give me a moment to check it on my device. So the v1.2 or the v1.1 works but v1.3 fails? What are the values of the unattached display's properties? Does it have a valid display name? ("//DISPLAY1", "//DISPLAY2" ...) And is there an already attached display that has the same name?

@novacto3
Copy link
Author

novacto3 commented Jun 15, 2020

I found the bug. In previous versions (tested on v1.1 and v1.2) the attached displays had names "//DISPLAY1", "//DISPLAY2", "//DISPLAY3" and the unattached display had name "//DISPLAY4". In the new release (v1.3), the attached display names stay the same, but the unattached display has the name "//DISPLAY2" (so there is a duplicity in the naming).

@falahati
Copy link
Owner

falahati commented Jun 15, 2020

Ok, the only change between the version that might be remotely related is the changes to the GetDisplayDevices() method. I will take another look into that. Meanwhile, if you don't need the DPI functionality you can use v1.2 safely.

Thanks for reporting this issue

@nxnxfly
Copy link

nxnxfly commented Dec 16, 2020

[DllImport("user32")]
public static extern Win32Status DisplayConfigGetDeviceInfo(
    ref DisplayConfigSupportVirtualResolution targetSupportVirtualResolution
);

Does it work well?

This is the Windows api:

WINUSERAPI LONG WINAPI DisplayConfigGetDeviceInfo( Inout_ DISPLAYCONFIG_DEVICE_INFO_HEADER* requestPacket);

And How convert DisplayConfigSupportVirtualResolution to DISPLAYCONFIG_DEVICE_INFO_HEADER?

@falahati
Copy link
Owner

falahati commented Dec 17, 2020

Yes, that part is correct. It is not the source of the problem.
You see, DisplayConfigGetDeviceInfo fills data based on the header of the passed struct. So in this case, DisplayConfigSupportVirtualResolution is a struct that is used to get virtual resolution information. What you are seeing in the native signature as DISPLAYCONFIG_DEVICE_INFO_HEADER is actually defined as DisplayConfigDeviceInfoHeader in this library and is included as the header of the DisplayConfigSupportVirtualResolution to notify the native method of the type of the data requested.

Check here:

[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;

And here:
https://github.com/falahati/WindowsDisplayAPI/blob/62e27b37dd1a3aa4e49a36286ae39b5aee7f3671/WindowsDisplayAPI/Native/DisplayConfig/Structures/DisplayConfigDeviceInfoHeader.cs

@madmagic007
Copy link

end of 2024, trying to enable a display on the latest nuget package still does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants