[PATCH 3/7] ninput: Implement CreateInteractionContext().

Józef Kucia jkucia at codeweavers.com
Thu Jun 21 09:19:42 CDT 2018


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---

For bug 44720

---
 configure                     |  1 +
 configure.ac                  |  1 +
 dlls/ninput/Makefile.in       |  1 +
 dlls/ninput/main.c            | 53 ++++++++++++++++++++++++++++++++++++++++---
 dlls/ninput/ninput.spec       |  4 ++--
 dlls/ninput/tests/Makefile.in |  4 ++++
 dlls/ninput/tests/ninput.c    | 41 +++++++++++++++++++++++++++++++++
 7 files changed, 100 insertions(+), 5 deletions(-)
 create mode 100644 dlls/ninput/tests/Makefile.in
 create mode 100644 dlls/ninput/tests/ninput.c

diff --git a/configure b/configure
index bcb660d56982..26aa115002d9 100755
--- a/configure
+++ b/configure
@@ -19023,6 +19023,7 @@ wine_fn_config_makefile dlls/netprofm enable_netprofm
 wine_fn_config_makefile dlls/netprofm/tests enable_tests
 wine_fn_config_makefile dlls/newdev enable_newdev
 wine_fn_config_makefile dlls/ninput enable_ninput
+wine_fn_config_makefile dlls/ninput/tests enable_tests
 wine_fn_config_makefile dlls/normaliz enable_normaliz
 wine_fn_config_makefile dlls/npmshtml enable_npmshtml
 wine_fn_config_makefile dlls/npptools enable_npptools
diff --git a/configure.ac b/configure.ac
index 469fa8d72977..0f7e130c322e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3522,6 +3522,7 @@ WINE_CONFIG_MAKEFILE(dlls/netprofm)
 WINE_CONFIG_MAKEFILE(dlls/netprofm/tests)
 WINE_CONFIG_MAKEFILE(dlls/newdev)
 WINE_CONFIG_MAKEFILE(dlls/ninput)
+WINE_CONFIG_MAKEFILE(dlls/ninput/tests)
 WINE_CONFIG_MAKEFILE(dlls/normaliz)
 WINE_CONFIG_MAKEFILE(dlls/npmshtml)
 WINE_CONFIG_MAKEFILE(dlls/npptools)
diff --git a/dlls/ninput/Makefile.in b/dlls/ninput/Makefile.in
index 3d3cc7fe85e8..8f1039b73c86 100644
--- a/dlls/ninput/Makefile.in
+++ b/dlls/ninput/Makefile.in
@@ -1,4 +1,5 @@
 MODULE    = ninput.dll
+IMPORTLIB = ninput
 
 C_SRCS = \
 	main.c
diff --git a/dlls/ninput/main.c b/dlls/ninput/main.c
index 0f23128cfe4d..1aa3c4652b6e 100644
--- a/dlls/ninput/main.c
+++ b/dlls/ninput/main.c
@@ -22,19 +22,66 @@
 #include "windef.h"
 #include "winbase.h"
 #include "wine/debug.h"
+#include "wine/heap.h"
+
+#include "interactioncontext.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ninput);
 
-BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID lpv)
+struct interaction_context
+{
+    BOOL filter_pointers;
+};
+
+static struct interaction_context *context_from_handle(HINTERACTIONCONTEXT handle)
+{
+    return (struct interaction_context *)handle;
+}
+
+HRESULT WINAPI CreateInteractionContext(HINTERACTIONCONTEXT *handle)
+{
+    struct interaction_context *context;
+
+    TRACE("handle %p.\n", handle);
+
+    if (!handle)
+        return E_POINTER;
+
+    if (!(context = heap_alloc(sizeof(*context))))
+        return E_OUTOFMEMORY;
+
+    context->filter_pointers = TRUE;
+
+    TRACE("Created context %p.\n", context);
+
+    *handle = (HINTERACTIONCONTEXT)context;
+
+    return S_OK;
+}
+
+HRESULT WINAPI DestroyInteractionContext(HINTERACTIONCONTEXT handle)
+{
+    struct interaction_context *context = context_from_handle(handle);
+
+    TRACE("context %p.\n", context);
+
+    if (!context)
+        return E_HANDLE;
+
+    heap_free(context);
+    return S_OK;
+}
+
+BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
 {
-    TRACE("(%p, %d, %p)\n", hInstDLL, reason, lpv);
+    TRACE("(%p, %d, %p)\n", inst, reason, reserved);
 
     switch (reason)
     {
     case DLL_WINE_PREATTACH:
         return FALSE;    /* prefer native version */
     case DLL_PROCESS_ATTACH:
-        DisableThreadLibraryCalls(hInstDLL);
+        DisableThreadLibraryCalls(inst);
         break;
     }
     return TRUE;
diff --git a/dlls/ninput/ninput.spec b/dlls/ninput/ninput.spec
index 372beb20eb15..0717cb1c2f47 100644
--- a/dlls/ninput/ninput.spec
+++ b/dlls/ninput/ninput.spec
@@ -1,8 +1,8 @@
 @ stub DefaultInputHandler
 @ stub AddPointerInteractionContext
 @ stub BufferPointerPacketsInteractionContext
-@ stub CreateInteractionContext
-@ stub DestroyInteractionContext
+@ stdcall CreateInteractionContext(ptr)
+@ stdcall DestroyInteractionContext(ptr)
 @ stub GetCrossSlideParameterInteractionContext
 @ stub GetInertiaParameterInteractionContext
 @ stub GetInteractionConfigurationInteractionContext
diff --git a/dlls/ninput/tests/Makefile.in b/dlls/ninput/tests/Makefile.in
new file mode 100644
index 000000000000..9c0b44fa17dc
--- /dev/null
+++ b/dlls/ninput/tests/Makefile.in
@@ -0,0 +1,4 @@
+TESTDLL = ninput.dll
+IMPORTS = ninput
+
+C_SRCS = ninput.c
diff --git a/dlls/ninput/tests/ninput.c b/dlls/ninput/tests/ninput.c
new file mode 100644
index 000000000000..d894ab8a847a
--- /dev/null
+++ b/dlls/ninput/tests/ninput.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2018 Józef Kucia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "interactioncontext.h"
+#include "wine/test.h"
+
+static void test_context(void)
+{
+    HINTERACTIONCONTEXT context;
+    HRESULT hr;
+
+    hr = CreateInteractionContext(&context);
+    ok(hr == S_OK, "Failed to create context, hr %#x.\n", hr);
+    hr = DestroyInteractionContext(context);
+    ok(hr == S_OK, "Failed to destroy context, hr %#x.\n", hr);
+
+    hr = CreateInteractionContext(NULL);
+    ok(hr == E_POINTER, "Got hr %#x.\n", hr);
+    hr = DestroyInteractionContext(NULL);
+    ok(hr == E_HANDLE, "Got hr %#x.\n", hr);
+}
+
+START_TEST(ninput)
+{
+    test_context();
+}
-- 
2.16.4




More information about the wine-devel mailing list