Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
da2551f8
Commit
da2551f8
authored
Apr 11, 2018
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Support returning to the process default in SetThreadDpiAwarenessContext().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
165f552c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
16 deletions
+55
-16
sysparams.c
dlls/user32/sysparams.c
+24
-14
sysparams.c
dlls/user32/tests/sysparams.c
+30
-1
user_private.h
dlls/user32/user_private.h
+1
-1
No files found.
dlls/user32/sysparams.c
View file @
da2551f8
...
...
@@ -2942,19 +2942,22 @@ BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum,
}
static
DPI_AWARENESS
_CONTEXT
dpi_awareness
;
static
DPI_AWARENESS
dpi_awareness
;
/**********************************************************************
* SetProcessDpiAwarenessContext (USER32.@)
*/
BOOL
WINAPI
SetProcessDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT
context
)
{
if
(
!
IsValidDpiAwarenessContext
(
context
))
DPI_AWARENESS
val
=
GetAwarenessFromDpiAwarenessContext
(
context
);
if
(
val
==
DPI_AWARENESS_INVALID
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
InterlockedCompareExchangePointer
(
(
void
**
)
&
dpi_awareness
,
context
,
NULL
))
val
|=
0x10
;
/* avoid 0 value */
if
(
InterlockedCompareExchange
(
&
dpi_awareness
,
val
,
0
))
{
SetLastError
(
ERROR_ACCESS_DENIED
);
return
FALSE
;
...
...
@@ -2973,7 +2976,7 @@ BOOL WINAPI GetProcessDpiAwarenessInternal( HANDLE process, DPI_AWARENESS *aware
WARN
(
"not supported on other process %p
\n
"
,
process
);
*
awareness
=
DPI_AWARENESS_UNAWARE
;
}
else
*
awareness
=
GetAwarenessFromDpiAwarenessContext
(
dpi_awareness
)
;
else
*
awareness
=
dpi_awareness
&
3
;
return
TRUE
;
}
...
...
@@ -3041,7 +3044,7 @@ BOOL WINAPI IsValidDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
BOOL
WINAPI
SetProcessDPIAware
(
void
)
{
TRACE
(
"
\n
"
);
InterlockedCompareExchange
Pointer
(
(
void
**
)
&
dpi_awareness
,
DPI_AWARENESS_CONTEXT_SYSTEM_AWARE
,
NULL
);
InterlockedCompareExchange
(
&
dpi_awareness
,
0x11
,
0
);
return
TRUE
;
}
...
...
@@ -3050,8 +3053,7 @@ BOOL WINAPI SetProcessDPIAware(void)
*/
BOOL
WINAPI
IsProcessDPIAware
(
void
)
{
/* FIXME: should default to FALSE when not set */
return
dpi_awareness
!=
DPI_AWARENESS_CONTEXT_UNAWARE
;
return
GetAwarenessFromDpiAwarenessContext
(
GetThreadDpiAwarenessContext
()
)
!=
DPI_AWARENESS_UNAWARE
;
}
/***********************************************************************
...
...
@@ -3088,9 +3090,9 @@ DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void)
{
struct
user_thread_info
*
info
=
get_user_thread_info
();
if
(
info
->
dpi_awareness
)
return
info
->
dpi_awareness
;
if
(
dpi_awareness
)
return
dpi_awareness
;
return
DPI_AWARENESS_CONTEXT_SYSTEM_AWARE
;
/* FIXME: should default to unaware */
if
(
info
->
dpi_awareness
)
return
ULongToHandle
(
info
->
dpi_awareness
)
;
if
(
dpi_awareness
)
return
ULongToHandle
(
dpi_awareness
)
;
return
(
DPI_AWARENESS_CONTEXT
)(
0x10
|
DPI_AWARENESS_SYSTEM_AWARE
)
;
/* FIXME: should default to unaware */
}
/**********************************************************************
...
...
@@ -3098,15 +3100,23 @@ DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void)
*/
DPI_AWARENESS_CONTEXT
WINAPI
SetThreadDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT
context
)
{
DPI_AWARENESS_CONTEXT
prev
=
GetThreadDpiAwarenessContext
();
struct
user_thread_info
*
info
=
get_user_thread_info
();
DPI_AWARENESS
prev
,
val
=
GetAwarenessFromDpiAwarenessContext
(
context
);
if
(
!
IsValidDpiAwarenessContext
(
context
)
)
if
(
val
==
DPI_AWARENESS_INVALID
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
get_user_thread_info
()
->
dpi_awareness
=
context
;
return
prev
;
if
(
!
(
prev
=
info
->
dpi_awareness
))
{
prev
=
dpi_awareness
;
if
(
!
prev
)
prev
=
0x10
|
DPI_AWARENESS_UNAWARE
;
prev
|=
0x80000000
;
/* restore to process default */
}
if
(((
ULONG_PTR
)
context
&
~
(
ULONG_PTR
)
0x13
)
==
0x80000000
)
info
->
dpi_awareness
=
0
;
else
info
->
dpi_awareness
=
val
|
0x10
;
return
ULongToHandle
(
prev
);
}
/**********************************************************************
...
...
dlls/user32/tests/sysparams.c
View file @
da2551f8
...
...
@@ -3010,9 +3010,13 @@ static void test_dpi_aware(void)
ULONG_PTR
i
;
context
=
pGetThreadDpiAwarenessContext
();
todo_wine
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x10
,
"wrong context %p
\n
"
,
context
);
awareness
=
pGetAwarenessFromDpiAwarenessContext
(
context
);
todo_wine
ok
(
awareness
==
DPI_AWARENESS_UNAWARE
,
"wrong awareness %u
\n
"
,
awareness
);
todo_wine
ok
(
!
pIsProcessDPIAware
(),
"already aware
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetProcessDpiAwarenessContext
(
NULL
);
ok
(
!
ret
,
"got %d
\n
"
,
ret
);
...
...
@@ -3023,6 +3027,7 @@ static void test_dpi_aware(void)
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
ret
=
pSetProcessDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT_SYSTEM_AWARE
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
ok
(
pIsProcessDPIAware
(),
"not aware
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetProcessDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT_SYSTEM_AWARE
);
ok
(
!
ret
,
"got %d
\n
"
,
ret
);
...
...
@@ -3051,6 +3056,7 @@ static void test_dpi_aware(void)
ret
=
pIsProcessDPIAware
();
ok
(
ret
,
"got %d
\n
"
,
ret
);
context
=
pGetThreadDpiAwarenessContext
();
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x11
,
"wrong context %p
\n
"
,
context
);
awareness
=
pGetAwarenessFromDpiAwarenessContext
(
context
);
ok
(
awareness
==
DPI_AWARENESS_SYSTEM_AWARE
,
"wrong awareness %u
\n
"
,
awareness
);
SetLastError
(
0xdeadbeef
);
...
...
@@ -3062,20 +3068,43 @@ static void test_dpi_aware(void)
ok
(
!
context
,
"got %p
\n
"
,
context
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
context
=
pSetThreadDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT_UNAWARE
);
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x80000011
,
"wrong context %p
\n
"
,
context
);
awareness
=
pGetAwarenessFromDpiAwarenessContext
(
context
);
ok
(
awareness
==
DPI_AWARENESS_SYSTEM_AWARE
,
"wrong awareness %u
\n
"
,
awareness
);
ok
(
!
pIsProcessDPIAware
(),
"still aware
\n
"
);
context
=
pGetThreadDpiAwarenessContext
();
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x10
,
"wrong context %p
\n
"
,
context
);
awareness
=
pGetAwarenessFromDpiAwarenessContext
(
context
);
ok
(
awareness
==
DPI_AWARENESS_UNAWARE
,
"wrong awareness %u
\n
"
,
awareness
);
context
=
pSetThreadDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x10
,
"wrong context %p
\n
"
,
context
);
awareness
=
pGetAwarenessFromDpiAwarenessContext
(
context
);
ok
(
awareness
==
DPI_AWARENESS_UNAWARE
,
"wrong awareness %u
\n
"
,
awareness
);
context
=
pGetThreadDpiAwarenessContext
();
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x12
,
"wrong context %p
\n
"
,
context
);
awareness
=
pGetAwarenessFromDpiAwarenessContext
(
context
);
ok
(
awareness
==
DPI_AWARENESS_PER_MONITOR_AWARE
,
"wrong awareness %u
\n
"
,
awareness
);
context
=
pSetThreadDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT_SYSTEM_AWARE
);
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x12
,
"wrong context %p
\n
"
,
context
);
awareness
=
pGetAwarenessFromDpiAwarenessContext
(
context
);
ok
(
awareness
==
DPI_AWARENESS_PER_MONITOR_AWARE
,
"wrong awareness %u
\n
"
,
awareness
);
ok
(
pIsProcessDPIAware
(),
"not aware
\n
"
);
context
=
pGetThreadDpiAwarenessContext
();
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x11
,
"wrong context %p
\n
"
,
context
);
context
=
pSetThreadDpiAwarenessContext
(
(
DPI_AWARENESS_CONTEXT
)
0x80000010
);
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x11
,
"wrong context %p
\n
"
,
context
);
context
=
pGetThreadDpiAwarenessContext
();
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x11
,
"wrong context %p
\n
"
,
context
);
context
=
pSetThreadDpiAwarenessContext
(
(
DPI_AWARENESS_CONTEXT
)
0x80000011
);
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x80000011
,
"wrong context %p
\n
"
,
context
);
context
=
pGetThreadDpiAwarenessContext
();
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x11
,
"wrong context %p
\n
"
,
context
);
context
=
pSetThreadDpiAwarenessContext
(
(
DPI_AWARENESS_CONTEXT
)
0x12
);
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x80000011
,
"wrong context %p
\n
"
,
context
);
context
=
pSetThreadDpiAwarenessContext
(
context
);
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x12
,
"wrong context %p
\n
"
,
context
);
context
=
pGetThreadDpiAwarenessContext
();
ok
(
context
==
(
DPI_AWARENESS_CONTEXT
)
0x11
,
"wrong context %p
\n
"
,
context
);
for
(
i
=
0
;
i
<
0x100
;
i
++
)
{
awareness
=
pGetAwarenessFromDpiAwarenessContext
(
(
DPI_AWARENESS_CONTEXT
)
i
);
...
...
@@ -3124,7 +3153,7 @@ static void test_dpi_aware(void)
}
}
}
else
win_skip
(
"SetProcessD
PIAware
not supported
\n
"
);
else
win_skip
(
"SetProcessD
piAwarenessContext
not supported
\n
"
);
ret
=
pSetProcessDPIAware
();
ok
(
ret
,
"got %d
\n
"
,
ret
);
...
...
dlls/user32/user_private.h
View file @
da2551f8
...
...
@@ -169,7 +169,7 @@ struct wm_char_mapping_data
/* no attempt is made to keep the layout compatible with the Windows one */
struct
user_thread_info
{
DPI_AWARENESS
_CONTEXT
dpi_awareness
;
/* DPI awareness context
*/
DPI_AWARENESS
dpi_awareness
;
/* DPI awareness
*/
HANDLE
server_queue
;
/* Handle to server-side queue */
DWORD
wake_mask
;
/* Current queue wake mask */
DWORD
changed_mask
;
/* Current queue changed mask */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment