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
a8344b96
Commit
a8344b96
authored
Mar 28, 2017
by
Huw Davies
Committed by
Alexandre Julliard
Mar 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Rationalize the popup menu margin calculation.
Signed-off-by:
Huw Davies
<
huw@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
71eb01cf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
33 deletions
+27
-33
menu.c
dlls/user32/menu.c
+27
-33
No files found.
dlls/user32/menu.c
View file @
a8344b96
...
...
@@ -133,9 +133,8 @@ typedef struct
/* Space between 2 columns */
#define MENU_COL_SPACE 4
/* top and bottom margins for popup menus */
#define MENU_TOP_MARGIN 3
#define MENU_BOTTOM_MARGIN 2
/* Margins for popup menus */
#define MENU_MARGIN 3
/* maximum allowed depth of any branch in the menu tree.
* This value is slightly larger than in windows (25) to
...
...
@@ -1175,7 +1174,7 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
SelectObject
(
hdc
,
get_menu_font
(
FALSE
));
start
=
0
;
maxX
=
2
+
1
;
maxX
=
MENU_MARGIN
;
lppop
->
textOffset
=
0
;
...
...
@@ -1185,7 +1184,7 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
orgX
=
maxX
;
if
(
lpitem
->
fType
&
(
MF_MENUBREAK
|
MF_MENUBARBREAK
))
orgX
+=
MENU_COL_SPACE
;
orgY
=
MENU_
TOP_
MARGIN
;
orgY
=
MENU_MARGIN
;
maxTab
=
maxTabWidth
=
0
;
/* Parse items until column break or end of menu */
...
...
@@ -1226,12 +1225,12 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
if
(
!
textandbmp
)
lppop
->
textOffset
=
0
;
/* space for 3d border */
lppop
->
Height
+=
MENU_
BOTTOM_
MARGIN
;
lppop
->
Width
+=
2
;
lppop
->
Height
+=
MENU_MARGIN
;
lppop
->
Width
+=
MENU_MARGIN
;
/* Adjust popup height if it exceeds maximum */
maxHeight
=
MENU_GetMaxPopupHeight
(
lppop
);
lppop
->
nTotalHeight
=
lppop
->
Height
-
MENU_
TOP_
MARGIN
;
lppop
->
nTotalHeight
=
lppop
->
Height
-
MENU_MARGIN
;
if
(
lppop
->
Height
>=
maxHeight
)
{
lppop
->
Height
=
maxHeight
;
...
...
@@ -1856,7 +1855,6 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
INT
x
,
INT
y
,
INT
xanchor
,
INT
yanchor
)
{
POPUPMENU
*
menu
;
INT
width
,
height
;
POINT
pt
;
HMONITOR
monitor
;
MONITORINFO
info
;
...
...
@@ -1876,9 +1874,6 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
/* adjust popup menu pos so that it fits within the desktop */
width
=
menu
->
Width
+
GetSystemMetrics
(
SM_CXBORDER
);
height
=
menu
->
Height
+
GetSystemMetrics
(
SM_CYBORDER
);
/* FIXME: should use item rect */
pt
.
x
=
x
;
pt
.
y
=
y
;
...
...
@@ -1889,29 +1884,29 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
if
(
flags
&
TPM_LAYOUTRTL
)
flags
^=
TPM_RIGHTALIGN
;
if
(
flags
&
TPM_RIGHTALIGN
)
x
-=
w
idth
;
if
(
flags
&
TPM_CENTERALIGN
)
x
-=
w
idth
/
2
;
if
(
flags
&
TPM_RIGHTALIGN
)
x
-=
menu
->
W
idth
;
if
(
flags
&
TPM_CENTERALIGN
)
x
-=
menu
->
W
idth
/
2
;
if
(
flags
&
TPM_BOTTOMALIGN
)
y
-=
h
eight
;
if
(
flags
&
TPM_VCENTERALIGN
)
y
-=
h
eight
/
2
;
if
(
flags
&
TPM_BOTTOMALIGN
)
y
-=
menu
->
H
eight
;
if
(
flags
&
TPM_VCENTERALIGN
)
y
-=
menu
->
H
eight
/
2
;
if
(
x
+
w
idth
>
info
.
rcWork
.
right
)
if
(
x
+
menu
->
W
idth
>
info
.
rcWork
.
right
)
{
if
(
xanchor
&&
x
>=
w
idth
-
xanchor
)
x
-=
w
idth
-
xanchor
;
if
(
xanchor
&&
x
>=
menu
->
W
idth
-
xanchor
)
x
-=
menu
->
W
idth
-
xanchor
;
if
(
x
+
w
idth
>
info
.
rcWork
.
right
)
x
=
info
.
rcWork
.
right
-
w
idth
;
if
(
x
+
menu
->
W
idth
>
info
.
rcWork
.
right
)
x
=
info
.
rcWork
.
right
-
menu
->
W
idth
;
}
if
(
x
<
info
.
rcWork
.
left
)
x
=
info
.
rcWork
.
left
;
if
(
y
+
h
eight
>
info
.
rcWork
.
bottom
)
if
(
y
+
menu
->
H
eight
>
info
.
rcWork
.
bottom
)
{
if
(
yanchor
&&
y
>=
h
eight
+
yanchor
)
y
-=
h
eight
+
yanchor
;
if
(
yanchor
&&
y
>=
menu
->
H
eight
+
yanchor
)
y
-=
menu
->
H
eight
+
yanchor
;
if
(
y
+
h
eight
>
info
.
rcWork
.
bottom
)
y
=
info
.
rcWork
.
bottom
-
h
eight
;
if
(
y
+
menu
->
H
eight
>
info
.
rcWork
.
bottom
)
y
=
info
.
rcWork
.
bottom
-
menu
->
H
eight
;
}
if
(
y
<
info
.
rcWork
.
top
)
y
=
info
.
rcWork
.
top
;
...
...
@@ -1921,7 +1916,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
}
/* Display the window */
SetWindowPos
(
menu
->
hWnd
,
HWND_TOPMOST
,
x
,
y
,
width
,
h
eight
,
SetWindowPos
(
menu
->
hWnd
,
HWND_TOPMOST
,
x
,
y
,
menu
->
Width
,
menu
->
H
eight
,
SWP_SHOWWINDOW
|
SWP_NOACTIVATE
);
UpdateWindow
(
menu
->
hWnd
);
return
TRUE
;
...
...
@@ -1949,7 +1944,7 @@ MENU_EnsureMenuItemVisible(LPPOPUPMENU lppop, UINT wIndex, HDC hdc)
arrow_bitmap_height
=
bmp
.
bmHeight
;
rc
.
top
+=
arrow_bitmap_height
;
rc
.
bottom
-=
arrow_bitmap_height
+
MENU_
BOTTOM_
MARGIN
;
rc
.
bottom
-=
arrow_bitmap_height
+
MENU_MARGIN
;
nMaxHeight
-=
GetSystemMetrics
(
SM_CYBORDER
)
+
2
*
arrow_bitmap_height
;
if
(
item
->
rect
.
bottom
>
lppop
->
nScrollPos
+
nMaxHeight
)
...
...
@@ -1959,9 +1954,9 @@ MENU_EnsureMenuItemVisible(LPPOPUPMENU lppop, UINT wIndex, HDC hdc)
ScrollWindow
(
lppop
->
hWnd
,
0
,
nOldPos
-
lppop
->
nScrollPos
,
&
rc
,
&
rc
);
MENU_DrawScrollArrows
(
lppop
,
hdc
);
}
else
if
(
item
->
rect
.
top
-
MENU_
TOP_
MARGIN
<
lppop
->
nScrollPos
)
else
if
(
item
->
rect
.
top
-
MENU_MARGIN
<
lppop
->
nScrollPos
)
{
lppop
->
nScrollPos
=
item
->
rect
.
top
-
MENU_
TOP_
MARGIN
;
lppop
->
nScrollPos
=
item
->
rect
.
top
-
MENU_MARGIN
;
ScrollWindow
(
lppop
->
hWnd
,
0
,
nOldPos
-
lppop
->
nScrollPos
,
&
rc
,
&
rc
);
MENU_DrawScrollArrows
(
lppop
,
hdc
);
}
...
...
@@ -2379,10 +2374,9 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
rect
.
left
+=
GetSystemMetrics
(
SM_CXBORDER
);
else
rect
.
left
+=
rc
.
right
-
GetSystemMetrics
(
SM_CXBORDER
);
rect
.
top
+=
rc
.
top
-
MENU_
TOP_
MARGIN
;
rect
.
top
+=
rc
.
top
-
MENU_MARGIN
;
rect
.
right
=
rc
.
left
-
rc
.
right
+
GetSystemMetrics
(
SM_CXBORDER
);
rect
.
bottom
=
rc
.
top
-
rc
.
bottom
-
MENU_TOP_MARGIN
-
MENU_BOTTOM_MARGIN
-
GetSystemMetrics
(
SM_CYBORDER
);
rect
.
bottom
=
rc
.
top
-
rc
.
bottom
-
2
*
MENU_MARGIN
;
}
else
{
...
...
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