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
75fb6780
Commit
75fb6780
authored
Oct 23, 2006
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user: Fixed MonitorFromWindow behavior for an invalid window handle.
parent
a9909513
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
24 deletions
+27
-24
dialog.c
dlls/user/dialog.c
+1
-6
dialog16.c
dlls/user/dialog16.c
+1
-6
misc.c
dlls/user/misc.c
+6
-1
monitor.c
dlls/user/tests/monitor.c
+18
-0
win.c
dlls/user/win.c
+1
-11
No files found.
dlls/user/dialog.c
View file @
75fb6780
...
...
@@ -543,12 +543,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
mon_info
.
cbSize
=
sizeof
(
mon_info
);
if
(
template
.
style
&
DS_CENTER
)
{
if
(
!
(
monitor
=
MonitorFromWindow
(
owner
?
owner
:
GetActiveWindow
(),
MONITOR_DEFAULTTOPRIMARY
)))
{
pos
.
x
=
pos
.
y
=
0
;
/* default to primary monitor */
monitor
=
MonitorFromPoint
(
pos
,
MONITOR_DEFAULTTOPRIMARY
);
}
monitor
=
MonitorFromWindow
(
owner
?
owner
:
GetActiveWindow
(),
MONITOR_DEFAULTTOPRIMARY
);
GetMonitorInfoW
(
monitor
,
&
mon_info
);
pos
.
x
=
(
mon_info
.
rcWork
.
left
+
mon_info
.
rcWork
.
right
-
size
.
cx
)
/
2
;
pos
.
y
=
(
mon_info
.
rcWork
.
top
+
mon_info
.
rcWork
.
bottom
-
size
.
cy
)
/
2
;
...
...
dlls/user/dialog16.c
View file @
75fb6780
...
...
@@ -375,12 +375,7 @@ static HWND DIALOG_CreateIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
mon_info
.
cbSize
=
sizeof
(
mon_info
);
if
(
template
.
style
&
DS_CENTER
)
{
if
(
!
(
monitor
=
MonitorFromWindow
(
owner
?
owner
:
GetActiveWindow
(),
MONITOR_DEFAULTTOPRIMARY
)))
{
pos
.
x
=
pos
.
y
=
0
;
/* default to primary monitor */
monitor
=
MonitorFromPoint
(
pos
,
MONITOR_DEFAULTTOPRIMARY
);
}
monitor
=
MonitorFromWindow
(
owner
?
owner
:
GetActiveWindow
(),
MONITOR_DEFAULTTOPRIMARY
);
GetMonitorInfoW
(
monitor
,
&
mon_info
);
pos
.
x
=
(
mon_info
.
rcWork
.
left
+
mon_info
.
rcWork
.
right
-
size
.
cx
)
/
2
;
pos
.
y
=
(
mon_info
.
rcWork
.
top
+
mon_info
.
rcWork
.
bottom
-
size
.
cy
)
/
2
;
...
...
dlls/user/misc.c
View file @
75fb6780
...
...
@@ -430,7 +430,12 @@ HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
if
(
IsIconic
(
hWnd
)
&&
GetWindowPlacement
(
hWnd
,
&
wp
))
return
MonitorFromRect
(
&
wp
.
rcNormalPosition
,
dwFlags
);
GetWindowRect
(
hWnd
,
&
rect
);
if
(
GetWindowRect
(
hWnd
,
&
rect
))
return
MonitorFromRect
(
&
rect
,
dwFlags
);
if
(
!
(
dwFlags
&
(
MONITOR_DEFAULTTOPRIMARY
|
MONITOR_DEFAULTTONEAREST
)))
return
0
;
/* retrieve the primary */
SetRect
(
&
rect
,
0
,
0
,
1
,
1
);
return
MonitorFromRect
(
&
rect
,
dwFlags
);
}
...
...
dlls/user/tests/monitor.c
View file @
75fb6780
...
...
@@ -146,10 +146,28 @@ static void test_ChangeDisplaySettingsEx(void)
ok
(
res
==
DISP_CHANGE_SUCCESSFUL
,
"Failed to reset default resolution: %d
\n
"
,
res
);
}
static
void
test_monitors
(
void
)
{
HMONITOR
monitor
,
primary
;
POINT
pt
;
pt
.
x
=
pt
.
y
=
0
;
primary
=
MonitorFromPoint
(
pt
,
MONITOR_DEFAULTTOPRIMARY
);
ok
(
primary
!=
0
,
"couldn't get primary monitor
\n
"
);
monitor
=
MonitorFromWindow
(
0
,
MONITOR_DEFAULTTONULL
);
ok
(
!
monitor
,
"got %p, should not get a monitor for an invalid window
\n
"
,
monitor
);
monitor
=
MonitorFromWindow
(
0
,
MONITOR_DEFAULTTOPRIMARY
);
ok
(
monitor
==
primary
,
"got %p, should get primary %p for MONITOR_DEFAULTTOPRIMARY
\n
"
,
monitor
,
primary
);
monitor
=
MonitorFromWindow
(
0
,
MONITOR_DEFAULTTONEAREST
);
ok
(
monitor
==
primary
,
"got %p, should get primary %p for MONITOR_DEFAULTTONEAREST
\n
"
,
monitor
,
primary
);
}
START_TEST
(
monitor
)
{
init_function_pointers
();
test_enumdisplaydevices
();
test_ChangeDisplaySettingsEx
();
test_monitors
();
}
dlls/user/win.c
View file @
75fb6780
...
...
@@ -706,20 +706,10 @@ static void WIN_FixCoordinates( CREATESTRUCTA *cs, INT *sw)
HMONITOR
monitor
;
MONITORINFO
mon_info
;
STARTUPINFOW
info
;
POINT
pt
;
if
(
!
IS_DEFAULT
(
cs
->
x
)
&&
!
IS_DEFAULT
(
cs
->
cx
)
&&
!
IS_DEFAULT
(
cs
->
cy
))
return
;
if
(
!
(
monitor
=
MonitorFromWindow
(
cs
->
hwndParent
,
MONITOR_DEFAULTTOPRIMARY
)))
{
pt
.
x
=
pt
.
y
=
0
;
/* default to primary monitor */
if
(
!
IS_DEFAULT
(
cs
->
x
))
{
pt
.
x
=
cs
->
x
;
pt
.
y
=
cs
->
y
;
}
monitor
=
MonitorFromPoint
(
pt
,
MONITOR_DEFAULTTOPRIMARY
);
}
monitor
=
MonitorFromWindow
(
cs
->
hwndParent
,
MONITOR_DEFAULTTOPRIMARY
);
mon_info
.
cbSize
=
sizeof
(
mon_info
);
GetMonitorInfoW
(
monitor
,
&
mon_info
);
GetStartupInfoW
(
&
info
);
...
...
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