windows显示驱动开发-多监视器管理器(三)

处理现有的监视器配置

除了在双监视器配置中检测新监视器和启动暂时性多监视器管理器 (TMM) 对话框外,TMM 还必须还原以前的显示配置。 TMM 可以通过 IViewHelper::SetConfiguration 方法将显示数据传递给用户模式显示驱动程序来还原显示配置。 TMM 将分配内存,并将显示模式和拓扑信息存储在内存中。 TMM 在 SetConfiguration的 pIStream 参数指向的 IStream 接口中传递此内存。 用户模式显示驱动程序还可以修改或折叠其他显示数据 (例如 gamma 或电视设置) 。 驱动程序完成显示数据后,驱动程序将调用 IStream::Release 方法来释放内存。

下图显示了 TMM 还原现有监视器配置时发生的操作流。

确定平台是移动平台还是桌面平台

TMM 仅在移动计算机上运行,并在台式计算机上自动禁用。 硬件供应商应启用并使用自己的专有方法在台式计算机上进入克隆视图。 他们应确定平台是否为移动平台,以避免使用其专有方法在移动计算机上进入克隆视图,转而使用 TMM。

硬件供应商可以使用以下代码来确定平台是移动平台还是桌面平台。 然后,平台可以使用适当的机制进入克隆视图。

复制代码
#include <Powrprof.h>   // For GetPwrCapabilities

    BOOL IsMobilePlatform()
    {
        BOOL fIsMobilePlatform = FALSE;

        fIsMobilePlatform = (PlatformRoleMobile == PowerDeterminePlatformRole());

        POWER_PLATFORM_ROLE iRole;

        // Check if the operating system determines 
        // that the computer is a mobile computer.
        iRole = PowerDeterminePlatformRole();

        if (PlatformRoleMobile == iRole)
        {
            fIsMobilePlatform = TRUE;
        }
        else if (PlatformRoleDesktop == iRole) 
        // Can happen when a battery is not plugged into a laptop
        {
            SYSTEM_POWER_CAPABILITIES powerCapabilities;

            if (GetPwrCapabilities(&powerCapabilities))
            {
         // Check if a battery exists, and it is not for a UPS.
         // Note that SystemBatteriesPresent is set on a laptop even if the battery is unplugged.
                fIsMobilePlatform = ((TRUE == powerCapabilities.SystemBatteriesPresent) && (FALSE == powerCapabilities.BatteriesAreShortTerm));
            }
            // GetPwrCapabilities should never fail 
            // However, if it does, leave fReturn == FALSE.
        }

        return fIsMobilePlatform;
    }
相关推荐
钛态20 分钟前
Flutter for OpenHarmony:mockito 单元测试的替身演员,轻松模拟复杂依赖(测试驱动开发必备) 深度解析与鸿蒙适配指南
服务器·驱动开发·安全·flutter·华为·单元测试·harmonyos
特立独行的猫a23 分钟前
在 Windows 10 上安装和使用 WSL 2 安装 Ubuntu24详细指南
windows·ubuntu·wsl2
奋斗的老史3 小时前
Stream-流式操作
java·windows
m0_488633323 小时前
Windows环境下编译运行C语言程序,合适工具与方法很关键
c语言·windows·git·开发工具·编译器
春日见3 小时前
云服务器开发与SSH
运维·服务器·人工智能·windows·git·自动驾驶·ssh
bloglin999996 小时前
windows中粘贴拷贝文件不会显示进度条,尤其是大文件
windows
人生苦短,菜的抠脚8 小时前
RK628 Linux 内核驱动开发指南
linux·驱动开发
xyyaihxl8 小时前
Redis 安装及配置教程(Windows)【安装】
数据库·windows·redis
CHQIUU9 小时前
解决VMware ESXi虚拟机挂载ISO后无法进入安装程序的问题
windows
路溪非溪10 小时前
Linux下wifi子系统的数据流
linux·arm开发·驱动开发