[PATCH 5/5] quartzdrv: Implement MsgWaitForMultipleObjectsEx and
initial Carbon event handling.
Pierre d'Herbemont
pdherbemont at free.fr
Wed Oct 25 08:39:51 CDT 2006
---
dlls/winequartz.drv/Makefile.in | 4 +
dlls/winequartz.drv/event.c | 94
+++++++++++++++++++++++++++++
dlls/winequartz.drv/quartzdrv.h | 7 ++
dlls/winequartz.drv/quartzdrv_carbon.c | 101
+++++++++++++++++++++++++++++++
dlls/winequartz.drv/quartzdrv_main.c | 13 ++++
dlls/winequartz.drv/winequartz.drv.spec | 3 +
6 files changed, 220 insertions(+), 2 deletions(-)
-------------- next part --------------
diff --git a/dlls/winequartz.drv/Makefile.in b/dlls/winequartz.drv/Makefile.in
index 809bf0a..cb826cd 100644
--- a/dlls/winequartz.drv/Makefile.in
+++ b/dlls/winequartz.drv/Makefile.in
@@ -5,9 +5,11 @@ VPATH = @srcdir@
MODULE = winequartz.drv
IMPORTS = user32 gdi32 advapi32 kernel32 ntdll
EXTRAINCL =
-EXTRALIBS =
+EXTRALIBS = -framework Carbon
C_SRCS = \
+ event.c \
+ quartzdrv_carbon.c \
quartzdrv_main.c
@MAKE_DLL_RULES@
diff --git a/dlls/winequartz.drv/event.c b/dlls/winequartz.drv/event.c
new file mode 100644
index 0000000..b6a8499
--- /dev/null
+++ b/dlls/winequartz.drv/event.c
@@ -0,0 +1,94 @@
+/*
+ * Quartz (Mac OS X) event driver
+ *
+ * Copyright 1993 Alexandre Julliard
+ * 1999 Noel Borthwick
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COM_NO_WINDOWS_H
+#include "config.h"
+
+#include <assert.h>
+#include <stdarg.h>
+#include <string.h>
+
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "shlobj.h" /* DROPFILES */
+
+#include "win.h"
+#include "winreg.h"
+#include "quartzdrv.h"
+#include "shellapi.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(event);
+
+/***********************************************************************
+ * MsgWaitForMultipleObjectsEx (QDRV.@)
+ */
+DWORD QDRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
+ DWORD timeout, DWORD mask, DWORD flags )
+{
+ DWORD ret;
+ struct quartzdrv_thread_data *data = quartzdrv_thread_data();
+
+ if (!data || data->process_event_count)
+ {
+ if (!count && !timeout) return WAIT_TIMEOUT;
+ return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
+ timeout, flags & MWMO_ALERTABLE );
+ }
+
+ data->process_event_count++;
+ if (QDRV_CarbonGetEvent()) ret = count;
+ else if (count || timeout)
+ {
+ DWORD remaining_timeout = timeout;
+ DWORD acceptable_timeout;
+
+ /* We can't remain too long without a carbon call,
+ or the application seems to hang for the user */
+ do {
+ if(remaining_timeout > 50 || remaining_timeout == INFINITE)
+ acceptable_timeout = 50;
+ else
+ acceptable_timeout = remaining_timeout;
+
+ ret = WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
+ acceptable_timeout, flags & MWMO_ALERTABLE );
+
+ if (ret == count)
+ QDRV_CarbonGetEvent();
+ else {
+ ret = WAIT_TIMEOUT;
+ break;
+ }
+ if(remaining_timeout != INFINITE)
+ remaining_timeout -= acceptable_timeout;
+ } while(remaining_timeout>0 || remaining_timeout == INFINITE);
+
+ }
+ else ret = WAIT_TIMEOUT;
+
+ data->process_event_count--;
+ return ret;
+}
\ No newline at end of file
diff --git a/dlls/winequartz.drv/quartzdrv.h b/dlls/winequartz.drv/quartzdrv.h
index 4f97bb1..8730733 100644
--- a/dlls/winequartz.drv/quartzdrv.h
+++ b/dlls/winequartz.drv/quartzdrv.h
@@ -45,4 +45,11 @@ inline static struct quartzdrv_thread_da
return data;
}
+/* ---------------------------------------------------------------------
+ quartzdrv_carbon.c
+*/
+extern int QDRV_CarbonGetEvent(void);
+extern void QDRV_CarbonInitialize(void);
+extern void QDRV_CarbonFinalize(void);
+
#endif /* __WINE_QUARTZDRV_H */
diff --git a/dlls/winequartz.drv/quartzdrv_carbon.c b/dlls/winequartz.drv/quartzdrv_carbon.c
new file mode 100644
index 0000000..2899b9c
--- /dev/null
+++ b/dlls/winequartz.drv/quartzdrv_carbon.c
@@ -0,0 +1,101 @@
+/*
+ * QUARTZDRV Carbon bridge code
+ *
+ * Copyright 2006 Emmanuel Maillard
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <Carbon/Carbon.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+/***********************************************************************
+ * QDRV_ProcessMouseEvent
+ * (returns 1 if an event was received, else 0)
+ */
+static int QDRV_ProcessMouseEvent(EventRef event, UInt32 kind)
+{
+ Point point;
+ WindowRef window;
+ WindowPartCode partCode;
+
+ GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL,
+ sizeof(Point), NULL, &point);
+
+ partCode = MacFindWindow(point, &window);
+
+ switch (kind)
+ {
+ case kEventMouseDown:
+ if (partCode == inMenuBar)
+ MenuSelect(point);
+ break;
+ case kEventMouseUp:
+ return 0;
+ case kEventMouseMoved:
+ return 0;
+ }
+
+ return 1;
+}
+
+/***********************************************************************
+ * QDRV_CarbonGetEvent
+ * (returns 1 if an event was received, else 0)
+ */
+int QDRV_CarbonGetEvent(void)
+{
+ EventRef event;
+ if (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &event) == noErr) {
+ UInt32 eventClass = GetEventClass(event);
+ UInt32 eventKind = GetEventKind(event);
+ switch (eventClass)
+ {
+ case kEventClassMouse:
+ if (!QDRV_ProcessMouseEvent(event, eventKind))
+ SendEventToEventTarget(event, GetEventDispatcherTarget());
+ break;
+ case kEventClassAppleEvent:
+ case kEventClassApplication:
+ default:
+ SendEventToEventTarget(event, GetEventDispatcherTarget());
+ break;
+ }
+ ReleaseEvent(event);
+ return 1;
+ }
+ return 0;
+}
+
+/***********************************************************************
+ * QDRV_Initialize
+ */
+void QDRV_CarbonInitialize(void)
+{
+ ProcessSerialNumber psn;
+
+ GetProcessForPID(getpid(), &psn);
+ TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+ SetFrontProcess(&psn);
+}
+
+/***********************************************************************
+ * QDRV_Finalize
+ */
+void QDRV_CarbonFinalize(void)
+{
+
+}
\ No newline at end of file
diff --git a/dlls/winequartz.drv/quartzdrv_main.c b/dlls/winequartz.drv/quartzdrv_main.c
index c8b9442..e65f9d2 100644
--- a/dlls/winequartz.drv/quartzdrv_main.c
+++ b/dlls/winequartz.drv/quartzdrv_main.c
@@ -34,6 +34,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartzdrv);
DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
+/**********************************************************************
+* CreateWindow (QDRV.@)
+*
+* Fake CreateWindow to let us work and test MsgWaitForMultipleObjectsEx.
+*/
+BOOL QDRV_CreateWindow( HWND hwnd, int *cs, BOOL unicode )
+{
+ FIXME("stub\n");
+ return 1;
+}
+
/***********************************************************************
* QDRV thread initialisation routine
*/
@@ -60,6 +71,7 @@ struct quartzdrv_thread_data *quartzdrv_
static BOOL process_attach(void)
{
TRACE("\n");
+ QDRV_CarbonInitialize();
return TRUE;
}
@@ -79,6 +91,7 @@ static void thread_detach(void)
static void process_detach(void)
{
TRACE("\n");
+ QDRV_CarbonFinalize();
}
/***********************************************************************
diff --git a/dlls/winequartz.drv/winequartz.drv.spec b/dlls/winequartz.drv/winequartz.drv.spec
index d98d860..b28ab80 100644
--- a/dlls/winequartz.drv/winequartz.drv.spec
+++ b/dlls/winequartz.drv/winequartz.drv.spec
@@ -1 +1,2 @@
-# Nothing Yet
+@ cdecl CreateWindow(long ptr long) QDRV_CreateWindow
+@ cdecl MsgWaitForMultipleObjectsEx(long ptr long long long) QDRV_MsgWaitForMultipleObjectsEx
\ No newline at end of file
More information about the wine-patches
mailing list