From 874dbe3ca9c75e400f6498645b4808d268ba53da Mon Sep 17 00:00:00 2001 From: Martin Steiger Date: Wed, 21 May 2014 21:36:15 +0200 Subject: [PATCH 1/5] Added Win32 Monitor Configuration API and demo --- CHANGES.md | 1 + .../sun/jna/contrib/demo/MonitorInfoDemo.java | 204 +++++++ .../com/sun/jna/platform/EnumConverter.java | 62 +++ .../src/com/sun/jna/platform/EnumUtils.java | 105 ++++ .../src/com/sun/jna/platform/win32/Dxva2.java | 509 ++++++++++++++++++ .../com/sun/jna/platform/win32/FlagEnum.java | 30 ++ .../HighLevelMonitorConfigurationAPI.java | 436 +++++++++++++++ .../LowLevelMonitorConfigurationAPI.java | 116 ++++ .../win32/PhysicalMonitorEnumerationAPI.java | 67 +++ .../com/sun/jna/platform/win32/User32.java | 95 +++- .../com/sun/jna/platform/win32/WinUser.java | 191 +++++++ 11 files changed, 1814 insertions(+), 2 deletions(-) create mode 100644 contrib/monitordemo/src/com/sun/jna/contrib/demo/MonitorInfoDemo.java create mode 100644 contrib/platform/src/com/sun/jna/platform/EnumConverter.java create mode 100644 contrib/platform/src/com/sun/jna/platform/EnumUtils.java create mode 100644 contrib/platform/src/com/sun/jna/platform/win32/Dxva2.java create mode 100644 contrib/platform/src/com/sun/jna/platform/win32/FlagEnum.java create mode 100644 contrib/platform/src/com/sun/jna/platform/win32/HighLevelMonitorConfigurationAPI.java create mode 100644 contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java create mode 100644 contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java diff --git a/CHANGES.md b/CHANGES.md index 3368d154d7..cc3a2c2a03 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ Features -------- * Updated AIX natives and build - [@twall](https://github.com/twall). * [#290](https://github.com/twall/jna/pull/290): Improved the stacktrace for the exceptions thrown by `com.sun.jna.Structure` - [@ebourg](https://github.com/ebourg). +* Added Win32 Monitor Configuration API Bug Fixes --------- diff --git a/contrib/monitordemo/src/com/sun/jna/contrib/demo/MonitorInfoDemo.java b/contrib/monitordemo/src/com/sun/jna/contrib/demo/MonitorInfoDemo.java new file mode 100644 index 0000000000..2462acd7d4 --- /dev/null +++ b/contrib/monitordemo/src/com/sun/jna/contrib/demo/MonitorInfoDemo.java @@ -0,0 +1,204 @@ +/* + * Copyright 2014 Martin Steiger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.jna.contrib.demo; + +import com.sun.jna.Memory; +import com.sun.jna.platform.EnumUtils; +import com.sun.jna.platform.win32.Dxva2; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_COLOR_TEMPERATURE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_DISPLAY_TECHNOLOGY_TYPE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_DRIVE_TYPE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_GAIN_TYPE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_POSITION_TYPE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_SIZE_TYPE; +import com.sun.jna.platform.win32.LowLevelMonitorConfigurationAPI.MC_TIMING_REPORT; +import com.sun.jna.platform.win32.PhysicalMonitorEnumerationAPI.PHYSICAL_MONITOR; +import com.sun.jna.platform.win32.User32; +import com.sun.jna.platform.win32.WTypes.LPSTR; +import com.sun.jna.platform.win32.WinDef.DWORD; +import com.sun.jna.platform.win32.WinDef.DWORDByReference; +import com.sun.jna.platform.win32.WinDef.HDC; +import com.sun.jna.platform.win32.WinDef.LPARAM; +import com.sun.jna.platform.win32.WinDef.RECT; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.platform.win32.WinUser; +import com.sun.jna.platform.win32.WinUser.HMONITOR; +import com.sun.jna.platform.win32.WinUser.MONITORENUMPROC; +import com.sun.jna.platform.win32.WinUser.MONITORINFOEX; + +/** + * A small demo that tests the Win32 monitor API. + * All available physical and virtual monitors are enumerated and + * their capabilities printed to stdout + * @author Martin Steiger + */ +public class MonitorInfoDemo +{ + /** + * @param args (ignored) + */ + public static void main(String[] args) + { + System.out.println("Installed Physical Monitors: " + User32.INSTANCE.GetSystemMetrics(WinUser.SM_CMONITORS)); + + User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() { + + @Override + public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam) + { + enumerate(hMonitor); + + return 1; + } + + }, new LPARAM(0)); + } + + static void enumerate(HMONITOR hMonitor) + { + System.out.println("Found HMONITOR: " + hMonitor.getPointer().toString()); + + MONITORINFOEX info = new MONITORINFOEX(); + User32.INSTANCE.GetMonitorInfo(hMonitor, info); + System.out.println("Screen " + info.rcMonitor); + System.out.println("Work area " + info.rcWork); + boolean isPrimary = (info.dwFlags & WinUser.MONITORINFOF_PRIMARY) != 0; + System.out.println("Primary? " + (isPrimary ? "yes" : "no")); + System.out.println("Device " + new String(info.szDevice)); + + DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference(); + Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors); + int monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue(); + + System.out.println("HMONITOR is linked to " + monitorCount + " physical monitors"); + + PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount]; + Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons); + + for (int i = 0; i < monitorCount; i++) + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; + System.out.println("Monitor " + i + " - " + new String(physMons[i].szPhysicalMonitorDescription)); + + enumeratePhysicalMonitor(hPhysicalMonitor); + } + } + + /** + * @param hPhysicalMonitor + */ + private static void enumeratePhysicalMonitor(HANDLE hPhysicalMonitor) + { + MC_DISPLAY_TECHNOLOGY_TYPE.ByReference techType = new MC_DISPLAY_TECHNOLOGY_TYPE.ByReference(); + Dxva2.INSTANCE.GetMonitorTechnologyType(hPhysicalMonitor, techType); + System.out.println("TECHTYPE: " + techType.getValue()); + + DWORDByReference temps = new DWORDByReference(); + DWORDByReference caps = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorCapabilities(hPhysicalMonitor, caps, temps); + System.out.println("CAPS " + EnumUtils.setFromInteger(caps.getValue().intValue(), HighLevelMonitorConfigurationAPI.MC_CAPS.class)); + System.out.println("Temps " + temps.getValue()); + + // Brightness + DWORDByReference pdwMinimumBrightness = new DWORDByReference(); + DWORDByReference pdwCurrentBrightness = new DWORDByReference(); + DWORDByReference pdwMaximumBrightness = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorBrightness(hPhysicalMonitor, pdwMinimumBrightness, pdwCurrentBrightness, pdwMaximumBrightness); + + System.out.println("Brightness Min: " + pdwMinimumBrightness.getValue()); + System.out.println("Brightness Current: " + pdwCurrentBrightness.getValue()); + System.out.println("Brightness Max: " + pdwMaximumBrightness.getValue()); + + // Contrast + DWORDByReference pdwMinimumContrast = new DWORDByReference(); + DWORDByReference pdwCurrentContrast = new DWORDByReference(); + DWORDByReference pdwMaximumContrast = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorContrast(hPhysicalMonitor, pdwMinimumContrast, pdwCurrentContrast, pdwMaximumContrast); + + System.out.println("Contrast Min: " + pdwMinimumContrast.getValue()); + System.out.println("Contrast Current: " + pdwCurrentContrast.getValue()); + System.out.println("Contrast Max: " + pdwMaximumContrast.getValue()); + + // Temperature + MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature = new MC_COLOR_TEMPERATURE.ByReference(); + Dxva2.INSTANCE.GetMonitorColorTemperature(hPhysicalMonitor, pctCurrentColorTemperature); + System.out.println("Current Temp: " + pctCurrentColorTemperature.getValue()); + + // Capabilities string + DWORDByReference pdwCapabilitiesStringLengthInCharacters = new DWORDByReference(); + Dxva2.INSTANCE.GetCapabilitiesStringLength(hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters); + DWORD capStrLen = pdwCapabilitiesStringLengthInCharacters.getValue(); + + LPSTR pszASCIICapabilitiesString = new LPSTR(new Memory(capStrLen.intValue())); + Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen); + System.out.println("Cap-String:" + new String(pszASCIICapabilitiesString.getPointer().getString(0))); + + // Position + MC_POSITION_TYPE ptPositionType = MC_POSITION_TYPE.MC_HORIZONTAL_POSITION; + DWORDByReference pdwMinimumPosition = new DWORDByReference(); + DWORDByReference pdwCurrentPosition = new DWORDByReference(); + DWORDByReference pdwMaximumPosition = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorDisplayAreaPosition(hPhysicalMonitor, ptPositionType, pdwMinimumPosition, pdwCurrentPosition, pdwMaximumPosition); + + System.out.println("Position (horz) Min: " + pdwMinimumPosition.getValue()); + System.out.println("Position (horz) Current: " + pdwCurrentPosition.getValue()); + System.out.println("Position (horz) Max: " + pdwMaximumPosition.getValue()); + + // Size + MC_SIZE_TYPE ptSizeType = MC_SIZE_TYPE.MC_WIDTH; + DWORDByReference pdwMinimumSize = new DWORDByReference(); + DWORDByReference pdwCurrentSize = new DWORDByReference(); + DWORDByReference pdwMaximumSize = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorDisplayAreaSize(hPhysicalMonitor, ptSizeType, pdwMinimumSize, pdwCurrentSize, pdwMaximumSize); + + System.out.println("Width Min: " + pdwMinimumSize.getValue()); + System.out.println("Width Current: " + pdwCurrentSize.getValue()); + System.out.println("Width Max: " + pdwMaximumSize.getValue()); + + // Gain + MC_GAIN_TYPE ptGainType = MC_GAIN_TYPE.MC_RED_GAIN; + DWORDByReference pdwMinimumGain = new DWORDByReference(); + DWORDByReference pdwCurrentGain = new DWORDByReference(); + DWORDByReference pdwMaximumGain = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorRedGreenOrBlueGain(hPhysicalMonitor, ptGainType, pdwMinimumGain, pdwCurrentGain, pdwMaximumGain); + + System.out.println("Red Gain Min: " + pdwMinimumSize.getValue()); + System.out.println("Red Gain Current: " + pdwCurrentSize.getValue()); + System.out.println("Red Gain Max: " + pdwMaximumSize.getValue()); + + // Drive + MC_DRIVE_TYPE ptDriveType = MC_DRIVE_TYPE.MC_RED_DRIVE; + DWORDByReference pdwMinimumDrive = new DWORDByReference(); + DWORDByReference pdwCurrentDrive = new DWORDByReference(); + DWORDByReference pdwMaximumDrive = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorRedGreenOrBlueDrive(hPhysicalMonitor, ptDriveType, pdwMinimumDrive, pdwCurrentDrive, pdwMaximumDrive); + + System.out.println("Red Drive Min: " + pdwMinimumSize.getValue()); + System.out.println("Red Drive Current: " + pdwCurrentSize.getValue()); + System.out.println("Red Drive Max: " + pdwMaximumSize.getValue()); + + // Timing Report + MC_TIMING_REPORT pmtrMonitorTimingReport = new MC_TIMING_REPORT(); + Dxva2.INSTANCE.GetTimingReport(hPhysicalMonitor, pmtrMonitorTimingReport); + System.out.println("HorizontalFrequencyInHZ " + pmtrMonitorTimingReport.dwHorizontalFrequencyInHZ); + System.out.println("VerticalFrequencyInHZ " + pmtrMonitorTimingReport.dwVerticalFrequencyInHZ); + + System.out.println("--------------------------------------"); + } + +} diff --git a/contrib/platform/src/com/sun/jna/platform/EnumConverter.java b/contrib/platform/src/com/sun/jna/platform/EnumConverter.java new file mode 100644 index 0000000000..d27ae2cba1 --- /dev/null +++ b/contrib/platform/src/com/sun/jna/platform/EnumConverter.java @@ -0,0 +1,62 @@ +/* + * Copyright 2014 Martin Steiger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.jna.platform; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; + +/** + * A {@link TypeConverter} that maps an integer enum value to + * an actual Java enum. + * @param the enum type + * @author Martin Steiger + */ +public class EnumConverter> implements TypeConverter { + + private final Class clazz; + + /** + * @param clazz the enum class + */ + public EnumConverter(Class clazz) + { + this.clazz = clazz; + } + + @Override + public T fromNative(Object input, FromNativeContext context) { + Integer i = (Integer) input; + + T[] vals = clazz.getEnumConstants(); + return vals[i]; + } + + @Override + public Integer toNative(Object input, ToNativeContext context) { + T t = clazz.cast(input); + + return Integer.valueOf(t.ordinal()); + } + + @Override + public Class nativeType() { + return Integer.class; + } +} + + diff --git a/contrib/platform/src/com/sun/jna/platform/EnumUtils.java b/contrib/platform/src/com/sun/jna/platform/EnumUtils.java new file mode 100644 index 0000000000..4eec551ecd --- /dev/null +++ b/contrib/platform/src/com/sun/jna/platform/EnumUtils.java @@ -0,0 +1,105 @@ +/* + * Copyright 2014 Martin Steiger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.jna.platform; + +import java.util.HashSet; +import java.util.Set; + +import com.sun.jna.platform.win32.FlagEnum; + +/** + * Several helper methods to convert integer flag (sets) + * into enum (sets) + * @author Martin Steiger + */ +public class EnumUtils +{ + /** + * Uninitialized integer flag + */ + public static final int UNINITIALIZED = -1; + + /** + * @param val the enum + * @return the index of the enum in the enum list + */ + public static > int toInteger(E val) + { + @SuppressWarnings("unchecked") + E[] vals = (E[]) val.getClass().getEnumConstants(); + + for (int idx = 0; idx < vals.length; idx++) + { + if (vals[idx] == val) + return idx; + } + + throw new IllegalArgumentException(); + } + + /** + * @param idx the enum index + * @param clazz the enum class + * @return the enum at position idx + */ + public static > E fromInteger(int idx, Class clazz) + { + if (idx == UNINITIALIZED) + return null; + + E[] vals = clazz.getEnumConstants(); + return vals[idx]; + } + + /** + * @param flags the ORed flags + * @param clazz the enum class + * @return the representing set + */ + public static Set setFromInteger(int flags, Class clazz) + { + T[] vals = clazz.getEnumConstants(); + Set result = new HashSet(); + + for (T val : vals) + { + if ((flags & val.getFlag()) != 0) + { + result.add(val); + } + } + + return result; + } + + /** + * @param set the set to convert + * @return the flags combined into an integer + */ + public static int setToInteger(Set set) { + int sum = 0; + + for (T t : set) + { + sum |= t.getFlag(); + } + + return sum; + } +} + + diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Dxva2.java b/contrib/platform/src/com/sun/jna/platform/win32/Dxva2.java new file mode 100644 index 0000000000..ae8a0399af --- /dev/null +++ b/contrib/platform/src/com/sun/jna/platform/win32/Dxva2.java @@ -0,0 +1,509 @@ +/* + * Copyright 2014 Martin Steiger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.jna.platform.win32; + +import java.util.HashMap; + +import com.sun.jna.DefaultTypeMapper; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.platform.EnumConverter; +import com.sun.jna.platform.win32.WTypes.LPSTR; +import com.sun.jna.platform.win32.WinDef.BOOL; +import com.sun.jna.platform.win32.WinDef.BYTE; +import com.sun.jna.platform.win32.WinDef.DWORD; +import com.sun.jna.platform.win32.WinDef.DWORDByReference; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.platform.win32.WinUser.HMONITOR; +import com.sun.jna.win32.StdCallLibrary; + +/** + * A port of dxva2.dll + * @author Martin Steiger + */ +public interface Dxva2 extends StdCallLibrary, PhysicalMonitorEnumerationAPI, HighLevelMonitorConfigurationAPI, LowLevelMonitorConfigurationAPI +{ + /** + * The only instance of the library + */ + Dxva2 INSTANCE = (Dxva2) Native.loadLibrary("Dxva2", Dxva2.class, new HashMap() + { + private static final long serialVersionUID = -1987971664975780480L; + + { + put(Library.OPTION_TYPE_MAPPER, new DefaultTypeMapper() + { + { + addTypeConverter(MC_POSITION_TYPE.class, new EnumConverter<>(MC_POSITION_TYPE.class)); + addTypeConverter(MC_SIZE_TYPE.class, new EnumConverter<>(MC_SIZE_TYPE.class)); + addTypeConverter(MC_GAIN_TYPE.class, new EnumConverter<>(MC_GAIN_TYPE.class)); + addTypeConverter(MC_DRIVE_TYPE.class, new EnumConverter<>(MC_DRIVE_TYPE.class)); + } + }); + } + }); + + + + /****************************************************************************** + Monitor capability functions + ******************************************************************************/ + /** + * Retrieves the configuration capabilities of a monitor. Call this function to find out which high-level + * monitor configuration functions are supported by the monitor. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call + * {@link #GetPhysicalMonitorsFromHMONITOR} + * @param pdwMonitorCapabilities Receives a bitwise OR of capabilities flags. (MC_CAPS_*) + * @param pdwSupportedColorTemperatures Receives a bitwise OR of color temperature flags. + * (MC_SUPPORTED_COLOR_TEMPERATURE_*) + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is + * FALSE. To get extended error information, call GetLastError. + *

+ * The function fails if the monitor does not support DDC/CI. + */ + BOOL GetMonitorCapabilities(HANDLE hMonitor, DWORDByReference pdwMonitorCapabilities, DWORDByReference pdwSupportedColorTemperatures); + + /****************************************************************************** + Monitor setting persistence functions + ******************************************************************************/ + + /** + * Saves the current monitor settings to the display's nonvolatile storage. + *

+ * This function takes about 200 milliseconds to return. + * This high-level function is identical to the low-level function SaveCurrentSettings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SaveCurrentMonitorSettings(HANDLE hMonitor); + + /****************************************************************************** + Monitor meta-data functions + ******************************************************************************/ + + /** + * Retrieves the type of technology used by a monitor. + * This function does not support every display technology. If a monitor uses a display technology that is + * supported by this function, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_TECHNOLOGY_TYPE + * flag. If that flag is absent, the GetMonitorTechnologyType function fails. + * Some monitor technologies do not support certain monitor configuration functions. For example, + * the DegaussMonitor function is supported only for cathode ray tube (CRT) monitors. To find out whether a + * specific function is supported, call GetMonitorCapabilities. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param pdtyDisplayTechnologyType Receives the technology type as defined in {@link HighLevelMonitorConfigurationAPI.MC_DISPLAY_TECHNOLOGY_TYPE}. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetMonitorTechnologyType(HANDLE hMonitor, MC_DISPLAY_TECHNOLOGY_TYPE.ByReference pdtyDisplayTechnologyType); + + /****************************************************************************** + Monitor image calibration functions + ******************************************************************************/ + + /** + * Retrieves a monitor's minimum, maximum, and current brightness settings. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_BRIGHTNESS flag. + * This function takes about 40 milliseconds to return. The brightness setting is a continuous monitor setting. + * @param hMonitor Handle to a physical monitor + * @param pdwMinimumBrightness Receives the monitor's minimum brightness. + * @param pdwCurrentBrightness Receives the monitor's current brightness. + * @param pdwMaximumBrightness Receives the monitor's maximum brightness. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetMonitorBrightness(HANDLE hMonitor, DWORDByReference pdwMinimumBrightness, + DWORDByReference pdwCurrentBrightness, DWORDByReference pdwMaximumBrightness); + + /** + * Retrieves a monitor's minimum, maximum, and current contrast settings. + * @param hMonitor Handle to a physical monitor. + * @param pdwMinimumContrast Receives the monitor's minimum contrast. + * @param pdwCurrentContrast Receives the monitor's current contrast. + * @param pdwMaximumContrast Receives the monitor's maximum contrast. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetMonitorContrast(HANDLE hMonitor, DWORDByReference pdwMinimumContrast, DWORDByReference pdwCurrentContrast, + DWORDByReference pdwMaximumContrast); + + /** + * Retrieves a monitor's current color temperature. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_COLOR_TEMPERATURE flag. + * This function takes between 0 and 80 milliseconds to return. + * @param hMonitor Handle to a physical monitor. + * @param pctCurrentColorTemperature Receives the monitor's current color temperature. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature); + + /** + * Retrieves a monitor's red, green, or blue drive value. + *

+ * Drive settings are generally used to adjust the monitor's white point. Drive and black level are different + * names for the same monitor setting. If this function is supported, the GetMonitorCapabilities function returns + * the MC_CAPS_RED_GREEN_BLUE_DRIVE flag. + * @param hMonitor Handle to a physical monitor. + * @param dtDriveType A member of the MC_DRIVE_TYPE enumeration, specifying whether to retrieve the red, green, or blue drive value. + * @param pdwMinimumDrive Receives the minimum red, green, or blue drive value. + * @param pdwCurrentDrive Receives the current red, green, or blue drive value. + * @param pdwMaximumDrive Receives the maximum red, green, or blue drive value. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, DWORDByReference pdwMinimumDrive, + DWORDByReference pdwCurrentDrive, DWORDByReference pdwMaximumDrive); + + /** + * Retrieves a monitor's red, green, or blue gain value. + *

+ * Gain settings are generally used to adjust the monitor's white point. If this function is supported, the + * GetMonitorCapabilities function returns the MC_CAPS_RED_GREEN_BLUE_GAIN flag. This function takes about 40 milliseconds to return. + * The gain settings are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. + * @param gtGainType A member of the MC_GAIN_TYPE enumeration, specifying whether to retrieve the red, green, or blue gain value. + * @param pdwMinimumGain Receives the minimum red, green, or blue gain value. + * @param pdwCurrentGain Receives the current red, green, or blue gain value. + * @param pdwMaximumGain Receives the maximum red, green, or blue gain value. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, DWORDByReference pdwMinimumGain, + DWORDByReference pdwCurrentGain, DWORDByReference pdwMaximumGain); + + /** + * Sets a monitor's brightness value. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_BRIGHTNESS flag. + * This function takes about 50 milliseconds to return. + * The brightness setting is a continuous monitor setting. + * @param hMonitor Handle to a physical monitor. + * @param dwNewBrightness Brightness value. To get the monitor's minimum and maximum brightness values, call GetMonitorBrightness. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorBrightness(HANDLE hMonitor, int dwNewBrightness); + + /** + * Sets a monitor's contrast value. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_CONTRAST flag. + * This function takes about 50 milliseconds to return. The brightness setting is a continuous monitor setting. + * @param hMonitor Handle to a physical monitor. + * @param dwNewContrast Contrast value. To get the monitor's minimum and maximum contrast values, call GetMonitorContrast. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorContrast(HANDLE hMonitor, int dwNewContrast); + + /** + * Sets a monitor's color temperature. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_COLOR_TEMPERATURE flag. + * The GetMonitorCapabilities function also returns the range of color temperatures that the monitor supports. + * The ctCurrentColorTemperature parameter must correspond to one of these values. Changing the color temperature + * changes the monitor's white point. It can also change the current drive and gain settings. To get the new drive + * and gain settings, call GetMonitorRedGreenOrBlueDrive and GetMonitorRedGreenOrBlueGain, respectively. + * This function takes from 50 to 90 milliseconds to return. + * @param hMonitor Handle to a physical monitor. + * @param ctCurrentColorTemperature Color temperature, specified as a member of the MC_COLOR_TEMPERATURE enumeration. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE ctCurrentColorTemperature); + + /** + * Sets a monitor's red, green, or blue drive value. + *

+ * Drive settings are generally used to adjust the + * monitor's white point. Drive and black level are different names for the same monitor setting. If this function + * is supported, the GetMonitorCapabilities function returns the MC_CAPS_RED_GREEN_BLUE_DRIVE flag. This function + * takes about 50 milliseconds to return. Changing the drive settings can change the color temperature. To get the + * new color temperature, call GetMonitorColorTemperature. The drive settings are continuous monitor settings + * @param hMonitor Handle to a physical monitor. + * @param dtDriveType A member of the MC_DRIVE_TYPE enumeration, specifying whether to set the red, green, or blue + * drive value. + * @param dwNewDrive Red, green, or blue drive value. To get the monitor's minimum and maximum drive values, call + * GetMonitorRedGreenOrBlueDrive. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, int dwNewDrive); + + /** + * Sets a monitor's red, green, or blue gain value. + *

+ * Gain settings are generally used to adjust the + * monitor's white point. If this function is supported, the GetMonitorCapabilities function returns the + * MC_CAPS_RED_GREEN_BLUE_GAIN flag. This function takes about 50 milliseconds to return. Changing the gain settings + * can change the color temperature. To get the new color temperature, call GetMonitorColorTemperature. The gain + * settings are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. + * @param gtGainType A member of the MC_GAIN_TYPE enumeration, specifying whether to set the red, green, or blue + * gain. + * @param dwNewGain Red, green, or blue gain value. To get the monitor's minimum and maximum gain values, call + * GetMonitorRedGreenOrBlueGain. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, int dwNewGain); + + /** + * Degausses a monitor. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DEGAUSS flag. Degaussing + * is supported only by cathode ray tube (CRT) monitors. This function takes about 50 milliseconds to return. This + * function should not be called frequently, because calling it frequently will not noticeably improve the monitor's + * image quality or color fidelity. + * @param hMonitor Handle to a physical monitor. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL DegaussMonitor(HANDLE hMonitor); + + /****************************************************************************** + * Monitor image size and position calibration functions + ******************************************************************************/ + + /** + * Retrieves a monitor's minimum, maximum, and current width or height. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_SIZE flag. + * This function takes about 40 milliseconds to return. The width and height settings are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param stSizeType A member of the MC_SIZE_TYPE enumeration, specifying whether to retrieve the width or the height. + * @param pdwMinimumWidthOrHeight Receives the minimum width or height. + * @param pdwCurrentWidthOrHeight Receives the current width or height. + * @param pdwMaximumWidthOrHeight Receives the maximum width or height. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, DWORDByReference pdwMinimumWidthOrHeight, + DWORDByReference pdwCurrentWidthOrHeight, DWORDByReference pdwMaximumWidthOrHeight); + + /** + * Retrieves a monitor's minimum, maximum, and current horizontal or vertical position. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_POSITION flag. + * This function takes about 40 milliseconds to return. The horizontal and vertical position are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param ptPositionType A member of the MC_POSITION_TYPE enumeration, specifying whether to retrieve the horizontal position or the vertical position. + * @param pdwMinimumPosition Receives the minimum horizontal or vertical position. + * @param pdwCurrentPosition Receives the current horizontal or vertical position. + * @param pdwMaximumPosition Receives the maximum horizontal or vertical position. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, + DWORDByReference pdwMinimumPosition, DWORDByReference pdwCurrentPosition, + DWORDByReference pdwMaximumPosition); + + /** + * Sets the width or height of a monitor's display area. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_SIZE flag. + * This function takes about 50 milliseconds to return. The width and height settings are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param stSizeType A member of the MC_SIZE_TYPE enumeration, specifying whether to set the width or the height. + * @param dwNewDisplayAreaWidthOrHeight Display area width or height. To get the minimum and maximum width and height, + * call GetMonitorDisplayAreaSize. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, int dwNewDisplayAreaWidthOrHeight); + + /** + * Sets the horizontal or vertical position of a monitor's display area. + *

+ * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_POSITION flag. + * This function takes about 50 milliseconds to return. The horizontal and vertical position are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param ptPositionType A member of the MC_POSITION_TYPE enumeration, specifying whether to set the horizontal position or the vertical position. + * @param dwNewPosition Horizontal or vertical position. To get the minimum and maximum position, call GetMonitorDisplayAreaPosition. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, int dwNewPosition); + + /****************************************************************************** + * Restore to defaults functions + ******************************************************************************/ + + /** + * Restores a monitor's color settings to their factory defaults. This function potentially changes the current + * value of the monitor's brightness, contrast, color temperature, drive, and gain. The current value of each + * setting is changed to its factory default. The default settings depend on the manufacturer. This function can + * also change the range of supported values for each of these settings. The function does not enable any monitor + * settings that were disabled. If this function is supported, the GetMonitorCapabilities function returns the + * MC_CAPS_RESTORE_FACTORY_COLOR_DEFAULTS flag. This function takes about 5 seconds to return. This function might + * reset monitor settings that are not accessible through the high-level monitor configuration functions. Whether + * this occurs depends on the specific model of monitor. The following settings are not affected by this function: + *
  • Display area size
  • + *
  • Display area position
  • + *
  • Capabilities flags
  • + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL RestoreMonitorFactoryColorDefaults(HANDLE hMonitor); + + /** + * Restores a monitor's settings to their factory defaults. This function restores all of the settings that are + * supported by the high-level monitor configuration functions. It might also restore settings that are available + * only through the low-level functions and are not supported by the high-level functions. The current value of each + * setting is changed to its factory default. The exact settings that change, and the default values of those + * settings, depend on the manufacturer. This function can also change the range of supported values for some + * settings. If this function is supported, the GetMonitorCapabilities function returns the + * MC_CAPS_RESTORE_FACTORY_DEFAULTS flag. This function takes about 5 seconds to return. If GetMonitorCapabilities + * returns the MC_RESTORE_FACTORY_DEFAULTS_ENABLES_MONITOR_SETTINGS flag, this function also enables all of the + * monitor settings that are supported by the high-level functions. It is sometimes possible for an application to + * disable certain settings by calling the low-level functions. It is also possible for the user to disable certain + * settings by adjusting settings on the monitor's physical control panel. If that happens, the setting can only be + * re-enabled through the control panel or by calling RestoreMonitorFactoryDefaults. It is not possible to disable + * any settings by using the high-level functions. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL RestoreMonitorFactoryDefaults(HANDLE hMonitor); + + // LowLevelMonitorConfigurationAPI.h + + /** + * Retrieves the current value, maximum value, and code type of a Virtual Control Panel (VCP) code for a monitor. + * This function corresponds to the "Get VCP Feature & VCP Feature Reply" command from the Display Data + * Channel Command Interface (DDC/CI) standard. Vendor-specific VCP codes can be used with this function. + * This function takes about 40 milliseconds to return. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param bVCPCode VCP code to query. The VCP codes are Include the VESA Monitor Control Command Set (MCCS) + * standard, versions 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a + * vendor-specific code. It should not be a table control code. + * @param pvct Receives the VCP code type, as a member of the MC_VCP_CODE_TYPE enumeration. This parameter can be NULL. + * @param pdwCurrentValue Receives the current value of the VCP code. This parameter can be NULL. + * @param pdwMaximumValue If bVCPCode specifies a continuous VCP code, this parameter receives the maximum value of + * the VCP code. If bVCPCode specifies a non-continuous VCP code, the value received in this parameter + * is undefined. This parameter can be NULL. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetVCPFeatureAndVCPFeatureReply(HANDLE hMonitor, BYTE bVCPCode, MC_VCP_CODE_TYPE.ByReference pvct, + DWORDByReference pdwCurrentValue, DWORDByReference pdwMaximumValue); + + /** + * Sets the value of a Virtual Control Panel (VCP) code for a monitor. This function corresponds to the + * "Set VCP Feature" command from the Display Data Channel Command Interface (DDC/CI) standard. This function takes + * about 50 milliseconds to return. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param bVCPCode VCP code to set. The VCP codes are defined in the VESA Monitor Control Command Set (MCCS) + * standard, version 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a + * vendor-specific code. It should not be a table control code. + * @param dwNewValue Value of the VCP code. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SetVCPFeature(HANDLE hMonitor, BYTE bVCPCode, DWORD dwNewValue); + + /** + * Saves the current monitor settings to the display's nonvolatile storage. This function corresponds to the + * "Save Current Settings" function from the Display Data Channel Command Interface (DDC/CI) standard. This function + * takes about 200 milliseconds to return. This low-level function is identical to the high-level function + * SaveCurrentMonitorSettings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SaveCurrentSettings(HANDLE hMonitor); + + /** + * Retrieves the length of a monitor's capabilities string. + * This function usually returns quickly, but sometimes it can take several seconds to complete. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param pdwCapabilitiesStringLengthInCharacters Receives the length of the capabilities string, in characters, including the terminating null character. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetCapabilitiesStringLength(HANDLE hMonitor, DWORDByReference pdwCapabilitiesStringLengthInCharacters); + + /** + * Retrieves a string describing a monitor's capabilities. This function corresponds to the + * "Capabilities Request & Capabilities Reply" command from the Display Data Channel Command Interface (DDC/CI) + * standard. For more information about the capabilities string, refer to the DDC/CI standard. This function usually + * returns quickly, but sometimes it can take several seconds to complete. You can update a monitor's capabilities + * string by adding an AddReg directive to the monitor's INF file. Add a registry key named "CapabilitiesString" to + * the monitor's driver key. The value of the registry key is the capabilities string. The registry data type is + * REG_SZ. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param pszASCIICapabilitiesString Pointer to a buffer that receives the monitor's capabilities string. The caller + * must allocate this buffer. To get the size of the string, call GetCapabilitiesStringLength. The capabilities + * string is always an ASCII string. The buffer must include space for the terminating null character. + * @param dwCapabilitiesStringLengthInCharacters Size of pszASCIICapabilitiesString in characters, including the + * terminating null character. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL CapabilitiesRequestAndCapabilitiesReply(HANDLE hMonitor, LPSTR pszASCIICapabilitiesString, + DWORD dwCapabilitiesStringLengthInCharacters); + + /** + * Retrieves a monitor's horizontal and vertical synchronization frequencies. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param pmtrMonitorTimingReport Pointer to an MC_TIMING_REPORT structure that receives the timing information. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetTimingReport(HANDLE hMonitor, MC_TIMING_REPORT pmtrMonitorTimingReport); + + // PhysicalMonitorEnumerationAPI.h + + /****************************************************************************** + * Physical Monitor Enumeration Functions + ******************************************************************************/ + + /** + * Retrieves the number of physical monitors associated with an HMONITOR monitor handle. Call this function before + * calling GetPhysicalMonitorsFromHMONITOR. + * @param hMonitor A monitor handle. Monitor handles are returned by several Multiple Display Monitor functions, + * including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI). + * @param pdwNumberOfPhysicalMonitors Receives the number of physical monitors associated with the monitor handle. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetNumberOfPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, DWORDByReference pdwNumberOfPhysicalMonitors); + + // HRESULT GetNumberOfPhysicalMonitorsFromIDirect3DDevice9 + // ( + // IDirect3DDevice9* pDirect3DDevice9, + // DWORDByReference pdwNumberOfPhysicalMonitors + // ); + + /** + * Retrieves the physical monitors associated with an HMONITOR monitor handle. A single HMONITOR handle can be + * associated with more than one physical monitor. This function returns a handle and a text description for each + * physical monitor. When you are done using the monitor handles, close them by passing the pPhysicalMonitorArray + * array to the DestroyPhysicalMonitors function. + * @param hMonitor A monitor handle. Monitor handles are returned by several Multiple Display Monitor functions, + * including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI). + * @param dwPhysicalMonitorArraySize Number of elements in pPhysicalMonitorArray. To get the required size of the + * array, call GetNumberOfPhysicalMonitorsFromHMONITOR. + * @param pPhysicalMonitorArray Pointer to an array of PHYSICAL_MONITOR structures. The caller must allocate the + * array. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, int dwPhysicalMonitorArraySize, + PHYSICAL_MONITOR[] pPhysicalMonitorArray); + + // HRESULT GetPhysicalMonitorsFromIDirect3DDevice9 + // ( + // __in IDirect3DDevice9* pDirect3DDevice9, + // __in DWORD dwPhysicalMonitorArraySize, + // __out_ecount(dwPhysicalMonitorArraySize) LPPHYSICAL_MONITOR pPhysicalMonitorArray + // ); + + /** + * Closes a handle to a physical monitor. + * Call this function to close a monitor handle obtained from the GetPhysicalMonitorsFromHMONITOR + * @param hMonitor Handle to a physical monitor. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL DestroyPhysicalMonitor(HANDLE hMonitor); + + /** + * Closes an array of physical monitor handles. + * Call this function to close an array of monitor handles obtained from the GetPhysicalMonitorsFromHMONITOR + * @param dwPhysicalMonitorArraySize Number of elements in the pPhysicalMonitorArray array. + * @param pPhysicalMonitorArray Pointer to an array of PHYSICAL_MONITOR structures. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL DestroyPhysicalMonitors(int dwPhysicalMonitorArraySize, PHYSICAL_MONITOR[] pPhysicalMonitorArray); +} diff --git a/contrib/platform/src/com/sun/jna/platform/win32/FlagEnum.java b/contrib/platform/src/com/sun/jna/platform/win32/FlagEnum.java new file mode 100644 index 0000000000..f650c1f384 --- /dev/null +++ b/contrib/platform/src/com/sun/jna/platform/win32/FlagEnum.java @@ -0,0 +1,30 @@ +/* + * Copyright 2014 Martin Steiger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.jna.platform.win32; + +/** + * An interface for enum that can be combined to a + * set based on an integer value + * @author Martin Steiger + */ +public interface FlagEnum +{ + /** + * @return the flag value - usually 2^n + */ + int getFlag(); +} diff --git a/contrib/platform/src/com/sun/jna/platform/win32/HighLevelMonitorConfigurationAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/HighLevelMonitorConfigurationAPI.java new file mode 100644 index 0000000000..a755556675 --- /dev/null +++ b/contrib/platform/src/com/sun/jna/platform/win32/HighLevelMonitorConfigurationAPI.java @@ -0,0 +1,436 @@ +/* + * Copyright 2014 Martin Steiger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.jna.platform.win32; + +import com.sun.jna.platform.EnumUtils; + +/** + * A conversion of HighLevelMonitorConfigurationAPI.h + * @author Martin Steiger + */ +public interface HighLevelMonitorConfigurationAPI +{ + /** + * Monitor capabilities - retrieved by GetMonitorCapabilities + */ + enum MC_CAPS implements FlagEnum + { + /** + * The monitor does not support any monitor settings. + */ + MC_CAPS_NONE (0x00000000), + + /** + * The monitor supports the GetMonitorTechnologyType function. + */ + MC_CAPS_MONITOR_TECHNOLOGY_TYPE (0x00000001), + + /** + * The monitor supports the GetMonitorBrightness and SetMonitorBrightness functions. + */ + MC_CAPS_BRIGHTNESS (0x00000002), + + /** + * The monitor supports the GetMonitorContrast and SetMonitorContrast functions. + */ + MC_CAPS_CONTRAST (0x00000004), + + /** + * The monitor supports the GetMonitorColorTemperature and SetMonitorColorTemperature functions. + */ + MC_CAPS_COLOR_TEMPERATURE (0x00000008), + + /** + * The monitor supports the GetMonitorRedGreenOrBlueGain and SetMonitorRedGreenOrBlueGain functions. + */ + MC_CAPS_RED_GREEN_BLUE_GAIN (0x00000010), + + /** + * The monitor supports the GetMonitorRedGreenOrBlueDrive and SetMonitorRedGreenOrBlueDrive functions. + */ + MC_CAPS_RED_GREEN_BLUE_DRIVE (0x00000020), + + /** + * The monitor supports the DegaussMonitor function. + */ + MC_CAPS_DEGAUSS (0x00000040), + + /** + * The monitor supports the GetMonitorDisplayAreaPosition and SetMonitorDisplayAreaPosition functions. + */ + MC_CAPS_DISPLAY_AREA_POSITION (0x00000080), + + /** + * The monitor supports the GetMonitorDisplayAreaSize and SetMonitorDisplayAreaSize functions. + */ + MC_CAPS_DISPLAY_AREA_SIZE (0x00000100), + + /** + * The monitor supports the RestoreMonitorFactoryDefaults function. + */ + MC_CAPS_RESTORE_FACTORY_DEFAULTS (0x00000400), + + /** + * The monitor supports the RestoreMonitorFactoryColorDefaults function. + */ + MC_CAPS_RESTORE_FACTORY_COLOR_DEFAULTS (0x00000800), + + /** + * If this flag is present, calling the RestoreMonitorFactoryDefaults function enables all of + * the monitor settings used by the high-level monitor configuration functions. For more + * information, see the Remarks section in RestoreMonitorFactoryDefaults. + */ + MC_RESTORE_FACTORY_DEFAULTS_ENABLES_MONITOR_SETTINGS (0x00001000); + + private int flag; + + MC_CAPS(int flag) + { + this.flag = flag; + } + + @Override + public int getFlag() + { + return flag; + } + } + + /** + * Monitor capabilities - retrieved by GetMonitorCapabilities + */ + enum MC_SUPPORTED_COLOR_TEMPERATURE implements FlagEnum + { + /** + * No color temperatures are supported. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_NONE (0x00000000), + + /** + * The monitor supports 4,000 kelvins (K) color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_4000K (0x00000001), + + /** + * The monitor supports 5,000 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_5000K (0x00000002), + + /** + * The monitor supports 6,500 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_6500K (0x00000004), + + /** + * The monitor supports 7,500 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_7500K (0x00000008), + + /** + * The monitor supports 8,200 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_8200K (0x00000010), + + /** + * The monitor supports 9,300 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_9300K (0x00000020), + + /** + * The monitor supports 10,000 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_10000K (0x00000040), + + /** + * The monitor supports 11,500 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_11500K (0x00000080); + + private int flag; + + MC_SUPPORTED_COLOR_TEMPERATURE(int flag) + { + this.flag = flag; + } + + @Override + public int getFlag() + { + return flag; + } + } + + // ****************************************************************************** + // Enumerations + // ****************************************************************************** + + /** + * Identifies monitor display technologies. + */ + public enum MC_DISPLAY_TECHNOLOGY_TYPE + { + /** + * Shadow-mask cathode ray tube (CRT). + */ + MC_SHADOW_MASK_CATHODE_RAY_TUBE, + + /** + * Aperture-grill CRT. + */ + MC_APERTURE_GRILL_CATHODE_RAY_TUBE, + + /** + * Thin-film transistor (TFT) display. + */ + MC_THIN_FILM_TRANSISTOR, + + /** + * Liquid crystal on silicon (LCOS) display. + */ + MC_LIQUID_CRYSTAL_ON_SILICON, + + /** + * Plasma display. + */ + MC_PLASMA, + + /** + * Organic light emitting diode (LED) display. + */ + MC_ORGANIC_LIGHT_EMITTING_DIODE, + + /** + * Electroluminescent display. + */ + MC_ELECTROLUMINESCENT, + + /** + * Microelectromechanical display. + */ + MC_MICROELECTROMECHANICAL, + + /** + * Field emission device (FED) display. + */ + MC_FIELD_EMISSION_DEVICE; + + /** + * Defines a Reference to the enum + */ + public static class ByReference extends com.sun.jna.ptr.ByReference { + + /** + * Create an uninitialized reference + */ + public ByReference() { + super(4); + getPointer().setInt(0, EnumUtils.UNINITIALIZED); + } + + /** + * Instantiates a new reference. + * @param value the value + */ + public ByReference(MC_DISPLAY_TECHNOLOGY_TYPE value) { + super(4); + setValue(value); + } + + /** + * Sets the value. + * @param value the new value + */ + public void setValue(MC_DISPLAY_TECHNOLOGY_TYPE value) { + getPointer().setInt(0, EnumUtils.toInteger(value)); + } + + /** + * Gets the value. + * @return the value + */ + public MC_DISPLAY_TECHNOLOGY_TYPE getValue() { + return EnumUtils.fromInteger(getPointer().getInt(0), MC_DISPLAY_TECHNOLOGY_TYPE.class); + } + } + } + + /** + * Specifies whether to set or get a monitor's red, green, or blue drive. + */ + public enum MC_DRIVE_TYPE + { + /** + * Red drive + */ + MC_RED_DRIVE, + + /** + * Green drive + */ + MC_GREEN_DRIVE, + + /** + * Blue drive + */ + MC_BLUE_DRIVE + } + + /** + * Specifies whether to get or set a monitor's red, green, or blue gain. + */ + public enum MC_GAIN_TYPE + { + /** + * Red gain + */ + MC_RED_GAIN, + + /** + * Green gain + */ + MC_GREEN_GAIN, + + /** + * Blue gain + */ + MC_BLUE_GAIN + } + + /** + * Specifies whether to get or set the vertical or horizontal position of a monitor's display area. + */ + public enum MC_POSITION_TYPE + { + /** + * Horizontal position + */ + MC_HORIZONTAL_POSITION, + + /** + * Vertival position + */ + MC_VERTICAL_POSITION + + } + + /** + * Specifies whether to get or set the width or height of a monitor's display area. + */ + public enum MC_SIZE_TYPE + { + /** + * Width + */ + MC_WIDTH, + + /** + * Height + */ + MC_HEIGHT + + } + + /** + * Describes a monitor's color temperature. + */ + public enum MC_COLOR_TEMPERATURE + { + /** + * Unknown temperature. + */ + MC_COLOR_TEMPERATURE_UNKNOWN, + + /** + * 4,000 kelvins (K). + */ + MC_COLOR_TEMPERATURE_4000K, + + /** + * 5,000 kelvins (K). + */ + MC_COLOR_TEMPERATURE_5000K, + + /** + * 6,500 kelvins (K). + */ + MC_COLOR_TEMPERATURE_6500K, + + /** + * 7,500 kelvins (K). + */ + MC_COLOR_TEMPERATURE_7500K, + + /** + * 8,200 kelvins (K). + */ + MC_COLOR_TEMPERATURE_8200K, + + /** + * 9,300 kelvins (K). + */ + MC_COLOR_TEMPERATURE_9300K, + + /** + * 10,000 kelvins (K). + */ + MC_COLOR_TEMPERATURE_10000K, + + /** + * 11,500 kelvins (K). + */ + MC_COLOR_TEMPERATURE_11500K; + + /** + * Defines a Reference to the enum + */ + public static class ByReference extends com.sun.jna.ptr.ByReference { + + /** + * Create an uninitialized reference + */ + public ByReference() { + super(4); + getPointer().setInt(0, EnumUtils.UNINITIALIZED); + } + + /** + * Instantiates a new reference. + * @param value the value + */ + public ByReference(MC_COLOR_TEMPERATURE value) { + super(4); + setValue(value); + } + + /** + * Sets the value. + * @param value the new value + */ + public void setValue(MC_COLOR_TEMPERATURE value) { + getPointer().setInt(0, EnumUtils.toInteger(value)); + } + + /** + * Gets the value. + * @return the value + */ + public MC_COLOR_TEMPERATURE getValue() { + return EnumUtils.fromInteger(getPointer().getInt(0), MC_COLOR_TEMPERATURE.class); + } + } + } +} diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java new file mode 100644 index 0000000000..549cdff709 --- /dev/null +++ b/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java @@ -0,0 +1,116 @@ +/* + * Copyright 2014 Martin Steiger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.jna.platform.win32; + +import java.util.Arrays; +import java.util.List; + +import com.sun.jna.Structure; +import com.sun.jna.platform.EnumUtils; +import com.sun.jna.platform.win32.WinDef.BYTE; +import com.sun.jna.platform.win32.WinDef.DWORD; + +/** + * Conversion of LowLevelMonitorConfigurationAPI.h + * @author Martin Steiger + */ +public interface LowLevelMonitorConfigurationAPI +{ + /** + * Contains information from a monitor's timing report. + */ + class MC_TIMING_REPORT extends Structure + { + /** + * The monitor's horizontal synchronization frequency in Hz. + */ + public DWORD dwHorizontalFrequencyInHZ; + + /** + * The monitor's vertical synchronization frequency in Hz. + */ + public DWORD dwVerticalFrequencyInHZ; + + /** + * Timing status byte. For more information about this value, see the Display Data Channel Command + * Interface (DDC/CI) standard. + */ + public BYTE bTimingStatusByte; + + @Override + protected List getFieldOrder() + { + return Arrays.asList("dwHorizontalFrequencyInHZ", "dwVerticalFrequencyInHZ", "bTimingStatusByte"); + } + } + + /** + * Describes a Virtual Control Panel (VCP) code type. + */ + enum MC_VCP_CODE_TYPE + { + /** + * Momentary VCP code. Sending a command of this type causes the monitor to initiate a self-timed + * operation and then revert to its original state. Examples include display tests and degaussing. + */ + MC_MOMENTARY, + + /** + * Set Parameter VCP code. Sending a command of this type changes some aspect of the monitor's operation. + */ + MC_SET_PARAMETER; + + /** + * Defines a Reference to the enum + */ + public static class ByReference extends com.sun.jna.ptr.ByReference { + + /** + * Create an uninitialized reference + */ + public ByReference() { + super(4); + } + + /** + * Instantiates a new reference. + * @param value the value + */ + public ByReference(MC_VCP_CODE_TYPE value) { + super(4); + setValue(value); + } + + /** + * Sets the value. + * @param value the new value + */ + public void setValue(MC_VCP_CODE_TYPE value) { + getPointer().setInt(0, EnumUtils.toInteger(value)); + } + + /** + * Gets the value. + * @return the value + */ + public MC_VCP_CODE_TYPE getValue() { + return EnumUtils.fromInteger(getPointer().getInt(0), MC_VCP_CODE_TYPE.class); + } + } + } +} + diff --git a/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java new file mode 100644 index 0000000000..a2301ec448 --- /dev/null +++ b/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java @@ -0,0 +1,67 @@ +/* + * Copyright 2014 Martin Steiger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.jna.platform.win32; + +import java.util.Arrays; +import java.util.List; + +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.WinNT.HANDLE; + +/** + * Conversion of PhysicalMonitorEnumerationAPI.h + * @author Martin Steiger + */ +public interface PhysicalMonitorEnumerationAPI +{ + + /****************************************************************************** + Physical Monitor Constants + ******************************************************************************/ + + /** + * A physical monitor description is always an array of 128 characters. Some + * of the characters may not be used. + */ + final int PHYSICAL_MONITOR_DESCRIPTION_SIZE = 128; + + /****************************************************************************** + Physical Monitor Structures + ******************************************************************************/ + + /** + * Contains a handle and text description corresponding to a physical monitor. + */ + public class PHYSICAL_MONITOR extends Structure + { + /** + * Handle to the physical monitor. + */ + public HANDLE hPhysicalMonitor; + + /** + * Text description of the physical monitor (always 128 chars) + */ + public char[] szPhysicalMonitorDescription = new char[PHYSICAL_MONITOR_DESCRIPTION_SIZE]; + + @Override + protected List getFieldOrder() + { + return Arrays.asList("hPhysicalMonitor", "szPhysicalMonitorDescription"); + } + } +} diff --git a/contrib/platform/src/com/sun/jna/platform/win32/User32.java b/contrib/platform/src/com/sun/jna/platform/win32/User32.java index 5c559634cd..bc6f891126 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/User32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/User32.java @@ -16,8 +16,6 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; -import com.sun.jna.platform.win32.BaseTSD.LONG_PTR; -import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.win32.StdCallLibrary; @@ -1702,4 +1700,97 @@ HDEVNOTIFY RegisterDeviceNotification(HANDLE hRecipient, *

    */ int RegisterWindowMessage(String string); + + /** + * Retrieves a handle to the display monitor that contains a specified point. + * @param pt A POINT structure that specifies the point of interest in virtual-screen + * coordinates. + * @param dwFlags Determines the function's return value if the window does not intersect + * any display monitor. This parameter can be one of the following values. + *
  • MONITOR_DEFAULTTONEAREST
  • + *
  • MONITOR_DEFAULTTONULL
  • + *
  • MONITOR_DEFAULTTOPRIMARY
  • + * @return If the point is contained by a display monitor, the return value is an HMONITOR + * handle to that display monitor. If the point is not contained by a display monitor, + * the return value depends on the value of dwFlags. + */ + HMONITOR MonitorFromPoint(POINT pt, int dwFlags); + + /** + * Retrieves a handle to the display monitor that has the largest area of intersection with + * a specified rectangle. + * @param lprc A pointer to a RECT structure that specifies the rectangle of interest in + * virtual-screen coordinates. + * @param dwFlags Determines the function's return value if the window does not intersect + * any display monitor. This parameter can be one of the following values. + *
  • MONITOR_DEFAULTTONEAREST
  • + *
  • MONITOR_DEFAULTTONULL
  • + *
  • MONITOR_DEFAULTTOPRIMARY
  • + * @return If the rectangle intersects one or more display monitor rectangles, the return + * value is an HMONITOR handle to the display monitor that has the largest area of + * intersection with the rectangle. If the rectangle does not intersect a display + * monitor, the return value depends on the value of dwFlags. + */ + HMONITOR MonitorFromRect(RECT lprc, int dwFlags); + + /** + * Retrieves a handle to the display monitor that has the largest area of intersection with + * the bounding rectangle of a specified window. + *

    + * If the window is currently minimized, MonitorFromWindow uses the rectangle of the window + * before it was minimized. + * @param hwnd A handle to the window of interest. + * @param dwFlags Determines the function's return value if the window does not intersect + * any display monitor. This parameter can be one of the following values. + *
  • MONITOR_DEFAULTTONEAREST
  • + *
  • MONITOR_DEFAULTTONULL
  • + *
  • MONITOR_DEFAULTTOPRIMARY
  • + * @return If the window intersects one or more display monitor rectangles, the return value + * is an HMONITOR handle to the display monitor that has the largest area of + * intersection with the window. If the window does not intersect a display monitor, + * the return value depends on the value of dwFlags. + */ + HMONITOR MonitorFromWindow(HWND hwnd, int dwFlags); + + /** + * Retrieves information about a display monitor. + * @param hMonitor A handle to the display monitor of interest. + * @param lpmi A pointer to a {@link WinUser.MONITORINFO} structure that receives information about + * the specified display monitor. + * @return If the function succeeds, the return value is nonzero. If the function + * fails, the return value is zero. + */ + BOOL GetMonitorInfo(HMONITOR hMonitor, MONITORINFO lpmi); + + /** + * Retrieves information about a display monitor. + * @param hMonitor A handle to the display monitor of interest. + * @param lpmi A pointer to a {@link WinUser.MONITORINFOEX} structure that receives information about + * the specified display monitor. + * @return If the function succeeds, the return value is nonzero. If the function + * fails, the return value is zero. + */ + BOOL GetMonitorInfo(HMONITOR hMonitor, MONITORINFOEX lpmi); + + /** + * Enumerates display monitors (including invisible pseudo-monitors associated with the mirroring drivers) + * that intersect a region formed by the intersection of a specified clipping rectangle and the visible + * region of a device context. EnumDisplayMonitors calls an application-defined MonitorEnumProc callback + * function once for each monitor that is enumerated. Note that GetSystemMetrics (SM_CMONITORS) counts + * only the display monitors. + * @param hdc A handle to a display device context that defines the visible region of interest. If this + * parameter is NULL, the hdcMonitor parameter passed to the callback function will be NULL, and + * the visible region of interest is the virtual screen that encompasses all the displays on the + * desktop. + * @param lprcClip A pointer to a RECT structure that specifies a clipping rectangle. The region of + * interest is the intersection of the clipping rectangle with the visible region specified by hdc. + * If hdc is non-NULL, the coordinates of the clipping rectangle are relative to the origin of the + * hdc. If hdc is NULL, the coordinates are virtual-screen coordinates. This parameter can be NULL + * if you don't want to clip the region specified by hdc. + * @param lpfnEnum A pointer to an application-defined callback function. + * @param dwData Application-defined data that EnumDisplayMonitors passes directly to the lpfnEnum function. + * @return If the function succeeds, the return value is nonzero. If the function fails, the return value + * is zero. + */ + BOOL EnumDisplayMonitors(HDC hdc, RECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java index aecdc48089..815915c488 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java @@ -23,11 +23,13 @@ import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR; import com.sun.jna.platform.win32.WinDef.HBRUSH; import com.sun.jna.platform.win32.WinDef.HCURSOR; +import com.sun.jna.platform.win32.WinDef.HDC; import com.sun.jna.platform.win32.WinDef.HICON; import com.sun.jna.platform.win32.WinDef.HINSTANCE; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinDef.LPARAM; import com.sun.jna.platform.win32.WinDef.LRESULT; +import com.sun.jna.platform.win32.WinDef.RECT; import com.sun.jna.platform.win32.WinDef.WPARAM; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.win32.StdCallLibrary; @@ -875,5 +877,194 @@ public interface WindowProc extends Callback { */ LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam); } + + /** + * Each physical display is represented by a monitor handle of type HMONITOR. A valid HMONITOR + * is guaranteed to be non-NULL. A physical display has the same HMONITOR as long as it is part + * of the desktop. + */ + public class HMONITOR extends HANDLE { + + /** + * Instantiates a new HMONITOR. + */ + public HMONITOR() + { + } + + /** + * Instantiates a new HMONITOR. + * @param p the pointer + */ + public HMONITOR(Pointer p) + { + super(p); + } + } + + /** + * Returns NULL. + */ + final int MONITOR_DEFAULTTONULL = 0x00000000; + + /** + * Returns a handle to the primary display monitor. + */ + final int MONITOR_DEFAULTTOPRIMARY = 0x00000001; + + /** + * Returns a handle to the display monitor that is nearest to the window. + */ + final int MONITOR_DEFAULTTONEAREST = 0x00000002; + + /** + * This is the primary display monitor. + */ + final int MONITORINFOF_PRIMARY = 0x00000001; + + /** + * Length of the device name in MONITORINFOEX + */ + final int CCHDEVICENAME = 32; + + /** + * The MONITORINFO structure contains information about a display monitor.
    + * The {@link MyUser32#GetMonitorInfo(HMONITOR, MONITORINFO)} function stores + * information into a MONITORINFO structure

    + * The MONITORINFO structure is a subset of the MONITORINFOEX structure. + */ + public class MONITORINFO extends Structure + { + /** + * The size, in bytes, of the structure. + */ + public int cbSize = size(); + + /** + * Specifies the display monitor rectangle, expressed in virtual-screen coordinates. + * Note that if the monitor is not the primary display monitor, some of the + * rectangle's coordinates may be negative values. + */ + public RECT rcMonitor; + + /** + * Specifies the work area rectangle of the display monitor that can be used by + * applications, expressed in virtual-screen coordinates. Windows uses this rectangle + * to maximize an application on the monitor. The rest of the area in rcMonitor + * contains system windows such as the task bar and side bars. Note that if the + * monitor is not the primary display monitor, some of the rectangle's coordinates + * may be negative values. + */ + public RECT rcWork; + + /** + * The attributes of the display monitor. This member can be the following value. + *
  • MONITORINFOF_PRIMARY
  • + */ + public int dwFlags; + + @Override + protected List getFieldOrder() + { + return Arrays.asList("cbSize", "rcMonitor", "rcWork", "dwFlags"); + } + } + + /** + * The MONITORINFOEX structure contains information about a display monitor.
    + * The {@link MyUser32#GetMonitorInfo(HMONITOR, MONITORINFOEX)} function stores + * information into a MONITORINFOEX structure

    + * The MONITORINFOEX structure is a superset of the MONITORINFO structure. + * The MONITORINFOEX structure adds a string member to contain a name for the display monitor. + */ + public class MONITORINFOEX extends Structure + { + /** + * The size, in bytes, of the structure. + */ + public int cbSize; + + /** + * Specifies the display monitor rectangle, expressed in virtual-screen coordinates. + * Note that if the monitor is not the primary display monitor, some of the + * rectangle's coordinates may be negative values. + */ + public RECT rcMonitor; + + /** + * Specifies the work area rectangle of the display monitor that can be used by + * applications, expressed in virtual-screen coordinates. Windows uses this rectangle + * to maximize an application on the monitor. The rest of the area in rcMonitor + * contains system windows such as the task bar and side bars. Note that if the + * monitor is not the primary display monitor, some of the rectangle's coordinates + * may be negative values. + */ + public RECT rcWork; + + /** + * The attributes of the display monitor. This member can be the following value. + *
  • MONITORINFOF_PRIMARY
  • + */ + public int dwFlags; + + /** + * A string that specifies the device name of the monitor being used. Most + * applications have no use for a display monitor name, and so can save some bytes + * by using a MONITORINFO structure. + */ + public char[] szDevice; + + public MONITORINFOEX() + { + szDevice = new char[CCHDEVICENAME]; + cbSize = size(); + } + + @Override + protected List getFieldOrder() + { + return Arrays.asList("cbSize", "rcMonitor", "rcWork", "dwFlags", "szDevice"); + } + } + + /** + * An application-defined callback function that is called by the {@link MyUser32#EnumDisplayMonitors} function. + *

    + * You can use the EnumDisplayMonitors function to enumerate the set of display monitors that intersect + * the visible region of a specified device context and, optionally, a clipping rectangle. To do this, + * set the hdc parameter to a non-NULL value, and set the lprcClip parameter as needed. + *

    + * You can also use the EnumDisplayMonitors function to enumerate one or more of the display monitors on + * the desktop, without supplying a device context. To do this, set the hdc parameter of + * EnumDisplayMonitors to NULL and set the lprcClip parameter as needed. + *

    + * In all cases, EnumDisplayMonitors calls a specified MonitorEnumProc function once for each display + * monitor in the calculated enumeration set. The MonitorEnumProc function always receives a handle to + * the display monitor. If the hdc parameter of EnumDisplayMonitors is non-NULL, the MonitorEnumProc + * function also receives a handle to a device context whose color format is appropriate for the + * display monitor. You can then paint into the device context in a manner that is optimal for the + * display monitor. + */ + public interface MONITORENUMPROC extends Callback + { + /** + * @param hMonitor A handle to the display monitor. This value will always be non-NULL. + * @param hdcMonitor A handle to a device context. The device context has color attributes that are + * appropriate for the display monitor identified by hMonitor. The clipping area of the device + * context is set to the intersection of the visible region of the device context identified + * by the hdc parameter of EnumDisplayMonitors, the rectangle pointed to by the lprcClip + * parameter of EnumDisplayMonitors, and the display monitor rectangle. + * @param lprcMonitor A pointer to a RECT structure. If hdcMonitor is non-NULL, this rectangle is the + * intersection of the clipping area of the device context identified by hdcMonitor and the + * display monitor rectangle. The rectangle coordinates are device-context coordinates. + * If hdcMonitor is NULL, this rectangle is the display monitor rectangle. The rectangle + * coordinates are virtual-screen coordinates. + * @param dwData Application-defined data that EnumDisplayMonitors passes directly to the enumeration + * function. + * @return To continue the enumeration, return TRUE. To stop the enumeration, return FALSE. + */ + public int apply(HMONITOR hMonitor, HDC hdcMonitor, RECT lprcMonitor, LPARAM dwData); + } + } From 5f6484d66d2417b1fcf8582852804c99e3e00168 Mon Sep 17 00:00:00 2001 From: Martin Steiger Date: Thu, 22 May 2014 17:36:24 +0200 Subject: [PATCH 2/5] Fixed whitespace/typos in WIn32 Monitor API --- CHANGES.md | 2 +- .../src/com/sun/jna/platform/win32/Dxva2.java | 937 +++++++++--------- .../HighLevelMonitorConfigurationAPI.java | 818 +++++++-------- .../LowLevelMonitorConfigurationAPI.java | 158 +-- .../win32/PhysicalMonitorEnumerationAPI.java | 68 +- .../com/sun/jna/platform/win32/User32.java | 186 ++-- .../com/sun/jna/platform/win32/WinUser.java | 334 +++---- 7 files changed, 1251 insertions(+), 1252 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cc3a2c2a03..5005384a82 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,7 +9,7 @@ Features -------- * Updated AIX natives and build - [@twall](https://github.com/twall). * [#290](https://github.com/twall/jna/pull/290): Improved the stacktrace for the exceptions thrown by `com.sun.jna.Structure` - [@ebourg](https://github.com/ebourg). -* Added Win32 Monitor Configuration API +* [#332](https://github.com/twall/jna/pull/332): Added Win32 Monitor Configuration APII - [@msteiger](https://github.com/msteiger). Bug Fixes --------- diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Dxva2.java b/contrib/platform/src/com/sun/jna/platform/win32/Dxva2.java index ae8a0399af..462e0c4cca 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Dxva2.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Dxva2.java @@ -37,473 +37,472 @@ */ public interface Dxva2 extends StdCallLibrary, PhysicalMonitorEnumerationAPI, HighLevelMonitorConfigurationAPI, LowLevelMonitorConfigurationAPI { - /** - * The only instance of the library - */ - Dxva2 INSTANCE = (Dxva2) Native.loadLibrary("Dxva2", Dxva2.class, new HashMap() - { - private static final long serialVersionUID = -1987971664975780480L; - - { - put(Library.OPTION_TYPE_MAPPER, new DefaultTypeMapper() - { - { - addTypeConverter(MC_POSITION_TYPE.class, new EnumConverter<>(MC_POSITION_TYPE.class)); - addTypeConverter(MC_SIZE_TYPE.class, new EnumConverter<>(MC_SIZE_TYPE.class)); - addTypeConverter(MC_GAIN_TYPE.class, new EnumConverter<>(MC_GAIN_TYPE.class)); - addTypeConverter(MC_DRIVE_TYPE.class, new EnumConverter<>(MC_DRIVE_TYPE.class)); - } - }); - } - }); - - - - /****************************************************************************** - Monitor capability functions - ******************************************************************************/ - /** - * Retrieves the configuration capabilities of a monitor. Call this function to find out which high-level - * monitor configuration functions are supported by the monitor. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call - * {@link #GetPhysicalMonitorsFromHMONITOR} - * @param pdwMonitorCapabilities Receives a bitwise OR of capabilities flags. (MC_CAPS_*) - * @param pdwSupportedColorTemperatures Receives a bitwise OR of color temperature flags. - * (MC_SUPPORTED_COLOR_TEMPERATURE_*) - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is - * FALSE. To get extended error information, call GetLastError. - *

    - * The function fails if the monitor does not support DDC/CI. - */ - BOOL GetMonitorCapabilities(HANDLE hMonitor, DWORDByReference pdwMonitorCapabilities, DWORDByReference pdwSupportedColorTemperatures); - - /****************************************************************************** - Monitor setting persistence functions - ******************************************************************************/ - - /** - * Saves the current monitor settings to the display's nonvolatile storage. - *

    - * This function takes about 200 milliseconds to return. - * This high-level function is identical to the low-level function SaveCurrentSettings. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL SaveCurrentMonitorSettings(HANDLE hMonitor); - - /****************************************************************************** - Monitor meta-data functions - ******************************************************************************/ - - /** - * Retrieves the type of technology used by a monitor. - * This function does not support every display technology. If a monitor uses a display technology that is - * supported by this function, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_TECHNOLOGY_TYPE - * flag. If that flag is absent, the GetMonitorTechnologyType function fails. - * Some monitor technologies do not support certain monitor configuration functions. For example, - * the DegaussMonitor function is supported only for cathode ray tube (CRT) monitors. To find out whether a - * specific function is supported, call GetMonitorCapabilities. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param pdtyDisplayTechnologyType Receives the technology type as defined in {@link HighLevelMonitorConfigurationAPI.MC_DISPLAY_TECHNOLOGY_TYPE}. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL GetMonitorTechnologyType(HANDLE hMonitor, MC_DISPLAY_TECHNOLOGY_TYPE.ByReference pdtyDisplayTechnologyType); - - /****************************************************************************** - Monitor image calibration functions - ******************************************************************************/ - - /** - * Retrieves a monitor's minimum, maximum, and current brightness settings. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_BRIGHTNESS flag. - * This function takes about 40 milliseconds to return. The brightness setting is a continuous monitor setting. - * @param hMonitor Handle to a physical monitor - * @param pdwMinimumBrightness Receives the monitor's minimum brightness. - * @param pdwCurrentBrightness Receives the monitor's current brightness. - * @param pdwMaximumBrightness Receives the monitor's maximum brightness. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL GetMonitorBrightness(HANDLE hMonitor, DWORDByReference pdwMinimumBrightness, - DWORDByReference pdwCurrentBrightness, DWORDByReference pdwMaximumBrightness); - - /** - * Retrieves a monitor's minimum, maximum, and current contrast settings. - * @param hMonitor Handle to a physical monitor. - * @param pdwMinimumContrast Receives the monitor's minimum contrast. - * @param pdwCurrentContrast Receives the monitor's current contrast. - * @param pdwMaximumContrast Receives the monitor's maximum contrast. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL GetMonitorContrast(HANDLE hMonitor, DWORDByReference pdwMinimumContrast, DWORDByReference pdwCurrentContrast, - DWORDByReference pdwMaximumContrast); - - /** - * Retrieves a monitor's current color temperature. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_COLOR_TEMPERATURE flag. - * This function takes between 0 and 80 milliseconds to return. - * @param hMonitor Handle to a physical monitor. - * @param pctCurrentColorTemperature Receives the monitor's current color temperature. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL GetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature); - - /** - * Retrieves a monitor's red, green, or blue drive value. - *

    - * Drive settings are generally used to adjust the monitor's white point. Drive and black level are different - * names for the same monitor setting. If this function is supported, the GetMonitorCapabilities function returns - * the MC_CAPS_RED_GREEN_BLUE_DRIVE flag. - * @param hMonitor Handle to a physical monitor. - * @param dtDriveType A member of the MC_DRIVE_TYPE enumeration, specifying whether to retrieve the red, green, or blue drive value. - * @param pdwMinimumDrive Receives the minimum red, green, or blue drive value. - * @param pdwCurrentDrive Receives the current red, green, or blue drive value. - * @param pdwMaximumDrive Receives the maximum red, green, or blue drive value. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL GetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, DWORDByReference pdwMinimumDrive, - DWORDByReference pdwCurrentDrive, DWORDByReference pdwMaximumDrive); - - /** - * Retrieves a monitor's red, green, or blue gain value. - *

    - * Gain settings are generally used to adjust the monitor's white point. If this function is supported, the - * GetMonitorCapabilities function returns the MC_CAPS_RED_GREEN_BLUE_GAIN flag. This function takes about 40 milliseconds to return. - * The gain settings are continuous monitor settings. - * @param hMonitor Handle to a physical monitor. - * @param gtGainType A member of the MC_GAIN_TYPE enumeration, specifying whether to retrieve the red, green, or blue gain value. - * @param pdwMinimumGain Receives the minimum red, green, or blue gain value. - * @param pdwCurrentGain Receives the current red, green, or blue gain value. - * @param pdwMaximumGain Receives the maximum red, green, or blue gain value. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL GetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, DWORDByReference pdwMinimumGain, - DWORDByReference pdwCurrentGain, DWORDByReference pdwMaximumGain); - - /** - * Sets a monitor's brightness value. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_BRIGHTNESS flag. - * This function takes about 50 milliseconds to return. - * The brightness setting is a continuous monitor setting. - * @param hMonitor Handle to a physical monitor. - * @param dwNewBrightness Brightness value. To get the monitor's minimum and maximum brightness values, call GetMonitorBrightness. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL SetMonitorBrightness(HANDLE hMonitor, int dwNewBrightness); - - /** - * Sets a monitor's contrast value. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_CONTRAST flag. - * This function takes about 50 milliseconds to return. The brightness setting is a continuous monitor setting. - * @param hMonitor Handle to a physical monitor. - * @param dwNewContrast Contrast value. To get the monitor's minimum and maximum contrast values, call GetMonitorContrast. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL SetMonitorContrast(HANDLE hMonitor, int dwNewContrast); - - /** - * Sets a monitor's color temperature. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_COLOR_TEMPERATURE flag. - * The GetMonitorCapabilities function also returns the range of color temperatures that the monitor supports. - * The ctCurrentColorTemperature parameter must correspond to one of these values. Changing the color temperature - * changes the monitor's white point. It can also change the current drive and gain settings. To get the new drive - * and gain settings, call GetMonitorRedGreenOrBlueDrive and GetMonitorRedGreenOrBlueGain, respectively. - * This function takes from 50 to 90 milliseconds to return. - * @param hMonitor Handle to a physical monitor. - * @param ctCurrentColorTemperature Color temperature, specified as a member of the MC_COLOR_TEMPERATURE enumeration. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL SetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE ctCurrentColorTemperature); - - /** - * Sets a monitor's red, green, or blue drive value. - *

    - * Drive settings are generally used to adjust the - * monitor's white point. Drive and black level are different names for the same monitor setting. If this function - * is supported, the GetMonitorCapabilities function returns the MC_CAPS_RED_GREEN_BLUE_DRIVE flag. This function - * takes about 50 milliseconds to return. Changing the drive settings can change the color temperature. To get the - * new color temperature, call GetMonitorColorTemperature. The drive settings are continuous monitor settings - * @param hMonitor Handle to a physical monitor. - * @param dtDriveType A member of the MC_DRIVE_TYPE enumeration, specifying whether to set the red, green, or blue - * drive value. - * @param dwNewDrive Red, green, or blue drive value. To get the monitor's minimum and maximum drive values, call - * GetMonitorRedGreenOrBlueDrive. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL SetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, int dwNewDrive); - - /** - * Sets a monitor's red, green, or blue gain value. - *

    - * Gain settings are generally used to adjust the - * monitor's white point. If this function is supported, the GetMonitorCapabilities function returns the - * MC_CAPS_RED_GREEN_BLUE_GAIN flag. This function takes about 50 milliseconds to return. Changing the gain settings - * can change the color temperature. To get the new color temperature, call GetMonitorColorTemperature. The gain - * settings are continuous monitor settings. - * @param hMonitor Handle to a physical monitor. - * @param gtGainType A member of the MC_GAIN_TYPE enumeration, specifying whether to set the red, green, or blue - * gain. - * @param dwNewGain Red, green, or blue gain value. To get the monitor's minimum and maximum gain values, call - * GetMonitorRedGreenOrBlueGain. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL SetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, int dwNewGain); - - /** - * Degausses a monitor. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DEGAUSS flag. Degaussing - * is supported only by cathode ray tube (CRT) monitors. This function takes about 50 milliseconds to return. This - * function should not be called frequently, because calling it frequently will not noticeably improve the monitor's - * image quality or color fidelity. - * @param hMonitor Handle to a physical monitor. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL DegaussMonitor(HANDLE hMonitor); - - /****************************************************************************** - * Monitor image size and position calibration functions - ******************************************************************************/ - - /** - * Retrieves a monitor's minimum, maximum, and current width or height. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_SIZE flag. - * This function takes about 40 milliseconds to return. The width and height settings are continuous monitor settings. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param stSizeType A member of the MC_SIZE_TYPE enumeration, specifying whether to retrieve the width or the height. - * @param pdwMinimumWidthOrHeight Receives the minimum width or height. - * @param pdwCurrentWidthOrHeight Receives the current width or height. - * @param pdwMaximumWidthOrHeight Receives the maximum width or height. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL GetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, DWORDByReference pdwMinimumWidthOrHeight, - DWORDByReference pdwCurrentWidthOrHeight, DWORDByReference pdwMaximumWidthOrHeight); - - /** - * Retrieves a monitor's minimum, maximum, and current horizontal or vertical position. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_POSITION flag. - * This function takes about 40 milliseconds to return. The horizontal and vertical position are continuous monitor settings. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param ptPositionType A member of the MC_POSITION_TYPE enumeration, specifying whether to retrieve the horizontal position or the vertical position. - * @param pdwMinimumPosition Receives the minimum horizontal or vertical position. - * @param pdwCurrentPosition Receives the current horizontal or vertical position. - * @param pdwMaximumPosition Receives the maximum horizontal or vertical position. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL GetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, - DWORDByReference pdwMinimumPosition, DWORDByReference pdwCurrentPosition, - DWORDByReference pdwMaximumPosition); - - /** - * Sets the width or height of a monitor's display area. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_SIZE flag. - * This function takes about 50 milliseconds to return. The width and height settings are continuous monitor settings. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param stSizeType A member of the MC_SIZE_TYPE enumeration, specifying whether to set the width or the height. - * @param dwNewDisplayAreaWidthOrHeight Display area width or height. To get the minimum and maximum width and height, - * call GetMonitorDisplayAreaSize. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL SetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, int dwNewDisplayAreaWidthOrHeight); - - /** - * Sets the horizontal or vertical position of a monitor's display area. - *

    - * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_POSITION flag. - * This function takes about 50 milliseconds to return. The horizontal and vertical position are continuous monitor settings. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param ptPositionType A member of the MC_POSITION_TYPE enumeration, specifying whether to set the horizontal position or the vertical position. - * @param dwNewPosition Horizontal or vertical position. To get the minimum and maximum position, call GetMonitorDisplayAreaPosition. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL SetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, int dwNewPosition); - - /****************************************************************************** - * Restore to defaults functions - ******************************************************************************/ - - /** - * Restores a monitor's color settings to their factory defaults. This function potentially changes the current - * value of the monitor's brightness, contrast, color temperature, drive, and gain. The current value of each - * setting is changed to its factory default. The default settings depend on the manufacturer. This function can - * also change the range of supported values for each of these settings. The function does not enable any monitor - * settings that were disabled. If this function is supported, the GetMonitorCapabilities function returns the - * MC_CAPS_RESTORE_FACTORY_COLOR_DEFAULTS flag. This function takes about 5 seconds to return. This function might - * reset monitor settings that are not accessible through the high-level monitor configuration functions. Whether - * this occurs depends on the specific model of monitor. The following settings are not affected by this function: - *
  • Display area size
  • - *
  • Display area position
  • - *
  • Capabilities flags
  • - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL RestoreMonitorFactoryColorDefaults(HANDLE hMonitor); - - /** - * Restores a monitor's settings to their factory defaults. This function restores all of the settings that are - * supported by the high-level monitor configuration functions. It might also restore settings that are available - * only through the low-level functions and are not supported by the high-level functions. The current value of each - * setting is changed to its factory default. The exact settings that change, and the default values of those - * settings, depend on the manufacturer. This function can also change the range of supported values for some - * settings. If this function is supported, the GetMonitorCapabilities function returns the - * MC_CAPS_RESTORE_FACTORY_DEFAULTS flag. This function takes about 5 seconds to return. If GetMonitorCapabilities - * returns the MC_RESTORE_FACTORY_DEFAULTS_ENABLES_MONITOR_SETTINGS flag, this function also enables all of the - * monitor settings that are supported by the high-level functions. It is sometimes possible for an application to - * disable certain settings by calling the low-level functions. It is also possible for the user to disable certain - * settings by adjusting settings on the monitor's physical control panel. If that happens, the setting can only be - * re-enabled through the control panel or by calling RestoreMonitorFactoryDefaults. It is not possible to disable - * any settings by using the high-level functions. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL RestoreMonitorFactoryDefaults(HANDLE hMonitor); - - // LowLevelMonitorConfigurationAPI.h - - /** - * Retrieves the current value, maximum value, and code type of a Virtual Control Panel (VCP) code for a monitor. - * This function corresponds to the "Get VCP Feature & VCP Feature Reply" command from the Display Data - * Channel Command Interface (DDC/CI) standard. Vendor-specific VCP codes can be used with this function. - * This function takes about 40 milliseconds to return. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param bVCPCode VCP code to query. The VCP codes are Include the VESA Monitor Control Command Set (MCCS) - * standard, versions 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a - * vendor-specific code. It should not be a table control code. - * @param pvct Receives the VCP code type, as a member of the MC_VCP_CODE_TYPE enumeration. This parameter can be NULL. - * @param pdwCurrentValue Receives the current value of the VCP code. This parameter can be NULL. - * @param pdwMaximumValue If bVCPCode specifies a continuous VCP code, this parameter receives the maximum value of - * the VCP code. If bVCPCode specifies a non-continuous VCP code, the value received in this parameter - * is undefined. This parameter can be NULL. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL GetVCPFeatureAndVCPFeatureReply(HANDLE hMonitor, BYTE bVCPCode, MC_VCP_CODE_TYPE.ByReference pvct, - DWORDByReference pdwCurrentValue, DWORDByReference pdwMaximumValue); - - /** - * Sets the value of a Virtual Control Panel (VCP) code for a monitor. This function corresponds to the - * "Set VCP Feature" command from the Display Data Channel Command Interface (DDC/CI) standard. This function takes - * about 50 milliseconds to return. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param bVCPCode VCP code to set. The VCP codes are defined in the VESA Monitor Control Command Set (MCCS) - * standard, version 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a - * vendor-specific code. It should not be a table control code. - * @param dwNewValue Value of the VCP code. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL SetVCPFeature(HANDLE hMonitor, BYTE bVCPCode, DWORD dwNewValue); - - /** - * Saves the current monitor settings to the display's nonvolatile storage. This function corresponds to the - * "Save Current Settings" function from the Display Data Channel Command Interface (DDC/CI) standard. This function - * takes about 200 milliseconds to return. This low-level function is identical to the high-level function - * SaveCurrentMonitorSettings. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL SaveCurrentSettings(HANDLE hMonitor); - - /** - * Retrieves the length of a monitor's capabilities string. - * This function usually returns quickly, but sometimes it can take several seconds to complete. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param pdwCapabilitiesStringLengthInCharacters Receives the length of the capabilities string, in characters, including the terminating null character. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL GetCapabilitiesStringLength(HANDLE hMonitor, DWORDByReference pdwCapabilitiesStringLengthInCharacters); - - /** - * Retrieves a string describing a monitor's capabilities. This function corresponds to the - * "Capabilities Request & Capabilities Reply" command from the Display Data Channel Command Interface (DDC/CI) - * standard. For more information about the capabilities string, refer to the DDC/CI standard. This function usually - * returns quickly, but sometimes it can take several seconds to complete. You can update a monitor's capabilities - * string by adding an AddReg directive to the monitor's INF file. Add a registry key named "CapabilitiesString" to - * the monitor's driver key. The value of the registry key is the capabilities string. The registry data type is - * REG_SZ. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param pszASCIICapabilitiesString Pointer to a buffer that receives the monitor's capabilities string. The caller - * must allocate this buffer. To get the size of the string, call GetCapabilitiesStringLength. The capabilities - * string is always an ASCII string. The buffer must include space for the terminating null character. - * @param dwCapabilitiesStringLengthInCharacters Size of pszASCIICapabilitiesString in characters, including the - * terminating null character. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL CapabilitiesRequestAndCapabilitiesReply(HANDLE hMonitor, LPSTR pszASCIICapabilitiesString, - DWORD dwCapabilitiesStringLengthInCharacters); - - /** - * Retrieves a monitor's horizontal and vertical synchronization frequencies. - * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR - * @param pmtrMonitorTimingReport Pointer to an MC_TIMING_REPORT structure that receives the timing information. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. - */ - BOOL GetTimingReport(HANDLE hMonitor, MC_TIMING_REPORT pmtrMonitorTimingReport); - - // PhysicalMonitorEnumerationAPI.h - - /****************************************************************************** - * Physical Monitor Enumeration Functions - ******************************************************************************/ - - /** - * Retrieves the number of physical monitors associated with an HMONITOR monitor handle. Call this function before - * calling GetPhysicalMonitorsFromHMONITOR. - * @param hMonitor A monitor handle. Monitor handles are returned by several Multiple Display Monitor functions, - * including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI). - * @param pdwNumberOfPhysicalMonitors Receives the number of physical monitors associated with the monitor handle. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL GetNumberOfPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, DWORDByReference pdwNumberOfPhysicalMonitors); - - // HRESULT GetNumberOfPhysicalMonitorsFromIDirect3DDevice9 - // ( - // IDirect3DDevice9* pDirect3DDevice9, - // DWORDByReference pdwNumberOfPhysicalMonitors - // ); - - /** - * Retrieves the physical monitors associated with an HMONITOR monitor handle. A single HMONITOR handle can be - * associated with more than one physical monitor. This function returns a handle and a text description for each - * physical monitor. When you are done using the monitor handles, close them by passing the pPhysicalMonitorArray - * array to the DestroyPhysicalMonitors function. - * @param hMonitor A monitor handle. Monitor handles are returned by several Multiple Display Monitor functions, - * including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI). - * @param dwPhysicalMonitorArraySize Number of elements in pPhysicalMonitorArray. To get the required size of the - * array, call GetNumberOfPhysicalMonitorsFromHMONITOR. - * @param pPhysicalMonitorArray Pointer to an array of PHYSICAL_MONITOR structures. The caller must allocate the - * array. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL GetPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, int dwPhysicalMonitorArraySize, - PHYSICAL_MONITOR[] pPhysicalMonitorArray); - - // HRESULT GetPhysicalMonitorsFromIDirect3DDevice9 - // ( - // __in IDirect3DDevice9* pDirect3DDevice9, - // __in DWORD dwPhysicalMonitorArraySize, - // __out_ecount(dwPhysicalMonitorArraySize) LPPHYSICAL_MONITOR pPhysicalMonitorArray - // ); - - /** - * Closes a handle to a physical monitor. - * Call this function to close a monitor handle obtained from the GetPhysicalMonitorsFromHMONITOR - * @param hMonitor Handle to a physical monitor. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL DestroyPhysicalMonitor(HANDLE hMonitor); - - /** - * Closes an array of physical monitor handles. - * Call this function to close an array of monitor handles obtained from the GetPhysicalMonitorsFromHMONITOR - * @param dwPhysicalMonitorArraySize Number of elements in the pPhysicalMonitorArray array. - * @param pPhysicalMonitorArray Pointer to an array of PHYSICAL_MONITOR structures. - * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE - */ - BOOL DestroyPhysicalMonitors(int dwPhysicalMonitorArraySize, PHYSICAL_MONITOR[] pPhysicalMonitorArray); + /** + * The only instance of the library + */ + Dxva2 INSTANCE = (Dxva2) Native.loadLibrary("Dxva2", Dxva2.class, new HashMap() + { + private static final long serialVersionUID = -1987971664975780480L; + + { + put(Library.OPTION_TYPE_MAPPER, new DefaultTypeMapper() + { + { + addTypeConverter(MC_POSITION_TYPE.class, new EnumConverter<>(MC_POSITION_TYPE.class)); + addTypeConverter(MC_SIZE_TYPE.class, new EnumConverter<>(MC_SIZE_TYPE.class)); + addTypeConverter(MC_GAIN_TYPE.class, new EnumConverter<>(MC_GAIN_TYPE.class)); + addTypeConverter(MC_DRIVE_TYPE.class, new EnumConverter<>(MC_DRIVE_TYPE.class)); + } + }); + } + }); + + + /****************************************************************************** + Monitor capability functions + ******************************************************************************/ + /** + * Retrieves the configuration capabilities of a monitor. Call this function to find out which high-level + * monitor configuration functions are supported by the monitor. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call + * {@link #GetPhysicalMonitorsFromHMONITOR} + * @param pdwMonitorCapabilities Receives a bitwise OR of capabilities flags. (MC_CAPS_*) + * @param pdwSupportedColorTemperatures Receives a bitwise OR of color temperature flags. + * (MC_SUPPORTED_COLOR_TEMPERATURE_*) + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is + * FALSE. To get extended error information, call GetLastError. + *

    + * The function fails if the monitor does not support DDC/CI. + */ + BOOL GetMonitorCapabilities(HANDLE hMonitor, DWORDByReference pdwMonitorCapabilities, DWORDByReference pdwSupportedColorTemperatures); + + /****************************************************************************** + Monitor setting persistence functions + ******************************************************************************/ + + /** + * Saves the current monitor settings to the display's nonvolatile storage. + *

    + * This function takes about 200 milliseconds to return. + * This high-level function is identical to the low-level function SaveCurrentSettings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SaveCurrentMonitorSettings(HANDLE hMonitor); + + /****************************************************************************** + Monitor meta-data functions + ******************************************************************************/ + + /** + * Retrieves the type of technology used by a monitor. + * This function does not support every display technology. If a monitor uses a display technology that is + * supported by this function, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_TECHNOLOGY_TYPE + * flag. If that flag is absent, the GetMonitorTechnologyType function fails. + * Some monitor technologies do not support certain monitor configuration functions. For example, + * the DegaussMonitor function is supported only for cathode ray tube (CRT) monitors. To find out whether a + * specific function is supported, call GetMonitorCapabilities. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param pdtyDisplayTechnologyType Receives the technology type as defined in {@link HighLevelMonitorConfigurationAPI.MC_DISPLAY_TECHNOLOGY_TYPE}. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetMonitorTechnologyType(HANDLE hMonitor, MC_DISPLAY_TECHNOLOGY_TYPE.ByReference pdtyDisplayTechnologyType); + + /****************************************************************************** + Monitor image calibration functions + ******************************************************************************/ + + /** + * Retrieves a monitor's minimum, maximum, and current brightness settings. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_BRIGHTNESS flag. + * This function takes about 40 milliseconds to return. The brightness setting is a continuous monitor setting. + * @param hMonitor Handle to a physical monitor + * @param pdwMinimumBrightness Receives the monitor's minimum brightness. + * @param pdwCurrentBrightness Receives the monitor's current brightness. + * @param pdwMaximumBrightness Receives the monitor's maximum brightness. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetMonitorBrightness(HANDLE hMonitor, DWORDByReference pdwMinimumBrightness, + DWORDByReference pdwCurrentBrightness, DWORDByReference pdwMaximumBrightness); + + /** + * Retrieves a monitor's minimum, maximum, and current contrast settings. + * @param hMonitor Handle to a physical monitor. + * @param pdwMinimumContrast Receives the monitor's minimum contrast. + * @param pdwCurrentContrast Receives the monitor's current contrast. + * @param pdwMaximumContrast Receives the monitor's maximum contrast. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetMonitorContrast(HANDLE hMonitor, DWORDByReference pdwMinimumContrast, DWORDByReference pdwCurrentContrast, + DWORDByReference pdwMaximumContrast); + + /** + * Retrieves a monitor's current color temperature. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_COLOR_TEMPERATURE flag. + * This function takes between 0 and 80 milliseconds to return. + * @param hMonitor Handle to a physical monitor. + * @param pctCurrentColorTemperature Receives the monitor's current color temperature. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature); + + /** + * Retrieves a monitor's red, green, or blue drive value. + *

    + * Drive settings are generally used to adjust the monitor's white point. Drive and black level are different + * names for the same monitor setting. If this function is supported, the GetMonitorCapabilities function returns + * the MC_CAPS_RED_GREEN_BLUE_DRIVE flag. + * @param hMonitor Handle to a physical monitor. + * @param dtDriveType A member of the MC_DRIVE_TYPE enumeration, specifying whether to retrieve the red, green, or blue drive value. + * @param pdwMinimumDrive Receives the minimum red, green, or blue drive value. + * @param pdwCurrentDrive Receives the current red, green, or blue drive value. + * @param pdwMaximumDrive Receives the maximum red, green, or blue drive value. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, DWORDByReference pdwMinimumDrive, + DWORDByReference pdwCurrentDrive, DWORDByReference pdwMaximumDrive); + + /** + * Retrieves a monitor's red, green, or blue gain value. + *

    + * Gain settings are generally used to adjust the monitor's white point. If this function is supported, the + * GetMonitorCapabilities function returns the MC_CAPS_RED_GREEN_BLUE_GAIN flag. This function takes about 40 milliseconds to return. + * The gain settings are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. + * @param gtGainType A member of the MC_GAIN_TYPE enumeration, specifying whether to retrieve the red, green, or blue gain value. + * @param pdwMinimumGain Receives the minimum red, green, or blue gain value. + * @param pdwCurrentGain Receives the current red, green, or blue gain value. + * @param pdwMaximumGain Receives the maximum red, green, or blue gain value. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, DWORDByReference pdwMinimumGain, + DWORDByReference pdwCurrentGain, DWORDByReference pdwMaximumGain); + + /** + * Sets a monitor's brightness value. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_BRIGHTNESS flag. + * This function takes about 50 milliseconds to return. + * The brightness setting is a continuous monitor setting. + * @param hMonitor Handle to a physical monitor. + * @param dwNewBrightness Brightness value. To get the monitor's minimum and maximum brightness values, call GetMonitorBrightness. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorBrightness(HANDLE hMonitor, int dwNewBrightness); + + /** + * Sets a monitor's contrast value. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_CONTRAST flag. + * This function takes about 50 milliseconds to return. The brightness setting is a continuous monitor setting. + * @param hMonitor Handle to a physical monitor. + * @param dwNewContrast Contrast value. To get the monitor's minimum and maximum contrast values, call GetMonitorContrast. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorContrast(HANDLE hMonitor, int dwNewContrast); + + /** + * Sets a monitor's color temperature. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_COLOR_TEMPERATURE flag. + * The GetMonitorCapabilities function also returns the range of color temperatures that the monitor supports. + * The ctCurrentColorTemperature parameter must correspond to one of these values. Changing the color temperature + * changes the monitor's white point. It can also change the current drive and gain settings. To get the new drive + * and gain settings, call GetMonitorRedGreenOrBlueDrive and GetMonitorRedGreenOrBlueGain, respectively. + * This function takes from 50 to 90 milliseconds to return. + * @param hMonitor Handle to a physical monitor. + * @param ctCurrentColorTemperature Color temperature, specified as a member of the MC_COLOR_TEMPERATURE enumeration. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE ctCurrentColorTemperature); + + /** + * Sets a monitor's red, green, or blue drive value. + *

    + * Drive settings are generally used to adjust the + * monitor's white point. Drive and black level are different names for the same monitor setting. If this function + * is supported, the GetMonitorCapabilities function returns the MC_CAPS_RED_GREEN_BLUE_DRIVE flag. This function + * takes about 50 milliseconds to return. Changing the drive settings can change the color temperature. To get the + * new color temperature, call GetMonitorColorTemperature. The drive settings are continuous monitor settings + * @param hMonitor Handle to a physical monitor. + * @param dtDriveType A member of the MC_DRIVE_TYPE enumeration, specifying whether to set the red, green, or blue + * drive value. + * @param dwNewDrive Red, green, or blue drive value. To get the monitor's minimum and maximum drive values, call + * GetMonitorRedGreenOrBlueDrive. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, int dwNewDrive); + + /** + * Sets a monitor's red, green, or blue gain value. + *

    + * Gain settings are generally used to adjust the + * monitor's white point. If this function is supported, the GetMonitorCapabilities function returns the + * MC_CAPS_RED_GREEN_BLUE_GAIN flag. This function takes about 50 milliseconds to return. Changing the gain settings + * can change the color temperature. To get the new color temperature, call GetMonitorColorTemperature. The gain + * settings are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. + * @param gtGainType A member of the MC_GAIN_TYPE enumeration, specifying whether to set the red, green, or blue + * gain. + * @param dwNewGain Red, green, or blue gain value. To get the monitor's minimum and maximum gain values, call + * GetMonitorRedGreenOrBlueGain. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL SetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, int dwNewGain); + + /** + * Degausses a monitor. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DEGAUSS flag. Degaussing + * is supported only by cathode ray tube (CRT) monitors. This function takes about 50 milliseconds to return. This + * function should not be called frequently, because calling it frequently will not noticeably improve the monitor's + * image quality or color fidelity. + * @param hMonitor Handle to a physical monitor. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL DegaussMonitor(HANDLE hMonitor); + + /****************************************************************************** + * Monitor image size and position calibration functions + ******************************************************************************/ + + /** + * Retrieves a monitor's minimum, maximum, and current width or height. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_SIZE flag. + * This function takes about 40 milliseconds to return. The width and height settings are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param stSizeType A member of the MC_SIZE_TYPE enumeration, specifying whether to retrieve the width or the height. + * @param pdwMinimumWidthOrHeight Receives the minimum width or height. + * @param pdwCurrentWidthOrHeight Receives the current width or height. + * @param pdwMaximumWidthOrHeight Receives the maximum width or height. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, DWORDByReference pdwMinimumWidthOrHeight, + DWORDByReference pdwCurrentWidthOrHeight, DWORDByReference pdwMaximumWidthOrHeight); + + /** + * Retrieves a monitor's minimum, maximum, and current horizontal or vertical position. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_POSITION flag. + * This function takes about 40 milliseconds to return. The horizontal and vertical position are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param ptPositionType A member of the MC_POSITION_TYPE enumeration, specifying whether to retrieve the horizontal position or the vertical position. + * @param pdwMinimumPosition Receives the minimum horizontal or vertical position. + * @param pdwCurrentPosition Receives the current horizontal or vertical position. + * @param pdwMaximumPosition Receives the maximum horizontal or vertical position. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, + DWORDByReference pdwMinimumPosition, DWORDByReference pdwCurrentPosition, + DWORDByReference pdwMaximumPosition); + + /** + * Sets the width or height of a monitor's display area. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_SIZE flag. + * This function takes about 50 milliseconds to return. The width and height settings are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param stSizeType A member of the MC_SIZE_TYPE enumeration, specifying whether to set the width or the height. + * @param dwNewDisplayAreaWidthOrHeight Display area width or height. To get the minimum and maximum width and height, + * call GetMonitorDisplayAreaSize. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, int dwNewDisplayAreaWidthOrHeight); + + /** + * Sets the horizontal or vertical position of a monitor's display area. + *

    + * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_POSITION flag. + * This function takes about 50 milliseconds to return. The horizontal and vertical position are continuous monitor settings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param ptPositionType A member of the MC_POSITION_TYPE enumeration, specifying whether to set the horizontal position or the vertical position. + * @param dwNewPosition Horizontal or vertical position. To get the minimum and maximum position, call GetMonitorDisplayAreaPosition. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, int dwNewPosition); + + /****************************************************************************** + * Restore to defaults functions + ******************************************************************************/ + + /** + * Restores a monitor's color settings to their factory defaults. This function potentially changes the current + * value of the monitor's brightness, contrast, color temperature, drive, and gain. The current value of each + * setting is changed to its factory default. The default settings depend on the manufacturer. This function can + * also change the range of supported values for each of these settings. The function does not enable any monitor + * settings that were disabled. If this function is supported, the GetMonitorCapabilities function returns the + * MC_CAPS_RESTORE_FACTORY_COLOR_DEFAULTS flag. This function takes about 5 seconds to return. This function might + * reset monitor settings that are not accessible through the high-level monitor configuration functions. Whether + * this occurs depends on the specific model of monitor. The following settings are not affected by this function: + *
  • Display area size
  • + *
  • Display area position
  • + *
  • Capabilities flags
  • + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL RestoreMonitorFactoryColorDefaults(HANDLE hMonitor); + + /** + * Restores a monitor's settings to their factory defaults. This function restores all of the settings that are + * supported by the high-level monitor configuration functions. It might also restore settings that are available + * only through the low-level functions and are not supported by the high-level functions. The current value of each + * setting is changed to its factory default. The exact settings that change, and the default values of those + * settings, depend on the manufacturer. This function can also change the range of supported values for some + * settings. If this function is supported, the GetMonitorCapabilities function returns the + * MC_CAPS_RESTORE_FACTORY_DEFAULTS flag. This function takes about 5 seconds to return. If GetMonitorCapabilities + * returns the MC_RESTORE_FACTORY_DEFAULTS_ENABLES_MONITOR_SETTINGS flag, this function also enables all of the + * monitor settings that are supported by the high-level functions. It is sometimes possible for an application to + * disable certain settings by calling the low-level functions. It is also possible for the user to disable certain + * settings by adjusting settings on the monitor's physical control panel. If that happens, the setting can only be + * re-enabled through the control panel or by calling RestoreMonitorFactoryDefaults. It is not possible to disable + * any settings by using the high-level functions. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL RestoreMonitorFactoryDefaults(HANDLE hMonitor); + + // LowLevelMonitorConfigurationAPI.h + + /** + * Retrieves the current value, maximum value, and code type of a Virtual Control Panel (VCP) code for a monitor. + * This function corresponds to the "Get VCP Feature & VCP Feature Reply" command from the Display Data + * Channel Command Interface (DDC/CI) standard. Vendor-specific VCP codes can be used with this function. + * This function takes about 40 milliseconds to return. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param bVCPCode VCP code to query. The VCP codes are Include the VESA Monitor Control Command Set (MCCS) + * standard, versions 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a + * vendor-specific code. It should not be a table control code. + * @param pvct Receives the VCP code type, as a member of the MC_VCP_CODE_TYPE enumeration. This parameter can be NULL. + * @param pdwCurrentValue Receives the current value of the VCP code. This parameter can be NULL. + * @param pdwMaximumValue If bVCPCode specifies a continuous VCP code, this parameter receives the maximum value of + * the VCP code. If bVCPCode specifies a non-continuous VCP code, the value received in this parameter + * is undefined. This parameter can be NULL. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetVCPFeatureAndVCPFeatureReply(HANDLE hMonitor, BYTE bVCPCode, MC_VCP_CODE_TYPE.ByReference pvct, + DWORDByReference pdwCurrentValue, DWORDByReference pdwMaximumValue); + + /** + * Sets the value of a Virtual Control Panel (VCP) code for a monitor. This function corresponds to the + * "Set VCP Feature" command from the Display Data Channel Command Interface (DDC/CI) standard. This function takes + * about 50 milliseconds to return. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param bVCPCode VCP code to set. The VCP codes are defined in the VESA Monitor Control Command Set (MCCS) + * standard, version 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a + * vendor-specific code. It should not be a table control code. + * @param dwNewValue Value of the VCP code. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SetVCPFeature(HANDLE hMonitor, BYTE bVCPCode, DWORD dwNewValue); + + /** + * Saves the current monitor settings to the display's nonvolatile storage. This function corresponds to the + * "Save Current Settings" function from the Display Data Channel Command Interface (DDC/CI) standard. This function + * takes about 200 milliseconds to return. This low-level function is identical to the high-level function + * SaveCurrentMonitorSettings. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL SaveCurrentSettings(HANDLE hMonitor); + + /** + * Retrieves the length of a monitor's capabilities string. + * This function usually returns quickly, but sometimes it can take several seconds to complete. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param pdwCapabilitiesStringLengthInCharacters Receives the length of the capabilities string, in characters, including the terminating null character. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetCapabilitiesStringLength(HANDLE hMonitor, DWORDByReference pdwCapabilitiesStringLengthInCharacters); + + /** + * Retrieves a string describing a monitor's capabilities. This function corresponds to the + * "Capabilities Request & Capabilities Reply" command from the Display Data Channel Command Interface (DDC/CI) + * standard. For more information about the capabilities string, refer to the DDC/CI standard. This function usually + * returns quickly, but sometimes it can take several seconds to complete. You can update a monitor's capabilities + * string by adding an AddReg directive to the monitor's INF file. Add a registry key named "CapabilitiesString" to + * the monitor's driver key. The value of the registry key is the capabilities string. The registry data type is + * REG_SZ. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param pszASCIICapabilitiesString Pointer to a buffer that receives the monitor's capabilities string. The caller + * must allocate this buffer. To get the size of the string, call GetCapabilitiesStringLength. The capabilities + * string is always an ASCII string. The buffer must include space for the terminating null character. + * @param dwCapabilitiesStringLengthInCharacters Size of pszASCIICapabilitiesString in characters, including the + * terminating null character. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL CapabilitiesRequestAndCapabilitiesReply(HANDLE hMonitor, LPSTR pszASCIICapabilitiesString, + DWORD dwCapabilitiesStringLengthInCharacters); + + /** + * Retrieves a monitor's horizontal and vertical synchronization frequencies. + * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR + * @param pmtrMonitorTimingReport Pointer to an MC_TIMING_REPORT structure that receives the timing information. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. + */ + BOOL GetTimingReport(HANDLE hMonitor, MC_TIMING_REPORT pmtrMonitorTimingReport); + + // PhysicalMonitorEnumerationAPI.h + + /****************************************************************************** + * Physical Monitor Enumeration Functions + ******************************************************************************/ + + /** + * Retrieves the number of physical monitors associated with an HMONITOR monitor handle. Call this function before + * calling GetPhysicalMonitorsFromHMONITOR. + * @param hMonitor A monitor handle. Monitor handles are returned by several Multiple Display Monitor functions, + * including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI). + * @param pdwNumberOfPhysicalMonitors Receives the number of physical monitors associated with the monitor handle. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetNumberOfPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, DWORDByReference pdwNumberOfPhysicalMonitors); + + // HRESULT GetNumberOfPhysicalMonitorsFromIDirect3DDevice9 + // ( + // IDirect3DDevice9* pDirect3DDevice9, + // DWORDByReference pdwNumberOfPhysicalMonitors + // ); + + /** + * Retrieves the physical monitors associated with an HMONITOR monitor handle. A single HMONITOR handle can be + * associated with more than one physical monitor. This function returns a handle and a text description for each + * physical monitor. When you are done using the monitor handles, close them by passing the pPhysicalMonitorArray + * array to the DestroyPhysicalMonitors function. + * @param hMonitor A monitor handle. Monitor handles are returned by several Multiple Display Monitor functions, + * including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI). + * @param dwPhysicalMonitorArraySize Number of elements in pPhysicalMonitorArray. To get the required size of the + * array, call GetNumberOfPhysicalMonitorsFromHMONITOR. + * @param pPhysicalMonitorArray Pointer to an array of PHYSICAL_MONITOR structures. The caller must allocate the + * array. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL GetPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, int dwPhysicalMonitorArraySize, + PHYSICAL_MONITOR[] pPhysicalMonitorArray); + + // HRESULT GetPhysicalMonitorsFromIDirect3DDevice9 + // ( + // __in IDirect3DDevice9* pDirect3DDevice9, + // __in DWORD dwPhysicalMonitorArraySize, + // __out_ecount(dwPhysicalMonitorArraySize) LPPHYSICAL_MONITOR pPhysicalMonitorArray + // ); + + /** + * Closes a handle to a physical monitor. + * Call this function to close a monitor handle obtained from the GetPhysicalMonitorsFromHMONITOR + * @param hMonitor Handle to a physical monitor. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL DestroyPhysicalMonitor(HANDLE hMonitor); + + /** + * Closes an array of physical monitor handles. + * Call this function to close an array of monitor handles obtained from the GetPhysicalMonitorsFromHMONITOR + * @param dwPhysicalMonitorArraySize Number of elements in the pPhysicalMonitorArray array. + * @param pPhysicalMonitorArray Pointer to an array of PHYSICAL_MONITOR structures. + * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE + */ + BOOL DestroyPhysicalMonitors(int dwPhysicalMonitorArraySize, PHYSICAL_MONITOR[] pPhysicalMonitorArray); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/HighLevelMonitorConfigurationAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/HighLevelMonitorConfigurationAPI.java index a755556675..2519260b82 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/HighLevelMonitorConfigurationAPI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/HighLevelMonitorConfigurationAPI.java @@ -24,413 +24,413 @@ */ public interface HighLevelMonitorConfigurationAPI { - /** - * Monitor capabilities - retrieved by GetMonitorCapabilities - */ - enum MC_CAPS implements FlagEnum - { - /** - * The monitor does not support any monitor settings. - */ - MC_CAPS_NONE (0x00000000), - - /** - * The monitor supports the GetMonitorTechnologyType function. - */ - MC_CAPS_MONITOR_TECHNOLOGY_TYPE (0x00000001), - - /** - * The monitor supports the GetMonitorBrightness and SetMonitorBrightness functions. - */ - MC_CAPS_BRIGHTNESS (0x00000002), - - /** - * The monitor supports the GetMonitorContrast and SetMonitorContrast functions. - */ - MC_CAPS_CONTRAST (0x00000004), - - /** - * The monitor supports the GetMonitorColorTemperature and SetMonitorColorTemperature functions. - */ - MC_CAPS_COLOR_TEMPERATURE (0x00000008), - - /** - * The monitor supports the GetMonitorRedGreenOrBlueGain and SetMonitorRedGreenOrBlueGain functions. - */ - MC_CAPS_RED_GREEN_BLUE_GAIN (0x00000010), - - /** - * The monitor supports the GetMonitorRedGreenOrBlueDrive and SetMonitorRedGreenOrBlueDrive functions. - */ - MC_CAPS_RED_GREEN_BLUE_DRIVE (0x00000020), - - /** - * The monitor supports the DegaussMonitor function. - */ - MC_CAPS_DEGAUSS (0x00000040), - - /** - * The monitor supports the GetMonitorDisplayAreaPosition and SetMonitorDisplayAreaPosition functions. - */ - MC_CAPS_DISPLAY_AREA_POSITION (0x00000080), - - /** - * The monitor supports the GetMonitorDisplayAreaSize and SetMonitorDisplayAreaSize functions. - */ - MC_CAPS_DISPLAY_AREA_SIZE (0x00000100), - - /** - * The monitor supports the RestoreMonitorFactoryDefaults function. - */ - MC_CAPS_RESTORE_FACTORY_DEFAULTS (0x00000400), - - /** - * The monitor supports the RestoreMonitorFactoryColorDefaults function. - */ - MC_CAPS_RESTORE_FACTORY_COLOR_DEFAULTS (0x00000800), - - /** - * If this flag is present, calling the RestoreMonitorFactoryDefaults function enables all of - * the monitor settings used by the high-level monitor configuration functions. For more - * information, see the Remarks section in RestoreMonitorFactoryDefaults. - */ - MC_RESTORE_FACTORY_DEFAULTS_ENABLES_MONITOR_SETTINGS (0x00001000); - - private int flag; - - MC_CAPS(int flag) - { - this.flag = flag; - } - - @Override - public int getFlag() - { - return flag; - } - } - - /** - * Monitor capabilities - retrieved by GetMonitorCapabilities - */ - enum MC_SUPPORTED_COLOR_TEMPERATURE implements FlagEnum - { - /** - * No color temperatures are supported. - */ - MC_SUPPORTED_COLOR_TEMPERATURE_NONE (0x00000000), - - /** - * The monitor supports 4,000 kelvins (K) color temperature. - */ - MC_SUPPORTED_COLOR_TEMPERATURE_4000K (0x00000001), - - /** - * The monitor supports 5,000 K color temperature. - */ - MC_SUPPORTED_COLOR_TEMPERATURE_5000K (0x00000002), - - /** - * The monitor supports 6,500 K color temperature. - */ - MC_SUPPORTED_COLOR_TEMPERATURE_6500K (0x00000004), - - /** - * The monitor supports 7,500 K color temperature. - */ - MC_SUPPORTED_COLOR_TEMPERATURE_7500K (0x00000008), - - /** - * The monitor supports 8,200 K color temperature. - */ - MC_SUPPORTED_COLOR_TEMPERATURE_8200K (0x00000010), - - /** - * The monitor supports 9,300 K color temperature. - */ - MC_SUPPORTED_COLOR_TEMPERATURE_9300K (0x00000020), - - /** - * The monitor supports 10,000 K color temperature. - */ - MC_SUPPORTED_COLOR_TEMPERATURE_10000K (0x00000040), - - /** - * The monitor supports 11,500 K color temperature. - */ - MC_SUPPORTED_COLOR_TEMPERATURE_11500K (0x00000080); - - private int flag; - - MC_SUPPORTED_COLOR_TEMPERATURE(int flag) - { - this.flag = flag; - } - - @Override - public int getFlag() - { - return flag; - } - } - - // ****************************************************************************** - // Enumerations - // ****************************************************************************** - - /** - * Identifies monitor display technologies. - */ - public enum MC_DISPLAY_TECHNOLOGY_TYPE - { - /** - * Shadow-mask cathode ray tube (CRT). - */ - MC_SHADOW_MASK_CATHODE_RAY_TUBE, - - /** - * Aperture-grill CRT. - */ - MC_APERTURE_GRILL_CATHODE_RAY_TUBE, - - /** - * Thin-film transistor (TFT) display. - */ - MC_THIN_FILM_TRANSISTOR, - - /** - * Liquid crystal on silicon (LCOS) display. - */ - MC_LIQUID_CRYSTAL_ON_SILICON, - - /** - * Plasma display. - */ - MC_PLASMA, - - /** - * Organic light emitting diode (LED) display. - */ - MC_ORGANIC_LIGHT_EMITTING_DIODE, - - /** - * Electroluminescent display. - */ - MC_ELECTROLUMINESCENT, - - /** - * Microelectromechanical display. - */ - MC_MICROELECTROMECHANICAL, - - /** - * Field emission device (FED) display. - */ - MC_FIELD_EMISSION_DEVICE; - - /** - * Defines a Reference to the enum - */ - public static class ByReference extends com.sun.jna.ptr.ByReference { - - /** - * Create an uninitialized reference - */ - public ByReference() { - super(4); - getPointer().setInt(0, EnumUtils.UNINITIALIZED); - } - - /** - * Instantiates a new reference. - * @param value the value - */ - public ByReference(MC_DISPLAY_TECHNOLOGY_TYPE value) { - super(4); - setValue(value); - } - - /** - * Sets the value. - * @param value the new value - */ - public void setValue(MC_DISPLAY_TECHNOLOGY_TYPE value) { - getPointer().setInt(0, EnumUtils.toInteger(value)); - } - - /** - * Gets the value. - * @return the value - */ - public MC_DISPLAY_TECHNOLOGY_TYPE getValue() { - return EnumUtils.fromInteger(getPointer().getInt(0), MC_DISPLAY_TECHNOLOGY_TYPE.class); - } - } - } - - /** - * Specifies whether to set or get a monitor's red, green, or blue drive. - */ - public enum MC_DRIVE_TYPE - { - /** - * Red drive - */ - MC_RED_DRIVE, - - /** - * Green drive - */ - MC_GREEN_DRIVE, - - /** - * Blue drive - */ - MC_BLUE_DRIVE - } - - /** - * Specifies whether to get or set a monitor's red, green, or blue gain. - */ - public enum MC_GAIN_TYPE - { - /** - * Red gain - */ - MC_RED_GAIN, - - /** - * Green gain - */ - MC_GREEN_GAIN, - - /** - * Blue gain - */ - MC_BLUE_GAIN - } - - /** - * Specifies whether to get or set the vertical or horizontal position of a monitor's display area. - */ - public enum MC_POSITION_TYPE - { - /** - * Horizontal position - */ - MC_HORIZONTAL_POSITION, - - /** - * Vertival position - */ - MC_VERTICAL_POSITION - - } - - /** - * Specifies whether to get or set the width or height of a monitor's display area. - */ - public enum MC_SIZE_TYPE - { - /** - * Width - */ - MC_WIDTH, - - /** - * Height - */ - MC_HEIGHT - - } - - /** - * Describes a monitor's color temperature. - */ - public enum MC_COLOR_TEMPERATURE - { - /** - * Unknown temperature. - */ - MC_COLOR_TEMPERATURE_UNKNOWN, - - /** - * 4,000 kelvins (K). - */ - MC_COLOR_TEMPERATURE_4000K, - - /** - * 5,000 kelvins (K). - */ - MC_COLOR_TEMPERATURE_5000K, - - /** - * 6,500 kelvins (K). - */ - MC_COLOR_TEMPERATURE_6500K, - - /** - * 7,500 kelvins (K). - */ - MC_COLOR_TEMPERATURE_7500K, - - /** - * 8,200 kelvins (K). - */ - MC_COLOR_TEMPERATURE_8200K, - - /** - * 9,300 kelvins (K). - */ - MC_COLOR_TEMPERATURE_9300K, - - /** - * 10,000 kelvins (K). - */ - MC_COLOR_TEMPERATURE_10000K, - - /** - * 11,500 kelvins (K). - */ - MC_COLOR_TEMPERATURE_11500K; - - /** - * Defines a Reference to the enum - */ - public static class ByReference extends com.sun.jna.ptr.ByReference { - - /** - * Create an uninitialized reference - */ - public ByReference() { - super(4); - getPointer().setInt(0, EnumUtils.UNINITIALIZED); - } - - /** - * Instantiates a new reference. - * @param value the value - */ - public ByReference(MC_COLOR_TEMPERATURE value) { - super(4); - setValue(value); - } - - /** - * Sets the value. - * @param value the new value - */ - public void setValue(MC_COLOR_TEMPERATURE value) { - getPointer().setInt(0, EnumUtils.toInteger(value)); - } - - /** - * Gets the value. - * @return the value - */ - public MC_COLOR_TEMPERATURE getValue() { - return EnumUtils.fromInteger(getPointer().getInt(0), MC_COLOR_TEMPERATURE.class); - } - } - } + /** + * Monitor capabilities - retrieved by GetMonitorCapabilities + */ + enum MC_CAPS implements FlagEnum + { + /** + * The monitor does not support any monitor settings. + */ + MC_CAPS_NONE (0x00000000), + + /** + * The monitor supports the GetMonitorTechnologyType function. + */ + MC_CAPS_MONITOR_TECHNOLOGY_TYPE (0x00000001), + + /** + * The monitor supports the GetMonitorBrightness and SetMonitorBrightness functions. + */ + MC_CAPS_BRIGHTNESS (0x00000002), + + /** + * The monitor supports the GetMonitorContrast and SetMonitorContrast functions. + */ + MC_CAPS_CONTRAST (0x00000004), + + /** + * The monitor supports the GetMonitorColorTemperature and SetMonitorColorTemperature functions. + */ + MC_CAPS_COLOR_TEMPERATURE (0x00000008), + + /** + * The monitor supports the GetMonitorRedGreenOrBlueGain and SetMonitorRedGreenOrBlueGain functions. + */ + MC_CAPS_RED_GREEN_BLUE_GAIN (0x00000010), + + /** + * The monitor supports the GetMonitorRedGreenOrBlueDrive and SetMonitorRedGreenOrBlueDrive functions. + */ + MC_CAPS_RED_GREEN_BLUE_DRIVE (0x00000020), + + /** + * The monitor supports the DegaussMonitor function. + */ + MC_CAPS_DEGAUSS (0x00000040), + + /** + * The monitor supports the GetMonitorDisplayAreaPosition and SetMonitorDisplayAreaPosition functions. + */ + MC_CAPS_DISPLAY_AREA_POSITION (0x00000080), + + /** + * The monitor supports the GetMonitorDisplayAreaSize and SetMonitorDisplayAreaSize functions. + */ + MC_CAPS_DISPLAY_AREA_SIZE (0x00000100), + + /** + * The monitor supports the RestoreMonitorFactoryDefaults function. + */ + MC_CAPS_RESTORE_FACTORY_DEFAULTS (0x00000400), + + /** + * The monitor supports the RestoreMonitorFactoryColorDefaults function. + */ + MC_CAPS_RESTORE_FACTORY_COLOR_DEFAULTS (0x00000800), + + /** + * If this flag is present, calling the RestoreMonitorFactoryDefaults function enables all of + * the monitor settings used by the high-level monitor configuration functions. For more + * information, see the Remarks section in RestoreMonitorFactoryDefaults. + */ + MC_RESTORE_FACTORY_DEFAULTS_ENABLES_MONITOR_SETTINGS (0x00001000); + + private int flag; + + MC_CAPS(int flag) + { + this.flag = flag; + } + + @Override + public int getFlag() + { + return flag; + } + } + + /** + * Monitor capabilities - retrieved by GetMonitorCapabilities + */ + enum MC_SUPPORTED_COLOR_TEMPERATURE implements FlagEnum + { + /** + * No color temperatures are supported. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_NONE (0x00000000), + + /** + * The monitor supports 4,000 kelvins (K) color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_4000K (0x00000001), + + /** + * The monitor supports 5,000 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_5000K (0x00000002), + + /** + * The monitor supports 6,500 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_6500K (0x00000004), + + /** + * The monitor supports 7,500 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_7500K (0x00000008), + + /** + * The monitor supports 8,200 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_8200K (0x00000010), + + /** + * The monitor supports 9,300 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_9300K (0x00000020), + + /** + * The monitor supports 10,000 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_10000K (0x00000040), + + /** + * The monitor supports 11,500 K color temperature. + */ + MC_SUPPORTED_COLOR_TEMPERATURE_11500K (0x00000080); + + private int flag; + + MC_SUPPORTED_COLOR_TEMPERATURE(int flag) + { + this.flag = flag; + } + + @Override + public int getFlag() + { + return flag; + } + } + + // ****************************************************************************** + // Enumerations + // ****************************************************************************** + + /** + * Identifies monitor display technologies. + */ + public enum MC_DISPLAY_TECHNOLOGY_TYPE + { + /** + * Shadow-mask cathode ray tube (CRT). + */ + MC_SHADOW_MASK_CATHODE_RAY_TUBE, + + /** + * Aperture-grill CRT. + */ + MC_APERTURE_GRILL_CATHODE_RAY_TUBE, + + /** + * Thin-film transistor (TFT) display. + */ + MC_THIN_FILM_TRANSISTOR, + + /** + * Liquid crystal on silicon (LCOS) display. + */ + MC_LIQUID_CRYSTAL_ON_SILICON, + + /** + * Plasma display. + */ + MC_PLASMA, + + /** + * Organic light emitting diode (LED) display. + */ + MC_ORGANIC_LIGHT_EMITTING_DIODE, + + /** + * Electroluminescent display. + */ + MC_ELECTROLUMINESCENT, + + /** + * Microelectromechanical display. + */ + MC_MICROELECTROMECHANICAL, + + /** + * Field emission device (FED) display. + */ + MC_FIELD_EMISSION_DEVICE; + + /** + * Defines a Reference to the enum + */ + public static class ByReference extends com.sun.jna.ptr.ByReference { + + /** + * Create an uninitialized reference + */ + public ByReference() { + super(4); + getPointer().setInt(0, EnumUtils.UNINITIALIZED); + } + + /** + * Instantiates a new reference. + * @param value the value + */ + public ByReference(MC_DISPLAY_TECHNOLOGY_TYPE value) { + super(4); + setValue(value); + } + + /** + * Sets the value. + * @param value the new value + */ + public void setValue(MC_DISPLAY_TECHNOLOGY_TYPE value) { + getPointer().setInt(0, EnumUtils.toInteger(value)); + } + + /** + * Gets the value. + * @return the value + */ + public MC_DISPLAY_TECHNOLOGY_TYPE getValue() { + return EnumUtils.fromInteger(getPointer().getInt(0), MC_DISPLAY_TECHNOLOGY_TYPE.class); + } + } + } + + /** + * Specifies whether to set or get a monitor's red, green, or blue drive. + */ + public enum MC_DRIVE_TYPE + { + /** + * Red drive + */ + MC_RED_DRIVE, + + /** + * Green drive + */ + MC_GREEN_DRIVE, + + /** + * Blue drive + */ + MC_BLUE_DRIVE + } + + /** + * Specifies whether to get or set a monitor's red, green, or blue gain. + */ + public enum MC_GAIN_TYPE + { + /** + * Red gain + */ + MC_RED_GAIN, + + /** + * Green gain + */ + MC_GREEN_GAIN, + + /** + * Blue gain + */ + MC_BLUE_GAIN + } + + /** + * Specifies whether to get or set the vertical or horizontal position of a monitor's display area. + */ + public enum MC_POSITION_TYPE + { + /** + * Horizontal position + */ + MC_HORIZONTAL_POSITION, + + /** + * Vertical position + */ + MC_VERTICAL_POSITION + + } + + /** + * Specifies whether to get or set the width or height of a monitor's display area. + */ + public enum MC_SIZE_TYPE + { + /** + * Width + */ + MC_WIDTH, + + /** + * Height + */ + MC_HEIGHT + + } + + /** + * Describes a monitor's color temperature. + */ + public enum MC_COLOR_TEMPERATURE + { + /** + * Unknown temperature. + */ + MC_COLOR_TEMPERATURE_UNKNOWN, + + /** + * 4,000 kelvins (K). + */ + MC_COLOR_TEMPERATURE_4000K, + + /** + * 5,000 kelvins (K). + */ + MC_COLOR_TEMPERATURE_5000K, + + /** + * 6,500 kelvins (K). + */ + MC_COLOR_TEMPERATURE_6500K, + + /** + * 7,500 kelvins (K). + */ + MC_COLOR_TEMPERATURE_7500K, + + /** + * 8,200 kelvins (K). + */ + MC_COLOR_TEMPERATURE_8200K, + + /** + * 9,300 kelvins (K). + */ + MC_COLOR_TEMPERATURE_9300K, + + /** + * 10,000 kelvins (K). + */ + MC_COLOR_TEMPERATURE_10000K, + + /** + * 11,500 kelvins (K). + */ + MC_COLOR_TEMPERATURE_11500K; + + /** + * Defines a Reference to the enum + */ + public static class ByReference extends com.sun.jna.ptr.ByReference { + + /** + * Create an uninitialized reference + */ + public ByReference() { + super(4); + getPointer().setInt(0, EnumUtils.UNINITIALIZED); + } + + /** + * Instantiates a new reference. + * @param value the value + */ + public ByReference(MC_COLOR_TEMPERATURE value) { + super(4); + setValue(value); + } + + /** + * Sets the value. + * @param value the new value + */ + public void setValue(MC_COLOR_TEMPERATURE value) { + getPointer().setInt(0, EnumUtils.toInteger(value)); + } + + /** + * Gets the value. + * @return the value + */ + public MC_COLOR_TEMPERATURE getValue() { + return EnumUtils.fromInteger(getPointer().getInt(0), MC_COLOR_TEMPERATURE.class); + } + } + } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java index 549cdff709..2882e09d0f 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java @@ -30,87 +30,87 @@ */ public interface LowLevelMonitorConfigurationAPI { - /** - * Contains information from a monitor's timing report. - */ - class MC_TIMING_REPORT extends Structure - { - /** - * The monitor's horizontal synchronization frequency in Hz. - */ - public DWORD dwHorizontalFrequencyInHZ; - - /** - * The monitor's vertical synchronization frequency in Hz. - */ - public DWORD dwVerticalFrequencyInHZ; - - /** - * Timing status byte. For more information about this value, see the Display Data Channel Command - * Interface (DDC/CI) standard. - */ - public BYTE bTimingStatusByte; - - @Override - protected List getFieldOrder() - { - return Arrays.asList("dwHorizontalFrequencyInHZ", "dwVerticalFrequencyInHZ", "bTimingStatusByte"); - } - } - - /** - * Describes a Virtual Control Panel (VCP) code type. - */ - enum MC_VCP_CODE_TYPE - { - /** - * Momentary VCP code. Sending a command of this type causes the monitor to initiate a self-timed - * operation and then revert to its original state. Examples include display tests and degaussing. - */ - MC_MOMENTARY, - - /** - * Set Parameter VCP code. Sending a command of this type changes some aspect of the monitor's operation. - */ - MC_SET_PARAMETER; - - /** - * Defines a Reference to the enum - */ - public static class ByReference extends com.sun.jna.ptr.ByReference { + /** + * Contains information from a monitor's timing report. + */ + class MC_TIMING_REPORT extends Structure + { + /** + * The monitor's horizontal synchronization frequency in Hz. + */ + public DWORD dwHorizontalFrequencyInHZ; - /** - * Create an uninitialized reference - */ - public ByReference() { - super(4); - } - - /** - * Instantiates a new reference. - * @param value the value - */ - public ByReference(MC_VCP_CODE_TYPE value) { - super(4); - setValue(value); - } + /** + * The monitor's vertical synchronization frequency in Hz. + */ + public DWORD dwVerticalFrequencyInHZ; - /** - * Sets the value. - * @param value the new value - */ - public void setValue(MC_VCP_CODE_TYPE value) { - getPointer().setInt(0, EnumUtils.toInteger(value)); - } + /** + * Timing status byte. For more information about this value, see the Display Data Channel Command + * Interface (DDC/CI) standard. + */ + public BYTE bTimingStatusByte; - /** - * Gets the value. - * @return the value - */ - public MC_VCP_CODE_TYPE getValue() { - return EnumUtils.fromInteger(getPointer().getInt(0), MC_VCP_CODE_TYPE.class); - } - } - } + @Override + protected List getFieldOrder() + { + return Arrays.asList("dwHorizontalFrequencyInHZ", "dwVerticalFrequencyInHZ", "bTimingStatusByte"); + } + } + + /** + * Describes a Virtual Control Panel (VCP) code type. + */ + enum MC_VCP_CODE_TYPE + { + /** + * Momentary VCP code. Sending a command of this type causes the monitor to initiate a self-timed + * operation and then revert to its original state. Examples include display tests and degaussing. + */ + MC_MOMENTARY, + + /** + * Set Parameter VCP code. Sending a command of this type changes some aspect of the monitor's operation. + */ + MC_SET_PARAMETER; + + /** + * Defines a Reference to the enum + */ + public static class ByReference extends com.sun.jna.ptr.ByReference { + + /** + * Create an uninitialized reference + */ + public ByReference() { + super(4); + } + + /** + * Instantiates a new reference. + * @param value the value + */ + public ByReference(MC_VCP_CODE_TYPE value) { + super(4); + setValue(value); + } + + /** + * Sets the value. + * @param value the new value + */ + public void setValue(MC_VCP_CODE_TYPE value) { + getPointer().setInt(0, EnumUtils.toInteger(value)); + } + + /** + * Gets the value. + * @return the value + */ + public MC_VCP_CODE_TYPE getValue() { + return EnumUtils.fromInteger(getPointer().getInt(0), MC_VCP_CODE_TYPE.class); + } + } + } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java index a2301ec448..bd129357d9 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java @@ -29,39 +29,39 @@ public interface PhysicalMonitorEnumerationAPI { - /****************************************************************************** + /****************************************************************************** Physical Monitor Constants - ******************************************************************************/ - - /** - * A physical monitor description is always an array of 128 characters. Some - * of the characters may not be used. - */ - final int PHYSICAL_MONITOR_DESCRIPTION_SIZE = 128; - - /****************************************************************************** - Physical Monitor Structures - ******************************************************************************/ - - /** - * Contains a handle and text description corresponding to a physical monitor. - */ - public class PHYSICAL_MONITOR extends Structure - { - /** - * Handle to the physical monitor. - */ - public HANDLE hPhysicalMonitor; - - /** - * Text description of the physical monitor (always 128 chars) - */ - public char[] szPhysicalMonitorDescription = new char[PHYSICAL_MONITOR_DESCRIPTION_SIZE]; - - @Override - protected List getFieldOrder() - { - return Arrays.asList("hPhysicalMonitor", "szPhysicalMonitorDescription"); - } - } + ******************************************************************************/ + + /** + * A physical monitor description is always an array of 128 characters. Some + * of the characters may not be used. + */ + final int PHYSICAL_MONITOR_DESCRIPTION_SIZE = 128; + + /****************************************************************************** + Physical Monitor Structures + ******************************************************************************/ + + /** + * Contains a handle and text description corresponding to a physical monitor. + */ + public class PHYSICAL_MONITOR extends Structure + { + /** + * Handle to the physical monitor. + */ + public HANDLE hPhysicalMonitor; + + /** + * Text description of the physical monitor (always 128 chars) + */ + public char[] szPhysicalMonitorDescription = new char[PHYSICAL_MONITOR_DESCRIPTION_SIZE]; + + @Override + protected List getFieldOrder() + { + return Arrays.asList("hPhysicalMonitor", "szPhysicalMonitorDescription"); + } + } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/User32.java b/contrib/platform/src/com/sun/jna/platform/win32/User32.java index bc6f891126..4c3ce26af9 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/User32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/User32.java @@ -1700,97 +1700,97 @@ HDEVNOTIFY RegisterDeviceNotification(HANDLE hRecipient, *

    */ int RegisterWindowMessage(String string); - - /** - * Retrieves a handle to the display monitor that contains a specified point. - * @param pt A POINT structure that specifies the point of interest in virtual-screen - * coordinates. - * @param dwFlags Determines the function's return value if the window does not intersect - * any display monitor. This parameter can be one of the following values. - *
  • MONITOR_DEFAULTTONEAREST
  • - *
  • MONITOR_DEFAULTTONULL
  • - *
  • MONITOR_DEFAULTTOPRIMARY
  • - * @return If the point is contained by a display monitor, the return value is an HMONITOR - * handle to that display monitor. If the point is not contained by a display monitor, - * the return value depends on the value of dwFlags. - */ - HMONITOR MonitorFromPoint(POINT pt, int dwFlags); - - /** - * Retrieves a handle to the display monitor that has the largest area of intersection with - * a specified rectangle. - * @param lprc A pointer to a RECT structure that specifies the rectangle of interest in - * virtual-screen coordinates. - * @param dwFlags Determines the function's return value if the window does not intersect - * any display monitor. This parameter can be one of the following values. - *
  • MONITOR_DEFAULTTONEAREST
  • - *
  • MONITOR_DEFAULTTONULL
  • - *
  • MONITOR_DEFAULTTOPRIMARY
  • - * @return If the rectangle intersects one or more display monitor rectangles, the return - * value is an HMONITOR handle to the display monitor that has the largest area of - * intersection with the rectangle. If the rectangle does not intersect a display - * monitor, the return value depends on the value of dwFlags. - */ - HMONITOR MonitorFromRect(RECT lprc, int dwFlags); - - /** - * Retrieves a handle to the display monitor that has the largest area of intersection with - * the bounding rectangle of a specified window. - *

    - * If the window is currently minimized, MonitorFromWindow uses the rectangle of the window - * before it was minimized. - * @param hwnd A handle to the window of interest. - * @param dwFlags Determines the function's return value if the window does not intersect - * any display monitor. This parameter can be one of the following values. - *
  • MONITOR_DEFAULTTONEAREST
  • - *
  • MONITOR_DEFAULTTONULL
  • - *
  • MONITOR_DEFAULTTOPRIMARY
  • - * @return If the window intersects one or more display monitor rectangles, the return value - * is an HMONITOR handle to the display monitor that has the largest area of - * intersection with the window. If the window does not intersect a display monitor, - * the return value depends on the value of dwFlags. - */ - HMONITOR MonitorFromWindow(HWND hwnd, int dwFlags); - - /** - * Retrieves information about a display monitor. - * @param hMonitor A handle to the display monitor of interest. - * @param lpmi A pointer to a {@link WinUser.MONITORINFO} structure that receives information about - * the specified display monitor. - * @return If the function succeeds, the return value is nonzero. If the function - * fails, the return value is zero. - */ - BOOL GetMonitorInfo(HMONITOR hMonitor, MONITORINFO lpmi); - - /** - * Retrieves information about a display monitor. - * @param hMonitor A handle to the display monitor of interest. - * @param lpmi A pointer to a {@link WinUser.MONITORINFOEX} structure that receives information about - * the specified display monitor. - * @return If the function succeeds, the return value is nonzero. If the function - * fails, the return value is zero. - */ - BOOL GetMonitorInfo(HMONITOR hMonitor, MONITORINFOEX lpmi); - - /** - * Enumerates display monitors (including invisible pseudo-monitors associated with the mirroring drivers) - * that intersect a region formed by the intersection of a specified clipping rectangle and the visible - * region of a device context. EnumDisplayMonitors calls an application-defined MonitorEnumProc callback - * function once for each monitor that is enumerated. Note that GetSystemMetrics (SM_CMONITORS) counts - * only the display monitors. - * @param hdc A handle to a display device context that defines the visible region of interest. If this - * parameter is NULL, the hdcMonitor parameter passed to the callback function will be NULL, and - * the visible region of interest is the virtual screen that encompasses all the displays on the - * desktop. - * @param lprcClip A pointer to a RECT structure that specifies a clipping rectangle. The region of - * interest is the intersection of the clipping rectangle with the visible region specified by hdc. - * If hdc is non-NULL, the coordinates of the clipping rectangle are relative to the origin of the - * hdc. If hdc is NULL, the coordinates are virtual-screen coordinates. This parameter can be NULL - * if you don't want to clip the region specified by hdc. - * @param lpfnEnum A pointer to an application-defined callback function. - * @param dwData Application-defined data that EnumDisplayMonitors passes directly to the lpfnEnum function. - * @return If the function succeeds, the return value is nonzero. If the function fails, the return value - * is zero. - */ - BOOL EnumDisplayMonitors(HDC hdc, RECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData); + + /** + * Retrieves a handle to the display monitor that contains a specified point. + * @param pt A POINT structure that specifies the point of interest in virtual-screen + * coordinates. + * @param dwFlags Determines the function's return value if the window does not intersect + * any display monitor. This parameter can be one of the following values. + *
  • MONITOR_DEFAULTTONEAREST
  • + *
  • MONITOR_DEFAULTTONULL
  • + *
  • MONITOR_DEFAULTTOPRIMARY
  • + * @return If the point is contained by a display monitor, the return value is an HMONITOR + * handle to that display monitor. If the point is not contained by a display monitor, + * the return value depends on the value of dwFlags. + */ + HMONITOR MonitorFromPoint(POINT pt, int dwFlags); + + /** + * Retrieves a handle to the display monitor that has the largest area of intersection with + * a specified rectangle. + * @param lprc A pointer to a RECT structure that specifies the rectangle of interest in + * virtual-screen coordinates. + * @param dwFlags Determines the function's return value if the window does not intersect + * any display monitor. This parameter can be one of the following values. + *
  • MONITOR_DEFAULTTONEAREST
  • + *
  • MONITOR_DEFAULTTONULL
  • + *
  • MONITOR_DEFAULTTOPRIMARY
  • + * @return If the rectangle intersects one or more display monitor rectangles, the return + * value is an HMONITOR handle to the display monitor that has the largest area of + * intersection with the rectangle. If the rectangle does not intersect a display + * monitor, the return value depends on the value of dwFlags. + */ + HMONITOR MonitorFromRect(RECT lprc, int dwFlags); + + /** + * Retrieves a handle to the display monitor that has the largest area of intersection with + * the bounding rectangle of a specified window. + *

    + * If the window is currently minimized, MonitorFromWindow uses the rectangle of the window + * before it was minimized. + * @param hwnd A handle to the window of interest. + * @param dwFlags Determines the function's return value if the window does not intersect + * any display monitor. This parameter can be one of the following values. + *
  • MONITOR_DEFAULTTONEAREST
  • + *
  • MONITOR_DEFAULTTONULL
  • + *
  • MONITOR_DEFAULTTOPRIMARY
  • + * @return If the window intersects one or more display monitor rectangles, the return value + * is an HMONITOR handle to the display monitor that has the largest area of + * intersection with the window. If the window does not intersect a display monitor, + * the return value depends on the value of dwFlags. + */ + HMONITOR MonitorFromWindow(HWND hwnd, int dwFlags); + + /** + * Retrieves information about a display monitor. + * @param hMonitor A handle to the display monitor of interest. + * @param lpmi A pointer to a {@link WinUser.MONITORINFO} structure that receives information about + * the specified display monitor. + * @return If the function succeeds, the return value is nonzero. If the function + * fails, the return value is zero. + */ + BOOL GetMonitorInfo(HMONITOR hMonitor, MONITORINFO lpmi); + + /** + * Retrieves information about a display monitor. + * @param hMonitor A handle to the display monitor of interest. + * @param lpmi A pointer to a {@link WinUser.MONITORINFOEX} structure that receives information about + * the specified display monitor. + * @return If the function succeeds, the return value is nonzero. If the function + * fails, the return value is zero. + */ + BOOL GetMonitorInfo(HMONITOR hMonitor, MONITORINFOEX lpmi); + + /** + * Enumerates display monitors (including invisible pseudo-monitors associated with the mirroring drivers) + * that intersect a region formed by the intersection of a specified clipping rectangle and the visible + * region of a device context. EnumDisplayMonitors calls an application-defined MonitorEnumProc callback + * function once for each monitor that is enumerated. Note that GetSystemMetrics (SM_CMONITORS) counts + * only the display monitors. + * @param hdc A handle to a display device context that defines the visible region of interest. If this + * parameter is NULL, the hdcMonitor parameter passed to the callback function will be NULL, and + * the visible region of interest is the virtual screen that encompasses all the displays on the + * desktop. + * @param lprcClip A pointer to a RECT structure that specifies a clipping rectangle. The region of + * interest is the intersection of the clipping rectangle with the visible region specified by hdc. + * If hdc is non-NULL, the coordinates of the clipping rectangle are relative to the origin of the + * hdc. If hdc is NULL, the coordinates are virtual-screen coordinates. This parameter can be NULL + * if you don't want to clip the region specified by hdc. + * @param lpfnEnum A pointer to an application-defined callback function. + * @param dwData Application-defined data that EnumDisplayMonitors passes directly to the lpfnEnum function. + * @return If the function succeeds, the return value is nonzero. If the function fails, the return value + * is zero. + */ + BOOL EnumDisplayMonitors(HDC hdc, RECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java index 815915c488..f6a5d44ef9 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java @@ -879,12 +879,12 @@ public interface WindowProc extends Callback { } /** - * Each physical display is represented by a monitor handle of type HMONITOR. A valid HMONITOR - * is guaranteed to be non-NULL. A physical display has the same HMONITOR as long as it is part - * of the desktop. - */ - public class HMONITOR extends HANDLE { - + * Each physical display is represented by a monitor handle of type HMONITOR. A valid HMONITOR + * is guaranteed to be non-NULL. A physical display has the same HMONITOR as long as it is part + * of the desktop. + */ + public class HMONITOR extends HANDLE { + /** * Instantiates a new HMONITOR. */ @@ -900,171 +900,171 @@ public HMONITOR(Pointer p) { super(p); } - } - - - /** - * Returns NULL. - */ - final int MONITOR_DEFAULTTONULL = 0x00000000; - - /** - * Returns a handle to the primary display monitor. - */ - final int MONITOR_DEFAULTTOPRIMARY = 0x00000001; - - /** - * Returns a handle to the display monitor that is nearest to the window. - */ - final int MONITOR_DEFAULTTONEAREST = 0x00000002; + } - /** - * This is the primary display monitor. - */ - final int MONITORINFOF_PRIMARY = 0x00000001; - /** - * Length of the device name in MONITORINFOEX - */ - final int CCHDEVICENAME = 32; + /** + * Returns NULL. + */ + final int MONITOR_DEFAULTTONULL = 0x00000000; - /** - * The MONITORINFO structure contains information about a display monitor.
    - * The {@link MyUser32#GetMonitorInfo(HMONITOR, MONITORINFO)} function stores - * information into a MONITORINFO structure

    - * The MONITORINFO structure is a subset of the MONITORINFOEX structure. - */ - public class MONITORINFO extends Structure - { - /** - * The size, in bytes, of the structure. - */ - public int cbSize = size(); - - /** - * Specifies the display monitor rectangle, expressed in virtual-screen coordinates. - * Note that if the monitor is not the primary display monitor, some of the - * rectangle's coordinates may be negative values. - */ - public RECT rcMonitor; - - /** - * Specifies the work area rectangle of the display monitor that can be used by - * applications, expressed in virtual-screen coordinates. Windows uses this rectangle - * to maximize an application on the monitor. The rest of the area in rcMonitor - * contains system windows such as the task bar and side bars. Note that if the - * monitor is not the primary display monitor, some of the rectangle's coordinates - * may be negative values. - */ - public RECT rcWork; - - /** - * The attributes of the display monitor. This member can be the following value. - *
  • MONITORINFOF_PRIMARY
  • - */ - public int dwFlags; - - @Override - protected List getFieldOrder() - { - return Arrays.asList("cbSize", "rcMonitor", "rcWork", "dwFlags"); - } - } + /** + * Returns a handle to the primary display monitor. + */ + final int MONITOR_DEFAULTTOPRIMARY = 0x00000001; - /** - * The MONITORINFOEX structure contains information about a display monitor.
    - * The {@link MyUser32#GetMonitorInfo(HMONITOR, MONITORINFOEX)} function stores - * information into a MONITORINFOEX structure

    - * The MONITORINFOEX structure is a superset of the MONITORINFO structure. - * The MONITORINFOEX structure adds a string member to contain a name for the display monitor. - */ - public class MONITORINFOEX extends Structure - { - /** - * The size, in bytes, of the structure. - */ - public int cbSize; - - /** - * Specifies the display monitor rectangle, expressed in virtual-screen coordinates. - * Note that if the monitor is not the primary display monitor, some of the - * rectangle's coordinates may be negative values. - */ - public RECT rcMonitor; - - /** - * Specifies the work area rectangle of the display monitor that can be used by - * applications, expressed in virtual-screen coordinates. Windows uses this rectangle - * to maximize an application on the monitor. The rest of the area in rcMonitor - * contains system windows such as the task bar and side bars. Note that if the - * monitor is not the primary display monitor, some of the rectangle's coordinates - * may be negative values. - */ - public RECT rcWork; - - /** - * The attributes of the display monitor. This member can be the following value. - *
  • MONITORINFOF_PRIMARY
  • - */ - public int dwFlags; - - /** - * A string that specifies the device name of the monitor being used. Most - * applications have no use for a display monitor name, and so can save some bytes - * by using a MONITORINFO structure. - */ - public char[] szDevice; - - public MONITORINFOEX() - { - szDevice = new char[CCHDEVICENAME]; - cbSize = size(); - } - - @Override - protected List getFieldOrder() - { - return Arrays.asList("cbSize", "rcMonitor", "rcWork", "dwFlags", "szDevice"); - } - } + /** + * Returns a handle to the display monitor that is nearest to the window. + */ + final int MONITOR_DEFAULTTONEAREST = 0x00000002; - /** - * An application-defined callback function that is called by the {@link MyUser32#EnumDisplayMonitors} function. - *

    - * You can use the EnumDisplayMonitors function to enumerate the set of display monitors that intersect - * the visible region of a specified device context and, optionally, a clipping rectangle. To do this, - * set the hdc parameter to a non-NULL value, and set the lprcClip parameter as needed. - *

    - * You can also use the EnumDisplayMonitors function to enumerate one or more of the display monitors on - * the desktop, without supplying a device context. To do this, set the hdc parameter of - * EnumDisplayMonitors to NULL and set the lprcClip parameter as needed. - *

    - * In all cases, EnumDisplayMonitors calls a specified MonitorEnumProc function once for each display - * monitor in the calculated enumeration set. The MonitorEnumProc function always receives a handle to - * the display monitor. If the hdc parameter of EnumDisplayMonitors is non-NULL, the MonitorEnumProc - * function also receives a handle to a device context whose color format is appropriate for the - * display monitor. You can then paint into the device context in a manner that is optimal for the - * display monitor. - */ - public interface MONITORENUMPROC extends Callback - { - /** - * @param hMonitor A handle to the display monitor. This value will always be non-NULL. - * @param hdcMonitor A handle to a device context. The device context has color attributes that are - * appropriate for the display monitor identified by hMonitor. The clipping area of the device - * context is set to the intersection of the visible region of the device context identified - * by the hdc parameter of EnumDisplayMonitors, the rectangle pointed to by the lprcClip - * parameter of EnumDisplayMonitors, and the display monitor rectangle. - * @param lprcMonitor A pointer to a RECT structure. If hdcMonitor is non-NULL, this rectangle is the - * intersection of the clipping area of the device context identified by hdcMonitor and the - * display monitor rectangle. The rectangle coordinates are device-context coordinates. - * If hdcMonitor is NULL, this rectangle is the display monitor rectangle. The rectangle - * coordinates are virtual-screen coordinates. - * @param dwData Application-defined data that EnumDisplayMonitors passes directly to the enumeration - * function. - * @return To continue the enumeration, return TRUE. To stop the enumeration, return FALSE. - */ - public int apply(HMONITOR hMonitor, HDC hdcMonitor, RECT lprcMonitor, LPARAM dwData); - } + /** + * This is the primary display monitor. + */ + final int MONITORINFOF_PRIMARY = 0x00000001; + + /** + * Length of the device name in MONITORINFOEX + */ + final int CCHDEVICENAME = 32; + + /** + * The MONITORINFO structure contains information about a display monitor.
    + * The {@link MyUser32#GetMonitorInfo(HMONITOR, MONITORINFO)} function stores + * information into a MONITORINFO structure

    + * The MONITORINFO structure is a subset of the MONITORINFOEX structure. + */ + public class MONITORINFO extends Structure + { + /** + * The size, in bytes, of the structure. + */ + public int cbSize = size(); + + /** + * Specifies the display monitor rectangle, expressed in virtual-screen coordinates. + * Note that if the monitor is not the primary display monitor, some of the + * rectangle's coordinates may be negative values. + */ + public RECT rcMonitor; + + /** + * Specifies the work area rectangle of the display monitor that can be used by + * applications, expressed in virtual-screen coordinates. Windows uses this rectangle + * to maximize an application on the monitor. The rest of the area in rcMonitor + * contains system windows such as the task bar and side bars. Note that if the + * monitor is not the primary display monitor, some of the rectangle's coordinates + * may be negative values. + */ + public RECT rcWork; + + /** + * The attributes of the display monitor. This member can be the following value. + *
  • MONITORINFOF_PRIMARY
  • + */ + public int dwFlags; + + @Override + protected List getFieldOrder() + { + return Arrays.asList("cbSize", "rcMonitor", "rcWork", "dwFlags"); + } + } + + /** + * The MONITORINFOEX structure contains information about a display monitor.
    + * The {@link MyUser32#GetMonitorInfo(HMONITOR, MONITORINFOEX)} function stores + * information into a MONITORINFOEX structure

    + * The MONITORINFOEX structure is a superset of the MONITORINFO structure. + * The MONITORINFOEX structure adds a string member to contain a name for the display monitor. + */ + public class MONITORINFOEX extends Structure + { + /** + * The size, in bytes, of the structure. + */ + public int cbSize; + + /** + * Specifies the display monitor rectangle, expressed in virtual-screen coordinates. + * Note that if the monitor is not the primary display monitor, some of the + * rectangle's coordinates may be negative values. + */ + public RECT rcMonitor; + + /** + * Specifies the work area rectangle of the display monitor that can be used by + * applications, expressed in virtual-screen coordinates. Windows uses this rectangle + * to maximize an application on the monitor. The rest of the area in rcMonitor + * contains system windows such as the task bar and side bars. Note that if the + * monitor is not the primary display monitor, some of the rectangle's coordinates + * may be negative values. + */ + public RECT rcWork; + + /** + * The attributes of the display monitor. This member can be the following value. + *
  • MONITORINFOF_PRIMARY
  • + */ + public int dwFlags; + + /** + * A string that specifies the device name of the monitor being used. Most + * applications have no use for a display monitor name, and so can save some bytes + * by using a MONITORINFO structure. + */ + public char[] szDevice; + + public MONITORINFOEX() + { + szDevice = new char[CCHDEVICENAME]; + cbSize = size(); + } + + @Override + protected List getFieldOrder() + { + return Arrays.asList("cbSize", "rcMonitor", "rcWork", "dwFlags", "szDevice"); + } + } + + /** + * An application-defined callback function that is called by the {@link MyUser32#EnumDisplayMonitors} function. + *

    + * You can use the EnumDisplayMonitors function to enumerate the set of display monitors that intersect + * the visible region of a specified device context and, optionally, a clipping rectangle. To do this, + * set the hdc parameter to a non-NULL value, and set the lprcClip parameter as needed. + *

    + * You can also use the EnumDisplayMonitors function to enumerate one or more of the display monitors on + * the desktop, without supplying a device context. To do this, set the hdc parameter of + * EnumDisplayMonitors to NULL and set the lprcClip parameter as needed. + *

    + * In all cases, EnumDisplayMonitors calls a specified MonitorEnumProc function once for each display + * monitor in the calculated enumeration set. The MonitorEnumProc function always receives a handle to + * the display monitor. If the hdc parameter of EnumDisplayMonitors is non-NULL, the MonitorEnumProc + * function also receives a handle to a device context whose color format is appropriate for the + * display monitor. You can then paint into the device context in a manner that is optimal for the + * display monitor. + */ + public interface MONITORENUMPROC extends Callback + { + /** + * @param hMonitor A handle to the display monitor. This value will always be non-NULL. + * @param hdcMonitor A handle to a device context. The device context has color attributes that are + * appropriate for the display monitor identified by hMonitor. The clipping area of the device + * context is set to the intersection of the visible region of the device context identified + * by the hdc parameter of EnumDisplayMonitors, the rectangle pointed to by the lprcClip + * parameter of EnumDisplayMonitors, and the display monitor rectangle. + * @param lprcMonitor A pointer to a RECT structure. If hdcMonitor is non-NULL, this rectangle is the + * intersection of the clipping area of the device context identified by hdcMonitor and the + * display monitor rectangle. The rectangle coordinates are device-context coordinates. + * If hdcMonitor is NULL, this rectangle is the display monitor rectangle. The rectangle + * coordinates are virtual-screen coordinates. + * @param dwData Application-defined data that EnumDisplayMonitors passes directly to the enumeration + * function. + * @return To continue the enumeration, return TRUE. To stop the enumeration, return FALSE. + */ + public int apply(HMONITOR hMonitor, HDC hdcMonitor, RECT lprcMonitor, LPARAM dwData); + } } From 1eca61dff75ab82d98b5d7e894744906b64accac Mon Sep 17 00:00:00 2001 From: Martin Steiger Date: Thu, 22 May 2014 18:05:52 +0200 Subject: [PATCH 3/5] Added tests for Dxva2 and User32 --- .../com/sun/jna/platform/win32/Dxva2Test.java | 142 ++++++++++++++++++ .../sun/jna/platform/win32/User32Test.java | 37 +++++ 2 files changed, 179 insertions(+) create mode 100644 contrib/platform/test/com/sun/jna/platform/win32/Dxva2Test.java diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Dxva2Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Dxva2Test.java new file mode 100644 index 0000000000..078df03b70 --- /dev/null +++ b/contrib/platform/test/com/sun/jna/platform/win32/Dxva2Test.java @@ -0,0 +1,142 @@ +/* + * Copyright 2014 Martin Steiger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.jna.platform.win32; + + +import junit.framework.TestCase; + +import com.sun.jna.Memory; +import com.sun.jna.platform.win32.Dxva2; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_COLOR_TEMPERATURE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_DISPLAY_TECHNOLOGY_TYPE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_DRIVE_TYPE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_GAIN_TYPE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_POSITION_TYPE; +import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_SIZE_TYPE; +import com.sun.jna.platform.win32.LowLevelMonitorConfigurationAPI.MC_TIMING_REPORT; +import com.sun.jna.platform.win32.PhysicalMonitorEnumerationAPI.PHYSICAL_MONITOR; +import com.sun.jna.platform.win32.User32; +import com.sun.jna.platform.win32.WTypes.LPSTR; +import com.sun.jna.platform.win32.WinDef.DWORD; +import com.sun.jna.platform.win32.WinDef.DWORDByReference; +import com.sun.jna.platform.win32.WinDef.HDC; +import com.sun.jna.platform.win32.WinDef.LPARAM; +import com.sun.jna.platform.win32.WinDef.RECT; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.platform.win32.WinUser.HMONITOR; +import com.sun.jna.platform.win32.WinUser.MONITORENUMPROC; + + +/** + * @author Martin Steiger + */ +public class Dxva2Test extends TestCase { + + public void testAll() { + User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() { + + @Override + public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam) + { + enumerate(hMonitor); + return 0; // stop + } + }, new LPARAM(0)); + } + + static void enumerate(HMONITOR hMonitor) + { + DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference(); + Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors); + int monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue(); + + PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount]; + Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons); + + for (int i = 0; i < monitorCount; i++) + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; + enumeratePhysicalMonitor(hPhysicalMonitor); + } + } + + private static void enumeratePhysicalMonitor(HANDLE hPhysicalMonitor) + { + MC_DISPLAY_TECHNOLOGY_TYPE.ByReference techType = new MC_DISPLAY_TECHNOLOGY_TYPE.ByReference(); + Dxva2.INSTANCE.GetMonitorTechnologyType(hPhysicalMonitor, techType); + + DWORDByReference temps = new DWORDByReference(); + DWORDByReference caps = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorCapabilities(hPhysicalMonitor, caps, temps); + + // Brightness + DWORDByReference pdwMinimumBrightness = new DWORDByReference(); + DWORDByReference pdwCurrentBrightness = new DWORDByReference(); + DWORDByReference pdwMaximumBrightness = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorBrightness(hPhysicalMonitor, pdwMinimumBrightness, pdwCurrentBrightness, pdwMaximumBrightness); + + // Contrast + DWORDByReference pdwMinimumContrast = new DWORDByReference(); + DWORDByReference pdwCurrentContrast = new DWORDByReference(); + DWORDByReference pdwMaximumContrast = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorContrast(hPhysicalMonitor, pdwMinimumContrast, pdwCurrentContrast, pdwMaximumContrast); + + // Temperature + MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature = new MC_COLOR_TEMPERATURE.ByReference(); + Dxva2.INSTANCE.GetMonitorColorTemperature(hPhysicalMonitor, pctCurrentColorTemperature); + + // Capabilities string + DWORDByReference pdwCapabilitiesStringLengthInCharacters = new DWORDByReference(); + Dxva2.INSTANCE.GetCapabilitiesStringLength(hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters); + DWORD capStrLen = pdwCapabilitiesStringLengthInCharacters.getValue(); + + LPSTR pszASCIICapabilitiesString = new LPSTR(new Memory(capStrLen.intValue())); + Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen); + + // Position + MC_POSITION_TYPE ptPositionType = MC_POSITION_TYPE.MC_HORIZONTAL_POSITION; + DWORDByReference pdwMinimumPosition = new DWORDByReference(); + DWORDByReference pdwCurrentPosition = new DWORDByReference(); + DWORDByReference pdwMaximumPosition = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorDisplayAreaPosition(hPhysicalMonitor, ptPositionType, pdwMinimumPosition, pdwCurrentPosition, pdwMaximumPosition); + + // Size + MC_SIZE_TYPE ptSizeType = MC_SIZE_TYPE.MC_WIDTH; + DWORDByReference pdwMinimumSize = new DWORDByReference(); + DWORDByReference pdwCurrentSize = new DWORDByReference(); + DWORDByReference pdwMaximumSize = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorDisplayAreaSize(hPhysicalMonitor, ptSizeType, pdwMinimumSize, pdwCurrentSize, pdwMaximumSize); + + // Gain + MC_GAIN_TYPE ptGainType = MC_GAIN_TYPE.MC_RED_GAIN; + DWORDByReference pdwMinimumGain = new DWORDByReference(); + DWORDByReference pdwCurrentGain = new DWORDByReference(); + DWORDByReference pdwMaximumGain = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorRedGreenOrBlueGain(hPhysicalMonitor, ptGainType, pdwMinimumGain, pdwCurrentGain, pdwMaximumGain); + + // Drive + MC_DRIVE_TYPE ptDriveType = MC_DRIVE_TYPE.MC_RED_DRIVE; + DWORDByReference pdwMinimumDrive = new DWORDByReference(); + DWORDByReference pdwCurrentDrive = new DWORDByReference(); + DWORDByReference pdwMaximumDrive = new DWORDByReference(); + Dxva2.INSTANCE.GetMonitorRedGreenOrBlueDrive(hPhysicalMonitor, ptDriveType, pdwMinimumDrive, pdwCurrentDrive, pdwMaximumDrive); + + // Timing Report + MC_TIMING_REPORT pmtrMonitorTimingReport = new MC_TIMING_REPORT(); + Dxva2.INSTANCE.GetTimingReport(hPhysicalMonitor, pmtrMonitorTimingReport); + } +} diff --git a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java index 4aa41a763d..c1e6a3263a 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java @@ -20,7 +20,16 @@ import junit.framework.TestCase; +import com.sun.jna.platform.win32.WinDef.HDC; +import com.sun.jna.platform.win32.WinDef.HWND; +import com.sun.jna.platform.win32.WinDef.LPARAM; +import com.sun.jna.platform.win32.WinDef.POINT; +import com.sun.jna.platform.win32.WinDef.RECT; +import com.sun.jna.platform.win32.WinUser.HMONITOR; import com.sun.jna.platform.win32.WinUser.LASTINPUTINFO; +import com.sun.jna.platform.win32.WinUser.MONITORENUMPROC; +import com.sun.jna.platform.win32.WinUser.MONITORINFO; +import com.sun.jna.platform.win32.WinUser.MONITORINFOEX; /** * @author dblock[at]dblock[dot]org @@ -110,4 +119,32 @@ public final void testRegisterWindowMessage() { final int msg = User32.INSTANCE.RegisterWindowMessage("RM_UNITTEST"); assertTrue(msg >= 0xC000 && msg <= 0xFFFF); } + + public final void testMonitorFrom() { + int dwFlags = WinUser.MONITOR_DEFAULTTOPRIMARY; + + POINT pt = new POINT(0, 0); + User32.INSTANCE.MonitorFromPoint(pt, dwFlags); + + RECT lprc = new RECT(); + User32.INSTANCE.MonitorFromRect(lprc, dwFlags); + + HWND hwnd = new HWND(); + User32.INSTANCE.MonitorFromWindow(hwnd, dwFlags); + } + + public final void testGetMonitor() { + User32.INSTANCE.GetMonitorInfo(new HMONITOR(), new MONITORINFO()); + + User32.INSTANCE.GetMonitorInfo(new HMONITOR(), new MONITORINFOEX()); + + User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() { + + @Override + public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam) + { + return 1; + } + }, new LPARAM(0)); + } } From a270aa8118ce92ea08959044830053d05bc268d0 Mon Sep 17 00:00:00 2001 From: Martin Steiger Date: Fri, 23 May 2014 18:43:02 +0200 Subject: [PATCH 4/5] Split monitor tests in Dxva2 and User32 into smaller ones --- .../com/sun/jna/platform/win32/Dxva2Test.java | 128 +++++++++++++----- .../sun/jna/platform/win32/User32Test.java | 30 ++-- 2 files changed, 113 insertions(+), 45 deletions(-) diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Dxva2Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Dxva2Test.java index 078df03b70..7e41107e3c 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/Dxva2Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/Dxva2Test.java @@ -16,7 +16,6 @@ package com.sun.jna.platform.win32; - import junit.framework.TestCase; import com.sun.jna.Memory; @@ -33,12 +32,10 @@ import com.sun.jna.platform.win32.WTypes.LPSTR; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinDef.DWORDByReference; -import com.sun.jna.platform.win32.WinDef.HDC; -import com.sun.jna.platform.win32.WinDef.LPARAM; -import com.sun.jna.platform.win32.WinDef.RECT; +import com.sun.jna.platform.win32.WinDef.POINT; import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.platform.win32.WinUser; import com.sun.jna.platform.win32.WinUser.HMONITOR; -import com.sun.jna.platform.win32.WinUser.MONITORENUMPROC; /** @@ -46,96 +43,155 @@ */ public class Dxva2Test extends TestCase { - public void testAll() { - User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() { - - @Override - public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam) - { - enumerate(hMonitor); - return 0; // stop - } - }, new LPARAM(0)); - } + private int monitorCount; + private PHYSICAL_MONITOR[] physMons; - static void enumerate(HMONITOR hMonitor) + @Override + public void setUp() { + HMONITOR hMonitor = User32.INSTANCE.MonitorFromPoint(new POINT(0, 0), WinUser.MONITOR_DEFAULTTOPRIMARY); + DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference(); - Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors); - int monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue(); + assertTrue(Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors).booleanValue()); - PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount]; - Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons); + monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue(); + physMons = new PHYSICAL_MONITOR[monitorCount]; + assertTrue(Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons).booleanValue()); + } - for (int i = 0; i < monitorCount; i++) - { - HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; - enumeratePhysicalMonitor(hPhysicalMonitor); - } + @Override + public void tearDown() + { + assertTrue(Dxva2.INSTANCE.DestroyPhysicalMonitors(monitorCount, physMons).booleanValue()); } - private static void enumeratePhysicalMonitor(HANDLE hPhysicalMonitor) + public void testGetMonitorTechnologyType() { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; + + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) MC_DISPLAY_TECHNOLOGY_TYPE.ByReference techType = new MC_DISPLAY_TECHNOLOGY_TYPE.ByReference(); Dxva2.INSTANCE.GetMonitorTechnologyType(hPhysicalMonitor, techType); + } + + public void testGetMonitorCapabilities() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) DWORDByReference temps = new DWORDByReference(); DWORDByReference caps = new DWORDByReference(); Dxva2.INSTANCE.GetMonitorCapabilities(hPhysicalMonitor, caps, temps); + } + + public void testGetMonitorBrightness() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; - // Brightness + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) DWORDByReference pdwMinimumBrightness = new DWORDByReference(); DWORDByReference pdwCurrentBrightness = new DWORDByReference(); DWORDByReference pdwMaximumBrightness = new DWORDByReference(); Dxva2.INSTANCE.GetMonitorBrightness(hPhysicalMonitor, pdwMinimumBrightness, pdwCurrentBrightness, pdwMaximumBrightness); + } - // Contrast + public void testGetMonitorContrast() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; + + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) DWORDByReference pdwMinimumContrast = new DWORDByReference(); DWORDByReference pdwCurrentContrast = new DWORDByReference(); DWORDByReference pdwMaximumContrast = new DWORDByReference(); Dxva2.INSTANCE.GetMonitorContrast(hPhysicalMonitor, pdwMinimumContrast, pdwCurrentContrast, pdwMaximumContrast); + } + + public void testGetMonitorColorTemperature() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; - // Temperature + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature = new MC_COLOR_TEMPERATURE.ByReference(); Dxva2.INSTANCE.GetMonitorColorTemperature(hPhysicalMonitor, pctCurrentColorTemperature); + } + + public void testCapabilitiesRequestAndCapabilitiesReply() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; - // Capabilities string + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) DWORDByReference pdwCapabilitiesStringLengthInCharacters = new DWORDByReference(); Dxva2.INSTANCE.GetCapabilitiesStringLength(hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters); DWORD capStrLen = pdwCapabilitiesStringLengthInCharacters.getValue(); LPSTR pszASCIICapabilitiesString = new LPSTR(new Memory(capStrLen.intValue())); Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen); + } - // Position + public void testGetMonitorDisplayAreaPosition() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; + + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) MC_POSITION_TYPE ptPositionType = MC_POSITION_TYPE.MC_HORIZONTAL_POSITION; DWORDByReference pdwMinimumPosition = new DWORDByReference(); DWORDByReference pdwCurrentPosition = new DWORDByReference(); DWORDByReference pdwMaximumPosition = new DWORDByReference(); Dxva2.INSTANCE.GetMonitorDisplayAreaPosition(hPhysicalMonitor, ptPositionType, pdwMinimumPosition, pdwCurrentPosition, pdwMaximumPosition); + } + + public void testGetMonitorDisplayAreaSize() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; - // Size + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) MC_SIZE_TYPE ptSizeType = MC_SIZE_TYPE.MC_WIDTH; DWORDByReference pdwMinimumSize = new DWORDByReference(); DWORDByReference pdwCurrentSize = new DWORDByReference(); DWORDByReference pdwMaximumSize = new DWORDByReference(); Dxva2.INSTANCE.GetMonitorDisplayAreaSize(hPhysicalMonitor, ptSizeType, pdwMinimumSize, pdwCurrentSize, pdwMaximumSize); + } + + public void testGetMonitorRedGreenOrBlueGain() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; - // Gain + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) MC_GAIN_TYPE ptGainType = MC_GAIN_TYPE.MC_RED_GAIN; DWORDByReference pdwMinimumGain = new DWORDByReference(); DWORDByReference pdwCurrentGain = new DWORDByReference(); DWORDByReference pdwMaximumGain = new DWORDByReference(); Dxva2.INSTANCE.GetMonitorRedGreenOrBlueGain(hPhysicalMonitor, ptGainType, pdwMinimumGain, pdwCurrentGain, pdwMaximumGain); + } - // Drive + public void testGetMonitorRedGreenOrBlueDrive() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; + + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) MC_DRIVE_TYPE ptDriveType = MC_DRIVE_TYPE.MC_RED_DRIVE; DWORDByReference pdwMinimumDrive = new DWORDByReference(); DWORDByReference pdwCurrentDrive = new DWORDByReference(); DWORDByReference pdwMaximumDrive = new DWORDByReference(); Dxva2.INSTANCE.GetMonitorRedGreenOrBlueDrive(hPhysicalMonitor, ptDriveType, pdwMinimumDrive, pdwCurrentDrive, pdwMaximumDrive); + } + + public void testGetTimingReport() + { + HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor; - // Timing Report + // the method returns FALSE if the monitor driver doesn't support it, + // but verifies that the JNA mapping is correct (no exception) MC_TIMING_REPORT pmtrMonitorTimingReport = new MC_TIMING_REPORT(); Dxva2.INSTANCE.GetTimingReport(hPhysicalMonitor, pmtrMonitorTimingReport); } diff --git a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java index c1e6a3263a..72823ef4df 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java @@ -120,31 +120,43 @@ public final void testRegisterWindowMessage() { assertTrue(msg >= 0xC000 && msg <= 0xFFFF); } - public final void testMonitorFrom() { + public final void testMonitorFromPoint() { int dwFlags = WinUser.MONITOR_DEFAULTTOPRIMARY; POINT pt = new POINT(0, 0); - User32.INSTANCE.MonitorFromPoint(pt, dwFlags); + assertNotNull(User32.INSTANCE.MonitorFromPoint(pt, dwFlags)); + } + public final void testMonitorFromRect() { + int dwFlags = WinUser.MONITOR_DEFAULTTOPRIMARY; RECT lprc = new RECT(); - User32.INSTANCE.MonitorFromRect(lprc, dwFlags); + assertNotNull(User32.INSTANCE.MonitorFromRect(lprc, dwFlags)); + } + + public final void testMonitorFromWindow() { + int dwFlags = WinUser.MONITOR_DEFAULTTOPRIMARY; HWND hwnd = new HWND(); - User32.INSTANCE.MonitorFromWindow(hwnd, dwFlags); + assertNotNull(User32.INSTANCE.MonitorFromWindow(hwnd, dwFlags)); } - public final void testGetMonitor() { - User32.INSTANCE.GetMonitorInfo(new HMONITOR(), new MONITORINFO()); + public final void testGetMonitorInfo() { + HMONITOR hMon = User32.INSTANCE.MonitorFromPoint(new POINT(0, 0), WinUser.MONITOR_DEFAULTTOPRIMARY); + + assertTrue(User32.INSTANCE.GetMonitorInfo(hMon, new MONITORINFO()).booleanValue()); + + assertTrue(User32.INSTANCE.GetMonitorInfo(hMon, new MONITORINFOEX()).booleanValue()); + } - User32.INSTANCE.GetMonitorInfo(new HMONITOR(), new MONITORINFOEX()); + public final void testEnumDisplayMonitors() { - User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() { + assertTrue(User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() { @Override public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam) { return 1; } - }, new LPARAM(0)); + }, new LPARAM(0)).booleanValue()); } } From 646ab833d923baed0dc1710180d1f4eb4321d378 Mon Sep 17 00:00:00 2001 From: Martin Steiger Date: Fri, 23 May 2014 18:48:38 +0200 Subject: [PATCH 5/5] Close handles in MonitorInfoDemo --- .../src/com/sun/jna/contrib/demo/MonitorInfoDemo.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/monitordemo/src/com/sun/jna/contrib/demo/MonitorInfoDemo.java b/contrib/monitordemo/src/com/sun/jna/contrib/demo/MonitorInfoDemo.java index 2462acd7d4..9a1e3271f7 100644 --- a/contrib/monitordemo/src/com/sun/jna/contrib/demo/MonitorInfoDemo.java +++ b/contrib/monitordemo/src/com/sun/jna/contrib/demo/MonitorInfoDemo.java @@ -97,6 +97,8 @@ static void enumerate(HMONITOR hMonitor) enumeratePhysicalMonitor(hPhysicalMonitor); } + + Dxva2.INSTANCE.DestroyPhysicalMonitors(monitorCount, physMons); } /**