winequartz.drv: Second glance at Window support.

Pierre d'Herbemont pdherbemont at free.fr
Mon Nov 13 13:32:11 CST 2006


Hi,

Here is an other attempt at Window support. This time I tried to show 
how Window could be represented using Carbon Structures.

A Win32 Window is representated with the quartzdrv_win_data structure.
It is associated to the hwnd using the SetPropA/GetPropA Win32 function.
The Window is linked to an HIView (quartzdrv_win_data.carbon_view), 
which can be the main view of a Carbon Window if the Win32 Window is at 
the Desktop level, and then quartzdrv_win_data.carbon_window points to 
the Carbon Window.

I have also implemented an Event Loop that is detached from the current 
thread. Thus we don't need to poll for events. Only left is the 
dispatchement. I am not sure how it should be done: For instance mouses 
messages should be sent to the Wine server, or should the Win32 
infrastructure be used?

Tell me what you think?

Pierre.

HIObjectSetCustomArchiveData---
  dlls/winequartz.drv/Makefile.in         |    7 +-
  dlls/winequartz.drv/carbon_imports.h    |   52 ++++++
  dlls/winequartz.drv/quartzdrv.h         |  106 +++++++++++++
  dlls/winequartz.drv/quartzdrv_carbon.c  |  228 +++++++++++++++++++++++++++
  dlls/winequartz.drv/quartzdrv_main.c    |   93 +++++++++++-
  dlls/winequartz.drv/window.c            |  261 
+++++++++++++++++++++++++++++++
  dlls/winequartz.drv/winequartz.drv.spec |   11 ++-
  dlls/winequartz.drv/winpos.c            |   74 +++++++++
  8 files changed, 825 insertions(+), 7 deletions(-)
-------------- next part --------------
diff --git a/dlls/winequartz.drv/Makefile.in b/dlls/winequartz.drv/Makefile.in
index b2214b6..863808c 100644
--- a/dlls/winequartz.drv/Makefile.in
+++ b/dlls/winequartz.drv/Makefile.in
@@ -4,9 +4,14 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winequartz.drv
 IMPORTS   = user32 gdi32 advapi32 kernel32 ntdll
+EXTRALIBS = -framework Carbon
 
 C_SRCS = \
-	quartzdrv_main.c
+	event.c \
+	quartzdrv_carbon.c \
+	quartzdrv_main.c \
+	window.c \
+	winpos.c
 
 @MAKE_DLL_RULES@
 
diff --git a/dlls/winequartz.drv/carbon_imports.h b/dlls/winequartz.drv/carbon_imports.h
new file mode 100644
index 0000000..12e3754
--- /dev/null
+++ b/dlls/winequartz.drv/carbon_imports.h
@@ -0,0 +1,52 @@
+/*
+ * Imported Carbon Functions code whose names may conflict with
+ * Win32 equivalents
+ *
+ * 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
+ */
+
+#ifndef __WINE_CARBON_IMPORTS_H
+#define __WINE_CARBON_IMPORTS_H
+
+#include <dlfcn.h>
+
+#define CARBON_FUNCT(fct) \
+	static typeof(fct) * carbonPtr_##fct;
+CARBON_FUNCT(ShowWindow)
+CARBON_FUNCT(HideWindow)
+#undef CARBON_FUNCT
+
+static inline void * BindCarbonFunctions(void)
+{    
+    void * HIToolBoxDLHandle = dlopen("/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/HIToolbox", RTLD_LAZY | RTLD_LOCAL);
+    
+    if (!HIToolBoxDLHandle) {
+        fprintf(stderr, "%s impossible d'ouvrir HIToolBoxDLHandle\n", __FUNCTION__);
+        return nil;
+    }
+#define LOAD_FUNCTION(f) \
+    if((carbonPtr_##f = dlsym(HIToolBoxDLHandle, #f)) == NULL) \
+    { \
+        fprintf(stderr, "%s Can't find symbol %s\n", __FUNCTION__,  #f); \
+        return nil;                                  \
+    }
+    LOAD_FUNCTION(ShowWindow)
+    LOAD_FUNCTION(HideWindow)
+#undef LOAD_FUNCTION
+	return HIToolBoxDLHandle;
+}
+#endif  /* __WINE_CARBON_IMPORTS_H */
diff --git a/dlls/winequartz.drv/quartzdrv.h b/dlls/winequartz.drv/quartzdrv.h
new file mode 100644
index 0000000..3365ec7
--- /dev/null
+++ b/dlls/winequartz.drv/quartzdrv.h
@@ -0,0 +1,106 @@
+/*
+ * Quartz driver definitions
+ *
+ * Copyright 1996 Alexandre Julliard
+ * Copyright 1999 Patrik Stridvall
+ * 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
+ */
+
+#ifndef __WINE_QUARTZDRV_H
+#define __WINE_QUARTZDRV_H
+
+/* ---------------------------------------------------------------------
+   per-Thread data management
+*/
+struct quartzdrv_thread_data
+{
+	int		process_event_count;  /* recursion count for event processing */
+};
+
+extern struct quartzdrv_thread_data *quartzdrv_init_thread_data(void);
+extern DWORD thread_data_tls_index;
+
+inline static struct quartzdrv_thread_data *quartzdrv_thread_data(void)
+{
+    struct quartzdrv_thread_data *data = TlsGetValue( thread_data_tls_index );
+    if (!data) data = quartzdrv_init_thread_data();
+    return data;
+}
+
+/* ---------------------------------------------------------------------
+   Window management
+*/
+typedef void * ObjectRef;
+
+struct quartzdrv_win_data
+{
+    HWND        hwnd;
+    ObjectRef   carbon_view;        /* Ptr to the Object HIViewRef
+                                       that represent the window on Carbon side */
+    ObjectRef   carbon_window;      /* if not NULL, carbon_window represents the WindowRef
+                                       asssociated with the hwnd */
+    RECT        hwnd_rect;          /* The position of the hwnd */
+};
+
+/* ---------------------------------------------------------------------
+   Display Context
+*/
+typedef struct {
+    HDC hdc;
+
+    ObjectRef     drawable;
+} QDRV_PDEVICE;
+
+/* ---------------------------------------------------------------------
+   Carbon/Carbon.h
+*/
+extern int HIViewSetVisible(ObjectRef inView, BOOL inVisible);
+extern ObjectRef HIViewGetRoot(ObjectRef inWindow);
+extern void CFRelease(ObjectRef obj);
+
+
+/* ---------------------------------------------------------------------
+   quartzdrv_carbon.c
+*/
+extern unsigned int screen_width;
+extern unsigned int screen_height;
+extern ObjectRef    root_window;
+
+extern void CARBON_ShowWindow(ObjectRef win);
+extern void CARBON_HideWindow(ObjectRef win);
+
+extern void QDRV_CarbonSetViewData(ObjectRef view, const struct quartzdrv_win_data *data);
+extern void QDRV_CarbonGetViewData(ObjectRef view, struct quartzdrv_win_data **data);
+extern void QDRV_CarbonSetWindowFrame(ObjectRef win, int left, int top, int right, int bottom);
+extern void QDRV_CarbonDeleteWindow(ObjectRef win);
+extern ObjectRef QDRV_CarbonCreateNewWindow(int top, int left, int right, int bottom);
+
+extern ObjectRef QDRV_CarbonCreateNewView(ObjectRef parent, int top, int left, int right, int bottom);
+
+extern void QDRV_CarbonRunEventLoop(void);
+
+extern void QDRV_CarbonInitialize(void);
+extern void QDRV_CarbonFinalize(void);
+
+/* ---------------------------------------------------------------------
+   quartzdrv_main.c
+*/
+extern void wine_quartzdrv_lock(void);
+extern void wine_quartzdrv_unlock(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..01c95cf
--- /dev/null
+++ b/dlls/winequartz.drv/quartzdrv_carbon.c
@@ -0,0 +1,228 @@
+/*
+ * 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>
+
+#include "carbon_imports.h"
+static void * HIToolBoxDLHandle = NULL;
+
+extern void wine_quartzdrv_lock(void);
+extern void wine_quartzdrv_unlock(void);
+
+static const void* wine_quartzdrv_view_data_key = (void*)'WQVD';
+
+unsigned int screen_width;
+unsigned int screen_height;
+WindowRef    root_window = NULL;
+
+
+/***********************************************************************
+ *          CARBON_ShowWindow
+ */
+void CARBON_ShowWindow(WindowRef win)
+{
+    if (carbonPtr_ShowWindow) carbonPtr_ShowWindow(win);
+}
+
+/***********************************************************************
+ *          CARBON_HideWindow
+ */
+void CARBON_HideWindow(WindowRef win)
+{
+    if (carbonPtr_ShowWindow) carbonPtr_ShowWindow(win);
+}
+
+/***********************************************************************
+ *          QDRV_SetWindowFrame
+ *
+ *          Associate the Window bridge data (hwnd mainly) with our
+ *          (Carbon) Window
+ */
+void QDRV_CarbonSetWindowFrame(WindowRef win, int left, int top, int right, int bottom)
+{
+    Rect bounds;
+    bounds.left = left;
+    bounds.top = top;
+    bounds.right = right;
+    bounds.bottom = bottom;
+    SetWindowBounds(win, kWindowStructureRgn, &bounds);
+}
+
+/***********************************************************************
+ *          QDRV_CarbonSetViewData
+ *
+ *          Associate the Window bridge data (hwnd mainly) with our
+ *          (Carbon) View
+ */
+void QDRV_CarbonSetViewData(HIViewRef view, const void *data)
+{
+    CFDictionaryRef dict;
+    OSStatus err;
+    dict = CFDictionaryCreate(kCFAllocatorDefault, &wine_quartzdrv_view_data_key, &data, 1, NULL, NULL);
+    err = HIObjectSetCustomArchiveData((HIObjectRef)view, dict);
+    if(err != noErr)
+        fprintf(stderr,"Can't HIObjectSetCustomArchiveData\n");
+}
+
+/***********************************************************************
+ *          QDRV_CarbonGetViewData
+ *
+ *          Return the Window bridge data (hwnd mainly) associated with
+ *          our (Carbon) View
+ */
+void QDRV_CarbonGetViewData(HIViewRef view, const void **data)
+{
+    CFDictionaryRef dict;
+    OSStatus err;
+    err = HIObjectCopyCustomArchiveData((HIObjectRef)view, &dict);
+    if(err != noErr)
+        fprintf(stderr,"Can't HIObjectCopyCustomArchiveData\n");
+    *data = CFDictionaryGetValue(dict, wine_quartzdrv_view_data_key);
+}
+
+/***********************************************************************
+ *          QDRV_CarbonDeleteWindow
+ */
+void QDRV_CarbonDeleteWindow(WindowRef win)
+{
+    DisposeWindow(win);
+}
+
+/***********************************************************************
+ *          QDRV_CarbonCreateNewWindow
+ */
+WindowRef QDRV_CarbonCreateNewWindow(int top, int left, int right, int bottom)
+{
+    OSStatus err;
+    WindowRef window;
+    Rect bounds;
+    WindowAttributes attrs;
+
+    attrs = kWindowStandardHandlerAttribute | kWindowCompositingAttribute | kWindowNoTitleBarAttribute;
+
+    bounds.top = top;
+    bounds.left = left;
+    bounds.right = right;
+    bounds.bottom = bottom;
+    
+    err = CreateNewWindow(kDocumentWindowClass, attrs, &bounds, &window);
+    if(err != noErr)
+        return nil;
+    return window;
+}
+
+/***********************************************************************
+ *          QDRV_CarbonCreateNewView
+ */
+HIViewRef QDRV_CarbonCreateNewView(HIViewRef parent, int top, int left, int right, int bottom)
+{
+    OSStatus err;
+    HIViewRef view;
+    HIRect frame;
+    
+    err = HIImageViewCreate(NULL, &view);
+    if(err != noErr)
+        return nil;
+
+    err = HIViewAddSubview(parent, view);
+    if(err != noErr)
+        return view;
+
+    frame.origin.x = (double)top;
+    frame.origin.y = (double)left;
+    frame.size.width = (double)(right-left);
+    frame.size.height = (double)(bottom-top);
+
+    err = HIViewSetFrame(view, &frame);
+    
+    return view;
+}
+
+
+/***********************************************************************
+ *          QDRV_CarbonRunEventLoop
+ */
+void QDRV_CarbonRunEventLoop(void)
+{
+    WindowRef window;
+    EventRef event;
+    
+    while(ReceiveNextEvent(0, NULL, kEventDurationForever, true, &event) == noErr)
+    {
+        UInt32 eventClass = GetEventClass(event);
+        UInt32 eventKind = GetEventKind(event);
+        Point point;
+        int where;
+        
+        switch (eventClass)
+        {
+            case kEventClassMouse:
+                GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL,
+                                sizeof(Point), NULL, &point);
+
+                wine_quartzdrv_lock();
+                where = MacFindWindow(point, &window);
+                wine_quartzdrv_unlock();
+
+                if(eventKind == kEventMouseDown && where == inMenuBar)
+                    MenuSelect(point);
+                else
+                    SendEventToEventTarget(event, GetEventDispatcherTarget());
+
+                break;
+            case kEventClassAppleEvent:
+            case kEventClassApplication:
+            default:
+            	SendEventToEventTarget(event, GetEventDispatcherTarget());
+        }
+	ReleaseEvent(event);
+    }
+
+    exit(0);
+}
+
+/***********************************************************************
+ *          QDRV_Initialize
+ */
+void QDRV_CarbonInitialize(void)
+{
+    ProcessSerialNumber psn;
+        
+    GetProcessForPID(getpid(), &psn);
+    TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+    SetFrontProcess(&psn);
+    
+    root_window = (WindowRef)CGMainDisplayID();
+
+    screen_width  = CGDisplayPixelsWide(CGMainDisplayID());
+    screen_height = CGDisplayPixelsHigh(CGMainDisplayID());
+    
+    HIToolBoxDLHandle = BindCarbonFunctions();
+}
+
+/***********************************************************************
+ *          QDRV_Finalize
+ */
+void QDRV_CarbonFinalize(void)
+{
+    dlclose(HIToolBoxDLHandle);
+}
\ No newline at end of file
diff --git a/dlls/winequartz.drv/quartzdrv_main.c b/dlls/winequartz.drv/quartzdrv_main.c
index 88bc6ac..b9daf0f 100644
--- a/dlls/winequartz.drv/quartzdrv_main.c
+++ b/dlls/winequartz.drv/quartzdrv_main.c
@@ -26,8 +26,91 @@
 #include "winbase.h"
 #include "winreg.h"
 
+#include "wine/debug.h"
+
+#include "quartzdrv.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(quartzdrv);
+
+DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
+
+static CRITICAL_SECTION QDRV_CritSection;
+static CRITICAL_SECTION_DEBUG critsect_debug =
+{
+    0, 0, &QDRV_CritSection,
+    { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
+      0, 0, { (DWORD_PTR)(__FILE__ ": QDRV_CritSection") }
+};
+static CRITICAL_SECTION QDRV_CritSection = { &critsect_debug, -1, 0, 0, 0, 0 };
+
+/***********************************************************************
+ *           QDRV thread initialisation routine
+ */
+struct quartzdrv_thread_data *quartzdrv_init_thread_data(void)
+{
+    struct quartzdrv_thread_data *data;
+    
+    if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) )))
+    {
+        ERR( "could not create data\n" );
+        ExitProcess(1);
+    }
+    
+    data->process_event_count = 0;
+
+    TlsSetValue( thread_data_tls_index, data );
+
+    return data;
+}
+
 /***********************************************************************
- *           QUARTZDRV initialisation routine
+ *		wine_quartzdrv_lock   (QDRV.@)
+ */
+void wine_quartzdrv_lock(void)
+{
+    EnterCriticalSection( &QDRV_CritSection );
+}
+
+/***********************************************************************
+ *		wine_quartzdrv_unlock   (QDRV.@)
+ */
+void wine_quartzdrv_unlock(void)
+{
+    LeaveCriticalSection( &QDRV_CritSection );
+}
+
+/***********************************************************************
+ *           process initialisation routine
+ */
+static BOOL process_attach(void)
+{
+    TRACE("\n");
+    QDRV_CarbonInitialize();
+    CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)QDRV_CarbonRunEventLoop, NULL, 0, NULL);
+    return TRUE;
+}
+
+
+/***********************************************************************
+ *           thread termination routine
+ */
+static void thread_detach(void)
+{
+    TRACE("\n");
+}
+
+
+/***********************************************************************
+ *           process termination routine
+ */
+static void process_detach(void)
+{
+    TRACE("\n");
+    QDRV_CarbonFinalize();
+}
+
+/***********************************************************************
+ *           Dll entry point
  */
 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
 {
@@ -36,14 +119,14 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DW
     switch(reason)
     {
     case DLL_PROCESS_ATTACH:
-        /* Do attach */
+        ret = process_attach();
         break;
     case DLL_THREAD_DETACH:
-        /* do thread detach */
+        thread_detach();
         break;
     case DLL_PROCESS_DETACH:
-        /* do detach */
+        process_detach();
         break;
     }
     return ret;
-}
+}
\ No newline at end of file
diff --git a/dlls/winequartz.drv/window.c b/dlls/winequartz.drv/window.c
new file mode 100644
index 0000000..218be6b
--- /dev/null
+++ b/dlls/winequartz.drv/window.c
@@ -0,0 +1,261 @@
+/*
+ * Window related functions
+ *
+ * Copyright 1993, 1994, 1995, 1996, 2001 Alexandre Julliard
+ * Copyright 1993 David Metcalfe
+ * Copyright 1995, 1996 Alex Korobka
+ *
+ * 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 "config.h"
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winreg.h"
+#include "winuser.h"
+#include "wine/unicode.h"
+
+#include "wine/debug.h"
+#include "wine/server.h"
+#include "win.h"
+
+#include "quartzdrv.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(quartzdrv);
+
+static const char * wine_quartzdrv_win_data = "__wine_quartzdrv_win_data" ;
+
+/* ---------------------------------------------------------------------
+ *  alloc_quartzdrv_win_data
+ */
+struct quartzdrv_win_data *alloc_quartzdrv_win_data(HWND hwnd)
+{
+    struct quartzdrv_win_data * data;
+    if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) )))
+    {
+        ERR("Not enough memory\n");
+        return NULL;
+    }
+    data->hwnd = hwnd;
+    data->carbon_window = 0;
+    data->carbon_view = 0;
+    SetPropA(hwnd, wine_quartzdrv_win_data, (HANDLE)data);
+    return data;
+}
+
+/* ---------------------------------------------------------------------
+ *  get_quartzdrv_win_data_from_hwnd
+ */
+struct quartzdrv_win_data *get_quartzdrv_win_data_from_hwnd(HWND hwnd)
+{
+    return (struct quartzdrv_win_data *)GetPropA(hwnd, wine_quartzdrv_win_data);
+}
+
+/***********************************************************************
+ *		SetWindowText   (QDRV.@)
+ */
+void QDRV_SetWindowText( HWND hwnd, LPCWSTR text )
+{
+    FIXME("stub!\n");
+}
+
+/***********************************************************************
+ *		DestroyWindow   (QDRV.@)
+ */
+void QDRV_DestroyWindow( HWND hwnd )
+{
+    FIXME("stub!\n");
+}
+
+/***********************************************************************
+ *		CreateDesktopWindow   (QDRV.@)
+ */
+BOOL QDRV_CreateDesktopWindow( HWND hwnd )
+{
+    FIXME("stub!\n");
+    return FALSE;
+}
+
+/***********************************************************************
+ *              ShowWindow   (QDRV.@)
+ */
+BOOL QDRV_ShowWindow( HWND hwnd, INT cmd )
+{
+    struct quartzdrv_win_data *data = get_quartzdrv_win_data_from_hwnd(hwnd);
+    
+    if(!data)
+        return FALSE;
+    
+    /* Quick stub to have the see window */
+    FIXME("stub\n");
+    
+    switch(cmd)
+    {
+        case SW_HIDE:
+            wine_quartzdrv_lock();
+            if(data->carbon_window)
+                CARBON_HideWindow(data->carbon_window);
+            else
+                HIViewSetVisible(data->carbon_view, FALSE);
+            wine_quartzdrv_unlock();
+
+	    break;
+
+	case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
+	case SW_SHOWNA:
+	case SW_SHOW:
+	case SW_SHOWNOACTIVATE:
+	case SW_SHOWNORMAL:  /* same as SW_NORMAL: */
+	case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
+            wine_quartzdrv_lock();
+            if(data->carbon_window)
+                CARBON_ShowWindow(data->carbon_window);
+            else
+                HIViewSetVisible(data->carbon_view, TRUE);
+            wine_quartzdrv_unlock();
+	    break;
+    }
+    return TRUE;
+}
+
+/***********************************************************************
+ *		CreateWindow   (QDRV.@)
+ */
+BOOL QDRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
+{
+    struct quartzdrv_win_data *data = alloc_quartzdrv_win_data(hwnd);
+    
+    if(!data)
+        return FALSE;
+
+    /* only a stub that show how window should be handled in carbon  */
+    FIXME("stub\n");
+
+    if ( (GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow()) || (hwnd == GetDesktopWindow()) )
+    {
+        wine_quartzdrv_lock();
+        data->carbon_window = QDRV_CarbonCreateNewWindow(cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy);
+        data->carbon_view = HIViewGetRoot(data->carbon_window);
+        QDRV_CarbonSetViewData(data->carbon_view, data);
+        wine_quartzdrv_unlock();
+
+    }
+    else
+    {
+        struct quartzdrv_win_data *parent_data = get_quartzdrv_win_data_from_hwnd(GetAncestor( hwnd, GA_PARENT ));
+        wine_quartzdrv_lock();
+        data->carbon_window = 0;
+        data->carbon_view = QDRV_CarbonCreateNewView(parent_data->carbon_view, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy);
+        QDRV_CarbonSetViewData(data->carbon_view, data);
+        wine_quartzdrv_unlock();
+
+    }
+    
+    SetRect(&data->hwnd_rect, cs->x, cs->y, cs->cx, cs->cy);
+
+    return TRUE;
+}
+
+/***********************************************************************
+ *		SetParent   (QDRV.@)
+ */
+HWND QDRV_SetParent( HWND hwnd, HWND parent )
+{
+    HWND old_parent = 0;
+    WND *wndPtr;
+    BOOL ret;
+
+    TRACE("\n");
+
+    /* Get the old parent from the wineserver */
+    wndPtr = WIN_GetPtr( hwnd );
+    if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return 0;
+
+    SERVER_START_REQ( set_parent )
+    {
+        req->handle = hwnd;
+        req->parent = parent;
+        if ((ret = !wine_server_call( req )))
+        {
+            old_parent = reply->old_parent;
+            wndPtr->parent = parent = reply->full_parent;
+        }
+
+    }
+    SERVER_END_REQ;
+    WIN_ReleasePtr( wndPtr );
+    if (!ret) return 0;
+
+    if (parent != old_parent)
+    {
+        struct quartzdrv_win_data *data = get_quartzdrv_win_data_from_hwnd(hwnd);
+        if(!data)
+            return 0;
+        if (parent != GetDesktopWindow())
+        {
+            if(old_parent == GetDesktopWindow())
+            {
+                /* make the hwnd a HIView instead of a Window */
+                struct quartzdrv_win_data *parent_data = get_quartzdrv_win_data_from_hwnd(parent);
+                ObjectRef parent_view = NULL;
+                if(parent_data)
+                    parent_view = parent_data->carbon_view;
+                
+                wine_quartzdrv_lock();
+                QDRV_CarbonDeleteWindow(data->carbon_window);
+                data->carbon_window = 0;
+                data->carbon_view = QDRV_CarbonCreateNewView(parent_view, data->hwnd_rect.top, data->hwnd_rect.left, data->hwnd_rect.right, data->hwnd_rect.bottom); 
+                QDRV_CarbonSetViewData(data->carbon_view, data);
+                wine_quartzdrv_unlock();
+            }
+        }
+        else
+        {
+            /* make the hwnd a Window instead of a HIView */
+            wine_quartzdrv_lock();
+            CFRelease(data->carbon_view);
+            data->carbon_window = QDRV_CarbonCreateNewWindow(data->hwnd_rect.top, data->hwnd_rect.left, data->hwnd_rect.right, data->hwnd_rect.bottom);
+            data->carbon_view = HIViewGetRoot(data->carbon_window);
+            QDRV_CarbonSetViewData(data->carbon_view, data);
+            wine_quartzdrv_unlock();
+        }
+    }
+    return old_parent;
+}
+
+/***********************************************************************
+ *		SetFocus   (QDRV.@)
+ */
+void QDRV_SetFocus( HWND hwnd )
+{
+    FIXME("stub!\n");
+}
+
+/***********************************************************************
+ *		SetWindowIcon (QDRV.@)
+ */
+void QDRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
+{
+    FIXME("stub!\n");
+}
diff --git a/dlls/winequartz.drv/winequartz.drv.spec b/dlls/winequartz.drv/winequartz.drv.spec
index d98d860..b23ab42 100644
--- a/dlls/winequartz.drv/winequartz.drv.spec
+++ b/dlls/winequartz.drv/winequartz.drv.spec
@@ -1 +1,10 @@
-# Nothing Yet
+# Window Function
+@ cdecl CreateWindow(long ptr long) QDRV_CreateWindow
+@ cdecl ShowWindow(long long) QDRV_ShowWindow
+@ cdecl SetParent(long long) QDRV_SetParent
+
+@ cdecl MsgWaitForMultipleObjectsEx(long ptr long long long) QDRV_MsgWaitForMultipleObjectsEx
+
+# Quartzdrv locks
+@ cdecl -norelay wine_quartzdrv_lock()
+@ cdecl -norelay wine_quartzdrv_unlock()
diff --git a/dlls/winequartz.drv/winpos.c b/dlls/winequartz.drv/winpos.c
new file mode 100644
index 0000000..a36545b
--- /dev/null
+++ b/dlls/winequartz.drv/winpos.c
@@ -0,0 +1,74 @@
+/*
+ * Window position related functions.
+ *
+ * Copyright 1993, 1994, 1995, 2001 Alexandre Julliard
+ * Copyright 1995, 1996, 1999 Alex Korobka
+ *
+ * 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 "config.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#ifdef HAVE_LIBXSHAPE
+#include <X11/extensions/shape.h>
+#endif /* HAVE_LIBXSHAPE */
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winerror.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(quartzdrv);
+
+/***********************************************************************
+ *		SetWindowStyle   (QDRV.@)
+ */
+void QDRV_SetWindowStyle( HWND hwnd, DWORD old_style )
+{
+    FIXME("stub!\n");
+}
+
+/***********************************************************************
+ *		SetWindowPos   (QDRV.@)
+ */
+BOOL QDRV_SetWindowPos( WINDOWPOS *winpos )
+{
+    FIXME("stub!\n");
+    return TRUE;
+}
+
+
+/***********************************************************************
+ *		SetWindowRgn  (QDRV.@)
+ */
+int QDRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
+{
+    FIXME("stub!\n");
+    return 0;
+}
+
+/***********************************************************************
+ *           SysCommandSizeMove   (QDRV.@)
+ */
+void QDRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
+{
+    FIXME("stub!\n");
+}


More information about the wine-patches mailing list