-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add gdigrab display enumeration #36
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
// Copyright (c) The Vignette Authors | ||
// This file is part of SeeShark. | ||
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SeeShark.Interop.Windows | ||
{ | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct DevMode | ||
{ | ||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)] | ||
internal string dmDeviceName; | ||
internal short dmSpecVersion; | ||
internal short dmDriverVersion; | ||
internal short dmSize; | ||
internal short dmDriverExtra; | ||
internal int dmFields; | ||
internal int dmPositionX; | ||
internal int dmPositionY; | ||
internal int dmDisplayOrientation; | ||
internal int dmDisplayFixedOutput; | ||
internal short dmColor; | ||
internal short dmDuplex; | ||
internal short dmYResolution; | ||
internal short dmTTOption; | ||
internal short dmCollate; | ||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)] | ||
internal string dmFormName; | ||
internal short dmLogPixels; | ||
internal int dmBitsPerPel; | ||
internal int dmPelsWidth; | ||
internal int dmPelsHeight; | ||
internal int dmDisplayFlags; | ||
internal int dmDisplayFrequency; | ||
internal int dmICMMethod; | ||
internal int dmICMIntent; | ||
internal int dmMediaType; | ||
internal int dmDitherType; | ||
internal int dmReserved1; | ||
internal int dmReserved2; | ||
internal int dmPanningWidth; | ||
internal int dmPanningHeight; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct Rect | ||
{ | ||
internal int left; | ||
internal int top; | ||
internal int right; | ||
internal int bottom; | ||
} | ||
|
||
internal enum MONITORINFOF : ulong | ||
{ | ||
PRIMARY = 1 | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct MonitorInfoEx | ||
{ | ||
internal uint size; | ||
internal Rect monitor; | ||
internal Rect work; | ||
internal uint flags; | ||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] | ||
internal string deviceName; | ||
} | ||
|
||
internal enum DpiType | ||
{ | ||
Effective, | ||
Angular, | ||
Raw | ||
} | ||
|
||
|
||
[Flags] | ||
internal enum DisplayDeviceStateFlags : int | ||
{ | ||
/// <summary> | ||
/// The device is part of the desktop. | ||
/// </summary> | ||
AttachedToDesktop = 0x1, | ||
MultiDriver = 0x2, | ||
/// <summary>The device is part of the desktop.</summary> | ||
PrimaryDevice = 0x4, | ||
/// <summary>Represents a pseudo device used to mirror application drawing for remoting or other purposes.</summary> | ||
MirroringDriver = 0x8, | ||
/// <summary>The device is VGA compatible.</summary> | ||
VGACompatible = 0x10, | ||
/// <summary>The device is removable; it cannot be the primary display.</summary> | ||
Removable = 0x20, | ||
/// <summary>The device has more display modes than its output devices support.</summary> | ||
ModesPruned = 0x8000000, | ||
Remote = 0x4000000, | ||
Disconnect = 0x2000000 | ||
} | ||
|
||
|
||
#pragma warning disable CA1815 | ||
|
||
// This is never compared in the code, so we can suppress the warning. | ||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] | ||
internal struct DISPLAY_DEVICE | ||
{ | ||
[MarshalAs(UnmanagedType.U4)] | ||
internal int cb; | ||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] | ||
internal string DeviceName; | ||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] | ||
internal string DeviceString; | ||
[MarshalAs(UnmanagedType.U4)] | ||
internal DisplayDeviceStateFlags StateFlags; | ||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] | ||
internal string DeviceID; | ||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] | ||
internal string DeviceKey; | ||
} | ||
#pragma warning restore CA1815 | ||
|
||
internal static partial class User32 | ||
{ | ||
internal delegate bool MonitorEnumDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData); | ||
|
||
[DllImport("user32.dll")] | ||
internal static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData); | ||
|
||
[DllImport("user32.dll")] | ||
internal static extern bool GetMonitorInfo(IntPtr hmon, ref MonitorInfoEx mi); | ||
|
||
#pragma warning disable CA2101 | ||
[DllImport("user32.dll", CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)] | ||
internal static extern bool EnumDisplaySettings(string deviceName, int modeNum, ref DevMode devMode); | ||
|
||
[DllImport("user32.dll", CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)] | ||
internal static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, ref DISPLAY_DEVICE lpDisplayDevice, uint dwFlags); | ||
|
||
#pragma warning restore CA2101 | ||
|
||
[DllImport("Shcore.dll")] | ||
internal static extern int GetDpiForMonitor(IntPtr hmon, DpiType dpiType, out uint dpiX, out uint dpiY); | ||
|
||
[DllImport("Shcore.dll")] | ||
internal static extern int SetProcessDpiAwareness(int awareness); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this comment for?