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

w32_common: implement support for --screen-name #11543

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ZenoArrows
Copy link
Contributor

@ZenoArrows ZenoArrows commented Apr 3, 2023

This PR implements Win32 support for --screen-name and --fs-screen-name. Detection is based on the EDID friendly monitor name that also shows up in advanced display settings control panel.

Implementation is done through the Display Devices API. This does not directly give us an HMONITOR handle, so instead we query the GDI device name in the form of \\.\DISPLAY1. Once the GDI device name has been found we can use EnumDisplayMonitors and GetMonitorInfoW to find the matching HMONITOR.

Parts of the implementation are based on example code found in the documentation.

@ZenoArrows ZenoArrows changed the title w32_common: Implement support for --screen-name. w32_common: implement support for --screen-name Apr 4, 2023
@dyphire
Copy link
Contributor

dyphire commented Apr 5, 2023

Since the EDID friendly monitor name can already be obtained, when it exists should also be applied to the property of display-names, which will provide a more reasonable property for conditional auto profiles.
This is necessary on windows because the display-names that mpv uses are in the form \\.\DISPLAY#, which are completely useless for setting persistent profiles as the numbers can change between boots or display configurations.

@ZenoArrows
Copy link
Contributor Author

Just to confirm I'm understanding correctly, your suggestion is to also expose the EDID display names in the display-names property? That sounds like a good idea to me, I'll implement that.


// Allocate the path and mode arrays
paths = realloc(paths, pathCount * sizeof(DISPLAYCONFIG_PATH_INFO));
modes = realloc(modes, modeCount * sizeof(DISPLAYCONFIG_MODE_INFO));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use talloc here instead.

@kasper93
Copy link
Contributor

kasper93 commented Oct 2, 2023

Please don't duplicate code, look at https://github.com/mpv-player/mpv/blob/01c5346d1ada7185710963628012a5c3dcf1ce74/video/out/win32/displayconfig.c

You can use existing functions and add new ones there if needed.

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

Successfully merging this pull request may close these issues.

4 participants