Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
c5a69256
Commit
c5a69256
authored
Aug 24, 2018
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Scale coordinates in WIN_GetRectangles() based on DPI awareness.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
10296553
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
45 additions
and
4 deletions
+45
-4
sysparams.c
dlls/user32/sysparams.c
+10
-0
win.c
dlls/user32/win.c
+4
-2
win.h
dlls/user32/win.h
+1
-0
server_protocol.h
include/wine/server_protocol.h
+2
-2
protocol.def
server/protocol.def
+1
-0
request.h
server/request.h
+1
-0
trace.c
server/trace.c
+1
-0
user.h
server/user.h
+14
-0
window.c
server/window.c
+11
-0
No files found.
dlls/user32/sysparams.c
View file @
c5a69256
...
...
@@ -3237,6 +3237,16 @@ RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to )
}
/**********************************************************************
* rect_win_to_thread_dpi
*/
RECT
rect_win_to_thread_dpi
(
HWND
hwnd
,
RECT
rect
)
{
UINT
dpi
=
get_thread_dpi
();
if
(
!
dpi
)
dpi
=
get_win_monitor_dpi
(
hwnd
);
return
map_dpi_rect
(
rect
,
GetDpiForWindow
(
hwnd
),
dpi
);
}
/**********************************************************************
* SetProcessDpiAwarenessContext (USER32.@)
*/
BOOL
WINAPI
SetProcessDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT
context
)
...
...
dlls/user32/win.c
View file @
c5a69256
...
...
@@ -844,6 +844,7 @@ BOOL WIN_GetRectangles( HWND hwnd, enum coords_relative relative, RECT *rectWind
{
rect
.
right
=
100
;
rect
.
bottom
=
100
;
rect
=
rect_win_to_thread_dpi
(
hwnd
,
rect
);
}
else
{
...
...
@@ -921,8 +922,8 @@ BOOL WIN_GetRectangles( HWND hwnd, enum coords_relative relative, RECT *rectWind
}
break
;
}
if
(
rectWindow
)
*
rectWindow
=
window_rect
;
if
(
rectClient
)
*
rectClient
=
client_rect
;
if
(
rectWindow
)
*
rectWindow
=
rect_win_to_thread_dpi
(
hwnd
,
window_rect
)
;
if
(
rectClient
)
*
rectClient
=
rect_win_to_thread_dpi
(
hwnd
,
client_rect
)
;
WIN_ReleasePtr
(
win
);
return
TRUE
;
}
...
...
@@ -932,6 +933,7 @@ other_process:
{
req
->
handle
=
wine_server_user_handle
(
hwnd
);
req
->
relative
=
relative
;
req
->
dpi
=
get_thread_dpi
();
if
((
ret
=
!
wine_server_call_err
(
req
)))
{
if
(
rectWindow
)
...
...
dlls/user32/win.h
View file @
c5a69256
...
...
@@ -132,6 +132,7 @@ extern UINT get_monitor_dpi( HMONITOR monitor ) DECLSPEC_HIDDEN;
extern
UINT
get_win_monitor_dpi
(
HWND
hwnd
)
DECLSPEC_HIDDEN
;
extern
UINT
get_thread_dpi
(
void
)
DECLSPEC_HIDDEN
;
extern
RECT
map_dpi_rect
(
RECT
rect
,
UINT
dpi_from
,
UINT
dpi_to
)
DECLSPEC_HIDDEN
;
extern
RECT
rect_win_to_thread_dpi
(
HWND
hwnd
,
RECT
rect
)
DECLSPEC_HIDDEN
;
extern
BOOL
set_window_pos
(
HWND
hwnd
,
HWND
insert_after
,
UINT
swp_flags
,
const
RECT
*
window_rect
,
const
RECT
*
client_rect
,
const
RECT
*
valid_rects
)
DECLSPEC_HIDDEN
;
...
...
include/wine/server_protocol.h
View file @
c5a69256
...
...
@@ -3692,7 +3692,7 @@ struct get_window_rectangles_request
struct
request_header
__header
;
user_handle_t
handle
;
int
relative
;
char
__pad_20
[
4
]
;
int
dpi
;
};
struct
get_window_rectangles_reply
{
...
...
@@ -6533,6 +6533,6 @@ union generic_reply
struct
terminate_job_reply
terminate_job_reply
;
};
#define SERVER_PROTOCOL_VERSION 55
6
#define SERVER_PROTOCOL_VERSION 55
7
#endif
/* __WINE_WINE_SERVER_PROTOCOL_H */
server/protocol.def
View file @
c5a69256
...
...
@@ -2651,6 +2651,7 @@ enum message_type
@REQ(get_window_rectangles)
user_handle_t handle; /* handle to the window */
int relative; /* coords relative to (see below) */
int dpi; /* DPI to map to, or zero for per-monitor DPI */
@REPLY
rectangle_t window; /* window rectangle */
rectangle_t client; /* client rectangle */
...
...
server/request.h
View file @
c5a69256
...
...
@@ -1773,6 +1773,7 @@ C_ASSERT( FIELD_OFFSET(struct set_window_pos_reply, needs_update) == 20 );
C_ASSERT
(
sizeof
(
struct
set_window_pos_reply
)
==
24
);
C_ASSERT
(
FIELD_OFFSET
(
struct
get_window_rectangles_request
,
handle
)
==
12
);
C_ASSERT
(
FIELD_OFFSET
(
struct
get_window_rectangles_request
,
relative
)
==
16
);
C_ASSERT
(
FIELD_OFFSET
(
struct
get_window_rectangles_request
,
dpi
)
==
20
);
C_ASSERT
(
sizeof
(
struct
get_window_rectangles_request
)
==
24
);
C_ASSERT
(
FIELD_OFFSET
(
struct
get_window_rectangles_reply
,
window
)
==
8
);
C_ASSERT
(
FIELD_OFFSET
(
struct
get_window_rectangles_reply
,
client
)
==
24
);
...
...
server/trace.c
View file @
c5a69256
...
...
@@ -3229,6 +3229,7 @@ static void dump_get_window_rectangles_request( const struct get_window_rectangl
{
fprintf
(
stderr
,
" handle=%08x"
,
req
->
handle
);
fprintf
(
stderr
,
", relative=%d"
,
req
->
relative
);
fprintf
(
stderr
,
", dpi=%d"
,
req
->
dpi
);
}
static
void
dump_get_window_rectangles_reply
(
const
struct
get_window_rectangles_reply
*
req
)
...
...
server/user.h
View file @
c5a69256
...
...
@@ -198,6 +198,20 @@ static inline int point_in_rect( const rectangle_t *rect, int x, int y )
return
(
x
>=
rect
->
left
&&
x
<
rect
->
right
&&
y
>=
rect
->
top
&&
y
<
rect
->
bottom
);
}
static
inline
int
scale_dpi
(
int
val
,
unsigned
int
dpi_from
,
unsigned
int
dpi_to
)
{
if
(
val
>=
0
)
return
(
val
*
dpi_to
+
(
dpi_from
/
2
))
/
dpi_from
;
return
(
val
*
dpi_to
-
(
dpi_from
/
2
))
/
dpi_from
;
}
static
inline
void
scale_dpi_rect
(
rectangle_t
*
rect
,
unsigned
int
dpi_from
,
unsigned
int
dpi_to
)
{
rect
->
left
=
scale_dpi
(
rect
->
left
,
dpi_from
,
dpi_to
);
rect
->
top
=
scale_dpi
(
rect
->
top
,
dpi_from
,
dpi_to
);
rect
->
right
=
scale_dpi
(
rect
->
right
,
dpi_from
,
dpi_to
);
rect
->
bottom
=
scale_dpi
(
rect
->
bottom
,
dpi_from
,
dpi_to
);
}
/* offset the coordinates of a rectangle */
static
inline
void
offset_rect
(
rectangle_t
*
rect
,
int
offset_x
,
int
offset_y
)
{
...
...
server/window.c
View file @
c5a69256
...
...
@@ -630,6 +630,15 @@ static inline void inc_window_paint_count( struct window *win, int incr )
if
(
win
->
thread
)
inc_queue_paint_count
(
win
->
thread
,
incr
);
}
/* map a window rectangle between different DPI scaling levels */
static
void
map_dpi_rect
(
struct
window
*
win
,
rectangle_t
*
rect
,
unsigned
int
from
,
unsigned
int
to
)
{
if
(
!
from
)
from
=
get_monitor_dpi
(
win
);
if
(
!
to
)
to
=
get_monitor_dpi
(
win
);
if
(
from
==
to
)
return
;
scale_dpi_rect
(
rect
,
from
,
to
);
}
/* check if window and all its ancestors are visible */
static
int
is_visible
(
const
struct
window
*
win
)
{
...
...
@@ -2349,6 +2358,8 @@ DECL_HANDLER(get_window_rectangles)
set_error
(
STATUS_INVALID_PARAMETER
);
break
;
}
map_dpi_rect
(
win
,
&
reply
->
window
,
win
->
dpi
,
req
->
dpi
);
map_dpi_rect
(
win
,
&
reply
->
client
,
win
->
dpi
,
req
->
dpi
);
}
...
...
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