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
4858c54a
Commit
4858c54a
authored
Sep 08, 2010
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Avoid direct accesses to the window structure in NC_HandleNCHitTest.
parent
ca499d07
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
60 deletions
+35
-60
nonclient.c
dlls/user32/nonclient.c
+35
-60
No files found.
dlls/user32/nonclient.c
View file @
4858c54a
...
@@ -60,7 +60,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(nonclient);
...
@@ -60,7 +60,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(nonclient);
((exStyle) & WS_EX_DLGMODALFRAME) || \
((exStyle) & WS_EX_DLGMODALFRAME) || \
!((style) & (WS_CHILD | WS_POPUP)))
!((style) & (WS_CHILD | WS_POPUP)))
#define HAS_MENU(
w) ((((w)->dwStyle & (WS_CHILD | WS_POPUP)) != WS_CHILD) && ((w)->wIDmenu != 0
))
#define HAS_MENU(
hwnd,style) ((((style) & (WS_CHILD | WS_POPUP)) != WS_CHILD) && GetMenu(hwnd
))
/******************************************************************************
/******************************************************************************
...
@@ -512,33 +512,29 @@ static void NC_GetInsideRect( HWND hwnd, enum coords_relative relative, RECT *re
...
@@ -512,33 +512,29 @@ static void NC_GetInsideRect( HWND hwnd, enum coords_relative relative, RECT *re
/***********************************************************************
/***********************************************************************
* NC_DoNCHitTest
* NC_HandleNCHitTest
*
* Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
*
*
*
FIXME: Just a modified copy of the Win 3.1 version
.
*
Handle a WM_NCHITTEST message. Called from DefWindowProc()
.
*/
*/
LRESULT
NC_HandleNCHitTest
(
HWND
hwnd
,
POINT
pt
)
static
LRESULT
NC_DoNCHitTest
(
WND
*
wndPtr
,
POINT
pt
)
{
{
RECT
rect
,
rcClient
;
RECT
rect
,
rcClient
;
POINT
ptClient
;
DWORD
style
,
ex_style
;
TRACE
(
"hwnd=%p pt=%d,%d
\n
"
,
wndPtr
->
obj
.
handle
,
pt
.
x
,
pt
.
y
);
TRACE
(
"hwnd=%p pt=%d,%d
\n
"
,
hwnd
,
pt
.
x
,
pt
.
y
);
GetWindowRect
(
wndPtr
->
obj
.
handle
,
&
rect
);
ScreenToClient
(
hwnd
,
&
pt
);
WIN_GetRectangles
(
hwnd
,
COORDS_CLIENT
,
&
rect
,
&
rcClient
);
if
(
!
PtInRect
(
&
rect
,
pt
))
return
HTNOWHERE
;
if
(
!
PtInRect
(
&
rect
,
pt
))
return
HTNOWHERE
;
if
(
wndPtr
->
dwStyle
&
WS_MINIMIZE
)
return
HTCAPTION
;
style
=
GetWindowLongW
(
hwnd
,
GWL_STYLE
);
ex_style
=
GetWindowLongW
(
hwnd
,
GWL_EXSTYLE
);
if
(
style
&
WS_MINIMIZE
)
return
HTCAPTION
;
/* Check client area */
if
(
PtInRect
(
&
rcClient
,
pt
))
return
HTCLIENT
;
ptClient
=
pt
;
ScreenToClient
(
wndPtr
->
obj
.
handle
,
&
ptClient
);
GetClientRect
(
wndPtr
->
obj
.
handle
,
&
rcClient
);
if
(
PtInRect
(
&
rcClient
,
ptClient
))
return
HTCLIENT
;
/* Check borders */
/* Check borders */
if
(
HAS_THICKFRAME
(
wndPtr
->
dwStyle
,
wndPtr
->
dwExS
tyle
))
if
(
HAS_THICKFRAME
(
style
,
ex_s
tyle
))
{
{
InflateRect
(
&
rect
,
-
GetSystemMetrics
(
SM_CXFRAME
),
-
GetSystemMetrics
(
SM_CYFRAME
)
);
InflateRect
(
&
rect
,
-
GetSystemMetrics
(
SM_CXFRAME
),
-
GetSystemMetrics
(
SM_CYFRAME
)
);
if
(
!
PtInRect
(
&
rect
,
pt
))
if
(
!
PtInRect
(
&
rect
,
pt
))
...
@@ -575,47 +571,46 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
...
@@ -575,47 +571,46 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
}
}
else
/* No thick frame */
else
/* No thick frame */
{
{
if
(
HAS_DLGFRAME
(
wndPtr
->
dwStyle
,
wndPtr
->
dwExS
tyle
))
if
(
HAS_DLGFRAME
(
style
,
ex_s
tyle
))
InflateRect
(
&
rect
,
-
GetSystemMetrics
(
SM_CXDLGFRAME
),
-
GetSystemMetrics
(
SM_CYDLGFRAME
));
InflateRect
(
&
rect
,
-
GetSystemMetrics
(
SM_CXDLGFRAME
),
-
GetSystemMetrics
(
SM_CYDLGFRAME
));
else
if
(
HAS_THINFRAME
(
wndPtr
->
dwS
tyle
))
else
if
(
HAS_THINFRAME
(
s
tyle
))
InflateRect
(
&
rect
,
-
GetSystemMetrics
(
SM_CXBORDER
),
-
GetSystemMetrics
(
SM_CYBORDER
));
InflateRect
(
&
rect
,
-
GetSystemMetrics
(
SM_CXBORDER
),
-
GetSystemMetrics
(
SM_CYBORDER
));
if
(
!
PtInRect
(
&
rect
,
pt
))
return
HTBORDER
;
if
(
!
PtInRect
(
&
rect
,
pt
))
return
HTBORDER
;
}
}
/* Check caption */
/* Check caption */
if
((
wndPtr
->
dwS
tyle
&
WS_CAPTION
)
==
WS_CAPTION
)
if
((
s
tyle
&
WS_CAPTION
)
==
WS_CAPTION
)
{
{
if
(
wndPtr
->
dwExS
tyle
&
WS_EX_TOOLWINDOW
)
if
(
ex_s
tyle
&
WS_EX_TOOLWINDOW
)
rect
.
top
+=
GetSystemMetrics
(
SM_CYSMCAPTION
)
-
1
;
rect
.
top
+=
GetSystemMetrics
(
SM_CYSMCAPTION
)
-
1
;
else
else
rect
.
top
+=
GetSystemMetrics
(
SM_CYCAPTION
)
-
1
;
rect
.
top
+=
GetSystemMetrics
(
SM_CYCAPTION
)
-
1
;
if
(
!
PtInRect
(
&
rect
,
pt
))
if
(
!
PtInRect
(
&
rect
,
pt
))
{
{
BOOL
min_or_max_box
=
(
wndPtr
->
dwS
tyle
&
WS_MAXIMIZEBOX
)
||
BOOL
min_or_max_box
=
(
s
tyle
&
WS_MAXIMIZEBOX
)
||
(
wndPtr
->
dwS
tyle
&
WS_MINIMIZEBOX
);
(
s
tyle
&
WS_MINIMIZEBOX
);
/* Check system menu */
/* Check system menu */
if
((
wndPtr
->
dwStyle
&
WS_SYSMENU
)
&&
!
(
wndPtr
->
dwExS
tyle
&
WS_EX_TOOLWINDOW
))
if
((
style
&
WS_SYSMENU
)
&&
!
(
ex_s
tyle
&
WS_EX_TOOLWINDOW
))
{
{
if
(
NC_IconForWindow
(
wndPtr
->
obj
.
handle
))
if
(
NC_IconForWindow
(
hwnd
))
rect
.
left
+=
GetSystemMetrics
(
SM_CYCAPTION
)
-
1
;
rect
.
left
+=
GetSystemMetrics
(
SM_CYCAPTION
)
-
1
;
}
}
if
(
pt
.
x
<
rect
.
left
)
return
HTSYSMENU
;
if
(
pt
.
x
<
rect
.
left
)
return
HTSYSMENU
;
/* Check close button */
/* Check close button */
if
(
wndPtr
->
dwS
tyle
&
WS_SYSMENU
)
if
(
s
tyle
&
WS_SYSMENU
)
rect
.
right
-=
GetSystemMetrics
(
SM_CYCAPTION
);
rect
.
right
-=
GetSystemMetrics
(
SM_CYCAPTION
);
if
(
pt
.
x
>
rect
.
right
)
return
HTCLOSE
;
if
(
pt
.
x
>
rect
.
right
)
return
HTCLOSE
;
/* Check maximize box */
/* Check maximize box */
/* In win95 there is automatically a Maximize button when there is a minimize one*/
/* In win95 there is automatically a Maximize button when there is a minimize one*/
if
(
min_or_max_box
&&
!
(
wndPtr
->
dwExS
tyle
&
WS_EX_TOOLWINDOW
))
if
(
min_or_max_box
&&
!
(
ex_s
tyle
&
WS_EX_TOOLWINDOW
))
rect
.
right
-=
GetSystemMetrics
(
SM_CXSIZE
);
rect
.
right
-=
GetSystemMetrics
(
SM_CXSIZE
);
if
(
pt
.
x
>
rect
.
right
)
return
HTMAXBUTTON
;
if
(
pt
.
x
>
rect
.
right
)
return
HTMAXBUTTON
;
/* Check minimize box */
/* Check minimize box */
/* In win95 there is automatically a Maximize button when there is a Maximize one*/
/* In win95 there is automatically a Maximize button when there is a Maximize one*/
if
(
min_or_max_box
&&
!
(
wndPtr
->
dwExS
tyle
&
WS_EX_TOOLWINDOW
))
if
(
min_or_max_box
&&
!
(
ex_s
tyle
&
WS_EX_TOOLWINDOW
))
rect
.
right
-=
GetSystemMetrics
(
SM_CXSIZE
);
rect
.
right
-=
GetSystemMetrics
(
SM_CXSIZE
);
if
(
pt
.
x
>
rect
.
right
)
return
HTMINBUTTON
;
if
(
pt
.
x
>
rect
.
right
)
return
HTMINBUTTON
;
...
@@ -625,26 +620,26 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
...
@@ -625,26 +620,26 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
/* Check vertical scroll bar */
/* Check vertical scroll bar */
if
(
wndPtr
->
dwS
tyle
&
WS_VSCROLL
)
if
(
s
tyle
&
WS_VSCROLL
)
{
{
if
((
wndPtr
->
dwExS
tyle
&
WS_EX_LEFTSCROLLBAR
)
!=
0
)
if
((
ex_s
tyle
&
WS_EX_LEFTSCROLLBAR
)
!=
0
)
rcClient
.
left
-=
GetSystemMetrics
(
SM_CXVSCROLL
);
rcClient
.
left
-=
GetSystemMetrics
(
SM_CXVSCROLL
);
else
else
rcClient
.
right
+=
GetSystemMetrics
(
SM_CXVSCROLL
);
rcClient
.
right
+=
GetSystemMetrics
(
SM_CXVSCROLL
);
if
(
PtInRect
(
&
rcClient
,
pt
Client
))
return
HTVSCROLL
;
if
(
PtInRect
(
&
rcClient
,
pt
))
return
HTVSCROLL
;
}
}
/* Check horizontal scroll bar */
/* Check horizontal scroll bar */
if
(
wndPtr
->
dwS
tyle
&
WS_HSCROLL
)
if
(
s
tyle
&
WS_HSCROLL
)
{
{
rcClient
.
bottom
+=
GetSystemMetrics
(
SM_CYHSCROLL
);
rcClient
.
bottom
+=
GetSystemMetrics
(
SM_CYHSCROLL
);
if
(
PtInRect
(
&
rcClient
,
pt
Client
))
if
(
PtInRect
(
&
rcClient
,
pt
))
{
{
/* Check size box */
/* Check size box */
if
((
wndPtr
->
dwS
tyle
&
WS_VSCROLL
)
&&
if
((
s
tyle
&
WS_VSCROLL
)
&&
((((
wndPtr
->
dwExStyle
&
WS_EX_LEFTSCROLLBAR
)
!=
0
)
&&
(
ptClien
t
.
x
<=
rcClient
.
left
+
GetSystemMetrics
(
SM_CXVSCROLL
)))
||
((((
ex_style
&
WS_EX_LEFTSCROLLBAR
)
!=
0
)
&&
(
p
t
.
x
<=
rcClient
.
left
+
GetSystemMetrics
(
SM_CXVSCROLL
)))
||
(((
wndPtr
->
dwExStyle
&
WS_EX_LEFTSCROLLBAR
)
==
0
)
&&
(
ptClien
t
.
x
>=
rcClient
.
right
-
GetSystemMetrics
(
SM_CXVSCROLL
)))))
(((
ex_style
&
WS_EX_LEFTSCROLLBAR
)
==
0
)
&&
(
p
t
.
x
>=
rcClient
.
right
-
GetSystemMetrics
(
SM_CXVSCROLL
)))))
return
HTSIZE
;
return
HTSIZE
;
return
HTHSCROLL
;
return
HTHSCROLL
;
}
}
...
@@ -652,9 +647,9 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
...
@@ -652,9 +647,9 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
/* Check menu bar */
/* Check menu bar */
if
(
HAS_MENU
(
wndPtr
))
if
(
HAS_MENU
(
hwnd
,
style
))
{
{
if
((
pt
Client
.
y
<
0
)
&&
(
ptClient
.
x
>=
0
)
&&
(
ptClien
t
.
x
<
rcClient
.
right
))
if
((
pt
.
y
<
0
)
&&
(
pt
.
x
>=
0
)
&&
(
p
t
.
x
<
rcClient
.
right
))
return
HTMENU
;
return
HTMENU
;
}
}
...
@@ -664,24 +659,6 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
...
@@ -664,24 +659,6 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
}
}
/***********************************************************************
* NC_HandleNCHitTest
*
* Handle a WM_NCHITTEST message. Called from DefWindowProc().
*/
LRESULT
NC_HandleNCHitTest
(
HWND
hwnd
,
POINT
pt
)
{
LRESULT
retvalue
;
WND
*
wndPtr
=
WIN_GetPtr
(
hwnd
);
if
(
!
wndPtr
||
wndPtr
==
WND_OTHER_PROCESS
||
wndPtr
==
WND_DESKTOP
)
return
HTERROR
;
retvalue
=
NC_DoNCHitTest
(
wndPtr
,
pt
);
WIN_ReleasePtr
(
wndPtr
);
return
retvalue
;
}
/******************************************************************************
/******************************************************************************
*
*
* NC_DrawSysButton
* NC_DrawSysButton
...
@@ -986,10 +963,8 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
...
@@ -986,10 +963,8 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
WORD
flags
;
WORD
flags
;
HRGN
hrgn
;
HRGN
hrgn
;
RECT
rectClient
;
RECT
rectClient
;
int
has_menu
;
if
(
!
(
wndPtr
=
WIN_GetPtr
(
hwnd
))
||
wndPtr
==
WND_OTHER_PROCESS
)
return
;
if
(
!
(
wndPtr
=
WIN_GetPtr
(
hwnd
))
||
wndPtr
==
WND_OTHER_PROCESS
)
return
;
has_menu
=
HAS_MENU
(
wndPtr
);
dwStyle
=
wndPtr
->
dwStyle
;
dwStyle
=
wndPtr
->
dwStyle
;
dwExStyle
=
wndPtr
->
dwExStyle
;
dwExStyle
=
wndPtr
->
dwExStyle
;
flags
=
wndPtr
->
flags
;
flags
=
wndPtr
->
flags
;
...
@@ -1053,7 +1028,7 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
...
@@ -1053,7 +1028,7 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
NC_DrawCaption
(
hdc
,
&
r
,
hwnd
,
dwStyle
,
dwExStyle
,
active
);
NC_DrawCaption
(
hdc
,
&
r
,
hwnd
,
dwStyle
,
dwExStyle
,
active
);
}
}
if
(
has_menu
)
if
(
HAS_MENU
(
hwnd
,
dwStyle
)
)
{
{
RECT
r
=
rect
;
RECT
r
=
rect
;
r
.
bottom
=
rect
.
top
+
GetSystemMetrics
(
SM_CYMENU
);
r
.
bottom
=
rect
.
top
+
GetSystemMetrics
(
SM_CYMENU
);
...
...
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