Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2022
- 68 participants
- 3274 messages
[PATCH v3 1/4] mf/tests: Add some missing IMFActivate_Shutdown calls.
by Rémi Bernon
From: Rémi Bernon <rbernon(a)codeweavers.com>
And extensive reference leak checks.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/mf/tests/mf.c | 541 +++++++++++++++++++++++++++++++--------------
1 file changed, 376 insertions(+), 165 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c
index 2f3ee3151da..260dcd494b0 100644
--- a/dlls/mf/tests/mf.c
+++ b/dlls/mf/tests/mf.c
@@ -346,6 +346,7 @@ static void test_topology(void)
UINT32 count;
HRESULT hr;
TOPOID id;
+ LONG ref;
hr = MFCreateTopology(NULL);
ok(hr == E_POINTER, "got %#lx\n", hr);
@@ -362,7 +363,8 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to get id, hr %#lx.\n", hr);
ok(id == 2, "Unexpected id.\n");
- IMFTopology_Release(topology);
+ ref = IMFTopology_Release(topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFCreateTopology(&topology);
ok(hr == S_OK, "Failed to create topology, hr %#lx.\n", hr);
@@ -370,7 +372,8 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to get id, hr %#lx.\n", hr);
ok(id == 3, "Unexpected id.\n");
- IMFTopology_Release(topology2);
+ ref = IMFTopology_Release(topology2);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* No attributes by default. */
for (node_type = MF_TOPOLOGY_OUTPUT_NODE; node_type < MF_TOPOLOGY_TEE_NODE; ++node_type)
@@ -380,7 +383,8 @@ static void test_topology(void)
hr = IMFTopologyNode_GetCount(node, &count);
ok(hr == S_OK, "Failed to get attribute count, hr %#lx.\n", hr);
ok(!count, "Unexpected attribute count %u.\n", count);
- IMFTopologyNode_Release(node);
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, NULL);
@@ -421,7 +425,8 @@ static void test_topology(void)
hr = IMFTopology_AddNode(topology, node2);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
- IMFTopologyNode_Release(node2);
+ ref = IMFTopologyNode_Release(node2);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = IMFTopology_GetNodeByID(topology, id, &node2);
ok(hr == S_OK, "Failed to get a node, hr %#lx.\n", hr);
@@ -461,7 +466,8 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to create topology node, hr %#lx.\n", hr);
hr = IMFTopology_AddNode(topology, node2);
ok(hr == S_OK, "Failed to add a node, hr %#lx.\n", hr);
- IMFTopologyNode_Release(node2);
+ ref = IMFTopologyNode_Release(node2);
+ ok(ref == 1, "Release returned %ld\n", ref);
node_count = 0;
hr = IMFTopology_GetNodeCount(topology, &node_count);
@@ -475,7 +481,8 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to set node id, hr %#lx.\n", hr);
hr = IMFTopology_RemoveNode(topology, node2);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
- IMFTopologyNode_Release(node2);
+ ref = IMFTopologyNode_Release(node2);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = IMFTopology_RemoveNode(topology, node);
ok(hr == S_OK, "Failed to remove a node, hr %#lx.\n", hr);
@@ -499,7 +506,8 @@ static void test_topology(void)
hr = IMFTopologyNode_SetTopoNodeID(node, 123);
ok(hr == S_OK, "Failed to set node id, hr %#lx.\n", hr);
- IMFTopologyNode_Release(node);
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Change id for attached node. */
hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &node);
@@ -525,13 +533,15 @@ static void test_topology(void)
ok(node3 == node, "Unexpected node.\n");
IMFTopologyNode_Release(node3);
- IMFTopologyNode_Release(node);
- IMFTopologyNode_Release(node2);
-
/* Source/output collections. */
hr = IMFTopology_Clear(topology);
ok(hr == S_OK, "Failed to clear topology, hr %#lx.\n", hr);
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopologyNode_Release(node2);
+ ok(ref == 0, "Release returned %ld\n", ref);
+
hr = IMFTopology_GetSourceNodeCollection(topology, NULL);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
@@ -548,19 +558,26 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to get item count, hr %#lx.\n", hr);
ok(!size, "Unexpected item count.\n");
+ EXPECT_REF(collection, 1);
hr = IMFCollection_AddElement(collection, (IUnknown *)collection);
ok(hr == S_OK, "Failed to add element, hr %#lx.\n", hr);
+ EXPECT_REF(collection, 2);
hr = IMFCollection_GetElementCount(collection, &size);
ok(hr == S_OK, "Failed to get item count, hr %#lx.\n", hr);
ok(size == 1, "Unexpected item count.\n");
+ hr = IMFCollection_RemoveAllElements(collection);
+ ok(hr == S_OK, "Failed to get item count, hr %#lx.\n", hr);
+
hr = IMFCollection_GetElementCount(collection2, &size);
ok(hr == S_OK, "Failed to get item count, hr %#lx.\n", hr);
ok(!size, "Unexpected item count.\n");
- IMFCollection_Release(collection2);
- IMFCollection_Release(collection);
+ ref = IMFCollection_Release(collection2);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFCollection_Release(collection);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Add some nodes. */
hr = IMFTopology_GetSourceNodeCollection(topology, NULL);
@@ -581,7 +598,8 @@ static void test_topology(void)
hr = IMFCollection_GetElementCount(collection, &size);
ok(hr == S_OK, "Failed to get item count, hr %#lx.\n", hr);
ok(size == 1, "Unexpected item count.\n");
- IMFCollection_Release(collection);
+ ref = IMFCollection_Release(collection);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFCreateTopologyNode(MF_TOPOLOGY_TEE_NODE, &node);
ok(hr == S_OK, "Failed to create a node, hr %#lx.\n", hr);
@@ -595,7 +613,8 @@ static void test_topology(void)
hr = IMFCollection_GetElementCount(collection, &size);
ok(hr == S_OK, "Failed to get item count, hr %#lx.\n", hr);
ok(size == 1, "Unexpected item count.\n");
- IMFCollection_Release(collection);
+ ref = IMFCollection_Release(collection);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFCreateTopologyNode(MF_TOPOLOGY_TRANSFORM_NODE, &node);
ok(hr == S_OK, "Failed to create a node, hr %#lx.\n", hr);
@@ -609,7 +628,8 @@ static void test_topology(void)
hr = IMFCollection_GetElementCount(collection, &size);
ok(hr == S_OK, "Failed to get item count, hr %#lx.\n", hr);
ok(size == 1, "Unexpected item count.\n");
- IMFCollection_Release(collection);
+ ref = IMFCollection_Release(collection);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &node);
ok(hr == S_OK, "Failed to create a node, hr %#lx.\n", hr);
@@ -701,7 +721,8 @@ static void test_topology(void)
hr = IMFTopologyNode_SetOutputPrefType(node, 0, mediatype);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
- IMFTopologyNode_Release(node);
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 1, "Release returned %ld\n", ref);
/* Source node. */
hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &node);
@@ -721,7 +742,8 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to get output count, hr %#lx.\n", hr);
ok(io_count == 3, "Unexpected count %lu.\n", io_count);
- IMFTopologyNode_Release(node);
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Tee node. */
hr = MFCreateTopologyNode(MF_TOPOLOGY_TEE_NODE, &node);
@@ -776,7 +798,8 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to get output count, hr %#lx.\n", hr);
ok(io_count == 5, "Unexpected count %lu.\n", io_count);
- IMFTopologyNode_Release(node);
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Transform node. */
hr = MFCreateTopologyNode(MF_TOPOLOGY_TRANSFORM_NODE, &node);
@@ -800,7 +823,8 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to get output count, hr %#lx.\n", hr);
ok(io_count == 5, "Unexpected count %lu.\n", io_count);
- IMFTopologyNode_Release(node);
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 0, "Release returned %ld\n", ref);
IMFMediaType_Release(mediatype);
@@ -812,10 +836,12 @@ static void test_topology(void)
hr = IMFCollection_GetElementCount(collection, &size);
ok(hr == S_OK, "Failed to get item count, hr %#lx.\n", hr);
ok(size == 1, "Unexpected item count.\n");
- IMFCollection_Release(collection);
+ ref = IMFCollection_Release(collection);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
- IMFTopology_Release(topology);
+ ref = IMFTopology_Release(topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Connect nodes. */
hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &node);
@@ -923,7 +949,8 @@ static void test_topology(void)
hr = IMFTopologyNode_CloneFrom(node, node2);
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#lx.\n", hr);
- IMFTopologyNode_Release(node2);
+ ref = IMFTopologyNode_Release(node2);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Cloning preferred types. */
hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &node2);
@@ -944,9 +971,11 @@ static void test_topology(void)
ok(mediatype == mediatype2, "Unexpected media type.\n");
IMFMediaType_Release(mediatype2);
- IMFMediaType_Release(mediatype);
- IMFTopologyNode_Release(node2);
+ ref = IMFTopologyNode_Release(node2);
+ ok(ref == 0, "Release returned %ld\n", ref);
+
+ IMFMediaType_Release(mediatype);
/* Existing preferred types are not cleared. */
hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &node2);
@@ -975,8 +1004,10 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to get output count, hr %#lx.\n", hr);
ok(io_count == 1, "Unexpected output count.\n");
- IMFTopologyNode_Release(node2);
- IMFTopologyNode_Release(node);
+ ref = IMFTopologyNode_Release(node2);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Add one node, connect to another that hasn't been added. */
hr = IMFTopology_Clear(topology);
@@ -1002,9 +1033,6 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to get node count, hr %#lx.\n", hr);
ok(node_count == 1, "Unexpected node count.\n");
- IMFTopologyNode_Release(node);
- IMFTopologyNode_Release(node2);
-
/* Add same node to different topologies. */
hr = IMFTopology_Clear(topology);
ok(hr == S_OK, "Failed to clear topology, hr %#lx.\n", hr);
@@ -1039,8 +1067,15 @@ static void test_topology(void)
ok(hr == S_OK, "Failed to get node count, hr %#lx.\n", hr);
ok(node_count == 1, "Unexpected node count.\n");
- IMFTopology_Release(topology2);
- IMFTopology_Release(topology);
+ ref = IMFTopology_Release(topology2);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopology_Release(topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
+
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopologyNode_Release(node2);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
static void test_topology_tee_node(void)
@@ -1050,6 +1085,7 @@ static void test_topology_tee_node(void)
IMFTopology *topology;
DWORD count;
HRESULT hr;
+ LONG ref;
hr = MFCreateTopology(&topology);
ok(hr == S_OK, "Failed to create topology, hr %#lx.\n", hr);
@@ -1101,10 +1137,20 @@ static void test_topology_tee_node(void)
ok(hr == S_OK, "Failed to get count, hr %#lx.\n", hr);
ok(count == 2, "Unexpected count %lu.\n", count);
- IMFMediaType_Release(mediatype);
- IMFTopologyNode_Release(src_node);
- IMFTopologyNode_Release(tee_node);
- IMFTopology_Release(topology);
+ EXPECT_REF(src_node, 2);
+ EXPECT_REF(tee_node, 2);
+ hr = IMFTopologyNode_DisconnectOutput(src_node, 1);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+ ref = IMFTopologyNode_Release(src_node);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopologyNode_Release(tee_node);
+ ok(ref == 0, "Release returned %ld\n", ref);
+
+ ref = IMFMediaType_Release(mediatype);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopology_Release(topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
static HRESULT WINAPI test_getservice_QI(IMFGetService *iface, REFIID riid, void **obj)
@@ -1237,6 +1283,7 @@ static void test_sequencer_source(void)
{
IMFSequencerSource *seq_source;
HRESULT hr;
+ LONG ref;
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr);
@@ -1246,7 +1293,8 @@ static void test_sequencer_source(void)
check_interface(seq_source, &IID_IMFMediaSourceTopologyProvider, TRUE);
- IMFSequencerSource_Release(seq_source);
+ ref = IMFSequencerSource_Release(seq_source);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFShutdown();
ok(hr == S_OK, "Shutdown failure, hr %#lx.\n", hr);
@@ -2069,6 +2117,7 @@ static void test_topology_loader(void)
DWORD index;
HRESULT hr;
BOOL ret;
+ LONG ref;
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr);
@@ -2084,8 +2133,9 @@ static void test_topology_loader(void)
/* Empty topology */
hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL);
- todo_wine
+ todo_wine_if(hr == S_OK)
ok(hr == MF_E_TOPO_UNSUPPORTED, "Unexpected hr %#lx.\n", hr);
+ if (hr == S_OK) IMFTopology_Release(full_topology);
/* Add source node. */
hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &src_node);
@@ -2117,8 +2167,6 @@ static void test_topology_loader(void)
hr = IMFTopologyNode_SetUnknown(src_node, &MF_TOPONODE_PRESENTATION_DESCRIPTOR, (IUnknown *)pd);
ok(hr == S_OK, "Failed to set node pd, hr %#lx.\n", hr);
- IMFPresentationDescriptor_Release(pd);
- IMFStreamDescriptor_Release(sd);
IMFMediaType_Release(media_type);
hr = IMFTopology_AddNode(topology, src_node);
@@ -2126,8 +2174,9 @@ static void test_topology_loader(void)
/* Source node only. */
hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL);
- todo_wine
+ todo_wine_if(hr == S_OK)
ok(hr == MF_E_TOPO_UNSUPPORTED, "Unexpected hr %#lx.\n", hr);
+ if (hr == S_OK) IMFTopology_Release(full_topology);
hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &sink_node);
ok(hr == S_OK, "Failed to create output node, hr %#lx.\n", hr);
@@ -2152,7 +2201,7 @@ static void test_topology_loader(void)
ok(hr == S_OK, "Failed to add sink node, hr %#lx.\n", hr);
hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL);
- todo_wine
+ todo_wine_if(hr == MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED)
ok(hr == MF_E_TOPO_UNSUPPORTED, "Unexpected hr %#lx.\n", hr);
hr = IMFTopologyNode_ConnectOutput(src_node, 0, sink_node, 0);
@@ -2195,7 +2244,13 @@ static void test_topology_loader(void)
ok(full_topology != topology, "Unexpected instance.\n");
}
- if (test->expected_result == S_OK && hr == S_OK)
+ if (test->expected_result != hr)
+ {
+ if (hr != S_OK) ref = 0;
+ else ref = IMFTopology_Release(full_topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ }
+ else if (test->expected_result == S_OK)
{
hr = IMFTopology_GetCount(full_topology, &count);
ok(hr == S_OK, "Failed to get attribute count, hr %#lx.\n", hr);
@@ -2300,6 +2355,7 @@ todo_wine {
IMFTransform_Release(transform);
}
+ IMFTopologyNode_Release(src_node2);
IMFTopologyNode_Release(sink_node2);
hr = IMFTopology_SetUINT32(full_topology, &IID_IMFTopology, 123);
@@ -2310,23 +2366,50 @@ todo_wine {
hr = IMFTopology_GetUINT32(topology2, &IID_IMFTopology, &value);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IMFTopology_Release(topology2);
- IMFTopology_Release(full_topology);
+ ref = IMFTopology_Release(topology2);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopology_Release(full_topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
hr = IMFTopology_GetCount(topology, &count);
ok(hr == S_OK, "Failed to get attribute count, hr %#lx.\n", hr);
ok(!count, "Unexpected count %u.\n", count);
- IMFActivate_ShutdownObject(sink_activate);
- IMFActivate_Release(sink_activate);
+ hr = IMFActivate_ShutdownObject(sink_activate);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+ ref = IMFActivate_Release(sink_activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
- IMFMediaType_Release(input_type);
- IMFMediaType_Release(output_type);
+ ref = IMFTopology_Release(topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopoLoader_Release(loader);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopologyNode_Release(src_node);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopologyNode_Release(sink_node);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
- IMFMediaSource_Release(source);
- IMFTopoLoader_Release(loader);
+ ref = IMFMediaSource_Release(source);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
+
+ ref = IMFPresentationDescriptor_Release(pd);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFStreamDescriptor_Release(sd);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
+
+ ref = IMFMediaType_Release(input_type);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
+ /* FIXME: is native really leaking refs here, or are we? */
+ ref = IMFMediaType_Release(output_type);
+ ok(ref != 0, "Release returned %ld\n", ref);
hr = MFShutdown();
ok(hr == S_OK, "Shutdown failure, hr %#lx.\n", hr);
@@ -2347,6 +2430,7 @@ static void test_topology_loader_evr(void)
UINT64 value64;
HWND window;
HRESULT hr;
+ LONG ref;
hr = CoInitialize(NULL);
ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
@@ -2397,7 +2481,6 @@ static void test_topology_loader_evr(void)
IMFMediaTypeHandler_Release(handler);
IMFStreamSink_Release(stream_sink);
- IMFMediaSink_Release(sink);
hr = MFCreateTopology(&topology);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
@@ -2447,16 +2530,34 @@ static void test_topology_loader_evr(void)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!value64, "Unexpected value.\n");
}
+
+ IMFTopologyNode_Release(node);
}
- IMFTopology_Release(full_topology);
+ ref = IMFTopology_Release(full_topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopoLoader_Release(loader);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopology_Release(topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopologyNode_Release(source_node);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopologyNode_Release(evr_node);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
- IMFTopoLoader_Release(loader);
+ hr = IMFActivate_ShutdownObject(activate);
+ ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
+ ref = IMFActivate_Release(activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaSink_Release(sink);
+ ok(ref == 0, "Release returned %ld\n", ref);
+
+ ref = IMFMediaType_Release(media_type);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
- IMFTopologyNode_Release(source_node);
- IMFTopologyNode_Release(evr_node);
- IMFTopology_Release(topology);
- IMFMediaType_Release(media_type);
DestroyWindow(window);
CoUninitialize();
@@ -2993,11 +3094,10 @@ static void test_sample_grabber(void)
IMFActivate *activate;
IMFMediaEvent *event;
UINT32 attr_count;
- ULONG refcount;
- IUnknown *unk;
float rate;
HRESULT hr;
GUID guid;
+ LONG ref;
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "Failed to start up, hr %#lx.\n", hr);
@@ -3122,8 +3222,7 @@ static void test_sample_grabber(void)
hr = IMFMediaEventGenerator_GetEvent(eg, MF_EVENT_FLAG_NO_WAIT, &event);
ok(hr == MF_E_NO_EVENTS_AVAILABLE, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaSink_QueryInterface(sink, &IID_IMFPresentationTimeSource, (void **)&unk);
- ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
+ check_interface(sink, &IID_IMFPresentationTimeSource, FALSE);
hr = IMFStreamSink_QueryInterface(stream, &IID_IMFMediaTypeHandler, (void **)&handler2);
ok(hr == S_OK, "Failed to get handler interface, hr %#lx.\n", hr);
@@ -3281,7 +3380,9 @@ static void test_sample_grabber(void)
EXPECT_REF(clock, 3);
hr = IMFMediaSink_Shutdown(sink);
ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
- EXPECT_REF(clock, 1);
+
+ ref = IMFPresentationClock_Release(clock);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = IMFMediaEventGenerator_GetEvent(eg, MF_EVENT_FLAG_NO_WAIT, &event);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
@@ -3326,8 +3427,11 @@ static void test_sample_grabber(void)
hr = IMFMediaTypeHandler_GetMediaTypeCount(handler, &count);
ok(hr == S_OK, "Failed to get type count, hr %#lx.\n", hr);
- IMFMediaType_Release(media_type2);
- IMFMediaType_Release(media_type);
+ ref = IMFMediaType_Release(media_type2);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaType_Release(media_type);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 0, &media_type);
ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr);
@@ -3355,11 +3459,12 @@ static void test_sample_grabber(void)
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
IMFMediaEventGenerator_Release(eg);
- IMFMediaSink_Release(sink);
IMFStreamSink_Release(stream);
- refcount = IMFActivate_Release(activate);
- ok(!refcount, "Unexpected refcount %lu.\n", refcount);
+ ref = IMFActivate_Release(activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaSink_Release(sink);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Rateless mode with MF_SAMPLEGRABBERSINK_IGNORE_CLOCK. */
hr = MFCreateMediaType(&media_type);
@@ -3386,10 +3491,14 @@ static void test_sample_grabber(void)
hr = IMFActivate_ShutdownObject(activate);
ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
+ /* required for the sink to be fully released */
hr = IMFMediaSink_Shutdown(sink);
ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
- IMFMediaSink_Release(sink);
+ ref = IMFActivate_Release(activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaSink_Release(sink);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Detaching */
hr = MFCreateSampleGrabberSinkActivate(media_type, &grabber_callback, &activate);
@@ -3397,12 +3506,11 @@ static void test_sample_grabber(void)
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink);
ok(hr == S_OK, "Failed to activate object, hr %#lx.\n", hr);
- IMFMediaSink_Release(sink);
hr = IMFActivate_ShutdownObject(activate);
ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
- hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink);
+ hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink2);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFActivate_GetCount(activate, &attr_count);
@@ -3411,10 +3519,18 @@ static void test_sample_grabber(void)
hr = IMFActivate_DetachObject(activate);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
- IMFActivate_Release(activate);
+ ref = IMFActivate_Release(activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
- IMFMediaType_Release(media_type);
- IMFPresentationClock_Release(clock);
+ /* required for the sink to be fully released */
+ hr = IMFMediaSink_Shutdown(sink);
+ ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
+
+ ref = IMFMediaSink_Release(sink);
+ ok(ref == 0, "Release returned %ld\n", ref);
+
+ ref = IMFMediaType_Release(media_type);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFShutdown();
ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
@@ -3427,9 +3543,9 @@ static void test_sample_grabber_is_mediatype_supported(void)
IMFActivate *activate;
IMFStreamSink *stream;
IMFMediaSink *sink;
- ULONG refcount;
HRESULT hr;
GUID guid;
+ LONG ref;
/* IsMediaTypeSupported checks are done against the creation type, and check format data */
hr = MFCreateMediaType(&media_type);
@@ -3454,8 +3570,6 @@ static void test_sample_grabber_is_mediatype_supported(void)
ok(hr == S_OK, "Failed to get type handler, hr %#lx.\n", hr);
IMFStreamSink_Release(stream);
- IMFMediaSink_Release(sink);
-
/* On Win8+ this initialization happens automatically. */
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, media_type);
ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr);
@@ -3514,13 +3628,25 @@ static void test_sample_grabber_is_mediatype_supported(void)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(IsEqualGUID(&guid, &MFMediaType_Audio), "Unexpected major type.\n");
- IMFMediaType_Release(media_type2);
- IMFMediaType_Release(media_type);
-
IMFMediaTypeHandler_Release(handler);
- refcount = IMFActivate_Release(activate);
- ok(!refcount, "Unexpected refcount %lu.\n", refcount);
+ hr = IMFActivate_ShutdownObject(activate);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+ ref = IMFActivate_Release(activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
+
+ /* required for the sink to be fully released */
+ hr = IMFMediaSink_Shutdown(sink);
+ ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
+
+ ref = IMFMediaSink_Release(sink);
+ ok(ref == 0, "Release returned %ld\n", ref);
+
+ ref = IMFMediaType_Release(media_type2);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaType_Release(media_type);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
static BOOL is_supported_video_type(const GUID *guid)
@@ -3627,6 +3753,7 @@ static void test_video_processor(void)
UINT32 count;
HRESULT hr;
GUID guid;
+ LONG ref;
hr = CoInitialize(NULL);
ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
@@ -3742,7 +3869,8 @@ todo_wine {
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_ProcessEvent(transform, 1, event);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
- IMFMediaEvent_Release(event);
+ ref = IMFMediaEvent_Release(event);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Configure stream types. */
for (i = 0;;++i)
@@ -3757,7 +3885,8 @@ todo_wine {
hr = IMFTransform_GetInputAvailableType(transform, 0, i, &media_type2);
ok(hr == S_OK, "Failed to get available type, hr %#lx.\n", hr);
ok(media_type != media_type2, "Unexpected instance.\n");
- IMFMediaType_Release(media_type2);
+ ref = IMFMediaType_Release(media_type2);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = IMFMediaType_GetMajorType(media_type, &guid);
ok(hr == S_OK, "Failed to get major type, hr %#lx.\n", hr);
@@ -3785,7 +3914,8 @@ todo_wine {
|| IsEqualGUID(&guid, &MFVideoFormat_D16) || IsEqualGUID(&guid, &MFVideoFormat_420O)
|| IsEqualGUID(&guid, &MFVideoFormat_A16B16G16R16F))
{
- IMFMediaType_Release(media_type);
+ ref = IMFMediaType_Release(media_type);
+ ok(ref == 0, "Release returned %ld\n", ref);
continue;
}
@@ -3921,13 +4051,17 @@ todo_wine {
ok(flags == 0, "Unexpected status %#lx.\n", flags);
}
- IMFSample_Release(sample2);
- IMFSample_Release(sample);
- IMFMediaBuffer_Release(buffer);
+ ref = IMFTransform_Release(transform);
+ ok(ref == 0, "Release returned %ld\n", ref);
- IMFMediaType_Release(media_type);
-
- IMFTransform_Release(transform);
+ ref = IMFMediaType_Release(media_type);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFSample_Release(sample2);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFSample_Release(sample);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaBuffer_Release(buffer);
+ ok(ref == 0, "Release returned %ld\n", ref);
failed:
CoUninitialize();
@@ -3939,6 +4073,7 @@ static void test_quality_manager(void)
IMFQualityManager *manager;
IMFTopology *topology;
HRESULT hr;
+ LONG ref;
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr);
@@ -3982,21 +4117,25 @@ static void test_quality_manager(void)
hr = IMFQualityManager_Shutdown(manager);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IMFQualityManager_Release(manager);
+ ref = IMFQualityManager_Release(manager);
+ ok(ref == 0, "Release returned %ld\n", ref);
- /* Set clock, then release without shutting down. */
hr = MFCreateStandardQualityManager(&manager);
ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr);
EXPECT_REF(clock, 1);
+ EXPECT_REF(manager, 1);
hr = IMFQualityManager_NotifyPresentationClock(manager, clock);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+ EXPECT_REF(manager, 2);
EXPECT_REF(clock, 2);
+ hr = IMFQualityManager_Shutdown(manager);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IMFQualityManager_Release(manager);
- EXPECT_REF(clock, 2);
-
- IMFPresentationClock_Release(clock);
+ ref = IMFQualityManager_Release(manager);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFPresentationClock_Release(clock);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Set topology. */
hr = MFCreateStandardQualityManager(&manager);
@@ -4025,7 +4164,8 @@ static void test_quality_manager(void)
hr = IMFQualityManager_NotifyTopology(manager, topology);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- IMFQualityManager_Release(manager);
+ ref = IMFQualityManager_Release(manager);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFCreateStandardQualityManager(&manager);
ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr);
@@ -4035,10 +4175,10 @@ static void test_quality_manager(void)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
EXPECT_REF(topology, 2);
- IMFQualityManager_Release(manager);
- EXPECT_REF(topology, 1);
-
- IMFTopology_Release(topology);
+ ref = IMFQualityManager_Release(manager);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFTopology_Release(topology);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFShutdown();
ok(hr == S_OK, "Shutdown failure, hr %#lx.\n", hr);
@@ -4168,6 +4308,7 @@ static void test_sar(void)
GUID guid;
BOOL mute;
int found;
+ LONG ref;
hr = CoInitialize(NULL);
ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
@@ -4495,7 +4636,9 @@ if (SUCCEEDED(hr))
check_sar_rate_support(sink);
- IMFMediaSink_Release(sink);
+ ref = IMFMediaSink_Release(sink);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Activation */
hr = MFCreateAudioRendererActivate(&activate);
@@ -4518,23 +4661,30 @@ if (SUCCEEDED(hr))
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- IMFMediaSink_Release(sink);
-
- hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink);
+ hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink2);
ok(hr == S_OK, "Failed to activate, hr %#lx.\n", hr);
+ todo_wine
+ ok(sink == sink2, "Unexpected instance.\n");
- hr = IMFMediaSink_GetCharacteristics(sink, &flags);
+ hr = IMFMediaSink_GetCharacteristics(sink2, &flags);
todo_wine
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- IMFMediaSink_Release(sink);
+ IMFMediaSink_Release(sink2);
hr = IMFActivate_DetachObject(activate);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
- IMFActivate_Release(activate);
+ hr = IMFActivate_ShutdownObject(activate);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+ ref = IMFActivate_Release(activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaSink_Release(sink);
+ ok(ref == 0, "Release returned %ld\n", ref);
- IMFPresentationClock_Release(present_clock);
+ ref = IMFPresentationClock_Release(present_clock);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFShutdown();
ok(hr == S_OK, "Shutdown failure, hr %#lx.\n", hr);
@@ -4549,7 +4699,13 @@ if (SUCCEEDED(hr))
hr = MFCreateAudioRenderer(attributes, &sink);
ok(hr == S_OK, "Failed to create a sink, hr %#lx.\n", hr);
- IMFMediaSink_Release(sink);
+
+ /* required for the sink to be fully released */
+ hr = IMFMediaSink_Shutdown(sink);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+ ref = IMFMediaSink_Release(sink);
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Invalid endpoint. */
hr = IMFAttributes_SetString(attributes, &MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID, L"endpoint");
@@ -4564,7 +4720,8 @@ if (SUCCEEDED(hr))
hr = MFCreateAudioRenderer(attributes, &sink);
ok(hr == MF_E_NO_AUDIO_PLAYBACK_DEVICE, "Failed to create a sink, hr %#lx.\n", hr);
- IMFAttributes_Release(attributes);
+ ref = IMFAttributes_Release(attributes);
+ ok(ref == 0, "Release returned %ld\n", ref);
CoUninitialize();
}
@@ -4595,10 +4752,10 @@ static void test_evr(void)
IMFSample *sample;
unsigned int i;
UINT64 window3;
- IUnknown *unk;
float rate;
HRESULT hr;
GUID guid;
+ LONG ref;
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr);
@@ -4609,7 +4766,16 @@ static void test_evr(void)
hr = IMFVideoRenderer_InitializeRenderer(video_renderer, NULL, NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IMFVideoRenderer_Release(video_renderer);
+ /* required for the video renderer to be fully released */
+ hr = IMFVideoRenderer_QueryInterface(video_renderer, &IID_IMFMediaSink, (void **)&sink);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+ hr = IMFMediaSink_Shutdown(sink);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+ IMFMediaSink_Release(sink);
+
+ ref = IMFVideoRenderer_Release(video_renderer);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFCreateVideoRendererActivate(NULL, NULL);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
@@ -4654,8 +4820,14 @@ static void test_evr(void)
ok(window2 == window, "Unexpected window %p.\n", window2);
IMFVideoDisplayControl_Release(display_control);
- IMFMediaSink_Release(sink);
- IMFActivate_Release(activate);
+
+ hr = IMFActivate_ShutdownObject(activate);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+ ref = IMFActivate_Release(activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaSink_Release(sink);
+ ok(ref == 0, "Release returned %ld\n", ref);
DestroyWindow(window);
hr = MFCreateVideoRendererActivate(NULL, &activate);
@@ -4674,9 +4846,8 @@ static void test_evr(void)
hr = IMFMediaSink_QueryInterface(sink, &IID_IMFAttributes, (void **)&attributes);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFAttributes_QueryInterface(attributes, &IID_IMFMediaSink, (void **)&unk);
- ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IUnknown_Release(unk);
+ check_interface(attributes, &IID_IMFMediaSink, TRUE);
+
hr = IMFAttributes_GetCount(attributes, &attr_count);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!!attr_count, "Unexpected count %u.\n", attr_count);
@@ -4709,9 +4880,7 @@ static void test_evr(void)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(value == 1, "Unexpected attribute value %u.\n", value);
- hr = IMFAttributes_QueryInterface(attributes, &IID_IMFStreamSink, (void **)&unk);
- ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IUnknown_Release(unk);
+ check_interface(attributes, &IID_IMFStreamSink, TRUE);
IMFAttributes_Release(attributes);
hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, &type_handler);
@@ -4779,9 +4948,7 @@ static void test_evr(void)
hr = IMFMediaTypeHandler_GetCurrentMediaType(type_handler, &media_type2);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaType_QueryInterface(media_type2, &IID_IMFVideoMediaType, (void **)&unk);
- ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IUnknown_Release(unk);
+ check_interface(media_type2, &IID_IMFVideoMediaType, TRUE);
IMFMediaType_Release(media_type2);
IMFMediaType_Release(media_type);
@@ -4817,6 +4984,7 @@ todo_wine {
IMFVideoSampleAllocatorCallback_Release(allocator_callback);
IMFVideoSampleAllocator_Release(allocator);
+ IMFStreamSink_Release(stream_sink);
/* Same test for a substream. */
hr = IMFMediaSink_AddStreamSink(sink, 1, NULL, &stream_sink2);
@@ -4832,7 +5000,8 @@ todo_wine {
hr = IMFMediaSink_RemoveStreamSink(sink, 1);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IMFStreamSink_Release(stream_sink2);
+ ref = IMFStreamSink_Release(stream_sink2);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
@@ -4860,14 +5029,18 @@ todo_wine {
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink2);
ok(hr == S_OK, "Failed to activate, hr %#lx.\n", hr);
+ todo_wine
+ ok(sink == sink2, "Unexpected instance.\n");
+ IMFMediaSink_Release(sink2);
hr = IMFActivate_ShutdownObject(activate);
ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
- IMFMediaSink_Release(sink2);
- IMFMediaSink_Release(sink);
-
- IMFActivate_Release(activate);
+ ref = IMFActivate_Release(activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaSink_Release(sink);
+ todo_wine
+ ok(ref == 0, "Release returned %ld\n", ref);
/* Set clock. */
window = create_window();
@@ -4877,6 +5050,8 @@ todo_wine {
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+ ref = IMFActivate_Release(activate);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = MFCreateSystemTimeSource(&time_source);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
@@ -4965,6 +5140,9 @@ todo_wine {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaTypeHandler_SetCurrentMediaType(type_handler, media_type);
ok(hr == S_OK, "Failed to set current type, hr %#lx.\n", hr);
+ IMFMediaType_Release(media_type);
+ IMFMediaTypeHandler_Release(type_handler);
+ IMFStreamSink_Release(stream_sink);
rate = 1.0f;
hr = IMFRateSupport_GetSlowestRate(rs, MFRATE_FORWARD, TRUE, &rate);
@@ -5011,10 +5189,6 @@ todo_wine {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
}
- IMFMediaTypeHandler_Release(type_handler);
- IMFMediaType_Release(media_type);
- IMFStreamSink_Release(stream_sink);
-
hr = IMFMediaSink_Shutdown(sink);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
@@ -5039,9 +5213,13 @@ todo_wine {
hr = IMFRateSupport_IsRateSupported(rs, TRUE, 1.0f, &rate);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- IMFPresentationClock_Release(clock);
+ ref = IMFRateSupport_Release(rs);
+ ok(ref == 1, "Release returned %ld\n", ref);
+ ref = IMFMediaSink_Release(sink);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFPresentationClock_Release(clock);
+ ok(ref == 0, "Release returned %ld\n", ref);
- IMFActivate_Release(activate);
DestroyWindow(window);
hr = MFShutdown();
@@ -5055,6 +5233,7 @@ static void test_MFCreateSimpleTypeHandler(void)
DWORD count;
HRESULT hr;
GUID guid;
+ LONG ref;
hr = MFCreateSimpleTypeHandler(&handler);
ok(hr == S_OK, "Failed to create object, hr %#lx.\n", hr);
@@ -5178,21 +5357,24 @@ static void test_MFCreateSimpleTypeHandler(void)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!media_type2, "Unexpected pointer.\n");
- IMFMediaType_Release(media_type3);
- IMFMediaType_Release(media_type);
+ ref = IMFMediaType_Release(media_type3);
+ ok(ref == 0, "Release returned %ld\n", ref);
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, NULL);
ok(hr == S_OK, "Failed to set current type, hr %#lx.\n", hr);
- media_type = (void *)0xdeadbeef;
- hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &media_type);
+ media_type2 = (void *)0xdeadbeef;
+ hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &media_type2);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- ok(!media_type, "Unexpected pointer.\n");
+ ok(!media_type2, "Unexpected pointer.\n");
hr = IMFMediaTypeHandler_GetMajorType(handler, &guid);
ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- IMFMediaTypeHandler_Release(handler);
+ ref = IMFMediaTypeHandler_Release(handler);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaType_Release(media_type);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
static void test_MFGetSupportedMimeTypes(void)
@@ -5258,6 +5440,7 @@ static void test_sample_copier(void)
DWORD flags, status;
UINT32 value, count;
HRESULT hr;
+ LONG ref;
if (!pMFCreateSampleCopierMFT)
{
@@ -5280,7 +5463,8 @@ static void test_sample_copier(void)
hr = IMFAttributes_GetUINT32(attributes, &MFT_SUPPORT_DYNAMIC_FORMAT_CHANGE, &value);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!!value, "Unexpected value %u.\n", value);
- IMFAttributes_Release(attributes);
+ ref = IMFAttributes_Release(attributes);
+ ok(ref == 1, "Release returned %ld\n", ref);
hr = IMFTransform_GetInputStreamAttributes(copier, 0, &attributes);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
@@ -5505,13 +5689,16 @@ static void test_sample_copier(void)
hr = IMFTransform_ProcessMessage(copier, MFT_MESSAGE_COMMAND_FLUSH, 0);
ok(hr == S_OK, "Failed to flush, hr %#lx.\n", hr);
- EXPECT_REF(sample, 1);
- IMFSample_Release(sample);
- IMFSample_Release(client_sample);
+ ref = IMFSample_Release(sample);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFSample_Release(client_sample);
+ ok(ref == 0, "Release returned %ld\n", ref);
- IMFMediaType_Release(mediatype);
- IMFTransform_Release(copier);
+ ref = IMFTransform_Release(copier);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaType_Release(mediatype);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
struct sample_metadata
@@ -5530,6 +5717,7 @@ static void sample_copier_process(IMFTransform *copier, IMFMediaBuffer *input_bu
DWORD flags, status;
LONGLONG time;
HRESULT hr;
+ LONG ref;
hr = MFCreateSample(&input_sample);
ok(hr == S_OK, "Failed to create a sample, hr %#lx.\n", hr);
@@ -5585,8 +5773,10 @@ static void sample_copier_process(IMFTransform *copier, IMFMediaBuffer *input_bu
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(md->duration == time, "Unexpected duration.\n");
- IMFSample_Release(input_sample);
- IMFSample_Release(output_sample);
+ ref = IMFSample_Release(input_sample);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFSample_Release(output_sample);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
static void test_sample_copier_output_processing(void)
@@ -5599,6 +5789,7 @@ static void test_sample_copier_output_processing(void)
DWORD max_length;
HRESULT hr;
BYTE *ptr;
+ LONG ref;
if (!pMFCreateSampleCopierMFT)
return;
@@ -5663,11 +5854,15 @@ static void test_sample_copier_output_processing(void)
md.duration = 2;
sample_copier_process(copier, input_buffer, output_buffer, &md);
- IMFMediaBuffer_Release(input_buffer);
- IMFMediaBuffer_Release(output_buffer);
+ ref = IMFMediaBuffer_Release(input_buffer);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaBuffer_Release(output_buffer);
+ ok(ref == 0, "Release returned %ld\n", ref);
- IMFMediaType_Release(mediatype);
- IMFTransform_Release(copier);
+ ref = IMFTransform_Release(copier);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaType_Release(mediatype);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
static void test_MFGetTopoNodeCurrentType(void)
@@ -5675,6 +5870,7 @@ static void test_MFGetTopoNodeCurrentType(void)
IMFMediaType *media_type, *media_type2;
IMFTopologyNode *node;
HRESULT hr;
+ LONG ref;
if (!pMFGetTopoNodeCurrentType)
{
@@ -5752,8 +5948,10 @@ static void test_MFGetTopoNodeCurrentType(void)
ok(media_type == media_type2, "Unexpected pointer.\n");
IMFMediaType_Release(media_type);
- IMFTopologyNode_Release(node);
- IMFMediaType_Release(media_type2);
+ ref = IMFTopologyNode_Release(node);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaType_Release(media_type2);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
static void init_functions(void)
@@ -5772,6 +5970,7 @@ static void test_MFRequireProtectedEnvironment(void)
IMFMediaType *mediatype;
IMFStreamDescriptor *sd;
HRESULT hr;
+ LONG ref;
hr = MFCreateMediaType(&mediatype);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
@@ -5800,9 +5999,12 @@ static void test_MFRequireProtectedEnvironment(void)
hr = MFRequireProtectedEnvironment(pd);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IMFMediaType_Release(mediatype);
- IMFStreamDescriptor_Release(sd);
- IMFPresentationDescriptor_Release(pd);
+ ref = IMFPresentationDescriptor_Release(pd);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFStreamDescriptor_Release(sd);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFMediaType_Release(mediatype);
+ ok(ref == 0, "Release returned %ld\n", ref);
}
static IMFSample *create_sample(const BYTE *data, ULONG size)
@@ -5989,6 +6191,7 @@ static void test_wma_encoder(void)
GUID class_id;
ULONG i, ret;
HRESULT hr;
+ LONG ref;
hr = CoInitialize(NULL);
ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
@@ -6051,7 +6254,8 @@ static void test_wma_encoder(void)
ok(hr == S_OK, "ProcessMessage returned %#lx\n", hr);
hr = IMFTransform_ProcessInput(transform, 0, sample, 0);
ok(hr == MF_E_NOTACCEPTING, "ProcessInput returned %#lx\n", hr);
- IMFSample_Release(sample);
+ ref = IMFSample_Release(sample);
+ ok(ref <= 1, "Release returned %ld\n", ref);
status = 0xdeadbeef;
sample = create_sample(NULL, output_info.cbSize);
@@ -6463,8 +6667,10 @@ static void test_wma_decoder(void)
outputs[1].pSample = sample;
hr = IMFTransform_ProcessOutput(transform, 0, 2, outputs, &status);
ok(hr == E_INVALIDARG, "ProcessOutput returned %#lx\n", hr);
- IMFSample_Release(outputs[0].pSample);
- IMFSample_Release(outputs[1].pSample);
+ ref = IMFSample_Release(outputs[0].pSample);
+ ok(ref == 0, "Release returned %ld\n", ref);
+ ref = IMFSample_Release(outputs[1].pSample);
+ ok(ref == 0, "Release returned %ld\n", ref);
resource = FindResourceW(NULL, L"wmadecdata.bin", (const WCHAR *)RT_RCDATA);
ok(resource != 0, "FindResourceW failed, error %lu\n", GetLastError());
@@ -6943,7 +7149,9 @@ static void test_h264_decoder(void)
ok(hr == S_OK, "GetAttributes returned %#lx\n", hr);
hr = IMFAttributes_SetUINT32(attributes, &MF_LOW_LATENCY, 1);
ok(hr == S_OK, "SetUINT32 returned %#lx\n", hr);
- IMFAttributes_Release(attributes);
+ ret = IMFAttributes_Release(attributes);
+ todo_wine
+ ok(ret == 1, "Release returned %ld\n", ret);
/* no output type is available before an input type is set */
@@ -7707,7 +7915,8 @@ static void test_audio_convert(void)
ok(hr == S_OK, "ProcessMessage returned %#lx\n", hr);
hr = IMFTransform_ProcessInput(transform, 0, sample, 0);
ok(hr == MF_E_NOTACCEPTING, "ProcessInput returned %#lx\n", hr);
- IMFSample_Release(sample);
+ ret = IMFSample_Release(sample);
+ ok(ret <= 1, "Release returned %ld\n", ret);
status = 0xdeadbeef;
sample = create_sample(NULL, audioconv_block_size);
@@ -8142,7 +8351,8 @@ static void test_color_convert(void)
ok(hr == MF_E_NOTACCEPTING, "ProcessInput returned %#lx\n", hr);
hr = IMFTransform_ProcessMessage(transform, MFT_MESSAGE_COMMAND_DRAIN, 0);
ok(hr == S_OK, "ProcessMessage returned %#lx\n", hr);
- IMFSample_Release(sample);
+ ret = IMFSample_Release(sample);
+ ok(ret <= 1, "Release returned %ld\n", ret);
resource = FindResourceW(NULL, L"rgb32frame.bin", (const WCHAR *)RT_RCDATA);
ok(resource != 0, "FindResourceW failed, error %lu\n", GetLastError());
@@ -8200,7 +8410,8 @@ static void test_color_convert(void)
ret = IMFSample_Release(sample);
ok(ret == 0, "Release returned %lu\n", ret);
- IMFTransform_Release(transform);
+ ret = IMFTransform_Release(transform);
+ ok(ret == 0, "Release returned %ld\n", ret);
failed:
CoUninitialize();
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/310
June 27, 2022
[PATCH v3 0/4] MR310: mf: Fix several reference leaks.
by Rémi Bernon
So that the mf tests pass again on 32bit on the testbot, though they still fail locally with `LIBGL_ALWAYS_SOFTWARE=true GALLIUM_DRIVER=softpipe`.
--
v3: mf: Uninitialize renderer before creating mixer and presenter.
mf: Release video renderer services before re-initializing.
mf: Avoid leaking nodes in IMFTopoLoader_Load.
mf/tests: Add some missing IMFActivate_Shutdown calls.
https://gitlab.winehq.org/wine/wine/-/merge_requests/310
June 27, 2022
Re: [PATCH v2 0/5] MR321: win32u: menu conversion - approved
by Huw Davies (@huw)
This merge request was approved by Huw Davies.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/321
June 27, 2022
Re: [PATCH v2 0/5] MR321: win32u: menu conversion
by Huw Davies (@huw)
I've pushed v2 which removes a few tabs.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/321#note_2758
June 27, 2022
[PATCH v2 5/5] user32: Remove no longer needed helpers.
by Jacek Caban
From: Jacek Caban <jacek(a)codeweavers.com>
---
dlls/user32/sysparams.c | 19 -------------------
dlls/user32/win.c | 37 ++++++++++++-------------------------
dlls/user32/win.h | 9 +--------
3 files changed, 13 insertions(+), 52 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
index 738186afb89..26259ab76e9 100644
--- a/dlls/user32/sysparams.c
+++ b/dlls/user32/sysparams.c
@@ -669,15 +669,6 @@ BOOL WINAPI EnumDisplaySettingsExW( const WCHAR *device, DWORD mode,
return NtUserEnumDisplaySettings( &str, mode, dev_mode, flags );
}
-/**********************************************************************
- * get_monitor_dpi
- */
-UINT get_monitor_dpi( HMONITOR monitor )
-{
- /* FIXME: use the monitor DPI instead */
- return system_dpi;
-}
-
/**********************************************************************
* get_win_monitor_dpi
*/
@@ -729,16 +720,6 @@ static POINT point_phys_to_win_dpi( HWND hwnd, POINT pt )
return map_dpi_point( pt, get_win_monitor_dpi( hwnd ), GetDpiForWindow( hwnd ));
}
-/**********************************************************************
- * point_win_to_thread_dpi
- */
-POINT point_win_to_thread_dpi( HWND hwnd, POINT pt )
-{
- UINT dpi = get_thread_dpi();
- if (!dpi) dpi = get_win_monitor_dpi( hwnd );
- return map_dpi_point( pt, GetDpiForWindow( hwnd ), dpi );
-}
-
/**********************************************************************
* map_dpi_rect
*/
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 9d19376fe44..d1b25da0e68 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -37,25 +37,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(win);
-/***********************************************************************
- * get_user_handle_ptr
- */
-void *get_user_handle_ptr( HANDLE handle, unsigned int type )
-{
- return (void *)NtUserCallTwoParam( HandleToUlong(handle), type, NtUserGetHandlePtr );
-}
-
-
-/***********************************************************************
- * release_user_handle_ptr
- */
-void release_user_handle_ptr( void *ptr )
-{
- assert( ptr && ptr != OBJ_OTHER_PROCESS );
- NtUserCallOneParam( 1, NtUserLock );
-}
-
-
/*******************************************************************
* list_window_children
*
@@ -149,16 +130,22 @@ BOOL is_desktop_window( HWND hwnd )
*/
WND *WIN_GetPtr( HWND hwnd )
{
- WND *ptr;
-
- if ((ptr = get_user_handle_ptr( hwnd, NTUSER_OBJ_WINDOW )) == WND_OTHER_PROCESS)
- {
- if (is_desktop_window( hwnd )) ptr = WND_DESKTOP;
- }
+ WND *ptr = (void *)NtUserCallTwoParam( HandleToUlong(hwnd), NTUSER_OBJ_WINDOW, NtUserGetHandlePtr );
+ if (ptr == WND_OTHER_PROCESS && is_desktop_window( hwnd )) ptr = WND_DESKTOP;
return ptr;
}
+/***********************************************************************
+ * WIN_ReleasePtr
+ */
+void WIN_ReleasePtr( WND *ptr )
+{
+ assert( ptr && ptr != OBJ_OTHER_PROCESS );
+ NtUserCallOneParam( 1, NtUserLock );
+}
+
+
/***********************************************************************
* WIN_IsCurrentProcess
*
diff --git a/dlls/user32/win.h b/dlls/user32/win.h
index bce93617d3f..59a7e0e2e38 100644
--- a/dlls/user32/win.h
+++ b/dlls/user32/win.h
@@ -37,6 +37,7 @@ struct tagDIALOGINFO;
extern HWND get_hwnd_message_parent(void) DECLSPEC_HIDDEN;
extern BOOL is_desktop_window( HWND hwnd ) DECLSPEC_HIDDEN;
extern WND *WIN_GetPtr( HWND hwnd ) DECLSPEC_HIDDEN;
+extern void WIN_ReleasePtr( WND *ptr ) DECLSPEC_HIDDEN;
extern HWND WIN_GetFullHandle( HWND hwnd ) DECLSPEC_HIDDEN;
extern HWND WIN_IsCurrentProcess( HWND hwnd ) DECLSPEC_HIDDEN;
extern HWND WIN_IsCurrentThread( HWND hwnd ) DECLSPEC_HIDDEN;
@@ -48,20 +49,12 @@ extern HWND *WIN_ListChildren( HWND hwnd ) DECLSPEC_HIDDEN;
extern void MDI_CalcDefaultChildPos( HWND hwndClient, INT total, LPPOINT lpPos, INT delta, UINT *id ) DECLSPEC_HIDDEN;
extern HDESK open_winstation_desktop( HWINSTA hwinsta, LPCWSTR name, DWORD flags, BOOL inherit, ACCESS_MASK access ) DECLSPEC_HIDDEN;
-/* to release pointers retrieved by WIN_GetPtr */
-static inline void WIN_ReleasePtr( WND *ptr )
-{
- release_user_handle_ptr( ptr );
-}
-
extern void WINPOS_ActivateOtherWindow( HWND hwnd ) DECLSPEC_HIDDEN;
-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 POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN;
extern POINT point_win_to_phys_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN;
-extern POINT point_win_to_thread_dpi( HWND hwnd, POINT pt ) 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;
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/321
June 27, 2022
[PATCH v2 4/5] win32u: Move menu object declarations to menu.c.
by Jacek Caban
From: Jacek Caban <jacek(a)codeweavers.com>
And drop typedefs.
---
dlls/win32u/menu.c | 289 ++++++++++++++++++++---------------
dlls/win32u/ntuser_private.h | 49 ------
2 files changed, 167 insertions(+), 171 deletions(-)
diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c
index 64c832c58a9..c67d0e00615 100644
--- a/dlls/win32u/menu.c
+++ b/dlls/win32u/menu.c
@@ -32,6 +32,51 @@
WINE_DEFAULT_DEBUG_CHANNEL(menu);
WINE_DECLARE_DEBUG_CHANNEL(accel);
+
+/* menu item structure */
+struct menu_item
+{
+ UINT fType; /* item type */
+ UINT fState; /* item state */
+ UINT_PTR wID; /* item id */
+ HMENU hSubMenu; /* pop-up menu */
+ HBITMAP hCheckBit; /* bitmap when checked */
+ HBITMAP hUnCheckBit; /* bitmap when unchecked */
+ LPWSTR text; /* item text */
+ ULONG_PTR dwItemData; /* application defined */
+ LPWSTR dwTypeData; /* depends on fMask */
+ HBITMAP hbmpItem; /* bitmap */
+ RECT rect; /* item area (relative to the items_rect), see adjust_menu_item_rect */
+ UINT xTab; /* X position of text after Tab */
+ SIZE bmpsize; /* size needed for the HBMMENU_CALLBACK bitmap */
+};
+
+/* menu user object */
+struct menu
+{
+ struct user_object obj;
+ struct menu_item *items; /* array of menu items */
+ WORD wFlags; /* menu flags (MF_POPUP, MF_SYSMENU) */
+ WORD Width; /* width of the whole menu */
+ WORD Height; /* height of the whole menu */
+ UINT nItems; /* number of items in the menu */
+ HWND hWnd; /* window containing the menu */
+ UINT FocusedItem; /* currently focused item */
+ HWND hwndOwner; /* window receiving the messages for ownerdraw */
+ BOOL bScrolling; /* scroll arrows are active */
+ UINT nScrollPos; /* current scroll position */
+ UINT nTotalHeight; /* total height of menu items inside menu */
+ RECT items_rect; /* rectangle within which the items lie, excludes margins and scroll arrows */
+ LONG refcount;
+ DWORD dwStyle; /* extended menu style */
+ UINT cyMax; /* max height of the whole menu, 0 is screen height */
+ HBRUSH hbrBack; /* brush for menu background */
+ DWORD dwContextHelpID;
+ ULONG_PTR dwMenuData; /* application defined value */
+ HMENU hSysMenuOwner; /* handle to the dummy sys menu holder */
+ WORD textOffset; /* offset of text when items have both bitmaps and text */
+};
+
/* the accelerator user object */
struct accelerator
{
@@ -190,7 +235,7 @@ BOOL WINAPI NtUserDestroyAcceleratorTable( HACCEL handle )
if (flags & (bit)) { flags &= ~(bit); strcat(buf, (text)); } \
} while (0)
-static const char *debugstr_menuitem( const MENUITEM *item )
+static const char *debugstr_menuitem( const struct menu_item *item )
{
static const char *const hbmmenus[] = { "HBMMENU_CALLBACK", "", "HBMMENU_SYSTEM",
"HBMMENU_MBAR_RESTORE", "HBMMENU_MBAR_MINIMIZE", "UNKNOWN BITMAP", "HBMMENU_MBAR_CLOSE",
@@ -252,9 +297,9 @@ static const char *debugstr_menuitem( const MENUITEM *item )
#undef MENUFLAG
-static POPUPMENU *grab_menu_ptr( HMENU handle )
+static struct menu *grab_menu_ptr( HMENU handle )
{
- POPUPMENU *menu = get_user_handle_ptr( handle, NTUSER_OBJ_MENU );
+ struct menu *menu = get_user_handle_ptr( handle, NTUSER_OBJ_MENU );
if (menu == OBJ_OTHER_PROCESS)
{
@@ -269,7 +314,7 @@ static POPUPMENU *grab_menu_ptr( HMENU handle )
return menu;
}
-static void release_menu_ptr( POPUPMENU *menu )
+static void release_menu_ptr( struct menu *menu )
{
if (menu)
{
@@ -282,9 +327,9 @@ static void release_menu_ptr( POPUPMENU *menu )
* Validate the given menu handle and returns the menu structure pointer.
* FIXME: this is unsafe, we should use a better mechanism instead.
*/
-static POPUPMENU *unsafe_menu_ptr( HMENU handle )
+static struct menu *unsafe_menu_ptr( HMENU handle )
{
- POPUPMENU *menu = grab_menu_ptr( handle );
+ struct menu *menu = grab_menu_ptr( handle );
if (menu) release_menu_ptr( menu );
return menu;
}
@@ -292,7 +337,7 @@ static POPUPMENU *unsafe_menu_ptr( HMENU handle )
/* see IsMenu */
BOOL is_menu( HMENU handle )
{
- POPUPMENU *menu;
+ struct menu *menu;
BOOL is_menu;
menu = grab_menu_ptr( handle );
@@ -320,10 +365,10 @@ static HMENU get_win_sys_menu( HWND hwnd )
return ret;
}
-static POPUPMENU *find_menu_item( HMENU handle, UINT id, UINT flags, UINT *pos )
+static struct menu *find_menu_item( HMENU handle, UINT id, UINT flags, UINT *pos )
{
UINT fallback_pos = ~0u, i;
- POPUPMENU *menu;
+ struct menu *menu;
menu = grab_menu_ptr( handle );
if (!menu)
@@ -342,12 +387,12 @@ static POPUPMENU *find_menu_item( HMENU handle, UINT id, UINT flags, UINT *pos )
}
else
{
- MENUITEM *item = menu->items;
+ struct menu_item *item = menu->items;
for (i = 0; i < menu->nItems; i++, item++)
{
if (item->fType & MF_POPUP)
{
- POPUPMENU *submenu = find_menu_item( item->hSubMenu, id, flags, pos );
+ struct menu *submenu = find_menu_item( item->hSubMenu, id, flags, pos );
if (submenu)
{
@@ -379,10 +424,10 @@ static POPUPMENU *find_menu_item( HMENU handle, UINT id, UINT flags, UINT *pos )
return menu;
}
-static POPUPMENU *insert_menu_item( HMENU handle, UINT id, UINT flags, UINT *ret_pos )
+static struct menu *insert_menu_item( HMENU handle, UINT id, UINT flags, UINT *ret_pos )
{
- MENUITEM *new_items;
- POPUPMENU *menu;
+ struct menu_item *new_items;
+ struct menu *menu;
UINT pos = id;
/* Find where to insert new item */
@@ -403,7 +448,7 @@ static POPUPMENU *insert_menu_item( HMENU handle, UINT id, UINT flags, UINT *ret
TRACE( "inserting at %u flags %x\n", pos, flags );
- new_items = malloc( sizeof(MENUITEM) * (menu->nItems + 1) );
+ new_items = malloc( sizeof(*new_items) * (menu->nItems + 1) );
if (!new_items)
{
release_menu_ptr( menu );
@@ -412,9 +457,9 @@ static POPUPMENU *insert_menu_item( HMENU handle, UINT id, UINT flags, UINT *ret
if (menu->nItems > 0)
{
/* Copy the old array into the new one */
- if (pos > 0) memcpy( new_items, menu->items, pos * sizeof(MENUITEM) );
+ if (pos > 0) memcpy( new_items, menu->items, pos * sizeof(*new_items) );
if (pos < menu->nItems) memcpy( &new_items[pos + 1], &menu->items[pos],
- (menu->nItems - pos) * sizeof(MENUITEM) );
+ (menu->nItems - pos) * sizeof(*new_items) );
free( menu->items );
}
menu->items = new_items;
@@ -440,8 +485,8 @@ static BOOL is_win_menu_disallowed( HWND hwnd )
*/
static UINT find_submenu( HMENU *handle_ptr, HMENU target )
{
- POPUPMENU *menu;
- MENUITEM *item;
+ struct menu *menu;
+ struct menu_item *item;
UINT i;
if (*handle_ptr == (HMENU)0xffff || !(menu = grab_menu_ptr( *handle_ptr )))
@@ -474,7 +519,7 @@ static UINT find_submenu( HMENU *handle_ptr, HMENU target )
}
/* Adjust menu item rectangle according to scrolling state */
-static void adjust_menu_item_rect( const POPUPMENU *menu, RECT *rect )
+static void adjust_menu_item_rect( const struct menu *menu, RECT *rect )
{
INT scroll_offset = menu->bScrolling ? menu->nScrollPos : 0;
OffsetRect( rect, menu->items_rect.left, menu->items_rect.top - scroll_offset );
@@ -493,10 +538,10 @@ static void adjust_menu_item_rect( const POPUPMENU *menu, RECT *rect )
* item that's just outside the items_rect - ie, the one that would
* be scrolled completely into view.
*/
-static enum hittest find_item_by_coords( const POPUPMENU *menu, POINT pt, UINT *pos )
+static enum hittest find_item_by_coords( const struct menu *menu, POINT pt, UINT *pos )
{
enum hittest ht = ht_border;
- MENUITEM *item;
+ struct menu_item *item;
RECT rect;
UINT i;
@@ -552,7 +597,7 @@ HMENU get_menu( HWND hwnd )
/* see CreateMenu and CreatePopupMenu */
HMENU create_menu( BOOL is_popup )
{
- POPUPMENU *menu;
+ struct menu *menu;
HMENU handle;
if (!(menu = calloc( 1, sizeof(*menu) ))) return 0;
@@ -571,7 +616,7 @@ HMENU create_menu( BOOL is_popup )
*/
BOOL WINAPI NtUserDestroyMenu( HMENU handle )
{
- POPUPMENU *menu;
+ struct menu *menu;
TRACE( "(%p)\n", handle );
@@ -588,7 +633,7 @@ BOOL WINAPI NtUserDestroyMenu( HMENU handle )
/* recursively destroy submenus */
if (menu->items)
{
- MENUITEM *item = menu->items;
+ struct menu_item *item = menu->items;
int i;
for (i = menu->nItems; i > 0; i--, item++)
@@ -627,7 +672,7 @@ BOOL set_window_menu( HWND hwnd, HMENU handle )
if (handle)
{
- POPUPMENU *menu;
+ struct menu *menu;
if (!(menu = grab_menu_ptr( handle ))) return FALSE;
menu->hWnd = hwnd;
@@ -657,8 +702,8 @@ BOOL WINAPI NtUserSetMenu( HWND hwnd, HMENU menu )
*/
DWORD WINAPI NtUserCheckMenuItem( HMENU handle, UINT id, UINT flags )
{
- POPUPMENU *menu;
- MENUITEM *item;
+ struct menu_item *item;
+ struct menu *menu;
DWORD ret;
UINT pos;
@@ -679,8 +724,8 @@ DWORD WINAPI NtUserCheckMenuItem( HMENU handle, UINT id, UINT flags )
BOOL WINAPI NtUserEnableMenuItem( HMENU handle, UINT id, UINT flags )
{
UINT oldflags, pos;
- POPUPMENU *menu;
- MENUITEM *item;
+ struct menu *menu;
+ struct menu_item *item;
TRACE( "(%p, %04x, %04x)\n", handle, id, flags );
@@ -695,7 +740,7 @@ BOOL WINAPI NtUserEnableMenuItem( HMENU handle, UINT id, UINT flags )
/* If the close item in the system menu change update the close button */
if (item->wID == SC_CLOSE && oldflags != flags && menu->hSysMenuOwner)
{
- POPUPMENU *parent_menu;
+ struct menu *parent_menu;
RECT rc;
HWND hwnd;
@@ -729,7 +774,7 @@ BOOL draw_menu_bar( HWND hwnd )
if ((handle = get_menu( hwnd )))
{
- POPUPMENU *menu = grab_menu_ptr( handle );
+ struct menu *menu = grab_menu_ptr( handle );
if (menu)
{
menu->Height = 0; /* Make sure we call MENU_MenuBarCalcSize */
@@ -747,7 +792,7 @@ BOOL draw_menu_bar( HWND hwnd )
*/
BOOL WINAPI NtUserGetMenuItemRect( HWND hwnd, HMENU handle, UINT item, RECT *rect )
{
- POPUPMENU *menu;
+ struct menu *menu;
UINT pos;
RECT window_rect;
@@ -784,7 +829,7 @@ BOOL WINAPI NtUserGetMenuItemRect( HWND hwnd, HMENU handle, UINT item, RECT *rec
static BOOL set_menu_info( HMENU handle, const MENUINFO *info )
{
- POPUPMENU *menu;
+ struct menu *menu;
if (!(menu = grab_menu_ptr( handle ))) return FALSE;
@@ -797,7 +842,7 @@ static BOOL set_menu_info( HMENU handle, const MENUINFO *info )
if (info->fMask & MIM_APPLYTOSUBMENUS)
{
int i;
- MENUITEM *item = menu->items;
+ struct menu_item *item = menu->items;
for (i = menu->nItems; i; i--, item++)
if (item->fType & MF_POPUP)
set_menu_info( item->hSubMenu, info);
@@ -838,7 +883,7 @@ BOOL WINAPI NtUserThunkedMenuInfo( HMENU menu, const MENUINFO *info )
/* see GetMenuInfo */
BOOL get_menu_info( HMENU handle, MENUINFO *info )
{
- POPUPMENU *menu;
+ struct menu *menu;
TRACE( "(%p %p)\n", handle, info );
@@ -863,17 +908,17 @@ BOOL get_menu_info( HMENU handle, MENUINFO *info )
*
* detect if there are loops in the menu tree (or the depth is too large)
*/
-static int menu_depth( POPUPMENU *pmenu, int depth)
+static int menu_depth( struct menu *pmenu, int depth)
{
int i, subdepth;
- MENUITEM *item;
+ struct menu_item *item;
if (++depth > MAXMENUDEPTH) return depth;
item = pmenu->items;
subdepth = depth;
for (i = 0; i < pmenu->nItems && subdepth <= MAXMENUDEPTH; i++, item++)
{
- POPUPMENU *submenu = item->hSubMenu ? grab_menu_ptr( item->hSubMenu ) : NULL;
+ struct menu *submenu = item->hSubMenu ? grab_menu_ptr( item->hSubMenu ) : NULL;
if (submenu)
{
int bdepth = menu_depth( submenu, depth);
@@ -887,7 +932,7 @@ static int menu_depth( POPUPMENU *pmenu, int depth)
return subdepth;
}
-static BOOL set_menu_item_info( MENUITEM *menu, const MENUITEMINFOW *info )
+static BOOL set_menu_item_info( struct menu_item *menu, const MENUITEMINFOW *info )
{
if (!menu) return FALSE;
@@ -922,7 +967,7 @@ static BOOL set_menu_item_info( MENUITEM *menu, const MENUITEMINFOW *info )
menu->hSubMenu = info->hSubMenu;
if (menu->hSubMenu)
{
- POPUPMENU *submenu = grab_menu_ptr( menu->hSubMenu );
+ struct menu *submenu = grab_menu_ptr( menu->hSubMenu );
if (!submenu)
{
SetLastError( ERROR_INVALID_PARAMETER);
@@ -964,9 +1009,9 @@ static BOOL set_menu_item_info( MENUITEM *menu, const MENUITEMINFOW *info )
/* see GetMenuState */
UINT get_menu_state( HMENU handle, UINT item_id, UINT flags )
{
- POPUPMENU *menu;
+ struct menu *menu;
UINT state, pos;
- MENUITEM *item;
+ struct menu_item *item;
TRACE( "(menu=%p, id=%04x, flags=%04x);\n", handle, item_id, flags );
@@ -977,7 +1022,7 @@ UINT get_menu_state( HMENU handle, UINT item_id, UINT flags )
TRACE( " item: %s\n", debugstr_menuitem( item ));
if (item->fType & MF_POPUP)
{
- POPUPMENU *submenu = grab_menu_ptr( item->hSubMenu );
+ struct menu *submenu = grab_menu_ptr( item->hSubMenu );
if (submenu)
state = (submenu->nItems << 8) | ((item->fState | item->fType) & 0xff);
else
@@ -994,8 +1039,8 @@ UINT get_menu_state( HMENU handle, UINT item_id, UINT flags )
static BOOL get_menu_item_info( HMENU handle, UINT id, UINT flags, MENUITEMINFOW *info, BOOL ansi )
{
- POPUPMENU *menu;
- MENUITEM *item;
+ struct menu *menu;
+ struct menu_item *item;
UINT pos;
if (!info || info->cbSize != sizeof(*info))
@@ -1111,13 +1156,13 @@ static BOOL get_menu_item_info( HMENU handle, UINT id, UINT flags, MENUITEMINFOW
static BOOL check_menu_radio_item( HMENU handle, UINT first, UINT last, UINT check, UINT flags )
{
- POPUPMENU *first_menu = NULL, *check_menu;
+ struct menu *first_menu = NULL, *check_menu;
UINT i, check_pos;
BOOL done = FALSE;
for (i = first; i <= last; i++)
{
- MENUITEM *item;
+ struct menu_item *item;
if (!(check_menu = find_menu_item( handle, i, flags, &check_pos ))) continue;
if (!first_menu) first_menu = grab_menu_ptr( check_menu->obj.handle );
@@ -1154,7 +1199,7 @@ static BOOL check_menu_radio_item( HMENU handle, UINT first, UINT last, UINT che
/* see GetSubMenu */
static HMENU get_sub_menu( HMENU handle, INT pos )
{
- POPUPMENU *menu;
+ struct menu *menu;
HMENU submenu;
UINT i;
@@ -1173,8 +1218,8 @@ static HMENU get_sub_menu( HMENU handle, INT pos )
/* see GetMenuDefaultItem */
static UINT get_menu_default_item( HMENU handle, UINT bypos, UINT flags )
{
- MENUITEM *item = NULL;
- POPUPMENU *menu;
+ struct menu_item *item = NULL;
+ struct menu *menu;
UINT i;
TRACE( "(%p,%d,%d)\n", handle, bypos, flags );
@@ -1215,7 +1260,7 @@ static UINT get_menu_default_item( HMENU handle, UINT bypos, UINT flags )
UINT WINAPI NtUserThunkedMenuItemInfo( HMENU handle, UINT pos, UINT flags, UINT method,
MENUITEMINFOW *info, UNICODE_STRING *str )
{
- POPUPMENU *menu;
+ struct menu *menu;
UINT i;
BOOL ret;
@@ -1294,7 +1339,7 @@ UINT WINAPI NtUserThunkedMenuItemInfo( HMENU handle, UINT pos, UINT flags, UINT
/* see GetMenuItemCount */
INT get_menu_item_count( HMENU handle )
{
- POPUPMENU *menu;
+ struct menu *menu;
INT count;
if (!(menu = grab_menu_ptr( handle ))) return -1;
@@ -1310,7 +1355,7 @@ INT get_menu_item_count( HMENU handle )
*/
BOOL WINAPI NtUserRemoveMenu( HMENU handle, UINT id, UINT flags )
{
- POPUPMENU *menu;
+ struct menu *menu;
UINT pos;
TRACE( "(menu=%p id=%#x flags=%04x)\n", handle, id, flags );
@@ -1328,7 +1373,7 @@ BOOL WINAPI NtUserRemoveMenu( HMENU handle, UINT id, UINT flags )
}
else
{
- MENUITEM *new_items, *item = &menu->items[pos];
+ struct menu_item *new_items, *item = &menu->items[pos];
while (pos < menu->nItems)
{
@@ -1336,7 +1381,7 @@ BOOL WINAPI NtUserRemoveMenu( HMENU handle, UINT id, UINT flags )
item++;
pos++;
}
- new_items = realloc( menu->items, menu->nItems * sizeof(MENUITEM) );
+ new_items = realloc( menu->items, menu->nItems * sizeof(*item) );
if (new_items) menu->items = new_items;
}
@@ -1349,7 +1394,7 @@ BOOL WINAPI NtUserRemoveMenu( HMENU handle, UINT id, UINT flags )
*/
BOOL WINAPI NtUserDeleteMenu( HMENU handle, UINT id, UINT flags )
{
- POPUPMENU *menu;
+ struct menu *menu;
UINT pos;
if (!(menu = find_menu_item( handle, id, flags, &pos )))
@@ -1368,7 +1413,7 @@ BOOL WINAPI NtUserDeleteMenu( HMENU handle, UINT id, UINT flags )
*/
BOOL WINAPI NtUserSetMenuContextHelpId( HMENU handle, DWORD id )
{
- POPUPMENU *menu;
+ struct menu *menu;
TRACE( "(%p 0x%08x)\n", handle, id );
@@ -1388,7 +1433,7 @@ static HMENU copy_sys_popup( BOOL mdi )
struct load_sys_menu_params params;
MENUITEMINFOW item_info;
MENUINFO menu_info;
- POPUPMENU *menu;
+ struct menu *menu;
void *ret_ptr;
ULONG ret_len;
HMENU handle;
@@ -1439,7 +1484,7 @@ static HMENU copy_sys_popup( BOOL mdi )
static HMENU get_sys_menu( HWND hwnd, HMENU popup_menu )
{
MENUITEMINFOW info;
- POPUPMENU *menu;
+ struct menu *menu;
HMENU handle;
TRACE("loading system menu, hwnd %p, popup_menu %p\n", hwnd, popup_menu);
@@ -1507,7 +1552,7 @@ static HMENU get_sys_menu( HWND hwnd, HMENU popup_menu )
INT WINAPI NtUserMenuItemFromPoint( HWND hwnd, HMENU handle, int x, int y )
{
POINT pt = { .x = x, .y = y };
- POPUPMENU *menu;
+ struct menu *menu;
UINT pos;
if (!(menu = grab_menu_ptr(handle))) return -1;
@@ -1542,7 +1587,7 @@ HMENU WINAPI NtUserGetSystemMenu( HWND hwnd, BOOL revert )
if (win->hSysMenu)
{
- POPUPMENU *menu;
+ struct menu *menu;
retvalue = get_sub_menu( win->hSysMenu, 0 );
/* Store the dummy sysmenu handle to facilitate the refresh */
@@ -1579,8 +1624,8 @@ BOOL WINAPI NtUserSetSystemMenu( HWND hwnd, HMENU menu )
*/
BOOL WINAPI NtUserSetMenuDefaultItem( HMENU handle, UINT item, UINT bypos )
{
- MENUITEM *menu_item;
- POPUPMENU *menu;
+ struct menu_item *menu_item;
+ struct menu *menu;
unsigned int i;
BOOL ret = FALSE;
@@ -1676,7 +1721,7 @@ found:
{
HMENU menu_handle, submenu, sys_menu;
UINT sys_stat = ~0u, stat = ~0u, pos;
- POPUPMENU *menu;
+ struct menu *menu;
menu_handle = (get_window_long( hwnd, GWL_STYLE ) & WS_CHILD) ? 0 : get_menu(hwnd);
sys_menu = get_win_sys_menu( hwnd );
@@ -1866,7 +1911,7 @@ static HBITMAP get_arrow_bitmap(void)
}
/* Get the size of a bitmap item */
-static void get_bitmap_item_size( MENUITEM *item, SIZE *size, HWND owner )
+static void get_bitmap_item_size( struct menu_item *item, SIZE *size, HWND owner )
{
HBITMAP bmp = item->hbmpItem;
BITMAP bm;
@@ -1922,8 +1967,8 @@ static void get_bitmap_item_size( MENUITEM *item, SIZE *size, HWND owner )
}
/* Calculate the size of the menu item and store it in item->rect */
-static void calc_menu_item_size( HDC hdc, MENUITEM *item, HWND owner, INT org_x, INT org_y,
- BOOL menu_bar, POPUPMENU *menu )
+static void calc_menu_item_size( HDC hdc, struct menu_item *item, HWND owner, INT org_x, INT org_y,
+ BOOL menu_bar, struct menu *menu )
{
UINT check_bitmap_width = get_system_metrics( SM_CXMENUCHECK );
UINT arrow_bitmap_width;
@@ -2070,11 +2115,11 @@ static void calc_menu_item_size( HDC hdc, MENUITEM *item, HWND owner, INT org_x,
}
/* Calculate the size of the menu bar */
-static void calc_menu_bar_size( HDC hdc, RECT *rect, POPUPMENU *menu, HWND owner )
+static void calc_menu_bar_size( HDC hdc, RECT *rect, struct menu *menu, HWND owner )
{
UINT start, i, help_pos;
int org_x, org_y;
- MENUITEM *item;
+ struct menu_item *item;
if (!rect || !menu || !menu->nItems) return;
@@ -2136,7 +2181,7 @@ static void calc_menu_bar_size( HDC hdc, RECT *rect, POPUPMENU *menu, HWND owner
UINT get_menu_bar_height( HWND hwnd, UINT width, INT org_x, INT org_y )
{
- POPUPMENU *menu;
+ struct menu *menu;
RECT rect_bar;
HDC hdc;
@@ -2165,8 +2210,8 @@ static void draw_popup_arrow( HDC hdc, RECT rect, UINT arrow_width, UINT arrow_h
NtGdiDeleteObjectApp( mem_hdc );
}
-static void draw_bitmap_item( HDC hdc, MENUITEM *item, const RECT *rect,
- POPUPMENU *menu, HWND owner, UINT odaction )
+static void draw_bitmap_item( HDC hdc, struct menu_item *item, const RECT *rect,
+ struct menu *menu, HWND owner, UINT odaction )
{
int w = rect->right - rect->left;
int h = rect->bottom - rect->top;
@@ -2300,8 +2345,8 @@ got_bitmap:
}
/* Draw a single menu item */
-static void draw_menu_item( HWND hwnd, POPUPMENU *menu, HWND owner, HDC hdc,
- MENUITEM *item, BOOL menu_bar, UINT odaction )
+static void draw_menu_item( HWND hwnd, struct menu *menu, HWND owner, HDC hdc,
+ struct menu_item *item, BOOL menu_bar, UINT odaction )
{
UINT arrow_width = 0, arrow_height = 0;
HRGN old_clip = NULL, clip;
@@ -2655,7 +2700,7 @@ DWORD WINAPI NtUserDrawMenuBarTemp( HWND hwnd, HDC hdc, RECT *rect, HMENU handle
{
BOOL flat_menu = FALSE;
HFONT prev_font = 0;
- POPUPMENU *menu;
+ struct menu *menu;
UINT i, retvalue;
NtUserSystemParametersInfo( SPI_GETFLATMENU, 0, &flat_menu, 0 );
@@ -2696,7 +2741,7 @@ DWORD WINAPI NtUserDrawMenuBarTemp( HWND hwnd, HDC hdc, RECT *rect, HMENU handle
return retvalue;
}
-static UINT get_scroll_arrow_height( const POPUPMENU *menu )
+static UINT get_scroll_arrow_height( const struct menu *menu )
{
return menucharsize.cy + 4;
}
@@ -2738,7 +2783,7 @@ static void draw_scroll_arrow( HDC hdc, int x, int top, int height, BOOL up, BOO
}
}
-static void draw_scroll_arrows( const POPUPMENU *menu, HDC hdc )
+static void draw_scroll_arrows( const struct menu *menu, HDC hdc )
{
UINT full_height = get_scroll_arrow_height( menu );
UINT arrow_height = full_height / 3;
@@ -2770,7 +2815,7 @@ static int frame_rect( HDC hdc, const RECT *rect, HBRUSH hbrush )
static void draw_popup_menu( HWND hwnd, HDC hdc, HMENU hmenu )
{
HBRUSH prev_hrush, brush = get_sys_color_brush( COLOR_MENU );
- POPUPMENU *menu = unsafe_menu_ptr( hmenu );
+ struct menu *menu = unsafe_menu_ptr( hmenu );
RECT rect;
TRACE( "wnd=%p dc=%p menu=%p\n", hwnd, hdc, hmenu );
@@ -2802,7 +2847,7 @@ static void draw_popup_menu( HWND hwnd, HDC hdc, HMENU hmenu )
/* draw menu items */
if (menu->nItems)
{
- MENUITEM *item;
+ struct menu_item *item;
UINT u;
item = menu->items;
@@ -2887,11 +2932,11 @@ HWND is_menu_active(void)
}
/* Calculate the size of a popup menu */
-static void calc_popup_menu_size( POPUPMENU *menu, UINT max_height )
+static void calc_popup_menu_size( struct menu *menu, UINT max_height )
{
BOOL textandbmp = FALSE, multi_col = FALSE;
int org_x, org_y, max_tab, max_tab_width;
- MENUITEM *item;
+ struct menu_item *item;
UINT start, i;
HDC hdc;
@@ -2983,7 +3028,7 @@ static void calc_popup_menu_size( POPUPMENU *menu, UINT max_height )
static BOOL show_popup( HWND owner, HMENU hmenu, UINT id, UINT flags,
int x, int y, INT xanchor, INT yanchor )
{
- POPUPMENU *menu;
+ struct menu *menu;
HMONITOR monitor;
MONITORINFO info;
UINT max_height;
@@ -3048,11 +3093,11 @@ static BOOL show_popup( HWND owner, HMENU hmenu, UINT id, UINT flags,
return TRUE;
}
-static void ensure_menu_item_visible( POPUPMENU *menu, UINT index, HDC hdc )
+static void ensure_menu_item_visible( struct menu *menu, UINT index, HDC hdc )
{
if (menu->bScrolling)
{
- MENUITEM *item = &menu->items[index];
+ struct menu_item *item = &menu->items[index];
UINT prev_pos = menu->nScrollPos;
const RECT *rc = &menu->items_rect;
UINT scroll_height = rc->bottom - rc->top;
@@ -3093,7 +3138,7 @@ static void ensure_menu_item_visible( POPUPMENU *menu, UINT index, HDC hdc )
static void select_item( HWND owner, HMENU hmenu, UINT index, BOOL send_select, HMENU topmenu )
{
- POPUPMENU *menu;
+ struct menu *menu;
HDC hdc;
TRACE( "owner %p menu %p index 0x%04x select 0x%04x\n", owner, hmenu, index, send_select );
@@ -3133,7 +3178,7 @@ static void select_item( HWND owner, HMENU hmenu, UINT index, BOOL send_select,
}
if (send_select)
{
- MENUITEM *ip = &menu->items[menu->FocusedItem];
+ struct menu_item *ip = &menu->items[menu->FocusedItem];
send_message( owner, WM_MENUSELECT,
MAKEWPARAM( ip->fType & MF_POPUP ? index: ip->wID,
ip->fType | ip->fState | (menu->wFlags & MF_SYSMENU) ),
@@ -3147,8 +3192,8 @@ static void select_item( HWND owner, HMENU hmenu, UINT index, BOOL send_select,
int pos = find_submenu( &topmenu, hmenu );
if (pos != NO_SELECTED_ITEM)
{
- POPUPMENU *ptm = unsafe_menu_ptr( topmenu );
- MENUITEM *ip = &ptm->items[pos];
+ struct menu *ptm = unsafe_menu_ptr( topmenu );
+ struct menu_item *ip = &ptm->items[pos];
send_message( owner, WM_MENUSELECT,
MAKEWPARAM( pos, ip->fType | ip->fState | (ptm->wFlags & MF_SYSMENU) ),
(LPARAM)topmenu );
@@ -3167,7 +3212,7 @@ static void select_item( HWND owner, HMENU hmenu, UINT index, BOOL send_select,
*/
static void move_selection( HWND owner, HMENU hmenu, INT offset )
{
- POPUPMENU *menu;
+ struct menu *menu;
int i;
TRACE( "hwnd %p hmenu %p off 0x%04x\n", owner, hmenu, offset );
@@ -3196,14 +3241,14 @@ static void move_selection( HWND owner, HMENU hmenu, INT offset )
static void hide_sub_popups( HWND owner, HMENU hmenu, BOOL send_select, UINT flags )
{
- POPUPMENU *menu = unsafe_menu_ptr( hmenu );
+ struct menu *menu = unsafe_menu_ptr( hmenu );
TRACE( "owner=%p hmenu=%p 0x%04x\n", owner, hmenu, send_select );
if (menu && top_popup)
{
- POPUPMENU *submenu;
- MENUITEM *item;
+ struct menu *submenu;
+ struct menu_item *item;
HMENU hsubmenu;
if (menu->FocusedItem == NO_SELECTED_ITEM) return;
@@ -3250,7 +3295,7 @@ static BOOL init_popup( HWND owner, HMENU hmenu, UINT flags )
{
UNICODE_STRING class_name = { .Buffer = MAKEINTRESOURCEW( POPUPMENU_CLASS_ATOM ) };
DWORD ex_style = 0;
- POPUPMENU *menu;
+ struct menu *menu;
TRACE( "owner %p hmenu %p\n", owner, hmenu );
@@ -3283,8 +3328,8 @@ static BOOL init_popup( HWND owner, HMENU hmenu, UINT flags )
*/
static HMENU show_sub_popup( HWND owner, HMENU hmenu, BOOL select_first, UINT flags )
{
- POPUPMENU *menu;
- MENUITEM *item;
+ struct menu *menu;
+ struct menu_item *item;
RECT rect;
HDC hdc;
@@ -3385,8 +3430,8 @@ static HMENU show_sub_popup( HWND owner, HMENU hmenu, BOOL select_first, UINT fl
*/
static INT exec_focused_item( MTRACKER *pmt, HMENU handle, UINT flags )
{
- MENUITEM *item;
- POPUPMENU *menu = unsafe_menu_ptr( handle );
+ struct menu_item *item;
+ struct menu *menu = unsafe_menu_ptr( handle );
TRACE( "%p hmenu=%p\n", pmt, handle );
@@ -3414,7 +3459,7 @@ static INT exec_focused_item( MTRACKER *pmt, HMENU handle, UINT flags )
MAKELPARAM( (INT16)pmt->pt.x, (INT16)pmt->pt.y ));
else
{
- POPUPMENU *topmenu = unsafe_menu_ptr( pmt->hTopMenu );
+ struct menu *topmenu = unsafe_menu_ptr( pmt->hTopMenu );
DWORD style = menu->dwStyle | (topmenu ? topmenu->dwStyle : 0);
if (style & MNS_NOTIFYBYPOS)
@@ -3435,8 +3480,8 @@ static INT exec_focused_item( MTRACKER *pmt, HMENU handle, UINT flags )
*/
static void switch_tracking( MTRACKER *pmt, HMENU pt_menu, UINT id, UINT flags )
{
- POPUPMENU *ptmenu = unsafe_menu_ptr( pt_menu );
- POPUPMENU *topmenu = unsafe_menu_ptr( pmt->hTopMenu );
+ struct menu *ptmenu = unsafe_menu_ptr( pt_menu );
+ struct menu *topmenu = unsafe_menu_ptr( pmt->hTopMenu );
TRACE( "%p hmenu=%p 0x%04x\n", pmt, pt_menu, id );
@@ -3462,7 +3507,7 @@ static BOOL menu_button_down( MTRACKER *pmt, UINT message, HMENU pt_menu, UINT f
if (pt_menu)
{
- POPUPMENU *ptmenu = unsafe_menu_ptr( pt_menu );
+ struct menu *ptmenu = unsafe_menu_ptr( pt_menu );
enum hittest ht = ht_item;
UINT pos;
@@ -3505,7 +3550,7 @@ static INT menu_button_up( MTRACKER *pmt, HMENU pt_menu, UINT flags )
if (pt_menu)
{
- POPUPMENU *ptmenu = unsafe_menu_ptr( pt_menu );
+ struct menu *ptmenu = unsafe_menu_ptr( pt_menu );
UINT pos;
if (IS_SYSTEM_MENU( ptmenu ))
@@ -3548,7 +3593,7 @@ static INT menu_button_up( MTRACKER *pmt, HMENU pt_menu, UINT flags )
*/
void end_menu( HWND hwnd )
{
- POPUPMENU *menu;
+ struct menu *menu;
BOOL call_end = FALSE;
if (top_popup_hmenu && (menu = grab_menu_ptr( top_popup_hmenu )))
{
@@ -3566,7 +3611,7 @@ void end_menu( HWND hwnd )
static BOOL menu_mouse_move( MTRACKER* pmt, HMENU pt_menu, UINT flags )
{
UINT id = NO_SELECTED_ITEM;
- POPUPMENU *ptmenu = NULL;
+ struct menu *ptmenu = NULL;
if (pt_menu)
{
@@ -3591,7 +3636,7 @@ static BOOL menu_mouse_move( MTRACKER* pmt, HMENU pt_menu, UINT flags )
static LRESULT do_next_menu( MTRACKER *pmt, UINT vk, UINT flags )
{
- POPUPMENU *menu = unsafe_menu_ptr( pmt->hTopMenu );
+ struct menu *menu = unsafe_menu_ptr( pmt->hTopMenu );
BOOL at_end = FALSE;
if (vk == VK_LEFT && menu->FocusedItem == 0)
@@ -3713,8 +3758,8 @@ static LRESULT do_next_menu( MTRACKER *pmt, UINT vk, UINT flags )
*/
static HMENU get_sub_popup( HMENU hmenu )
{
- POPUPMENU *menu;
- MENUITEM *item;
+ struct menu *menu;
+ struct menu_item *item;
menu = unsafe_menu_ptr( hmenu );
@@ -3737,7 +3782,7 @@ static BOOL menu_key_escape( MTRACKER *pmt, UINT flags )
if (pmt->hCurrentMenu != pmt->hTopMenu)
{
- POPUPMENU *menu = unsafe_menu_ptr( pmt->hCurrentMenu );
+ struct menu *menu = unsafe_menu_ptr( pmt->hCurrentMenu );
if (menu->wFlags & MF_POPUP)
{
@@ -3763,7 +3808,7 @@ static BOOL menu_key_escape( MTRACKER *pmt, UINT flags )
static UINT get_start_of_next_column( HMENU handle )
{
- POPUPMENU *menu = unsafe_menu_ptr( handle );
+ struct menu *menu = unsafe_menu_ptr( handle );
UINT i;
if (!menu) return NO_SELECTED_ITEM;
@@ -3783,7 +3828,7 @@ static UINT get_start_of_next_column( HMENU handle )
static UINT get_start_of_prev_column( HMENU handle )
{
- POPUPMENU *menu = unsafe_menu_ptr( handle );
+ struct menu *menu = unsafe_menu_ptr( handle );
UINT i;
if (!menu) return NO_SELECTED_ITEM;
@@ -3843,7 +3888,7 @@ static BOOL suspend_popup( MTRACKER *pmt, UINT message )
static void menu_key_left( MTRACKER *pmt, UINT flags, UINT msg )
{
- POPUPMENU *menu;
+ struct menu *menu;
HMENU tmp_menu, prev_menu;
UINT prevcol;
@@ -3885,7 +3930,7 @@ static void menu_key_left( MTRACKER *pmt, UINT flags, UINT msg )
static void menu_right_key( MTRACKER *pmt, UINT flags, UINT msg )
{
- POPUPMENU *menu = unsafe_menu_ptr( pmt->hTopMenu );
+ struct menu *menu = unsafe_menu_ptr( pmt->hTopMenu );
HMENU tmp_menu;
UINT nextcol;
@@ -3937,7 +3982,7 @@ static void menu_right_key( MTRACKER *pmt, UINT flags, UINT msg )
*/
static HMENU menu_from_point( HMENU handle, POINT pt )
{
- POPUPMENU *menu = unsafe_menu_ptr( handle );
+ struct menu *menu = unsafe_menu_ptr( handle );
UINT item = menu->FocusedItem;
HMENU ret = 0;
@@ -3975,8 +4020,8 @@ static UINT find_item_by_key( HWND owner, HMENU hmenu, WCHAR key, BOOL force_men
if (hmenu)
{
- POPUPMENU *menu = unsafe_menu_ptr( hmenu );
- MENUITEM *item = menu->items;
+ struct menu *menu = unsafe_menu_ptr( hmenu );
+ struct menu_item *item = menu->items;
LRESULT menuchar;
if (!force_menu_char)
@@ -4020,7 +4065,7 @@ static BOOL track_menu_impl( HMENU hmenu, UINT flags, int x, int y, HWND hwnd, c
BOOL enter_idle_sent = FALSE;
int executed_menu_id = -1;
HWND capture_win;
- POPUPMENU *menu;
+ struct menu *menu;
BOOL remove;
MTRACKER mt;
MSG msg;
@@ -4331,7 +4376,7 @@ static BOOL track_menu( HMENU handle, UINT flags, int x, int y, HWND hwnd, const
static BOOL init_tracking( HWND hwnd, HMENU handle, BOOL is_popup, UINT flags )
{
- POPUPMENU *menu;
+ struct menu *menu;
TRACE( "hwnd=%p hmenu=%p\n", hwnd, handle );
@@ -4461,7 +4506,7 @@ track_menu:
BOOL WINAPI NtUserTrackPopupMenuEx( HMENU handle, UINT flags, INT x, INT y, HWND hwnd,
TPMPARAMS *params )
{
- POPUPMENU *menu;
+ struct menu *menu;
BOOL ret = FALSE;
TRACE( "hmenu %p flags %04x (%d,%d) hwnd %p params %p rect %s\n",
@@ -4519,7 +4564,7 @@ BOOL WINAPI NtUserHiliteMenuItem( HWND hwnd, HMENU handle, UINT item, UINT hilit
{
HMENU handle_menu;
UINT focused_item;
- POPUPMENU *menu;
+ struct menu *menu;
UINT pos;
TRACE( "(%p, %p, %04x, %04x);\n", hwnd, handle, item, hilite );
@@ -4544,7 +4589,7 @@ BOOL WINAPI NtUserHiliteMenuItem( HWND hwnd, HMENU handle, UINT item, UINT hilit
BOOL WINAPI NtUserGetMenuBarInfo( HWND hwnd, LONG id, LONG item, MENUBARINFO *info )
{
HMENU hmenu = NULL;
- POPUPMENU *menu;
+ struct menu *menu;
ATOM class_atom;
TRACE( "(%p,0x%08x,0x%08x,%p)\n", hwnd, id, item, info );
@@ -4613,7 +4658,7 @@ BOOL WINAPI NtUserGetMenuBarInfo( HWND hwnd, LONG id, LONG item, MENUBARINFO *in
info->fFocused = menu->FocusedItem == item - 1;
if (info->fFocused && (menu->items[item - 1].fType & MF_POPUP))
{
- POPUPMENU *hwnd_menu = grab_menu_ptr( menu->items[item - 1].hSubMenu );
+ struct menu *hwnd_menu = grab_menu_ptr( menu->items[item - 1].hSubMenu );
if (hwnd_menu)
{
info->hwndMenu = hwnd_menu->hWnd;
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h
index a5b77a85396..fd70c022c6f 100644
--- a/dlls/win32u/ntuser_private.h
+++ b/dlls/win32u/ntuser_private.h
@@ -205,55 +205,6 @@ enum builtin_winprocs
NB_BUILTIN_AW_WINPROCS = WINPROC_DESKTOP
};
-/* FIXME: make it private to menu.c */
-
-/* Menu item structure */
-typedef struct menu_item
-{
- /* ----------- MENUITEMINFO Stuff ----------- */
- UINT fType; /* Item type. */
- UINT fState; /* Item state. */
- UINT_PTR wID; /* Item id. */
- HMENU hSubMenu; /* Pop-up menu. */
- HBITMAP hCheckBit; /* Bitmap when checked. */
- HBITMAP hUnCheckBit; /* Bitmap when unchecked. */
- LPWSTR text; /* Item text. */
- ULONG_PTR dwItemData; /* Application defined. */
- LPWSTR dwTypeData; /* depends on fMask */
- HBITMAP hbmpItem; /* bitmap */
- /* ----------- Wine stuff ----------- */
- RECT rect; /* Item area (relative to the items_rect),
- * see MENU_AdjustMenuItemRect(). */
- UINT xTab; /* X position of text after Tab */
- SIZE bmpsize; /* size needed for the HBMMENU_CALLBACK bitmap */
-} MENUITEM;
-
-typedef struct
-{
- struct user_object obj;
- WORD wFlags; /* Menu flags (MF_POPUP, MF_SYSMENU) */
- WORD Width; /* Width of the whole menu */
- WORD Height; /* Height of the whole menu */
- UINT nItems; /* Number of items in the menu */
- HWND hWnd; /* Window containing the menu */
- struct menu_item *items; /* Array of menu items */
- UINT FocusedItem; /* Currently focused item */
- HWND hwndOwner; /* window receiving the messages for ownerdraw */
- BOOL bScrolling; /* Scroll arrows are active */
- UINT nScrollPos; /* Current scroll position */
- UINT nTotalHeight; /* Total height of menu items inside menu */
- RECT items_rect; /* Rectangle within which the items lie. Excludes margins and scroll arrows */
- LONG refcount;
- /* ------------ MENUINFO members ------ */
- DWORD dwStyle; /* Extended menu style */
- UINT cyMax; /* max height of the whole menu, 0 is screen height */
- HBRUSH hbrBack; /* brush for menu background */
- DWORD dwContextHelpID;
- ULONG_PTR dwMenuData; /* application defined value */
- HMENU hSysMenuOwner; /* Handle to the dummy sys menu holder */
- WORD textOffset; /* Offset of text when items have both bitmaps and text */
-} POPUPMENU, *LPPOPUPMENU;
-
/* FIXME: make it private to class.c */
typedef struct tagWINDOWPROC
{
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/321
June 27, 2022
[PATCH v2 3/5] win32u: Move NtUserGetSystemMenu implementation from user32.
by Jacek Caban
From: Jacek Caban <jacek(a)codeweavers.com>
---
dlls/user32/controls.h | 6 --
dlls/user32/menu.c | 124 ---------------------------------
dlls/user32/user_main.c | 8 ++-
dlls/win32u/menu.c | 129 ++++++++++++++++++++++++++++++++++-
dlls/win32u/ntuser_private.h | 1 -
include/ntuser.h | 7 ++
6 files changed, 140 insertions(+), 135 deletions(-)
diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h
index 639b9f2214e..48127ca6bb2 100644
--- a/dlls/user32/controls.h
+++ b/dlls/user32/controls.h
@@ -112,12 +112,6 @@ extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ) DECLSPEC_HIDDEN;
/* desktop */
extern BOOL update_wallpaper( const WCHAR *wallpaper, const WCHAR *pattern ) DECLSPEC_HIDDEN;
-/* menu controls */
-extern void MENU_TrackMouseMenuBar( HWND hwnd, INT ht, POINT pt ) DECLSPEC_HIDDEN;
-extern void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar ) DECLSPEC_HIDDEN;
-extern void MENU_EndMenu(HWND) DECLSPEC_HIDDEN;
-extern HMENU MENU_GetSysMenu( HWND hWnd, HMENU hPopupMenu ) DECLSPEC_HIDDEN;
-
/* nonclient area */
extern LRESULT NC_HandleNCMouseMove( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
extern LRESULT NC_HandleNCMouseLeave( HWND hwnd ) DECLSPEC_HIDDEN;
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 52dc6369e3a..07be830eed3 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -42,15 +42,10 @@
#include <stdarg.h>
#include <string.h>
-#define OEMRESOURCE
-
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winnls.h"
-#include "wine/server.h"
-#include "wine/exception.h"
-#include "win.h"
#include "controls.h"
#include "user_private.h"
#include "wine/debug.h"
@@ -58,15 +53,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(menu);
- /* Space between 2 columns */
-#define MENU_COL_SPACE 4
-
- /* Margins for popup menus */
-#define MENU_MARGIN 3
-
- /* (other menu->FocusedItem values give the position of the focused item) */
-#define NO_SELECTED_ITEM 0xffff
-
#define MENU_ITEM_TYPE(flags) \
((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR))
@@ -96,116 +82,6 @@ const struct builtin_class_descr MENU_builtin_class =
};
-/***********************************************************************
- * MENU_GetMenu
- *
- * Validate the given menu handle and returns the menu structure pointer.
- */
-static POPUPMENU *MENU_GetMenu(HMENU hMenu)
-{
- POPUPMENU *menu = get_user_handle_ptr( hMenu, NTUSER_OBJ_MENU );
-
- if (menu == OBJ_OTHER_PROCESS)
- {
- WARN( "other process menu %p?\n", hMenu);
- return NULL;
- }
- if (menu) release_user_handle_ptr( menu ); /* FIXME! */
- else WARN("invalid menu handle=%p\n", hMenu);
- return menu;
-}
-
-/***********************************************************************
- * MENU_CopySysPopup
- *
- * Return the default system menu.
- */
-static HMENU MENU_CopySysPopup(BOOL mdi)
-{
- HMENU hMenu = LoadMenuW(user32_module, mdi ? L"SYSMENUMDI" : L"SYSMENU");
-
- if( hMenu ) {
- MENUINFO minfo;
- MENUITEMINFOW miteminfo;
- POPUPMENU* menu = MENU_GetMenu(hMenu);
- menu->wFlags |= MF_SYSMENU | MF_POPUP;
- /* decorate the menu with bitmaps */
- minfo.cbSize = sizeof( MENUINFO);
- minfo.dwStyle = MNS_CHECKORBMP;
- minfo.fMask = MIM_STYLE;
- SetMenuInfo( hMenu, &minfo);
- miteminfo.cbSize = sizeof( MENUITEMINFOW);
- miteminfo.fMask = MIIM_BITMAP;
- miteminfo.hbmpItem = HBMMENU_POPUP_CLOSE;
- SetMenuItemInfoW( hMenu, SC_CLOSE, FALSE, &miteminfo);
- miteminfo.hbmpItem = HBMMENU_POPUP_RESTORE;
- SetMenuItemInfoW( hMenu, SC_RESTORE, FALSE, &miteminfo);
- miteminfo.hbmpItem = HBMMENU_POPUP_MAXIMIZE;
- SetMenuItemInfoW( hMenu, SC_MAXIMIZE, FALSE, &miteminfo);
- miteminfo.hbmpItem = HBMMENU_POPUP_MINIMIZE;
- SetMenuItemInfoW( hMenu, SC_MINIMIZE, FALSE, &miteminfo);
- NtUserSetMenuDefaultItem( hMenu, SC_CLOSE, FALSE );
- }
- else
- ERR("Unable to load default system menu\n" );
-
- TRACE("returning %p (mdi=%d).\n", hMenu, mdi );
-
- return hMenu;
-}
-
-
-/**********************************************************************
- * MENU_GetSysMenu
- *
- * Create a copy of the system menu. System menu in Windows is
- * a special menu bar with the single entry - system menu popup.
- * This popup is presented to the outside world as a "system menu".
- * However, the real system menu handle is sometimes seen in the
- * WM_MENUSELECT parameters (and Word 6 likes it this way).
- */
-HMENU MENU_GetSysMenu( HWND hWnd, HMENU hPopupMenu )
-{
- HMENU hMenu;
-
- TRACE("loading system menu, hWnd %p, hPopupMenu %p\n", hWnd, hPopupMenu);
- if ((hMenu = CreateMenu()))
- {
- POPUPMENU *menu = MENU_GetMenu(hMenu);
- menu->wFlags = MF_SYSMENU;
- menu->hWnd = WIN_GetFullHandle( hWnd );
- TRACE("hWnd %p (hMenu %p)\n", menu->hWnd, hMenu);
-
- if (!hPopupMenu)
- {
- if (GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_MDICHILD)
- hPopupMenu = MENU_CopySysPopup(TRUE);
- else
- hPopupMenu = MENU_CopySysPopup(FALSE);
- }
-
- if (hPopupMenu)
- {
- if (GetClassLongW(hWnd, GCL_STYLE) & CS_NOCLOSE)
- NtUserDeleteMenu( hPopupMenu, SC_CLOSE, MF_BYCOMMAND );
-
- InsertMenuW( hMenu, -1, MF_SYSMENU | MF_POPUP | MF_BYPOSITION,
- (UINT_PTR)hPopupMenu, NULL );
-
- menu->items[0].fType = MF_SYSMENU | MF_POPUP;
- menu->items[0].fState = 0;
- if ((menu = MENU_GetMenu(hPopupMenu))) menu->wFlags |= MF_SYSMENU;
-
- TRACE("hMenu=%p (hPopup %p)\n", hMenu, hPopupMenu );
- return hMenu;
- }
- NtUserDestroyMenu( hMenu );
- }
- ERR("failed to load system menu!\n");
- return 0;
-}
-
-
/**********************************************************************
* MENU_ParseResource
*
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index 55e72dcf203..038f1f0796f 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -159,7 +159,6 @@ static const struct user_callbacks user_funcs =
NtWaitForMultipleObjects,
SCROLL_DrawNCScrollBar,
free_win_ptr,
- MENU_GetSysMenu,
notify_ime,
post_dde_message,
rawinput_update_device_list,
@@ -190,6 +189,12 @@ static NTSTATUS WINAPI User32LoadImage( const struct load_image_params *params,
return HandleToUlong( ret );
}
+static NTSTATUS WINAPI User32LoadSysMenu( const struct load_sys_menu_params *params, ULONG size )
+{
+ HMENU ret = LoadMenuW( user32_module, params->mdi ? L"SYSMENUMDI" : L"SYSMENU" );
+ return HandleToUlong( ret );
+}
+
static NTSTATUS WINAPI User32FreeCachedClipboardData( const struct free_cached_data_params *params,
ULONG size )
{
@@ -221,6 +226,7 @@ static const void *kernel_callback_table[NtUserCallCount] =
User32FreeCachedClipboardData,
User32LoadDriver,
User32LoadImage,
+ User32LoadSysMenu,
User32RegisterBuiltinClasses,
User32RenderSsynthesizedFormat,
};
diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c
index cf755c57a15..64c832c58a9 100644
--- a/dlls/win32u/menu.c
+++ b/dlls/win32u/menu.c
@@ -1378,6 +1378,129 @@ BOOL WINAPI NtUserSetMenuContextHelpId( HMENU handle, DWORD id )
return TRUE;
}
+/***********************************************************************
+ * copy_sys_popup
+ *
+ * Return the default system menu.
+ */
+static HMENU copy_sys_popup( BOOL mdi )
+{
+ struct load_sys_menu_params params;
+ MENUITEMINFOW item_info;
+ MENUINFO menu_info;
+ POPUPMENU *menu;
+ void *ret_ptr;
+ ULONG ret_len;
+ HMENU handle;
+
+ params.mdi = mdi;
+ handle = UlongToHandle( KeUserModeCallback( NtUserLoadSysMenu, ¶ms, sizeof(params),
+ &ret_ptr, &ret_len ));
+
+ if (!handle || !(menu = grab_menu_ptr( handle )))
+ {
+ ERR("Unable to load default system menu\n" );
+ return 0;
+ }
+
+ menu->wFlags |= MF_SYSMENU | MF_POPUP;
+ release_menu_ptr( menu );
+
+ /* decorate the menu with bitmaps */
+ menu_info.cbSize = sizeof(MENUINFO);
+ menu_info.dwStyle = MNS_CHECKORBMP;
+ menu_info.fMask = MIM_STYLE;
+ NtUserThunkedMenuInfo( handle, &menu_info );
+ item_info.cbSize = sizeof(MENUITEMINFOW);
+ item_info.fMask = MIIM_BITMAP;
+ item_info.hbmpItem = HBMMENU_POPUP_CLOSE;
+ NtUserThunkedMenuItemInfo( handle, SC_CLOSE, 0, NtUserSetMenuItemInfo, &item_info, NULL );
+ item_info.hbmpItem = HBMMENU_POPUP_RESTORE;
+ NtUserThunkedMenuItemInfo( handle, SC_RESTORE, 0, NtUserSetMenuItemInfo, &item_info, NULL );
+ item_info.hbmpItem = HBMMENU_POPUP_MAXIMIZE;
+ NtUserThunkedMenuItemInfo( handle, SC_MAXIMIZE, 0, NtUserSetMenuItemInfo, &item_info, NULL );
+ item_info.hbmpItem = HBMMENU_POPUP_MINIMIZE;
+ NtUserThunkedMenuItemInfo( handle, SC_MINIMIZE, 0, NtUserSetMenuItemInfo, &item_info, NULL );
+ NtUserSetMenuDefaultItem( handle, SC_CLOSE, FALSE );
+
+ TRACE( "returning %p (mdi=%d).\n", handle, mdi );
+ return handle;
+}
+
+/**********************************************************************
+ * get_sys_menu
+ *
+ * Create a copy of the system menu. System menu in Windows is
+ * a special menu bar with the single entry - system menu popup.
+ * This popup is presented to the outside world as a "system menu".
+ * However, the real system menu handle is sometimes seen in the
+ * WM_MENUSELECT parameters (and Word 6 likes it this way).
+ */
+static HMENU get_sys_menu( HWND hwnd, HMENU popup_menu )
+{
+ MENUITEMINFOW info;
+ POPUPMENU *menu;
+ HMENU handle;
+
+ TRACE("loading system menu, hwnd %p, popup_menu %p\n", hwnd, popup_menu);
+ if (!(handle = create_menu( FALSE )))
+ {
+ ERR("failed to load system menu!\n");
+ return 0;
+ }
+
+ if (!(menu = grab_menu_ptr( handle )))
+ {
+ NtUserDestroyMenu( handle );
+ return 0;
+ }
+ menu->wFlags = MF_SYSMENU;
+ menu->hWnd = get_full_window_handle( hwnd );
+ release_menu_ptr( menu );
+ TRACE("hwnd %p (handle %p)\n", menu->hWnd, handle);
+
+ if (!popup_menu)
+ {
+ if (get_window_long(hwnd, GWL_EXSTYLE) & WS_EX_MDICHILD)
+ popup_menu = copy_sys_popup(TRUE);
+ else
+ popup_menu = copy_sys_popup(FALSE);
+ }
+ if (!popup_menu)
+ {
+ NtUserDestroyMenu( handle );
+ return 0;
+ }
+
+ if (get_class_long( hwnd, GCL_STYLE, FALSE ) & CS_NOCLOSE)
+ NtUserDeleteMenu(popup_menu, SC_CLOSE, MF_BYCOMMAND);
+
+ info.cbSize = sizeof(info);
+ info.fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE | MIIM_SUBMENU;
+ info.fState = 0;
+ info.fType = MF_SYSMENU | MF_POPUP;
+ info.wID = (UINT_PTR)popup_menu;
+ info.hSubMenu = popup_menu;
+
+ NtUserThunkedMenuItemInfo( handle, -1, MF_SYSMENU | MF_POPUP | MF_BYPOSITION,
+ NtUserInsertMenuItem, &info, NULL );
+
+ if ((menu = grab_menu_ptr( handle )))
+ {
+ menu->items[0].fType = MF_SYSMENU | MF_POPUP;
+ menu->items[0].fState = 0;
+ release_menu_ptr( menu );
+ }
+ if ((menu = grab_menu_ptr(popup_menu)))
+ {
+ menu->wFlags |= MF_SYSMENU;
+ release_menu_ptr( menu );
+ }
+
+ TRACE("handle=%p (hPopup %p)\n", handle, popup_menu );
+ return handle;
+}
+
/**********************************************************************
* NtUserMenuItemFromPoint (win32u.@)
*/
@@ -1414,8 +1537,8 @@ HMENU WINAPI NtUserGetSystemMenu( HWND hwnd, BOOL revert )
win->hSysMenu = 0;
}
- if (!win->hSysMenu && (win->dwStyle & WS_SYSMENU) && user_callbacks)
- win->hSysMenu = user_callbacks->get_sys_menu( hwnd, 0 );
+ if (!win->hSysMenu && (win->dwStyle & WS_SYSMENU))
+ win->hSysMenu = get_sys_menu( hwnd, 0 );
if (win->hSysMenu)
{
@@ -1446,7 +1569,7 @@ BOOL WINAPI NtUserSetSystemMenu( HWND hwnd, HMENU menu )
if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE;
if (win->hSysMenu) NtUserDestroyMenu( win->hSysMenu );
- win->hSysMenu = user_callbacks ? user_callbacks->get_sys_menu( hwnd, menu ) : NULL;
+ win->hSysMenu = get_sys_menu( hwnd, menu );
release_win_ptr( win );
return TRUE;
}
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h
index eb851f57cdb..a5b77a85396 100644
--- a/dlls/win32u/ntuser_private.h
+++ b/dlls/win32u/ntuser_private.h
@@ -37,7 +37,6 @@ struct user_callbacks
NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*);
void (CDECL *draw_nc_scrollbar)( HWND hwnd, HDC hdc, BOOL draw_horizontal, BOOL draw_vertical );
void (CDECL *free_win_ptr)( struct tagWND *win );
- HMENU (CDECL *get_sys_menu)( HWND hwnd, HMENU popup );
void (CDECL *notify_ime)( HWND hwnd, UINT param );
BOOL (CDECL *post_dde_message)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid,
DWORD type );
diff --git a/include/ntuser.h b/include/ntuser.h
index e1435bc2626..18ddbcaa4a4 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -37,6 +37,7 @@ enum
NtUserFreeCachedClipboardData,
NtUserLoadDriver,
NtUserLoadImage,
+ NtUserLoadSysMenu,
NtUserRegisterBuiltinClasses,
NtUserRenderSynthesizedFormat,
/* win16 hooks */
@@ -187,6 +188,12 @@ struct load_image_params
UINT flags;
};
+/* NtUserLoadSysMenu params */
+struct load_sys_menu_params
+{
+ BOOL mdi;
+};
+
/* NtUserRenderSynthesizedFormat params */
struct render_synthesized_format_params
{
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/321
June 27, 2022
[PATCH v2 2/5] user32: Use IsMenu in MENU_mnu2mnuii.
by Jacek Caban
From: Jacek Caban <jacek(a)codeweavers.com>
---
dlls/user32/menu.c | 3 ++-
dlls/user32/tests/menu.c | 11 +++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index afbf4d2fcea..52dc6369e3a 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -489,7 +489,8 @@ static void MENU_mnu2mnuii( UINT flags, UINT_PTR id, LPCWSTR str,
pmii->fMask |= MIIM_DATA;
pmii->dwItemData = (ULONG_PTR) str;
}
- if( flags & MF_POPUP && MENU_GetMenu((HMENU)id)) {
+ if ((flags & MF_POPUP) && IsMenu( UlongToHandle( id )))
+ {
pmii->fMask |= MIIM_SUBMENU;
pmii->hSubMenu = (HMENU)id;
}
diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c
index c7a20e1b8e9..6862f13c6b1 100644
--- a/dlls/user32/tests/menu.c
+++ b/dlls/user32/tests/menu.c
@@ -3013,6 +3013,7 @@ static void test_InsertMenu(void)
{ MF_HELP, 1, MAKEINTRESOURCEA(1) }
};
HMENU hmenu;
+ BOOL ret;
#define create_menu(a) create_menu_from_data((a), ARRAY_SIZE(a))
#define create_menuitem(a) create_menuitem_from_data((a), ARRAY_SIZE(a))
@@ -3054,6 +3055,16 @@ static void test_InsertMenu(void)
#undef create_menu
#undef create_menuitem
#undef compare_menu
+
+ hmenu = CreateMenu();
+
+ SetLastError(0xdeadbeef);
+ ret = InsertMenuW(hmenu, -1, MF_BYPOSITION | MF_POPUP, 0xdeadbeef, L"test");
+ ok(ret && GetLastError() == ERROR_INVALID_MENU_HANDLE,
+ "InsertMenuW returned %x %lu\n", ret, GetLastError());
+ ok(GetMenuItemCount(hmenu) == 1, "GetMenuItemCount() = %d\n", GetMenuItemCount(hmenu));
+
+ DestroyMenu(hmenu);
}
static void test_menu_getmenuinfo(void)
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/321
June 27, 2022
[PATCH v2 1/5] win32u: Move GetMenuDefaultItem implementation from user32.
by Jacek Caban
From: Jacek Caban <jacek(a)codeweavers.com>
---
dlls/user32/menu.c | 37 ++-----------------------------------
dlls/win32u/menu.c | 42 ++++++++++++++++++++++++++++++++++++++++++
include/ntuser.h | 1 +
3 files changed, 45 insertions(+), 35 deletions(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 6fb381ea617..afbf4d2fcea 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -911,42 +911,9 @@ BOOL WINAPI SetMenuItemInfoW(HMENU hmenu, UINT item, BOOL bypos,
/**********************************************************************
* GetMenuDefaultItem (USER32.@)
*/
-UINT WINAPI GetMenuDefaultItem(HMENU hmenu, UINT bypos, UINT flags)
+UINT WINAPI GetMenuDefaultItem( HMENU menu, UINT bypos, UINT flags )
{
- POPUPMENU *menu;
- MENUITEM * item;
- UINT i = 0;
-
- TRACE("(%p,%d,%d)\n", hmenu, bypos, flags);
-
- if (!(menu = MENU_GetMenu(hmenu))) return -1;
-
- /* find default item */
- item = menu->items;
-
- /* empty menu */
- if (! item) return -1;
-
- while ( !( item->fState & MFS_DEFAULT ) )
- {
- i++; item++;
- if (i >= menu->nItems ) return -1;
- }
-
- /* default: don't return disabled items */
- if ( (!(GMDI_USEDISABLED & flags)) && (item->fState & MFS_DISABLED )) return -1;
-
- /* search rekursiv when needed */
- if ( (item->fType & MF_POPUP) && (flags & GMDI_GOINTOPOPUPS) )
- {
- UINT ret;
- ret = GetMenuDefaultItem( item->hSubMenu, bypos, flags );
- if ( -1 != ret ) return ret;
-
- /* when item not found in submenu, return the popup item */
- }
- return ( bypos ) ? i : item->wID;
-
+ return NtUserThunkedMenuItemInfo( menu, bypos, flags, NtUserGetMenuDefaultItem, NULL, NULL );
}
diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c
index 598576437c6..cf755c57a15 100644
--- a/dlls/win32u/menu.c
+++ b/dlls/win32u/menu.c
@@ -1170,6 +1170,45 @@ static HMENU get_sub_menu( HMENU handle, INT pos )
return submenu;
}
+/* see GetMenuDefaultItem */
+static UINT get_menu_default_item( HMENU handle, UINT bypos, UINT flags )
+{
+ MENUITEM *item = NULL;
+ POPUPMENU *menu;
+ UINT i;
+
+ TRACE( "(%p,%d,%d)\n", handle, bypos, flags );
+
+ if (!(menu = grab_menu_ptr( handle ))) return -1;
+
+ for (i = 0; i < menu->nItems; i++)
+ {
+ if (!(menu->items[i].fState & MFS_DEFAULT)) continue;
+ item = &menu->items[i];
+ break;
+ }
+
+ /* default: don't return disabled items */
+ if (item && (!(GMDI_USEDISABLED & flags)) && (item->fState & MFS_DISABLED)) item = NULL;
+
+ /* search submenu when needed */
+ if (item && (item->fType & MF_POPUP) && (flags & GMDI_GOINTOPOPUPS))
+ {
+ UINT ret = get_menu_default_item( item->hSubMenu, bypos, flags );
+ if (ret != -1)
+ {
+ release_menu_ptr( menu );
+ return ret;
+ }
+ /* when item not found in submenu, return the popup item */
+ }
+
+ if (!item) i = -1;
+ else if (!bypos) i = item->wID;
+ release_menu_ptr( menu );
+ return i;
+}
+
/**********************************************************************
* NtUserThunkedMenuItemInfo (win32u.@)
*/
@@ -1185,6 +1224,9 @@ UINT WINAPI NtUserThunkedMenuItemInfo( HMENU handle, UINT pos, UINT flags, UINT
case NtUserCheckMenuRadioItem:
return check_menu_radio_item( handle, pos, info->cch, info->fMask, flags );
+ case NtUserGetMenuDefaultItem:
+ return get_menu_default_item( handle, pos, flags );
+
case NtUserGetMenuItemID:
if (!(menu = find_menu_item( handle, pos, flags, &i ))) return -1;
ret = menu->items[i].fType & MF_POPUP ? -1 : menu->items[i].wID;
diff --git a/include/ntuser.h b/include/ntuser.h
index bf4e9f4b13a..e1435bc2626 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -225,6 +225,7 @@ enum
NtUserInsertMenuItem,
/* Wine extensions */
NtUserCheckMenuRadioItem,
+ NtUserGetMenuDefaultItem,
NtUserGetMenuItemID,
NtUserGetMenuItemInfoA,
NtUserGetMenuItemInfoW,
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/321
June 27, 2022
[PATCH v2 0/5] MR321: win32u: menu conversion
by Jacek Caban (@jacek)
--
v2: user32: Remove no longer needed helpers.
win32u: Move menu object declarations to menu.c.
https://gitlab.winehq.org/wine/wine/-/merge_requests/321
June 27, 2022