Commit 656edbb5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winex11: Get primary monitor rect from win32u.

parent 586f377b
...@@ -1474,7 +1474,7 @@ RECT get_display_rect( const WCHAR *display ) ...@@ -1474,7 +1474,7 @@ RECT get_display_rect( const WCHAR *display )
return map_dpi_rect( rect, system_dpi, get_thread_dpi() ); return map_dpi_rect( rect, system_dpi, get_thread_dpi() );
} }
static RECT get_primary_monitor_rect(void) static RECT get_primary_monitor_rect( UINT dpi )
{ {
struct monitor *monitor; struct monitor *monitor;
RECT rect = {0}; RECT rect = {0};
...@@ -1489,7 +1489,7 @@ static RECT get_primary_monitor_rect(void) ...@@ -1489,7 +1489,7 @@ static RECT get_primary_monitor_rect(void)
} }
unlock_display_devices(); unlock_display_devices();
return map_dpi_rect( rect, system_dpi, get_thread_dpi() ); return map_dpi_rect( rect, system_dpi, dpi );
} }
/********************************************************************** /**********************************************************************
...@@ -4203,10 +4203,10 @@ int get_system_metrics( int index ) ...@@ -4203,10 +4203,10 @@ int get_system_metrics( int index )
case SM_MOUSEWHEELPRESENT: case SM_MOUSEWHEELPRESENT:
return 1; return 1;
case SM_CXSCREEN: case SM_CXSCREEN:
rect = get_primary_monitor_rect(); rect = get_primary_monitor_rect( get_thread_dpi() );
return rect.right - rect.left; return rect.right - rect.left;
case SM_CYSCREEN: case SM_CYSCREEN:
rect = get_primary_monitor_rect(); rect = get_primary_monitor_rect( get_thread_dpi() );
return rect.bottom - rect.top; return rect.bottom - rect.top;
case SM_XVIRTUALSCREEN: case SM_XVIRTUALSCREEN:
rect = get_virtual_screen_rect( get_thread_dpi() ); rect = get_virtual_screen_rect( get_thread_dpi() );
...@@ -4528,6 +4528,9 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code ) ...@@ -4528,6 +4528,9 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code )
return get_sys_color( arg ); return get_sys_color( arg );
case NtUserRealizePalette: case NtUserRealizePalette:
return realize_palette( UlongToHandle(arg) ); return realize_palette( UlongToHandle(arg) );
case NtUserGetPrimaryMonitorRect:
*(RECT *)arg = get_primary_monitor_rect( 0 );
return 1;
case NtUserGetSysColorBrush: case NtUserGetSysColorBrush:
return HandleToUlong( get_sys_color_brush(arg) ); return HandleToUlong( get_sys_color_brush(arg) );
case NtUserGetSysColorPen: case NtUserGetSysColorPen:
......
EXTRADEFS = -DWINE_NO_LONG_TYPES EXTRADEFS = -DWINE_NO_LONG_TYPES
MODULE = winex11.drv MODULE = winex11.drv
IMPORTS = uuid setupapi rpcrt4 user32 gdi32 advapi32 win32u IMPORTS = uuid user32 gdi32 advapi32 win32u
DELAYIMPORTS = comctl32 ole32 shell32 imm32 DELAYIMPORTS = comctl32 ole32 shell32 imm32
EXTRAINCL = $(X_CFLAGS) EXTRAINCL = $(X_CFLAGS)
EXTRALIBS = $(X_LIBS) $(X_EXTRA_LIBS) EXTRALIBS = $(X_LIBS) $(X_EXTRA_LIBS)
......
...@@ -19,52 +19,14 @@ ...@@ -19,52 +19,14 @@
*/ */
#include "config.h" #include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "rpc.h"
#include "winreg.h"
#include "cfgmgr32.h"
#include "initguid.h"
#include "devguid.h"
#include "devpkey.h"
#include "ntddvdeo.h"
#include "setupapi.h"
#define WIN32_NO_STATUS
#include "winternl.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "x11drv.h" #include "x11drv.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(x11drv); WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
/* Wine specific properties */
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_RCMONITOR, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 3);
static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
static const WCHAR video_keyW[] = {
'H','A','R','D','W','A','R','E','\\',
'D','E','V','I','C','E','M','A','P','\\',
'V','I','D','E','O',0};
static struct x11drv_display_device_handler host_handler; static struct x11drv_display_device_handler host_handler;
struct x11drv_display_device_handler desktop_handler; struct x11drv_display_device_handler desktop_handler;
/* Cached screen information, protected by screen_section */
static HKEY video_key;
static RECT primary_monitor_rect;
static FILETIME last_query_screen_time;
static CRITICAL_SECTION screen_section;
static CRITICAL_SECTION_DEBUG screen_critsect_debug =
{
0, 0, &screen_section,
{&screen_critsect_debug.ProcessLocksList, &screen_critsect_debug.ProcessLocksList},
0, 0, {(DWORD_PTR)(__FILE__ ": screen_section")}
};
static CRITICAL_SECTION screen_section = {&screen_critsect_debug, -1, 0, 0, 0, 0};
HANDLE get_display_device_init_mutex(void) HANDLE get_display_device_init_mutex(void)
{ {
static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0}; static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0};
...@@ -80,61 +42,6 @@ void release_display_device_init_mutex(HANDLE mutex) ...@@ -80,61 +42,6 @@ void release_display_device_init_mutex(HANDLE mutex)
CloseHandle(mutex); CloseHandle(mutex);
} }
/* Update screen rectangle cache from SetupAPI if it's outdated, return FALSE on failure and TRUE on success */
static BOOL update_screen_cache(void)
{
RECT virtual_rect = {0}, primary_rect = {0}, monitor_rect;
SP_DEVINFO_DATA device_data = {sizeof(device_data)};
HDEVINFO devinfo = INVALID_HANDLE_VALUE;
FILETIME filetime = {0};
HANDLE mutex = NULL;
DWORD i = 0;
INT result;
DWORD type;
BOOL ret = FALSE;
EnterCriticalSection(&screen_section);
if ((!video_key && RegOpenKeyW(HKEY_LOCAL_MACHINE, video_keyW, &video_key))
|| RegQueryInfoKeyW(video_key, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &filetime))
{
LeaveCriticalSection(&screen_section);
return FALSE;
}
result = CompareFileTime(&filetime, &last_query_screen_time);
LeaveCriticalSection(&screen_section);
if (result < 1)
return TRUE;
mutex = get_display_device_init_mutex();
devinfo = SetupDiGetClassDevsW(&GUID_DEVCLASS_MONITOR, displayW, NULL, DIGCF_PRESENT);
if (devinfo == INVALID_HANDLE_VALUE)
goto fail;
while (SetupDiEnumDeviceInfo(devinfo, i++, &device_data))
{
if (!SetupDiGetDevicePropertyW(devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_RCMONITOR, &type,
(BYTE *)&monitor_rect, sizeof(monitor_rect), NULL, 0))
goto fail;
UnionRect(&virtual_rect, &virtual_rect, &monitor_rect);
if (i == 1)
primary_rect = monitor_rect;
}
EnterCriticalSection(&screen_section);
primary_monitor_rect = primary_rect;
last_query_screen_time = filetime;
LeaveCriticalSection(&screen_section);
ret = TRUE;
fail:
SetupDiDestroyDeviceInfoList(devinfo);
release_display_device_init_mutex(mutex);
if (!ret)
WARN("Update screen cache failed!\n");
return ret;
}
POINT virtual_screen_to_root(INT x, INT y) POINT virtual_screen_to_root(INT x, INT y)
{ {
RECT virtual = get_virtual_screen_rect(); RECT virtual = get_virtual_screen_rect();
...@@ -165,11 +72,7 @@ RECT get_virtual_screen_rect(void) ...@@ -165,11 +72,7 @@ RECT get_virtual_screen_rect(void)
RECT get_primary_monitor_rect(void) RECT get_primary_monitor_rect(void)
{ {
RECT primary; RECT primary;
NtUserCallOneParam( (UINT_PTR)&primary, NtUserGetPrimaryMonitorRect );
update_screen_cache();
EnterCriticalSection(&screen_section);
primary = primary_monitor_rect;
LeaveCriticalSection(&screen_section);
return primary; return primary;
} }
......
...@@ -75,6 +75,7 @@ enum ...@@ -75,6 +75,7 @@ enum
{ {
NtUserGetClipCursor, NtUserGetClipCursor,
NtUserGetCursorPos, NtUserGetCursorPos,
NtUserGetPrimaryMonitorRect,
NtUserGetSysColor, NtUserGetSysColor,
NtUserGetSysColorBrush, NtUserGetSysColorBrush,
NtUserGetSysColorPen, NtUserGetSysColorPen,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment