diff --git a/ChangeLog b/ChangeLog index a957c33c41b..5533bfc1dad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,455 @@ +---------------------------------------------------------------------- +Tue Mar 1 11:30:21 1994 Bob Amstadt (bob@pooh) + + * [Configure] [*/Imakefile] + Created configure script to handle different types of Wine builds. + + * [Configure] [tools/build.c] [if1632/Imakefile] [Wine.tmpl] + Added ability to compile Wine on systems with 14-char filename limit. + + * [if1632/relay.c] [include/options.h] [misc/main.c] + Added -relaydbg option to command line if DEBUG_RELAY is defined. + + * [loader/selector.c] + Fixed bug in GetEntryDLLName() that caused Wine to seg fault. + + * [memory/heap.c] + Fixed LocalInit() to work correctly. + + * [misc/user.c] + Added code to call loaded DLLs' initialization routines. + +Tue Mar 1 01:01:17 MET 1994 julliard@di.epfl.ch (Alexandre Julliard) + + * [windows/dce.c] + Added clipping of child windows by their parent's client area. + + * [windows/nonclient.c] + Bug fix in NC_DoNCPaint(). + + * [windows/painting.c] + Bug fix in RedrawWindow(). + +Feb 27, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) + + * [mem/atom.c] + Bug fix again in ATOM_DeleteAtom() : + change LocalFree() by USER_HEAP_FREE(). + (Previous patch done Feb 13th had been lost) + + * [controls/scroll.c] + Move bitmaps loading in AllocScrollBar() instead of in WM_CREATE. + + * [windows/class.c] (sorry Alex ...) + There was no bug there "in RegisterClass() : + WNDCLASS->lpszClassName was reset to NULL." + ^^^^^ + + * [misc/clipboard.c] --- New File --- + New function EnumClipboardFormats(). + New function OpenClipboard(). + New function CloseClipboard(). + New function EmptyClipboard(). + New function GetClipboardOwner(). + New function GetClipboardViewer(). + New function CountClipboardFormats(). + New function IsClipboardFormatAvailable(). + New function OpenClipboard(). + New function GetClipboardData(). + New function SetClipboardViewer(). + New function EnumClipboardFormats(). + New function RegisterClipboardFormat(). + New function ChangeClipboardChain(). + New function SetClipboardData(). + New function GetOpenClipboardWindow(). + New function GetPriorityClipboardFormat(). + New function GetClipboardFormatName(). + +Tue Mar 1 20:15:45 1994 Erik Bos + + * [misc/comm.c] + bugfix in OpenComm(). + +---------------------------------------------------------------------- +Tue Feb 22 18:04:02 1994 Jeffrey Hsu + + * [include/winsock.h] + The sockproto struct is already defined in + + * [misc/winsock.c] + Need to include for struct in-addr. + Use sys_errlist[] instead of strerror[]. + + *[toolkit/heap.c] + ANSI C specifies that the malloc functions are defined in stdlib.h, + so we don't need to include malloc.h. + + *[loader/ldtlib.c] + Print informative error message about probable cause of i386_set_ldt() + failure and then exit. + + *[Imakefile] + For systems that don't use gmake by default, set the MAKE variable + to gmake and propagate it on recursive makes. + Take out -li386 for FreeBSD systems and define __FreeBSD__ so Wine + can be built with the FreeBSD 1.0.2 compiler. + +Tue Feb 22 02:52:19 EST 1994 jrichard@cs.uml.edu (John Richardson) + + * [objects/bitblt.c] + Added in three functions to do stretching and compression + for WHITEONBLACK, BLACKONWHITE, and color copies. + +Tue Feb 22 15:01:31 EST 1994 jrichard@cs.uml.edu (John Richardson) + + * [windows/graphics.c] + Added FloodFill and FloodFill_rec. FloodFill_rec is pretty + inefficent, but should suffice for now. + + * [include/windows.h] + Changed the x,y paramaters for the FloodFill prototype + from ints to shorts + +Tue Feb 22 00:58:28 MET 1994 julliard@di.epfl.ch (Alexandre Julliard) + + * [windows/widgets.c] + Added desktop window class. + + * [windows/painting.c] + Bug fix in RedrawWindow(). + Implemented ExcludeUpdateRgn(). + + * [windows/win.c] [windows/winpos.c] + Implemented desktop window. + + * [controls/desktop.c] + Preliminary desktop window procedure. + +Feb 20, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) + + * [controls/menu.c] + New function LoadMenuIndirect(). + New function GetMenuCheckMarkDimensions(). + + * [if1632/user.spec] + Entry for DefDlgProc(). + + * [windows/class.c] + Fix bug in RegisterClass() : + WNDCLASS->lpszMenuName was reset to NULL. + + * [windows/win.c] + In CreateWindowEx(), if hMenu == 0 then use + wndclass->lpszMenuName to load Menu from resource; + +Mon Feb 21 22:38:28 1994 Erik Bos (erik@trashcan.hacktic.nl) + + * [loader/library.c] [loader/wine.c] + Fixed runing DLL's as main executable problem. + + * [misc/dos_fs.c] + Added wildcard support in DOS_readdir(). + + * [misc/winsocket.c] + Added proper error handling of BSD winsocket functions. + + * [miscemu/int21.c] + KERNEL_DOS3Call renamed to DOS3Call and modified to use do_int21(). + + * [main/main.c] + Added functions for GetVersion, GetWinFlags and GetTimerResolution + for libwine.a, SystemParametersInfo() partly implemented. + +Tue Feb 22 19:00:02 1994 Miguel de Icaza (miguel@xochitl.nuclecu.unam.mx) + + * [toolkit/winmain.c] + Added _WinMain function. Setups the library (calls USER_InitApp). + + * [toolkit/sup.c] + Added load_mz_header, load_ne_header, load_type_info and + load_name_info functions. + + * [toolkit/heap.c] + Code cleanup. + + * [misc/user.c] + Moved from loader/misc.c. I hope to put back all the loader + functions in the ~loader subdirectory in the future. CUrrently is + needed since it has USER_InitApp. + + * [misc/resource.c] + Since WineLib will probably need DLLs (currently it needs + Sysres.dll). WineLib will be using much code of the loader again. + So I removed some ifdefs that were used by WineLib. + + Added load_typeinfo and load_nameinfo (and the corresponding + functions in [toolkit/sup.c] + + Added integer convertion functions in the needed places. + + Added very ugly patch (includes wine.c). In the next release I + plan to move back all the loader routines to ~/loader. In the + meantime I needed this patch. It doesn't affect any of the + emulator code (its ifdefed for WineLib). + + * [misc/main.c] + Cleaned up call to WinMain (now uses [toolkit/winmain.c] + Ifdefed argument number checking when compiling the library. + + * [loader/wine.c] + Modified to use load_(mz|ne)_header instead of doing a direct + read. When compiling the emulator it still uses the direct read + for performance. + + * [include/wine.h] + Prototypes for loading routines. + + * [include/class.h] + Added WINE_PACKED macro instead of __attribute__ ((packed)) + + * [include/arch.h] + Macros for converting integers (Little endian to big-endian). + Needed in the Sun to allow loading of DLL files. + +---------------------------------------------------------------------- +Mon Feb 14 23:48:09 MET 1994 julliard@di.epfl.ch (Alexandre Julliard) + + * [windows/clipping.c] + Moved everything into windows/painting.c and removed this file. + + * [windows/message.c] + Removed calls to memmove() in MSG_RemoveMsg(). + + * [windows/nonclient.c] + Added WM_GETMINMAXINFO support for window resizing. + + * [windows/painting.c] + Implemented RedrawWindow(). + + * [windows/scroll.c] + Bug fix in ScrollWindowEx(). + + * [windows/win.c] + Moved UpdateWindow() to windows/painting.c. + +Fri Feb 11 12:41:28 1994 Erik Bos (erik@trashcan.hacktic.nl) + + * [loader/wine.c] [misc/dos_fs.c] + getenv() eq NULL bugfixes. + + * [misc/comm.c] + cfmakeraw changed for SunOS. + +Feb 13, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) + + * [mem/atom.c] + Bug fix in ATOM_DeleteAtom() : + change LocalFree() by USER_HEAP_FREE(). + + * [misc/message.c] + New function FatalAppExit(). + + * [objects/font.c] + New empty stub SetMapperFlags(). + + * [controls/menu.c] + Better CheckMark & other bitmaps placement. + + * [windows/graphics.c] + New function RoundRect() : calc.exe now working... + +Tue Feb 15 14:29:37 1994 John Richardson + + * [objects/bitblt.c] + Fixed StretchBlt so it works quicker and faster. It still doesn't + use the StretchMode bits for bitmap compression, but that will + come soon. + +Mon Feb 14 13:21:04 1994 Miguel de Icaza (miguel@roxanne.nuclecu.unam.mx) + + * [include/windows.h,dialog.h,gdi.h] + Changed __atribute__ ((packed)) for WINE_PACKED. + When compiling the library this is defined as nothing. This gets + rid with all the problems compiling under SunOS. Also + + * [windows/utility.c] + Added DebugPrintString. + + * [toolkit/sup.c] + Added hSysRes = 1 definition to resolve externals. + Added CallLineDDAProc function (toolkit version). + Added toy, and hi ineficient memmove until code in message.c get + rewritten. + + * [objects/gdiobj.c] + Ifdefed linux/emulator-dependent code to allow compilation of + WineLib. + + * [misc/winsocket.c] + Added ifdef to allow compilation under SunOS. + + * [misc/resource.c] + When compiling the library, the resource file is expected to be in + a file called $argv[0].Res. Also the information of the resource + is expected to be at offset 0 of the .Res file. + + * [misc/main.c] + Call WinMain with arguments if compiling WineLib. + Call shutdown functions (Comm_DeInit, DOS_DeInitFS). + Call sync_profiles to preserve changes to .INI files. + + * [misc/comm.c,dos_fs.c] + removed call to atexit(Comm_DeInit) + removed call to atexit(DOS_DeInitFS) + Shutdown functions are now called from the return of WinMain + + * removed memorylib subdirectory + + * moved memory/atom.c to misc/atom.c + moved memorylib/heap.c to toolkit/heap.c + + * [loader/wine.c] + Moved DebugPrintString to windows/utility.c + + * [include/winsock.h] + Define SO_DONTLINGER only if it has not been previously defined. + + * [include/windows.h] + added definition for DLGPROC. + added definition for LMEM_WINE_ALIGN and other LMEM_* constants. + When compiling WineLib WNDPROC is defined with all the parameters + to avoid compilation problems. + + * [include/user.h] + When compiling WineLib USER_HEAP_(ALLOC|REALLOC|ADDR|FREE) the + calls are translated to the library allocation routines. + + * [include/gdi.h,user.h] + When compiling WineLib GDI_HEAP_(ALLOC|ADDR|FREE) the calls are + translated to the library allocation routines. + + * [include/atom.h] + Defined LocalAlign. When compiling the emulator it's translated as + a call to LocalAlloc (the original code), when compiling WineLib + as a call to LocalAlloc with a WINE-flag called LMEM_WINE_ALIGN + (atom.c needs aligned data on a 4 byte boundary). + + * [misc/file.c] + Renamed KERNEL_* functions and fixed prototypes. + + * [if1632/kernel.spec] + Renamed KERNEL_* functions in order to be used by applications + using Wine as a library (OpeFile, _lclose, _lread, _lcreate, + _llseek, _lopen, _lwrite). + + * [Makefile] + Create library instead of executable when building target + libwine.a + +---------------------------------------------------------------------- +Tue Feb 8 13:52:11 1994 Miguel de Icaza (miguel@roxanne) + + * [Makefiles] + Use $(CC) instead of cc. + Added libwine target. + + * [include/prototypes] + #ifdefed section for WineLib + + * moved loader/cursor.c to misc/cursor.c + moved loader/resource.c to misc/resource.c + moved misc/emulate.c to miscemu/emulate.c + moved misc/int1a.c to miscemu/int1a.c + moved misc/int21.c to miscemu/int21.c + moved misc/kernel.c to miscemu/kernel.c + moved misc/user.c to miscemu/user.c + + * [memorylib/heap.c] + Heap management for WineLib + + * [misc/comm.c] + Modified to allow compilation under SunOS (#include errno, SunOS + doesn't have atexit ()). + + * [misc/dos_fs.c] + Modified to allow compilation under SunOS (#include vfs.h) + + * [misc/file.c] + Modified to allow compilation under SunOS (OPEN_MAX constant, + #include unistd.h) + + * [objects/palette.c] + Modified to allow compilation under SunOS (#include limits) + + * [toolkit/sup.c] + WineLib version of CallWindowProc. + + * [windows/event.c] + Typedef XPointer under X11R4 (OpenWindows). + + * [windows/win.c] + When compiling WineLib, use direct callbacks instead of the + windows supplied callbacks. + +Mon Feb 7 22:37:34 MET 1994 julliard@di.epfl.ch (Alexandre Julliard) + + * [loader/cursor.c] + New function CURSOR_SetWinCursor(), for internal use, to set + the cursor of a specific window more reliably than with SetCursor(). + + * [windows/nonclient.c] + Better window management. Moving and resizing from the system + menu should work now. + Added scroll-bar mouse tracking. + + * [windows/win.c] + Moved scroll-bar creation and destruction to defwnd.c. + +Feb 5, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) + + * [windows/nonclient.c] + Call to StdDrawMenuBar() during NC's drawing. + New NC_TrackMouseMenuBar() function which call + MenuButtonDown(), MenuButtonUp() & MenuMouseMove(). + + * [controls/menu.c] + New ChangeMenu() function. + Remove permanently old Xt menu code. + Make common functions MenuButtonDown(), MenuButtonUp() + & MenuMouseMove() for both popups & menubar. + + * [controls/combo.c] + Paint OBM_COMBO directly in combo client. + + * [controls/listbox.c] + Fix bug in multicolumns calculations. + + * [controls/Makefile] + Remove rules for old file 'caption.c'. + + * [misc/kernel.c] + Remove empty stub GetModuleFileName(). + + * [loader/library.c] + New GetModuleHandle() function. + New GetModuleUsage() function. + New GetModuleFileName() function. + + * [loader/resource.c] + Try to find the bug a missing menu loading ... Not found yet ! + + * [windows/win.c] + Remove old menubar creation. + +Thu Feb 3 22:30:11 1994 Erik Bos (erik@trashcan.hacktic.nl) + + * [misc/winsocket.c] + More functions added. + + * [if1632/winsock.spec] [misc/winsocket.c] + Added John Brezak's winsock.dll stuff. + +---------------------------------------------------------------------- Tue Feb 1 21:14:47 1994 Bob Amstadt (bob@pooh) * [loader/selector.c] @@ -58,7 +510,7 @@ Jan 31, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) New GetSubMenu() function. Move GetMenu() & SetMenu() functions from 'windows/win.c'. - * [controls/combo.c] + * [controls/listbox.c] Start changes to satisfy recent changes in scrollbars/windows. * [loader/resource.c] diff --git a/Configure b/Configure new file mode 100755 index 00000000000..c6bf0978802 --- /dev/null +++ b/Configure @@ -0,0 +1,30 @@ +#! /bin/sh + +ALLDEFINES='' + +echo -n 'Build Wine as emulator or library (E/L) [E]? ' +read input +if [ "$input" = 'l' -o "$input" = 'L' ] +then + WINELIB='#define WineLib -DWINELIB' + ALLDEFINES=$ALLDEFINES -DWINELIB +else + WINELIB='' +fi + +echo -n 'Short filenames (Y/N) [N]? ' +read input +if [ "$input" = 'y' -o "$input" = 'Y' ] +then + SHORTNAMES='#define ShortNames -DSHORTNAMES' + ALLDEFINES=$ALLDEFINES -DSHORTNAMES +else + SHORTNAMES='' +fi + +echo '/* autoconf.h generated automatically. Run Configure. */' > autoconf.h +echo $WINELIB >> autoconf.h +echo $SHORTNAMES >> autoconf.h +echo "#define AutoDefines $ALLDEFINES" >> autoconf.h + +xmkmf -a diff --git a/Imakefile b/Imakefile index 05b5b4f0f9a..e0662aab8ab 100644 --- a/Imakefile +++ b/Imakefile @@ -1,5 +1,13 @@ +#include "autoconf.h" #include "Wine.tmpl" +#if defined(i386FreeBsd) +MAKE = gmake +CC = gcc -D__FreeBSD__ +#endif + +DEFINES = AutoDefines -DUSE_READLINE -DWINESTAT + /* * This is the second try at using Imakefiles. There are probably many * problems and things I haven't even considered. I do not have a fixed @@ -12,66 +20,76 @@ */ #define IHaveSubdirs -#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' 'CC=$(CC)' +#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' 'CC=$(CC)' 'MAKE=$(MAKE)'\ + 'DEFINES=$(DEFINES)' -SUBDIRS = \ - tools \ +COMMONSUBDIRS = \ controls \ etc \ - if1632 \ include \ - loader \ - memory \ misc \ objects \ test \ windows -/* - * due to me not having the time and resources to test this, debugging - * has been left out by for now of the Imakefiles. To put it back you have - * to add: - * debugger - * to the SUBDIRS list and: - * debugger - * readline.o - * to the OBJS list. - * - * Not doing this will make the build fail in loader/signal.c, with an - * unresolved reference to wine_debug. Comment out the line for now... - * sigh. Fixed soon. - */ +EMUSUBDIRS = \ + tools \ + debugger \ + if1632 \ + loader \ + memory \ + miscemu + +LIBSUBDIRS = \ + toolkit WINEDIR = $(LIBDIR)/wine -OBJS = \ - if1632.o \ +COMMONOBJS = \ controls.o \ - loader.o \ - memory.o \ misc.o \ objects.o \ windows.o -#ifdef i386BsdArchitecture -SYSLIBS = -ll -lm -li386 -lgnumalloc +/* + * WARNING: if1632.o must be the first object file because its code must be + * linked at the lowest possible addresses. + */ +EMUOBJS = \ + if1632.o \ + debugger.o \ + loader.o \ + memory.o \ + miscemu.o \ + readline.o + +LIBOBJS = \ + toolkit.o + +#ifndef WINELIB +SUBDIRS = $(COMMONSUBDIRS) $(EMUSUBDIRS) +OBJS = $(COMMONOBJS) $(EMUOBJS) #else -#ifdef LinuxArchitecture -SYSLIBS = -lm +SUBDIRS = $(COMMONSUBDIRS) $(LIBSUBDIRS) +OBJS = $(COMMONOBJS) $(LIBOBJS) #endif + +#if defined(i386BsdArchitecture) +SYSLIBS = -ll -lm -li386 -lgnumalloc +#elif defined(i386FreeBsd) +SYSLIBS = -ll -lm -lgnumalloc +#elif defined(LinuxArchitecture) +SYSLIBS = -lm -lg #endif MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) - -#ifdef i386BsdArchitecture AllTarget(wine) -#endif -NormalProgramTarget(wine,$(OBJS),XawClientDepLibs,XawClientLibs,$(SYSLIBS)) - -#ifdef LinuxArchitecture -AllTarget(wine) +#ifndef WINELIB +NormalProgramTarget(wine,$(EMUOBJS) $(COMMONOBJS),$(DEPXLIB),$(XLIB),$(SYSLIBS)) +#else +NormalLibraryTarget(wine,$(LIBOBJS) $(COMMONOBJS)) #endif depend:: diff --git a/Makefile b/Makefile deleted file mode 100644 index bbae18ac65c..00000000000 --- a/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -###################################################################### -# These variables are inherited by the sub-makefiles -DEBUGOPTS= -COPTS=-O2 -m486 -INCLUDE_DIR=include -LDFLAGS= - -###################################################################### -# These definitions are for the top level -TARGET=wine -LIBS=-L/usr/X386/lib -lX11 -lm -OBJS=if1632/if1632.o controls/controls.o loader/loader.o \ - memory/memory.o misc/misc.o objects/objects.o windows/windows.o debugger/debugger.o -SUBDIRS=if1632 controls loader memory misc objects windows debugger -TAGFILES=if1632/{*.c,*.S} controls/{*.c,*.S} loader/{*.c,*.S} \ - memory/{*.c,*.S} misc/{*.c,*.S} objects/{*.c,*.S} \ - windows/{*.c,*.S} debugger/{*.c,*.S} - -all: $(TARGET) - -dummy: - -tags: - etags $(TAGFILES) - -clean: - rm -f *~ *.o *# - @for i in tools $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done - -patchclean: - rm -f `find . -name '*.orig' -o -name '*.rej'` - -$(TARGET): dummy - @for i in tools $(SUBDIRS); \ - do (cd $$i && echo $$i && $(MAKE) INCLUDE_DIR=../$(INCLUDE_DIR) \ - COPTS="$(COPTS)" DEBUGOPTS="$(DEBUGOPTS)") || exit; done - $(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS) - -depend: - @for i in tools $(SUBDIRS); \ - do (cd $$i && echo $$i && \ - $(MAKE) INCLUDE_DIR=../$(INCLUDE_DIR) COPTS="$(COPTS)" depend) \ - || exit; done diff --git a/README b/README index 6b0e42a3545..c7ff6b43c82 100644 --- a/README +++ b/README @@ -4,23 +4,16 @@ LICENSE unless explicitly stated in the individual source file. INSTALLATION: -Linux: +You must have one of: - Uncompress and untar this archive into the directory of your -choice. This release requires a Linux version 0.99 pl13 kernel -or above. + Linux version 0.99.13 or above + NetBSD-current + FreeBSD-current or FreeBSD 1.1 -NetBSD: - - If you use BSD make rather than GNU make, you must apply the patches -in the file "bsdmake.patch". This release requires NetBSD-current. - -All: - -To build Wine, first do a "make depend" and then a "make". The +To build Wine, first do a "./Configure" and then a "make". The executable "wine" will be built. "wine" will load and run Windows' executables. You must have a file "wine.ini" in the current directory, -your homedirectory, or in the path specified by the environment +your home directory, or in the path specified by the environment variable WINEPATH. Multiple directories in WINEPATH should be seperated by semi-colons and NOT by colons! @@ -41,6 +34,31 @@ For example: to run Windows' solitaire: Have a nice game of solitaire, but be careful. Emulation isn't perfect. So, occassionally it will crash. +WHAT'S NEW with Wine-940301: (see ChangeLog for details) + - NEW Configure script to set compile time options! + - Support for filesystems with short (less than 14 chars) filenames. + - Clipboard functions! + - and more... + +WHAT'S NEW with Wine-940223: (see ChangeLog for details) + - FreeBSD support + - FloodFill() + - Desktop window support + - Menu fixes + - and more... + +WHAT'S NEW with Wine-940216: (see ChangeLog for details) + - Many many bug fixes + - Switched to using Imakefile's instead of Makefile's. + - Lot's of changes for libwine.a + +WHAT'S NEW with Wine-940209: (see ChangeLog for details) + - Many many bug fixes + - Minor directory structure reorganization + - New GetModule*() functions. + - WINSOCK DLL + - First stab at Wine as a library + WHAT'S NEW with Wine-940201: (see ChangeLog for details) - Support for huge data structures. - FreeBSD support. diff --git a/Wine.tmpl b/Wine.tmpl index 3bb9466ace7..7740d326afd 100644 --- a/Wine.tmpl +++ b/Wine.tmpl @@ -6,13 +6,22 @@ XCOMM Imake rules go here XCOMM First, dll description to files etc #ifndef MakeDllFromSpec +#ifndef ShortNames #define MakeDllFromSpec(name,objfile) @@\ objfile.o: Concat(dll_,name.o) Concat3(dll_,name,_tab.o) @@\ @@\ Concat(dll_,name.S) Concat3(dll_,name,_tab.c): name.spec $(TOP)/tools/build @@\ $(TOP)/tools/build name.spec @@\ -#endif +#else +#define MakeDllFromSpec(name,objfile) @@\ +objfile.o: Concat(dll_,name.o) Concat(dtb_,name.o) @@\ + @@\ +Concat(dll_,name.S) Concat(dtb_,name.c): name.spec $(TOP)/tools/build @@\ + $(TOP)/tools/build name.spec @@\ + +#endif /* SHORTNAMES */ +#endif /* MakeDllFromSpec */ /* * WineRelocatableTarget - generate rules to produce a relocatable object diff --git a/autoconf.h b/autoconf.h new file mode 100644 index 00000000000..223fbc15817 --- /dev/null +++ b/autoconf.h @@ -0,0 +1,2 @@ +/* autoconf.h generated automatically. Run Configure. */ +#error You must run Configure before you can build the makefiles. diff --git a/bsdmake.patch b/bsdmake.patch deleted file mode 100644 index 92dc3a5c879..00000000000 --- a/bsdmake.patch +++ /dev/null @@ -1,140 +0,0 @@ -*** Makefile.orig Tue Jan 18 12:36:47 1994 ---- Makefile Mon Jan 24 22:34:06 1994 -*************** -*** 8,14 **** - ###################################################################### - # These definitions are for the top level - TARGET=wine -! LIBS=-L/usr/X386/lib -lX11 -lm - OBJS=if1632/if1632.o controls/controls.o loader/loader.o \ - memory/memory.o misc/misc.o objects/objects.o windows/windows.o debugger/debugger.o - SUBDIRS=if1632 controls loader memory misc objects windows debugger ---- 8,14 ---- - ###################################################################### - # These definitions are for the top level - TARGET=wine -! LIBS=-L/usr/X386/lib -lX11 -lm -li386 -lgnumalloc -ll - OBJS=if1632/if1632.o controls/controls.o loader/loader.o \ - memory/memory.o misc/misc.o objects/objects.o windows/windows.o debugger/debugger.o - SUBDIRS=if1632 controls loader memory misc objects windows debugger -diff -ruN ../Backup//controls/Makefile ./controls/Makefile ---- ../Backup//controls/Makefile Sat Sep 11 22:13:44 1993 -+++ ./controls/Makefile Thu Sep 16 10:00:24 1993 -@@ -14,6 +14,7 @@ - depend: - $(CC) $(CFLAGS) -M *.c > .depend - --ifeq (.depend,$(wildcard .depend)) --include .depend --endif -+.if exists(.depend) -+.include ".depend" -+.endif -+ -diff -ruN ../Backup//if1632/Makefile ./if1632/Makefile ---- ../Backup//if1632/Makefile Tue Sep 14 08:56:17 1993 -+++ ./if1632/Makefile Thu Sep 16 10:00:24 1993 -@@ -45,9 +45,9 @@ - depend: - $(CC) $(CFLAGS) -M *.c > .depend - --ifeq (.depend,$(wildcard .depend)) --include .depend --endif -+.if exists(.depend) -+.include ".depend" -+.endif - - - -diff -ruN ../Backup//loader/Makefile ./loader/Makefile ---- ../Backup//loader/Makefile Sat Sep 11 21:42:05 1993 -+++ ./loader/Makefile Thu Sep 16 10:00:24 1993 -@@ -13,6 +13,6 @@ - depend: - $(CC) $(CFLAGS) -M *.c > .depend - --ifeq (.depend,$(wildcard .depend)) --include .depend --endif -+.if exists(.depend) -+.include ".depend" -+.endif -diff -ruN ../Backup//memory/Makefile ./memory/Makefile ---- ../Backup//memory/Makefile Sat Sep 11 21:42:05 1993 -+++ ./memory/Makefile Thu Sep 16 10:00:24 1993 -@@ -13,6 +13,6 @@ - depend: - $(CC) $(CFLAGS) -M *.c > .depend - --ifeq (.depend,$(wildcard .depend)) --include .depend --endif -+.if exists(.depend) -+.include ".depend" -+.endif -diff -ruN ../Backup//misc/Makefile ./misc/Makefile ---- ../Backup//misc/Makefile Tue Sep 14 09:17:00 1993 -+++ ./misc/Makefile Thu Sep 16 10:00:24 1993 -@@ -14,6 +14,6 @@ - depend: - $(CC) $(CFLAGS) -M *.c > .depend - --ifeq (.depend,$(wildcard .depend)) --include .depend --endif -+.if exists(.depend) -+.include ".depend" -+.endif -diff -ruN ../Backup//objects/Makefile ./objects/Makefile ---- ../Backup//objects/Makefile Tue Sep 14 13:59:04 1993 -+++ ./objects/Makefile Thu Sep 16 10:00:24 1993 -@@ -14,6 +14,6 @@ - depend: - $(CC) $(CFLAGS) -M *.c > .depend - --ifeq (.depend,$(wildcard .depend)) --include .depend --endif -+.if exists(.depend) -+.include ".depend" -+.endif -diff -ruN ../Backup//tools/Makefile ./tools/Makefile ---- ../Backup//tools/Makefile Tue Sep 14 09:46:40 1993 -+++ ./tools/Makefile Thu Sep 16 10:00:24 1993 -@@ -14,6 +14,10 @@ - # - # Dependency lists - # --ifeq (.depend,$(wildcard .depend)) --include .depend --endif -+.if exists(.depend) -+.include ".depend" -+.endif -+ -+#ifeq (.depend,$(wildcard .depend)) -+#include .depend -+#endif -diff -ruN ../Backup//windows/Makefile ./windows/Makefile ---- ../Backup//windows/Makefile Tue Sep 14 08:39:45 1993 -+++ ./windows/Makefile Thu Sep 16 10:00:24 1993 -@@ -14,6 +14,6 @@ - depend: - $(CC) $(CFLAGS) -M *.c > .depend - --ifeq (.depend,$(wildcard .depend)) --include .depend --endif -+.if exists(.depend) -+.include ".depend" -+.endif ---- debugger/Makefile.orig Thu Sep 30 07:29:39 1993 -+++ debugger/Makefile Thu Sep 30 07:27:00 1993 -@@ -37,3 +37,6 @@ - depend: dbg.tab.c dbg.tab.h lex.yy.c - $(CC) $(CFLAGS) -M *.c > .depend - -+.if exists(.depend) -+.include ".depend" -+.endif diff --git a/controls/Imakefile b/controls/Imakefile index 22fb4afae89..0f76706fd33 100644 --- a/controls/Imakefile +++ b/controls/Imakefile @@ -4,23 +4,15 @@ MODULE = controls SRCS = \ button.c \ - caption.c \ combo.c \ listbox.c \ menu.c \ scroll.c \ static.c \ + desktop.c \ widgets.c -OBJS = \ - button.o \ - caption.o \ - combo.o \ - listbox.o \ - menu.o \ - scroll.o \ - static.o \ - widgets.o +OBJS = $(SRCS:.c=.o) WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) DependTarget() diff --git a/controls/Makefile b/controls/Makefile deleted file mode 100644 index fb915e7b0ad..00000000000 --- a/controls/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR) - -OBJS = menu.o caption.o widgets.o button.o \ - scroll.o listbox.o combo.o static.o - -default: controls.o - -controls.o: $(OBJS) - $(LD) -r -o controls.o $(OBJS) - -clean: - rm -f *.o *~ *.s dll_* *.a *# - -depend: - $(CC) $(CFLAGS) -M *.c > .depend - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/controls/caption.c b/controls/caption.c deleted file mode 100644 index 68283a77dee..00000000000 --- a/controls/caption.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Interface code to CAPTION widget - * - * Copyright Martin Ayotte, 1994 - * - */ - -/* -#define DEBUG_CAPTION -*/ - -static char Copyright[] = "Copyright Martin Ayotte, 1994"; - -#include -#include -#include "windows.h" -#include "caption.h" -#include "heap.h" -#include "win.h" -#include -#include -#include - -HBITMAP hStdClose = (HBITMAP)NULL; -HBITMAP hStdCloseD = (HBITMAP)NULL; -HBITMAP hStdMinim = (HBITMAP)NULL; -HBITMAP hStdMinimD = (HBITMAP)NULL; -HBITMAP hStdMaxim = (HBITMAP)NULL; -HBITMAP hStdMaximD = (HBITMAP)NULL; -HMENU hStdSysMenu = (HMENU)NULL; - -LPHEADCAPTION CaptionBarGetWindowAndStorage(HWND hWnd, WND **wndPtr); -LPHEADCAPTION CaptionBarGetStorageHeader(HWND hWnd); -void SetMenuLogicalParent(HMENU hMenu, HWND hWnd); - - -/*********************************************************************** - * CaptionBarWndProc - */ -LONG CaptionBarWndProc( HWND hWnd, WORD message, WORD wParam, LONG lParam ) -{ - WORD wRet; - short x, y; - short width, height; - WND *wndPtr; - LPHEADCAPTION lphs; - PAINTSTRUCT ps; - HDC hDC; - HDC hMemDC; - BITMAP bm; - RECT rect; - char str[128]; - switch(message) - { - case WM_CREATE: - wndPtr = WIN_FindWndPtr(hWnd); - lphs = (LPHEADCAPTION)malloc(sizeof(HEADCAPTION)); - if (lphs == 0) { - printf("Bad Memory Alloc on CAPTIONBAR !\n"); - return 0; - } - memset(lphs, 0, sizeof(HEADCAPTION)); -#ifdef DEBUG_CAPTION - printf("CreateCaptionBarStruct %lX !\n", lphs); -#endif - *((LPHEADCAPTION *)&wndPtr->wExtra[1]) = lphs; - if (hStdClose == (HBITMAP)NULL) - hStdClose = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_CLOSE)); - lphs->hClose = hStdClose; - if (hStdMinim == (HBITMAP)NULL) - hStdMinim = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_REDUCE)); - lphs->hMinim = hStdMinim; - if (hStdMaxim == (HBITMAP)NULL) - hStdMaxim = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RESTORE)); - lphs->hMaxim = hStdMaxim; - if (hStdCloseD == (HBITMAP)NULL) - hStdCloseD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_CLOSE)); - if (hStdMinimD == (HBITMAP)NULL) - hStdMinimD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_REDUCED)); - if (hStdMaximD == (HBITMAP)NULL) - hStdMaximD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RESTORED)); - if (hStdSysMenu == (HBITMAP)NULL) - hStdSysMenu = LoadMenu((HINSTANCE)NULL, "SYSMENU"); - lphs->hSysMenu = hStdSysMenu; - printf("CaptionBar SYSMENU %04X !\n", lphs->hSysMenu); - if (lphs->hSysMenu == 0) lphs->hSysMenu = CreatePopupMenu(); - AppendMenu(lphs->hSysMenu, MF_STRING, 9999, "About &Wine ..."); - GetClientRect(hWnd, &rect); - CopyRect(&lphs->rectClose, &rect); - CopyRect(&lphs->rectMaxim, &rect); - lphs->rectClose.right = lphs->rectClose.left + - lphs->rectClose.bottom + lphs->rectClose.top; - lphs->rectMaxim.left = lphs->rectMaxim.right - - lphs->rectMaxim.bottom + lphs->rectMaxim.top; - CopyRect(&lphs->rectMinim, &lphs->rectMaxim); - if (lphs->hMaxim != 0) { - lphs->rectMinim.left = lphs->rectMaxim.bottom + lphs->rectMaxim.top; - lphs->rectMinim.right = lphs->rectMaxim.bottom + lphs->rectMaxim.top; - } - if (lphs->hClose == 0) lphs->rectClose.right = lphs->rectClose.left; - printf("CAPTION Close.right=%d Maxim.left=%d Minim.left=%d !\n", - lphs->rectClose.right, lphs->rectMaxim.left, lphs->rectMinim.left); - return 0; - case WM_DESTROY: - lphs = CaptionBarGetWindowAndStorage(hWnd, &wndPtr); - if (lphs == 0) return 0; -#ifdef DEBUG_CAPTION - printf("CaptionBar WM_DESTROY %lX !\n", lphs); -#endif - DestroyMenu(lphs->hSysMenu); - free(lphs); - *((LPHEADCAPTION *)&wndPtr->wExtra[1]) = 0; - return 0; - case WM_COMMAND: -#ifdef DEBUG_CAPTION - printf("CaptionBar WM_COMMAND %04X %08X !\n", wParam, lParam); -#endif - lphs = CaptionBarGetWindowAndStorage(hWnd, &wndPtr); - if (wParam == 9999) { - printf("CaptionBar Show 'About Wine ...' !\n"); - } - SendMessage(wndPtr->hwndParent, message, wParam, lParam); - break; - case WM_SIZE: - lphs = CaptionBarGetWindowAndStorage(hWnd, &wndPtr); - width = LOWORD(lParam); - height = HIWORD(lParam); - if (lphs->hClose != 0) - SetRect(&lphs->rectClose, 0, 0, height, height); - if (lphs->hMinim != 0) { - if (lphs->hMaxim != 0) - SetRect(&lphs->rectMinim, width - 2 * height, 0, - width - height, height); - else - SetRect(&lphs->rectMinim, width - height, 0, width, height); - } - if (lphs->hMaxim != 0) - SetRect(&lphs->rectMaxim, width - height, 0, width, height); - break; - case WM_LBUTTONDOWN: - lphs = CaptionBarGetWindowAndStorage(hWnd, &wndPtr); - SetCapture(hWnd); - x = LOWORD(lParam); - y = HIWORD(lParam); - hDC = GetDC(hWnd); - if (x > lphs->rectClose.left && x < lphs->rectClose.right) { - lphs->hClose = hStdCloseD; - InvalidateRect(hWnd, &lphs->rectClose, TRUE); - UpdateWindow(hWnd); - } - if (x > lphs->rectMinim.left && x < lphs->rectMinim.right) { - lphs->hMinim = hStdMinimD; - InvalidateRect(hWnd, &lphs->rectMinim, TRUE); - UpdateWindow(hWnd); - } - if (x > lphs->rectMaxim.left && x < lphs->rectMaxim.right && - lphs->hMaxim != 0) { - lphs->hMaxim = hStdMaximD; - InvalidateRect(hWnd, &lphs->rectMaxim, TRUE); - UpdateWindow(hWnd); - } - ReleaseDC(hWnd, hDC); - break; - case WM_LBUTTONUP: - lphs = CaptionBarGetWindowAndStorage(hWnd, &wndPtr); - ReleaseCapture(); -#ifdef DEBUG_CAPTION - printf("CaptionBar WM_LBUTTONUP %lX !\n", lParam); -#endif - x = LOWORD(lParam); - y = HIWORD(lParam); - if (x > lphs->rectClose.left && x < lphs->rectClose.right) { - lphs->hClose = hStdClose; - InvalidateRect(hWnd, &lphs->rectClose, TRUE); - UpdateWindow(hWnd); - TrackPopupMenu(lphs->hSysMenu, TPM_LEFTBUTTON, 0, -20, - 0, wndPtr->hwndParent, (LPRECT)NULL); - SetMenuLogicalParent(lphs->hSysMenu, hWnd); - printf("CAPTION Pop the SYSMENU !\n"); - break; - } - if (x > lphs->rectMinim.left && x < lphs->rectMinim.right) { - SendMessage(wndPtr->hwndParent, WM_SYSCOMMAND, SC_MINIMIZE, 0L); - lphs->hMinim = hStdMinim; - InvalidateRect(hWnd, &lphs->rectMinim, TRUE); - UpdateWindow(hWnd); - printf("CAPTION Minimize Window !\n"); - break; - } - if (x > lphs->rectMaxim.left && x < lphs->rectMaxim.right) { - lphs->hMaxim = hStdMaxim; - InvalidateRect(hWnd, &lphs->rectMaxim, TRUE); - UpdateWindow(hWnd); - SendMessage(wndPtr->hwndParent, WM_SYSCOMMAND, SC_MAXIMIZE, 0L); - printf("CAPTION Maximize Window !\n"); - break; - } - break; - - case WM_LBUTTONDBLCLK: - lphs = CaptionBarGetWindowAndStorage(hWnd, &wndPtr); -#ifdef DEBUG_CAPTION - printf("CaptionBar WM_LBUTTONDBLCLK %lX !\n", lParam); -#endif - x = LOWORD(lParam); - y = HIWORD(lParam); - if (x > lphs->rectClose.left && x < lphs->rectClose.right) { - SendMessage(wndPtr->hwndParent, WM_SYSCOMMAND, SC_CLOSE, 0L); - printf("CAPTION DoubleClick Close Window !\n"); - break; - } - break; - - case WM_KEYDOWN: - case WM_KEYUP: - case WM_CHAR: - lphs = CaptionBarGetWindowAndStorage(hWnd, &wndPtr); - return(SendMessage(wndPtr->hwndParent, message, wParam, lParam)); - - case WM_PAINT: - GetWindowRect(hWnd, &rect); -#ifdef DEBUG_CAPTION - printf("CaptionBar WM_PAINT left=%d top=%d right=%d bottom=%d !\n", - rect.left, rect.top, rect.right, rect.bottom); -#endif - lphs = CaptionBarGetWindowAndStorage(hWnd, &wndPtr); - hDC = BeginPaint(hWnd, &ps); - hMemDC = CreateCompatibleDC(hDC); - if (lphs->hClose != 0) { - GetObject(lphs->hClose, sizeof(BITMAP), (LPSTR)&bm); - SelectObject(hMemDC, lphs->hClose); - BitBlt(hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); - } - if (lphs->hMinim != 0) { - GetObject(lphs->hMinim, sizeof(BITMAP), (LPSTR)&bm); - SelectObject(hMemDC, lphs->hMinim); - BitBlt(hDC, lphs->rectMinim.left, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); - } - if (lphs->hMaxim != 0) { - GetObject(lphs->hMaxim, sizeof(BITMAP), (LPSTR)&bm); - SelectObject(hMemDC, lphs->hMaxim); - BitBlt(hDC, lphs->rectMaxim.left, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); - } - DeleteDC(hMemDC); - GetClientRect(hWnd, &rect); - FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH)); - rect.left = lphs->rectClose.right; - rect.right = lphs->rectMinim.left; -#ifdef DEBUG_CAPTION - printf("CaptionBar WM_PAINT left=%d top=%d right=%d bottom=%d !\n", - rect.left, rect.top, rect.right, rect.bottom); -#endif - FillRect(hDC, &rect, GetStockObject(GRAY_BRUSH)); - if (GetWindowTextLength(wndPtr->hwndParent) > 0) { - GetWindowText(wndPtr->hwndParent, str, sizeof(str)); - width = GetTextExtent(hDC, str, strlen(str)); - DrawText(hDC, str, -1, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); - } - EndPaint(hWnd, &ps); - break; - default: - return DefWindowProc( hWnd, message, wParam, lParam ); - } -return(0); -} - - - -LPHEADCAPTION CaptionBarGetWindowAndStorage(HWND hWnd, WND **wndPtr) -{ - WND *Ptr; - LPHEADCAPTION lphs; - *(wndPtr) = Ptr = WIN_FindWndPtr(hWnd); - if (Ptr == 0) { - printf("Bad Window handle on CaptionBar !\n"); - return 0; - } - lphs = *((LPHEADCAPTION *)&Ptr->wExtra[1]); - return lphs; -} - - -LPHEADCAPTION CaptionBarGetStorageHeader(HWND hWnd) -{ - WND *wndPtr; - LPHEADCAPTION lphs; - wndPtr = WIN_FindWndPtr(hWnd); - if (wndPtr == 0) { - printf("Bad Window handle on CaptionBar !\n"); - return 0; - } - lphs = *((LPHEADCAPTION *)&wndPtr->wExtra[1]); - return lphs; -} - - diff --git a/controls/combo.c b/controls/combo.c index 2bcde7f37c1..61b5e20ee60 100644 --- a/controls/combo.c +++ b/controls/combo.c @@ -11,8 +11,6 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; -#include -#include #include "windows.h" #include "combo.h" #include "heap.h" @@ -39,8 +37,7 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) int AltState; WND *wndPtr; LPHEADCOMBO lphc; - LPDRAWITEMSTRUCT lpdis; - HDC hMemDC; + HDC hDC, hMemDC; BITMAP bm; char str[128]; PAINTSTRUCT paintstruct; @@ -48,47 +45,48 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) switch(message) { case WM_CREATE: - ShowScrollBar(hwnd, SB_BOTH, FALSE); - GetClientRect(hwnd, &rect); - width = rect.right - rect.left; - height = rect.bottom - rect.top; -/* SetWindowPos(hwnd, 0, 0, 0, width, 16, - SWP_NOMOVE | SWP_NOZORDER); */ - CreateComboStruct(hwnd); wndPtr = WIN_FindWndPtr(hwnd); - lphc = ComboGetStorageHeader(hwnd); - if (lphc == NULL) return 0; + if (wndPtr == NULL) return 0; #ifdef DEBUG_COMBO printf("Combo WM_CREATE %lX !\n", lphc); #endif if (hComboBit == (HBITMAP)NULL) hComboBit = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_COMBO)); - lphc->hWndDrop = CreateWindow("BUTTON", "", - WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_OWNERDRAW, - width - 16, 0, 16, 16, hwnd, 1, wndPtr->hInstance, 0L); + GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm); + wndPtr->dwStyle &= 0xFFFFFFFFL ^ (WS_VSCROLL | WS_HSCROLL); + GetWindowRect(hwnd, &rect); + width = rect.right - rect.left; + height = rect.bottom - rect.top; + SetWindowPos(hwnd, 0, 0, 0, width + bm.bmHeight, bm.bmHeight, + SWP_NOMOVE | SWP_NOZORDER); + CreateComboStruct(hwnd); + lphc = ComboGetStorageHeader(hwnd); + if (lphc == NULL) return 0; if (wndPtr->dwStyle & CBS_SIMPLE) /* lphc->hWndEdit = CreateWindow("EDIT", "", */ lphc->hWndEdit = CreateWindow("STATIC", "", WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT, - 0, 0, width - 16, 16, hwnd, 1, wndPtr->hInstance, 0L); + 0, 0, width - bm.bmHeight, bm.bmHeight, + hwnd, 1, wndPtr->hInstance, 0L); else lphc->hWndEdit = CreateWindow("STATIC", "", WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT, - 0, 0, width - 16, 16, hwnd, 1, wndPtr->hInstance, 0L); + 0, 0, width - bm.bmHeight, bm.bmHeight, + hwnd, 1, wndPtr->hInstance, 0L); lphc->hWndLBox = CreateWindow("LISTBOX", "", WS_CHILD | WS_CLIPCHILDREN | WS_BORDER | WS_VSCROLL | LBS_NOTIFY, - wndPtr->rectClient.left, wndPtr->rectClient.top + 16, width, height, - wndPtr->hwndParent, 1, wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd)); + wndPtr->rectClient.left, wndPtr->rectClient.top + bm.bmHeight, + width, height, wndPtr->hwndParent, 1, + wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd)); ShowWindow(lphc->hWndLBox, SW_HIDE); #ifdef DEBUG_COMBO - printf("Combo Creation Drop=%X LBox=%X!\n", lphc->hWndDrop, lphc->hWndLBox); + printf("Combo Creation LBox=%X!\n", lphc->hWndLBox); #endif return 0; case WM_DESTROY: lphc = ComboGetStorageHeader(hwnd); if (lphc == 0) return 0; /* - DestroyWindow(lphc->hWndDrop); DestroyWindow(lphc->hWndEdit); */ DestroyWindow(lphc->hWndLBox); @@ -106,30 +104,6 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) wndPtr = WIN_FindWndPtr(hwnd); lphc = ComboGetStorageHeader(hwnd); if (lphc == NULL) return 0; - if (LOWORD(lParam) == lphc->hWndDrop) { - if (HIWORD(lParam) != BN_CLICKED) return 0; -#ifdef DEBUG_COMBO - printf("CB_SHOWDROPDOWN !\n"); -#endif - lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN; - if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) { - ShowWindow(lphc->hWndLBox, SW_SHOW); -/* - SetFocus(lphc->hWndLBox); -*/ - } - else { -/* - SetFocus(lphc->hWndEdit); -*/ - ShowWindow(lphc->hWndLBox, SW_HIDE); - y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); - if (y != LB_ERR) { - SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); - SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); - } - } - } if (LOWORD(lParam) == lphc->hWndLBox) { switch(HIWORD(lParam)) { @@ -153,13 +127,39 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) break; case WM_LBUTTONDOWN: printf("Combo WM_LBUTTONDOWN wParam=%x lParam=%lX !\n", wParam, lParam); + GetClientRect(hwnd, &rect); + rect.left = rect.right - (rect.bottom - rect.top); + hDC = GetDC(hwnd); + InflateRect(&rect, -1, -1); + DrawReliefRect(hDC, rect, 1, 1); + ReleaseDC(hwnd, hDC); wndPtr = WIN_FindWndPtr(hwnd); lphc = ComboGetStorageHeader(hwnd); lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN; if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) ShowWindow(lphc->hWndLBox, SW_SHOW); + else { +/* + SetFocus(lphc->hWndEdit); +*/ + ShowWindow(lphc->hWndLBox, SW_HIDE); + y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); + if (y != LB_ERR) { + SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); + SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); + } + } break; - case WM_KEYDOWN: + case WM_LBUTTONUP: + printf("Combo WM_LBUTTONUP wParam=%x lParam=%lX !\n", wParam, lParam); + GetClientRect(hwnd, &rect); + rect.left = rect.right - (rect.bottom - rect.top); + hDC = GetDC(hwnd); + InflateRect(&rect, -1, -1); + DrawReliefRect(hDC, rect, 1, 0); + ReleaseDC(hwnd, hDC); + break; + case WM_KEYDOWN: wndPtr = WIN_FindWndPtr(hwnd); lphc = ComboGetStorageHeader(hwnd); y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); @@ -206,32 +206,19 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) break; case WM_CTLCOLOR: return(SendMessage(GetParent(hwnd), WM_CTLCOLOR, wParam, lParam)); - case WM_DRAWITEM: -#ifdef DEBUG_SCROLL - printf("ComboBox WM_DRAWITEM w=%04X l=%08X\n", wParam, lParam); -#endif - lpdis = (LPDRAWITEMSTRUCT)lParam; - if (lpdis->CtlType == ODT_BUTTON && lpdis->itemAction == ODA_DRAWENTIRE) { - hMemDC = CreateCompatibleDC(lpdis->hDC); - GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm); - SelectObject(hMemDC, hComboBit); - BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); - DeleteDC(hMemDC); - } - if (lpdis->CtlType == ODT_BUTTON && lpdis->itemAction == ODA_SELECT) { - CopyRect(&rect, &lpdis->rcItem); - InflateRect(&rect, -1, -1); - DrawReliefRect(lpdis->hDC, rect, 1, 1); - } - break; case WM_PAINT: - BeginPaint( hwnd, &paintstruct ); - EndPaint( hwnd, &paintstruct ); + GetClientRect(hwnd, &rect); + hDC = BeginPaint(hwnd, &paintstruct); + hMemDC = CreateCompatibleDC(hDC); + GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm); + SelectObject(hMemDC, hComboBit); + BitBlt(hDC, rect.right - bm.bmWidth, 0, + bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + DeleteDC(hMemDC); + EndPaint(hwnd, &paintstruct); lphc = ComboGetStorageHeader(hwnd); InvalidateRect(lphc->hWndEdit, NULL, TRUE); UpdateWindow(lphc->hWndEdit); - InvalidateRect(lphc->hWndDrop, NULL, TRUE); - UpdateWindow(lphc->hWndDrop); if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) { InvalidateRect(lphc->hWndLBox, NULL, TRUE); UpdateWindow(lphc->hWndLBox); diff --git a/controls/desktop.c b/controls/desktop.c new file mode 100644 index 00000000000..14bf3c56659 --- /dev/null +++ b/controls/desktop.c @@ -0,0 +1,21 @@ +/* + * Desktop window class. + * + * Copyright 1994 Alexandre Julliard + */ + +static char Copyright[] = "Copyright Alexandre Julliard, 1994"; + +#include "windows.h" + +LONG DesktopWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam ) +{ + /* Most messages are ignored (we DON'T call DefWindowProc) */ + + switch(message) + { + } + + return 0; +} + diff --git a/controls/listbox.c b/controls/listbox.c index 642d47ef35e..76a3ecdf7f4 100644 --- a/controls/listbox.c +++ b/controls/listbox.c @@ -12,8 +12,6 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; #include -#include -#include #include #include #include @@ -87,14 +85,11 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) SetScrollRange(hwnd, SB_HORZ, 1, 1, TRUE); ShowScrollBar(hwnd, SB_HORZ, FALSE); } - if (wndPtr->hCursor == (HCURSOR)NULL) - wndPtr->hCursor = LoadCursor((HINSTANCE)NULL, IDC_ARROW); return 0; case WM_DESTROY: lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); if (lphl == 0) return 0; ListBoxResetContent(hwnd); - DestroyCursor(wndPtr->hCursor); free(lphl); *((LPHEADLIST *)&wndPtr->wExtra[1]) = 0; #ifdef DEBUG_LISTBOX @@ -496,6 +491,19 @@ void StdDrawListBox(HWND hwnd) lphl->ItemsPerColumn = ipc = 0; for(i = 1; i <= lphl->ItemsCount; i++) { if (i >= lphl->FirstVisible) { + if (lpls == NULL) break; + if ((h + lpls->dis.rcItem.bottom - lpls->dis.rcItem.top) > rect.bottom) { + if ((wndPtr->dwStyle & LBS_MULTICOLUMN) == LBS_MULTICOLUMN) { + lphl->ItemsPerColumn = max(lphl->ItemsPerColumn, ipc); + ipc = 0; + h = 0; + rect.left += lphl->ColumnsWidth; + rect.right += lphl->ColumnsWidth; + if (rect.left > maxwidth) break; + } + else + break; + } h2 = lpls->dis.rcItem.bottom - lpls->dis.rcItem.top; lpls->dis.rcItem.top = h; lpls->dis.rcItem.bottom = h + h2; @@ -512,18 +520,6 @@ void StdDrawListBox(HWND hwnd) h += h2; lphl->ItemsVisible++; ipc++; - if (h > rect.bottom) { - if ((wndPtr->dwStyle & LBS_MULTICOLUMN) == LBS_MULTICOLUMN) { - lphl->ItemsPerColumn = max(lphl->ItemsPerColumn, ipc); - ipc = 0; - h = 0; - rect.left += lphl->ColumnsWidth; - rect.right += lphl->ColumnsWidth; - if (rect.left > maxwidth) break; - } - else - break; - } } if (lpls->lpNext == NULL) goto EndOfPaint; lpls = (LPLISTSTRUCT)lpls->lpNext; @@ -624,7 +620,7 @@ EndOfPaint: int ListBoxFindMouse(HWND hwnd, int X, int Y) { - WND *wndPtr; + WND *wndPtr; LPHEADLIST lphl; LPLISTSTRUCT lpls; RECT rect; diff --git a/controls/menu.c b/controls/menu.c index add8f1820e2..53d9f0ddf98 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -1,22 +1,19 @@ +/* + * Menus functions + */ static char RCSId[] = "$Id$"; -static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; -static char Copyright2[] = "Copyright Martin Ayotte, 1993"; +static char Copyright[] = "Copyright Martin Ayotte, 1993"; /* #define DEBUG_MENU #define DEBUG_SYSMENU */ -#define USE_POPUPMENU -#include -#include #include "windows.h" #include "sysmetrics.h" #include "menu.h" #include "heap.h" #include "win.h" -#include "bitmaps/check_bitmap" -#include "bitmaps/nocheck_bitmap" #define SC_ABOUTWINE SC_SCREENSAVE+1 #define SC_SYSMENU SC_SCREENSAVE+2 @@ -27,22 +24,17 @@ HMENU hSysMenu = 0; HBITMAP hStdCheck = 0; HBITMAP hStdMnArrow = 0; -static LPMENUBAR firstMenu = NULL; -static MENUITEM *parentItem; -static MENUITEM *siblingItem; -static int lastLevel; -static int menuId = 0; -static Pixmap checkBitmap = XtUnspecifiedPixmap; -static Pixmap nocheckBitmap = XtUnspecifiedPixmap; - LPPOPUPMENU PopupMenuGetStorageHeader(HWND hwnd); LPPOPUPMENU PopupMenuGetWindowAndStorage(HWND hwnd, WND **wndPtr); -void StdDrawMenuBar(HWND hwnd); +void StdDrawMenuBar(HDC hDC, LPRECT lprect, LPPOPUPMENU lppop); +void MenuButtonDown(HWND hWnd, LPPOPUPMENU lppop, int x, int y); +void MenuButtonUp(HWND hWnd, LPPOPUPMENU lppop, int x, int y); +void MenuMouseMove(HWND hWnd, LPPOPUPMENU lppop, WORD wParam, int x, int y); void StdDrawPopupMenu(HWND hwnd); -LPMENUITEM MenuFindItem(HWND hwnd, int x, int y, WORD *lpRet); -LPMENUITEM MenuFindItemBySelKey(HWND hwnd, WORD key, WORD *lpRet); +LPMENUITEM MenuFindItem(LPPOPUPMENU lppop, int x, int y, WORD *lpRet); +LPMENUITEM MenuFindItemBySelKey(LPPOPUPMENU lppop, WORD key, WORD *lpRet); void PopupMenuCalcSize(HWND hwnd); -void MenuBarCalcSize(HWND hwnd); +void MenuBarCalcSize(HDC hDC, LPRECT lprect, LPPOPUPMENU lppop); LPMENUITEM GetMenuItemPtr(LPPOPUPMENU menu, WORD nPos); WORD GetSelectionKey(LPSTR str); LPSTR GetShortCutString(LPSTR str); @@ -68,6 +60,7 @@ LONG PopupMenuWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) HMENU hSubMenu; RECT rect; HDC hDC; + PAINTSTRUCT ps; switch(message) { case WM_CREATE: @@ -82,20 +75,6 @@ LONG PopupMenuWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) #ifdef DEBUG_MENU printf("PopupMenu WM_CREATE lppop=%08X !\n", lppop); #endif -/* - if (lppop->BarFlags == 0) { - PopupMenuCalcSize(hwnd); - printf("PopupMenu WM_CREATE Width=%d Height=%d !\n", - lppop->Width, lppop->Height); - SetWindowPos(hwnd, 0, 0, 0, lppop->Width + 2, lppop->Height, - SWP_NOZORDER | SWP_NOMOVE); - } - else { - MenuBarCalcSize(hwnd); - SetWindowPos(hwnd, 0, 0, -16, lppop->Width, lppop->Height, - SWP_NOZORDER); - } -*/ if (hStdCheck == (HBITMAP)NULL) hStdCheck = LoadBitmap((HANDLE)NULL, (LPSTR)OBM_CHECK); if (hStdMnArrow == (HBITMAP)NULL) @@ -129,15 +108,18 @@ LONG PopupMenuWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) SendMessage(lppop->ownerWnd, WM_SYSCOMMAND, wParam, lParam); } } - if (lppop->BarFlags == 0) ShowWindow(hwnd, SW_HIDE); + if (lppop->BarFlags == 0) ShowWindow(hwnd, SW_HIDE); break; case WM_SHOWWINDOW: lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr); - if (wParam == 0) { + if (wParam == 0 && lParam == 0L) { HideAllSubPopupMenu(lppop); #ifdef DEBUG_MENU - printf("PopupMenu WM_SHOWWINDOW -> HIDE!\n"); + printf("PopupMenu WM_SHOWWINDOW -> HIDE!\n"); #endif +/* + UpdateWindow(lppop->ownerWnd); +*/ break; } lppop->FocusedItem = (WORD)-1; @@ -150,167 +132,20 @@ LONG PopupMenuWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) SetWindowPos(hwnd, 0, 0, 0, lppop->Width + 2, lppop->Height, SWP_NOZORDER | SWP_NOMOVE); } - else { - MenuBarCalcSize(hwnd); -#ifdef DEBUG_MENU - printf("MenuBarMenu WM_SHOWWINDOW Width=%d Height=%d !\n", - lppop->Width, lppop->Height); -#endif - SetWindowPos(hwnd, 0, 0, -16, lppop->Width, lppop->Height, - SWP_NOZORDER); - } break; case WM_LBUTTONDOWN: lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr); SetCapture(hwnd); - lpitem = MenuFindItem(hwnd, LOWORD(lParam), HIWORD(lParam), &wRet); -#ifdef DEBUG_MENU - printf("PopupMenu WM_LBUTTONDOWN wRet=%d lpitem=%08X !\n", wRet, lpitem); -#endif - if (lpitem != NULL) { - if (lppop->FocusedItem != (WORD)-1) { - HideAllSubPopupMenu(lppop); - lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem); - if (((lpitem2->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && - ((lpitem2->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) { - hDC = GetDC(hwnd); - InvertRect(hDC, &lpitem2->rect); - ReleaseDC(hwnd, hDC); - } - } - lppop->FocusedItem = wRet; - if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && - ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) { - hDC = GetDC(hwnd); - InvertRect(hDC, &lpitem->rect); - ReleaseDC(hwnd, hDC); - } - if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) { - hSubMenu = (HMENU)lpitem->item_id; - lppop2 = (LPPOPUPMENU) GlobalLock(hSubMenu); - if (lppop2 == NULL) break; - lppop2->hWndParent = hwnd; - GetClientRect(hwnd, &rect); - if (lppop->BarFlags != 0) { - y = rect.bottom - rect.top; - GetWindowRect(hwnd, &rect); - y += rect.top; - TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, - rect.left + lpitem->rect.left, - y, 0, lppop->ownerWnd, (LPRECT)NULL); - } - else { - x = rect.right; - GetWindowRect(hwnd, &rect); - x += rect.left; - TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, - x, rect.top + lpitem->rect.top, - 0, lppop->ownerWnd, (LPRECT)NULL); - } - break; - } - } + MenuButtonDown(hwnd, lppop, LOWORD(lParam), HIWORD(lParam)); break; case WM_LBUTTONUP: lppop = PopupMenuGetStorageHeader(hwnd); ReleaseCapture(); - lpitem = MenuFindItem(hwnd, LOWORD(lParam), HIWORD(lParam), &wRet); -#ifdef DEBUG_MENU - printf("PopupMenu WM_LBUTTONUP wRet=%d lpitem=%08X !\n", wRet, lpitem); -#endif - if (lpitem != NULL) { - if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) { - break; - } - if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && - ((lpitem->item_flags & MF_POPUP) != MF_POPUP)) { - ShowWindow(lppop->hWnd, SW_HIDE); - if (lppop->hWndParent != (HWND)NULL) { - SendMessage(lppop->hWndParent, WM_COMMAND, - lpitem->item_id, 0L); -#ifdef DEBUG_MENU - printf("PopupMenu // WM_COMMAND to ParentMenu wParam=%d !\n", - lpitem->item_id); -#endif - } - else { - if (lppop->SysFlag == 0) { -#ifdef DEBUG_MENU - printf("PopupMenu // WM_COMMAND wParam=%d !\n", - lpitem->item_id); -#endif - SendMessage(lppop->ownerWnd, WM_COMMAND, - lpitem->item_id, 0L); - } - else { - if (lpitem->item_id == SC_ABOUTWINE) { - printf("SysMenu // Show 'About Wine ...' !\n"); -/* DialogBox(hSysRes, MAKEINTRESOURCE(SC_ABOUTWINEDLG), */ - DialogBox(hSysRes, MAKEINTRESOURCE(2), - GetParent(hwnd), (FARPROC)AboutWine_Proc); - } - else { - SendMessage(lppop->ownerWnd, WM_SYSCOMMAND, - lpitem->item_id, 0L); -#ifdef DEBUG_SYSMENU - printf("PopupMenu // WM_SYSCOMMAND wParam=%04X !\n", - lpitem->item_id); -#endif - } - } - } -#ifdef DEBUG_MENU - printf("PopupMenu // SendMessage WM_COMMAND wParam=%d !\n", - lpitem->item_id); -#endif - break; - } - } - if (lppop->FocusedItem != (WORD)-1) { - HideAllSubPopupMenu(lppop); - lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem); - if (((lpitem2->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && - ((lpitem2->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) { - hDC = GetDC(hwnd); - InvertRect(hDC, &lpitem2->rect); - ReleaseDC(hwnd, hDC); - } - } + MenuButtonUp(hwnd, lppop, LOWORD(lParam), HIWORD(lParam)); break; case WM_MOUSEMOVE: - if ((wParam & MK_LBUTTON) != 0) { - lppop = PopupMenuGetStorageHeader(hwnd); - lpitem = MenuFindItem(hwnd, LOWORD(lParam), HIWORD(lParam), &wRet); - if ((lpitem != NULL) && (lppop->FocusedItem != wRet)) { - lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem); - hDC = GetDC(hwnd); - if (((lpitem2->item_flags & MF_POPUP) == MF_POPUP) || - ((lpitem2->item_flags & MF_STRING) == MF_STRING)) { - InvertRect(hDC, &lpitem2->rect); - } - if ((lpitem2->item_flags & MF_POPUP) == MF_POPUP) { - HideAllSubPopupMenu(lppop); - } - lppop->FocusedItem = wRet; - if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) || - ((lpitem->item_flags & MF_STRING) == MF_STRING)) { - InvertRect(hDC, &lpitem->rect); - } - if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) { - hSubMenu = (HMENU)lpitem->item_id; - lppop2 = (LPPOPUPMENU) GlobalLock(hSubMenu); - if (lppop2 == NULL) break; - if (lppop->BarFlags != 0) { - lppop2->hWndParent = hwnd; - GetWindowRect(hwnd, &rect); - TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, - lpitem->rect.left, rect.top, - 0, lppop->ownerWnd, (LPRECT)NULL); - } - } - ReleaseDC(hwnd, hDC); - } - } + lppop = PopupMenuGetStorageHeader(hwnd); + MenuMouseMove(hwnd, lppop, wParam, LOWORD(lParam), HIWORD(lParam)); break; case WM_KEYDOWN: @@ -441,6 +276,7 @@ ProceedSPACE: x, lpitem->rect.top, 0, lppop->ownerWnd, (LPRECT)NULL); } + GlobalUnlock(hSubMenu); break; } if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && @@ -482,7 +318,7 @@ ProceedSPACE: } } if (wParam >= 'a' && wParam <= 'z') wParam -= 'a' - 'A'; - lpitem = MenuFindItemBySelKey(hwnd, wParam, &wRet); + lpitem = MenuFindItemBySelKey(lppop, wParam, &wRet); if (lpitem != NULL) { printf("Found wRet=%d !\n", wRet); if (lppop->FocusedItem != (WORD)-1) { @@ -502,13 +338,7 @@ ProceedSPACE: break; case WM_PAINT: lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr); - if (lppop->BarFlags != 0) { - MenuBarCalcSize(hwnd); - printf("PopupMenu WM_PAINT Width=%d Height=%d !\n", - lppop->Width, lppop->Height); - StdDrawMenuBar(hwnd); - } - else{ + if (lppop->BarFlags == 0) { PopupMenuCalcSize(hwnd); StdDrawPopupMenu(hwnd); } @@ -520,6 +350,192 @@ return(0); } +void MenuButtonDown(HWND hWnd, LPPOPUPMENU lppop, int x, int y) +{ + HDC hDC; + LPMENUITEM lpitem, lpitem2; + RECT rect; + HMENU hSubMenu; + WORD wRet; + LPPOPUPMENU lppop2; + lpitem = MenuFindItem(lppop, x, y, &wRet); +#ifdef DEBUG_MENU + printf("MenuButtonDown // x=%d y=%d // wRet=%d lpitem=%08X !\n", + x, y, wRet, lpitem); +#endif + if (lpitem != NULL) { + if (lppop->FocusedItem != (WORD)-1) { + HideAllSubPopupMenu(lppop); + lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem); + if (((lpitem2->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && + ((lpitem2->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) { + hDC = GetWindowDC(hWnd); + InvertRect(hDC, &lpitem2->rect); + ReleaseDC(hWnd, hDC); + } + } + lppop->FocusedItem = wRet; + if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && + ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) { + hDC = GetWindowDC(hWnd); + InvertRect(hDC, &lpitem->rect); + ReleaseDC(hWnd, hDC); + } + if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) { + hSubMenu = (HMENU)lpitem->item_id; + lppop2 = (LPPOPUPMENU) GlobalLock(hSubMenu); + if (lppop2 == NULL) return; + lppop2->hWndParent = hWnd; + if (lppop->BarFlags != 0) { + GetWindowRect(hWnd, &rect); +/* y = rect.top + lppop->Height; */ + y = rect.top + lppop->rect.bottom; + TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, + rect.left + lpitem->rect.left, + y, 0, lppop->ownerWnd, (LPRECT)NULL); + } + else { + x = lppop->rect.right; + GetWindowRect(hWnd, &rect); + x += rect.left; + TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, + x, rect.top + lpitem->rect.top, + 0, lppop->ownerWnd, (LPRECT)NULL); + } + GlobalUnlock(hSubMenu); + } + } +} + + + +void MenuButtonUp(HWND hWnd, LPPOPUPMENU lppop, int x, int y) +{ + HDC hDC; + LPMENUITEM lpitem, lpitem2; + RECT rect; + HMENU hSubMenu; + WORD wRet; + LPPOPUPMENU lppop2; + lpitem = MenuFindItem(lppop, x, y, &wRet); +#ifdef DEBUG_MENU + printf("MenuButtonUp // x=%d y=%d // wRet=%d lpitem=%08X !\n", + x, y, wRet, lpitem); +#endif + if (lpitem != NULL) { + if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) { + return; + } + if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && + ((lpitem->item_flags & MF_POPUP) != MF_POPUP)) { + ShowWindow(lppop->hWnd, SW_HIDE); + if (lppop->hWndParent != (HWND)NULL) { + SendMessage(lppop->hWndParent, WM_COMMAND, + lpitem->item_id, 0L); +#ifdef DEBUG_MENU + printf("MenuButtonUp // WM_COMMAND to ParentMenu wParam=%d !\n", + lpitem->item_id); +#endif + } + else { + if (lppop->SysFlag == 0) { +#ifdef DEBUG_MENU + printf("PopupMenu // WM_COMMAND wParam=%d !\n", + lpitem->item_id); +#endif + SendMessage(lppop->ownerWnd, WM_COMMAND, + lpitem->item_id, 0L); + } + else { + if (lpitem->item_id == SC_ABOUTWINE) { + printf("SysMenu // Show 'About Wine ...' !\n"); +/* DialogBox(hSysRes, MAKEINTRESOURCE(SC_ABOUTWINEDLG), */ + DialogBox(hSysRes, MAKEINTRESOURCE(2), + GetParent(hWnd), (FARPROC)AboutWine_Proc); + } + else { + SendMessage(lppop->ownerWnd, WM_SYSCOMMAND, + lpitem->item_id, 0L); +#ifdef DEBUG_SYSMENU + printf("MenuButtonUp // WM_SYSCOMMAND wParam=%04X !\n", + lpitem->item_id); +#endif + } + } + } +#ifdef DEBUG_MENU + printf("MenuButtonUp // SendMessage WM_COMMAND wParam=%d !\n", + lpitem->item_id); +#endif + return; + } + } + if (lppop->FocusedItem != (WORD)-1) { + HideAllSubPopupMenu(lppop); + lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem); + if (((lpitem2->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && + ((lpitem2->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) { + hDC = GetWindowDC(hWnd); + InvertRect(hDC, &lpitem2->rect); + ReleaseDC(hWnd, hDC); + } + } +} + + + +void MenuMouseMove(HWND hWnd, LPPOPUPMENU lppop, WORD wParam, int x, int y) +{ + HDC hDC; + LPMENUITEM lpitem, lpitem2; + RECT rect; + HMENU hSubMenu; + WORD wRet; + LPPOPUPMENU lppop2; + if ((wParam & MK_LBUTTON) != 0) { + lpitem = MenuFindItem(lppop, x, y, &wRet); +#ifdef DEBUG_MENU + printf("MenuMouseMove // x=%d y=%d // wRet=%d lpitem=%08X !\n", + x, y, wRet, lpitem); +#endif + if ((lpitem != NULL) && (lppop->FocusedItem != wRet)) { + lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem); + hDC = GetWindowDC(hWnd); + if (((lpitem2->item_flags & MF_POPUP) == MF_POPUP) || + ((lpitem2->item_flags & MF_STRING) == MF_STRING)) { + InvertRect(hDC, &lpitem2->rect); + } + if ((lpitem2->item_flags & MF_POPUP) == MF_POPUP) { + HideAllSubPopupMenu(lppop); + } + lppop->FocusedItem = wRet; + if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) || + ((lpitem->item_flags & MF_STRING) == MF_STRING)) { + InvertRect(hDC, &lpitem->rect); + } + if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) { + hSubMenu = (HMENU)lpitem->item_id; + lppop2 = (LPPOPUPMENU) GlobalLock(hSubMenu); + if (lppop2 == NULL) { + ReleaseDC(hWnd, hDC); + return; + } + if (lppop->BarFlags != 0) { + lppop2->hWndParent = hWnd; + GetWindowRect(hWnd, &rect); + rect.top += lppop->rect.bottom; + TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, + rect.left + lpitem->rect.left, rect.top, + 0, lppop->ownerWnd, (LPRECT)NULL); + } + GlobalUnlock(hSubMenu); + } + ReleaseDC(hWnd, hDC); + } + } +} + + LPPOPUPMENU PopupMenuGetWindowAndStorage(HWND hwnd, WND **wndPtr) { @@ -554,6 +570,7 @@ void SetMenuLogicalParent(HMENU hMenu, HWND hWnd) LPPOPUPMENU lppop; lppop = (LPPOPUPMENU)GlobalLock(hMenu); lppop->hWndParent = hWnd; + GlobalUnlock(hMenu); } @@ -589,16 +606,40 @@ void StdDrawPopupMenu(HWND hwnd) lpitem = lppop->firstItem; if (lpitem == NULL) goto EndOfPaint; for(i = 0; i < lppop->nItems; i++) { + CopyRect(&rect2, &lpitem->rect); if ((lpitem->item_flags & MF_SEPARATOR) == MF_SEPARATOR) { - CopyRect(&rect2, &lpitem->rect); hOldPen = SelectObject(hDC, GetStockObject(BLACK_PEN)); MoveTo(hDC, rect2.left, rect2.top + 1); LineTo(hDC, rect2.right, rect2.top + 1); SelectObject(hDC, hOldPen); } + if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) { + hMemDC = CreateCompatibleDC(hDC); + if (lpitem->hCheckBit == 0) { + SelectObject(hMemDC, hStdCheck); + GetObject(hStdCheck, sizeof(BITMAP), (LPSTR)&bm); + } + else { + SelectObject(hMemDC, lpitem->hCheckBit); + GetObject(lpitem->hCheckBit, sizeof(BITMAP), (LPSTR)&bm); + } + BitBlt(hDC, rect2.left, rect2.top + 1, + bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + DeleteDC(hMemDC); + } + else { + if (lpitem->hUnCheckBit != 0) { + hMemDC = CreateCompatibleDC(hDC); + SelectObject(hMemDC, lpitem->hUnCheckBit); + GetObject(lpitem->hUnCheckBit, sizeof(BITMAP), (LPSTR)&bm); + BitBlt(hDC, rect2.left, rect2.top + 1, + bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + DeleteDC(hMemDC); + } + } if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) { hBitMap = (HBITMAP)LOWORD((LONG)lpitem->item_text); - CopyRect(&rect2, &lpitem->rect); + rect2.left += lppop->CheckWidth; hMemDC = CreateCompatibleDC(hDC); SelectObject(hMemDC, hBitMap); GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm); @@ -616,6 +657,7 @@ void StdDrawPopupMenu(HWND hwnd) OldTextColor = SetTextColor(hDC, 0x00000000L); CopyRect(&rect3, &lpitem->rect); InflateRect(&rect3, 0, -2); + rect3.left += lppop->CheckWidth; if ((x = GetShortCutPos(lpitem->item_text)) != (WORD)-1) { DrawText(hDC, lpitem->item_text, x, &rect3, DT_LEFT | DT_VCENTER | DT_SINGLELINE); @@ -629,31 +671,13 @@ void StdDrawPopupMenu(HWND hwnd) SelectObject(hDC, hOldFont); CopyRect(&rect2, &lpitem->rect); } - if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) { - CopyRect(&rect3, &rect2); - rect3.left = rect3.right - rect3.bottom + rect3.top; - hMemDC = CreateCompatibleDC(hDC); - if (lpitem->hCheckBit == 0) - SelectObject(hMemDC, hStdCheck); - else - SelectObject(hMemDC, lpitem->hCheckBit); - GetObject(hStdCheck, sizeof(BITMAP), (LPSTR)&bm); - BitBlt(hDC, rect3.left, rect3.top, - bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); - DeleteDC(hMemDC); - printf("StdDrawPopupMenu // MF_CHECKED hStdCheck=%04X !\n", hStdCheck); - } - else { - if (lpitem->hUnCheckBit != 0) - SelectObject(hMemDC, lpitem->hUnCheckBit); - } if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) { - CopyRect(&rect3, &rect2); - rect3.left = rect3.right - rect3.bottom + rect3.top; + CopyRect(&rect3, &lpitem->rect); + rect3.left = rect3.right - lppop->PopWidth; hMemDC = CreateCompatibleDC(hDC); SelectObject(hMemDC, hStdMnArrow); GetObject(hStdMnArrow, sizeof(BITMAP), (LPSTR)&bm); - BitBlt(hDC, rect3.left, rect3.top, + BitBlt(hDC, rect3.left, rect3.top + 1, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); DeleteDC(hMemDC); } @@ -666,40 +690,59 @@ EndOfPaint: -void StdDrawMenuBar(HWND hwnd) +void StdDrawMenuBar(HDC hDC, LPRECT lprect, LPPOPUPMENU lppop) { - WND *wndPtr; - LPPOPUPMENU lppop; LPMENUITEM lpitem; - PAINTSTRUCT ps; HBRUSH hBrush; HPEN hOldPen; - HWND hWndParent; - HDC hDC, hMemDC; + HDC hMemDC; RECT rect, rect2, rect3; HFONT hOldFont; + DWORD OldTextColor; HBITMAP hBitMap; BITMAP bm; UINT i, textwidth; - hDC = BeginPaint( hwnd, &ps ); - if (!IsWindowVisible(hwnd)) { - EndPaint( hwnd, &ps ); - return; - } + if (lppop == NULL || lprect == NULL) return; +#ifdef DEBUG_MENU + printf("StdDrawMenuBar(%04X, %08X, %08X); !\n", hDC, lprect, lppop); +#endif + MenuBarCalcSize(hDC, lprect, lppop); hOldFont = SelectObject(hDC, GetStockObject(SYSTEM_FONT)); - lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr); - if (lppop == NULL) goto EndOfPaint; hBrush = GetStockObject(WHITE_BRUSH); - GetClientRect(hwnd, &rect); + CopyRect(&rect, lprect); FillRect(hDC, &rect, hBrush); FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH)); if (lppop->nItems == 0) goto EndOfPaint; lpitem = lppop->firstItem; if (lpitem == NULL) goto EndOfPaint; for(i = 0; i < lppop->nItems; i++) { + CopyRect(&rect2, &lpitem->rect); + if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) { + hMemDC = CreateCompatibleDC(hDC); + if (lpitem->hCheckBit == 0) { + SelectObject(hMemDC, hStdCheck); + GetObject(hStdCheck, sizeof(BITMAP), (LPSTR)&bm); + } + else { + SelectObject(hMemDC, lpitem->hCheckBit); + GetObject(lpitem->hCheckBit, sizeof(BITMAP), (LPSTR)&bm); + } + BitBlt(hDC, rect2.left, rect2.top + 1, + bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + DeleteDC(hMemDC); + } + else { + if (lpitem->hUnCheckBit != 0) { + hMemDC = CreateCompatibleDC(hDC); + SelectObject(hMemDC, lpitem->hUnCheckBit); + GetObject(lpitem->hUnCheckBit, sizeof(BITMAP), (LPSTR)&bm); + BitBlt(hDC, rect2.left, rect2.top + 1, + bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + DeleteDC(hMemDC); + } + } if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) { hBitMap = (HBITMAP)LOWORD((LONG)lpitem->item_text); - CopyRect(&rect2, &lpitem->rect); hMemDC = CreateCompatibleDC(hDC); SelectObject(hMemDC, hBitMap); GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm); @@ -710,37 +753,30 @@ void StdDrawMenuBar(HWND hwnd) if (((lpitem->item_flags & MF_BITMAP) != MF_BITMAP) && ((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) && ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) { - CopyRect(&rect2, &lpitem->rect); + hOldFont = SelectObject(hDC, GetStockObject(SYSTEM_FONT)); + if ((lpitem->item_flags & MF_DISABLED) == MF_DISABLED) + OldTextColor = SetTextColor(hDC, 0x00C0C0C0L); + else + OldTextColor = SetTextColor(hDC, 0x00000000L); DrawText(hDC, lpitem->item_text, -1, &rect2, DT_LEFT | DT_VCENTER | DT_SINGLELINE); - } - if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) { - CopyRect(&rect3, &rect2); - rect3.left = rect3.right - rect3.bottom + rect3.top; - hMemDC = CreateCompatibleDC(hDC); - SelectObject(hMemDC, hStdCheck); - GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm); - BitBlt(hDC, rect3.left, rect3.top, - bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); - DeleteDC(hMemDC); + SetTextColor(hDC, OldTextColor); + SelectObject(hDC, hOldFont); } if (lpitem->next == NULL) goto EndOfPaint; lpitem = (LPMENUITEM)lpitem->next; } EndOfPaint: SelectObject(hDC, hOldFont); - EndPaint( hwnd, &ps ); -} +} -LPMENUITEM MenuFindItem(HWND hwnd, int x, int y, WORD *lpRet) +LPMENUITEM MenuFindItem(LPPOPUPMENU lppop, int x, int y, WORD *lpRet) { - WND *wndPtr; - LPPOPUPMENU lppop; LPMENUITEM lpitem; UINT i; - lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr); + if (lpRet != NULL) *lpRet = 0; if (lppop == NULL) return NULL; if (lppop->nItems == 0) return NULL; lpitem = lppop->firstItem; @@ -762,13 +798,10 @@ LPMENUITEM MenuFindItem(HWND hwnd, int x, int y, WORD *lpRet) } -LPMENUITEM MenuFindItemBySelKey(HWND hwnd, WORD key, WORD *lpRet) +LPMENUITEM MenuFindItemBySelKey(LPPOPUPMENU lppop, WORD key, WORD *lpRet) { - WND *wndPtr; - LPPOPUPMENU lppop; LPMENUITEM lpitem; UINT i; - lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr); if (lppop == NULL) return NULL; if (lppop->nItems == 0) return NULL; lpitem = lppop->firstItem; @@ -808,6 +841,7 @@ void PopupMenuCalcSize(HWND hwnd) if (lppop->nItems == 0) return; hDC = GetDC(hwnd); lppop->Width = 20; + lppop->CheckWidth = lppop->PopWidth = 0; hOldFont = SelectObject(hDC, GetStockObject(SYSTEM_FONT)); CalcAGAIN: OldWidth = lppop->Width; @@ -819,6 +853,23 @@ CalcAGAIN: printf("PopupMenuCalcSize item #%d !\n", i); #endif rect.right = rect.left + lppop->Width; + if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) { + if (lpitem->hCheckBit != 0) + GetObject(lpitem->hCheckBit, sizeof(BITMAP), (LPSTR)&bm); + else + GetObject(hStdCheck, sizeof(BITMAP), (LPSTR)&bm); + lppop->CheckWidth = max(lppop->CheckWidth, bm.bmWidth); + } + else { + if (lpitem->hUnCheckBit != 0) { + GetObject(lpitem->hUnCheckBit, sizeof(BITMAP), (LPSTR)&bm); + lppop->CheckWidth = max(lppop->CheckWidth, bm.bmWidth); + } + } + if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) { + GetObject(hStdMnArrow, sizeof(BITMAP), (LPSTR)&bm); + lppop->PopWidth = max(lppop->PopWidth, bm.bmWidth); + } if ((lpitem->item_flags & MF_SEPARATOR) == MF_SEPARATOR) { rect.bottom = rect.top + 3; } @@ -838,6 +889,8 @@ CalcAGAIN: TempWidth = LOWORD(dwRet); if (GetShortCutPos(lpitem->item_text) != (WORD)-1) TempWidth += 15; + TempWidth += lppop->CheckWidth; + TempWidth += lppop->PopWidth; lppop->Width = max(lppop->Width, TempWidth); } CopyRect(&lpitem->rect, &rect); @@ -846,6 +899,7 @@ CalcAGAIN: } if (OldWidth < lppop->Width) goto CalcAGAIN; lppop->Height = rect.bottom; + SetRect(&lppop->rect, 1, 1, lppop->Width, lppop->Height); #ifdef DEBUG_MENUCALC printf("PopupMenuCalcSize w=%d h=%d !\n", lppop->Width, lppop->Height); #endif @@ -855,31 +909,33 @@ CalcAGAIN: -void MenuBarCalcSize(HWND hwnd) +void MenuBarCalcSize(HDC hDC, LPRECT lprect, LPPOPUPMENU lppop) { - WND *wndPtr; - LPPOPUPMENU lppop; LPMENUITEM lpitem; - HDC hDC; RECT rect; HBITMAP hBitMap; BITMAP bm; HFONT hOldFont; UINT i, OldHeight; DWORD dwRet; - lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr); if (lppop == NULL) return; if (lppop->nItems == 0) return; - hDC = GetDC(hwnd); +#ifdef DEBUG_MENUCALC + printf("MenuBarCalcSize left=%d top=%d right=%d bottom=%d !\n", + lprect->left, lprect->top, lprect->right, lprect->bottom); +#endif hOldFont = SelectObject(hDC, GetStockObject(SYSTEM_FONT)); - lppop->Height = 10; + lppop->Height = lprect->bottom - lprect->top; CalcAGAIN: OldHeight = lppop->Height; - SetRect(&rect, 1, 1, 0, OldHeight); + SetRect(&rect, lprect->left, lprect->top, 0, lprect->top + OldHeight); lpitem = lppop->firstItem; for(i = 0; i < lppop->nItems; i++) { if (lpitem == NULL) break; - rect.bottom = rect.top + lppop->Height; + rect.bottom = lprect->top + lppop->Height; + if (rect.right > lprect->right) + SetRect(&rect, lprect->left, rect.bottom, + 0, rect.bottom + SYSMETRICS_CYMENU); if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) { hBitMap = (HBITMAP)LOWORD((LONG)lpitem->item_text); GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm); @@ -900,12 +956,13 @@ CalcAGAIN: } if (OldHeight < lppop->Height) goto CalcAGAIN; lppop->Width = rect.right; + lprect->bottom = lprect->top + lppop->Height; + CopyRect(&lppop->rect, lprect); #ifdef DEBUG_MENUCALC printf("MenuBarCalcSize w=%d h=%d !\n", lppop->Width, lppop->Height); #endif SelectObject(hDC, hOldFont); - ReleaseDC(hwnd, hDC); } @@ -956,13 +1013,13 @@ LPSTR GetShortCutString(LPSTR str) if (str[i] == '\t' && str[i + 1] != '\t') { str2 = &str[i + 1]; -#ifdef DEBUG_MENU +#ifdef DEBUG_MENUSHORTCUT printf("GetShortCutString // '%s' \n", str2); #endif return str2; } } -#ifdef DEBUG_MENU +#ifdef DEBUG_MENUSHORTCUT printf("GetShortCutString NULL \n"); #endif return NULL; @@ -976,13 +1033,13 @@ WORD GetShortCutPos(LPSTR str) for (i = 0; i < strlen(str); i++) { if (str[i] == '\t' && str[i + 1] != '\t') { -#ifdef DEBUG_MENU +#ifdef DEBUG_MENUSHORTCUT printf("GetShortCutPos = %d \n", i); #endif return i; } } -#ifdef DEBUG_MENU +#ifdef DEBUG_MENUSHORTCUT printf("GetShortCutString NULL \n"); #endif return -1; @@ -1007,6 +1064,7 @@ BOOL HideAllSubPopupMenu(LPPOPUPMENU menu) ShowWindow(submenu->hWnd, SW_HIDE); someClosed = TRUE; } + GlobalUnlock((HMENU)lpitem->item_id); } } lpitem = (LPMENUITEM)lpitem->next; @@ -1015,553 +1073,31 @@ BOOL HideAllSubPopupMenu(LPPOPUPMENU menu) } -#ifdef USE_XTMENU + /********************************************************************** - * MENU_CheckWidget + * ChangeMenu [USER.153] */ -void -MENU_CheckWidget(Widget w, Boolean check) +BOOL ChangeMenu(HMENU hMenu, WORD nPos, LPSTR lpNewItem, + WORD wItemID, WORD wFlags) { - if (checkBitmap == XtUnspecifiedPixmap) - { - Display *display = XtDisplayOfObject(w); - - checkBitmap = XCreateBitmapFromData(display, - DefaultRootWindow(display), - check_bitmap_bits, - check_bitmap_width, - check_bitmap_height); - nocheckBitmap = XCreateBitmapFromData(display, - DefaultRootWindow(display), - nocheck_bitmap_bits, - nocheck_bitmap_width, - nocheck_bitmap_height); - } - - if (check) - XtVaSetValues(w, XtNleftBitmap, checkBitmap, NULL); - else - XtVaSetValues(w, XtNleftBitmap, nocheckBitmap, NULL); -} - -/********************************************************************** - * MENU_ParseMenu - */ -WORD * -MENU_ParseMenu(WORD *first_item, - int level, - int limit, - int (*action)(WORD *item, int level, void *app_data), - void *app_data) -{ - WORD *item; - WORD *next_item; - int i; - - level++; - next_item = first_item; - i = 0; - do - { - i++; - item = next_item; - (*action)(item, level, app_data); - if (*item & MF_POPUP) - { - MENU_POPUPITEM *popup_item = (MENU_POPUPITEM *) item; - - next_item = (WORD *) (popup_item->item_text + - strlen(popup_item->item_text) + 1); - next_item = MENU_ParseMenu(next_item, level, 0, action, app_data); + if (wFlags & MF_APPEND) { + return AppendMenu(hMenu, wFlags, wItemID, lpNewItem); } - else - { - MENU_NORMALITEM *normal_item = (MENU_NORMALITEM *) item; - - next_item = (WORD *) (normal_item->item_text + - strlen(normal_item->item_text) + 1); + if (wFlags & MF_DELETE) { + return DeleteMenu(hMenu, wItemID, wFlags); } - } - while (!(*item & MF_END) && i != limit); - - return next_item; -} - -/********************************************************************** - * MENU_FindMenuBar - */ -LPMENUBAR -MENU_FindMenuBar(MENUITEM *this_item) -{ - MENUITEM *root; - LPMENUBAR menu; - - /* - * Find root item on menu bar. - */ - for (root = this_item; root->parent != NULL; root = root->parent) - ; - for ( ; root->prev != NULL; root = root->prev) - ; - - /* - * Find menu bar for the root item. - */ - for (menu = firstMenu; - menu != NULL && menu->firstItem != root; - menu = menu->next) - ; - - return menu; -} - -/********************************************************************** - * MENU_SelectionCallback - */ -static void -MENU_SelectionCallback(Widget w, XtPointer client_data, XtPointer call_data) -{ - MENUITEM *this_item = (MENUITEM *) client_data; - LPMENUBAR menu; - WND *wndPtr; - - if (this_item->menu_w != NULL || (this_item->item_flags & MF_DISABLED)) - return; - - /* - * Find menu bar for the root item. - */ - menu = MENU_FindMenuBar(this_item); - if (menu != NULL) - { - wndPtr = WIN_FindWndPtr(menu->ownerWnd); - if (wndPtr == NULL) - return; - -#ifdef DEBUG_MENU - printf("Selected '%s' (%d).\n", - this_item->item_text, this_item->item_id); -#endif - - CallWindowProc(wndPtr->lpfnWndProc, menu->ownerWnd, WM_COMMAND, - this_item->item_id, 0); - } -} - -/********************************************************************** - * MENU_CreateItems - */ -int -MENU_CreateItems(WORD *item, int level, void *app_data) -{ - MENU_POPUPITEM *popup_item; - MENU_NORMALITEM *normal_item; - MENUITEM *this_item; - Arg this_args[10]; - int n_args = 0; - LPMENUBAR menu = (LPMENUBAR) app_data; - - if (menu->nItems == 0) - this_item = menu->firstItem; - else - this_item = (MENUITEM *) GlobalQuickAlloc(sizeof(MENUITEM)); - - if (this_item == NULL) - return 0; - - if (level > lastLevel) - { - parentItem = siblingItem; - siblingItem = NULL; - } - - while (level < lastLevel) - { - siblingItem = parentItem; - if (siblingItem != NULL) - parentItem = siblingItem->parent; - else - parentItem = NULL; - - lastLevel--; - } - lastLevel = level; - - this_item->next = NULL; - this_item->prev = siblingItem; - this_item->child = NULL; - this_item->parent = parentItem; - - if (siblingItem != NULL) - siblingItem->next = this_item; - if (parentItem != NULL && parentItem->child == NULL) - parentItem->child = this_item; - - siblingItem = this_item; - - if (*item & MF_POPUP) - { - popup_item = (MENU_POPUPITEM *) item; - this_item->item_flags = popup_item->item_flags; - this_item->item_id = -1; - this_item->item_text = popup_item->item_text; - -#ifdef DEBUG_MENU - printf("%d: popup %s\n", level, this_item->item_text); -#endif - } - else - { - normal_item = (MENU_NORMALITEM *) item; - this_item->item_flags = normal_item->item_flags; - this_item->item_id = normal_item->item_id; - this_item->item_text = normal_item->item_text; - -#ifdef DEBUG_MENU - printf("%d: normal %s (%04x)\n", level, this_item->item_text, - this_item->item_flags); -#endif - } - - if (level == 1) - { - menu->nItems++; - - if (this_item->prev != NULL) - { - XtSetArg(this_args[n_args], XtNhorizDistance, 10); - n_args++; - XtSetArg(this_args[n_args], XtNfromHoriz, this_item->prev->w); - n_args++; + if (wFlags & MF_INSERT) { + return InsertMenu(hMenu, nPos, wFlags, wItemID, lpNewItem); } - - if (this_item->item_flags & MF_POPUP) - { - sprintf(this_item->menu_name, "Menu%d", menuId++); - XtSetArg(this_args[n_args], XtNmenuName, this_item->menu_name); - n_args++; - - this_item->w = XtCreateManagedWidget(this_item->item_text, - winMenuButtonWidgetClass, - menu->parentWidget, - this_args, n_args); - this_item->menu_w = XtCreatePopupShell(this_item->menu_name, - simpleMenuWidgetClass, - this_item->w, - NULL, 0); + if (wFlags & MF_CHANGE) { + return ModifyMenu(hMenu, nPos, wFlags, wItemID, lpNewItem); } - else - { - this_item->w = XtCreateManagedWidget(this_item->item_text, - winCommandWidgetClass, - menu->parentWidget, - this_args, n_args); - this_item->menu_w = NULL; - XtAddCallback(this_item->w, XtNcallback, MENU_SelectionCallback, - (XtPointer) this_item); + if (wFlags & MF_REMOVE) { + return RemoveMenu(hMenu, wItemID, wFlags); } - - if (menu->firstItem == NULL) - menu->firstItem = this_item; - } - else - { - if ((this_item->item_flags & MF_MENUBREAK) || - (strlen(this_item->item_text) == 0)) - { - XtSetArg(this_args[n_args], XtNheight, 10); - n_args++; - this_item->w = XtCreateManagedWidget("separator", - smeLineObjectClass, - this_item->parent->menu_w, - this_args, n_args); - } - else - { - XtSetArg(this_args[n_args], XtNmenuName, this_item->menu_name); - n_args++; - this_item->w = XtCreateManagedWidget(this_item->item_text, - smeMenuButtonObjectClass, - this_item->parent->menu_w, - this_args, n_args); - - if (this_item->item_flags & MF_POPUP) - { - sprintf(this_item->menu_name, "Menu%d", menuId++); - this_item->menu_w = XtCreatePopupShell(this_item->menu_name, - simpleMenuWidgetClass, - this_item->parent->menu_w, - NULL, 0); - } - else - { - this_item->menu_w = NULL; - XtAddCallback(this_item->w, XtNcallback, - MENU_SelectionCallback, (XtPointer) this_item); - } - } - } - - if (this_item->w != NULL) - { - if (this_item->item_flags & MF_GRAYED) - XtSetSensitive(this_item->w, False); - if (this_item->item_flags & MF_DISABLED) - XtVaSetValues(this_item->w, XtNinactive, True, NULL); - if (this_item->item_flags & MF_CHECKED) - MENU_CheckWidget(this_item->w, True); - } - - return 1; + return FALSE; } - -/********************************************************************** - * MENU_UseMenu - */ -LPMENUBAR -MENU_UseMenu(Widget parent, HANDLE instance, HWND wnd, HMENU hmenu, int width) -{ - LPMENUBAR menubar; - MENUITEM *menu; - MENU_HEADER *menu_desc; - - menu = (MENUITEM *) GlobalLock(hmenu); - if (hmenu == 0 || menu == NULL) - { - return NULL; - } - - menubar = MENU_FindMenuBar(menu); - if (menubar == NULL) - { - GlobalUnlock(hmenu); - return NULL; - } - - menubar->nItems = 0; - menubar->parentWidget = parent; - menubar->ownerWnd = wnd; - - menu_desc = (MENU_HEADER *) GlobalLock(menubar->menuDescription); - - parentItem = NULL; - siblingItem = NULL; - lastLevel = 0; - MENU_ParseMenu((WORD *) (menu_desc + 1), 0, 0, MENU_CreateItems, menubar); - - menubar->menuBarWidget = menubar->firstItem->w; - - menubar->next = firstMenu; - firstMenu = menubar; - - return menubar; -} - -/********************************************************************** - * MENU_CreateMenuBar - */ -LPMENUBAR -MENU_CreateMenuBar(Widget parent, HANDLE instance, HWND wnd, - char *menu_name, int width) -{ - LPMENUBAR menubar; - HMENU hmenu; - MENUITEM *menu; - MENU_HEADER *menu_desc; - -#ifdef DEBUG_MENU - printf("CreateMenuBar: instance %02x, menu '%s', width %d\n", - instance, menu_name, width); -#endif - - hmenu = LoadMenu(instance, menu_name); - return MENU_UseMenu(parent, instance, wnd, hmenu, width); -} - -/********************************************************************** - * MENU_FindItem - */ -MENUITEM * -MENU_FindItem(MENUITEM *menu, WORD item_id, WORD flags) -{ - MENUITEM *item; - WORD position; - - if (flags & MF_BYPOSITION) - { - item = menu; - for (position = 0; item != NULL && position != item_id; position++) - item = item->next; - - if (position == item_id) - return item; - } - else - { - for ( ; menu != NULL; menu = menu->next) - { - if (menu->item_id == item_id && menu->child == NULL) - return menu; - if (menu->child != NULL) - { - item = MENU_FindItem(menu->child, item_id, flags); - if (item != NULL) - return item; - } - } - } - - return NULL; -} - -/********************************************************************** - * MENU_CollapseMenu - */ -static void -MENU_CollapseBranch(MENUITEM *item, Boolean first_flag) -{ - MENUITEM *next_item; - - for ( ; item != NULL; item = next_item) - { - next_item = item->next; - - if (item->child != NULL) - MENU_CollapseBranch(item->child, False); - - if (item->w != NULL) - XtDestroyWidget(item->w); - if (item->menu_w != NULL) - XtDestroyWidget(item->menu_w); - - if (first_flag) - { - item->prev = NULL; - item->child = NULL; - item->next = NULL; - item->parent = NULL; - item->item_flags = 0; - item->item_id = 0; - item->item_text = NULL; - item->w = NULL; - item->menu_w = NULL; - - first_flag = False; - } - else - { - GlobalFree((unsigned int) item); - } - } -} - -void -MENU_CollapseMenu(LPMENUBAR menubar) -{ - MENU_CollapseBranch(menubar->firstItem, True); - - menubar->nItems = 0; - menubar->parentWidget = NULL; - menubar->ownerWnd = 0; - menubar->menuBarWidget = NULL; -} - - -/********************************************************************** - * CheckMenu - */ -BOOL -CheckMenu(HMENU hmenu, WORD item_id, WORD check_flags) -{ - MENUITEM *item; - Pixmap left_bitmap; - - if ((item = (MENUITEM *) GlobalLock(hmenu)) == NULL) - return -1; - - item = MENU_FindItem(item, item_id, check_flags); - if (item == NULL) - { - GlobalUnlock(hmenu); - return -1; - } - - XtVaGetValues(item->w, XtNleftBitmap, &left_bitmap, NULL); - MENU_CheckWidget(item->w, (check_flags & MF_CHECKED)); - - if (left_bitmap == XtUnspecifiedPixmap) - return MF_UNCHECKED; - else - return MF_CHECKED; -} - - -/********************************************************************** - * LoadMenu - */ -HMENU -LoadMenu(HINSTANCE instance, char *menu_name) -{ - HANDLE hmenubar; - LPMENUBAR menu; - HANDLE hmenu_desc; - HMENU hmenu; - MENU_HEADER *menu_desc; - -#ifdef DEBUG_MENU - printf("LoadMenu: instance %02x, menu '%s'\n", - instance, menu_name); -#endif - - if (menu_name == NULL || - (hmenu_desc = RSC_LoadMenu(instance, menu_name)) == 0 || - (menu_desc = (MENU_HEADER *) GlobalLock(hmenu_desc)) == NULL) - { - return 0; - } - - hmenubar = GlobalAlloc(GMEM_MOVEABLE, sizeof(MENUBAR)); - menu = (LPMENUBAR) GlobalLock(hmenubar); - if (menu == NULL) - { - GlobalFree(hmenu_desc); - GlobalFree(hmenubar); - return 0; - } - - hmenu = GlobalAlloc(GMEM_MOVEABLE, sizeof(MENUITEM)); - if (hmenu == 0) - { - GlobalFree(hmenu_desc); - GlobalFree(hmenubar); - return 0; - } - - menu->menuDescription = hmenu_desc; - menu->nItems = 0; - menu->parentWidget = NULL; - menu->firstItem = (MENUITEM *) GlobalLock(hmenu); - menu->ownerWnd = 0; - menu->menuBarWidget = NULL; - - menu->firstItem->next = NULL; - menu->firstItem->prev = NULL; - menu->firstItem->child = NULL; - menu->firstItem->parent = NULL; - menu->firstItem->item_flags = 0; - menu->firstItem->item_id = 0; - menu->firstItem->item_text = NULL; - menu->firstItem->w = NULL; - menu->firstItem->menu_w = NULL; - - menu->next = firstMenu; - firstMenu = menu; - - return GlobalHandleFromPointer(menu->firstItem); -} - -#endif /********************************************************************** @@ -1586,10 +1122,12 @@ BOOL CheckMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags) lpitem->item_flags |= MF_CHECKED; else lpitem->item_flags &= ((WORD)-1 ^ MF_CHECKED); + GlobalUnlock(hMenu); return(TRUE); } lpitem = (LPMENUITEM)lpitem->next; } + GlobalUnlock(hMenu); return FALSE; } @@ -1616,10 +1154,12 @@ BOOL EnableMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags) lpitem->item_flags |= MF_DISABLED; else lpitem->item_flags &= ((WORD)-1 ^ MF_DISABLED); + GlobalUnlock(hMenu); return(TRUE); } lpitem = (LPMENUITEM)lpitem->next; } + GlobalUnlock(hMenu); return FALSE; } @@ -1635,8 +1175,12 @@ BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt LPMENUITEM lpitem, lpitem2; int i; #ifdef DEBUG_MENU - printf("InsertMenu (%04X, %04X, %04X, %04X, %08X) !\n", - hMenu, nPos, wFlags, wItemID, lpNewItem); + if (wFlags & MF_STRING) + printf("InsertMenu (%04X, %04X, %04X, '%s') !\n", + hMenu, wFlags, wItemID, lpNewItem); + else + printf("InsertMenu (%04X, %04X, %04X, %04X, %08X) !\n", + hMenu, nPos, wFlags, wItemID, lpNewItem); #endif menu = (LPPOPUPMENU) GlobalLock(hMenu); if (menu == NULL) return FALSE; @@ -1649,10 +1193,14 @@ BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt } printf("InsertMenu // after loop items !\n"); hNewItem = GlobalAlloc(GMEM_MOVEABLE, sizeof(MENUITEM)); - if (hNewItem == 0) return FALSE; + if (hNewItem == 0) { + GlobalUnlock(hMenu); + return FALSE; + } lpitem2 = (LPMENUITEM)GlobalLock(hNewItem); if (lpitem2 == NULL) { GlobalFree(hNewItem); + GlobalUnlock(hMenu); return FALSE; } lpitem2->item_flags = wFlags; @@ -1673,9 +1221,8 @@ BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt lpitem->next = lpitem2; lpitem2->child = NULL; lpitem2->parent = NULL; - lpitem2->w = NULL; - lpitem2->menu_w = NULL; menu->nItems++; + GlobalUnlock(hMenu); return TRUE; } @@ -1690,8 +1237,12 @@ BOOL AppendMenu(HMENU hMenu, WORD wFlags, WORD wItemID, LPSTR lpNewItem) HANDLE hNewItem; LPMENUITEM lpitem, lpitem2; #ifdef DEBUG_MENU - printf("AppendMenu (%04X, %04X, %04X, %08X) !\n", - hMenu, wFlags, wItemID, lpNewItem); + if ((wFlags & (MF_BITMAP | MF_SEPARATOR | MF_MENUBREAK | MF_OWNERDRAW)) == 0) + printf("AppendMenu (%04X, %04X, %04X, '%s') !\n", + hMenu, wFlags, wItemID, lpNewItem); + else + printf("AppendMenu (%04X, %04X, %04X, %08X) !\n", + hMenu, wFlags, wItemID, lpNewItem); #endif menu = (LPPOPUPMENU) GlobalLock(hMenu); if (menu == NULL) return FALSE; @@ -1702,10 +1253,14 @@ BOOL AppendMenu(HMENU hMenu, WORD wFlags, WORD wItemID, LPSTR lpNewItem) } } hNewItem = GlobalAlloc(GMEM_MOVEABLE, sizeof(MENUITEM)); - if (hNewItem == 0) return FALSE; + if (hNewItem == 0) { + GlobalUnlock(hMenu); + return FALSE; + } lpitem2 = (LPMENUITEM)GlobalLock(hNewItem); if (lpitem2 == NULL) { GlobalFree(hNewItem); + GlobalUnlock(hMenu); return FALSE; } lpitem2->item_flags = wFlags; @@ -1727,11 +1282,10 @@ BOOL AppendMenu(HMENU hMenu, WORD wFlags, WORD wItemID, LPSTR lpNewItem) lpitem2->next = NULL; lpitem2->child = NULL; lpitem2->parent = NULL; - lpitem2->w = NULL; - lpitem2->menu_w = NULL; lpitem2->hCheckBit = (HBITMAP)NULL; lpitem2->hUnCheckBit = (HBITMAP)NULL; menu->nItems++; + GlobalUnlock(hMenu); return TRUE; } @@ -1757,12 +1311,14 @@ BOOL RemoveMenu(HMENU hMenu, WORD nPos, WORD wFlags) lpitem->prev->next = lpitem->next; lpitem->next->prev = lpitem->prev; GlobalFree(HIWORD(lpitem)); + GlobalUnlock(hMenu); return(TRUE); } lpitem = (LPMENUITEM)lpitem->next; printf("RemoveMenu // during loop items !\n"); } printf("RemoveMenu // after loop items !\n"); + GlobalUnlock(hMenu); return FALSE; } @@ -1801,10 +1357,12 @@ BOOL ModifyMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt lpitem->item_flags = wFlags; lpitem->item_id = wItemID; lpitem->item_text = lpNewItem; + GlobalUnlock(hMenu); return(TRUE); } lpitem = (LPMENUITEM)lpitem->next; } + GlobalUnlock(hMenu); return FALSE; } @@ -1836,6 +1394,7 @@ HMENU CreatePopupMenu() menu->SysFlag = FALSE; menu->Width = 100; menu->Height = 0; + GlobalUnlock(hMenu); return hMenu; } @@ -1848,6 +1407,7 @@ BOOL TrackPopupMenu(HMENU hMenu, WORD wFlags, short x, short y, { WND *wndPtr; LPPOPUPMENU lppop; + RECT rect; #ifdef DEBUG_MENU printf("TrackPopupMenu (%04X, %04X, %d, %d, %04X, %04X, %08X) !\n", hMenu, wFlags, x, y, nReserved, hWnd, lpRect); @@ -1873,15 +1433,7 @@ BOOL TrackPopupMenu(HMENU hMenu, WORD wFlags, short x, short y, SetWindowPos(lppop->hWnd, 0, x, y, lppop->Width + 2, lppop->Height, SWP_NOZORDER); } - else { - MenuBarCalcSize(lppop->hWnd); -#ifdef DEBUG_MENU - printf("TrackMenuBar // x=%d y=%d Width=%d Height=%d\n", - x, y, lppop->Width, lppop->Height); -#endif - SetWindowPos(lppop->hWnd, 0, 0, -16, lppop->Width, lppop->Height, - SWP_NOZORDER); - } + GlobalUnlock(hMenu); return TRUE; } @@ -1889,7 +1441,7 @@ BOOL TrackPopupMenu(HMENU hMenu, WORD wFlags, short x, short y, /********************************************************************** * NC_TrackSysMenu [Internal] */ -void NC_TrackSysMenu(hWnd) +void NC_TrackSysMenu(HWND hWnd) { RECT rect; LPPOPUPMENU lpsys; @@ -1920,6 +1472,20 @@ void NC_TrackSysMenu(hWnd) else { ShowWindow(lpsys->hWnd, SW_HIDE); } + GlobalUnlock(wndPtr->hSysMenu); +} + + +/********************************************************************** + * GetMenuCheckMarkDimensions [USER.417] + */ +DWORD GetMenuCheckMarkDimensions() +{ + BITMAP bm; + if (hStdCheck == (HBITMAP)NULL) + hStdCheck = LoadBitmap((HANDLE)NULL, (LPSTR)OBM_CHECK); + GetObject(hStdCheck, sizeof(BITMAP), (LPSTR)&bm); + return MAKELONG(bm.bmWidth, bm.bmHeight); } @@ -1945,10 +1511,12 @@ BOOL SetMenuItemBitmaps(HMENU hMenu, WORD nPos, WORD wFlags, if (i == nPos) { lpitem->hCheckBit = hNewCheck; lpitem->hUnCheckBit = hNewUnCheck; - return(TRUE); + GlobalUnlock(hMenu); + return TRUE; } lpitem = (LPMENUITEM)lpitem->next; } + GlobalUnlock(hMenu); return FALSE; } @@ -1980,6 +1548,7 @@ HMENU CreateMenu() menu->SysFlag = FALSE; menu->Width = 100; menu->Height = 0; + GlobalUnlock(hMenu); return hMenu; } @@ -2008,6 +1577,7 @@ BOOL DestroyMenu(HMENU hMenu) } lpitem = (LPMENUITEM)lpitem->next; } + GlobalUnlock(hMenu); GlobalFree(hMenu); #ifdef DEBUG_MENU printf("DestroyMenu (%04X) // End !\n", hMenu); @@ -2016,9 +1586,6 @@ BOOL DestroyMenu(HMENU hMenu) } -#ifdef USE_POPUPMENU - - /********************************************************************** * LoadMenu [USER.150] */ @@ -2027,7 +1594,6 @@ HMENU LoadMenu(HINSTANCE instance, char *menu_name) HMENU hMenu; HANDLE hMenu_desc; MENU_HEADER *menu_desc; - #ifdef DEBUG_MENU if ((LONG)menu_name & 0xFFFF0000L) printf("LoadMenu: instance %02x, menu '%s'\n", instance, menu_name); @@ -2037,12 +1603,16 @@ HMENU LoadMenu(HINSTANCE instance, char *menu_name) if (instance == (HANDLE)NULL) instance = hSysRes; if (menu_name == NULL || (hMenu_desc = RSC_LoadMenu(instance, menu_name)) == 0 || - (menu_desc = (MENU_HEADER *) GlobalLock(hMenu_desc)) == NULL) - { + (menu_desc = (MENU_HEADER *) GlobalLock(hMenu_desc)) == NULL) { return 0; - } + } + hMenu = LoadMenuIndirect((LPSTR)menu_desc); +/* hMenu = CreateMenu(); ParseMenuResource((WORD *) (menu_desc + 1), 0, hMenu); + GlobalUnlock(hMenu_desc); + GlobalFree(hMenu_desc); +*/ return hMenu; } @@ -2080,9 +1650,18 @@ HMENU GetMenu(HWND hWnd) */ BOOL SetMenu(HWND hWnd, HMENU hMenu) { + LPPOPUPMENU lppop; WND * wndPtr = WIN_FindWndPtr(hWnd); if (wndPtr == NULL) return FALSE; +#ifdef DEBUG_MENU + printf("SetMenu(%04X, %04X);\n", hWnd, hMenu); +#endif wndPtr->wIDmenu = hMenu; + if (hMenu == 0) return TRUE; + lppop = (LPPOPUPMENU) GlobalLock(hMenu); + if (lppop == NULL) return FALSE; + lppop->ownerWnd = hWnd; + GlobalUnlock(hMenu); return TRUE; } @@ -2127,13 +1706,32 @@ void DrawMenuBar(HWND hWnd) printf("DrawMenuBar (%04X)\n", hWnd); #endif wndPtr = WIN_FindWndPtr(hWnd); - if (wndPtr != NULL && wndPtr->hWndMenuBar != 0) { - InvalidateRect(wndPtr->hWndMenuBar, NULL, TRUE); - UpdateWindow(wndPtr->hWndMenuBar); + if (wndPtr != NULL && wndPtr->wIDmenu != 0) { +#ifdef DEBUG_MENU + printf("DrawMenuBar wIDmenu=%04X \n", wndPtr->wIDmenu); +#endif + SendMessage(hWnd, WM_NCPAINT, 1, 0L); } } +/********************************************************************** + * LoadMenuIndirect [USER.220] + */ +HMENU LoadMenuIndirect(LPSTR menu_template) +{ + HMENU hMenu; + MENU_HEADER *menu_desc; +#ifdef DEBUG_MENU + printf("LoadMenuIndirect: menu_template '%08X'\n", menu_template); +#endif + hMenu = CreateMenu(); + menu_desc = (MENU_HEADER *)menu_template; + ParseMenuResource((WORD *)(menu_desc + 1), 0, hMenu); + return hMenu; +} + + /********************************************************************** * CopySysMenu (Internal) */ @@ -2175,12 +1773,15 @@ HMENU CopySysMenu() } GlobalUnlock(hMenu); GlobalUnlock(hSysMenu); +#ifdef DEBUG_MENU + printf("CopySysMenu hMenu=%04X !\n", hMenu); +#endif return hMenu; } /********************************************************************** - * ParseMenuResource (for Xlib version) + * ParseMenuResource (from Resource or Template) */ WORD * ParseMenuResource(WORD *first_item, int level, HMENU hMenu) { @@ -2205,7 +1806,7 @@ WORD * ParseMenuResource(WORD *first_item, int level, HMENU hMenu) hSubMenu, popup_item->item_text); } else { - MENU_NORMALITEM *normal_item = (MENU_NORMALITEM *) item; + MENUITEMTEMPLATE *normal_item = (MENUITEMTEMPLATE *) item; next_item = (WORD *) (normal_item->item_text + strlen(normal_item->item_text) + 1); AppendMenu(hMenu, normal_item->item_flags, @@ -2217,5 +1818,3 @@ WORD * ParseMenuResource(WORD *first_item, int level, HMENU hMenu) } -#endif - diff --git a/controls/scroll.c b/controls/scroll.c index 0f2aa848243..2894b211cc2 100644 --- a/controls/scroll.c +++ b/controls/scroll.c @@ -10,8 +10,6 @@ */ static char Copyright[] = "Copyright Martin Ayotte, 1993"; -#include -#include #include "windows.h" #include "sysmetrics.h" #include "scroll.h" @@ -32,7 +30,7 @@ HBITMAP hRgArrowD = 0; LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hWnd, WND **wndPtr); LPHEADSCROLL ScrollBarGetStorageHeader(HWND hWnd); -LPHEADSCROLL GetScrollObjectHandle(HWND hWnd, int nBar); +LPHEADSCROLL GetScrollObjectStruct(HWND hWnd, int nBar); void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y); void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y); void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y); @@ -64,22 +62,6 @@ LONG ScrollBarWndProc( HWND hWnd, WORD message, WORD wParam, LONG lParam ) #ifdef DEBUG_SCROLL printf("ScrollBar Creation !\n"); #endif - if (hUpArrow == (HBITMAP)NULL) - hUpArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWI)); - if (hDnArrow == (HBITMAP)NULL) - hDnArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWI)); - if (hLfArrow == (HBITMAP)NULL) - hLfArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWI)); - if (hRgArrow == (HBITMAP)NULL) - hRgArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWI)); - if (hUpArrowD == (HBITMAP)NULL) - hUpArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWD)); - if (hDnArrowD == (HBITMAP)NULL) - hDnArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWD)); - if (hLfArrowD == (HBITMAP)NULL) - hLfArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWD)); - if (hRgArrowD == (HBITMAP)NULL) - hRgArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWD)); return 0; case WM_DESTROY: lphs = ScrollBarGetWindowAndStorage(hWnd, &wndPtr); @@ -165,10 +147,9 @@ void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y) RECT rect, rect2; int width, height; LONG dwOwner; - lphs = GetScrollObjectHandle(hWnd, nBar); - printf("ScrollBarButtonDown // x=%d y=%d\n", x, y); + lphs = GetScrollObjectStruct(hWnd, nBar); #ifdef DEBUG_SCROLL - printf("ScrollBarButtonDown // x=%d y=%d\n", x, y); + printf("ScrollBarButtonDown // x=%d y=%d\n", x, y); #endif if (nBar == SB_CTL) { hWndParent = GetParent(hWnd); @@ -181,16 +162,12 @@ void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y) /* SetFocus(lphs->hWndOwner); */ - if (nBar != SB_CTL) { - GetWindowRect(lphs->hWndOwner, &rect); - x -= rect.left; - y -= rect.top; - } CopyRect(&rect, &lphs->rect); +#ifdef DEBUG_SCROLL printf("ScrollDown / x=%d y=%d left=%d top=%d right=%d bottom=%d \n", x, y, rect.left, rect.top, rect.right, rect.bottom); +#endif if (lphs->Direction == WM_VSCROLL) { - y -= rect.top; width = rect.right - rect.left; if (y < (lphs->CurPix + width)) { if (y < width) { @@ -198,30 +175,26 @@ void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y) CopyRect(&rect2, &rect); rect2.bottom = rect2.top + width; InvalidateRect(lphs->hWndOwner, &rect2, TRUE); - printf("ScrollBarButtonDown // SB_LINEUP \n"); SendMessage(hWndParent, lphs->Direction, SB_LINEUP, dwOwner); } else { lphs->ButtonDown = 5; - printf("ScrollBarButtonDown // SB_PAGEUP \n"); SendMessage(hWndParent, lphs->Direction, SB_PAGEUP, dwOwner); } } if (y > (lphs->CurPix + (width << 1))) { - if (y > (rect.bottom - width)) { + if (y > (rect.bottom - rect.top - width)) { lphs->ButtonDown = 2; CopyRect(&rect2, &rect); rect2.top = rect2.bottom - width; InvalidateRect(lphs->hWndOwner, &rect2, TRUE); - printf("ScrollBarButtonDown // SB_LINEDOWN \n"); SendMessage(hWndParent, lphs->Direction, SB_LINEDOWN, dwOwner); } else { lphs->ButtonDown = 6; - printf("ScrollBarButtonDown // SB_PAGEDOWN \n"); SendMessage(hWndParent, lphs->Direction, SB_PAGEDOWN, dwOwner); } @@ -235,7 +208,6 @@ void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y) } } else { - x -= rect.left; height = rect.bottom - rect.top; if (x < (lphs->CurPix + height)) { if (x < height) { @@ -289,11 +261,10 @@ void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y) { LPHEADSCROLL lphs; RECT rect, rect2; - printf("ScrollBarButtonUp // x=%d y=%d\n", x, y); #ifdef DEBUG_SCROLL printf("ScrollBarButtonUp // x=%d y=%d\n", x, y); #endif - lphs = GetScrollObjectHandle(hWnd, nBar); + lphs = GetScrollObjectStruct(hWnd, nBar); lphs->ThumbActive = FALSE; if (lphs->ButtonDown != 0) { lphs->ButtonDown = 0; @@ -314,7 +285,7 @@ void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y) #ifdef DEBUG_SCROLL printf("ScrollBarButtonMove // w=%04X x=%d y=%d \n", wParam, x, y); #endif - lphs = GetScrollObjectHandle(hWnd, nBar); + lphs = GetScrollObjectStruct(hWnd, nBar); if (lphs->ThumbActive == 0) return; if (nBar == SB_CTL) { hWndParent = GetParent(hWnd); @@ -399,6 +370,14 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL CopyRect(&rect, lprect); w = rect.right - rect.left; h = rect.bottom - rect.top; + if (lphs->Direction == WM_VSCROLL) + lphs->MaxPix = h - 3 * w; + else + lphs->MaxPix = w - 3 * h; + if (lphs->MaxVal != lphs->MinVal) + lphs->CurPix = lphs->MaxPix * (abs((short)lphs->CurVal) - abs(lphs->MinVal)) / + (abs(lphs->MaxVal) - abs(lphs->MinVal)); + if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix; hMemDC = CreateCompatibleDC(hDC); if (lphs->Direction == WM_VSCROLL) { GetObject(hUpArrow, sizeof(BITMAP), (LPSTR)&bm); @@ -473,39 +452,18 @@ int CreateScrollBarStruct(HWND hWnd) WND *wndPtr; LPHEADSCROLL lphs; wndPtr = WIN_FindWndPtr(hWnd); - lphs = (LPHEADSCROLL)malloc(sizeof(HEADSCROLL)); - if (lphs == 0) { - printf("Bad Memory Alloc on ScrollBar !\n"); - return 0; - } + width = wndPtr->rectClient.right - wndPtr->rectClient.left; + height = wndPtr->rectClient.bottom - wndPtr->rectClient.top; + if (width <= height) + lphs = AllocScrollBar(WS_VSCROLL, width, height); + else + lphs = AllocScrollBar(WS_HSCROLL, width, height); #ifdef DEBUG_SCROLL printf("CreateScrollBarStruct %lX !\n", lphs); #endif *((LPHEADSCROLL *)&wndPtr->wExtra[1]) = lphs; lphs->hWndOwner = hWnd; - lphs->ThumbActive = FALSE; - lphs->TimerPending = FALSE; - lphs->ButtonDown = 0; - lphs->MinVal = 0; - lphs->MaxVal = 100; - lphs->CurVal = 0; - lphs->CurPix = 0; - width = wndPtr->rectClient.right - wndPtr->rectClient.left; - height = wndPtr->rectClient.bottom - wndPtr->rectClient.top; CopyRect(&lphs->rect, &wndPtr->rectClient); - if (width <= height) - { - lphs->MaxPix = height - 3 * width; - lphs->Direction = WM_VSCROLL; - } - else - { - lphs->MaxPix = width - 3 * height; - lphs->Direction = WM_HSCROLL; - } - if (lphs->MaxPix < 1) lphs->MaxPix = 1; - if (wndPtr->hCursor == (HCURSOR)NULL) - wndPtr->hCursor = LoadCursor((HINSTANCE)NULL, IDC_ARROW); return TRUE; } @@ -514,6 +472,22 @@ int CreateScrollBarStruct(HWND hWnd) LPHEADSCROLL AllocScrollBar(DWORD dwStyle, int width, int height) { LPHEADSCROLL lphs; + if (hUpArrow == (HBITMAP)NULL) + hUpArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWI)); + if (hDnArrow == (HBITMAP)NULL) + hDnArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWI)); + if (hLfArrow == (HBITMAP)NULL) + hLfArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWI)); + if (hRgArrow == (HBITMAP)NULL) + hRgArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWI)); + if (hUpArrowD == (HBITMAP)NULL) + hUpArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWD)); + if (hDnArrowD == (HBITMAP)NULL) + hDnArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWD)); + if (hLfArrowD == (HBITMAP)NULL) + hLfArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWD)); + if (hRgArrowD == (HBITMAP)NULL) + hRgArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWD)); lphs = (LPHEADSCROLL)malloc(sizeof(HEADSCROLL)); if (lphs == 0) { printf("Bad Memory Alloc on ScrollBar !\n"); @@ -570,9 +544,9 @@ void NC_CreateScrollBars(HWND hWnd) /************************************************************************* - * GetScrollObjectHandle + * GetScrollObjectStruct [internal] */ -LPHEADSCROLL GetScrollObjectHandle(HWND hWnd, int nBar) +LPHEADSCROLL GetScrollObjectStruct(HWND hWnd, int nBar) { WND *wndPtr; LPHEADSCROLL lphs; @@ -593,7 +567,7 @@ int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw) { int nRet; LPHEADSCROLL lphs; - lphs = GetScrollObjectHandle(hWnd, nBar); + lphs = GetScrollObjectStruct(hWnd, nBar); if (lphs == NULL) return 0; nRet = lphs->CurVal; lphs->CurVal = (short)nPos; @@ -622,7 +596,7 @@ int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw) int GetScrollPos(HWND hWnd, int nBar) { LPHEADSCROLL lphs; - lphs = GetScrollObjectHandle(hWnd, nBar); + lphs = GetScrollObjectStruct(hWnd, nBar); if (lphs == NULL) return 0; return lphs->CurVal; } @@ -635,7 +609,7 @@ int GetScrollPos(HWND hWnd, int nBar) void SetScrollRange(HWND hWnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw) { LPHEADSCROLL lphs; - lphs = GetScrollObjectHandle(hWnd, nBar); + lphs = GetScrollObjectStruct(hWnd, nBar); if (lphs == NULL) return; lphs->MinVal = (short)MinPos; lphs->MaxVal = (short)MaxPos; @@ -661,7 +635,7 @@ void SetScrollRange(HWND hWnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw) void GetScrollRange(HWND hWnd, int nBar, LPINT lpMin, LPINT lpMax) { LPHEADSCROLL lphs; - lphs = GetScrollObjectHandle(hWnd, nBar); + lphs = GetScrollObjectStruct(hWnd, nBar); if (lphs == NULL) return; *lpMin = lphs->MinVal; *lpMax = lphs->MaxVal; @@ -686,22 +660,20 @@ void ShowScrollBar(HWND hWnd, WORD wBar, BOOL bFlag) return; } wndPtr = WIN_FindWndPtr(hWnd); - if ((wBar == SB_VERT) || (wBar == SB_BOTH)) { /* + if ((wBar == SB_VERT) || (wBar == SB_BOTH)) { if (bFlag) - ShowWindow(wndPtr->hWndVScroll, SW_SHOW); + wndPtr->dwStyle |= WS_VSCROLL; else - ShowWindow(wndPtr->hWndVScroll, SW_HIDE); -*/ + wndPtr->dwStyle &= 0xFFFFFFFFL ^ WS_VSCROLL; } if ((wBar == SB_HORZ) || (wBar == SB_BOTH)) { -/* if (bFlag) - ShowWindow(wndPtr->hWndHScroll, SW_SHOW); + wndPtr->dwStyle |= WS_HSCROLL; else - ShowWindow(wndPtr->hWndHScroll, SW_HIDE); -*/ + wndPtr->dwStyle &= 0xFFFFFFFFL ^ WS_HSCROLL; } +*/ } diff --git a/controls/widgets.c b/controls/widgets.c index 37b74f1dbd4..1ad506d8012 100644 --- a/controls/widgets.c +++ b/controls/widgets.c @@ -6,8 +6,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; -#include "windows.h" -#include "dialog.h" +#include "win.h" LONG ButtonWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ); @@ -16,6 +15,7 @@ LONG ScrollBarWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ); LONG ListBoxWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam ); LONG ComboBoxWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam ); LONG PopupMenuWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam ); +LONG DesktopWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam ); static WNDCLASS WIDGETS_BuiltinClasses[] = @@ -32,6 +32,8 @@ static WNDCLASS WIDGETS_BuiltinClasses[] = 0, 0, 0, 0, NULL, "COMBOBOX" }, { CS_GLOBALCLASS, (LONG(*)())PopupMenuWndProc, 0, 8, 0, 0, 0, 0, NULL, "POPUPMENU" }, + { CS_GLOBALCLASS, (LONG(*)())DesktopWndProc, 0, 0, + 0, 0, 0, 0, NULL, DESKTOP_CLASS_NAME }, { CS_GLOBALCLASS, (LONG(*)())DefDlgProc, 0, DLGWINDOWEXTRA, 0, 0, 0, 0, NULL, DIALOG_CLASS_NAME } }; diff --git a/debugger/Imakefile b/debugger/Imakefile index 4b4ed0442c9..2e481f0cc33 100644 --- a/debugger/Imakefile +++ b/debugger/Imakefile @@ -5,8 +5,6 @@ MODULE = debugger -DEFINES = -DUSE_READLINE - SUBDIRS = readline /* Quick and dirt hack, since i386 is defined as 1. sigh */ diff --git a/debugger/Makefile b/debugger/Makefile deleted file mode 100644 index 6a2714091b0..00000000000 --- a/debugger/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -CFLAGS=-g -I../include -DUSE_READLINE ${COPTS} -LIBS= readline/libedit.a -OBJS=dbg.tab.o hash.o lex.yy.o info.o i386-pinsn.o -#YACC=bison -v -d -YACC=yacc -b dbg -d -#LEX=flex -LEX=lex - -debugger.o: ${OBJS} readline/libedit.a - (cd readline; make) - ld -r -o debugger.o ${OBJS} $(LIBS) - - -readline/libedit.a: - (cd readline; make) - -dbg.tab.o: dbg.tab.c - gcc $(CFLAGS) -DYYDEBUG=1 -c dbg.tab.c - -lex.yy.o: lex.yy.c - gcc $(CFLAGS) -I. -c lex.yy.c - - -lex.yy.c: debug.l - ${LEX} -I debug.l - -dbg.tab.c dbg.tab.h: dbg.y - ${YACC} dbg.y - -dtest: dtest.o debugger.o - gcc -o dtest dtest.o debugger.o - -clean: - rm -f *.o main dbg.tab.* lex.yy.* *.output *~ *# dtest - (cd readline; make clean) - -depend: dbg.tab.c dbg.tab.h lex.yy.c - $(CC) $(CFLAGS) -M *.c > .depend - diff --git a/debugger/debug.l b/debugger/debug.l index 6de63a40d89..005c556b797 100644 --- a/debugger/debug.l +++ b/debugger/debug.l @@ -113,6 +113,10 @@ c { return 'c'; } %% +#ifndef yywrap +int yywrap(void) { return 1; } +#endif + #ifdef USE_READLINE #ifndef whitespace #define whitespace(c) (((c) == ' ') || ((c) == '\t')) diff --git a/debugger/readline/Makefile b/debugger/readline/Makefile deleted file mode 100644 index 0ec38896543..00000000000 --- a/debugger/readline/Makefile +++ /dev/null @@ -1,66 +0,0 @@ -## $Revision: 1.3 $ -## -## Unix makefile for editline library. -## - -## Set your options: -## -DANSI_ARROWS ANSI arrows keys work like emacs. -## -DHAVE_STDLIB Have . -## -DHAVE_TCGETATTR Have tcgetattr(), tcsetattr(). -## -DHIDE Make static functions static (non debug). -## -DHIST_SIZE=n History size. -## -DNEED_STRDUP Don't have strdup(). -## -DUNIQUE_HISTORY Don't save command if same as last one. -## -DUSE_DIRENT Use , not ? -## -DUSE_TERMCAP Use the termcap library for terminal size -## see LDFLAGS, below, if you set this. -## -DNEED_PERROR Don't have perror() (used in testit) -DEFS = -DANSI_ARROWS -DHAVE_TCGETATTR -DHIDE -DUSE_DIRENT -DSYS_UNIX - -## Set your C compiler: -WARN = -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings \ - -Wunused -Wcomment -Wswitch -CC = gcc -ansi $(WARN) -#CC = cc -CFLAGS = $(DEFS) -O -g - -## If you have -DUSE_TERMCAP, set this as appropriate: -#LDFLAGS = -ltermlib -#LDFLAGS = -ltermcap - -## Set ranlib as appropriate: -RANLIB = ranlib -#RANLIB = echo - -## End of configuration. - -SOURCES = editline.c complete.c sysunix.c -OBJECTS = editline.o complete.o sysunix.o -SHARFILES = README Makefile editline.3 editline.h unix.h editline.c \ - complete.c sysunix.c testit.c \ - Make.os9 os9.h sysos9.c - -all: libedit.a - -testit: testit.c libedit.a - $(CC) $(CFLAGS) -o testit testit.c libedit.a $(LDFLAGS) - -shar: $(SHARFILES) - shar $(SHARFILES) >shar - -clean: - rm -f *.[oa] testit foo core tags lint lint.all a.out shar *# *~ - -lint: testit - lint -a -b -u -x $(DEFS) $(SOURCES) testit.c >lint.all - sed -e '/warning: function prototype not in scope/d' \ - -e '/warning: old style argument declaration/'d \ - -e '/mix of old and new style function declaration/'d \ - lint - -libedit.a: $(OBJECTS) - @rm -f $@ - ar r $@ $(OBJECTS) - $(RANLIB) $@ - -$(OBJECTS): editline.h diff --git a/etc/Makefile b/etc/Makefile deleted file mode 100644 index 87948b04a9d..00000000000 --- a/etc/Makefile +++ /dev/null @@ -1,358 +0,0 @@ -# Makefile generated by imake - do not edit! -# $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $ - -# ------------------------------------------------------------------------- -# Makefile generated from "Imake.tmpl" and -# $XFree86: mit/config/Imake.tmpl,v 1.17 1993/06/03 15:26:36 dawes Exp $ -# $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $ -# -# Platform-specific parameters may be set in the appropriate .cf -# configuration files. Site-specific parameters should be set in the file -# site.def. Full rebuilds are recommended if any parameters are changed. -# -# If your C preprocessor does not define any unique symbols, you will need -# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing -# "make World" the first time). -# - -# ------------------------------------------------------------------------- -# site-specific configuration parameters that need to come before -# the platform-specific parameters - edit site.def to change - -# $XFree86: mit/config/site.def,v 1.65 1993/06/04 16:02:47 dawes Exp $ -# site: $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $ - -# obz: changes for making Linux distribution - -# ------------------------------------------------------------------------- -# platform-specific configuration parameters - edit x386.cf to change - -# $XFree86: mit/config/x386.cf,v 1.90 1993/06/04 16:02:50 dawes Exp $ -# platform: $XConsortium: x386.cf,v 1.7 91/08/16 19:30:10 gildea Exp $ - -# ------------------------------------------------------------------------- -# XFree86 version definition -# $XFree86: mit/config/xf86_vers.def,v 1.5 1993/06/01 09:12:47 dawes Exp $ - -# ------------------------------------------------------------------------- -# XFree86 version: 1300 -# ------------------------------------------------------------------------- - -# $XFree86: mit/config/lnuxLib.rules,v 1.2 1993/06/02 13:48:12 dawes Exp $ - -DLL_BINDIR = /usr/dll/bin - -# operating system: Linux - -# ------------------------------------------------------------------------- -# site-specific configuration parameters that go after -# the platform-specific parameters - edit site.def to change - -# $XFree86: mit/config/site.def,v 1.65 1993/06/04 16:02:47 dawes Exp $ -# site: $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $ - -# obz: changes for making Linux distribution - - SHELL = /bin/sh - - TOP = ../. - CURRENT_DIR = ./etc - - AR = ar clq - BOOTSTRAPCFLAGS = - CC = gcc - AS = as - - LEX = flex - - YACC = bison -y - - COMPRESS = compress - CPP = /lib/cpp $(STD_CPP_DEFINES) - PREPROCESSCMD = /lib/cpp $(STD_CPP_DEFINES) - INSTALL = install - LD = ld - LINT = lint - LINTLIBFLAG = -C - LINTOPTS = -axz - LN = ln -s - MAKE = make - MV = mv - CP = cp - - RANLIB = ranlib - RANLIBINSTFLAGS = - - RM = rm -f - TROFF = psroff - MSMACROS = -ms - TBL = tbl - EQN = eqn - STD_INCLUDES = - STD_CPP_DEFINES = -traditional -D_POSIX_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -Dlinux - STD_DEFINES = -D_POSIX_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -Dlinux - EXTRA_LOAD_FLAGS = - EXTRA_LIBRARIES = - OS_LIBRARIES = - TAGS = ctags - - SHAREDCODEDEF = - SHLIBDEF = - - PROTO_DEFINES = -DFUNCPROTO=11 -DNARROWPROTO - - INSTPGMFLAGS = -s - - INSTBINFLAGS = -m 0755 - INSTUIDFLAGS = -s -m 4755 - INSTLIBFLAGS = -m 0644 - INSTINCFLAGS = -m 0444 - INSTMANFLAGS = -m 0444 - INSTDATFLAGS = -m 0444 - INSTKMEMFLAGS = -s -m 4755 - - PROJECTROOT = /usr/X386 - - TOP_INCLUDES = -I$(INCROOT) - - CDEBUGFLAGS = -O2 - CCOPTIONS = -m486 -DNO_ASM -fwritable-strings - ANSICCOPTIONS = - - ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES) - ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES) - CFLAGS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) - LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) - - LDLIBS = $(OS_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) - - LDOPTIONS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR) - - LDCOMBINEFLAGS = -r - DEPENDFLAGS = - - MACROFILE = x386.cf - RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut - - IMAKE_DEFINES = - - IRULESRC = $(CONFIGDIR) - IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) - - ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) - -# ------------------------------------------------------------------------- -# X Window System Build Parameters -# $XFree86: mit/config/Project.tmpl,v 1.13 1993/03/27 03:32:45 dawes Exp $ -# $XConsortium: Project.tmpl,v 1.138.1.1 92/11/11 09:49:19 rws Exp $ - -_percentC_ = %C - -# ------------------------------------------------------------------------- -# X Window System make variables; this need to be coordinated with rules - - PATHSEP = / - USRLIBDIR = /usr/X386/lib - BINDIR = /usr/X386/bin - INCROOT = /usr/X386/include - BUILDINCROOT = $(TOP) - BUILDINCDIR = $(BUILDINCROOT)/X11 - BUILDINCTOP = .. - INCDIR = $(INCROOT)/X11 - ADMDIR = /usr/adm - LIBDIR = $(USRLIBDIR)/X11 - CONFIGDIR = $(LIBDIR)/config - LINTLIBDIR = $(USRLIBDIR)/lint - - FONTDIR = $(LIBDIR)/fonts - XINITDIR = $(LIBDIR)/xinit - XDMDIR = $(LIBDIR)/xdm - TWMDIR = $(LIBDIR)/twm - MANPATH = /usr/X386/man - MANSOURCEPATH = $(MANPATH)/man - MANSUFFIX = 1x - LIBMANSUFFIX = 3x - MANDIR = $(MANSOURCEPATH)1 - LIBMANDIR = $(MANSOURCEPATH)3 - NLSDIR = $(LIBDIR)/nls - PEXAPIDIR = $(LIBDIR)/PEX - XAPPLOADDIR = $(LIBDIR)/app-defaults - FONTCFLAGS = -t - LINKKITDIR = $(USRLIBDIR)/Server - - INSTAPPFLAGS = $(INSTDATFLAGS) - - IMAKE = imake - DEPEND = makedepend - RGB = rgb - - FONTC = bdftopcf - - MKFONTDIR = mkfontdir - MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier - - CONFIGSRC = $(TOP)/config - DOCUTILSRC = $(TOP)/doc/util - CLIENTSRC = $(TOP)/clients - DEMOSRC = $(TOP)/demos - LIBSRC = $(TOP)/lib - FONTSRC = $(TOP)/fonts - INCLUDESRC = $(TOP)/X11 - SERVERSRC = $(TOP)/server - UTILSRC = $(TOP)/util - SCRIPTSRC = $(UTILSRC)/scripts - EXAMPLESRC = $(TOP)/examples - CONTRIBSRC = $(TOP)/../contrib - DOCSRC = $(TOP)/doc - RGBSRC = $(TOP)/rgb - DEPENDSRC = $(UTILSRC)/makedepend - IMAKESRC = $(CONFIGSRC) - XAUTHSRC = $(LIBSRC)/Xau - XLIBSRC = $(LIBSRC)/X - XMUSRC = $(LIBSRC)/Xmu - TOOLKITSRC = $(LIBSRC)/Xt - AWIDGETSRC = $(LIBSRC)/Xaw - OLDXLIBSRC = $(LIBSRC)/oldX - XDMCPLIBSRC = $(LIBSRC)/Xdmcp - BDFTOSNFSRC = $(FONTSRC)/bdftosnf - BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf - BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf - MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir - FSLIBSRC = $(FONTSRC)/lib/fs - FONTSERVERSRC = $(FONTSRC)/server - EXTENSIONSRC = $(TOP)/extensions - XILIBSRC = $(EXTENSIONSRC)/lib/xinput - PEXLIBSRC = $(EXTENSIONSRC)/lib/PEXlib - PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX - -# $XFree86: mit/config/lnuxLib.tmpl,v 1.1 1993/04/16 14:06:06 dawes Exp $ - -SHLIBLDFLAGS = -PICFLAGS = -B/usr/dll/jump/ - - DEPEXTENSIONLIB = - EXTENSIONLIB = -lXext - - DEPXLIB = $(DEPEXTENSIONLIB) - XLIB = $(EXTENSIONLIB) -lX11 - - DEPXMULIB = - XMULIB = -lXmu - - DEPXTOOLLIB = - XTOOLLIB = -lXt - - DEPXAWLIB = - XAWLIB = -lXaw - - DEPXILIB = - XILIB = -lXi - - DEPXTESTLIB = - XTESTLIB = -lXtst - - DEPPEXLIB = - PEXLIB = -lPEX5 - - SOXLIBREV = 3.0.1 - SOXTREV = 3.0.1 - SOXAWREV = 3.0.1 - SOOLDXREV = 3.0.1 - SOXMUREV = 3.0.1 - SOXEXTREV = 3.0.1 - SOXINPUTREV = 3.0.1 - SOPEXREV = 1.0.1 - - DEPXAUTHLIB = $(USRLIBDIR)/libXau.a - XAUTHLIB = -lXau - DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a - XDMCPLIB = -lXdmcp - - DEPOLDXLIB = $(USRLIBDIR)/liboldX.a - OLDXLIB = -loldX - - DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a - PHIGSLIB = -lphigs - - DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a - XBSDLIB = -lXbsd - - LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln - LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln - LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln - LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln - LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln - LINTXI = $(LINTLIBDIR)/llib-lXi.ln - LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln - LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln - - DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) - - DEPLIBS1 = $(DEPLIBS) - DEPLIBS2 = $(DEPLIBS) - DEPLIBS3 = $(DEPLIBS) - -# ------------------------------------------------------------------------- -# Imake rules for building libraries, programs, scripts, and data files -# $XFree86: mit/config/Imake.rules,v 1.9 1993/03/23 12:56:27 dawes Exp $ -# rules: $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $ - -# ------------------------------------------------------------------------- -# start of Imakefile - -# $Id$ - -INCLUDES = -I$(TOP)/include - -# Imake rules go here - -# First, dll description to files etc - -MODULE = etc - -all:: - -depend:: - -clean:: - $(RM_CMD) "#"* - -includes:: - -# ------------------------------------------------------------------------- -# common rules for all Makefiles - do not edit - -emptyrule:: - -clean:: - $(RM_CMD) "#"* - -Makefile:: - -@if [ -f Makefile ]; then set -x; \ - $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ - else exit 0; fi - $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) - -tags:: - $(TAGS) -w *.[ch] - $(TAGS) -xw *.[ch] > TAGS - -# ------------------------------------------------------------------------- -# empty rules for directories that do not have SUBDIRS - do not edit - -install:: - @echo "install in $(CURRENT_DIR) done" - -install.man:: - @echo "install.man in $(CURRENT_DIR) done" - -install.linkkit:: - @echo "install.linkkit in $(CURRENT_DIR) done" - -Makefiles:: - -includes:: - -# ------------------------------------------------------------------------- -# dependencies generated by makedepend - diff --git a/if1632/Imakefile b/if1632/Imakefile index 4c36d99d270..6803aaaa42b 100644 --- a/if1632/Imakefile +++ b/if1632/Imakefile @@ -1,3 +1,4 @@ +#include "../autoconf.h" #include "../Wine.tmpl" MODULE = if1632 @@ -28,6 +29,7 @@ MakeDllFromSpec(sound,$(TOP)/$(MODULE)) MakeDllFromSpec(unixlib,$(TOP)/$(MODULE)) MakeDllFromSpec(user,$(TOP)/$(MODULE)) MakeDllFromSpec(win87em,$(TOP)/$(MODULE)) +MakeDllFromSpec(winsock,$(TOP)/$(MODULE)) /* * Yes I know *.o is not very clever, but can you do it cleaner ? @@ -37,7 +39,7 @@ WineRelocatableTarget($(TOP)/$(MODULE),*.o,) $(TOP)/$(MODULE).o: $(OBJS) clean:: - $(RM) dll* + $(RM) dll* dtb* depend:: diff --git a/if1632/Makefile b/if1632/Makefile deleted file mode 100644 index 36073244c2b..00000000000 --- a/if1632/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR) - -BUILDOBJS=dll_kernel.o dll_user.o dll_gdi.o dll_unixlib.o \ - dll_win87em.o dll_shell.o dll_sound.o dll_keyboard.o\ - dll_kernel_tab.o dll_user_tab.o dll_gdi_tab.o dll_unixlib_tab.o \ - dll_win87em_tab.o dll_shell_tab.o \ - dll_sound_tab.o dll_keyboard_tab.o - -MUST_BE_LINKED_FIRST=call.o $(BUILDOBJS) - -OBJS=$(MUST_BE_LINKED_FIRST) callback.o relay.o - -# Uncomment the following 2 lines for use with FreeBSD -# %.o: %.S -# $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) $(COPTS) -c -o $@ $< - -default: if1632.o - -if1632.o: $(OBJS) - $(LD) -r -o if1632.o $(OBJS) - -clean: - rm -f *.o *~ *.s dll_* *.a *# - -dll_kernel.S dll_kernel_tab.c: ../tools/build kernel.spec - ../tools/build kernel.spec - -dll_user.S dll_user_tab.c: ../tools/build user.spec - ../tools/build user.spec - -dll_gdi.S dll_gdi_tab.c: ../tools/build gdi.spec - ../tools/build gdi.spec - -dll_unixlib.S dll_unixlib_tab.c: ../tools/build unixlib.spec - ../tools/build unixlib.spec - -dll_win87em.S dll_win87em_tab.c: ../tools/build win87em.spec - ../tools/build win87em.spec - -dll_shell.S dll_shell_tab.c: ../tools/build shell.spec - ../tools/build shell.spec - -dll_sound.S dll_sound_tab.c: ../tools/build sound.spec - ../tools/build sound.spec - -dll_keyboard.S dll_keyboard_tab.c: ../tools/build keyboard.spec - ../tools/build keyboard.spec - -depend: - $(CC) $(CFLAGS) -M *.c > .depend - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif - - - - diff --git a/if1632/call.S b/if1632/call.S index 88534962d09..5b49777aa8e 100644 --- a/if1632/call.S +++ b/if1632/call.S @@ -102,11 +102,11 @@ _CallToInit16: movw %ax,%ss movl %esp,%eax movl %eax,%ebp -#if 1 movw $UDATASEL,%ax movw %ax,%fs movw %ax,%gs -#endif + movw %ds,%ax + /* * Call entry point */ diff --git a/if1632/gdi.spec b/if1632/gdi.spec index 16a55487b05..144e0dfeb03 100644 --- a/if1632/gdi.spec +++ b/if1632/gdi.spec @@ -33,9 +33,12 @@ length 490 23 pascal Arc(word s_word s_word s_word s_word s_word s_word s_word s_word) Arc(1 2 3 4 5 6 7 8 9) 24 pascal Ellipse(word s_word s_word s_word s_word) Ellipse(1 2 3 4 5) +25 pascal FloodFill(word word word long) FloodFill(1 2 3 4) 26 pascal Pie(word s_word s_word s_word s_word s_word s_word s_word s_word) Pie(1 2 3 4 5 6 7 8 9) 27 pascal Rectangle(word s_word s_word s_word s_word) Rectangle(1 2 3 4 5) +28 pascal RoundRect(word s_word s_word s_word s_word s_word s_word) + RoundRect(1 2 3 4 5 6 7) 29 pascal PatBlt(word s_word s_word s_word s_word long) PatBlt(1 2 3 4 5 6) 30 pascal SaveDC(word) SaveDC(1) 31 pascal SetPixel(word s_word s_word long) SetPixel(1 2 3 4) @@ -135,6 +138,7 @@ length 490 346 pascal SetTextAlign(word word) SetTextAlign(1 2) 348 pascal Chord(word s_word s_word s_word s_word s_word s_word s_word s_word) Chord(1 2 3 4 5 6 7 8 9) +349 pascal SetMapperFlags(word word) SetMapperFlags(1 2) 350 pascal GetCharWidth(word word word ptr) GetCharWidth(1 2 3 4) 360 pascal CreatePalette(ptr) CreatePalette(1) 363 pascal GetPaletteEntries(word word word ptr) GetPaletteEntries(1 2 3 4) diff --git a/if1632/kernel.spec b/if1632/kernel.spec index 15021aa3f27..a3f9dd2ada7 100644 --- a/if1632/kernel.spec +++ b/if1632/kernel.spec @@ -4,7 +4,8 @@ name kernel id 1 length 415 -3 return GetVersion 0 0x301 +3 pascal GetVersion() GetVersion() +#return GetVersion 0 0x301 4 pascal LocalInit(word word word) LocalInit(1 2 3) 5 pascal LocalAlloc(word word) LocalAlloc(1 2) 6 pascal LocalReAlloc(word word word) LocalReAlloc(1 2 3) @@ -30,7 +31,10 @@ length 415 30 pascal WaitEvent(word) KERNEL_WaitEvent(1) 34 pascal SetTaskQueue(word word) SetTaskQueue(1 2) 35 pascal GetTaskQueue(word) GetTaskQueue(1) -49 pascal GetModuleFileName(word ptr s_word) KERNEL_GetModuleFileName(1 2 3) +36 pascal GetCurrentTask() GetCurrentTask() +47 pascal GetModuleHandle(ptr) GetModuleHandle(1) +48 pascal GetModuleUsage(word) GetModuleUsage(1) +49 pascal GetModuleFileName(word ptr s_word) GetModuleFileName(1 2 3) 50 pascal GetProcAddress(word ptr) GetProcAddress(1 2) 51 pascal MakeProcInstance(ptr word) CALLBACK_MakeProcInstance(1 2) 52 pascal FreeProcInstance(ptr) FreeProcInstance(1) @@ -42,13 +46,13 @@ length 415 62 pascal LockResource(word) LockResource(1) 63 pascal FreeResource(word) FreeResource(1) 64 pascal AccessResource(word word) AccessResource(1 2) -74 pascal OpenFile(ptr ptr word) KERNEL_OpenFile(1 2 3) -81 pascal _lclose(word) KERNEL__lclose(1) -82 pascal _lread(word ptr word) KERNEL__lread(1 2 3) -83 pascal _lcreate(ptr word) KERNEL__lcreate(1 2) -84 pascal _llseek(word long word) KERNEL__llseek(1 2 3) -85 pascal _lopen(ptr word) KERNEL__lopen(1 2) -86 pascal _lwrite(word ptr word) KERNEL__lwrite(1 2 3) +74 pascal OpenFile(ptr ptr word) OpenFile(1 2 3) +81 pascal _lclose(word) _lclose(1) +82 pascal _lread(word ptr word) _lread(1 2 3) +83 pascal _lcreate(ptr word) _lcreate(1 2) +84 pascal _llseek(word long word) _llseek(1 2 3) +85 pascal _lopen(ptr word) _lopen(1 2) +86 pascal _lwrite(word ptr word) _lwrite(1 2 3) 88 pascal lstrcpy(ptr ptr) lstrcpy(1 2) 89 pascal lstrcat(ptr ptr) lstrcat(1 2) 90 pascal lstrlen(ptr) lstrlen(1) @@ -58,10 +62,10 @@ length 415 92 pascal GetTempDrive(byte) GetTempDrive(1) 95 pascal LoadLibrary(ptr) LoadLibrary(1) 96 pascal FreeLibrary(word) FreeLibrary(1) -97 pascal GetTempFileName(byte ptr word ptr) GetTempDrive(1 2 3 4) +97 pascal GetTempFileName(byte ptr word ptr) GetTempFileName(1 2 3 4) 102 register DOS3Call(word word word word word word word word word word) - KERNEL_DOS3Call() + DOS3Call() 107 pascal SetErrorMode(word) SetErrorMode(1) 111 pascal GlobalWire(word) GlobalLock(1) 112 pascal GlobalUnWire(word) GlobalUnlock(1) @@ -74,10 +78,12 @@ length 415 129 pascal WritePrivateProfileString(ptr ptr ptr ptr) WritePrivateProfileString(1 2 3 4) 131 pascal GetDOSEnvironment() GetDOSEnvironment() -132 return GetWinFlags 0 0x413 +132 pascal GetWinFlags() GetWinFlags() +#132 return GetWinFlags 0 0x413 134 pascal GetWindowsDirectory(ptr word) GetWindowsDirectory(1 2) 135 pascal GetSystemDirectory(ptr word) GetSystemDirectory(1 2) 136 pascal GetDriveType(byte) GetWindowsDirectory(1) +137 pascal FatalAppExit(word ptr) FatalAppExit(1 2) 152 return GetNumTasks 0 1 154 return GlobalNotify 4 0 163 pascal GlobalLRUOldest(word) ReturnArg(1) diff --git a/if1632/relay.c b/if1632/relay.c index 52f7d426b60..92d5622a061 100644 --- a/if1632/relay.c +++ b/if1632/relay.c @@ -18,10 +18,11 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include "segmem.h" #include "prototypes.h" #include "dlls.h" +#include "options.h" -/* #define DEBUG_RELAY /* */ +#define DEBUG_RELAY /* */ -#define N_BUILTINS 8 +#define N_BUILTINS 9 struct dll_name_table_entry_s dll_builtin_table[N_BUILTINS] = { @@ -33,6 +34,7 @@ struct dll_name_table_entry_s dll_builtin_table[N_BUILTINS] = { "SHELL", SHELL_table, 256, 6 }, { "SOUND", SOUND_table, 20, 7 }, { "KEYBOARD",KEYBOARD_table,137, 8 }, + { "WINSOCK", WINSOCK_table, 155, 9 }, }; unsigned short *Stack16Frame; @@ -87,6 +89,7 @@ DLLRelay(unsigned int func_num, unsigned int seg_off) dll_p = &dll_builtin_table[dll_id].dll_table[ordinal]; #ifdef DEBUG_RELAY + if (Options.relay_debug) { unsigned int *ret_addr; unsigned short *stack_p; @@ -185,10 +188,13 @@ DLLRelay(unsigned int func_num, unsigned int seg_off) arg_table[15]); #ifdef DEBUG_RELAY - printf("Returning %08.8x from %s (%s.%d)\n", - ret_val, - dll_p->export_name, - dll_builtin_table[dll_id].dll_name, ordinal); + if (Options.relay_debug) + { + printf("Returning %08.8x from %s (%s.%d)\n", + ret_val, + dll_p->export_name, + dll_builtin_table[dll_id].dll_name, ordinal); + } #endif return ret_val; diff --git a/if1632/user.spec b/if1632/user.spec index 5303a7511b0..d6f213a3de4 100644 --- a/if1632/user.spec +++ b/if1632/user.spec @@ -11,7 +11,7 @@ length 540 11 pascal SetSystemTimer(word word word ptr) SetSystemTimer(1 2 3 4) 12 pascal KillTimer(word word) KillTimer(1 2) 13 pascal GetTickCount() GetTickCount() -14 return GetTimerResolution 0 1000 +14 pascal GetTimerResolution() GetTimerResolution() 15 pascal GetCurrentTime() GetTickCount() 16 pascal ClipCursor(ptr) ClipCursor(1) 17 pascal GetCursorPos(ptr) GetCursorPos(1) @@ -121,9 +121,23 @@ length 540 134 pascal SetWindowWord(word s_word word) SetWindowWord(1 2 3) 135 pascal GetWindowLong(word s_word) GetWindowLong(1 2) 136 pascal SetWindowLong(word s_word long) SetWindowLong(1 2 3) +137 pascal OpenClipboard(word) OpenClipboard(1) +138 pascal CloseClipboard() CloseClipboard() +139 pascal EmptyClipboard() EmptyClipboard() +140 pascal GetClipboardOwner() GetClipboardOwner() +141 pascal SetClipboardData(word word) SetClipboardData(1 2) +142 pascal GetClipboardData(word) GetClipboardData(1) +143 pascal CountClipboardFormats() CountClipboardFormats() +144 pascal EnumClipboardFormats(word) EnumClipboardFormats(1) +145 pascal RegisterClipboardFormat(ptr) RegisterClipboardFormat(1) +146 pascal GetClipboardFormatName(word ptr s_word) GetClipboardFormatName(1 2 3) +147 pascal SetClipboardViewer(word) SetClipboardViewer(1) +148 pascal GetClipboardViewer() GetClipboardViewer() +149 pascal ChangeClipboardChain(word ptr) ChangeClipboardChain(1 2) 150 pascal LoadMenu(word ptr) LoadMenu(1 2) 151 pascal CreateMenu() CreateMenu() 152 pascal DestroyMenu(word) DestroyMenu(1) +153 pascal ChangeMenu(word word ptr word word) ChangeMenu(1 2 3 4 5) 154 pascal CheckMenuItem(word word word) CheckMenuItem(1 2 3) 155 pascal EnableMenuItem(word word word) EnableMenuItem(1 2 3) 156 pascal GetSystemMenu(word word) GetSystemMenu(1 2) @@ -136,7 +150,7 @@ length 540 165 pascal SetCaretPos(word word) SetCaretPos(1 2) 166 pascal HideCaret(word) HideCaret(1) 167 pascal ShowCaret(word) ShowCaret(1) -166 pascal SetCaretBlinkTime(word) SetCaretBlinkTime(1) +168 pascal SetCaretBlinkTime(word) SetCaretBlinkTime(1) 169 pascal GetCaretBlinkTime() GetCaretBlinkTime() 171 pascal WinHelp(word word long) WinHelp(1 2 3) 173 pascal LoadCursor(word ptr) LoadCursor(1 2) @@ -152,6 +166,7 @@ length 540 183 pascal GetCaretPos(ptr) GetCaretPos(1) 190 pascal GetUpdateRect(word ptr word) GetUpdateRect(1 2 3) 191 pascal ChildWindowFromPoint(word long) ChildWindowFromPoint(1 2) +193 pascal IsClipboardFormatAvailable(word) IsClipboardFormatAvailable(1) 200 pascal OpenComm(ptr word word) OpenComm(1 2 3) 201 pascal SetCommState(ptr) SetCommState(1) 202 pascal GetCommState(word ptr) GetCommState(1 2) @@ -171,6 +186,7 @@ length 540 218 pascal DialogBoxIndirect(word word word ptr) DialogBoxIndirect(1 2 3 4) 219 pascal CreateDialogIndirect(word ptr word ptr) CreateDialogIndirect(1 2 3 4) +220 pascal LoadMenuIndirect(ptr) LoadMenuIndirect(1) 221 pascal ScrollDC(word s_word s_word ptr ptr word ptr) ScrollDC(1 2 3 4 5 6 7) 227 pascal GetNextDlgGroupItem(word word word) GetNextDlgGroupItem(1 2 3) @@ -181,6 +197,7 @@ length 540 SetWindowPos(1 2 3 4 5 6 7) 236 pascal GetCapture() GetCapture() 237 pascal GetUpdateRgn(word word word) GetUpdateRgn(1 2 3) +238 pascal ExcludeUpdateRgn(word word) ExcludeUpdateRgn(1 2) 239 pascal DialogBoxParam(word ptr word ptr long) DialogBoxParam(1 2 3 4 5) 240 pascal DialogBoxIndirectParam(word word word ptr long) DialogBoxIndirectParam(1 2 3 4 5) @@ -189,6 +206,7 @@ length 540 242 pascal CreateDialogIndirectParam(word ptr word ptr long) CreateDialogIndirectParam(1 2 3 4 5) 244 pascal EqualRect(ptr ptr) EqualRect(1 2) +248 pascal GetOpenClipboardWindow() GetOpenClipboardWindow() 258 pascal MapWindowPoints(word word ptr word) MapWindowPoints(1 2 3 4) 262 pascal GetWindow(word word) GetWindow(1 2) 266 pascal SetMessageQueue(word) SetMessageQueue(1) @@ -199,6 +217,8 @@ length 540 283 pascal RealizePalette(word) RealizePalette(1) 286 pascal GetDesktopWindow() GetDesktopWindow() 288 pascal GetMessageExtraInfo() GetMessageExtraInfo() +290 pascal RedrawWindow(word ptr word word) RedrawWindow(1 2 3 4) +308 pascal DefDlgProc(word word word long) DefDlgProc(1 2 3 4) 319 pascal ScrollWindowEx(word s_word s_word ptr ptr word ptr word) ScrollWindowEx(1 2 3 4 5 6 7 8) 324 pascal FillWindow(word word word word) FillWindow(1 2 3 4) @@ -209,6 +229,8 @@ length 540 370 pascal GetWindowPlacement(word ptr) GetWindowPlacement(1 2) 371 pascal SetWindowPlacement(word ptr) SetWindowPlacement(1 2) 373 pascal SubtractRect(ptr ptr ptr) SubtractRect(1 2 3) +402 pascal GetPriorityClipboardFormat(word ptr s_word) + GetPriorityClipboardFormat(1 2 3) 403 pascal UnregisterClass(ptr word) UnregisterClass(1 2) 404 pascal GetClassInfo(word ptr ptr) GetClassInfo(1 2 3) 406 pascal CreateCursor(word word word word word ptr ptr) @@ -221,6 +243,7 @@ length 540 415 pascal CreatePopupMenu() CreatePopupMenu() 416 pascal TrackPopupMenu(word word word word word word ptr) TrackPopupMenu(1 2 3 4 5 6 7) +417 pascal GetMenuCheckMarkDimensions() GetMenuCheckMarkDimensions() 418 pascal SetMenuItemBitmaps(word word word word word) SetMenuItemBitmaps(1 2 3 4 5) 420 pascal wsprintf(ptr ptr) wsprintf(1 2) @@ -246,3 +269,4 @@ length 540 471 pascal lstrcmpi(ptr ptr) lstrcmpi(1 2) 472 pascal AnsiNext(ptr) AnsiNext(1 ) 473 pascal AnsiPrev(ptr ptr) AnsiPrev(1 2) +483 pascal SystemParametersInfo(word word ptr word) SystemParametersInfo(1 2 3 4) diff --git a/if1632/winsock.spec b/if1632/winsock.spec new file mode 100644 index 00000000000..ba0e5fbc230 --- /dev/null +++ b/if1632/winsock.spec @@ -0,0 +1,71 @@ +# +# File: winsock.def +# System: MS-Windows 3.x +# Summary: Module definition file for Windows Sockets DLL. +# +name winsock +id 9 +length 155 + +1 pascal accept(long ptr ptr) Winsock_accept(1 2 3) +2 pascal bind(long ptr word) Winsock_bind(1 2 3) +3 pascal closesocket(long) Winsock_closesocket(1) +4 pascal connect(long ptr word) Winsock_connect(1 2 3) +5 pascal getpeername(long ptr ptr) Winsock_getpeername(1 2 3) +6 pascal getsockname(long ptr ptr) Winsock_getsockname(1 2 3) +7 pascal getsockopt(long word word ptr ptr) + Winsock_getsockopt(1 2 3 4 5) +8 pascal htonl(long) Winsock_htonl(1) +9 pascal htons(word) Winsock_htons(1) +10 pascal inet_addr(ptr) Winsock_inet_addr(1) +11 pascal inet_ntoa(long) Winsock_inet_ntoa(1) +12 pascal ioctlsocket(long long ptr) Winsock_ioctlsocket(1 2 3) +13 pascal listen(long word) Winsock_listen(1 2) +14 pascal ntohl(long) Winsock_ntohl(1) +15 pascal ntohs(word) Winsock_ntohs(1) +16 pascal recv(long ptr word word) Winsock_recv(1 2 3 4) +17 pascal recvfrom(long ptr word word ptr ptr) + Winsock_recvfrom(1 2 3 4 5 6) +18 pascal select(word ptr ptr ptr ptr word) + Winsock_select(1 2 3 4 5 6) +19 pascal send(long ptr word word) Winsock_send(1 2 3 4) +20 pascal sendto(long ptr word word ptr ptr) + Winsock_sendto(1 2 3 4 5 6) +21 pascal setsockopt(long word word ptr word) + Winsock_setsockopt(1 2 3 4 5) +22 pascal shutdown(long word) Winsock_shutdown(1 2) +23 pascal socket(word word word) Winsock_socket(1 2 3) + +51 pascal gethostbyaddr(ptr word word) Winsock_gethostbyaddr(1 2 3) +52 pascal gethostbyname(ptr) Winsock_gethostbyname(1) +53 pascal getprotobyname(ptr) Winsock_getprotobyname(1) +54 pascal getprotobynumber(word) Winsock_getprotobynumber(1) +55 pascal getservbyname(ptr) Winsock_getservbyname(1) +56 pascal getservbyport(word ptr) Winsock_getservbyport(1 2) +57 pascal gethostname(ptr word) Winsock_gethostname(1 2) + +101 pascal WSAAsyncSelect(long word word long) + WSAAsyncSelect(1 2 3 4) +102 pascal WSAAsyncGetHostByAddr(word word ptr word word ptr word) + WSAAsyncGetHostByAddr(1 2 3 4 5 6 7) +103 pascal WSAAsyncGetHostByName(word word ptr ptr word) + WSAAsyncGetHostByName(1 2 3 4 5) +104 pascal WSAAsyncGetProtoByNumber(word word word ptr word) + WSAAsyncGetProtoByNumber(1 2 3 4 5) +105 pascal WSAAsyncGetProtoByName(word word ptr ptr word) + WSAAsyncGetProtoByName(1 2 3 4 5) +106 pascal WSAAsyncGetServByPort(word word word ptr ptr word) + WSAAsyncGetServByPort(1 2 3 4 5 6) +107 pascal WSAAsyncGetServByName(word word ptr ptr ptr word) + WSAAsyncGetServByName(1 2 3 4 5 6) +108 pascal WSACancelAsyncRequest(word) WSACancelAsyncRequest(1) +109 pascal WSASetBlockingHook() WSASetBlockingHook() +110 pascal WSAUnhookBlockingHook() WSAUnhookBlockingHook() +111 pascal WSAGetLastError() WSAGetLastError() +112 pascal WSASetLastError(word) WSASetLastError(1) +113 pascal WSACancelBlockingCall() WSACancelBlockingCall() +114 pascal WSAIsBlocking() WSAIsBlocking() +115 pascal WSAStartup(word ptr) WSAStartup(1 2) +116 pascal WSACleanup() WSACleanup() + +151 pascal __WSAFDIsSet(long ptr) WSAFDIsSet(1 2) diff --git a/include/Makefile b/include/Makefile deleted file mode 100644 index 97bc6f4a06b..00000000000 --- a/include/Makefile +++ /dev/null @@ -1,360 +0,0 @@ -# Makefile generated by imake - do not edit! -# $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $ - -# ------------------------------------------------------------------------- -# Makefile generated from "Imake.tmpl" and -# $XFree86: mit/config/Imake.tmpl,v 1.17 1993/06/03 15:26:36 dawes Exp $ -# $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $ -# -# Platform-specific parameters may be set in the appropriate .cf -# configuration files. Site-specific parameters should be set in the file -# site.def. Full rebuilds are recommended if any parameters are changed. -# -# If your C preprocessor does not define any unique symbols, you will need -# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing -# "make World" the first time). -# - -# ------------------------------------------------------------------------- -# site-specific configuration parameters that need to come before -# the platform-specific parameters - edit site.def to change - -# $XFree86: mit/config/site.def,v 1.65 1993/06/04 16:02:47 dawes Exp $ -# site: $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $ - -# obz: changes for making Linux distribution - -# ------------------------------------------------------------------------- -# platform-specific configuration parameters - edit x386.cf to change - -# $XFree86: mit/config/x386.cf,v 1.90 1993/06/04 16:02:50 dawes Exp $ -# platform: $XConsortium: x386.cf,v 1.7 91/08/16 19:30:10 gildea Exp $ - -# ------------------------------------------------------------------------- -# XFree86 version definition -# $XFree86: mit/config/xf86_vers.def,v 1.5 1993/06/01 09:12:47 dawes Exp $ - -# ------------------------------------------------------------------------- -# XFree86 version: 1300 -# ------------------------------------------------------------------------- - -# $XFree86: mit/config/lnuxLib.rules,v 1.2 1993/06/02 13:48:12 dawes Exp $ - -DLL_BINDIR = /usr/dll/bin - -# operating system: Linux - -# ------------------------------------------------------------------------- -# site-specific configuration parameters that go after -# the platform-specific parameters - edit site.def to change - -# $XFree86: mit/config/site.def,v 1.65 1993/06/04 16:02:47 dawes Exp $ -# site: $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $ - -# obz: changes for making Linux distribution - - SHELL = /bin/sh - - TOP = ../. - CURRENT_DIR = ./include - - AR = ar clq - BOOTSTRAPCFLAGS = - CC = gcc - AS = as - - LEX = flex - - YACC = bison -y - - COMPRESS = compress - CPP = /lib/cpp $(STD_CPP_DEFINES) - PREPROCESSCMD = /lib/cpp $(STD_CPP_DEFINES) - INSTALL = install - LD = ld - LINT = lint - LINTLIBFLAG = -C - LINTOPTS = -axz - LN = ln -s - MAKE = make - MV = mv - CP = cp - - RANLIB = ranlib - RANLIBINSTFLAGS = - - RM = rm -f - TROFF = psroff - MSMACROS = -ms - TBL = tbl - EQN = eqn - STD_INCLUDES = - STD_CPP_DEFINES = -traditional -D_POSIX_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -Dlinux - STD_DEFINES = -D_POSIX_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -Dlinux - EXTRA_LOAD_FLAGS = - EXTRA_LIBRARIES = - OS_LIBRARIES = - TAGS = ctags - - SHAREDCODEDEF = - SHLIBDEF = - - PROTO_DEFINES = -DFUNCPROTO=11 -DNARROWPROTO - - INSTPGMFLAGS = -s - - INSTBINFLAGS = -m 0755 - INSTUIDFLAGS = -s -m 4755 - INSTLIBFLAGS = -m 0644 - INSTINCFLAGS = -m 0444 - INSTMANFLAGS = -m 0444 - INSTDATFLAGS = -m 0444 - INSTKMEMFLAGS = -s -m 4755 - - PROJECTROOT = /usr/X386 - - TOP_INCLUDES = -I$(INCROOT) - - CDEBUGFLAGS = -O2 - CCOPTIONS = -m486 -DNO_ASM -fwritable-strings - ANSICCOPTIONS = - - ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES) - ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES) - CFLAGS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) - LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) - - LDLIBS = $(OS_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) - - LDOPTIONS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR) - - LDCOMBINEFLAGS = -r - DEPENDFLAGS = - - MACROFILE = x386.cf - RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut - - IMAKE_DEFINES = - - IRULESRC = $(CONFIGDIR) - IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) - - ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) - -# ------------------------------------------------------------------------- -# X Window System Build Parameters -# $XFree86: mit/config/Project.tmpl,v 1.13 1993/03/27 03:32:45 dawes Exp $ -# $XConsortium: Project.tmpl,v 1.138.1.1 92/11/11 09:49:19 rws Exp $ - -_percentC_ = %C - -# ------------------------------------------------------------------------- -# X Window System make variables; this need to be coordinated with rules - - PATHSEP = / - USRLIBDIR = /usr/X386/lib - BINDIR = /usr/X386/bin - INCROOT = /usr/X386/include - BUILDINCROOT = $(TOP) - BUILDINCDIR = $(BUILDINCROOT)/X11 - BUILDINCTOP = .. - INCDIR = $(INCROOT)/X11 - ADMDIR = /usr/adm - LIBDIR = $(USRLIBDIR)/X11 - CONFIGDIR = $(LIBDIR)/config - LINTLIBDIR = $(USRLIBDIR)/lint - - FONTDIR = $(LIBDIR)/fonts - XINITDIR = $(LIBDIR)/xinit - XDMDIR = $(LIBDIR)/xdm - TWMDIR = $(LIBDIR)/twm - MANPATH = /usr/X386/man - MANSOURCEPATH = $(MANPATH)/man - MANSUFFIX = 1x - LIBMANSUFFIX = 3x - MANDIR = $(MANSOURCEPATH)1 - LIBMANDIR = $(MANSOURCEPATH)3 - NLSDIR = $(LIBDIR)/nls - PEXAPIDIR = $(LIBDIR)/PEX - XAPPLOADDIR = $(LIBDIR)/app-defaults - FONTCFLAGS = -t - LINKKITDIR = $(USRLIBDIR)/Server - - INSTAPPFLAGS = $(INSTDATFLAGS) - - IMAKE = imake - DEPEND = makedepend - RGB = rgb - - FONTC = bdftopcf - - MKFONTDIR = mkfontdir - MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier - - CONFIGSRC = $(TOP)/config - DOCUTILSRC = $(TOP)/doc/util - CLIENTSRC = $(TOP)/clients - DEMOSRC = $(TOP)/demos - LIBSRC = $(TOP)/lib - FONTSRC = $(TOP)/fonts - INCLUDESRC = $(TOP)/X11 - SERVERSRC = $(TOP)/server - UTILSRC = $(TOP)/util - SCRIPTSRC = $(UTILSRC)/scripts - EXAMPLESRC = $(TOP)/examples - CONTRIBSRC = $(TOP)/../contrib - DOCSRC = $(TOP)/doc - RGBSRC = $(TOP)/rgb - DEPENDSRC = $(UTILSRC)/makedepend - IMAKESRC = $(CONFIGSRC) - XAUTHSRC = $(LIBSRC)/Xau - XLIBSRC = $(LIBSRC)/X - XMUSRC = $(LIBSRC)/Xmu - TOOLKITSRC = $(LIBSRC)/Xt - AWIDGETSRC = $(LIBSRC)/Xaw - OLDXLIBSRC = $(LIBSRC)/oldX - XDMCPLIBSRC = $(LIBSRC)/Xdmcp - BDFTOSNFSRC = $(FONTSRC)/bdftosnf - BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf - BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf - MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir - FSLIBSRC = $(FONTSRC)/lib/fs - FONTSERVERSRC = $(FONTSRC)/server - EXTENSIONSRC = $(TOP)/extensions - XILIBSRC = $(EXTENSIONSRC)/lib/xinput - PEXLIBSRC = $(EXTENSIONSRC)/lib/PEXlib - PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX - -# $XFree86: mit/config/lnuxLib.tmpl,v 1.1 1993/04/16 14:06:06 dawes Exp $ - -SHLIBLDFLAGS = -PICFLAGS = -B/usr/dll/jump/ - - DEPEXTENSIONLIB = - EXTENSIONLIB = -lXext - - DEPXLIB = $(DEPEXTENSIONLIB) - XLIB = $(EXTENSIONLIB) -lX11 - - DEPXMULIB = - XMULIB = -lXmu - - DEPXTOOLLIB = - XTOOLLIB = -lXt - - DEPXAWLIB = - XAWLIB = -lXaw - - DEPXILIB = - XILIB = -lXi - - DEPXTESTLIB = - XTESTLIB = -lXtst - - DEPPEXLIB = - PEXLIB = -lPEX5 - - SOXLIBREV = 3.0.1 - SOXTREV = 3.0.1 - SOXAWREV = 3.0.1 - SOOLDXREV = 3.0.1 - SOXMUREV = 3.0.1 - SOXEXTREV = 3.0.1 - SOXINPUTREV = 3.0.1 - SOPEXREV = 1.0.1 - - DEPXAUTHLIB = $(USRLIBDIR)/libXau.a - XAUTHLIB = -lXau - DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a - XDMCPLIB = -lXdmcp - - DEPOLDXLIB = $(USRLIBDIR)/liboldX.a - OLDXLIB = -loldX - - DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a - PHIGSLIB = -lphigs - - DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a - XBSDLIB = -lXbsd - - LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln - LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln - LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln - LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln - LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln - LINTXI = $(LINTLIBDIR)/llib-lXi.ln - LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln - LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln - - DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) - - DEPLIBS1 = $(DEPLIBS) - DEPLIBS2 = $(DEPLIBS) - DEPLIBS3 = $(DEPLIBS) - -# ------------------------------------------------------------------------- -# Imake rules for building libraries, programs, scripts, and data files -# $XFree86: mit/config/Imake.rules,v 1.9 1993/03/23 12:56:27 dawes Exp $ -# rules: $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $ - -# ------------------------------------------------------------------------- -# start of Imakefile - -# $Id$ - -INCLUDES = -I$(TOP)/include - -# Imake rules go here - -# First, dll description to files etc - -MODULE = include - -HEADERS = atom.h callback.h class.h combo.h cursor.h dce.h dialog.h dlls.h files.h gdi.h heap.h icon.h int21.h listbox.h menu.h message.h neexe.h prototypes.h regfunc.h scroll.h segmem.h user.h win.h windows.h wine.h - -all:: - -depend:: - -clean:: - $(RM_CMD) "#"* - -includes:: - -# ------------------------------------------------------------------------- -# common rules for all Makefiles - do not edit - -emptyrule:: - -clean:: - $(RM_CMD) "#"* - -Makefile:: - -@if [ -f Makefile ]; then set -x; \ - $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ - else exit 0; fi - $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) - -tags:: - $(TAGS) -w *.[ch] - $(TAGS) -xw *.[ch] > TAGS - -# ------------------------------------------------------------------------- -# empty rules for directories that do not have SUBDIRS - do not edit - -install:: - @echo "install in $(CURRENT_DIR) done" - -install.man:: - @echo "install.man in $(CURRENT_DIR) done" - -install.linkkit:: - @echo "install.linkkit in $(CURRENT_DIR) done" - -Makefiles:: - -includes:: - -# ------------------------------------------------------------------------- -# dependencies generated by makedepend - diff --git a/include/arch.h b/include/arch.h new file mode 100644 index 00000000000..50e8255be73 --- /dev/null +++ b/include/arch.h @@ -0,0 +1,17 @@ +/* + * Machine dependent integer conversions + * + * Copyright Miguel de Icaza, 1994 +*/ + +#if defined (mc68000) || defined (sparc) +#define CONV_LONG(a) (((a)&0xFF) << 24) | (((a) & 0xFF00) << 8) | (((a) & 0xFF0000) >> 8) | ((a)&0xFF000000 >> 24) +#define CONV_SHORT(a) (((a) & 0xFF) << 8) | (((a) & 0xFF00) >> 8) +#define CONV_CHAR_TO_LONG(x) ((x) >> 24) +#define CONV_SHORT_TO_LONG(x) ((x) >> 16) +#else +#define CONV_LONG(a) (a) +#define CONV_SHORT(a) (a) +#define CONV_CHAR_TO_LONG(a) (a) +#define CONV_SHORT_TO_LONG(a) (a) +#endif diff --git a/include/atom.h b/include/atom.h index 61cf6b1b7c7..c6234f4db10 100644 --- a/include/atom.h +++ b/include/atom.h @@ -24,4 +24,10 @@ typedef struct HANDLE entries[1]; } ATOMTABLE; +#ifdef WINELIB +#define LocalAlign(flags,bytes) LocalAlloc (flags|LMEM_WINE_ALIGN,bytes) +#else +#define LocalAlign(flags,bytes) LocalAlloc (flags,bytes) +#endif + #endif /* ATOM_H */ diff --git a/include/class.h b/include/class.h index 285e81bf746..3812122f267 100644 --- a/include/class.h +++ b/include/class.h @@ -19,7 +19,7 @@ typedef struct tagCLASS ATOM atomName; /* Name of the class */ HANDLE hdce; /* Class DCE (if CS_CLASSDC) */ WORD cWindows; /* Count of existing windows of this class */ - WNDCLASS wc __attribute__ ((packed)); /* Class information */ + WNDCLASS wc WINE_PACKED; /* Class information */ WORD wExtra[1]; /* Class extra bytes */ } CLASS; diff --git a/include/combo.h b/include/combo.h index b6ea1d8b9b5..01626648f34 100644 --- a/include/combo.h +++ b/include/combo.h @@ -6,7 +6,6 @@ typedef struct tagHEADCOMBO { DWORD dwStyle; DWORD dwState; - HWND hWndDrop; HWND hWndEdit; HWND hWndLBox; } HEADCOMBO; diff --git a/include/dialog.h b/include/dialog.h index 4cfddbaaebb..b6fe1b31942 100644 --- a/include/dialog.h +++ b/include/dialog.h @@ -9,8 +9,6 @@ #include "windows.h" -#define DIALOG_CLASS_NAME "#32770" /* Integer atom */ - /* Dialog info structure. * This structure is stored into the window extra bytes (cbWndExtra). @@ -34,11 +32,11 @@ typedef struct typedef struct { DWORD style; - BYTE nbItems __attribute__ ((packed)); - WORD x __attribute__ ((packed)); - WORD y __attribute__ ((packed)); - WORD cx __attribute__ ((packed)); - WORD cy __attribute__ ((packed)); + BYTE nbItems WINE_PACKED; + WORD x WINE_PACKED; + WORD y WINE_PACKED; + WORD cx WINE_PACKED; + WORD cy WINE_PACKED; } DLGTEMPLATEHEADER; @@ -50,7 +48,7 @@ typedef struct WORD cx; WORD cy; WORD id; - DWORD style __attribute__ ((packed)); + DWORD style WINE_PACKED; } DLGCONTROLHEADER; diff --git a/include/dlls.h b/include/dlls.h index a0af4b0420c..f82ae94a4f8 100644 --- a/include/dlls.h +++ b/include/dlls.h @@ -13,6 +13,9 @@ typedef struct dll_arg_relocation_s unsigned char src_type; /* Argument type */ } DLL_ARG; +#define DLL 0 +#define EXE 1 + #define DLL_ARGTYPE_SIGNEDWORD 0 #define DLL_ARGTYPE_WORD 1 #define DLL_ARGTYPE_LONG 2 @@ -59,5 +62,6 @@ extern struct dll_table_entry_s WIN87EM_table[]; extern struct dll_table_entry_s SHELL_table[]; extern struct dll_table_entry_s SOUND_table[]; extern struct dll_table_entry_s KEYBOARD_table[]; +extern struct dll_table_entry_s WINSOCK_table[]; #endif /* DLLS_H */ diff --git a/include/gdi.h b/include/gdi.h index b0771350d3d..c1a56717d0e 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -45,25 +45,25 @@ typedef struct tagGDIOBJHDR typedef struct tagBRUSHOBJ { GDIOBJHDR header; - LOGBRUSH logbrush __attribute__ ((packed)); + LOGBRUSH logbrush WINE_PACKED; } BRUSHOBJ; typedef struct tagPENOBJ { GDIOBJHDR header; - LOGPEN logpen __attribute__ ((packed)); + LOGPEN logpen WINE_PACKED; } PENOBJ; typedef struct tagPALETTEOBJ { GDIOBJHDR header; - LOGPALETTE logpalette __attribute__ ((packed)); + LOGPALETTE logpalette WINE_PACKED; } PALETTEOBJ; typedef struct tagFONTOBJ { GDIOBJHDR header; - LOGFONT logfont __attribute__ ((packed)); + LOGFONT logfont WINE_PACKED; } FONTOBJ; typedef struct tagBITMAPOBJ @@ -271,12 +271,21 @@ typedef struct tagDC /* GDI local heap */ +#ifdef WINELIB + +#define GDI_HEAP_ALLOC(f,size) LocalAlloc (f,size) +#define GDI_HEAP_ADDR(handle) LocalLock (handle) +#define GDI_HEAP_FREE(handle) LocalFree (handle) + +#else + extern MDESC *GDI_Heap; #define GDI_HEAP_ALLOC(f,size) ((int)HEAP_Alloc(&GDI_Heap,f,size) & 0xffff) #define GDI_HEAP_ADDR(handle) ((void *)(handle | ((int)GDI_Heap & 0xffff0000))) #define GDI_HEAP_FREE(handle) (HEAP_Free(&GDI_Heap,GDI_HEAP_ADDR(handle))) +#endif extern HANDLE GDI_AllocObject( WORD, WORD ); extern BOOL GDI_FreeObject( HANDLE ); diff --git a/include/int21.h b/include/int21.h index f44c9a433fa..2d3d221b337 100644 --- a/include/int21.h +++ b/include/int21.h @@ -7,6 +7,7 @@ struct dosdirent { DIR *ds; char unixpath[256]; char filename[256]; + char filemask[12]; char attribute; long filesize; long filetime; @@ -35,17 +36,21 @@ struct diskinfo { #define CX (context->sc_ecx & 0x0000ffffL) #define DX (context->sc_edx & 0x0000ffffL) -#define ES context->sc_es +#define CS context->sc_cs #define DS context->sc_ds +#define ES context->sc_es + #define DI context->sc_edi #define SI context->sc_esi +#define EFL context->sc_efl + #define pointer(a,b) (((unsigned int) a << 16) | b) #define segment(a) (a >> 16) #define offset(a) (a & 0xffff) -#define SetCflag (context->sc_efl |= 0x00000001L) -#define ResetCflag (context->sc_efl &= 0xfffffffeL) +#define SetCflag (EFL |= 0x00000001L) +#define ResetCflag (EFL &= 0xfffffffeL) /* extended error codes */ diff --git a/include/menu.h b/include/menu.h index 34cdb2c1cec..315ef2ee5e4 100644 --- a/include/menu.h +++ b/include/menu.h @@ -6,12 +6,6 @@ #ifndef MENU_H #define MENU_H -#include -#include -#include -#include -#include -#include typedef struct tagMENUITEM @@ -25,24 +19,12 @@ typedef struct tagMENUITEM WORD sel_key; char *shortcut; char *item_text; - Widget w; - Widget menu_w; char menu_name[10]; RECT rect; HBITMAP hCheckBit; HBITMAP hUnCheckBit; } MENUITEM, *LPMENUITEM; -typedef struct tagMENUBAR -{ - struct tagMENUBAR *next; - HANDLE menuDescription; /* Memory containing menu desc. */ - HWND ownerWnd; /* Owner window */ - int nItems; /* Number of items on menu */ - Widget parentWidget; /* Parent of menu widget */ - Widget menuBarWidget; /* Widget to contain menu options */ - MENUITEM *firstItem; -} MENUBAR, *LPMENUBAR; typedef struct tagPOPUPMENU { @@ -57,6 +39,9 @@ typedef struct tagPOPUPMENU BOOL SysFlag; WORD Width; WORD Height; + WORD CheckWidth; + WORD PopWidth; + RECT rect; } POPUPMENU, *LPPOPUPMENU; typedef struct @@ -76,11 +61,12 @@ typedef struct WORD item_flags; /* See windows.h */ WORD item_id; /* Control Id for menu item */ char item_text[1]; /* Text for menu item */ -} MENU_NORMALITEM; +} MENUITEMTEMPLATE; -extern LPMENUBAR MENU_CreateMenuBar(Widget parent, HANDLE instance, - HWND wnd, char *menu_name, int width); -extern LPMENUBAR MENU_UseMenu(Widget parent, HANDLE instance, - HWND wnd, HMENU hmenu, int width); +void StdDrawMenuBar(HDC hDC, LPRECT lprect, LPPOPUPMENU lppop); +void MenuButtonDown(HWND hWnd, LPPOPUPMENU lppop, int x, int y); +void MenuButtonUp(HWND hWnd, LPPOPUPMENU lppop, int x, int y); +void MenuMouseMove(HWND hWnd, LPPOPUPMENU lppop, WORD wParam, int x, int y); +extern void NC_TrackSysMenu(HWND hwnd); #endif /* MENU_H */ diff --git a/include/neexe.h b/include/neexe.h index 58e67ccc275..cf2700d030f 100644 --- a/include/neexe.h +++ b/include/neexe.h @@ -27,9 +27,9 @@ struct ne_header_s u_char linker_version; /* Linker version number */ u_char linker_revision; /* Linker revision number */ u_short entry_tab_offset; /* Offset to entry table relative to NE */ - u_short entry_tab_length; /* Length of etnry table in bytes */ + u_short entry_tab_length; /* Length of entry table in bytes */ u_long reserved1; /* Reserved by Microsoft */ - u_short format_flags; /* Flags that segments in this file */ + u_short format_flags; /* Flags about segments in this file */ u_short auto_data_seg; /* Automatic data segment number */ u_short local_heap_length; /* Initial size of local heap */ u_short stack_length; /* Initial size of stack */ diff --git a/include/options.h b/include/options.h index a783b3216b7..e313305a644 100644 --- a/include/options.h +++ b/include/options.h @@ -13,6 +13,7 @@ struct options int usePrivateMap; int synchronous; short cmdShow; + int relay_debug; }; extern struct options Options; diff --git a/include/prototypes.h b/include/prototypes.h index 8bd189d3ba3..d8a319588b8 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -7,11 +7,13 @@ #define PROTOTYPES_H #include + #include "neexe.h" #include "segmem.h" #include "wine.h" #include "int21.h" +#ifndef WINELIB extern struct segment_descriptor_s * CreateSelectors(struct w_files *); @@ -49,4 +51,6 @@ extern struct dosdirent *DOS_opendir(char *dosdirname); extern struct dosdirent *DOS_readdir(struct dosdirent *de); extern void DOS_closedir(struct dosdirent *de); +#endif /* WINELIB */ + #endif /* PROTOTYPES_H */ diff --git a/include/segmem.h b/include/segmem.h index f2bf2d6ba63..b0f38f7f997 100644 --- a/include/segmem.h +++ b/include/segmem.h @@ -12,6 +12,15 @@ #include #endif +#if defined(__NetBSD__) || defined(__FreeBSD__) +#define HAVE_IPC +#include +#include +#include +#define SHMSEG 32 /* XXX SEMMNI /usr/src/sys/conf/param.h */ +#define SHM_RANGE_START 0x40000000 +#endif + /* * Array to track selector allocation. */ diff --git a/include/user.h b/include/user.h index 3b9867db86b..d702023e55a 100644 --- a/include/user.h +++ b/include/user.h @@ -10,7 +10,15 @@ #include "segmem.h" #include "heap.h" - /* USER local heap */ +/* USER local heap */ + +#ifdef WINELIB + +#define USER_HEAP_ALLOC(f,size) LocalAlloc (f, size) +#define USER_HEAP_REALLOC(handle,size,f) LocalReAlloc (handle,size,f) +#define USER_HEAP_ADDR(handle) LocalLock (handle) +#define USER_HEAP_FREE(handle) LocalFree (handle) +#else extern MDESC *USER_Heap; @@ -20,4 +28,6 @@ extern MDESC *USER_Heap; #define USER_HEAP_ADDR(handle) ((void *)(handle|((int)USER_Heap & 0xffff0000))) #define USER_HEAP_FREE(handle) (HEAP_Free(&USER_Heap,USER_HEAP_ADDR(handle))) +#endif /* WINELIB */ + #endif /* USER_H */ diff --git a/include/win.h b/include/win.h index 371b0368249..706deec2e7c 100644 --- a/include/win.h +++ b/include/win.h @@ -10,10 +10,15 @@ #include #include "windows.h" -#include "menu.h" #define WND_MAGIC 0x444e4957 /* 'WIND' */ + /* Built-in class names (see _Undocumented_Windows_ p.418) */ +#define POPUPMENU_CLASS_NAME "#32768" /* PopupMenu */ +#define DESKTOP_CLASS_NAME "#32769" /* Desktop */ +#define DIALOG_CLASS_NAME "#32770" /* Dialog */ +#define WINSWITCH_CLASS_NAME "#32771" /* WinSwitch */ +#define ICONTITLE_CLASS_NAME "#32772" /* IconTitle */ typedef struct tagWND { @@ -37,16 +42,13 @@ typedef struct tagWND DWORD dwExStyle; /* Extended style (from CreateWindowEx) */ HANDLE hdce; /* Window DCE (if CS_OWNDC or CS_CLASSDC) */ HMENU hmenuSystem; /* System menu */ - HCURSOR hCursor; /* Window Current Cursor */ void *VScroll; /* Vertical ScrollBar Struct Pointer */ void *HScroll; /* Horizontal ScrollBar Struct Pointer */ WORD wIDmenu; /* ID or hmenu (from CreateWindow) */ HANDLE hText; /* Handle of window text */ - WORD flags; /* Misc. flags */ + WORD flags; /* Misc. flags (see below) */ Window window; /* X window */ - LPMENUBAR menuBarPtr; /* Menu bar */ HMENU hSysMenu; /* window's copy of System Menu */ - HWND hWndMenuBar; /* Menu bar */ WORD wExtra[1]; /* Window extra bytes */ } WND; @@ -58,9 +60,7 @@ typedef struct tagWND #define WIN_CLASS_DC 0x10 /* Win class has style CS_CLASSDC */ #define WIN_DOUBLE_CLICKS 0x20 /* Win class has style CS_DBLCLKS */ #define WIN_RESTORE_MAX 0x40 /* Maximize when restoring */ - - /* First top-level window */ -extern HWND firstWindow; +#define WIN_INTERNAL_PAINT 0x80 /* Internal WM_PAINT message pending */ /* Window functions */ WND *WIN_FindWndPtr( HWND hwnd ); @@ -68,5 +68,7 @@ BOOL WIN_UnlinkWindow( HWND hwnd ); BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter ); HWND WIN_FindWinToRepaint( HWND hwnd ); +extern Display * display; +extern Screen * screen; #endif /* WIN_H */ diff --git a/include/windows.h b/include/windows.h index a6f8c981acc..4bd02053647 100644 --- a/include/windows.h +++ b/include/windows.h @@ -42,6 +42,7 @@ typedef char *NPSTR; typedef short *LPINT; typedef void *LPVOID; typedef long (*FARPROC)(); +typedef FARPROC DLGPROC; typedef int CATCHBUF[9]; typedef int *LPCATCHBUF; @@ -144,22 +145,36 @@ typedef PAINTSTRUCT *PPAINTSTRUCT; typedef PAINTSTRUCT *NPPAINTSTRUCT; typedef PAINTSTRUCT *LPPAINTSTRUCT; +#ifdef WINELIB +#define WINE_PACKED +#else +#define WINE_PACKED __attribute__ ((packed)) +#endif + /* Window classes */ +#ifdef WINELIB +typedef LONG (*WNDPROC)(HWND, UINT, WPARAM, LPARAM); +#else +typedef LONG (* WNDPROC)() WINE_PACKED; +#endif + typedef struct { WORD style; - LONG (*lpfnWndProc)() __attribute__ ((packed)); +#ifdef WINELIB + WNDPROC lpfnWndProc; +#else + LONG (*lpfnWndProc)() WINE_PACKED; +#endif short cbClsExtra, cbWndExtra; HANDLE hInstance; HICON hIcon; HCURSOR hCursor; HBRUSH hbrBackground; - LPSTR lpszMenuName __attribute__ ((packed)); - LPSTR lpszClassName __attribute__ ((packed)); + LPSTR lpszMenuName WINE_PACKED; + LPSTR lpszClassName WINE_PACKED; } WNDCLASS, *LPWNDCLASS; -typedef LONG (* WNDPROC)() __attribute__ ((packed)); - #define CS_VREDRAW 0x0001 #define CS_HREDRAW 0x0002 #define CS_KEYCVTWINDOW 0x0004 @@ -197,10 +212,10 @@ typedef struct { short cx; short y; short x; - LONG style __attribute__ ((packed)); - char * lpszName __attribute__ ((packed)); - char * lpszClass __attribute__ ((packed)); - DWORD dwExStyle __attribute__ ((packed)); + LONG style WINE_PACKED; + char * lpszName WINE_PACKED; + char * lpszClass WINE_PACKED; + DWORD dwExStyle WINE_PACKED; } CREATESTRUCT, *LPCREATESTRUCT; /* Offsets for GetWindowLong() and GetWindowWord() */ @@ -232,6 +247,19 @@ typedef struct POINT ptMaxTrackSize; } MINMAXINFO; + /* RedrawWindow() flags */ +#define RDW_INVALIDATE 0x0001 +#define RDW_INTERNALPAINT 0x0002 +#define RDW_ERASE 0x0004 +#define RDW_VALIDATE 0x0008 +#define RDW_NOINTERNALPAINT 0x0010 +#define RDW_NOERASE 0x0020 +#define RDW_NOCHILDREN 0x0040 +#define RDW_ALLCHILDREN 0x0080 +#define RDW_UPDATENOW 0x0100 +#define RDW_ERASENOW 0x0200 +#define RDW_FRAME 0x0400 +#define RDW_NOFRAME 0x0800 /* WM_WINDOWPOSCHANGING/CHANGED struct */ typedef struct @@ -251,9 +279,9 @@ typedef struct UINT length; UINT flags; UINT showCmd; - POINT ptMinPosition __attribute__ ((packed)); - POINT ptMaxPosition __attribute__ ((packed)); - RECT rcNormalPosition __attribute__ ((packed)); + POINT ptMinPosition WINE_PACKED; + POINT ptMaxPosition WINE_PACKED; + RECT rcNormalPosition WINE_PACKED; } WINDOWPLACEMENT, *LPWINDOWPLACEMENT; /* WINDOWPLACEMENT flags */ @@ -379,9 +407,9 @@ typedef struct tagMSG HWND hwnd; WORD message; WORD wParam; - DWORD lParam __attribute__ ((packed)); - DWORD time __attribute__ ((packed)); - POINT pt __attribute__ ((packed)); + DWORD lParam WINE_PACKED; + DWORD time WINE_PACKED; + POINT pt WINE_PACKED; } MSG, *LPMSG; typedef WORD ATOM; @@ -485,7 +513,7 @@ typedef struct tagBITMAP short bmWidthBytes; BYTE bmPlanes; BYTE bmBitsPixel; - void * bmBits __attribute__ ((packed)); + void * bmBits WINE_PACKED; } BITMAP; typedef BITMAP *PBITMAP; @@ -497,7 +525,7 @@ typedef BITMAP *LPBITMAP; typedef struct tagLOGBRUSH { WORD lbStyle; - COLORREF lbColor __attribute__ ((packed)); + COLORREF lbColor WINE_PACKED; short lbHatch; } LOGBRUSH, *PLOGBRUSH, *NPLOGBRUSH, *LPLOGBRUSH; @@ -526,7 +554,7 @@ typedef struct tagLOGFONT short lfHeight, lfWidth, lfEscapement, lfOrientation, lfWeight; BYTE lfItalic, lfUnderline, lfStrikeOut, lfCharSet; BYTE lfOutPrecision, lfClipPrecision, lfQuality, lfPitchAndFamily; - BYTE lfFaceName[LF_FACESIZE] __attribute__ ((packed)); + BYTE lfFaceName[LF_FACESIZE] WINE_PACKED; } LOGFONT, *PLOGFONT, *NPLOGFONT, *LPLOGFONT; /* lfWeight values */ @@ -638,7 +666,7 @@ typedef struct tagLOGPALETTE { WORD palVersion; WORD palNumEntries; - PALETTEENTRY palPalEntry[1] __attribute__ ((packed)); + PALETTEENTRY palPalEntry[1] WINE_PACKED; } LOGPALETTE, *PLOGPALETTE, *NPLOGPALETTE, *LPLOGPALETTE; @@ -647,8 +675,8 @@ typedef struct tagLOGPALETTE typedef struct tagLOGPEN { WORD lopnStyle; - POINT lopnWidth __attribute__ ((packed)); - COLORREF lopnColor __attribute__ ((packed)); + POINT lopnWidth WINE_PACKED; + COLORREF lopnColor WINE_PACKED; } LOGPEN, *PLOGPEN, *NPLOGPEN, *LPLOGPEN; #define PS_SOLID 0 @@ -1112,7 +1140,64 @@ typedef struct tagCOMSTAT #define CSTF_EOF 0x20 #define CSTF_TXIM 0x40 -/* */ +/* SystemParametersInfo */ + +#define SPI_GETBEEP 1 +#define SPI_SETBEEP 2 +#define SPI_GETMOUSE 3 +#define SPI_SETMOUSE 4 +#define SPI_GETBORDER 5 +#define SPI_SETBORDER 6 +#define SPI_GETKEYBOARDSPEED 10 +#define SPI_SETKEYBOARDSPEED 11 +#define SPI_LANGDRIVER 12 +#define SPI_ICONHORIZONTALSPACING 13 +#define SPI_GETSCREENSAVETIMEOUT 14 +#define SPI_SETSCREENSAVETIMEOUT 15 +#define SPI_GETSCREENSAVEACTIVE 16 +#define SPI_SETSCREENSAVEACTIVE 17 +#define SPI_GETGRIDGRANULARITY 18 +#define SPI_SETGRIDGRANULARITY 19 +#define SPI_SETDESKWALLPAPER 20 +#define SPI_SETDESKPATTERN 21 +#define SPI_GETKEYBOARDDELAY 22 +#define SPI_SETKEYBOARDDELAY 23 +#define SPI_ICONVERTICALSPACING 24 +#define SPI_GETICONTITLEWRAP 25 +#define SPI_SETICONTITLEWRAP 26 +#define SPI_GETMENUDROPALIGNMENT 27 +#define SPI_SETMENUDROPALIGNMENT 28 +#define SPI_SETDOUBLECLKWIDTH 29 +#define SPI_SETDOUBLECLKHEIGHT 30 +#define SPI_GETICONTITLELOGFONT 31 +#define SPI_SETDOUBLECLICKTIME 32 +#define SPI_SETMOUSEBUTTONSWAP 33 +#define SPI_SETICONTITLELOGFONT 34 +#define SPI_GETFASTTASKSWITCH 35 +#define SPI_SETFASTTASKSWITCH 36 + +/* SystemParametersInfo flags */ + +#define SPIF_UPDATEINIFILE 1 +#define SPIF_SENDWININICHANGE 2 + +/* GetWinFlags */ + +#define WF_PMODE 0x0001 +#define WF_CPU286 0x0002 +#define WF_CPU386 0x0004 +#define WF_CPU486 0x0008 +#define WF_STANDARD 0x0010 +#define WF_WIN286 0x0010 +#define WF_ENHANCED 0x0020 +#define WF_WIN386 0x0020 +#define WF_CPU086 0x0040 +#define WF_CPU186 0x0080 +#define WF_LARGEFRAME 0x0100 +#define WF_SMALLFRAME 0x0200 +#define WF_80x87 0x0400 +#define WF_PAGING 0x0800 +#define WF_WLO 0x8000 typedef struct { @@ -1937,7 +2022,11 @@ typedef COMPAREITEMSTRUCT FAR* LPCOMPAREITEMSTRUCT; #define VK_SCROLL 0x91 -#define LMEM_MOVEABLE 0x0002 +#define LMEM_FIXED 0 +#define LMEM_MOVEABLE 0x0002 +#define LMEM_ZEROINIT 0x0040 +#define LMEM_DISCARDABLE 0x0F00 +#define LMEM_WINE_ALIGN 0x1000 #define GMEM_FIXED 0x0000 #define GMEM_MOVEABLE 0x0002 @@ -1956,6 +2045,55 @@ typedef COMPAREITEMSTRUCT FAR* LPCOMPAREITEMSTRUCT; #define GPTR (GMEM_FIXED | GMEM_ZEROINIT) +/* Predefined Clipboard Formats */ +#define CF_TEXT 1 +#define CF_BITMAP 2 +#define CF_METAFILEPICT 3 +#define CF_SYLK 4 +#define CF_DIF 5 +#define CF_TIFF 6 +#define CF_OEMTEXT 7 +#define CF_DIB 8 +#define CF_PALETTE 9 +#define CF_PENDATA 10 +#define CF_RIFF 11 +#define CF_WAVE 12 + +#define CF_OWNERDISPLAY 0x0080 +#define CF_DSPTEXT 0x0081 +#define CF_DSPBITMAP 0x0082 +#define CF_DSPMETAFILEPICT 0x0083 + +/* "Private" formats don't get GlobalFree()'d */ +#define CF_PRIVATEFIRST 0x0200 +#define CF_PRIVATELAST 0x02FF + +/* "GDIOBJ" formats do get DeleteObject()'d */ +#define CF_GDIOBJFIRST 0x0300 +#define CF_GDIOBJLAST 0x03FF + +/* Clipboard command messages */ +#define WM_CUT 0x0300 +#define WM_COPY 0x0301 +#define WM_PASTE 0x0302 +#define WM_CLEAR 0x0303 +#define WM_UNDO 0x0304 + +/* Clipboard owner messages */ +#define WM_RENDERFORMAT 0x0305 +#define WM_RENDERALLFORMATS 0x0306 +#define WM_DESTROYCLIPBOARD 0x0307 + +/* Clipboard viewer messages */ +#define WM_DRAWCLIPBOARD 0x0308 +#define WM_PAINTCLIPBOARD 0x0309 +#define WM_SIZECLIPBOARD 0x030B +#define WM_VSCROLLCLIPBOARD 0x030A +#define WM_HSCROLLCLIPBOARD 0x030E +#define WM_ASKCBFORMATNAME 0x030C +#define WM_CHANGECBCHAIN 0x030D + + #define F(ret,name) ret name(void); #define Fa(ret,name,t1,a1) ret name(t1 a1); #define Fb(ret,name,t1,a1,t2,a2) ret name(t1 a1,t2 a2); @@ -1995,12 +2133,13 @@ F(HMENU,CreatePopupMenu) F(HWND,GetActiveWindow) F(HWND,GetCapture) F(HWND,GetClipboardOwner) +F(HWND,GetOpenClipboardWindow) F(HWND,GetClipboardViewer) F(HWND,GetDesktopHwnd) F(HWND,GetDesktopWindow) F(HWND,GetFocus) F(HWND,GetSysModalWindow) -F(LONG,GetMenuCheckMarkDimensions) +F(DWORD,GetMenuCheckMarkDimensions) F(LONG,GetWinFlags) F(LPINT,GetThresholdEvent) F(LPSTR,ValidateFreeSpaces) @@ -2009,7 +2148,7 @@ F(WORD,GetCaretBlinkTime) F(WORD,GetCurrentPDB) F(WORD,GetDoubleClickTime) F(WORD,GetNumTasks) -F(WORD,GetVersion) +F(LONG,GetVersion) F(int,CountClipboardFormats) F(int,GetKBCodePage) F(int,GetThresholdStatus) @@ -2342,7 +2481,7 @@ Fb(int,GetClipBox,HDC,a,LPRECT,b) Fb(int,GetCommError,int,a,COMSTAT*,b) Fb(int,GetCommState,int,a,DCB*,b) Fb(int,GetDeviceCaps,HDC,a,WORD,b) -Fb(int,GetPriorityClipboardFormat,WORD FAR*,a,int,b) +Fb(int,GetPriorityClipboardFormat,WORD FAR*,a,short,b) Fb(int,GetRgnBox,HRGN,a,LPRECT,b) Fb(int,GetScrollPos,HWND,a,int,b) Fb(int,ReleaseDC,HWND,a,HDC,b) @@ -2436,11 +2575,11 @@ Fc(WORD,SetClassWord,HWND,a,short,b,WORD,c) Fc(WORD,SetWindowWord,HWND,a,short,b,WORD,c) Fc(int,FrameRect,HDC,a,LPRECT,b,HBRUSH,c) Fc(int,GetClassName,HWND,a,LPSTR,b,short,c) -Fc(int,GetClipboardFormatName,WORD,a,LPSTR,b,int,c) +Fc(int,GetClipboardFormatName,WORD,a,LPSTR,b,short,c) Fc(int,GetEnvironment,LPSTR,a,LPSTR,b,WORD,c) Fc(int,GetInstanceData,HANDLE,a,NPSTR,b,int,c) Fc(int,GetKeyNameText,LONG,a,LPSTR,b,int,c) -Fc(int,GetModuleFileName,HANDLE,a,LPSTR,b,int,c) +Fc(int,GetModuleFileName,HANDLE,a,LPSTR,b,short,c) Fc(int,GetObject,HANDLE,a,int,b,LPSTR,c) Fc(int,GetTextFace,HDC,a,int,b,LPSTR,c) Fc(int,GetUpdateRgn,HWND,a,HRGN,b,BOOL,c) @@ -2477,12 +2616,13 @@ Fd(BOOL,GetMessage,LPMSG,msg,HWND,b,WORD,c,WORD,d) Fd(BOOL,GetTextExtentPoint,HDC,a,LPSTR,b,short,c,LPSIZE,d) Fd(BOOL,DrawIcon,HDC,a,short,b,short,c,HICON,d) Fd(BOOL,EnumMetaFile,HDC,a,LOCALHANDLE,b,FARPROC,c,BYTE FAR*,d) -Fd(BOOL,FloodFill,HDC,a,int,b,int,c,DWORD,d) +Fd(BOOL,FloodFill,HDC,a,short,b,short,c,DWORD,d) Fd(BOOL,GetCharWidth,HDC,a,WORD,b,WORD,c,LPINT,d) Fd(BOOL,HiliteMenuItem,HWND,a,HMENU,b,WORD,c,WORD,d) Fd(BOOL,MoveToEx,HDC,a,short,b,short,c,LPPOINT,d) Fd(BOOL,PolyPolygon,HDC,a,LPPOINT,b,LPINT,c,int,d) Fd(BOOL,PostAppMessage,HANDLE,a,WORD,b,WORD,c,LONG,d) +Fd(BOOL,RedrawWindow,HWND,a,LPRECT,b,HRGN,c,UINT,d) Fd(BOOL,SetBitmapDimensionEx,HBITMAP,a,short,b,short,c,LPSIZE,d) Fd(BOOL,WinHelp,HWND,hwndMain,LPSTR,lpszHelp,WORD,usCommand,DWORD,ulData) Fd(BOOL,WritePrivateProfileString,LPSTR,a,LPSTR,b,LPSTR,c,LPSTR,d) diff --git a/include/wine.h b/include/wine.h index 7931c486c2c..13eee6158b2 100644 --- a/include/wine.h +++ b/include/wine.h @@ -63,4 +63,9 @@ struct sigcontext_struct { #define HZ 100 #endif +void load_mz_header (int, struct mz_header_s *); +void load_ne_header (int, struct ne_header_s *); +int load_typeinfo (int, struct resource_typeinfo_s *); +int load_nameinfo (int, struct resource_nameinfo_s *); + #endif /* WINE_H */ diff --git a/include/winsock.h b/include/winsock.h new file mode 100644 index 00000000000..6b83e52ab82 --- /dev/null +++ b/include/winsock.h @@ -0,0 +1,367 @@ +/* WINSOCK.H--definitions to be used with the WINSOCK.DLL + * + * This header file corresponds to version 1.1 of the Windows Sockets + * specification. + */ + +#ifndef _WINSOCKAPI_ +#define _WINSOCKAPI_ + +#include +#include +#include +#include +#include +#include +#include + +/* + * The new type to be used in all + * instances which refer to sockets. + */ +typedef u_int SOCKET; + +extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *); + +/* + * Internet address (old style... should be updated) + */ +#define s_addr S_un.S_addr /* can be used for most tcp & ip code */ +#define s_host S_un.S_un_b.s_b2 /* host on imp */ +#define s_net S_un.S_un_b.s_b1 /* network */ +#define s_imp S_un.S_un_w.s_w2 /* imp */ +#define s_impno S_un.S_un_b.s_b4 /* imp # */ +#define s_lh S_un.S_un_b.s_b3 /* logical host */ + +#define WSADESCRIPTION_LEN 256 +#define WSASYS_STATUS_LEN 128 + +typedef struct WSAData { + WORD wVersion; + WORD wHighVersion; + char szDescription[WSADESCRIPTION_LEN+1]; + char szSystemStatus[WSASYS_STATUS_LEN+1]; + unsigned short iMaxSockets; + unsigned short iMaxUdpDg; + char FAR * lpVendorInfo; +} WSADATA; + +typedef WSADATA FAR *LPWSADATA; + +/* + * This is used instead of -1, since the + * SOCKET type is unsigned. + */ +#define INVALID_SOCKET (SOCKET)(~0) +#define SOCKET_ERROR (-1) + +/* + * Option flags per-socket. + */ +#ifndef SO_DONTLINGER +#define SO_DONTLINGER (u_int)(~SO_LINGER) +#endif + +#ifndef _SYS_SOCKET_H_ +/* + * Structure used by kernel to pass protocol + * information in raw sockets. + */ +struct sockproto { + u_short sp_family; /* address family */ + u_short sp_protocol; /* protocol */ +}; +#endif + +/* + * Maximum queue length specifiable by listen. + */ +#define SOMAXCONN 5 +#define MSG_DONTROUTE 0x4 /* send without using routing tables */ +#define MSG_MAXIOVLEN 16 + +/* + * Define constant based on rfc883, used by gethostbyxxxx() calls. + */ +#define MAXGETHOSTSTRUCT 1024 + +/* + * Define flags to be used with the WSAAsyncSelect() call. + */ +#define FD_READ 0x01 +#define FD_WRITE 0x02 +#define FD_OOB 0x04 +#define FD_ACCEPT 0x08 +#define FD_CONNECT 0x10 +#define FD_CLOSE 0x20 + +/* + * All Windows Sockets error constants are biased by WSABASEERR from + * the "normal" + */ +#define WSABASEERR 10000 +/* + * Windows Sockets definitions of regular Microsoft C error constants + */ +#define WSAEINTR (WSABASEERR+4) +#define WSAEBADF (WSABASEERR+9) +#define WSAEACCES (WSABASEERR+13) +#define WSAEFAULT (WSABASEERR+14) +#define WSAEINVAL (WSABASEERR+22) +#define WSAEMFILE (WSABASEERR+24) + +/* + * Windows Sockets definitions of regular Berkeley error constants + */ +#define WSAEWOULDBLOCK (WSABASEERR+35) +#define WSAEINPROGRESS (WSABASEERR+36) +#define WSAEALREADY (WSABASEERR+37) +#define WSAENOTSOCK (WSABASEERR+38) +#define WSAEDESTADDRREQ (WSABASEERR+39) +#define WSAEMSGSIZE (WSABASEERR+40) +#define WSAEPROTOTYPE (WSABASEERR+41) +#define WSAENOPROTOOPT (WSABASEERR+42) +#define WSAEPROTONOSUPPORT (WSABASEERR+43) +#define WSAESOCKTNOSUPPORT (WSABASEERR+44) +#define WSAEOPNOTSUPP (WSABASEERR+45) +#define WSAEPFNOSUPPORT (WSABASEERR+46) +#define WSAEAFNOSUPPORT (WSABASEERR+47) +#define WSAEADDRINUSE (WSABASEERR+48) +#define WSAEADDRNOTAVAIL (WSABASEERR+49) +#define WSAENETDOWN (WSABASEERR+50) +#define WSAENETUNREACH (WSABASEERR+51) +#define WSAENETRESET (WSABASEERR+52) +#define WSAECONNABORTED (WSABASEERR+53) +#define WSAECONNRESET (WSABASEERR+54) +#define WSAENOBUFS (WSABASEERR+55) +#define WSAEISCONN (WSABASEERR+56) +#define WSAENOTCONN (WSABASEERR+57) +#define WSAESHUTDOWN (WSABASEERR+58) +#define WSAETOOMANYREFS (WSABASEERR+59) +#define WSAETIMEDOUT (WSABASEERR+60) +#define WSAECONNREFUSED (WSABASEERR+61) +#define WSAELOOP (WSABASEERR+62) +#define WSAENAMETOOLONG (WSABASEERR+63) +#define WSAEHOSTDOWN (WSABASEERR+64) +#define WSAEHOSTUNREACH (WSABASEERR+65) +#define WSAENOTEMPTY (WSABASEERR+66) +#define WSAEPROCLIM (WSABASEERR+67) +#define WSAEUSERS (WSABASEERR+68) +#define WSAEDQUOT (WSABASEERR+69) +#define WSAESTALE (WSABASEERR+70) +#define WSAEREMOTE (WSABASEERR+71) + +/* + * Extended Windows Sockets error constant definitions + */ +#define WSASYSNOTREADY (WSABASEERR+91) +#define WSAVERNOTSUPPORTED (WSABASEERR+92) +#define WSANOTINITIALISED (WSABASEERR+93) + +/* + * Error return codes from gethostbyname() and gethostbyaddr() + * (when using the resolver). Note that these errors are + * retrieved via WSAGetLastError() and must therefore follow + * the rules for avoiding clashes with error numbers from + * specific implementations or language run-time systems. + * For this reason the codes are based at WSABASEERR+1001. + * Note also that [WSA]NO_ADDRESS is defined only for + * compatibility purposes. + */ + +#define h_errno WSAGetLastError() + +/* Authoritative Answer: Host not found */ +#define WSAHOST_NOT_FOUND (WSABASEERR+1001) + +/* Non-Authoritative: Host not found, or SERVERFAIL */ +#define WSATRY_AGAIN (WSABASEERR+1002) + +/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ +#define WSANO_RECOVERY (WSABASEERR+1003) + +/* Valid name, no data record of requested type */ +#define WSANO_DATA (WSABASEERR+1004) + +/* no address, look for MX record */ +#define WSANO_ADDRESS WSANO_DATA + +/* + * Windows Sockets errors redefined as regular Berkeley error constants + + * AAARGH! * + +#define EWOULDBLOCK WSAEWOULDBLOCK +#define EINPROGRESS WSAEINPROGRESS +#define EALREADY WSAEALREADY +#define ENOTSOCK WSAENOTSOCK +#define EDESTADDRREQ WSAEDESTADDRREQ +#define EMSGSIZE WSAEMSGSIZE +#define EPROTOTYPE WSAEPROTOTYPE +#define ENOPROTOOPT WSAENOPROTOOPT +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +#define EOPNOTSUPP WSAEOPNOTSUPP +#define EPFNOSUPPORT WSAEPFNOSUPPORT +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#define EADDRINUSE WSAEADDRINUSE +#define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#define ENETDOWN WSAENETDOWN +#define ENETUNREACH WSAENETUNREACH +#define ENETRESET WSAENETRESET +#define ECONNABORTED WSAECONNABORTED +#define ECONNRESET WSAECONNRESET +#define ENOBUFS WSAENOBUFS +#define EISCONN WSAEISCONN +#define ENOTCONN WSAENOTCONN +#define ESHUTDOWN WSAESHUTDOWN +#define ETOOMANYREFS WSAETOOMANYREFS +#define ETIMEDOUT WSAETIMEDOUT +#define ECONNREFUSED WSAECONNREFUSED +#define ELOOP WSAELOOP +#define ENAMETOOLONG WSAENAMETOOLONG +#define EHOSTDOWN WSAEHOSTDOWN +#define EHOSTUNREACH WSAEHOSTUNREACH +#define ENOTEMPTY WSAENOTEMPTY +#define EPROCLIM WSAEPROCLIM +#define EUSERS WSAEUSERS +#define EDQUOT WSAEDQUOT +#define ESTALE WSAESTALE +#define EREMOTE WSAEREMOTE + +*/ + +/* Socket function prototypes */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Microsoft Windows Extension function prototypes */ + +int PASCAL FAR WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData); + +int PASCAL FAR WSACleanup(void); + +void PASCAL FAR WSASetLastError(int iError); + +int PASCAL FAR WSAGetLastError(void); + +BOOL PASCAL FAR WSAIsBlocking(void); + +int PASCAL FAR WSAUnhookBlockingHook(void); + +FARPROC PASCAL FAR WSASetBlockingHook(FARPROC lpBlockFunc); + +int PASCAL FAR WSACancelBlockingCall(void); + +HANDLE PASCAL FAR WSAAsyncGetServByName(HWND hWnd, u_int wMsg, + const char FAR * name, + const char FAR * proto, + char FAR * buf, int buflen); + +HANDLE PASCAL FAR WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port, + const char FAR * proto, char FAR * buf, + int buflen); + +HANDLE PASCAL FAR WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, + const char FAR * name, char FAR * buf, + int buflen); + +HANDLE PASCAL FAR WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, + int number, char FAR * buf, + int buflen); + +HANDLE PASCAL FAR WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, + const char FAR * name, char FAR * buf, + int buflen); + +HANDLE PASCAL FAR WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, + const char FAR * addr, int len, int type, + const char FAR * buf, int buflen); + +int PASCAL FAR WSACancelAsyncRequest(HANDLE hAsyncTaskHandle); + +int PASCAL FAR WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, + long lEvent); + +#ifdef __cplusplus +} +#endif + +/* Microsoft Windows Extended data types */ +typedef struct sockaddr SOCKADDR; +typedef struct sockaddr *PSOCKADDR; +typedef struct sockaddr FAR *LPSOCKADDR; + +typedef struct sockaddr_in SOCKADDR_IN; +typedef struct sockaddr_in *PSOCKADDR_IN; +typedef struct sockaddr_in FAR *LPSOCKADDR_IN; + +typedef struct linger LINGER; +typedef struct linger *PLINGER; +typedef struct linger FAR *LPLINGER; + +typedef struct in_addr IN_ADDR; +typedef struct in_addr *PIN_ADDR; +typedef struct in_addr FAR *LPIN_ADDR; + +typedef struct fd_set FD_SET; +typedef struct fd_set *PFD_SET; +typedef struct fd_set FAR *LPFD_SET; + +typedef struct hostent HOSTENT; +typedef struct hostent *PHOSTENT; +typedef struct hostent FAR *LPHOSTENT; + +typedef struct servent SERVENT; +typedef struct servent *PSERVENT; +typedef struct servent FAR *LPSERVENT; + +typedef struct protoent PROTOENT; +typedef struct protoent *PPROTOENT; +typedef struct protoent FAR *LPPROTOENT; + +typedef struct timeval TIMEVAL; +typedef struct timeval *PTIMEVAL; +typedef struct timeval FAR *LPTIMEVAL; + +/* + * Windows message parameter composition and decomposition + * macros. + * + * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation + * when constructing the response to a WSAAsyncGetXByY() routine. + */ +#define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error) +/* + * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation + * when constructing the response to WSAAsyncSelect(). + */ +#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error) +/* + * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application + * to extract the buffer length from the lParam in the response + * to a WSAGetXByY(). + */ +#define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam) +/* + * WSAGETASYNCERROR is intended for use by the Windows Sockets application + * to extract the error code from the lParam in the response + * to a WSAGetXByY(). + */ +#define WSAGETASYNCERROR(lParam) HIWORD(lParam) +/* + * WSAGETSELECTEVENT is intended for use by the Windows Sockets application + * to extract the event code from the lParam in the response + * to a WSAAsyncSelect(). + */ +#define WSAGETSELECTEVENT(lParam) LOWORD(lParam) +/* + * WSAGETSELECTERROR is intended for use by the Windows Sockets application + * to extract the error code from the lParam in the response + * to a WSAAsyncSelect(). + */ +#define WSAGETSELECTERROR(lParam) HIWORD(lParam) + +#endif /* _WINSOCKAPI_ */ diff --git a/loader/Imakefile b/loader/Imakefile index f83143548f9..7c9ddeb670d 100644 --- a/loader/Imakefile +++ b/loader/Imakefile @@ -3,32 +3,15 @@ MODULE = loader SRCS = \ - int1a.c \ - int21.c \ dump.c \ - files.c \ ldt.c \ ldtlib.c \ - resource.c \ selector.c \ signal.c \ library.c \ - wine.c \ - cursor.c + wine.c -OBJS = \ - int1a.o \ - int21.o \ - dump.o \ - files.o \ - ldt.o \ - ldtlib.o \ - resource.o \ - selector.o \ - signal.o \ - library.o \ - wine.o \ - cursor.o +OBJS = $(SRCS:.c=.o) WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) DependTarget() diff --git a/loader/Makefile b/loader/Makefile deleted file mode 100644 index 083d8f68a65..00000000000 --- a/loader/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CFLAGS=$(COPTS) $(DEBUGOPTS) -I../include - -OBJS=dump.o ldt.o ldtlib.o resource.o selector.o signal.o library.o \ - wine.o cursor.o - -default: loader.o - -loader.o: $(OBJS) - $(LD) -r -o loader.o $(OBJS) - -clean: - rm -f *.o *~ *.s dll_* *.a *# - -depend: - $(CC) $(CFLAGS) -M *.c > .depend - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/loader/ldtlib.c b/loader/ldtlib.c index 76924fe6b37..d3610407d66 100644 --- a/loader/ldtlib.c +++ b/loader/ldtlib.c @@ -79,9 +79,13 @@ set_ldt_entry(int entry, unsigned long base, unsigned int limit, sd = make_sd(base, limit, contents, read_only_flag, seg_32bit_flag, limit_in_pages_flag); ret = i386_set_ldt(entry, (union descriptor *)sd, 1); - if (ret < 0) + if (ret < 0) { perror("i386_set_ldt"); - + fprintf(stderr, + "Did you reconfigure the kernel with \"options USER_LDT\"?\n"); + exit(1); + } + return ret; #endif diff --git a/loader/library.c b/loader/library.c index fe7813e26e3..ebb91fec64a 100644 --- a/loader/library.c +++ b/loader/library.c @@ -1,4 +1,3 @@ - #include #include #include @@ -7,10 +6,72 @@ #include #include "prototypes.h" #include "windows.h" -#include "win.h" -#include "gdi.h" #include "wine.h" +#include "dlls.h" +extern struct w_files * wine_files; + + +/********************************************************************** + * GetCurrentTask [KERNEL.36] + */ +HTASK GetCurrentTask() +{ + int pid = getpid(); + printf("GetCurrentTask() returned %d !\n", pid); + return pid; +} + + +/********************************************************************** + * GetModuleHandle [KERNEL.47] + */ +HANDLE GetModuleHandle(LPSTR lpModuleName) +{ + register struct w_files *w = wine_files; + printf("GetModuleHandle('%s');\n", lpModuleName); + while (w) { + printf("GetModuleHandle // '%s' \n", w->name); + if (strcmp(w->name, lpModuleName) == 0) { + printf("GetModuleHandle('%s') return %04X \n", + lpModuleName, w->hinstance); + return w->hinstance; + } + w = w->next; + } + printf("GetModuleHandle('%s') not found !\n", lpModuleName); + return 0; +} + + +/********************************************************************** + * GetModuleUsage [KERNEL.48] + */ +int GetModuleUsage(HANDLE hModule) +{ + struct w_files *w; + printf("GetModuleUsage(%04X);\n", hModule); + w = GetFileInfo(hModule); +/* return w->Usage; */ + return 1; +} + + +/********************************************************************** + * GetModuleFilename [KERNEL.49] + */ +int GetModuleFileName(HANDLE hModule, LPSTR lpFileName, short nSize) +{ + struct w_files *w; + printf("GetModuleFileName(%04X, %08X, %d);\n", hModule, lpFileName, nSize); + if (lpFileName == NULL) return 0; + w = GetFileInfo(hModule); + if (w == NULL) return 0; + if (nSize > strlen(w->name)) nSize = strlen(w->name) + 1; + strncpy(lpFileName, w->name, nSize); + printf("GetModuleFileName copied '%s' return %d \n", lpFileName, nSize); + return nSize - 1; +} /********************************************************************** @@ -20,7 +81,7 @@ HANDLE LoadLibrary(LPSTR libname) { HANDLE hRet; printf("LoadLibrary '%s'\n", libname); - hRet = LoadImage(libname); + hRet = LoadImage(libname, DLL); printf("after LoadLibrary hRet=%04X\n", hRet); return hRet; } @@ -35,3 +96,4 @@ void FreeLibrary(HANDLE hLib) if (hLib != (HANDLE)NULL) GlobalFree(hLib); } + diff --git a/loader/selector.c b/loader/selector.c index 76c66ba37d7..bea1886e594 100644 --- a/loader/selector.c +++ b/loader/selector.c @@ -585,7 +585,7 @@ unsigned int GetEntryDLLName(char * dll_name, char * function, int * sel, j = GetEntryPointFromOrdinal(wpnt, ordinal); *addr = j & 0xffff; j = j >> 16; - *sel = wpnt->selector_table[j].selector; + *sel = j; return 0; }; return 1; @@ -615,12 +615,7 @@ unsigned int GetEntryDLLOrdinal(char * dll_name, int ordinal, int * sel, j = GetEntryPointFromOrdinal(wpnt, ordinal); *addr = j & 0xffff; j = j >> 16; -#if 0 - /* This seems like it would never work */ - *sel = wpnt->selector_table[j].selector; -#else - *sel = j; /* Is there any reason this will ever fail?? */ -#endif + *sel = j; return 0; }; return 1; diff --git a/loader/wine.c b/loader/wine.c index 11aed625aa8..26936da4ebd 100644 --- a/loader/wine.c +++ b/loader/wine.c @@ -22,6 +22,7 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include "wine.h" #include "windows.h" #include "wineopts.h" +#include "arch.h" /* #define DEBUG_FIXUP */ @@ -46,21 +47,12 @@ struct ne_header_s *CurrentNEHeader; int CurrentNEFile; HINSTANCE hSysRes; -static char *Extensions[] = { "dll", "exe", NULL }; +static char *DLL_Extensions[] = { "dll", "exe", NULL }; +static char *EXE_Extensions[] = { "exe", NULL }; static char *WinePath = NULL; FILE *SpyFp = NULL; -/********************************************************************** - * DebugPrintString - */ -int -DebugPrintString(char *str) -{ - printf("%s", str); - return 0; -} - /********************************************************************** * myerror */ @@ -103,11 +95,35 @@ GetFileInfo(unsigned short instance) return w; } +#ifndef WINELIB +/********************************************************************** + * + * Load MZ Header + */ +void load_mz_header(int fd, struct mz_header_s *mz_header) +{ + if (read(fd, mz_header, sizeof(struct mz_header_s)) != + sizeof(struct mz_header_s)) + { + myerror("Unable to read MZ header from file"); + } +} + +void load_ne_header (int fd, struct ne_header_s *ne_header) +{ + if (read(fd, ne_header, sizeof(struct ne_header_s)) + != sizeof(struct ne_header_s)) + { + myerror("Unable to read NE header from file"); + } +} +#endif + /********************************************************************** * LoadImage * Load one NE format executable into memory */ -HINSTANCE LoadImage(char *modulename) +HINSTANCE LoadImage(char *modulename, int filetype) { unsigned int read_size; int i; @@ -118,11 +134,9 @@ HINSTANCE LoadImage(char *modulename) /* * search file */ - if (FindFile(buffer, sizeof(buffer), modulename, Extensions, WindowsPath) - ==NULL) + if (FindFile(buffer, sizeof(buffer), modulename, (filetype == EXE ? + EXE_Extensions : DLL_Extensions), WindowsPath) ==NULL) { - - fprintf(stderr,"LoadImage: I can't find %s !\n",modulename); return (HINSTANCE) NULL; } @@ -159,21 +173,13 @@ HINSTANCE LoadImage(char *modulename) wpnt->mz_header = (struct mz_header_s *) malloc(sizeof(struct mz_header_s));; status = lseek(wpnt->fd, 0, SEEK_SET); - if (read(wpnt->fd, wpnt->mz_header, sizeof(struct mz_header_s)) != - sizeof(struct mz_header_s)) - { - myerror("Unable to read MZ header from file"); - } + load_mz_header (wpnt->fd, wpnt->mz_header); if (wpnt->mz_header->must_be_0x40 != 0x40) myerror("This is not a Windows program"); wpnt->ne_header = (struct ne_header_s *) malloc(sizeof(struct ne_header_s)); status = lseek(wpnt->fd, wpnt->mz_header->ne_offset, SEEK_SET); - if (read(wpnt->fd, wpnt->ne_header, sizeof(struct ne_header_s)) - != sizeof(struct ne_header_s)) - { - myerror("Unable to read NE header from file"); - } + load_ne_header (wpnt->fd, wpnt->ne_header); if (wpnt->ne_header->header_type[0] != 'N' || wpnt->ne_header->header_type[1] != 'E') myerror("This is not a Windows program"); @@ -190,6 +196,7 @@ HINSTANCE LoadImage(char *modulename) /* * Create segment selectors. */ +#ifndef WINELIB status = lseek(wpnt->fd, wpnt->mz_header->ne_offset + wpnt->ne_header->segment_tab_offset, SEEK_SET); @@ -235,7 +242,7 @@ HINSTANCE LoadImage(char *modulename) wpnt->name = (char*) malloc(*wpnt->rname_table + 1); memcpy(wpnt->name, wpnt->rname_table+1, *wpnt->rname_table); wpnt->name[*wpnt->rname_table] = 0; - +#endif /* * Now load any DLLs that this module refers to. */ @@ -245,9 +252,11 @@ HINSTANCE LoadImage(char *modulename) int fd, j; GetModuleName(wpnt, i + 1, buff); +#ifndef WINELIB if(FindDLLTable(buff)) continue; /* This module already loaded */ +#endif - LoadImage(buff); + LoadImage(buff, DLL); /* fprintf(stderr,"Unable to load:%s\n", buff); */ @@ -255,31 +264,6 @@ HINSTANCE LoadImage(char *modulename) return(wpnt->hinstance); } -/********************************************************************** - * ParseArgs - */ -void -ParseArgs(int argc, char **argv) -{ - if (argc < 2) - { - fprintf(stderr, "usage: %s [-spy FILENAME] FILENAME\n", argv[0]); - exit(1); - } - - Argc = argc - 1; - - for (Argv = argv + 1; **Argv == '-' && Argc > 0; Argv++) - { - if (strcmp(*Argv, "-spy") == 0) - { - if (strcmp(*(++Argv), "-") == 0) - SpyFp = stdout; - else - SpyFp = fopen(*Argv, "a"); - } - } -} /********************************************************************** * main @@ -300,22 +284,29 @@ _WinMain(int argc, char **argv) int i; int rv; - ParseArgs(argc, argv); - - p = getenv("WINEPATH"); - WinePath = malloc(256 + strlen(p)); - getcwd(WinePath, 256); - strcat(WinePath, ";"); - strcat(WinePath, p); - - LoadImage(Argv[0]); + Argc = argc - 1; + Argv = argv + 1; + + WinePath = malloc(1024); + + getcwd(WinePath, 512); + + if ((p = getenv("WINEPATH")) != NULL) { + strcat(WinePath, ";"); + strcat(WinePath, p); + } + + if (LoadImage(Argv[0], EXE) == (HINSTANCE) NULL ) { + fprintf(stderr, "wine: can't find %s!.\n", Argv[0]); + exit(1); + } GetPrivateProfileString("wine", "SystemResources", "sysres.dll", - filename, sizeof(filename), - WINE_INI); - hSysRes = LoadImage(filename); + filename, sizeof(filename), WINE_INI); + + hSysRes = LoadImage(filename, DLL); if (hSysRes == (HINSTANCE)NULL) - printf("Error Loading System Resources !!!\n"); + fprintf(stderr, "wine: can't find %s!.\n", filename); else printf("System Resources Loaded // hSysRes='%04X'\n", hSysRes); @@ -324,22 +315,15 @@ _WinMain(int argc, char **argv) */ wpnt = wine_files; for(wpnt = wine_files; wpnt; wpnt = wpnt->next) - for (segment = 0; segment < wpnt->ne_header->n_segment_tab; segment++) + { + for (segment = 0; segment < wpnt->ne_header->n_segment_tab; segment++) { - if (FixupSegment(wpnt, segment) < 0) + if (FixupSegment(wpnt, segment) < 0) { - myerror("fixup failed."); + myerror("fixup failed."); } } - - /* - * Fixup stack and jump to start. - */ - ds_reg = wine_files->selector_table[wine_files->ne_header->auto_data_seg-1].selector; - cs_reg = wine_files->selector_table[wine_files->ne_header->cs-1].selector; - ip_reg = wine_files->ne_header->ip; - ss_reg = wine_files->selector_table[wine_files->ne_header->ss-1].selector; - sp_reg = wine_files->ne_header->sp; + } #ifdef WINESTAT cp = strrchr(argv[0], '/'); @@ -351,27 +335,65 @@ _WinMain(int argc, char **argv) }; #endif + /* + * Initialize signal handling. + */ init_wine_signals(); - if (WineForceFail) - { - p = (char *) ((cs_reg << 16) | ip_reg); - - *p++ = 0xcd; - *p++ = 0x20; - } - - if (ss_reg == 0) - { - fprintf(stderr, "SS is 0\n"); - } - - LinearTest(); + /* + * Fixup stack and jump to start. + */ + ds_reg = (wine_files-> + selector_table[wine_files->ne_header->auto_data_seg-1].selector); + cs_reg = wine_files->selector_table[wine_files->ne_header->cs-1].selector; + ip_reg = wine_files->ne_header->ip; + ss_reg = wine_files->selector_table[wine_files->ne_header->ss-1].selector; + sp_reg = wine_files->ne_header->sp; rv = CallToInit16(cs_reg << 16 | ip_reg, ss_reg << 16 | sp_reg, ds_reg); printf ("rv = %x\n", rv); } +void InitializeLoadedDLLs() +{ + struct w_files * wpnt; + int cs_reg, ds_reg, ip_reg; + int rv; + + fprintf(stderr, "Initializing DLLs\n"); + + /* + * Initialize libraries + */ + wpnt = wine_files; + for(wpnt = wine_files; wpnt; wpnt = wpnt->next) + { + /* + * Is this a library? + */ + if (wpnt->ne_header->format_flags & 0x8000) + { + if (!(wpnt->ne_header->format_flags & 0x0001)) + { + /* Not SINGLEDATA */ + fprintf(stderr, "Library is not marked SINGLEDATA\n"); + exit(1); + } + + ds_reg = wpnt->selector_table[wpnt-> + ne_header->auto_data_seg-1].selector; + cs_reg = wpnt->selector_table[wpnt->ne_header->cs-1].selector; + ip_reg = wpnt->ne_header->ip; + + fprintf(stderr, "Initializing %s, cs:ip %04x:%04x, ds %04x\n", + wpnt->name, cs_reg, ip_reg, ds_reg); + + rv = CallTo16(cs_reg << 16 | ip_reg, ds_reg); + printf ("rv = %x\n", rv); + } + } +} + /********************************************************************** * GetImportedName @@ -389,6 +411,7 @@ GetImportedName(int fd, struct mz_header_s *mz_header, name_offset, SEEK_SET); length = 0; read(fd, &length, 1); /* Get the length byte */ + length = CONV_CHAR_TO_LONG (length); read(fd, buffer, length); buffer[length] = 0; return buffer; @@ -405,17 +428,19 @@ GetModuleName(struct w_files * wpnt, int index, char *buffer) struct ne_header_s *ne_header = wpnt->ne_header; char *p; int length; - int name_offset, status; + WORD name_offset, status; int i; status = lseek(fd, mz_header->ne_offset + ne_header->moduleref_tab_offset + 2*(index - 1), SEEK_SET); name_offset = 0; read(fd, &name_offset, 2); + name_offset = CONV_SHORT (name_offset); status = lseek(fd, mz_header->ne_offset + ne_header->iname_tab_offset + name_offset, SEEK_SET); length = 0; read(fd, &length, 1); /* Get the length byte */ + length = CONV_CHAR_TO_LONG (length); read(fd, buffer, length); buffer[length] = 0; @@ -427,6 +452,7 @@ GetModuleName(struct w_files * wpnt, int index, char *buffer) } +#ifndef WINELIB /********************************************************************** * FixupSegment */ @@ -700,3 +726,4 @@ FARPROC GetProcAddress(HINSTANCE hinstance, char *proc_name) return NULL; } +#endif diff --git a/memory/Imakefile b/memory/Imakefile index edf4b6d5604..57b61f27d31 100644 --- a/memory/Imakefile +++ b/memory/Imakefile @@ -5,12 +5,9 @@ MODULE = memory SRCS = \ global.c \ heap.c \ - atom.c + linear.c -OBJS = \ - global.o \ - heap.o \ - atom.o +OBJS = $(SRCS:.c=.o) WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) DependTarget() diff --git a/memory/Makefile b/memory/Makefile deleted file mode 100644 index d9abf4c3a5c..00000000000 --- a/memory/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR) - -OBJS=global.o heap.o atom.o linear.o - -default: memory.o - -memory.o: $(OBJS) - $(LD) -r -o memory.o $(OBJS) - -clean: - rm -f *.o *~ *.s dll_* *.a *# - -depend: - $(CC) $(CFLAGS) -M *.c > .depend - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/memory/heap.c b/memory/heap.c index 252f5fb90bf..18f50a4c7dd 100644 --- a/memory/heap.c +++ b/memory/heap.c @@ -138,8 +138,8 @@ HEAP_ReAlloc(MDESC **free_list, void *old_block, if (new_size > m->length) { m_free = m + 1 + m->length / sizeof(MDESC); - if (m_free->next != m_free || - m_free->prev != m_free || + if (m_free->next == m_free || + m_free->prev == m_free || m_free->length + sizeof(MDESC) < new_size) { void *new_p = HEAP_Alloc(free_list, flags, new_size); @@ -284,7 +284,7 @@ HEAP_Free(MDESC **free_list, void *block) /********************************************************************** * HEAP_LocalFindHeap */ -MDESC ** +LHEAP * HEAP_LocalFindHeap(unsigned short owner) { LHEAP *lh; @@ -296,13 +296,13 @@ HEAP_LocalFindHeap(unsigned short owner) for (lh = LocalHeaps; lh != NULL; lh = lh->next) { if (lh->selector == owner) - return &lh->free_list; + return lh; } return NULL; } -#define LOCALHEAP() HEAP_LocalFindHeap(Segments[Stack16Frame[11] >> 3].owner) +#define LOCALHEAP() (&HEAP_LocalFindHeap(Segments[Stack16Frame[11] >> 3].owner)->free_list) /********************************************************************** * HEAP_LocalInit @@ -402,8 +402,25 @@ LocalFree(unsigned int handle) unsigned int LocalInit(unsigned int segment, unsigned int start, unsigned int end) { - HEAP_Init(LOCALHEAP(), - (void *) ((segment << 16) | start), end - start + 1); + unsigned short owner = Segments[Stack16Frame[11] >> 3].owner; + LHEAP *lh = HEAP_LocalFindHeap(owner); + + if (segment == 0) + { + /* Get current DS */ + segment = Stack16Frame[6]; + } + + if (lh == NULL) + { + HEAP_LocalInit(owner, + (void *) ((segment << 16) | start), end - start + 1); + } + else + { + HEAP_Init(&lh->free_list, + (void *) ((segment << 16) | start), end - start + 1); + } return segment; } diff --git a/misc/Imakefile b/misc/Imakefile index b628e2e5a6f..43ee484af2b 100644 --- a/misc/Imakefile +++ b/misc/Imakefile @@ -3,46 +3,26 @@ MODULE = misc SRCS = \ + atom.c \ + clipboard.c \ comm.c \ - dos.c \ + cursor.c \ dos_fs.c \ - emulate.c \ exec.c \ file.c \ - int1a.c \ - int21.c \ - kernel.c \ keyboard.c \ lstr.c \ main.c \ message.c \ profile.c \ rect.c \ + resource.c \ sound.c \ spy.c \ user.c \ - xt.c + winsocket.c -OBJS = \ - comm.o \ - dos.o \ - dos_fs.o \ - emulate.o \ - exec.o \ - file.o \ - int1a.o \ - int21.o \ - kernel.o \ - keyboard.o \ - lstr.o \ - main.o \ - message.o \ - profile.o \ - rect.o \ - sound.o \ - spy.o \ - user.o \ - xt.o +OBJS = $(SRCS:.c=.o) WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) DependTarget() diff --git a/misc/Makefile b/misc/Makefile deleted file mode 100644 index f72ab80c637..00000000000 --- a/misc/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -CFLAGS=$(COPTS) $(DEBUGOPTS) -I../include - -OBJS=main.o kernel.o user.o rect.o file.o sound.o emulate.o \ - keyboard.o profile.o lstr.o exec.o message.o int1a.o int21.o \ - dos_fs.o comm.o spy.o - -default: misc.o - -misc.o: $(OBJS) - $(LD) -r -o misc.o $(OBJS) - -clean: - rm -f *.o *~ *.s dll_* *.a *# - -depend: - $(CC) $(CFLAGS) -M *.c > .depend - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/memory/atom.c b/misc/atom.c similarity index 94% rename from memory/atom.c rename to misc/atom.c index ad0345e8985..79db3b9b092 100644 --- a/memory/atom.c +++ b/misc/atom.c @@ -22,12 +22,19 @@ * because they can't generally be differentiated from string constants * located below 0x10000 in the emulation library. If you need * integer atoms, use the "#1234" form. + * + * 13/Feb, miguel + * Changed the calls to LocalAlloc to LocalAlign. When compiling WINELIB + * you call a special version of LocalAlloc that would do the alignement. + * When compiling the emulator we depend on LocalAlloc returning the + * aligned block. Needed to test the Library. */ #include #include #include +#include "user.h" #include "atom.h" @@ -50,7 +57,7 @@ static BOOL ATOM_InitTable( ATOMTABLE ** table, WORD entries ) int i; HANDLE handle; - handle = LocalAlloc( LMEM_MOVEABLE, sizeof(ATOMTABLE) + + handle = LocalAlign ( LMEM_MOVEABLE, sizeof(ATOMTABLE) + (entries-1) * sizeof(HANDLE) ); if (!handle) return FALSE; *table = (ATOMTABLE *) LocalLock( handle ); @@ -126,7 +133,7 @@ static ATOM ATOM_AddAtom( ATOMTABLE * table, LPCSTR str ) entry = entryPtr->next; } - entry = (int)LocalAlloc( LMEM_MOVEABLE, sizeof(ATOMENTRY)+len-1 ) & 0xffff; + entry = (int)LocalAlign( LMEM_MOVEABLE, sizeof(ATOMENTRY)+len-1 ) & 0xffff; if (!entry) return 0; entryPtr = ATOM_MakePtr( table, entry ); entryPtr->next = table->entries[hash]; @@ -166,7 +173,7 @@ static ATOM ATOM_DeleteAtom( ATOMTABLE * table, ATOM atom ) if (--entryPtr->refCount == 0) { *prevEntry = entryPtr->next; - LocalFree( entry ); + USER_HEAP_FREE( entry ); } return 0; } diff --git a/misc/clipboard.c b/misc/clipboard.c new file mode 100644 index 00000000000..f62d083837c --- /dev/null +++ b/misc/clipboard.c @@ -0,0 +1,350 @@ +/* + * 'Wine' Clipboard function handling + * + * Copyright 1994 Martin Ayotte + */ + +static char Copyright[] = "Copyright Martin Ayotte, 1994"; + +/* +#define DEBUG_CLIPBOARD +*/ + +#include +#include +#include +#include +#include +#include "prototypes.h" +#include "heap.h" +#include "win.h" + +typedef struct tagCLIPFORMAT { + WORD wFormatID; + WORD wRefCount; + LPSTR Name; + HANDLE hData; + DWORD BufSize; + void *PrevFormat; + void *NextFormat; +} CLIPFORMAT; +typedef CLIPFORMAT FAR* LPCLIPFORMAT; + +static HWND hWndClipboardOwner = 0; +static HWND hWndViewer = 0; +static WORD LastRegFormat = 0xC000; + +CLIPFORMAT ClipFormats[12] = { + { CF_TEXT, 1, "Text", (HANDLE)NULL, 0, NULL, &ClipFormats[1] }, + { CF_BITMAP, 1, "Bitmap", (HANDLE)NULL, 0, &ClipFormats[0], &ClipFormats[2] }, + { CF_METAFILEPICT, 1, "MetaFile Picture", (HANDLE)NULL, 0, &ClipFormats[1], &ClipFormats[3] }, + { CF_SYLK, 1, "Sylk", (HANDLE)NULL, 0, &ClipFormats[2], &ClipFormats[4] }, + { CF_DIF, 1, "DIF", (HANDLE)NULL, 0, &ClipFormats[3], &ClipFormats[5] }, + { CF_TIFF, 1, "TIFF", (HANDLE)NULL, 0, &ClipFormats[4], &ClipFormats[6] }, + { CF_OEMTEXT, 1, "OEM Text", (HANDLE)NULL, 0, &ClipFormats[5], &ClipFormats[7] }, + { CF_DIB, 1, "DIB", (HANDLE)NULL, 0, &ClipFormats[6], &ClipFormats[8] }, + { CF_PALETTE, 1, "Palette", (HANDLE)NULL, 0, &ClipFormats[7], &ClipFormats[9] }, + { CF_PENDATA, 1, "PenData", (HANDLE)NULL, 0, &ClipFormats[8], &ClipFormats[10] }, + { CF_RIFF, 1, "RIFF", (HANDLE)NULL, 0, &ClipFormats[9], &ClipFormats[11] }, + { CF_WAVE, 1, "Wave", (HANDLE)NULL, 0, &ClipFormats[10], NULL } + }; + +/************************************************************************** + * OpenClipboard [USER.137] + */ +BOOL OpenClipboard(HWND hWnd) +{ + if (hWndClipboardOwner != 0) return FALSE; + hWndClipboardOwner = hWnd; +#ifdef DEBUG_CLIPBOARD + printf("OpenClipboard(%04X); !\n", hWnd); +#endif + return TRUE; +} + + +/************************************************************************** + * CloseClipboard [USER.138] + */ +BOOL CloseClipboard() +{ + if (hWndClipboardOwner == 0) return FALSE; + hWndClipboardOwner = 0; +#ifdef DEBUG_CLIPBOARD + printf("CloseClipboard(); !\n"); +#endif + return TRUE; +} + + +/************************************************************************** + * EmptyClipboard [USER.139] + */ +BOOL EmptyClipboard() +{ + LPCLIPFORMAT lpFormat = ClipFormats; + if (hWndClipboardOwner == 0) return FALSE; +#ifdef DEBUG_CLIPBOARD + printf("EmptyClipboard(); !\n"); +#endif + while(TRUE) { + if (lpFormat == NULL) break; + if (lpFormat->hData != 0) { + GlobalFree(lpFormat->hData); + lpFormat->hData = 0; + } + lpFormat = lpFormat->NextFormat; + } + return TRUE; +} + + +/************************************************************************** + * GetClipboardOwner [USER.140] + */ +HWND GetClipboardOwner() +{ +#ifdef DEBUG_CLIPBOARD + printf("GetClipboardOwner() = %04X !\n", hWndClipboardOwner); +#endif + return hWndClipboardOwner; +} + + +/************************************************************************** + * SetClipboardData [USER.141] + */ +HANDLE SetClipboardData(WORD wFormat, HANDLE hData) +{ + LPCLIPFORMAT lpFormat = ClipFormats; +#ifdef DEBUG_CLIPBOARD + printf("SetClipboardDate(%04X, %04X) !\n", wFormat, hData); +#endif + while(TRUE) { + if (lpFormat == NULL) return 0; + if (lpFormat->wFormatID == wFormat) break; + lpFormat = lpFormat->NextFormat; + } + if (lpFormat->hData != 0) GlobalFree(lpFormat->hData); + lpFormat->hData = hData; + return lpFormat->hData; +} + + +/************************************************************************** + * GetClipboardData [USER.142] + */ +HANDLE GetClipboardData(WORD wFormat) +{ + LPCLIPFORMAT lpFormat = ClipFormats; +#ifdef DEBUG_CLIPBOARD + printf("GetClipboardData(%04X) !\n", wFormat); +#endif + while(TRUE) { + if (lpFormat == NULL) return 0; + if (lpFormat->wFormatID == wFormat) break; + lpFormat = lpFormat->NextFormat; + } + return lpFormat->hData; +} + + +/************************************************************************** + * CountClipboardFormats [USER.143] + */ +int CountClipboardFormats() +{ + int FormatCount = 0; + LPCLIPFORMAT lpFormat = ClipFormats; + while(TRUE) { + if (lpFormat == NULL) break; + if (lpFormat->hData != 0) { +#ifdef DEBUG_CLIPBOARD + printf("CountClipboardFormats // Find Not Empty (%04X) !\n", + lpFormat->hData); +#endif + FormatCount++; + } + lpFormat = lpFormat->NextFormat; + } +#ifdef DEBUG_CLIPBOARD + printf("CountClipboardFormats() = %d !\n", FormatCount); +#endif + return FormatCount; +} + + +/************************************************************************** + * EnumClipboardFormats [USER.144] + */ +WORD EnumClipboardFormats(WORD wFormat) +{ + LPCLIPFORMAT lpFormat = ClipFormats; +#ifdef DEBUG_CLIPBOARD + printf("EnumClipboardFormats(%04X) !\n", wFormat); +#endif + if (wFormat == 0) { + if (lpFormat->hData != 0) + return lpFormat->wFormatID; + else + wFormat = lpFormat->wFormatID; + } + while(TRUE) { + if (lpFormat == NULL) return 0; + if (lpFormat->wFormatID == wFormat) break; + lpFormat = lpFormat->NextFormat; + } +#ifdef DEBUG_CLIPBOARD + printf("EnumClipboardFormats // Find Last (%04X) !\n", + lpFormat->wFormatID); +#endif + lpFormat = lpFormat->NextFormat; + while(TRUE) { + if (lpFormat == NULL) return 0; + if (lpFormat->hData != 0) break; + lpFormat = lpFormat->NextFormat; + } +#ifdef DEBUG_CLIPBOARD + printf("EnumClipboardFormats // Find Not Empty Id=%04X hData=%04X !\n", + lpFormat->wFormatID, lpFormat->hData); +#endif + return lpFormat->wFormatID; +} + + +/************************************************************************** + * RegisterClipboardFormat [USER.145] + */ +WORD RegisterClipboardFormat(LPCSTR FormatName) +{ + LPCLIPFORMAT lpNewFormat; + LPCLIPFORMAT lpFormat = ClipFormats; + if (FormatName == NULL) return 0; + while(TRUE) { + if (lpFormat->NextFormat == NULL) break; + lpFormat = lpFormat->NextFormat; + } + lpNewFormat = (LPCLIPFORMAT)malloc(sizeof(CLIPFORMAT)); + if (lpNewFormat == NULL) return 0; + lpFormat->NextFormat = lpNewFormat; +#ifdef DEBUG_CLIPBOARD + printf("RegisterClipboardFormat('%s') !\n", FormatName); +#endif + lpNewFormat->wFormatID = LastRegFormat; + lpNewFormat->wRefCount = 1; + lpNewFormat->Name = (LPSTR)malloc(strlen(FormatName) + 1); + if (lpNewFormat->Name == NULL) { + free(lpNewFormat); + return 0; + } + strcpy(lpNewFormat->Name, FormatName); + lpNewFormat->hData = 0; + lpNewFormat->BufSize = 0; + lpNewFormat->PrevFormat = lpFormat; + lpNewFormat->NextFormat = NULL; + return LastRegFormat++; +} + + +/************************************************************************** + * GetClipboardFormatName [USER.146] + */ +int GetClipboardFormatName(WORD wFormat, LPSTR retStr, short maxlen) +{ + LPCLIPFORMAT lpFormat = ClipFormats; +#ifdef DEBUG_CLIPBOARD + printf("GetClipboardFormat(%04X, %08X, %d) !\n", wFormat, retStr, maxlen); +#endif + while(TRUE) { + if (lpFormat == NULL) return 0; + if (lpFormat->wFormatID == wFormat) break; + lpFormat = lpFormat->NextFormat; + } + if (lpFormat->Name == NULL) return 0; +#ifdef DEBUG_CLIPBOARD + printf("GetClipboardFormat // Name='%s' !\n", lpFormat->Name); +#endif + maxlen = min(maxlen - 1, strlen(lpFormat->Name)); + printf("GetClipboardFormat // maxlen=%d !\n", maxlen); + memcpy(retStr, lpFormat->Name, maxlen); + retStr[maxlen] = 0; + return maxlen; +} + + +/************************************************************************** + * SetClipboardViewer [USER.147] + */ +HWND SetClipboardViewer(HWND hWnd) +{ +#ifdef DEBUG_CLIPBOARD + printf("SetClipboardFormat(%04X) !\n", hWnd); +#endif + hWndViewer = hWnd; +} + + +/************************************************************************** + * GetClipboardViewer [USER.148] + */ +HWND GetClipboardViewer() +{ +#ifdef DEBUG_CLIPBOARD + printf("GetClipboardFormat() = %04X !\n", hWndViewer); +#endif +} + + +/************************************************************************** + * ChangeClipboardChain [USER.149] + */ +BOOL ChangeClipboardChain(HWND hWnd, HWND hWndNext) +{ +#ifdef DEBUG_CLIPBOARD + printf("ChangeClipboardChain(%04X, %04X) !\n", hWnd, hWndNext); +#endif +} + + +/************************************************************************** + * IsClipboardFormatAvailable [USER.193] + */ +BOOL IsClipboardFormatAvailable(WORD wFormat) +{ + LPCLIPFORMAT lpFormat = ClipFormats; +#ifdef DEBUG_CLIPBOARD + printf("IsClipboardFormatAvailable(%04X) !\n", wFormat); +#endif + while(TRUE) { + if (lpFormat == NULL) return FALSE; + if (lpFormat->wFormatID == wFormat) break; + lpFormat = lpFormat->NextFormat; + } + return (lpFormat->hData != 0); +} + + +/************************************************************************** + * GetOpenClipboardWindow [USER.248] + */ +HWND GetOpenClipboardWindow() +{ +#ifdef DEBUG_CLIPBOARD + printf("GetOpenClipboardWindow() = %04X !\n", hWndClipboardOwner); +#endif + return hWndClipboardOwner; +} + + +/************************************************************************** + * GetPriorityClipboardFormat [USER.402] + */ +int GetPriorityClipboardFormat(WORD FAR *lpPriorityList, short nCount) +{ +#ifdef DEBUG_CLIPBOARD + printf("GetPriorityClipboardFormat(%08X, %d) !\n", lpPriorityList, nCount); +#endif +} + + + diff --git a/misc/comm.c b/misc/comm.c index d9f53444973..84cc620f557 100644 --- a/misc/comm.c +++ b/misc/comm.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #if defined(__NetBSD__) || defined(__FreeBSD__) #include @@ -53,12 +54,12 @@ void Comm_Init(void) if (!S_ISCHR(st.st_mode)) fprintf(stderr,"comm: can 't use `%s' as COM%d !\n", temp, x); else - if ((ptr = malloc(strlen(temp)+1)) == NULL) + if ((COM[serial].devicename = malloc(strlen(temp)+1)) == NULL) fprintf(stderr,"comm: can't malloc for device info!\n"); else { COM[serial].fd = 0; - COM[serial].devicename = ptr; - strcpy(COM[serial++].devicename, temp); + strcpy(COM[serial].devicename, temp); + serial++; } } @@ -74,17 +75,16 @@ void Comm_Init(void) if (!S_ISCHR(st.st_mode)) fprintf(stderr,"comm: can 't use `%s' as LPT%d !\n", temp, x); else - if ((ptr = malloc(strlen(temp)+1)) == NULL) + if ((LPT[parallel].devicename = malloc(strlen(temp)+1)) == NULL) fprintf(stderr,"comm: can't malloc for device info!\n"); else { - LPT[serial].fd = 0; - LPT[serial].devicename = ptr; - strcpy(LPT[serial++].devicename, temp); + LPT[parallel].fd = 0; + strcpy(LPT[parallel].devicename, temp); + parallel++; } } } - atexit(Comm_DeInit); } void Comm_DeInit(void) @@ -155,6 +155,12 @@ fprintf(stderr,"BuildCommDCB: (%s), ptr %d\n", device, lpdcb); if (!strncmp(device,"COM",3)) { port = device[3] - '0'; + + if (port-- == 0) { + fprintf(stderr, "comm: BUG ! COM0 can't exists!.\n"); + commerror = IE_BADID; + } + if (!ValidCOMPort(port)) { commerror = IE_BADID; return -1; @@ -240,6 +246,11 @@ fprintf(stderr,"OpenComm: %s, %d, %d\n", device, cbInQueue, cbOutQueue); if (!strncmp(device,"COM",3)) { port = device[3] - '0'; + if (port-- == 0) { + fprintf(stderr, "comm: BUG ! COM0 doesn't exists!.\n"); + commerror = IE_BADID; + } + if (!ValidCOMPort(port)) { commerror = IE_BADID; return -1; @@ -252,7 +263,7 @@ fprintf(stderr,"OpenComm: %s, %d, %d\n", device, cbInQueue, cbOutQueue); fd = open(COM[port].devicename, O_RDWR | O_NONBLOCK, 0); if (fd == -1) { commerror = WinError(); - return -1; + return -1; } else { COM[port].fd = fd; return fd; @@ -473,9 +484,20 @@ fprintf(stderr,"SetCommState: fd %d, ptr %d\n", lpdcb->Id, lpdcb); commerror = WinError(); return -1; } - cfmakeraw(&port); + port.c_cc[VMIN] = 0; - port.c_cc[VTIME] = 0; + port.c_cc[VTIME] = 1; + + port.c_iflag &= ~(ISTRIP|BRKINT|IGNCR|ICRNL|INLCR|IMAXBEL); + port.c_iflag |= (IGNBRK); + + port.c_oflag &= ~(OPOST); + + port.c_cflag &= ~(HUPCL); + port.c_cflag |= CLOCAL | CREAD; + + port.c_lflag &= ~(ICANON|ECHO|ISIG); + port.c_lflag |= NOFLSH; fprintf(stderr,"SetCommState: baudrate %d\n",lpdcb->BaudRate); #ifdef CBAUD diff --git a/loader/cursor.c b/misc/cursor.c similarity index 94% rename from loader/cursor.c rename to misc/cursor.c index ff8c7bdea48..931d538e411 100644 --- a/loader/cursor.c +++ b/misc/cursor.c @@ -7,7 +7,6 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; #define DEBUG_CURSOR */ -#include #include #include #include @@ -292,6 +291,30 @@ BOOL DestroyCursor(HCURSOR hCursor) } +/********************************************************************** + * CURSOR_SetWinCursor + * + * Set the cursor for a given window. To be used instead of SetCursor() + * wherever possible. + */ +HCURSOR CURSOR_SetWinCursor( HWND hwnd, HCURSOR hCursor ) +{ + CURSORALLOC *lpcur; + HCURSOR hOldCursor; + WND * wndPtr = WIN_FindWndPtr( hwnd ); + + if (!wndPtr || !hCursor) return 0; + lpcur = (CURSORALLOC *)GlobalLock(hCursor); + hOldCursor = hActiveCursor; + if (hActiveCursor != hCursor) ShowCursCount = 0; + if (ShowCursCount >= 0) + XDefineCursor( display, wndPtr->window, lpcur->xcursor ); + GlobalUnlock(hCursor); + hActiveCursor = hCursor; + return hOldCursor; +} + + /********************************************************************** * SetCursor [USER.69] */ diff --git a/misc/dos_fs.c b/misc/dos_fs.c index 3840972e0f4..cc220c4d6f3 100644 --- a/misc/dos_fs.c +++ b/misc/dos_fs.c @@ -10,7 +10,7 @@ #include #include #include -#ifdef __linux__ +#if defined(__linux__) || defined(sun) #include #endif #if defined(__NetBSD__) || defined(__FreeBSD__) @@ -73,15 +73,6 @@ void DOS_InitFS(void) ToDos(TempDirectory); ToDos(WindowsPath); -#ifdef DEBUG - fprintf(stderr,"wine.ini = %s\n",WINE_INI); - fprintf(stderr,"win.ini = %s\n",WIN_INI); - fprintf(stderr,"windir = %s\n",WindowsDirectory); - fprintf(stderr,"sysdir = %s\n",SystemDirectory); - fprintf(stderr,"tempdir = %s\n",TempDirectory); - fprintf(stderr,"path = %s\n",WindowsPath); -#endif - for (x=0; x!=MAX_DOS_DRIVES; x++) { DosDrives[x].serialnumber = (0xEB0500L | x); @@ -104,14 +95,11 @@ void DOS_InitFS(void) temp[strlen(temp)] = '\0'; DosDrives[x].rootdir = ptr; strcpy(DosDrives[x].rootdir, temp); - strcpy(DosDrives[x].cwd, "/windows/"); + strcpy(DosDrives[x].cwd, "/"); strcpy(DosDrives[x].label, "DRIVE-"); strcat(DosDrives[x].label, drive); DosDrives[x].disabled = 0; } - - atexit(DOS_DeInitFS); - DOS_SetDefaultDrive(2); for (x=0; x!=MAX_DOS_DRIVES; x++) { @@ -132,6 +120,14 @@ void DOS_InitFS(void) for (x=0; x!=MAX_OPEN_DIRS ; x++) DosDirs[x].inuse = 0; +#ifdef DEBUG + fprintf(stderr,"wine.ini = %s\n",WINE_INI); + fprintf(stderr,"win.ini = %s\n",WIN_INI); + fprintf(stderr,"windir = %s\n",WindowsDirectory); + fprintf(stderr,"sysdir = %s\n",SystemDirectory); + fprintf(stderr,"tempdir = %s\n",TempDirectory); + fprintf(stderr,"path = %s\n",WindowsPath); +#endif } void DOS_DeInitFS(void) @@ -187,7 +183,7 @@ WORD DOS_GetEquipment(void) if (diskdrives) diskdrives--; - equipment = diskdrives << 6; + equipment = (diskdrives << 6) || 0x02; return (equipment); } @@ -633,17 +629,23 @@ fprintf(stderr,"FindFile: looking for %s\n",rootname); */ char *WineIniFileName(void) { - static char *IniName = NULL; + static char *IniName = NULL, *env; + char inipath[256]; if (IniName) return IniName; getcwd(inipath, 256); - strcat(inipath, ";"); - strcat(inipath, getenv("HOME")); - strcat(inipath, ";"); - strcat(inipath, getenv("WINEPATH")); + + if ((env = getenv("HOME")) !=NULL) { + strcat(inipath, ";"); + strcat(inipath, env); + } + if ((env = getenv("WINEPATH")) !=NULL) { + strcat(inipath, ";"); + strcat(inipath, env); + } IniName = malloc(1024); if (FindFile(IniName, 1024, "wine.ini", NULL, inipath) == NULL) @@ -672,6 +674,43 @@ char *WinIniFileName() return name; } +int match(char *filename, char *filemask) +{ + int x, masklength = strlen(filemask); + +#ifdef DEBUG + fprintf(stderr, "match: %s, %s\n", filename, filemask); +#endif + + for (x = 0; x != masklength ; x++) { +#ifdef DEBUG + printf("(%c%c) ", *filename, filemask[x]); +#endif + + if (!*filename) + /* stop if EOFname */ + return 1; + + if (filemask[x] == '?') { + /* skip the next char */ + filename++; + continue; + } + + if (filemask[x] == '*') { + /* skip each char until '.' or EOFname */ + while (*filename && *filename !='.') + filename++; + continue; + } + if (filemask[x] != *filename) + return 0; + + filename++; + } + return 1; +} + struct dosdirent *DOS_opendir(char *dosdirname) { int x,y; @@ -687,21 +726,24 @@ struct dosdirent *DOS_opendir(char *dosdirname) if ((unixdirname = GetDirectUnixFileName(dosdirname)) == NULL) return NULL; - strcpy(temp,unixdirname); + strcpy(temp, unixdirname); y = strlen(temp); - while (y--) { if (temp[y] == '/') { - temp[y] = '\0'; + temp[y++] = '\0'; + strcpy(DosDirs[x].filemask, temp +y); + ToDos(DosDirs[x].filemask); break; } } - fprintf(stderr,"%s -> %s\n",unixdirname,temp); +#ifdef DEBUG + fprintf(stderr,"DOS_opendir: %s -> %s\n", unixdirname, temp); +#endif DosDirs[x].inuse = 1; strcpy(DosDirs[x].unixpath, temp); @@ -722,17 +764,20 @@ struct dosdirent *DOS_readdir(struct dosdirent *de) if (!de->inuse) return NULL; - if ((d = readdir(de->ds)) == NULL) - { - closedir(de->ds); - de->inuse = 0; - return de; - } + do { + if ((d = readdir(de->ds)) == NULL) + { + closedir(de->ds); + de->inuse = 0; + return de; + } - strcpy(de->filename, d->d_name); - if (d->d_reclen > 12) - de->filename[12] = '\0'; - ToDos (de->filename); + strcpy(de->filename, d->d_name); + if (d->d_reclen > 12) + de->filename[12] = '\0'; + + ToDos(de->filename); + } while ( !match(de->filename, de->filemask) ); de->attribute = 0x0; diff --git a/misc/exec.c b/misc/exec.c index e20e53a3c09..a41a95cdc90 100644 --- a/misc/exec.c +++ b/misc/exec.c @@ -3,7 +3,7 @@ * */ -#include "win.h" +#include "windows.h" #define HELP_CONTEXT 0x0001 #define HELP_QUIT 0x0002 @@ -25,7 +25,7 @@ WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow) { int X, X2, C; char *ArgV[20]; - printf("WinExec(%s, %u)\n", lpCmdLine, nCmdShow); + printf("WinExec('%s', %04X)\n", lpCmdLine, nCmdShow); for (X = X2 = C = 0; X < strlen(lpCmdLine) + 1; X++) { if ((lpCmdLine[X] == ' ') || (lpCmdLine[X] == '\0')) { ArgV[C] = (char *)malloc(X - X2 + 1); diff --git a/misc/file.c b/misc/file.c index adc43683313..de8a7e29a36 100644 --- a/misc/file.c +++ b/misc/file.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "prototypes.h" char WindowsDirectory[256], SystemDirectory[256], TempDirectory[256]; @@ -33,7 +34,7 @@ char WindowsDirectory[256], SystemDirectory[256], TempDirectory[256]; Emulate the _lopen windows call ***************************************************************************/ -WORD KERNEL__lopen (LPSTR lpPathName, WORD iReadWrite) +int _lopen (LPSTR lpPathName, int iReadWrite) { int handle; char *UnixFileName; @@ -60,7 +61,7 @@ WORD KERNEL__lopen (LPSTR lpPathName, WORD iReadWrite) /*************************************************************************** _lread ***************************************************************************/ -WORD KERNEL__lread (WORD hFile, LPSTR lpBuffer, WORD wBytes) +WORD _lread (int hFile, LPSTR lpBuffer, int wBytes) { int result; @@ -80,7 +81,7 @@ WORD KERNEL__lread (WORD hFile, LPSTR lpBuffer, WORD wBytes) /**************************************************************************** _lwrite ****************************************************************************/ -WORD KERNEL__lwrite (WORD hFile, LPSTR lpBuffer, WORD wBytes) +WORD _lwrite (int hFile, LPSTR lpBuffer, int wBytes) { int result; @@ -99,7 +100,7 @@ WORD KERNEL__lwrite (WORD hFile, LPSTR lpBuffer, WORD wBytes) /*************************************************************************** _lclose ***************************************************************************/ -WORD KERNEL__lclose (WORD hFile) +int _lclose (int hFile) { #ifdef DEBUG_FILE fprintf(stderr, "_lclose: handle %d\n", hFile); @@ -114,7 +115,7 @@ WORD KERNEL__lclose (WORD hFile) Warning: This is nearly totally untested. It compiles, that's it... -SL 9/13/93 **************************************************************************/ -WORD KERNEL_OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle) +int OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle) { int base,flags; @@ -141,7 +142,7 @@ WORD KERNEL_OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle) } else { - return KERNEL__lopen (lpFileName, wStyle); + return _lopen (lpFileName, wStyle); } } @@ -152,6 +153,10 @@ WORD KERNEL_OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle) Linux isn't limited to 20 files, this one's easy. - SL **************************************************************************/ +#if !defined (OPEN_MAX) +/* This one is for the Sun */ +#define OPEN_MAX _POSIX_OPEN_MAX +#endif WORD SetHandleCount (WORD wNumber) { printf("SetHandleCount(%d)\n",wNumber); @@ -161,7 +166,7 @@ WORD SetHandleCount (WORD wNumber) /*************************************************************************** _llseek ***************************************************************************/ -LONG KERNEL__llseek (WORD hFile, LONG lOffset, int nOrigin) +LONG _llseek (int hFile, LONG lOffset, int nOrigin) { int origin; @@ -184,7 +189,7 @@ LONG KERNEL__llseek (WORD hFile, LONG lOffset, int nOrigin) /*************************************************************************** _lcreate ***************************************************************************/ -LONG KERNEL__lcreate (LPSTR lpszFilename, int fnAttribute) +LONG _lcreate (LPSTR lpszFilename, int fnAttribute) { int handle; char *UnixFileName; diff --git a/misc/main.c b/misc/main.c index c371d01cd90..59bd197139e 100644 --- a/misc/main.c +++ b/misc/main.c @@ -20,13 +20,15 @@ Screen * XT_screen; /* To be removed */ Display * display; Screen * screen; +char *ProgramName; /* Used by resource.c with WINELIB */ struct options Options = { /* default options */ NULL, /* spyFilename */ FALSE, /* usePrivateMap */ FALSE, /* synchronous */ - SW_SHOWNORMAL /* cmdShow */ + SW_SHOWNORMAL, /* cmdShow */ + FALSE }; @@ -36,7 +38,8 @@ static XrmOptionDescRec optionsTable[] = { "-iconic", ".iconic", XrmoptionNoArg, (caddr_t)"on" }, { "-privatemap", ".privatemap", XrmoptionNoArg, (caddr_t)"on" }, { "-synchronous", ".synchronous", XrmoptionNoArg, (caddr_t)"on" }, - { "-spy", ".spy", XrmoptionSepArg, (caddr_t)NULL } + { "-spy", ".spy", XrmoptionSepArg, (caddr_t)NULL }, + { "-relaydbg", ".relaydbg", XrmoptionNoArg, (caddr_t)"on" } }; #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0])) @@ -66,8 +69,11 @@ static void MAIN_ParseOptions( int *argc, char *argv[] ) XrmDatabase db = NULL; XrmParseCommand( &db, optionsTable, NB_OPTIONS, "wine", argc, argv ); +#ifdef WINELIB + /* Need to assemble command line and pass it to WinMain */ +#else if (*argc < 2) MAIN_Usage( argv[0] ); - +#endif if (XrmGetResource( db, "wine.display", "Wine.display", &dummy, &value )) display_name = value.addr; else display_name = NULL; @@ -85,6 +91,8 @@ static void MAIN_ParseOptions( int *argc, char *argv[] ) Options.usePrivateMap = TRUE; if (XrmGetResource(db,"wine.synchronous","Wine.synchronous",&dummy,&value)) Options.synchronous = TRUE; + if (XrmGetResource(db,"wine.relaydbg","Wine.relaydbg",&dummy,&value)) + Options.relay_debug = TRUE; if (XrmGetResource(db,"wine.spy","Wine.spy",&dummy,&value)) Options.spyFilename = value.addr; } @@ -95,7 +103,10 @@ static void MAIN_ParseOptions( int *argc, char *argv[] ) */ int main( int argc, char *argv[] ) { - + int ret_val; + XKeyboardState keyboard_state; + XKeyboardControl keyboard_value; + XrmInitialize(); MAIN_ParseOptions( &argc, argv ); @@ -105,16 +116,171 @@ int main( int argc, char *argv[] ) XT_screen = screen; if (Options.synchronous) XSynchronize( display, True ); + XGetKeyboardControl(display, &keyboard_state); + + ProgramName = argv [0]; DOS_InitFS(); Comm_Init(); - return _WinMain( argc, argv ); -} + ret_val = _WinMain( argc, argv ); + + Comm_DeInit (); + DOS_DeInitFS (); + sync_profiles (); + + /* restore sounds/keyboard settings */ + + keyboard_value.key_click_percent = keyboard_state.key_click_percent; + keyboard_value.bell_percent = keyboard_state.bell_percent; + keyboard_value.bell_pitch = keyboard_state.bell_pitch; + keyboard_value.bell_duration = keyboard_state.bell_duration; + keyboard_value.auto_repeat_mode = keyboard_state.global_auto_repeat; + + XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent | + KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value); + + return ret_val; +} /*********************************************************************** * MessageBeep (USER.104) */ void MessageBeep( WORD i ) { - XBell( display, 100 ); + XBell(display, 100); +} + +/*********************************************************************** + * GetVersion (KERNEL.3) + */ +LONG GetVersion(void) +{ + return (0x04001003); /* dos version 4.00, win ver 3.1 */ +} + +/*********************************************************************** + * GetWinFlags (KERNEL.132) + */ +LONG GetWinFlags(void) +{ + return (WF_STANDARD | WF_CPU286 | WF_PMODE | WF_80x87); +} + +/*********************************************************************** + * GetTimerResolution (USER.14) + */ +LONG GetTimerResolution(void) +{ + return (1000); +} + +/*********************************************************************** + * SystemParametersInfo (USER.483) + */ +BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT fuWinIni) +{ + XKeyboardState keyboard_state; + XKeyboardControl keyboard_value; + + fprintf(stderr, "SystemParametersInfo: action %d, param %x, flag %x\n", + uAction, uParam, fuWinIni); + + switch (uAction) { + case SPI_GETBEEP: + XGetKeyboardControl(display, &keyboard_state); + if (keyboard_state.bell_percent == 0) + *(BOOL *) lpvParam = FALSE; + else + *(BOOL *) lpvParam = TRUE; + break; + + case SPI_GETBORDER: + *(int *) lpvParam = 1; + break; + + case SPI_GETFASTTASKSWITCH: + *(BOOL *) lpvParam = FALSE; + break; + + case SPI_GETGRIDGRANULARITY: + *(int *) lpvParam = 1; + break; + + case SPI_GETICONTITLEWRAP: + *(BOOL *) lpvParam = FALSE; + break; + + case SPI_GETKEYBOARDDELAY: + *(int *) lpvParam = 1; + break; + + case SPI_GETKEYBOARDSPEED: + *(WORD *) lpvParam = 30; + break; + + case SPI_GETMENUDROPALIGNMENT: + *(BOOL *) lpvParam = FALSE; + break; + + case SPI_GETSCREENSAVEACTIVE: + *(WORD *) lpvParam = FALSE; + break; + + case SPI_GETSCREENSAVETIMEOUT: + *(int *) lpvParam = 0; + break; + + case SPI_ICONHORIZONTALSPACING: + if (lpvParam == NULL) + fprintf(stderr, "SystemParametersInfo: Horizontal icon spacing set to %d\n.", uParam); + else + *(int *) lpvParam = 50; + break; + + case SPI_ICONVERTICALSPACING: + if (lpvParam == NULL) + fprintf(stderr, "SystemParametersInfo: Vertical icon spacing set to %d\n.", uParam); + else + *(int *) lpvParam = 50; + break; + + case SPI_SETBEEP: + if (uParam == TRUE) + keyboard_value.bell_percent = -1; + else + keyboard_value.bell_percent = 0; + XChangeKeyboardControl(display, KBBellPercent, + &keyboard_value); + break; + + case SPI_SETSCREENSAVEACTIVE: + if (uParam == TRUE) + XActivateScreenSaver(display); + else + XResetScreenSaver(display); + break; + + case SPI_SETSCREENSAVETIMEOUT: + XSetScreenSaver(display, uParam, 60, DefaultBlanking, + DefaultExposures); + break; + + case SPI_LANGDRIVER: + case SPI_SETBORDER: + case SPI_SETDESKPATTERN: + case SPI_SETDESKWALLPAPER: + case SPI_SETDOUBLECLKHEIGHT: + case SPI_SETDOUBLECLICKTIME: + case SPI_SETDOUBLECLKWIDTH: + case SPI_SETFASTTASKSWITCH: + case SPI_SETKEYBOARDDELAY: + case SPI_SETKEYBOARDSPEED: + fprintf(stderr, "SystemParametersInfo: option %d ignored.\n", uParam); + break; + + default: + fprintf(stderr, "SystemParametersInfo: unknown option %d.\n", uParam); + break; + } + return 1; } diff --git a/misc/message.c b/misc/message.c index 364b4602b89..79a49f7f40b 100644 --- a/misc/message.c +++ b/misc/message.c @@ -17,6 +17,8 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; #include "heap.h" #include "win.h" +extern HINSTANCE hSysRes; +extern HBITMAP hUpArrow; typedef struct tagMSGBOX { LPSTR Title; @@ -39,7 +41,7 @@ LONG SystemMessageBoxProc(HWND hwnd, WORD message, WORD wParam, LONG lParam); * MessageBox [USER.1] */ -int MessageBox( HWND hWnd, LPSTR str, LPSTR title, WORD type ) +int MessageBox(HWND hWnd, LPSTR str, LPSTR title, WORD type) { HWND hDlg; WND *wndPtr; @@ -47,15 +49,20 @@ int MessageBox( HWND hWnd, LPSTR str, LPSTR title, WORD type ) MSG msg; MSGBOX mb; DWORD dwStyle; + HINSTANCE hInst; wndPtr = WIN_FindWndPtr(hWnd); #ifdef DEBUG_MSGBOX printf( "MessageBox: '%s'\n", str ); #endif + if (wndPtr == NULL) + hInst = hSysRes; + else + hInst = wndPtr->hInstance; wndClass.style = CS_HREDRAW | CS_VREDRAW ; wndClass.lpfnWndProc = (WNDPROC)SystemMessageBoxProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; - wndClass.hInstance = wndPtr->hInstance; + wndClass.hInstance = hInst; wndClass.hIcon = (HICON)NULL; wndClass.hCursor = LoadCursor((HANDLE)NULL, IDC_ARROW); wndClass.hbrBackground = GetStockObject(WHITE_BRUSH); @@ -70,7 +77,7 @@ int MessageBox( HWND hWnd, LPSTR str, LPSTR title, WORD type ) dwStyle = WS_POPUP | WS_DLGFRAME | WS_VISIBLE; if ((type & (MB_SYSTEMMODAL | MB_TASKMODAL)) == 0) dwStyle |= WS_CAPTION; hDlg = CreateWindow("MESSAGEBOX", title, dwStyle, 100, 150, 400, 120, - (HWND)NULL, (HMENU)NULL, wndPtr->hInstance, (LPSTR)&mb); + (HWND)NULL, (HMENU)NULL, hInst, (LPSTR)&mb); if (hDlg == 0) return 0; while(TRUE) { if (!mb.ActiveFlg) break; @@ -78,15 +85,13 @@ int MessageBox( HWND hWnd, LPSTR str, LPSTR title, WORD type ) TranslateMessage(&msg); DispatchMessage(&msg); } - if (!UnregisterClass("MESSAGEBOX", wndPtr->hInstance)) return 0; + if (!UnregisterClass("MESSAGEBOX", hInst)) return 0; #ifdef DEBUG_MSGBOX printf( "MessageBox return %04X !\n", mb.wRetVal); #endif return(mb.wRetVal); } - - LPMSGBOX MsgBoxGetStorageHeader(HWND hwnd) { WND *wndPtr; @@ -286,17 +291,13 @@ BOOL FAR PASCAL AboutWine_Proc(HWND hDlg, WORD msg, WORD wParam, LONG lParam) CreditMode = FALSE; strcpy(str, "WINELOGO"); hBitMap = LoadBitmap((HINSTANCE)NULL, (LPSTR)str); -/* getcwd(str, 256); - strcat(str, ";"); - strcat(str, getenv("HOME")); - strcat(str, ";"); - strcat(str, getenv("WINEPATH")); */ + strcpy(str, "PROPOSED_LICENSE"); printf("str = '%s'\n", str); - hFile = KERNEL_OpenFile((LPSTR)str, &ofstruct, OF_READ); + hFile = OpenFile((LPSTR)str, &ofstruct, OF_READ); ptr = (LPSTR)malloc(2048); lseek(hFile, 0L, SEEK_SET); - KERNEL__lread(hFile, ptr, 2000L); + _lread(hFile, ptr, 2000L); close(hFile); return TRUE; case WM_PAINT: @@ -353,3 +354,12 @@ return FALSE; } +/************************************************************************** + * FatalAppExit [USER.137] + */ + +void FatalAppExit(WORD wAction, LPSTR str) +{ +MessageBox((HWND)NULL, str, NULL, MB_SYSTEMMODAL | MB_OK); +exit(1); +} diff --git a/misc/rect.c b/misc/rect.c index 6adc0a52748..cbb2281f347 100644 --- a/misc/rect.c +++ b/misc/rect.c @@ -90,7 +90,8 @@ void InflateRect( LPRECT rect, short x, short y ) */ BOOL IntersectRect( LPRECT dest, LPRECT src1, LPRECT src2 ) { - if ((src1->left >= src2->right) || (src2->left >= src1->right) || + if (IsRectEmpty(src1) || IsRectEmpty(src2) || + (src1->left >= src2->right) || (src2->left >= src1->right) || (src1->top >= src2->bottom) || (src2->top >= src1->bottom)) { SetRectEmpty( dest ); diff --git a/loader/resource.c b/misc/resource.c similarity index 90% rename from loader/resource.c rename to misc/resource.c index bf2d18529a0..680b61f1f93 100644 --- a/loader/resource.c +++ b/misc/resource.c @@ -1,16 +1,17 @@ +#ifndef WINELIB static char RCSId[] = "$Id: resource.c,v 1.4 1993/07/04 04:04:21 root Exp root $"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; +#endif -#include #include #include #include #include #include #include +#include "arch.h" #include "prototypes.h" #include "windows.h" -#include "win.h" #include "gdi.h" #include "wine.h" #include "icon.h" @@ -35,6 +36,16 @@ extern HINSTANCE hSysRes; HANDLE RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret); +extern char *ProgramName; + +/***************************************************************************** + * Super Patch, I promise to arrange things as soon as I can. + * +******************************************************************************/ +#ifdef WINELIB +#include "../loader/wine.c" +#endif + /********************************************************************** * OpenResourceFile @@ -43,21 +54,28 @@ int OpenResourceFile(HANDLE instance) { struct w_files *w; + char *res_file; if (ResourceInst == instance) return ResourceFd; - + w = GetFileInfo(instance); if (w == NULL) return -1; + ResourceFileInfo = w; + res_file = w->filename; if (ResourceFd >= 0) close(ResourceFd); ResourceInst = instance; - ResourceFileInfo = w; - ResourceFd = open(w->filename, O_RDONLY); - + + ResourceFd = open (res_file, O_RDONLY); + +#ifdef DEBUG_RESOURCE + printf("OpenResourceFile(%04X) // file='%s' hFile=%04X !\n", + instance, w->filename, ResourceFd); +#endif return ResourceFd; } @@ -128,6 +146,12 @@ ConvertInfoBitmap( HDC hdc, BITMAPINFO * image ) bits, image, DIB_RGB_COLORS ); } +#ifndef WINELIB +load_typeinfo (int fd, struct resource_typeinfo_s *typeinfo) +{ + return read (fd, typeinfo, sizeof (*typeinfo)) == sizeof (*typeinfo); +} +#endif /********************************************************************** * FindResourceByNumber */ @@ -157,26 +181,30 @@ FindResourceByNumber(struct resource_nameinfo_s *result_p, printf("FindResourceByNumber (%s) bad block size !\n", resource_id); return -1; } - + size_shift = CONV_SHORT(size_shift); /* * Find resource. */ typeinfo.type_id = 0xffff; while (typeinfo.type_id != 0) { - if (read(ResourceFd, &typeinfo, sizeof(typeinfo)) != - sizeof(typeinfo)) { + if (!load_typeinfo (ResourceFd, &typeinfo)){ printf("FindResourceByNumber (%X) bad typeinfo size !\n", resource_id); return -1; } #ifdef DEBUG_RESOURCE - printf("FindResourceByNumber type=%X count=%d\n", - typeinfo.type_id, typeinfo.count); + printf("FindResourceByNumber type=%X count=%d searched=%d \n", + typeinfo.type_id, typeinfo.count, type_id); #endif if (typeinfo.type_id == 0) break; if (typeinfo.type_id == type_id || type_id == -1) { for (i = 0; i < typeinfo.count; i++) { +#ifndef WINELIB if (read(ResourceFd, &nameinfo, sizeof(nameinfo)) != - sizeof(nameinfo)) { + sizeof(nameinfo)) +#else + if (!load_nameinfo (ResourceFd, &nameinfo)) +#endif + { printf("FindResourceByNumber (%X) bad nameinfo size !\n", resource_id); return -1; } @@ -229,6 +257,7 @@ FindResourceByName(struct resource_nameinfo_s *result_p, printf("FindResourceByName (%s) bad block size !\n", resource_name); return -1; } + size_shift = CONV_SHORT (size_shift); /* * Find resource. @@ -236,43 +265,55 @@ FindResourceByName(struct resource_nameinfo_s *result_p, typeinfo.type_id = 0xffff; while (typeinfo.type_id != 0) { - if (read(ResourceFd, &typeinfo, sizeof(typeinfo)) != - sizeof(typeinfo)) + if (!load_typeinfo (ResourceFd, &typeinfo)) { printf("FindResourceByName (%s) bad typeinfo size !\n", resource_name); return -1; } #ifdef DEBUG_RESOURCE - printf("FindResourceByName typeinfo.type_id=%X type_id=%X\n", - typeinfo.type_id, type_id); + printf("FindResourceByName typeinfo.type_id=%X count=%d type_id=%X\n", + typeinfo.type_id, typeinfo.count, type_id); #endif if (typeinfo.type_id == 0) break; if (typeinfo.type_id == type_id || type_id == -1) { for (i = 0; i < typeinfo.count; i++) { +#ifndef WINELIB if (read(ResourceFd, &nameinfo, sizeof(nameinfo)) != sizeof(nameinfo)) +#else + if (!load_nameinfo (ResourceFd, &nameinfo)) +#endif { printf("FindResourceByName (%s) bad nameinfo size !\n", resource_name); return -1; } - - if (nameinfo.id & 0x8000) - continue; - +/* + if ((nameinfo.id & 0x8000) != 0) continue; +*/ +#ifdef DEBUG_RESOURCE + printf("FindResourceByName // nameinfo.id=%04X !\n", nameinfo.id); +#endif old_pos = lseek(ResourceFd, 0, SEEK_CUR); new_pos = rtoff + nameinfo.id; lseek(ResourceFd, new_pos, SEEK_SET); read(ResourceFd, &nbytes, 1); +#ifdef DEBUG_RESOURCE + printf("FindResourceByName // namesize=%d !\n", nbytes); +#endif + nbytes = CONV_CHAR_TO_LONG (nbytes); read(ResourceFd, name, nbytes); lseek(ResourceFd, old_pos, SEEK_SET); name[nbytes] = '\0'; #ifdef DEBUG_RESOURCE - printf("FindResourceByName type_id=%X name='%s' resource_name='%s'\n", - typeinfo.type_id, name, resource_name); + printf("FindResourceByName type_id=%X (%d of %d) name='%s' resource_name='%s'\n", + typeinfo.type_id, i + 1, typeinfo.count, + name, resource_name); #endif - if (strcasecmp(name, resource_name) == 0) +/* if (strcasecmp(name, resource_name) == 0) */ + if (strcasecmp(name, resource_name) == 0 || + (nameinfo.id == 0x8001 && type_id == NE_RSCTYPE_MENU)) { memcpy(result_p, &nameinfo, sizeof(nameinfo)); return size_shift; @@ -333,7 +374,6 @@ HICON LoadIcon(HANDLE instance, LPSTR icon_name) ReleaseDC(GetDesktopWindow(), hdc); return 0; } - printf("LoadIcon Alloc hIcon=%X\n", hIcon); lpico = (ICONALLOC *)GlobalLock(hIcon); lpico->descriptor = *lpicodesc; width = lpicodesc->Width; @@ -390,6 +430,9 @@ HICON LoadIcon(HANDLE instance, LPSTR icon_name) DeleteDC(hMemDC2); ReleaseDC(GetDesktopWindow(), hdc); GlobalUnlock(hIcon); +#ifdef DEBUG_RESOURCE + printf("LoadIcon Alloc hIcon=%X\n", hIcon); +#endif return hIcon; } @@ -679,7 +722,10 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret) size_shift = FindResourceByName(&nameinfo, type, rsc_name); } if (size_shift == -1) { - printf("RSC_LoadResource / Resource '%X' not Found !\n", rsc_name); + if ((LONG)rsc_name >= 0x00010000L) + printf("RSC_LoadResource / Resource '%s' not Found !\n", rsc_name); + else + printf("RSC_LoadResource / Resource '%X' not Found !\n", rsc_name); return 0; } /* diff --git a/misc/user.c b/misc/user.c index d8e0596360a..51b94afc241 100644 --- a/misc/user.c +++ b/misc/user.c @@ -18,6 +18,7 @@ extern BOOL ATOM_Init(); extern BOOL GDI_Init(); extern void SYSMETRICS_Init(); +#ifndef WINELIB /*********************************************************************** * USER_HeapInit */ @@ -29,7 +30,7 @@ static BOOL USER_HeapInit() HEAP_Init( &USER_Heap, s->base_addr, USER_HEAP_SIZE ); return TRUE; } - +#endif /********************************************************************** * USER_InitApp @@ -52,9 +53,11 @@ USER_InitApp(int hInstance) /* Initialize system colors and metrics*/ SYSMETRICS_Init(); SYSCOLOR_Init(); - + +#ifndef WINELIB /* Create USER heap */ if (!USER_HeapInit()) return 0; +#endif /* Create the DCEs */ DCE_Init(); @@ -72,6 +75,11 @@ USER_InitApp(int hInstance) /* Create task message queue */ queueSize = GetProfileInt( "windows", "DefaultQueueSize", 8 ); if (!SetMessageQueue( queueSize )) return 0; + +#ifndef WINELIB + /* Initialize DLLs */ + InitializeLoadedDLLs(); +#endif return 1; } diff --git a/misc/winsocket.c b/misc/winsocket.c new file mode 100644 index 00000000000..d5483f9f42c --- /dev/null +++ b/misc/winsocket.c @@ -0,0 +1,470 @@ +/* + * based on Windows Sockets 1.1 specs + * (ftp.microsoft.com:/Advsys/winsock/spec11/WINSOCK.TXT) + */ + +#include +#include +#include +#include +#if defined(__FreeBSD__) +#include +#endif +#include +#include +#include +#include "winsock.h" + +#define DEBUG_WINSOCK + +/* XXX per task */ +WORD wsa_errno; +int wsa_initted; + +WORD errno_to_wsaerrno(int errno) +{ + switch(errno) { + case ENETDOWN: + return WSAENETDOWN; + case EAFNOSUPPORT: + return WSAEAFNOSUPPORT; + case EMFILE: + return WSAEMFILE; + case ENOBUFS: + return WSAENOBUFS; + case EPROTONOSUPPORT: + return EPROTONOSUPPORT; + case EPROTOTYPE: + return WSAEPROTOTYPE; + case EBADF: + case ENOTSOCK: + return WSAENOTSOCK; + + default: +#ifndef sun +#if defined(__FreeBSD__) + fprintf(stderr, "winsock: errno_to_wsaerrno translation failure.\n\t: %s (%d)\n", + sys_errlist[errno], errno); +#else + fprintf(stderr, "winsock: errno_to_wsaerrno translation failure.\n\t: %s (%d)\n", + strerror [errno], errno); +#endif +#else + fprintf (stderr, "winsock: errno_to_wsaerrno translation failure.\n"); +#endif + break; + } +} + +SOCKET Winsock_accept(SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen) +{ + int sock; + + if ((sock = accept(s, addr, addrlen)) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return INVALID_SOCKET; + } + return sock; +} + +int Winsock_bind(SOCKET s, struct sockaddr FAR *name, int namelen) +{ + if (bind(s, name, namelen) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +int Winsock_closesocket(SOCKET s) +{ + if (close(s) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +int Winsock_connect(SOCKET s, struct sockaddr FAR *name, int namelen) +{ + if (connect(s, name, namelen) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +int Winsock_getpeername(SOCKET s, struct sockaddr FAR *name, int FAR *namelen) +{ + if (getpeername(s, name, namelen) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +int Winsock_getsockname(SOCKET s, struct sockaddr FAR *name, int FAR *namelen) +{ + if (getsockname(s, name, namelen) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +int Winsock_getsockopt(SOCKET s, int loptname, char FAR *optval, int FAR *optlen) +{ + if (getsockopt(s, 0, loptname, optval, optlen) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +u_long Winsock_htonl(u_long hostlong) +{ + return( htonl(hostlong) ); +} + +u_short Winsock_htons(u_short hostshort) +{ + return( htons(hostshort) ); +} + +u_long Winsock_inet_addr(char FAR *cp) +{ + return( inet_addr(cp) ); +} + +char *Winsock_inet_ntoa(struct in_addr in) +{ + char *s; + + if ((s = inet_ntoa(in)) == NULL) { + wsa_errno = errno_to_wsaerrno(errno); + return NULL; + } + return s; +} + +int Winsock_ioctlsocket(SOCKET s, long cmd, u_long FAR *argp) +{ + if (ioctl(s, cmd, argp) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +int Winsock_listen(SOCKET s, int backlog) +{ + if (listen(s, backlog) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +u_long Winsock_ntohl(u_long netlong) +{ + return( ntohl(netlong) ); +} + +u_short Winsock_ntohs(u_short netshort) +{ + return( ntohs(netshort) ); +} + +int Winsock_recv(SOCKET s, char FAR *buf, int len, int flags) +{ + int length; + + if ((length = recv(s, buf, len, flags)) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return length; +} + +int Winsock_recvfrom(SOCKET s, char FAR *buf, int len, int flags, + struct sockaddr FAR *from, int FAR *fromlen) +{ + int length; + + if ((length = recvfrom(s, buf, len, flags, from, fromlen)) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return length; +} + +int Winsock_select(int nfds, fd_set FAR *readfds, fd_set FAR *writefds, + fd_set FAR *exceptfds, struct timeval FAR *timeout) +{ + return(select(nfds, readfds, writefds, exceptfds, timeout)); +} + +int Winsock_send(SOCKET s, char FAR *buf, int len, int flags) +{ + int length; + + if ((length = send(s, buf, len, flags)) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return length; +} + +int Winsock_sendto(SOCKET s, char FAR *buf, int len, int flags, + struct sockaddr FAR *to, int tolen) +{ + int length; + + if ((length = sendto(s, buf, len, flags, to, tolen)) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return length; +} + +int Winsock_setsockopt(SOCKET s, int level, int optname, const char FAR *optval, + int optlen) +{ + if (setsockopt(s, level, optname, optval, optlen) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +int Winsock_shutdown(SOCKET s, int how) +{ + if (shutdown(s, how) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +SOCKET Winsock_socket(WORD af, WORD type, WORD protocol) +{ + int sock; + +#ifdef DEBUG_WINSOCK + printf("Winsock_socket: af=%d type=%d protocol=%d\n", af, type, protocol); +#endif + +/* let the kernel do the dirty work.. + + if (!wsa_initted) { + wsa_errno = WSANOTINITIALISED; + return INVALID_SOCKET; + } +*/ + if ((sock = socket(af, type, protocol)) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return INVALID_SOCKET; + } + return sock; +} + +struct hostent *Winsock_gethostbyaddr(const char FAR *addr, int len, int type) +{ + struct hostent *host; + + if ((host = gethostbyaddr(addr, len, type)) == NULL) { + wsa_errno = errno_to_wsaerrno(errno); + return NULL; + } + return host; +} + +struct hostent *Winsock_gethostbyname(const char FAR *name) +{ + struct hostent *host; + + if ((host = gethostbyname(name)) == NULL) { + wsa_errno = errno_to_wsaerrno(errno); + return NULL; + } + return host; +} + +int Winsock_gethostname(char FAR *name, int namelen) +{ + if (gethostname(name, namelen) < 0) { + wsa_errno = errno_to_wsaerrno(errno); + return SOCKET_ERROR; + } + return 0; +} + +struct protoent *Winsock_getprotobyname(char FAR *name) +{ + struct protoent *proto; + + if ((proto = getprotobyname(name)) == NULL) { + wsa_errno = errno_to_wsaerrno(errno); + return NULL; + } + return proto; +} + +struct protoent *Winsock_getprotobynumber(int number) +{ + struct protoent *proto; + + if ((proto = getprotobynumber(number)) == NULL) { + wsa_errno = errno_to_wsaerrno(errno); + return NULL; + } + return proto; +} + +struct servent *Winsock_getservbyname(const char FAR *name, const char FAR *proto) +{ + struct servent *service; + + if ((service = getservbyname(name, proto)) == NULL) { + wsa_errno = errno_to_wsaerrno(errno); + return NULL; + } + return service; +} + +struct servent *Winsock_getservbyport(int port, const char FAR *proto) +{ + struct servent *service; + + if ((service = getservbyport(port, proto)) == NULL) { + wsa_errno = errno_to_wsaerrno(errno); + return NULL; + } + return service; +} + +HANDLE WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char FAR *addr, + int len, int type, const char FAR *buf, int buflen) +{ + +} + +HANDLE WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, const char FAR *name, + char FAR *buf, int buflen) +{ + +} + +HANDLE WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, const char FAR *name, + char FAR *buf, int buflen) +{ + +} + +HANDLE WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, int number, + char FAR *buf, int buflen) +{ + +} + +HANDLE WSAAsyncGetServByName(HWND hWnd, u_int wMsg, const char FAR *name, + const char FAR *proto, char FAR *buf, int buflen) +{ + +} + +HANDLE WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port, const char FAR + *proto, char FAR *buf, int buflen) +{ + +} + +int WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent) +{ + +} + +int WSAFDIsSet(int fd, fd_set *set) +{ + return( FD_ISSET(fd, set) ); +} + +WSACancelAsyncRequest(HANDLE hAsyncTaskHandle) +{ + +} + +WSACancelBlockingCall ( void ) +{ + +} + +int WSAGetLastError(void) +{ + return wsa_errno; +} + +void WSASetLastError(int iError) +{ + wsa_errno = iError; +} + +BOOL WSAIsBlocking (void) +{ + +} + +FARPROC WSASetBlockingHook(FARPROC lpBlockFunc) +{ + +} + +int WSAUnhookBlockingHook(void) +{ + +} + +WSADATA Winsock_data = { + 0x0101, + 0x0101, + "WINE Sockets", +#ifdef linux + "LINUX/i386", +#endif +#ifdef __NetBSD__ + "NetBSD/i386", +#endif +#ifdef sunos + "SunOS", +#endif + 128, + 1024, + NULL +}; + +int WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData) +{ +#ifdef DEBUG_WINSOCK + fprintf(stderr, "WSAStartup: verReq=%x\n", wVersionRequested); +#endif + + if (LOBYTE(wVersionRequested) < 1 || + (LOBYTE(wVersionRequested) == 1 && + HIBYTE(wVersionRequested) < 1)) + return WSAVERNOTSUPPORTED; + + if (!lpWSAData) + return WSAEINVAL; + + bcopy(&Winsock_data, lpWSAData, sizeof(Winsock_data)); + + wsa_initted = 1; + + return(0); +} + +int WSACleanup(void) +{ + wsa_initted = 0; + return 0; +} diff --git a/miscemu/Imakefile b/miscemu/Imakefile new file mode 100644 index 00000000000..dca1f1dbe44 --- /dev/null +++ b/miscemu/Imakefile @@ -0,0 +1,19 @@ +#include "../Wine.tmpl" + +MODULE = miscemu + +SRCS = \ + emulate.c \ + int1a.c \ + int21.c \ + kernel.c + +OBJS = $(SRCS:.c=.o) + +WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) +DependTarget() +CleanTarget() + +includes:: + +install:: diff --git a/misc/emulate.c b/miscemu/emulate.c similarity index 100% rename from misc/emulate.c rename to miscemu/emulate.c diff --git a/misc/int1a.c b/miscemu/int1a.c similarity index 100% rename from misc/int1a.c rename to miscemu/int1a.c diff --git a/misc/int21.c b/miscemu/int21.c similarity index 94% rename from misc/int21.c rename to miscemu/int21.c index 6caaa7cf46b..47368e1f200 100644 --- a/misc/int21.c +++ b/miscemu/int21.c @@ -22,7 +22,7 @@ static char Copyright[] = "copyright Erik Bos, 1993"; WORD ExtendedError, CodePage = 437; BYTE ErrorClass, Action, ErrorLocus; -extern char *TempDirectory; +extern char TempDirectory[]; void Error(int e, int class, int el) { @@ -749,11 +749,12 @@ void SetDiskSerialNumber(struct sigcontext_struct *context) /************************************************************************/ -int do_int21(struct sigcontext_struct * context){ +int do_int21(struct sigcontext_struct * context) +{ int ah; - fprintf(stderr,"int21: doing AX=%04x BX=%04x CX=%04x DX=%04x\n", - EAX & 0xffffL,EBX & 0xffffL,ECX & 0xffffL,EDX & 0xffffL); + fprintf(stderr, "int21: AX %04x, BX %04x, CX %04x, DX %04x, SI %04x, DI %04x, DS %04x, ES %04x\n", + AX, BX, CX, DX, SI, DI, DS, ES); ah = (EAX >> 8) & 0xffL; @@ -834,7 +835,7 @@ int do_int21(struct sigcontext_struct * context){ case 0x19: /* GET CURRENT DEFAULT DRIVE */ GetDefaultDrive(context); break; - + case 0x1b: /* GET ALLOCATION INFORMATION FOR DEFAULT DRIVE */ GetDefDriveAllocInfo(context); break; @@ -1159,71 +1160,42 @@ int do_int21(struct sigcontext_struct * context){ return 1; } -/********************************************************************/ - -static void -GetTimeDate(int time_flag) -{ - struct tm *now; - time_t ltime; - - ltime = time(NULL); - now = localtime(<ime); - if (time_flag) - { - _CX = (now->tm_hour << 8) | now->tm_min; - _DX = now->tm_sec << 8; - } - else - { - _CX = now->tm_year + 1900; - _DX = ((now->tm_mon + 1) << 8) | now->tm_mday; - _AX &= 0xff00; - _AX |= now->tm_wday; - } -#ifdef DEBUG_DOS - printf("GetTimeDate: AX = %04x, CX = %04x, DX = %04x\n", _AX, _CX, _DX); -#endif - - ReturnFromRegisterFunc(); - /* Function does not return */ -} - /********************************************************************** - * KERNEL_DOS3Call + * DOS3Call */ -int KERNEL_DOS3Call() +int DOS3Call() { - switch ((_AX >> 8) & 0xff) - { - case 0x30: - _AX = 0x0303; - ReturnFromRegisterFunc(); - /* Function does not return */ + static struct sigcontext_struct *context = NULL; - case 0x25: - case 0x35: + if (!context) + context = malloc(sizeof(struct sigcontext_struct)); + +/* fprintf(stderr, "DOS3: AX %04x, BX %04x, CX %04x, DX %04x, SI %04x, DI %04x, DS %04x, ES %04x\n", + _AX, _BX, _CX, _DX, _SI, _DI, _DS, _ES); +*/ + EAX = _AX; + EBX = _BX; + ECX = _CX; + EDX = _DX; + DS = _DS; + ES = _ES; + DI = _DI; + SI = _SI; +/* EFL = _FL; +*/ + do_int21(context); + + _AX = AX; + _BX = BX; + _CX = CX; + _DX = DX; + + _DS = DS; + _ES = ES; + + _DI = DI; + _SI = SI; +/* _FL = EFL; + */ return 0; - - case 0x2a: - GetTimeDate(0); - /* Function does not return */ - - case 0x2c: - GetTimeDate(1); - /* Function does not return */ - - case 0x4c: - exit(_AX & 0xff); - - default: - fprintf(stderr, "DOS: AX %04x, BX %04x, CX %04x, DX %04x\n", - _AX, _BX, _CX, _DX); - fprintf(stderr, " SP %04x, BP %04x, SI %04x, DI %04x\n", - _SP, _BP, _SI, _DI); - fprintf(stderr, " DS %04x, ES %04x\n", - _DS, _ES); - } - - return 0; } diff --git a/misc/kernel.c b/miscemu/kernel.c similarity index 78% rename from misc/kernel.c rename to miscemu/kernel.c index 3cdd9504158..d257b1611f0 100644 --- a/misc/kernel.c +++ b/miscemu/kernel.c @@ -66,18 +66,3 @@ KERNEL_WaitEvent(int task) #endif return 0; } -/********************************************************************** - * KERNEL_GetModuleFileName - */ -int -KERNEL_GetModuleFileName(int module, char *filename, int bytes) -{ -#ifdef DEBUG_RELAY - printf("GetModuleFileName: module %d, filename %x, bytes %d\n", - module, filename, bytes); -#endif - - strcpy(filename, "TEST.EXE"); - - return strlen(filename); -} diff --git a/objects/Makefile b/objects/Makefile deleted file mode 100644 index cb70d89a4ee..00000000000 --- a/objects/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR) - -OBJS=bitmap.o brush.o font.o gdiobj.o palette.o pen.o dib.o region.o \ - text.o dcvalues.o clipping.o bitblt.o linedda.o color.o - -default: objects.o - -objects.o: $(OBJS) - $(LD) -r -o objects.o $(OBJS) - -clean: - rm -f *.o *~ *.s dll_* *.a *# - -depend: - $(CC) $(CFLAGS) -M *.c > .depend - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/objects/bitblt.c b/objects/bitblt.c index 7b0d4ae366f..bbfa3bd5e52 100644 --- a/objects/bitblt.c +++ b/objects/bitblt.c @@ -9,6 +9,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include #include #include +#include #include "gdi.h" @@ -112,8 +113,148 @@ BOOL BitBlt( HDC hdcDest, short xDest, short yDest, short width, short height, +/*********************************************************************** + * black on white stretch -- favors color pixels over white + * + */ +static void bonw_stretch(XImage *sxi, XImage *dxi, + short widthSrc, short heightSrc, short widthDest, short heightDest) +{ + float deltax, deltay, sourcex, sourcey, oldsourcex, oldsourcey; + register int x, y; + Pixel whitep; + int totalx, totaly, xavgwhite, yavgwhite; + register int i; + int endx, endy; + + deltax = (float)widthSrc/widthDest; + deltay = (float)heightSrc/heightDest; + whitep = WhitePixel(display, DefaultScreen(display)); + + oldsourcex = 0; + for (x=0, sourcex=0.0; x 1.0) { + totalx = 0; + endx = (int)sourcex; + for (i=(int)oldsourcex; i<=endx; i++) + if (XGetPixel(sxi, i, (int)sourcey) == whitep) + totalx++; + xavgwhite = (totalx > (int)(deltax / 2.0)); + } else { + xavgwhite = 0; + } + + oldsourcey = 0; + for (y=0, sourcey=0.0; y 1.0) { + totaly = 0; + endy = (int)sourcey; + for (i=(int)oldsourcey; i<=endy; i++) + if (XGetPixel(sxi, (int)sourcex, i) == whitep) + totaly++; + yavgwhite = (totaly > ((int)deltay / 2)); + } else { + yavgwhite = 0; + } + if (xavgwhite && yavgwhite) + XPutPixel(dxi, x, y, whitep); + else + XPutPixel(dxi, x, y, XGetPixel(sxi, (int)sourcex, (int)sourcey)); + + } /* for all y in dest */ + } /* for all x in dest */ + +} + +/*********************************************************************** + * white on black stretch -- favors color pixels over black + * + */ +static void wonb_stretch(XImage *sxi, XImage *dxi, + short widthSrc, short heightSrc, short widthDest, short heightDest) +{ + float deltax, deltay, sourcex, sourcey, oldsourcex, oldsourcey; + register int x, y; + Pixel blackp; + int totalx, totaly, xavgblack, yavgblack; + register int i; + int endx, endy; + + deltax = (float)widthSrc/widthDest; + deltay = (float)heightSrc/heightDest; + blackp = WhitePixel(display, DefaultScreen(display)); + + oldsourcex = 0; + for (x=0, sourcex=0.0; x 1.0) { + totalx = 0; + endx = (int)sourcex; + for (i=(int)oldsourcex; i<=endx; i++) + if (XGetPixel(sxi, i, (int)sourcey) == blackp) + totalx++; + xavgblack = (totalx > (int)(deltax / 2.0)); + } else { + xavgblack = 0; + } + + oldsourcey = 0; + for (y=0, sourcey=0.0; y 1.0) { + totaly = 0; + endy = (int)sourcey; + for (i=(int)oldsourcey; i<=endy; i++) + if (XGetPixel(sxi, (int)sourcex, i) == blackp) + totaly++; + yavgblack = (totaly > ((int)deltay / 2)); + } else { + yavgblack = 0; + } + if (xavgblack && yavgblack) + XPutPixel(dxi, x, y, blackp); + else + XPutPixel(dxi, x, y, XGetPixel(sxi, (int)sourcex, (int)sourcey)); + + } /* for all y in dest */ + } /* for all x in dest */ +} + +/*********************************************************************** + * color stretch -- deletes unused pixels + * + */ +static void color_stretch(XImage *sxi, XImage *dxi, + short widthSrc, short heightSrc, short widthDest, short heightDest) +{ + float deltax, deltay, sourcex, sourcey; + register int x, y; + + deltax = (float)widthSrc/widthDest; + deltay = (float)heightSrc/heightDest; + + for (x=0, sourcex=0.0; xw.stretchBltMode); +#endif if ((rop & 0xcc0000) == ((rop & 0x330000) << 2)) return PatBlt( hdcDest, xDest, yDest, widthDest, heightDest, rop ); - printf("here\n"); + /* don't stretch the bitmap unless we have to; if we don't, + * call BitBlt for a performance boost + */ + + if (widthSrc == widthDest && heightSrc == heightDest) { + return BitBlt(hdcDest, xDest, yDest, widthSrc, heightSrc, + hdcSrc, xSrc, ySrc, rop); + } rop >>= 16; if ((rop & 0x0f) != (rop >> 4)) { - printf( "BitBlt: Unimplemented ROP %02x\n", rop ); + printf( "StretchBlt: Unimplemented ROP %02x\n", rop ); return FALSE; } - printf("here2\n"); - dcDest = (DC *) GDI_GetObjPtr( hdcDest, DC_MAGIC ); if (!dcDest) return FALSE; dcSrc = (DC *) GDI_GetObjPtr( hdcSrc, DC_MAGIC ); if (!dcSrc) return FALSE; - xs1 = XLPTODP( dcSrc, xSrc ); - xs2 = XLPTODP( dcSrc, xSrc + widthSrc ); - ys1 = YLPTODP( dcSrc, ySrc ); - ys2 = YLPTODP( dcSrc, ySrc + heightSrc ); - xd1 = XLPTODP( dcDest, xDest ); - xd2 = XLPTODP( dcDest, xDest + widthDest ); - yd1 = YLPTODP( dcDest, yDest ); - yd2 = YLPTODP( dcDest, yDest + heightDest ); + xs1 = dcSrc->w.DCOrgX + XLPTODP( dcSrc, xSrc ); + xs2 = dcSrc->w.DCOrgX + XLPTODP( dcSrc, xSrc + widthSrc ); + ys1 = dcSrc->w.DCOrgY + YLPTODP( dcSrc, ySrc ); + ys2 = dcSrc->w.DCOrgY + YLPTODP( dcSrc, ySrc + heightSrc ); + xd1 = dcDest->w.DCOrgX + XLPTODP( dcDest, xDest ); + xd2 = dcDest->w.DCOrgX + XLPTODP( dcDest, xDest + widthDest ); + yd1 = dcDest->w.DCOrgY + YLPTODP( dcDest, yDest ); + yd2 = dcDest->w.DCOrgY + YLPTODP( dcDest, yDest + heightDest ); - DC_SetupGCForText( dcDest ); - XSetFunction( XT_display, dcDest->u.x.gc, DC_XROPfunction[rop & 0x0f] ); - if (dcSrc->w.bitsPerPixel == dcDest->w.bitsPerPixel) - { - printf("XCopyArea\n"); - XCopyArea( XT_display, dcSrc->u.x.drawable, - dcDest->u.x.drawable, dcDest->u.x.gc, - MIN(xs1,xs2), MIN(ys1,ys2), abs(xd2-xd1), abs(yd2-yd1), - MIN(xd1,xd2), MIN(yd1,yd2) ); - } - else - { - printf("XCopyPlane\n"); - if (dcSrc->w.bitsPerPixel != 1) return FALSE; - XCopyPlane( XT_display, dcSrc->u.x.drawable, - dcDest->u.x.drawable, dcDest->u.x.gc, - MIN(xs1,xs2), MIN(ys1,ys2), abs(xd2-xd1), abs(yd2-yd1), - MIN(xd1,xd2), MIN(yd1,yd2), 1 ); + /* get a source and destination image so we can manipulate + * the pixels + */ + + sxi = XGetImage(display, dcSrc->u.x.drawable, xs1, ys1, + widthSrc, heightSrc, AllPlanes, ZPixmap); + dxi = XCreateImage(display, DefaultVisualOfScreen(screen), + DefaultDepthOfScreen(screen), ZPixmap, + 0, NULL, widthDest, heightDest, + 32, 0); + dxi->data = malloc(dxi->bytes_per_line * heightDest); + + stretchmode = ((DC *)GDI_GetObjPtr(hdcDest, DC_MAGIC))->w.stretchBltMode; + + /* the actual stretching is done here, we'll try to use + * some interolation to get some speed out of it in + * the future + */ + + switch (stretchmode) { + case BLACKONWHITE: + bonw_stretch(sxi, dxi, widthSrc, heightSrc, + widthDest, heightDest); + break; + case WHITEONBLACK: + wonb_stretch(sxi, dxi, widthSrc, heightSrc, + widthDest, heightDest); + break; + case COLORONCOLOR: + color_stretch(sxi, dxi, widthSrc, heightSrc, + widthDest, heightDest); + break; + default: + fprintf(stderr, "StretchBlt: unknown stretchmode '%d'\n", + stretchmode); + break; } + + DC_SetupGCForText(dcDest); + XSetFunction(display, dcDest->u.x.gc, DC_XROPfunction[rop & 0x0f]); + XPutImage(display, dcDest->u.x.drawable, dcDest->u.x.gc, + dxi, 0, 0, MIN(xd1,xd2), MIN(yd1,yd2), + widthDest, heightDest); + + /* now free the images we created */ + + XDestroyImage(sxi); + XDestroyImage(dxi); + return TRUE; - - } diff --git a/objects/font.c b/objects/font.c index 8345e0b1323..883e699bf98 100644 --- a/objects/font.c +++ b/objects/font.c @@ -358,6 +358,16 @@ BOOL GetTextMetrics( HDC hdc, LPTEXTMETRIC metrics ) CI_GET_CHAR_INFO(fs, fs->default_char, NULL, cs) +/*********************************************************************** + * SetMapperFlags (GDI.349) + */ +DWORD SetMapperFlags(HDC hDC, DWORD dwFlag) +{ + printf("SetmapperFlags(%04X, %08X) // Empty Stub !\n", hDC, dwFlag); + return 0L; +} + + /*********************************************************************** * GetCharWidth (GDI.350) */ diff --git a/objects/gdiobj.c b/objects/gdiobj.c index 1b98fc8db81..bc59d860b15 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -146,12 +146,14 @@ BOOL GDI_Init() { struct segment_descriptor_s * s; - /* Create GDI heap */ +#ifndef WINELIB + /* Create GDI heap */ s = (struct segment_descriptor_s *)GetNextSegment( 0, 0x10000 ); if (s == NULL) return FALSE; HEAP_Init( &GDI_Heap, s->base_addr, GDI_HEAP_SIZE ); - +#endif + /* Create default palette */ COLOR_Init(); diff --git a/objects/palette.c b/objects/palette.c index 0ff149ebb6e..03300c43778 100644 --- a/objects/palette.c +++ b/objects/palette.c @@ -10,10 +10,11 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #ifdef linux #include #endif -#if defined(__NetBSD__) || defined(__FreeBSD__) +#if !defined (MAXINT) #include #define MAXINT INT_MAX #endif + #include #include "gdi.h" diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index 535cc4716d3..00000000000 --- a/test/Makefile +++ /dev/null @@ -1,347 +0,0 @@ -# Makefile generated by imake - do not edit! -# $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $ - -# ------------------------------------------------------------------------- -# Makefile generated from "Imake.tmpl" and -# $XFree86: mit/config/Imake.tmpl,v 1.17 1993/06/03 15:26:36 dawes Exp $ -# $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $ -# -# Platform-specific parameters may be set in the appropriate .cf -# configuration files. Site-specific parameters should be set in the file -# site.def. Full rebuilds are recommended if any parameters are changed. -# -# If your C preprocessor does not define any unique symbols, you will need -# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing -# "make World" the first time). -# - -# ------------------------------------------------------------------------- -# site-specific configuration parameters that need to come before -# the platform-specific parameters - edit site.def to change - -# $XFree86: mit/config/site.def,v 1.65 1993/06/04 16:02:47 dawes Exp $ -# site: $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $ - -# obz: changes for making Linux distribution - -# ------------------------------------------------------------------------- -# platform-specific configuration parameters - edit x386.cf to change - -# $XFree86: mit/config/x386.cf,v 1.90 1993/06/04 16:02:50 dawes Exp $ -# platform: $XConsortium: x386.cf,v 1.7 91/08/16 19:30:10 gildea Exp $ - -# ------------------------------------------------------------------------- -# XFree86 version definition -# $XFree86: mit/config/xf86_vers.def,v 1.5 1993/06/01 09:12:47 dawes Exp $ - -# ------------------------------------------------------------------------- -# XFree86 version: 1300 -# ------------------------------------------------------------------------- - -# $XFree86: mit/config/lnuxLib.rules,v 1.2 1993/06/02 13:48:12 dawes Exp $ - -DLL_BINDIR = /usr/dll/bin - -# operating system: Linux - -# ------------------------------------------------------------------------- -# site-specific configuration parameters that go after -# the platform-specific parameters - edit site.def to change - -# $XFree86: mit/config/site.def,v 1.65 1993/06/04 16:02:47 dawes Exp $ -# site: $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $ - -# obz: changes for making Linux distribution - - SHELL = /bin/sh - - TOP = ../. - CURRENT_DIR = ./test - - AR = ar clq - BOOTSTRAPCFLAGS = - CC = gcc - AS = as - - LEX = flex - - YACC = bison -y - - COMPRESS = compress - CPP = /lib/cpp $(STD_CPP_DEFINES) - PREPROCESSCMD = /lib/cpp $(STD_CPP_DEFINES) - INSTALL = install - LD = ld - LINT = lint - LINTLIBFLAG = -C - LINTOPTS = -axz - LN = ln -s - MAKE = make - MV = mv - CP = cp - - RANLIB = ranlib - RANLIBINSTFLAGS = - - RM = rm -f - TROFF = psroff - MSMACROS = -ms - TBL = tbl - EQN = eqn - STD_INCLUDES = - STD_CPP_DEFINES = -traditional -D_POSIX_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -Dlinux - STD_DEFINES = -D_POSIX_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -Dlinux - EXTRA_LOAD_FLAGS = - EXTRA_LIBRARIES = - OS_LIBRARIES = - TAGS = ctags - - SHAREDCODEDEF = - SHLIBDEF = - - PROTO_DEFINES = -DFUNCPROTO=11 -DNARROWPROTO - - INSTPGMFLAGS = -s - - INSTBINFLAGS = -m 0755 - INSTUIDFLAGS = -s -m 4755 - INSTLIBFLAGS = -m 0644 - INSTINCFLAGS = -m 0444 - INSTMANFLAGS = -m 0444 - INSTDATFLAGS = -m 0444 - INSTKMEMFLAGS = -s -m 4755 - - PROJECTROOT = /usr/X386 - - TOP_INCLUDES = -I$(INCROOT) - - CDEBUGFLAGS = -O2 - CCOPTIONS = -m486 -DNO_ASM -fwritable-strings - ANSICCOPTIONS = - - ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES) - ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES) - CFLAGS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) - LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) - - LDLIBS = $(OS_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) - - LDOPTIONS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR) - - LDCOMBINEFLAGS = -r - DEPENDFLAGS = - - MACROFILE = x386.cf - RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut - - IMAKE_DEFINES = - - IRULESRC = $(CONFIGDIR) - IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) - - ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) - -# ------------------------------------------------------------------------- -# X Window System Build Parameters -# $XFree86: mit/config/Project.tmpl,v 1.13 1993/03/27 03:32:45 dawes Exp $ -# $XConsortium: Project.tmpl,v 1.138.1.1 92/11/11 09:49:19 rws Exp $ - -_percentC_ = %C - -# ------------------------------------------------------------------------- -# X Window System make variables; this need to be coordinated with rules - - PATHSEP = / - USRLIBDIR = /usr/X386/lib - BINDIR = /usr/X386/bin - INCROOT = /usr/X386/include - BUILDINCROOT = $(TOP) - BUILDINCDIR = $(BUILDINCROOT)/X11 - BUILDINCTOP = .. - INCDIR = $(INCROOT)/X11 - ADMDIR = /usr/adm - LIBDIR = $(USRLIBDIR)/X11 - CONFIGDIR = $(LIBDIR)/config - LINTLIBDIR = $(USRLIBDIR)/lint - - FONTDIR = $(LIBDIR)/fonts - XINITDIR = $(LIBDIR)/xinit - XDMDIR = $(LIBDIR)/xdm - TWMDIR = $(LIBDIR)/twm - MANPATH = /usr/X386/man - MANSOURCEPATH = $(MANPATH)/man - MANSUFFIX = 1x - LIBMANSUFFIX = 3x - MANDIR = $(MANSOURCEPATH)1 - LIBMANDIR = $(MANSOURCEPATH)3 - NLSDIR = $(LIBDIR)/nls - PEXAPIDIR = $(LIBDIR)/PEX - XAPPLOADDIR = $(LIBDIR)/app-defaults - FONTCFLAGS = -t - LINKKITDIR = $(USRLIBDIR)/Server - - INSTAPPFLAGS = $(INSTDATFLAGS) - - IMAKE = imake - DEPEND = makedepend - RGB = rgb - - FONTC = bdftopcf - - MKFONTDIR = mkfontdir - MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier - - CONFIGSRC = $(TOP)/config - DOCUTILSRC = $(TOP)/doc/util - CLIENTSRC = $(TOP)/clients - DEMOSRC = $(TOP)/demos - LIBSRC = $(TOP)/lib - FONTSRC = $(TOP)/fonts - INCLUDESRC = $(TOP)/X11 - SERVERSRC = $(TOP)/server - UTILSRC = $(TOP)/util - SCRIPTSRC = $(UTILSRC)/scripts - EXAMPLESRC = $(TOP)/examples - CONTRIBSRC = $(TOP)/../contrib - DOCSRC = $(TOP)/doc - RGBSRC = $(TOP)/rgb - DEPENDSRC = $(UTILSRC)/makedepend - IMAKESRC = $(CONFIGSRC) - XAUTHSRC = $(LIBSRC)/Xau - XLIBSRC = $(LIBSRC)/X - XMUSRC = $(LIBSRC)/Xmu - TOOLKITSRC = $(LIBSRC)/Xt - AWIDGETSRC = $(LIBSRC)/Xaw - OLDXLIBSRC = $(LIBSRC)/oldX - XDMCPLIBSRC = $(LIBSRC)/Xdmcp - BDFTOSNFSRC = $(FONTSRC)/bdftosnf - BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf - BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf - MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir - FSLIBSRC = $(FONTSRC)/lib/fs - FONTSERVERSRC = $(FONTSRC)/server - EXTENSIONSRC = $(TOP)/extensions - XILIBSRC = $(EXTENSIONSRC)/lib/xinput - PEXLIBSRC = $(EXTENSIONSRC)/lib/PEXlib - PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX - -# $XFree86: mit/config/lnuxLib.tmpl,v 1.1 1993/04/16 14:06:06 dawes Exp $ - -SHLIBLDFLAGS = -PICFLAGS = -B/usr/dll/jump/ - - DEPEXTENSIONLIB = - EXTENSIONLIB = -lXext - - DEPXLIB = $(DEPEXTENSIONLIB) - XLIB = $(EXTENSIONLIB) -lX11 - - DEPXMULIB = - XMULIB = -lXmu - - DEPXTOOLLIB = - XTOOLLIB = -lXt - - DEPXAWLIB = - XAWLIB = -lXaw - - DEPXILIB = - XILIB = -lXi - - DEPXTESTLIB = - XTESTLIB = -lXtst - - DEPPEXLIB = - PEXLIB = -lPEX5 - - SOXLIBREV = 3.0.1 - SOXTREV = 3.0.1 - SOXAWREV = 3.0.1 - SOOLDXREV = 3.0.1 - SOXMUREV = 3.0.1 - SOXEXTREV = 3.0.1 - SOXINPUTREV = 3.0.1 - SOPEXREV = 1.0.1 - - DEPXAUTHLIB = $(USRLIBDIR)/libXau.a - XAUTHLIB = -lXau - DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a - XDMCPLIB = -lXdmcp - - DEPOLDXLIB = $(USRLIBDIR)/liboldX.a - OLDXLIB = -loldX - - DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a - PHIGSLIB = -lphigs - - DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a - XBSDLIB = -lXbsd - - LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln - LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln - LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln - LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln - LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln - LINTXI = $(LINTLIBDIR)/llib-lXi.ln - LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln - LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln - - DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) - - DEPLIBS1 = $(DEPLIBS) - DEPLIBS2 = $(DEPLIBS) - DEPLIBS3 = $(DEPLIBS) - -# ------------------------------------------------------------------------- -# Imake rules for building libraries, programs, scripts, and data files -# $XFree86: mit/config/Imake.rules,v 1.9 1993/03/23 12:56:27 dawes Exp $ -# rules: $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $ - -# ------------------------------------------------------------------------- -# start of Imakefile - -all:: - -depend:: - -clean:: - -includes:: - -# ------------------------------------------------------------------------- -# common rules for all Makefiles - do not edit - -emptyrule:: - -clean:: - $(RM_CMD) "#"* - -Makefile:: - -@if [ -f Makefile ]; then set -x; \ - $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ - else exit 0; fi - $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) - -tags:: - $(TAGS) -w *.[ch] - $(TAGS) -xw *.[ch] > TAGS - -# ------------------------------------------------------------------------- -# empty rules for directories that do not have SUBDIRS - do not edit - -install:: - @echo "install in $(CURRENT_DIR) done" - -install.man:: - @echo "install.man in $(CURRENT_DIR) done" - -install.linkkit:: - @echo "install.linkkit in $(CURRENT_DIR) done" - -Makefiles:: - -includes:: - -# ------------------------------------------------------------------------- -# dependencies generated by makedepend - diff --git a/test/hyperoid.exe b/test/hyperoid.exe new file mode 100644 index 00000000000..4e689f0eeb6 Binary files /dev/null and b/test/hyperoid.exe differ diff --git a/test/widget.exe b/test/widget.exe index 42d1465cc5f..6d8fb2ff67d 100755 Binary files a/test/widget.exe and b/test/widget.exe differ diff --git a/toolkit/Imakefile b/toolkit/Imakefile new file mode 100644 index 00000000000..53a7da3ffc0 --- /dev/null +++ b/toolkit/Imakefile @@ -0,0 +1,18 @@ +#include "../Wine.tmpl" + +MODULE = toolkit + +SRCS = \ + heap.c \ + sup.c \ + winmain.c + +OBJS = $(SRCS:.c=.o) + +WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) +DependTarget() +CleanTarget() + +includes:: + +install:: diff --git a/toolkit/heap.c b/toolkit/heap.c new file mode 100644 index 00000000000..93071569c21 --- /dev/null +++ b/toolkit/heap.c @@ -0,0 +1,202 @@ +/* + * Memory alllocation for the Wine Library toolkit + * + * Copyright (C) 1994 Miguel de Icaza + * + * All the memory management is being done by the libc malloc and friends. + */ + +#ifndef __STDC__ +#include +#endif +#include "windows.h" + +/* Controls the blocks per handle table */ +#define MAXBLOCKS 512 + +static char Copyright [] = "Copyright (C) 1994 Miguel de Icaza"; + +typedef struct handle_table { + struct handle_table *next; + void *blocks [MAXBLOCKS]; +} handle_table_t; + +static handle_table_t handle_table; + +static void **HEAP_GetFreeSlot (HANDLE *hNum) +{ + handle_table_t *table, *last; + int i, j; + + for (table = &handle_table, j = 0; table; table = table->next, j++){ + for (i = 0; i < MAXBLOCKS; i++) + if (!table->blocks [i]) + goto AssignBlock; + last = table; + } + + /* No free slots */ + last->next = malloc (sizeof (handle_table_t)); + table = last->next; + memset (table, 0, sizeof (handle_table_t)); + i = 0; + + AssignBlock: + *hNum = j*MAXBLOCKS+i; + return &table->blocks [i]; +} + +static void HEAP_Handle_is_Zero () +{ + printf ("Warning: Handle is Zero, segmentation fault comming\n"); +} + +static void **HEAP_FindSlot (HANDLE hNum) +{ + handle_table_t *table = &handle_table; + int i, j; + + if (!hNum) + HEAP_Handle_is_Zero (); + + hNum--; + for (j = hNum; j > MAXBLOCKS; j -= MAXBLOCKS){ + table = table->next; + if (!table) return 0; + } + return &table->blocks [hNum%MAXBLOCKS]; +} + +HANDLE LocalAlloc (WORD flags, WORD bytes) +{ + void *m; + void **slot; + HANDLE hMem; + + slot = HEAP_GetFreeSlot (&hMem); + if (flags & LMEM_WINE_ALIGN) + m = memalign (4, bytes); + else + m = malloc (bytes); + if (m){ + *slot = m; + if (flags & LMEM_ZEROINIT) + bzero (m, bytes); + +#ifdef DEBUG_HEAP + printf ("Handle %d [%d] = %p\n", hMem+1, bytes, m); +#endif + return hMem+1; + } + return 0; +} + +WORD LocalCompact (WORD min_free) +{ + return min_free; +} + +WORD LocalFlags (HANDLE hMem) +{ + return 0; +} + +HANDLE LocalFree (HANDLE hMem) +{ + void **m = HEAP_FindSlot (hMem); + + free (*m); + *m = 0; + return 0; +} + +BOOL LocalInit (WORD segment, WORD start, WORD end) +{ + return 1; +} + +char *LocalLock (HANDLE hMem) +{ + void **m = HEAP_FindSlot (hMem); +#ifdef DEBUG_HEAP + printf (">%d->%p\n", hMem, *m); +#endif + return *m; +} + +HANDLE LocalReAlloc (HANDLE hMem, WORD flags, WORD bytes) +{ + void **m = HEAP_FindSlot (hMem); + + realloc (*m, bytes); +} + +WORD LocalSize (HANDLE hMem) +{ + /* Not implemented yet */ +} + + +BOOL LocalUnLock (HANDLE hMem) +{ + return 0; +} + +HANDLE GlobalAlloc (WORD flags, DWORD size) +{ + return LocalAlloc (flags, size); +} + +HANDLE GlobalFree (HANDLE hMem) +{ + return LocalFree (hMem); +} + +char *GlobalLock (HANDLE hMem) +{ + return LocalLock (hMem); +} + +BOOL GlobalUnlock (HANDLE hMem) +{ + return LocalUnLock (hMem); +} + +WORD GlobalFlags (HANDLE hMem) +{ + return LocalFlags (hMem); +} + +DWORD GlobalSize (HANDLE hMem) +{ + return LocalSize (hMem); +} + +DWORD GlobalCompact(DWORD desired) +{ + if (desired) + return desired; + else + return 0x01000000; /* Should check the available core. */ +} + +HANDLE GlobalReAlloc(HANDLE hMem, DWORD new_size, WORD flags) +{ + if (!(flags & GMEM_MODIFY)) + return LocalReAlloc (hMem, new_size, flags); +} + +#ifdef UNIMPLEMENTED +void *GlobalQuickAlloc(int size) +{ +} + +DWORD int GlobalHandle(WORD selector) +{ +} + +unsigned int GlobalHandleFromPointer(void *block) +{ +} + +#endif diff --git a/toolkit/sup.c b/toolkit/sup.c new file mode 100644 index 00000000000..e1c4c0e5f73 --- /dev/null +++ b/toolkit/sup.c @@ -0,0 +1,102 @@ +#include +#include "prototypes.h" +#include "windows.h" +#include "callback.h" +#include "wine.h" +#include "arch.h" + +/* HANDLE hSysRes = 1; */ + +LONG CallWindowProc (FARPROC func, HWND hwnd, WORD message, + WORD wParam, LONG lParam) +{ + (*func)(hwnd, message, wParam, lParam); +} + +CallLineDDAProc (FARPROC back, int x, int y, long lParam) +{ + (*back)(x, y, lParam); +} + +/* + * Header loading routines for WineLib. + */ + +/* LOADSHORT Calls LOAD and swaps the high and the low bytes */ + +#define LOAD(x) read (fd, &TAB->x, sizeof (TAB->x)) +#define LOADSHORT(x) LOAD(x); TAB->x = CONV_SHORT (TAB->x); +#define LOADLONG(x) LOAD(x); TAB->x = CONV_LONG (TAB->x); + +void load_mz_header (int fd, struct mz_header_s *mz_header) +{ +#define TAB mz_header + LOAD (dont_care1); + LOAD (must_be_0x40); + LOAD (dont_care2); + LOADSHORT (ne_offset); +} + +void load_ne_header (int fd, struct ne_header_s *ne_header) +{ +#undef TAB +#define TAB ne_header + LOAD (header_type); + LOADSHORT (linker_version); + LOADSHORT (linker_revision); + LOADSHORT (entry_tab_offset); + LOADSHORT (entry_tab_length); + LOAD (reserved1); + LOADSHORT (format_flags); + LOADSHORT (auto_data_seg); + LOADSHORT (local_heap_length); + LOADSHORT (stack_length); + LOADSHORT (ip); + LOADSHORT (cs); + LOADSHORT (sp); + LOADSHORT (ss); + LOADSHORT (n_segment_tab); + LOADSHORT (n_mod_ref_tab); + LOADSHORT (nrname_tab_length); + LOADSHORT (segment_tab_offset); + LOADSHORT (resource_tab_offset); + LOADSHORT (rname_tab_offset); + LOADSHORT (moduleref_tab_offset); + LOADSHORT (iname_tab_offset); + LOADLONG (nrname_tab_offset); + LOADSHORT (n_mov_entry_points); + LOADSHORT (align_shift_count); + LOADSHORT (n_resource_seg); + LOAD (operating_system); + LOAD (additional_flags); + LOADSHORT (fastload_offset); + LOADSHORT (fastload_length); + LOADSHORT (reserved2); + LOADSHORT (expect_version); +} + +/* + * Typeinfo loading routines for non PC-architectures. + */ + +int load_typeinfo (int fd, struct resource_typeinfo_s *typeinfo) +{ +#undef TAB +#define TAB typeinfo + LOADSHORT (type_id); + LOADSHORT (count); + LOADLONG (reserved); + return 1; +} + +int load_nameinfo (int fd, struct resource_nameinfo_s *nameinfo) +{ +#undef TAB +#define TAB nameinfo + LOADSHORT (offset); + LOADSHORT (length); + LOADSHORT (flags); + LOADSHORT (id); + LOADSHORT (handle); + LOADSHORT (usage); +} diff --git a/toolkit/winmain.c b/toolkit/winmain.c new file mode 100644 index 00000000000..3f68eb76eb2 --- /dev/null +++ b/toolkit/winmain.c @@ -0,0 +1,26 @@ +#include +#include "windows.h" +#include "wine.h" + +extern HINSTANCE hSysRes; + +_WinMain (int argc, char *argv []) +{ + int ret_val; + char filename [4096]; + + GetPrivateProfileString("wine", "SystemResources", "sysres.dll", + filename, sizeof(filename), WINE_INI); + hSysRes = LoadImage(filename); + if (hSysRes == (HINSTANCE)NULL) + printf("Error Loading System Resources !!!\n"); + else + printf("System Resources Loaded // hSysRes='%04X'\n", hSysRes); + + USER_InitApp (hSysRes); + ret_val = WinMain (1, /* hInstance */ + 0, /* hPrevInstance */ + "", /* lpszCmdParam */ + SW_NORMAL); /* nCmdShow */ + return ret_val; +} diff --git a/tools/Makefile b/tools/Makefile deleted file mode 100644 index f74628e7970..00000000000 --- a/tools/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR) - -build: build.c - cc $(CFLAGS) -o build build.c - -clean: - rm -f *.o *~ build *# - -depend: - $(CC) $(CFLAGS) -M *.c > .depend - -dummy: - -# -# Dependency lists -# -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/tools/build.c b/tools/build.c index 7343b765e16..9b0eadaff97 100644 --- a/tools/build.c +++ b/tools/build.c @@ -744,7 +744,11 @@ main(int argc, char **argv) fclose(fp); +#ifndef SHORTNAMES sprintf(filename, "dll_%s_tab.c", LowerDLLName); +#else + sprintf(filename, "dtb_%s.c", LowerDLLName); +#endif fp = fopen(filename, "w"); fprintf(fp, "#include \n"); diff --git a/windows/Imakefile b/windows/Imakefile index 5aa561e1adc..947968a3deb 100644 --- a/windows/Imakefile +++ b/windows/Imakefile @@ -5,7 +5,6 @@ MODULE = windows SRCS = \ caret.c \ class.c \ - clipping.c \ dc.c \ dce.c \ defdlg.c \ @@ -27,30 +26,7 @@ SRCS = \ win.c \ winpos.c -OBJS = \ - caret.o \ - class.o \ - clipping.o \ - dc.o \ - dce.o \ - defdlg.o \ - defwnd.o \ - dialog.o \ - event.o \ - focus.o \ - graphics.o \ - keyboard.o \ - mapping.o \ - message.o \ - nonclient.o \ - painting.o \ - scroll.o \ - syscolor.o \ - sysmetrics.o \ - timer.o \ - utility.o \ - win.o \ - winpos.o +OBJS = $(SRCS:.c=.o) WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) DependTarget() diff --git a/windows/Makefile b/windows/Makefile deleted file mode 100644 index 8ac8efab582..00000000000 --- a/windows/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR) - -OBJS=class.o dc.o dce.o event.o message.o win.o timer.o graphics.o \ - clipping.o mapping.o painting.o keyboard.o utility.o syscolor.o \ - defwnd.o defdlg.o dialog.o focus.o scroll.o caret.o winpos.o \ - sysmetrics.o nonclient.o - -default: windows.o - -windows.o: $(OBJS) - $(LD) -r -o windows.o $(OBJS) - -clean: - rm -f *.o *~ *.s dll_* *.a *# - -depend: - $(CC) $(CFLAGS) -M *.c > .depend - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/windows/caret.c b/windows/caret.c index 566e32179e5..1d85120e86a 100644 --- a/windows/caret.c +++ b/windows/caret.c @@ -18,6 +18,7 @@ typedef struct short width; short height; COLORREF color; + HBITMAP bitmap; WORD timeout; WORD timerid; } CARET; @@ -47,7 +48,10 @@ static WORD CARET_Callback(HWND hwnd, WORD msg, WORD timerid, LONG ctime) { Caret.on = (Caret.on ? FALSE : TRUE); hdc = GetDC(Caret.hwnd); - hBrush = CreateSolidBrush(Caret.color); + if (Caret.bitmap == 0 || Caret.bitmap == 1) + hBrush = CreateSolidBrush(Caret.color); + else + hBrush = CreatePatternBrush(Caret.bitmap); SelectObject(hdc, (HANDLE)hBrush); SetROP2(hdc, R2_XORPEN); rgn = CreateRectRgn(Caret.x, Caret.y, @@ -74,7 +78,10 @@ static void CARET_HideCaret() Caret.on = FALSE; hdc = GetDC(Caret.hwnd); - hBrush = CreateSolidBrush(Caret.color); + if (Caret.bitmap == 0 || Caret.bitmap == 1) + hBrush = CreateSolidBrush(Caret.color); + else + hBrush = CreatePatternBrush(Caret.bitmap); SelectObject(hdc, (HANDLE)hBrush); SetROP2(hdc, R2_XORPEN); rgn = CreateRectRgn(Caret.x, Caret.y, @@ -100,28 +107,28 @@ void CreateCaret(HWND hwnd, HBITMAP bitmap, short width, short height) /* if (Caret.hwnd) DestroyCaret(); */ - if (bitmap) - { - printf("CreateCaret: Bitmaps are currently not supported\n"); - return; - } + if (bitmap && bitmap != 1) + Caret.bitmap = bitmap; if (width) Caret.width = width; else - Caret.width = 3; /* should be SM_CXBORDER */ + Caret.width = GetSystemMetrics(SM_CXBORDER); if (height) Caret.height = height; else - Caret.height = 3; /* should be SM_CYBORDER */ + Caret.height = GetSystemMetrics(SM_CYBORDER); Caret.hwnd = hwnd; Caret.hidden = 1; Caret.on = FALSE; Caret.x = 0; Caret.y = 0; - Caret.color = GetSysColor(COLOR_WINDOWTEXT); + if (bitmap == 1) + Caret.color = GetSysColor(COLOR_GRAYTEXT); + else + Caret.color = GetSysColor(COLOR_WINDOWTEXT); Caret.timeout = 750; LockCaret = FALSE; diff --git a/windows/class.c b/windows/class.c index 4ca2d9f5a2d..fbec0a16819 100644 --- a/windows/class.c +++ b/windows/class.c @@ -123,7 +123,7 @@ ATOM RegisterClass( LPWNDCLASS class ) else newClass->hdce = 0; /* Menu name should also be set to zero. */ - newClass->wc.lpszClassName = NULL; + newClass->wc.lpszClassName = NULL; if (class->cbClsExtra) memset( newClass->wExtra, 0, class->cbClsExtra ); firstClass = handle; diff --git a/windows/clipping.c b/windows/clipping.c deleted file mode 100644 index 28d0da9578e..00000000000 --- a/windows/clipping.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Window clipping functions - * - * Copyright 1993 Alexandre Julliard - */ - -static char Copyright[] = "Copyright Alexandre Julliard, 1993"; - -#include - -#include "windows.h" -#include "win.h" -#include "message.h" - - -/*********************************************************************** - * InvalidateRgn (USER.126) - */ -void InvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase ) -{ - HRGN newRgn; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return; - - if (!hrgn) - { - newRgn = CreateRectRgn(0, 0, - wndPtr->rectClient.right-wndPtr->rectClient.left, - wndPtr->rectClient.bottom-wndPtr->rectClient.top ); - } - else - { - if (!(newRgn = CreateRectRgn( 0, 0, 0, 0 ))) return; - if (!wndPtr->hrgnUpdate) CombineRgn( newRgn, hrgn, 0, RGN_COPY ); - else CombineRgn( newRgn, wndPtr->hrgnUpdate, hrgn, RGN_OR ); - } - if (wndPtr->hrgnUpdate) DeleteObject( wndPtr->hrgnUpdate ); - else MSG_IncPaintCount( wndPtr->hmemTaskQ ); - wndPtr->hrgnUpdate = newRgn; - if (erase) wndPtr->flags |= WIN_ERASE_UPDATERGN; - - /* Invalidate the children overlapping the region */ - - if (wndPtr->dwStyle & WS_CLIPCHILDREN) return; - for (hwnd = wndPtr->hwndChild; (hwnd); hwnd = wndPtr->hwndNext) - { - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break; - if (hrgn && !RectInRegion( hrgn, &wndPtr->rectWindow )) continue; - InvalidateRgn( hwnd, hrgn, erase ); - } -} - - -/*********************************************************************** - * InvalidateRect (USER.125) - */ -void InvalidateRect( HWND hwnd, LPRECT rect, BOOL erase ) -{ - HRGN hrgn = 0; - - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return; - -#ifdef DEBUG_WIN - if (rect) printf( "InvalidateRect: %d %d,%d-%d,%d\n", hwnd, - rect->left, rect->top, rect->right, rect->bottom ); - else printf( "InvalidateRect: %d NULL\n", hwnd ); -#endif - if (rect) hrgn = CreateRectRgnIndirect( rect ); - InvalidateRgn( hwnd, hrgn, erase ); - if (hrgn) DeleteObject( hrgn ); -} - - -/*********************************************************************** - * ValidateRgn (USER.128) - */ -void ValidateRgn( HWND hwnd, HRGN hrgn ) -{ - HRGN newRgn; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return; - - if (!wndPtr->hrgnUpdate) return; - if (!hrgn) newRgn = 0; - else - { - if (!(newRgn = CreateRectRgn( 0, 0, 0, 0 ))) return; - if (CombineRgn( newRgn, wndPtr->hrgnUpdate, hrgn, RGN_DIFF ) == NULLREGION) - { - DeleteObject( newRgn ); - newRgn = 0; - } - } - DeleteObject( wndPtr->hrgnUpdate ); - wndPtr->hrgnUpdate = newRgn; - if (!wndPtr->hrgnUpdate) wndPtr->flags &= ~WIN_ERASE_UPDATERGN; -} - - -/*********************************************************************** - * ValidateRect (USER.127) - */ -void ValidateRect( HWND hwnd, LPRECT rect ) -{ - HRGN hrgn = 0; - - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return; - - if (rect) hrgn = CreateRectRgnIndirect( rect ); - ValidateRgn( hwnd, hrgn ); - if (hrgn) DeleteObject( hrgn ); -} - - -/*********************************************************************** - * GetUpdateRect (USER.190) - */ -BOOL GetUpdateRect( HWND hwnd, LPRECT rect, BOOL erase ) -{ - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return FALSE; - - if (rect) - { - if (wndPtr->hrgnUpdate) - { - HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); - if (GetUpdateRgn( hwnd, hrgn, erase ) == ERROR) return FALSE; - GetRgnBox( hrgn, rect ); - DeleteObject( hrgn ); - } - else SetRectEmpty( rect ); - } - return (wndPtr->hrgnUpdate != 0); -} - - -/*********************************************************************** - * GetUpdateRgn (USER.237) - */ -int GetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase ) -{ - HRGN hrgnClip; - int retval; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return ERROR; - - if (!wndPtr->hrgnUpdate) - { - if (!(hrgnClip = CreateRectRgn( 0, 0, 0, 0 ))) return ERROR; - retval = CombineRgn( hrgn, hrgnClip, 0, RGN_COPY ); - } - else - { - hrgnClip = CreateRectRgn( 0, 0, - wndPtr->rectClient.right-wndPtr->rectClient.left, - wndPtr->rectClient.bottom-wndPtr->rectClient.top ); - if (!hrgnClip) return ERROR; - retval = CombineRgn( hrgn, wndPtr->hrgnUpdate, hrgnClip, RGN_AND ); - if (erase) - { - HDC hdc = GetDCEx( hwnd, wndPtr->hrgnUpdate, - DCX_INTERSECTRGN | DCX_USESTYLE ); - if (hdc) - { - SendMessage( hwnd, WM_ERASEBKGND, hdc, 0 ); - ReleaseDC( hwnd, hdc ); - } - } - } - DeleteObject( hrgnClip ); - return retval; -} diff --git a/windows/dce.c b/windows/dce.c index 5aef283c7f7..6df7ccd121f 100644 --- a/windows/dce.c +++ b/windows/dce.c @@ -86,6 +86,37 @@ void DCE_Init() } +/*********************************************************************** + * DCE_GetVisRect + * + * Return the visible rectangle of a window, i.e. the client or + * window area clipped by the client area of all ancestors. + */ +static void DCE_GetVisRect( WND *wndPtr, BOOL clientArea, RECT *lprect ) +{ + int xoffset, yoffset; + + *lprect = clientArea ? wndPtr->rectClient : wndPtr->rectWindow; + xoffset = lprect->left; + yoffset = lprect->top; + + while (wndPtr->dwStyle & WS_CHILD) + { + WND *parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ); + xoffset += parentPtr->rectClient.left; + yoffset += parentPtr->rectClient.top; + OffsetRect( lprect, parentPtr->rectClient.left, + parentPtr->rectClient.top ); + + /* Warning!! we assume that IntersectRect() handles the case */ + /* where the destination is the same as one of the sources. */ + IntersectRect( lprect, lprect, &parentPtr->rectClient ); + wndPtr = parentPtr; + } + OffsetRect( lprect, -xoffset, -yoffset ); +} + + /*********************************************************************** * GetDCEx (USER.359) */ @@ -94,6 +125,7 @@ void DCE_Init() HDC GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) { HANDLE hdce; + RECT clipRect; HDC hdc = 0; DCE * dce; DC * dc; @@ -155,8 +187,11 @@ HDC GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) dc->w.DCOrgY = wndPtr->rectClient.top - wndPtr->rectWindow.top; dc->w.DCSizeX = wndPtr->rectClient.right - wndPtr->rectClient.left; dc->w.DCSizeY = wndPtr->rectClient.bottom - wndPtr->rectClient.top; - IntersectVisRect( hdc, 0, 0, dc->w.DCSizeX, dc->w.DCSizeY ); } + + DCE_GetVisRect( wndPtr, !(flags & DCX_WINDOW), &clipRect ); + IntersectVisRect( hdc, clipRect.left, clipRect.top, + clipRect.right, clipRect.bottom ); } else dc->u.x.drawable = DefaultRootWindow( display ); diff --git a/windows/defwnd.c b/windows/defwnd.c index 62f9f502d71..a495d08b088 100644 --- a/windows/defwnd.c +++ b/windows/defwnd.c @@ -64,6 +64,8 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam ) CREATESTRUCT * createStruct = (CREATESTRUCT *)lParam; if (createStruct->lpszName) DEFWND_SetText( hwnd, createStruct->lpszName ); + if ((createStruct->style & WS_VSCROLL) || + (createStruct->style & WS_HSCROLL)) NC_CreateScrollBars(hwnd); return 1; } @@ -86,11 +88,11 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam ) return NC_HandleNCActivate( hwnd, wParam ); case WM_NCDESTROY: - { - if (wndPtr->hText) USER_HEAP_FREE(wndPtr->hText); - wndPtr->hText = 0; - return 0; - } + if (wndPtr->hText) USER_HEAP_FREE(wndPtr->hText); + wndPtr->hText = 0; + if (wndPtr->VScroll) free(wndPtr->VScroll); + if (wndPtr->HScroll) free(wndPtr->HScroll); + return 0; case WM_PAINT: { diff --git a/windows/event.c b/windows/event.c index 155c66f5e58..87c0229a240 100644 --- a/windows/event.c +++ b/windows/event.c @@ -7,12 +7,17 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include +#include +#include #include "windows.h" #include "win.h" #include "class.h" #include "message.h" +#ifndef FamilyAmoeba +typedef char *XPointer; +#endif #define NB_BUTTONS 3 /* Windows can handle 3 buttons */ @@ -228,8 +233,9 @@ static void EVENT_Expose( HWND hwnd, XExposeEvent *event ) rect.right = rect.left + event->width; rect.bottom = rect.top + event->height; winHasCursor = event->window; - - InvalidateRect( hwnd, &rect, TRUE ); + + RedrawWindow( hwnd, &rect, 0, + RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_NOCHILDREN ); } diff --git a/windows/focus.c b/windows/focus.c index 0e8813857f1..a3ac280e1c7 100644 --- a/windows/focus.c +++ b/windows/focus.c @@ -6,10 +6,7 @@ static char Copyright[] = "Copyright David Metcalfe, 1993"; -#include -#include #include "win.h" -#include "gdi.h" HWND hWndFocus = 0; diff --git a/windows/graphics.c b/windows/graphics.c index 1160d3fec87..b37da40b692 100644 --- a/windows/graphics.c +++ b/windows/graphics.c @@ -10,6 +10,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include #include #include +#include #ifndef PI #define PI M_PI #endif @@ -207,6 +208,75 @@ BOOL Rectangle( HDC hdc, int left, int top, int right, int bottom ) } +/*********************************************************************** + * RoundRect (GDI.28) + */ +BOOL RoundRect( HDC hDC, short left, short top, short right, short bottom, + short ell_width, short ell_height) +{ + int x1, y1, x2, y2; + DC * dc = (DC *) GDI_GetObjPtr(hDC, DC_MAGIC); + if (!dc) return FALSE; +/* + printf("RoundRect(%d %d %d %d %d %d\n", + left, top, right, bottom, ell_width, ell_height); +*/ + x1 = XLPTODP(dc, left); + y1 = YLPTODP(dc, top); + x2 = XLPTODP(dc, right - ell_width); + y2 = YLPTODP(dc, bottom - ell_height); + if (DC_SetupGCForBrush(dc)) { + XFillArc(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + x1, dc->w.DCOrgY + y1, + ell_width, ell_height, 90 * 64, 90 * 64); + XFillArc(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + x1, dc->w.DCOrgY + y2, + ell_width, ell_height, 180 * 64, 90 * 64); + XFillArc(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + x2, dc->w.DCOrgY + y2, + ell_width, ell_height, 270 * 64, 90 * 64); + XFillArc(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + x2, dc->w.DCOrgY + y1, + ell_width, ell_height, 0, 90 * 64); + ell_width /= 2; ell_height /= 2; + XFillRectangle(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + left + ell_width, dc->w.DCOrgY + top, + right - left - 2 * ell_width, bottom - top); + XFillRectangle(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + left, dc->w.DCOrgY + top + ell_height, + ell_width, bottom - top - 2 * ell_height); + XFillRectangle(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + right - ell_width, dc->w.DCOrgY + top + ell_height, + ell_width, bottom - top - 2 * ell_height); + ell_width *= 2; ell_height *= 2; + } + if (DC_SetupGCForPen(dc)) { + XDrawArc(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + x1, dc->w.DCOrgY + y1, + ell_width, ell_height, 90 * 64, 90 * 64); + XDrawArc(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + x1, dc->w.DCOrgY + y2, + ell_width, ell_height, 180 * 64, 90 * 64); + XDrawArc(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + x2, dc->w.DCOrgY + y2, + ell_width, ell_height, 270 * 64, 90 * 64); + XDrawArc(XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + x2, dc->w.DCOrgY + y1, + ell_width, ell_height, 0, 90 * 64); + } + ell_width /= 2; ell_height /= 2; + MoveTo(hDC, left, top + ell_height); + LineTo(hDC, left, bottom - ell_height); + MoveTo(hDC, left + ell_width, bottom); + LineTo(hDC, right - ell_width, bottom); + MoveTo(hDC, right, bottom - ell_height); + LineTo(hDC, right, top + ell_height); + MoveTo(hDC, right - ell_width, top); + LineTo(hDC, left + ell_width, top); + return TRUE; +} + + /*********************************************************************** * FillRect (USER.81) */ @@ -511,5 +581,95 @@ BOOL Polygon (HDC hdc, LPPOINT pt, int count) free ((void *) points); return (TRUE); } - + +/********************************************************************** + * FloodFill_rec -- FloodFill helper function + * + * Just does a recursive flood fill: + * this is /not/ efficent -- a better way would be to draw + * an entire line at a time, but this will do for now. + */ +static BOOL FloodFill_rec(XImage *image, int x, int y, + int orgx, int orgy, int endx, int endy, + Pixel borderp, Pixel fillp) +{ + Pixel testp; + + if (x > endx || x < orgx || y > endy || y < orgy) + return FALSE; + XPutPixel(image, x, y, fillp); + + testp = XGetPixel(image, x+1, y+1); + if (testp != borderp && testp != fillp) + FloodFill_rec(image, x+1, y+1, orgx, orgy, + endx, endy, borderp, fillp); + + testp = XGetPixel(image, x+1, y-1); + if (testp != borderp && testp != fillp) + FloodFill_rec(image, x+1, y-1, orgx, orgy, + endx, endy, borderp, fillp); + testp = XGetPixel(image, x-1, y+1); + if (testp != borderp && testp != fillp) + FloodFill_rec(image, x-1, y+1, orgx, orgy, + endx, endy, borderp, fillp); + testp = XGetPixel(image, x-1, y-1); + if (testp != borderp && testp != fillp) + FloodFill_rec(image, x-1, y-1, orgx, orgy, + endx, endy, borderp, fillp); + return TRUE; +} + + +/********************************************************************** + * FloodFill (GDI.25) + */ +BOOL FloodFill(HDC hdc, short x, short y, DWORD crColor) +{ + Pixel boundrypixel; + int imagex, imagey; + XImage *image; + DC *dc; + +#ifdef DEBUG_GRAPHICS + printf("FloodFill %x %d,%d %x\n", hdc, x, y, crColor); +#endif + dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC); + + if (!dc) return 0; + + x = dc->w.DCOrgX + XLPTODP(dc, x); + y = dc->w.DCOrgY + YLPTODP(dc, y); + + if (x < dc->w.DCOrgX || x > dc->w.DCOrgX + dc->w.DCSizeX || + y < dc->w.DCOrgY || y > dc->w.DCOrgY + dc->w.DCSizeY) + return 0; + + if (!DC_SetupGCForBrush(dc)) + return FALSE; + + boundrypixel = GetNearestPaletteIndex( dc->w.hPalette, crColor ); + + image = XGetImage(display, dc->u.x.drawable, + dc->w.DCOrgX, dc->w.DCOrgY, + dc->w.DCSizeX, dc->w.DCSizeY, AllPlanes, ZPixmap); + if (XGetPixel(image, x, y) == boundrypixel) + return FALSE; + if (!FloodFill_rec(image, x, y, + 0,0, + dc->w.DCOrgX + dc->w.DCSizeX, + dc->w.DCOrgY + dc->w.DCSizeY, + boundrypixel, dc->u.x.brush.pixel)) { + XDestroyImage(image); + return 0; + } + + XPutImage(display, dc->u.x.drawable, dc->u.x.gc, image, + 0, 0, + dc->w.DCOrgX, dc->w.DCOrgY, + dc->w.DCSizeX, dc->w.DCSizeY); + XDestroyImage(image); + + return TRUE; +} + diff --git a/windows/keyboard.c b/windows/keyboard.c index 888fd27900c..e3afb20a365 100644 --- a/windows/keyboard.c +++ b/windows/keyboard.c @@ -6,8 +6,6 @@ static char Copyright[] = "Copyright Bob Amstadt, 1993"; -#include -#include #include "win.h" /********************************************************************** diff --git a/windows/message.c b/windows/message.c index de06f2841ce..910f7a418c2 100644 --- a/windows/message.c +++ b/windows/message.c @@ -163,26 +163,18 @@ static int MSG_FindMsg(MESSAGEQUEUE * msgQueue, HWND hwnd, int first, int last) */ static void MSG_RemoveMsg( MESSAGEQUEUE * msgQueue, int pos ) { - QMSG * qmsg; - - if (!msgQueue) return; - qmsg = &msgQueue->messages[pos]; - if (pos >= msgQueue->nextMessage) { - int count = pos - msgQueue->nextMessage; - if (count) memmove( &msgQueue->messages[msgQueue->nextMessage+1], - &msgQueue->messages[msgQueue->nextMessage], - count * sizeof(QMSG) ); + for ( ; pos > msgQueue->nextMessage; pos--) + msgQueue->messages[pos] = msgQueue->messages[pos-1]; msgQueue->nextMessage++; if (msgQueue->nextMessage >= msgQueue->queueSize) msgQueue->nextMessage = 0; } else { - int count = msgQueue->nextFreeMessage - pos; - if (count) memmove( &msgQueue->messages[pos], - &msgQueue->messages[pos+1], count * sizeof(QMSG) ); + for ( ; pos < msgQueue->nextFreeMessage; pos++) + msgQueue->messages[pos] = msgQueue->messages[pos+1]; if (msgQueue->nextFreeMessage) msgQueue->nextFreeMessage--; else msgQueue->nextFreeMessage = msgQueue->queueSize-1; } diff --git a/windows/nonclient.c b/windows/nonclient.c index 8f848020c8b..5456b08ff36 100644 --- a/windows/nonclient.c +++ b/windows/nonclient.c @@ -7,11 +7,12 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1994"; #include "win.h" +#include "class.h" #include "message.h" #include "sysmetrics.h" #include "user.h" #include "scroll.h" - +#include "menu.h" static HBITMAP hbitmapClose = 0; static HBITMAP hbitmapMinimize = 0; @@ -21,11 +22,9 @@ static HBITMAP hbitmapMaximizeD = 0; static HBITMAP hbitmapRestore = 0; static HBITMAP hbitmapRestoreD = 0; -extern void NC_TrackSysMenu( HWND hwnd ); /* menu.c */ extern void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack ); /* winpos.c */ - -extern Display * display; +extern void CURSOR_SetWinCursor( HWND hwnd, HCURSOR hcursor ); /* cursor.c */ /* Some useful macros */ @@ -39,6 +38,15 @@ extern Display * display; #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0)) +#define ON_LEFT_BORDER(hit) \ + (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT)) +#define ON_RIGHT_BORDER(hit) \ + (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT)) +#define ON_TOP_BORDER(hit) \ + (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT)) +#define ON_BOTTOM_BORDER(hit) \ + (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT)) + /*********************************************************************** * NC_AdjustRect * @@ -512,6 +520,7 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, * NC_DoNCPaint * * Paint the non-client area. + * 'hrgn' is the update rgn to use (in client coords) or 1 if no update rgn. */ static void NC_DoNCPaint( HWND hwnd, HRGN hrgn, BOOL active ) { @@ -531,7 +540,15 @@ static void NC_DoNCPaint( HWND hwnd, HRGN hrgn, BOOL active ) return; /* Nothing to do! */ if (hrgn == 1) hdc = GetDCEx( hwnd, 0, DCX_CACHE | DCX_WINDOW ); - else hdc = GetDCEx( hwnd, hrgn, DCX_CACHE | DCX_WINDOW | DCX_INTERSECTRGN); + else + { + /* Make region relative to window area */ + int xoffset = wndPtr->rectWindow.left - wndPtr->rectClient.left; + int yoffset = wndPtr->rectWindow.top - wndPtr->rectClient.top; + OffsetRgn( hrgn, -xoffset, -yoffset ); + hdc = GetDCEx( hwnd, hrgn, DCX_CACHE | DCX_WINDOW | DCX_INTERSECTRGN); + OffsetRgn( hrgn, xoffset, yoffset ); /* Restore region */ + } if (!hdc) return; if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left, wndPtr->rectClient.top-wndPtr->rectWindow.top, @@ -577,15 +594,29 @@ static void NC_DoNCPaint( HWND hwnd, HRGN hrgn, BOOL active ) NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active ); } - if (wndPtr->dwStyle & (WS_VSCROLL | WS_HSCROLL)) - { - if (wndPtr->dwStyle & WS_VSCROLL) { - int bottom = rect.bottom; - if (wndPtr->dwStyle & WS_HSCROLL) bottom -= SYSMETRICS_CYHSCROLL; - SetRect(&rect2, rect.right - SYSMETRICS_CXVSCROLL, rect.top, - rect.right, bottom); - StdDrawScrollBar(hwnd, hdc, SB_VERT, &rect2, (LPHEADSCROLL)wndPtr->VScroll); - } + if (wndPtr->wIDmenu != 0 && + (wndPtr->dwStyle & WS_CHILD) != WS_CHILD) { + int oldbottom; + CopyRect(&rect2, &rect); + /* Default MenuBar height */ + oldbottom = rect2.bottom = rect2.top + SYSMETRICS_CYMENU; + StdDrawMenuBar(hdc, &rect2, (LPPOPUPMENU)GlobalLock(wndPtr->wIDmenu)); + GlobalUnlock(wndPtr->wIDmenu); + /* Reduce ClientRect according to MenuBar height */ + rect.top += rect2.bottom - oldbottom; + } + + if (wndPtr->dwStyle & (WS_VSCROLL | WS_HSCROLL)) { + if (wndPtr->dwStyle & WS_VSCROLL) { + int bottom = rect.bottom; + if (wndPtr->dwStyle & WS_HSCROLL) bottom -= SYSMETRICS_CYHSCROLL; + SetRect(&rect2, rect.right - SYSMETRICS_CXVSCROLL, + rect.top, rect.right, bottom); + if (wndPtr->dwStyle & WS_CAPTION) rect.top += SYSMETRICS_CYSIZE; + if (wndPtr->wIDmenu != 0 && (wndPtr->dwStyle & WS_CHILD) != WS_CHILD) + rect2.top += SYSMETRICS_CYMENU; + StdDrawScrollBar(hwnd, hdc, SB_VERT, &rect2, (LPHEADSCROLL)wndPtr->VScroll); + } if (wndPtr->dwStyle & WS_HSCROLL) { int right = rect.right; if (wndPtr->dwStyle & WS_VSCROLL) right -= SYSMETRICS_CYVSCROLL; @@ -593,18 +624,15 @@ static void NC_DoNCPaint( HWND hwnd, HRGN hrgn, BOOL active ) right, rect.bottom); StdDrawScrollBar(hwnd, hdc, SB_HORZ, &rect2, (LPHEADSCROLL)wndPtr->HScroll); } -/* - HBRUSH hbrushScroll = CreateSolidBrush( GetSysColor(COLOR_SCROLLBAR) ); - HBRUSH hbrushOld = SelectObject( hdc, hbrushScroll ); - if (wndPtr->dwStyle & WS_VSCROLL) - PatBlt( hdc, rect.right - SYSMETRICS_CXVSCROLL, rect.top, - SYSMETRICS_CXVSCROLL, rect.bottom-rect.top, PATCOPY ); - if (wndPtr->dwStyle & WS_HSCROLL) - PatBlt( hdc, rect.left, rect.bottom - SYSMETRICS_CYHSCROLL, - rect.right-rect.left, SYSMETRICS_CYHSCROLL, PATCOPY ); - SelectObject( hdc, hbrushOld ); - DeleteObject( hbrushScroll ); -*/ + + if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL)) + { + HBRUSH hbrushScroll = CreateSolidBrush( GetSysColor(COLOR_SCROLLBAR) ); + RECT r = rect; + r.left = r.right - SYSMETRICS_CXVSCROLL; + r.top = r.bottom - SYSMETRICS_CYHSCROLL; + FillRect( hdc, &r, hbrushScroll ); + } } ReleaseDC( hwnd, hdc ); @@ -637,6 +665,151 @@ LONG NC_HandleNCActivate( HWND hwnd, WORD wParam ) } +/*********************************************************************** + * NC_HandleSetCursor + * + * Handle a WM_SETCURSOR message. Called from DefWindowProc(). + */ +LONG NC_HandleSetCursor( HWND hwnd, WORD wParam, LONG lParam ) +{ + if (hwnd != wParam) return 0; /* Don't set the cursor for child windows */ + + switch(LOWORD(lParam)) + { + case HTERROR: + { + WORD msg = HIWORD( lParam ); + if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) || + (msg == WM_RBUTTONDOWN)) + MessageBeep(0); + } + break; + + case HTCLIENT: + { + WND *wndPtr; + CLASS *classPtr; + if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break; + if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) break; + if (classPtr->wc.hCursor) + { + CURSOR_SetWinCursor( hwnd, classPtr->wc.hCursor ); + return TRUE; + } + } + break; + + case HTLEFT: + case HTRIGHT: + CURSOR_SetWinCursor( hwnd, LoadCursor( 0, IDC_SIZEWE ) ); + return TRUE; + + case HTTOP: + case HTBOTTOM: + CURSOR_SetWinCursor( hwnd, LoadCursor( 0, IDC_SIZENS ) ); + return TRUE; + + case HTTOPLEFT: + case HTBOTTOMRIGHT: + CURSOR_SetWinCursor( hwnd, LoadCursor( 0, IDC_SIZENWSE ) ); + return TRUE; + + case HTTOPRIGHT: + case HTBOTTOMLEFT: + CURSOR_SetWinCursor( hwnd, LoadCursor( 0, IDC_SIZENESW ) ); + return TRUE; + } + + /* Default cursor: arrow */ + CURSOR_SetWinCursor( hwnd, LoadCursor( 0, IDC_ARROW ) ); + return TRUE; +} + + +/*********************************************************************** + * NC_StartSizeMove + * + * Initialisation of a move or resize, when initiatied from a menu choice. + * Return hit test code for caption or sizing border. + */ +static LONG NC_StartSizeMove( HWND hwnd, WORD wParam, POINT *capturePoint ) +{ + LONG hittest = 0; + POINT pt; + MSG msg; + WND * wndPtr = WIN_FindWndPtr( hwnd ); + + if ((wParam & 0xfff0) == SC_MOVE) + { + /* Move pointer at the center of the caption */ + RECT rect; + NC_GetInsideRect( hwnd, &rect ); + if (wndPtr->dwStyle & WS_SYSMENU) + rect.left += SYSMETRICS_CXSIZE + 1; + if (wndPtr->dwStyle & WS_MINIMIZEBOX) + rect.right -= SYSMETRICS_CXSIZE + 1; + if (wndPtr->dwStyle & WS_MAXIMIZEBOX) + rect.right -= SYSMETRICS_CXSIZE + 1; + pt.x = wndPtr->rectWindow.left + (rect.right - rect.left) / 2; + pt.y = wndPtr->rectWindow.top + rect.top + SYSMETRICS_CYSIZE/2; + if (wndPtr->dwStyle & WS_CHILD) + ClientToScreen( wndPtr->hwndParent, &pt ); + hittest = HTCAPTION; + } + else /* SC_SIZE */ + { + SetCapture(hwnd); + while(!hittest) + { + MSG_GetHardwareMessage( &msg ); + switch(msg.message) + { + case WM_MOUSEMOVE: + hittest = NC_InternalNCHitTest( hwnd, msg.pt ); + pt = msg.pt; + if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) + hittest = 0; + break; + + case WM_LBUTTONUP: + return 0; + + case WM_KEYDOWN: + switch(msg.wParam) + { + case VK_UP: + hittest = HTTOP; + pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2; + pt.y = wndPtr->rectWindow.top + SYSMETRICS_CYFRAME / 2; + break; + case VK_DOWN: + hittest = HTBOTTOM; + pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2; + pt.y = wndPtr->rectWindow.bottom - SYSMETRICS_CYFRAME / 2; + break; + case VK_LEFT: + hittest = HTLEFT; + pt.x = wndPtr->rectWindow.left + SYSMETRICS_CXFRAME / 2; + pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2; + break; + case VK_RIGHT: + hittest = HTRIGHT; + pt.x = wndPtr->rectWindow.right - SYSMETRICS_CXFRAME / 2; + pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2; + break; + case VK_RETURN: + case VK_ESCAPE: return 0; + } + } + } + } + *capturePoint = pt; + SetCursorPos( capturePoint->x, capturePoint->y ); + NC_HandleSetCursor( hwnd, hwnd, MAKELONG( hittest, WM_MOUSEMOVE )); + return hittest; +} + + /*********************************************************************** * NC_DoSizeMove * @@ -645,8 +818,8 @@ LONG NC_HandleNCActivate( HWND hwnd, WORD wParam ) static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt ) { MSG msg; - WORD hittest; - RECT sizingRect; + LONG hittest; + RECT sizingRect, mouseRect; HDC hdc; BOOL thickframe; POINT minTrack, maxTrack, capturePoint = pt; @@ -659,44 +832,62 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt ) if ((wParam & 0xfff0) == SC_MOVE) { if (!(wndPtr->dwStyle & WS_CAPTION)) return; - if (!hittest) - { - /* Move pointer at the center of the caption */ - RECT rect; - POINT point; - NC_GetInsideRect( hwnd, &rect ); - if (wndPtr->dwStyle & WS_SYSMENU) - rect.left += SYSMETRICS_CXSIZE + 1; - if (wndPtr->dwStyle & WS_MINIMIZEBOX) - rect.right -= SYSMETRICS_CXSIZE + 1; - if (wndPtr->dwStyle & WS_MAXIMIZEBOX) - rect.right -= SYSMETRICS_CXSIZE + 1; - point.x = wndPtr->rectWindow.left + (rect.right - rect.left) / 2; - point.y = wndPtr->rectWindow.top + rect.top + SYSMETRICS_CYSIZE/2; - if (wndPtr->dwStyle & WS_CHILD) - ClientToScreen( wndPtr->hwndParent, &point ); - SetCursorPos( point.x, point.y ); - hittest = HTCAPTION; - capturePoint = point; - } + if (!hittest) hittest = NC_StartSizeMove( hwnd, wParam, &capturePoint ); + if (!hittest) return; } else /* SC_SIZE */ { if (!thickframe) return; if (hittest) hittest += HTLEFT-1; + else + { + SetCapture(hwnd); + hittest = NC_StartSizeMove( hwnd, wParam, &capturePoint ); + if (!hittest) + { + ReleaseCapture(); + return; + } + } } + /* Get min/max info */ + WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack ); + sizingRect = wndPtr->rectWindow; + if (wndPtr->dwStyle & WS_CHILD) + GetClientRect( wndPtr->hwndParent, &mouseRect ); + else SetRect( &mouseRect, 0, 0, SYSMETRICS_CXSCREEN, SYSMETRICS_CYSCREEN ); + if (ON_LEFT_BORDER(hittest)) + { + mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x ); + mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x ); + } + else if (ON_RIGHT_BORDER(hittest)) + { + mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x ); + mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x ); + } + if (ON_TOP_BORDER(hittest)) + { + mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y ); + mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y); + } + else if (ON_BOTTOM_BORDER(hittest)) + { + mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y ); + mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y ); + } SendMessage( hwnd, WM_ENTERSIZEMOVE, 0, 0 ); + if (GetCapture() != hwnd) SetCapture( hwnd ); + if (wndPtr->dwStyle & WS_CHILD) hdc = GetDC( wndPtr->hwndParent ); else { /* Grab the server only when moving top-level windows */ hdc = GetDC( 0 ); XGrabServer( display ); } - SetCapture( hwnd ); - sizingRect = wndPtr->rectWindow; NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); while(1) @@ -710,69 +901,47 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt ) ((msg.message == WM_KEYDOWN) && ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break; + if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE)) + continue; /* We are not interested in other messages */ + + pt = msg.pt; if (wndPtr->dwStyle & WS_CHILD) - ScreenToClient( wndPtr->hwndParent, &msg.pt ); + ScreenToClient( wndPtr->hwndParent, &pt ); - switch(msg.message) + + if (msg.message == WM_KEYDOWN) switch(msg.wParam) { - case WM_MOUSEMOVE: - dx = msg.pt.x - capturePoint.x; - dy = msg.pt.y - capturePoint.y; - break; + case VK_UP: pt.y -= 8; break; + case VK_DOWN: pt.y += 8; break; + case VK_LEFT: pt.x -= 8; break; + case VK_RIGHT: pt.x += 8; break; + } - case WM_KEYDOWN: - switch(msg.wParam) - { - case VK_UP: msg.pt.y -= 8; break; - case VK_DOWN: msg.pt.y += 8; break; - case VK_LEFT: msg.pt.x -= 8; break; - case VK_RIGHT: msg.pt.x += 8; break; - } - SetCursorPos( msg.pt.x, msg.pt.y ); - break; - } + pt.x = max( pt.x, mouseRect.left ); + pt.x = min( pt.x, mouseRect.right ); + pt.y = max( pt.y, mouseRect.top ); + pt.y = min( pt.y, mouseRect.bottom ); + + dx = pt.x - capturePoint.x; + dy = pt.y - capturePoint.y; if (dx || dy) { - RECT newRect = sizingRect; - switch(hittest) + if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y ); + else { - case HTCAPTION: - OffsetRect( &newRect, dx, dy ); - break; - case HTLEFT: - newRect.left += dx; - break; - case HTRIGHT: - newRect.right += dx; - break; - case HTTOP: - newRect.top += dy; - break; - case HTTOPLEFT: - newRect.left += dx; - newRect.top += dy; - break; - case HTTOPRIGHT: - newRect.right += dx; - newRect.top += dy; - break; - case HTBOTTOM: - newRect.bottom += dy; - break; - case HTBOTTOMLEFT: - newRect.left += dx; - newRect.bottom += dy; - break; - case HTBOTTOMRIGHT: - newRect.right += dx; - newRect.bottom += dy; - break; - } - NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); - NC_DrawMovingFrame( hdc, &newRect, thickframe ); - capturePoint = msg.pt; - sizingRect = newRect; + RECT newRect = sizingRect; + + if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy ); + if (ON_LEFT_BORDER(hittest)) newRect.left += dx; + else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx; + if (ON_TOP_BORDER(hittest)) newRect.top += dy; + else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy; + NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); + NC_DrawMovingFrame( hdc, &newRect, thickframe ); + capturePoint = pt; + sizingRect = newRect; + } } } @@ -842,6 +1011,90 @@ static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam ) } +/*********************************************************************** + * NC_TrackScrollBar + * + * Track a mouse button press on the horizontal or vertical scroll-bar. + */ +static void NC_TrackScrollBar( HWND hwnd, WORD wParam, POINT pt ) +{ + MSG msg; + WORD scrollbar; + + if ((wParam & 0xfff0) == SC_HSCROLL) + { + if ((wParam & 0x0f) != HTHSCROLL) return; + scrollbar = SB_HORZ; + } + else /* SC_VSCROLL */ + { + if ((wParam & 0x0f) != HTVSCROLL) return; + scrollbar = SB_VERT; + } + + ScreenToClient( hwnd, &pt ); + ScrollBarButtonDown( hwnd, scrollbar, pt.x, pt.y ); + SetCapture( hwnd ); + + do + { + MSG_GetHardwareMessage( &msg ); + ScreenToClient( msg.hwnd, &msg.pt ); + switch(msg.message) + { + case WM_LBUTTONUP: + ScrollBarButtonUp( hwnd, scrollbar, msg.pt.x, msg.pt.y ); + break; + case WM_MOUSEMOVE: + ScrollBarMouseMove(hwnd, scrollbar, msg.wParam, msg.pt.x,msg.pt.y); + break; + } + } while (msg.message != WM_LBUTTONUP); + ReleaseCapture(); +} + + +/*********************************************************************** + * NC_TrackMouseMenuBar + * + * Track a mouse events for the MenuBar. + */ +static void NC_TrackMouseMenuBar( HWND hwnd, WORD wParam, POINT pt ) +{ + WND *wndPtr; + LPPOPUPMENU lppop; + MSG msg; + wndPtr = WIN_FindWndPtr(hwnd); + lppop = (LPPOPUPMENU)GlobalLock(wndPtr->wIDmenu); +#ifdef DEBUG_MENU + printf("NC_TrackMouseMenuBar // wndPtr=%08X lppop=%08X !\n", wndPtr, lppop); +#endif + ScreenToClient(hwnd, &pt); + pt.y += lppop->rect.bottom; + MenuButtonDown(hwnd, lppop, pt.x, pt.y); + SetCapture(hwnd); + do { + if (!GetMessage(&msg, (HWND)NULL, 0, 0)) break; + ScreenToClient(hwnd, &msg.pt); + msg.pt.y += lppop->rect.bottom; + switch(msg.message) { + case WM_LBUTTONUP: + MenuButtonUp(hwnd, lppop, msg.pt.x, msg.pt.y); + break; + case WM_MOUSEMOVE: + MenuMouseMove(hwnd, lppop, msg.wParam, msg.pt.x, msg.pt.y); + break; + default: + TranslateMessage(&msg); + DispatchMessage(&msg); + break; + } + } while (msg.message != WM_LBUTTONUP); + ReleaseCapture(); + GlobalUnlock(wndPtr->wIDmenu); +} + + /*********************************************************************** * NC_HandleNCLButtonDown * @@ -863,14 +1116,15 @@ LONG NC_HandleNCLButtonDown( HWND hwnd, WORD wParam, LONG lParam ) break; case HTMENU: + SendMessage( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam ); break; case HTHSCROLL: - SendMessage( hwnd, WM_SYSCOMMAND, SC_HSCROLL, lParam ); + SendMessage( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam ); break; case HTVSCROLL: - SendMessage( hwnd, WM_SYSCOMMAND, SC_VSCROLL, lParam ); + SendMessage( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam ); break; case HTMINBUTTON: @@ -962,9 +1216,17 @@ LONG NC_HandleSysCommand( HWND hwnd, WORD wParam, POINT pt ) case SC_VSCROLL: case SC_HSCROLL: + NC_TrackScrollBar( hwnd, wParam, pt ); break; + case SC_MOUSEMENU: + NC_TrackMouseMenuBar( hwnd, wParam, pt ); + break; + case SC_KEYMENU: +/* NC_KeyMenuBar( hwnd, wParam, pt ); */ + break; + case SC_ARRANGE: break; @@ -977,61 +1239,3 @@ LONG NC_HandleSysCommand( HWND hwnd, WORD wParam, POINT pt ) } -/*********************************************************************** - * NC_HandleSetCursor - * - * Handle a WM_SETCURSOR message. Called from DefWindowProc(). - */ -LONG NC_HandleSetCursor( HWND hwnd, WORD wParam, LONG lParam ) -{ - if (hwnd != wParam) return 0; /* Don't set the cursor for child windows */ - - switch(LOWORD(lParam)) - { - case HTERROR: - { - WORD msg = HIWORD( lParam ); - if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) || - (msg == WM_RBUTTONDOWN)) - MessageBeep(0); - } - break; - - case HTCLIENT: - { - WND *wndPtr = WIN_FindWndPtr( hwnd ); - if (wndPtr && wndPtr->hCursor) - { - SetCursor( wndPtr->hCursor ); - return TRUE; - } - } - break; - - case HTLEFT: - case HTRIGHT: - SetCursor( LoadCursor( 0, IDC_SIZEWE ) ); - return TRUE; - - case HTTOP: - case HTBOTTOM: - SetCursor( LoadCursor( 0, IDC_SIZENS ) ); - return TRUE; - - case HTTOPLEFT: - case HTBOTTOMRIGHT: - SetCursor( LoadCursor( 0, IDC_SIZENWSE ) ); - return TRUE; - - case HTTOPRIGHT: - case HTBOTTOMLEFT: - SetCursor( LoadCursor( 0, IDC_SIZENESW ) ); - return TRUE; - } - - /* Default cursor: arrow */ - SetCursor( LoadCursor( 0, IDC_ARROW ) ); - return TRUE; -} - - diff --git a/windows/painting.c b/windows/painting.c index c218e237546..0090d916cb8 100644 --- a/windows/painting.c +++ b/windows/painting.c @@ -6,7 +6,6 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; -#include #include #include "win.h" @@ -31,12 +30,11 @@ HDC BeginPaint( HWND hwnd, LPPAINTSTRUCT lps ) DCX_INTERSECTRGN | DCX_USESTYLE ))) return 0; GetRgnBox( InquireVisRgn(lps->hdc), &lps->rcPaint ); - if (wndPtr->hrgnUpdate) - { - wndPtr->hrgnUpdate = 0; + if (wndPtr->hrgnUpdate || (wndPtr->flags & WIN_INTERNAL_PAINT)) MSG_DecPaintCount( wndPtr->hmemTaskQ ); - } - wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT; + + wndPtr->hrgnUpdate = 0; + wndPtr->flags &= ~(WIN_NEEDS_BEGINPAINT | WIN_INTERNAL_PAINT); SendMessage( hwnd, WM_NCPAINT, hrgnUpdate, 0 ); if (hrgnUpdate) DeleteObject( hrgnUpdate ); @@ -83,3 +81,323 @@ void PaintRect(HWND hwndParent, HWND hwnd, HDC hdc, HBRUSH hbrush, LPRECT rect) } if (hbrush) FillRect( hdc, rect, hbrush ); } + + +/*********************************************************************** + * RedrawWindow (USER.290) + */ +BOOL RedrawWindow( HWND hwnd, LPRECT rectUpdate, HRGN hrgnUpdate, UINT flags ) +{ + HRGN tmpRgn, hrgn = 0; + RECT rectClient, rectWindow; + WND * wndPtr; + + if (!hwnd) hwnd = GetDesktopWindow(); + if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; + + GetClientRect( hwnd, &rectClient ); + rectWindow = wndPtr->rectWindow; + OffsetRect(&rectWindow, -wndPtr->rectClient.left, -wndPtr->rectClient.top); + + if (flags & RDW_INVALIDATE) /* Invalidate */ + { + if (flags & RDW_ERASE) wndPtr->flags |= WIN_ERASE_UPDATERGN; + + if (hrgnUpdate) /* Invalidate a region */ + { + if (flags & RDW_FRAME) tmpRgn = CreateRectRgnIndirect(&rectWindow); + else tmpRgn = CreateRectRgnIndirect( &rectClient ); + if (!tmpRgn) return FALSE; + hrgn = CreateRectRgn( 0, 0, 0, 0 ); + if (CombineRgn( hrgn, hrgnUpdate, tmpRgn, RGN_AND ) == NULLREGION) + { + DeleteObject( hrgn ); + hrgn = 0; + } + DeleteObject( tmpRgn ); + } + else /* Invalidate a rectangle */ + { + RECT rect; + if (flags & RDW_FRAME) + { + if (rectUpdate) IntersectRect( &rect, rectUpdate, &rectWindow); + else rect = rectWindow; + } + else + { + if (rectUpdate) IntersectRect( &rect, rectUpdate, &rectClient); + else rect = rectClient; + } + if (!IsRectEmpty(&rect)) hrgn = CreateRectRgnIndirect( &rect ); + } + + /* Set update region */ + + if (hrgn) + { + if (!wndPtr->hrgnUpdate) + { + wndPtr->hrgnUpdate = hrgn; + if (!(wndPtr->flags & WIN_INTERNAL_PAINT)) + MSG_IncPaintCount( wndPtr->hmemTaskQ ); + } + else + { + tmpRgn = CreateRectRgn( 0, 0, 0, 0 ); + CombineRgn( tmpRgn, wndPtr->hrgnUpdate, hrgn, RGN_OR ); + DeleteObject( wndPtr->hrgnUpdate ); + DeleteObject( hrgn ); + wndPtr->hrgnUpdate = tmpRgn; + } + } + flags |= RDW_FRAME; /* Force invalidating the frame of children */ + } + else if (flags & RDW_VALIDATE) /* Validate */ + { + if (flags & RDW_NOERASE) wndPtr->flags &= ~WIN_ERASE_UPDATERGN; + if (!(hrgn = CreateRectRgn( 0, 0, 0, 0 ))) return FALSE; + + /* Remove frame from update region */ + + if (wndPtr->hrgnUpdate && (flags & RDW_NOFRAME)) + { + if (!(tmpRgn = CreateRectRgnIndirect( &rectClient ))) + return FALSE; + if (CombineRgn(hrgn,tmpRgn,wndPtr->hrgnUpdate,RGN_AND) == NULLREGION) + { + DeleteObject( hrgn ); + hrgn = 0; + } + DeleteObject( tmpRgn ); + DeleteObject( wndPtr->hrgnUpdate ); + wndPtr->hrgnUpdate = hrgn; + hrgn = CreateRectRgn( 0, 0, 0, 0 ); + } + + /* Set update region */ + + if (wndPtr->hrgnUpdate) + { + int res; + if (hrgnUpdate) /* Validate a region */ + { + res = CombineRgn(hrgn,wndPtr->hrgnUpdate,hrgnUpdate,RGN_DIFF); + } + else /* Validate a rectangle */ + { + if (rectUpdate) tmpRgn = CreateRectRgnIndirect( rectUpdate ); + else tmpRgn = CreateRectRgnIndirect( &rectWindow ); + res = CombineRgn( hrgn, wndPtr->hrgnUpdate, tmpRgn, RGN_DIFF ); + DeleteObject( tmpRgn ); + } + DeleteObject( wndPtr->hrgnUpdate ); + if (res == NULLREGION) + { + DeleteObject( hrgn ); + wndPtr->hrgnUpdate = 0; + if (!(wndPtr->flags & WIN_INTERNAL_PAINT)) + MSG_DecPaintCount( wndPtr->hmemTaskQ ); + } + else wndPtr->hrgnUpdate = hrgn; + } + } + + /* Set/clear internal paint flag */ + + if (flags & RDW_INTERNALPAINT) + { + if (!wndPtr->hrgnUpdate && !(wndPtr->flags & WIN_INTERNAL_PAINT)) + MSG_IncPaintCount( wndPtr->hmemTaskQ ); + wndPtr->flags |= WIN_INTERNAL_PAINT; + } + else if (flags & RDW_NOINTERNALPAINT) + { + if (!wndPtr->hrgnUpdate && (wndPtr->flags & WIN_INTERNAL_PAINT)) + MSG_DecPaintCount( wndPtr->hmemTaskQ ); + wndPtr->flags &= ~WIN_INTERNAL_PAINT; + } + + /* Erase/update window */ + + if (flags & RDW_UPDATENOW) UpdateWindow( hwnd ); + else if (flags & RDW_ERASENOW) + { + HDC hdc = GetDCEx( hwnd, wndPtr->hrgnUpdate, + DCX_INTERSECTRGN | DCX_USESTYLE ); + if (hdc) + { + SendMessage( hwnd, WM_NCPAINT, wndPtr->hrgnUpdate, 0 ); + SendMessage( hwnd, WM_ERASEBKGND, hdc, 0 ); + ReleaseDC( hwnd, hdc ); + } + } + + /* Recursively process children */ + + if (!(flags & RDW_NOCHILDREN) && + ((flags && RDW_ALLCHILDREN) || (wndPtr->dwStyle & WS_CLIPCHILDREN))) + { + if (hrgnUpdate) + { + HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); + if (!hrgn) return TRUE; + for (hwnd = wndPtr->hwndChild; (hwnd); hwnd = wndPtr->hwndNext) + { + if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break; + CombineRgn( hrgn, hrgnUpdate, 0, RGN_COPY ); + OffsetRgn( hrgn, -wndPtr->rectClient.left, + -wndPtr->rectClient.top ); + RedrawWindow( hwnd, NULL, hrgn, flags ); + } + DeleteObject( hrgn ); + } + else + { + RECT rect; + for (hwnd = wndPtr->hwndChild; (hwnd); hwnd = wndPtr->hwndNext) + { + if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break; + if (rectUpdate) + { + rect = *rectUpdate; + OffsetRect( &rect, -wndPtr->rectClient.left, + -wndPtr->rectClient.top ); + RedrawWindow( hwnd, &rect, 0, flags ); + } + else RedrawWindow( hwnd, NULL, 0, flags ); + } + } + } + return TRUE; +} + + +/*********************************************************************** + * UpdateWindow (USER.124) + */ +void UpdateWindow( HWND hwnd ) +{ + if (GetUpdateRect( hwnd, NULL, FALSE )) + { + if (IsWindowVisible( hwnd )) SendMessage( hwnd, WM_PAINT, 0, 0 ); + } +} + + +/*********************************************************************** + * InvalidateRgn (USER.126) + */ +void InvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase ) +{ + RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) ); +} + + +/*********************************************************************** + * InvalidateRect (USER.125) + */ +void InvalidateRect( HWND hwnd, LPRECT rect, BOOL erase ) +{ + RedrawWindow( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) ); +} + + +/*********************************************************************** + * ValidateRgn (USER.128) + */ +void ValidateRgn( HWND hwnd, HRGN hrgn ) +{ + RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN ); +} + + +/*********************************************************************** + * ValidateRect (USER.127) + */ +void ValidateRect( HWND hwnd, LPRECT rect ) +{ + RedrawWindow( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN ); +} + + +/*********************************************************************** + * GetUpdateRect (USER.190) + */ +BOOL GetUpdateRect( HWND hwnd, LPRECT rect, BOOL erase ) +{ + WND * wndPtr = WIN_FindWndPtr( hwnd ); + if (!wndPtr) return FALSE; + + if (rect) + { + if (wndPtr->hrgnUpdate) + { + HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); + if (GetUpdateRgn( hwnd, hrgn, erase ) == ERROR) return FALSE; + GetRgnBox( hrgn, rect ); + DeleteObject( hrgn ); + } + else SetRectEmpty( rect ); + } + return (wndPtr->hrgnUpdate != 0); +} + + +/*********************************************************************** + * GetUpdateRgn (USER.237) + */ +int GetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase ) +{ + HRGN hrgnClip; + int retval; + WND * wndPtr = WIN_FindWndPtr( hwnd ); + if (!wndPtr) return ERROR; + + if (!wndPtr->hrgnUpdate) + { + if (!(hrgnClip = CreateRectRgn( 0, 0, 0, 0 ))) return ERROR; + retval = CombineRgn( hrgn, hrgnClip, 0, RGN_COPY ); + } + else + { + hrgnClip = CreateRectRgn( 0, 0, + wndPtr->rectClient.right-wndPtr->rectClient.left, + wndPtr->rectClient.bottom-wndPtr->rectClient.top ); + if (!hrgnClip) return ERROR; + retval = CombineRgn( hrgn, wndPtr->hrgnUpdate, hrgnClip, RGN_AND ); + if (erase) + { + HDC hdc = GetDCEx( hwnd, wndPtr->hrgnUpdate, + DCX_INTERSECTRGN | DCX_USESTYLE ); + if (hdc) + { + SendMessage( hwnd, WM_ERASEBKGND, hdc, 0 ); + ReleaseDC( hwnd, hdc ); + } + } + } + DeleteObject( hrgnClip ); + return retval; +} + + +/*********************************************************************** + * ExcludeUpdateRgn (USER.238) + */ +int ExcludeUpdateRgn( HDC hdc, HWND hwnd ) +{ + int retval; + HRGN hrgn; + WND * wndPtr; + + if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return ERROR; + if ((hrgn = CreateRectRgn( 0, 0, 0, 0 )) != 0) + { + retval = CombineRgn( hrgn, InquireVisRgn(hdc), + wndPtr->hrgnUpdate, RGN_DIFF ); + if (retval) SelectVisRgn( hdc, hrgn ); + DeleteObject( hrgn ); + } + return retval; +} diff --git a/windows/scroll.c b/windows/scroll.c index 34d43fd2c6c..29dbe7ca5ff 100644 --- a/windows/scroll.c +++ b/windows/scroll.c @@ -160,10 +160,8 @@ int ScrollWindowEx(HWND hwnd, short dx, short dy, LPRECT rect, LPRECT clipRect, if (flags | SW_INVALIDATE) { - InvalidateRgn(hwnd, hrgnUpdate, FALSE); - - if (flags | SW_ERASE) - SendMessage(hwnd, WM_ERASEBKGND, (WORD)hdc, (LONG)NULL); + RedrawWindow(hwnd, NULL, hrgnUpdate, + RDW_INVALIDATE | ((flags & SW_ERASE) ? RDW_ERASENOW : 0)); } ReleaseDC(hwnd, hdc); diff --git a/windows/utility.c b/windows/utility.c index ab189a097a6..00e16836d76 100644 --- a/windows/utility.c +++ b/windows/utility.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "windows.h" static char Copyright[] = "Copyright Andrew C. Bulhak, 1993"; @@ -45,6 +46,16 @@ void UTILITY_strip015(char *dest) { *dest = '\0'; /* Add null terminator */ }; +/********************************************************************** + * DebugPrintString + */ +int +DebugPrintString(char *str) +{ + printf("%s", str); + return 0; +} + /* * OutputDebugString strips CRs from its (string) parameter and * calls DebugPrintString(), which was written by someone else. diff --git a/windows/win.c b/windows/win.c index 5cef378027c..45157f9eac3 100644 --- a/windows/win.c +++ b/windows/win.c @@ -6,10 +6,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; -#include -#include -#include -#include +#include #include "class.h" #include "win.h" @@ -18,13 +15,13 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "sysmetrics.h" #include "scroll.h" -extern Display * display; extern Colormap COLOR_WinColormap; extern void EVENT_RegisterWindow( Window w, HWND hwnd ); /* event.c */ +extern void CURSOR_SetWinCursor( HWND hwnd, HCURSOR hcursor ); /* cursor.c */ extern HMENU CopySysMenu(); /* menu.c */ -HWND firstWindow = 0; +static HWND hwndDesktop = 0; /*********************************************************************** * WIN_FindWndPtr @@ -50,15 +47,12 @@ WND * WIN_FindWndPtr( HWND hwnd ) BOOL WIN_UnlinkWindow( HWND hwnd ) { HWND * curWndPtr; - WND * wndPtr = WIN_FindWndPtr( hwnd ); + WND *parentPtr, *wndPtr; - if (!wndPtr) return FALSE; - if (wndPtr->hwndParent) - { - WND * parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ); - curWndPtr = &parentPtr->hwndChild; - } - else curWndPtr = &firstWindow; + if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; + if (!(parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ))) return FALSE; + + curWndPtr = &parentPtr->hwndChild; while (*curWndPtr != hwnd) { @@ -80,19 +74,14 @@ BOOL WIN_UnlinkWindow( HWND hwnd ) BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter ) { HWND * hwndPtr = NULL; /* pointer to hwnd to change */ + WND *wndPtr, *parentPtr; + + if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; + if (!(parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ))) return FALSE; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return FALSE; - if ((hwndInsertAfter == HWND_TOP) || (hwndInsertAfter == HWND_BOTTOM)) { - /* Make hwndPtr point to the first sibling hwnd */ - if (wndPtr->hwndParent) - { - WND * parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ); - if (parentPtr) hwndPtr = &parentPtr->hwndChild; - } - else hwndPtr = &firstWindow; + hwndPtr = &parentPtr->hwndChild; /* Point to first sibling hwnd */ if (hwndInsertAfter == HWND_BOTTOM) /* Find last sibling hwnd */ while (*hwndPtr) { @@ -121,11 +110,12 @@ HWND WIN_FindWinToRepaint( HWND hwnd ) { WND * wndPtr; - if (!hwnd) hwnd = firstWindow; + if (!hwnd) hwnd = GetTopWindow( hwndDesktop ); for ( ; hwnd != 0; hwnd = wndPtr->hwndNext ) { if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0; - if (wndPtr->hrgnUpdate) return hwnd; + if (wndPtr->hrgnUpdate || (wndPtr->flags & WIN_INTERNAL_PAINT)) + return hwnd; if (wndPtr->hwndChild) { HWND child; @@ -145,7 +135,7 @@ HWND WIN_FindWinToRepaint( HWND hwnd ) */ static void WIN_SendParentNotify( HWND hwnd, WND * wndPtr, WORD event ) { - HWND current = wndPtr->hwndParent; + HWND current = GetParent( hwnd ); if (wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) return; while (current) @@ -157,6 +147,61 @@ static void WIN_SendParentNotify( HWND hwnd, WND * wndPtr, WORD event ) } +/*********************************************************************** + * WIN_CreateDesktopWindow + * + * Create the desktop window. + */ +static HWND WIN_CreateDesktopWindow() +{ + HWND hwnd; + WND *wndPtr; + HCLASS hclass; + CLASS *classPtr; + + if (!(hclass = CLASS_FindClassByName( DESKTOP_CLASS_NAME, &classPtr ))) + return 0; + + hwnd = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(WND)+classPtr->wc.cbWndExtra); + if (!hwnd) return 0; + wndPtr = (WND *) USER_HEAP_ADDR( hwnd ); + + wndPtr->hwndNext = 0; + wndPtr->hwndChild = 0; + wndPtr->dwMagic = WND_MAGIC; + wndPtr->hwndParent = 0; + wndPtr->hwndOwner = 0; + wndPtr->hClass = hclass; + wndPtr->hInstance = 0; + wndPtr->rectWindow.left = 0; + wndPtr->rectWindow.top = 0; + wndPtr->rectWindow.right = SYSMETRICS_CXSCREEN; + wndPtr->rectWindow.bottom = SYSMETRICS_CYSCREEN; + wndPtr->rectClient = wndPtr->rectWindow; + wndPtr->rectNormal = wndPtr->rectWindow; + wndPtr->ptIconPos.x = -1; + wndPtr->ptIconPos.y = -1; + wndPtr->ptMaxPos.x = -1; + wndPtr->ptMaxPos.y = -1; + wndPtr->hmemTaskQ = 0; /* Desktop does not belong to a task */ + wndPtr->hrgnUpdate = 0; + wndPtr->hwndLastActive = 0; + wndPtr->lpfnWndProc = classPtr->wc.lpfnWndProc; + wndPtr->dwStyle = WS_VISIBLE | WS_CLIPCHILDREN; + wndPtr->dwExStyle = 0; + wndPtr->hdce = 0; + wndPtr->hmenuSystem = 0; + wndPtr->VScroll = NULL; + wndPtr->HScroll = NULL; + wndPtr->wIDmenu = 0; + wndPtr->hText = 0; + wndPtr->flags = 0; + wndPtr->window = DefaultRootWindow( display ); + wndPtr->hSysMenu = 0; + return hwnd; +} + + /*********************************************************************** * CreateWindow (USER.41) */ @@ -185,13 +230,16 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName, XSetWindowAttributes win_attr; Window parentWindow; int x_rel, y_rel; - LPPOPUPMENU lpbar; #ifdef DEBUG_WIN printf( "CreateWindowEx: %d '%s' '%s' %d,%d %dx%d %08x %x\n", exStyle, className, windowName, x, y, width, height, style, parent); #endif + /* Before anything, create the desktop window */ + if (!hwndDesktop) + if (!(hwndDesktop = WIN_CreateDesktopWindow())) return 0; + if (x == CW_USEDEFAULT) x = y = 0; if (width == CW_USEDEFAULT) { @@ -203,11 +251,10 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName, /* Find the parent and class */ - if (parent) + if (parent) { /* Check if parent is valid */ - parentPtr = WIN_FindWndPtr( parent ); - if (!parent) return 0; + if (!(parentPtr = WIN_FindWndPtr( parent ))) return 0; } else if (style & WS_CHILD) return 0; /* WS_CHILD needs a parent */ @@ -233,7 +280,7 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName, wndPtr->hwndNext = 0; wndPtr->hwndChild = 0; wndPtr->dwMagic = WND_MAGIC; - wndPtr->hwndParent = (style & WS_CHILD) ? parent : 0; + wndPtr->hwndParent = (style & WS_CHILD) ? parent : hwndDesktop; wndPtr->hwndOwner = (style & WS_CHILD) ? 0 : parent; wndPtr->hClass = class; wndPtr->hInstance = instance; @@ -254,14 +301,23 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName, wndPtr->dwStyle = style; wndPtr->dwExStyle = exStyle; wndPtr->hmenuSystem = 0; - wndPtr->wIDmenu = menu; +#ifdef DEBUG_MENU + printf("CreateWindowEx // menu=%04X instance=%04X classmenu=%08X !\n", + menu, instance, classPtr->wc.lpszMenuName); +#endif + if (menu != 0) + wndPtr->wIDmenu = menu; + else { + if (classPtr->wc.lpszMenuName != NULL) + wndPtr->wIDmenu = LoadMenu(instance, classPtr->wc.lpszMenuName); + else + wndPtr->wIDmenu = 0; + } wndPtr->hText = 0; wndPtr->flags = 0; - wndPtr->hCursor = 0; wndPtr->VScroll = NULL; wndPtr->HScroll = NULL; wndPtr->hSysMenu = 0; - wndPtr->hWndMenuBar = 0; if (classPtr->wc.cbWndExtra) memset( wndPtr->wExtra, 0, classPtr->wc.cbWndExtra ); @@ -362,25 +418,13 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName, return 0; } - /* Create scrollbars */ + /* Create a copy of SysMenu */ + if (style & WS_SYSMENU) wndPtr->hSysMenu = CopySysMenu(); + + /* Set window cursor */ + if (classPtr->wc.hCursor) CURSOR_SetWinCursor( hwnd, classPtr->wc.hCursor); + else CURSOR_SetWinCursor( hwnd, LoadCursor( 0, IDC_ARROW )); - if ((style & WS_SYSMENU) == WS_SYSMENU) { - wndPtr->hSysMenu = CopySysMenu(); - } - if (((style & WS_CHILD) != WS_CHILD) && (wndPtr->wIDmenu != 0)) { - lpbar = (LPPOPUPMENU) GlobalLock(wndPtr->wIDmenu); - if (lpbar != NULL) { - lpbar->ownerWnd = hwnd; - wndPtr->hWndMenuBar = CreateWindow("POPUPMENU", "", - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, - 0, 0, width, 20, hwnd, 2, instance, (LPSTR)lpbar); - } - } - /* Create scrollbars */ - if ((style & WS_VSCROLL) == WS_VSCROLL || - (style & WS_HSCROLL) == WS_HSCROLL) { - NC_CreateScrollBars(hwnd); - } EVENT_RegisterWindow( wndPtr->window, hwnd ); WIN_SendParentNotify( hwnd, wndPtr, WM_CREATE ); @@ -403,17 +447,12 @@ BOOL DestroyWindow( HWND hwnd ) if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return FALSE; WIN_SendParentNotify( hwnd, wndPtr, WM_DESTROY ); - /* Send destroy messages */ + /* Send destroy messages and destroy children */ SendMessage( hwnd, WM_DESTROY, 0, 0 ); - SendMessage( hwnd, WM_NCDESTROY, 0, 0 ); - - /* Destroy all children */ - - if (wndPtr->VScroll) free(wndPtr->VScroll); - if (wndPtr->HScroll) free(wndPtr->HScroll); while (wndPtr->hwndChild) /* The child removes itself from the list */ DestroyWindow( wndPtr->hwndChild ); + SendMessage( hwnd, WM_NCDESTROY, 0, 0 ); /* Remove the window from the linked list */ @@ -466,24 +505,12 @@ HWND FindWindow(LPSTR ClassMatch, LPSTR TitleMatch) } -/*********************************************************************** - * UpdateWindow (USER.124) - */ -void UpdateWindow( HWND hwnd ) -{ - if (GetUpdateRect( hwnd, NULL, FALSE )) - { - if (IsWindowVisible( hwnd )) SendMessage( hwnd, WM_PAINT, 0, 0 ); - } -} - - /********************************************************************** * GetDesktopWindow (USER.286) */ HWND GetDesktopWindow() { - return 0; + return hwndDesktop; } @@ -690,7 +717,7 @@ BOOL IsWindow( HWND hwnd ) HWND GetParent(HWND hwnd) { WND *wndPtr = WIN_FindWndPtr(hwnd); - if (!wndPtr) return 0; + if (!wndPtr || !(wndPtr->dwStyle & WS_CHILD)) return 0; return wndPtr->hwndParent; } @@ -700,20 +727,12 @@ HWND GetParent(HWND hwnd) */ BOOL IsChild( HWND parent, HWND child ) { - HWND curChild; - WND * parentPtr; - WND * childPtr; - - if (!(parentPtr = WIN_FindWndPtr( parent ))) return FALSE; - curChild = parentPtr->hwndChild; - - while (curChild) + WND * wndPtr = WIN_FindWndPtr( child ); + while (wndPtr && (wndPtr->dwStyle & WS_CHILD)) { - if (curChild == child) return TRUE; - if (IsChild( curChild, child )) return TRUE; - if (!(childPtr = WIN_FindWndPtr( curChild ))) return FALSE; - curChild = childPtr->hwndNext; - } + if (wndPtr->hwndParent == parent) return TRUE; + wndPtr = WIN_FindWndPtr( wndPtr->hwndParent ); + } return FALSE; } @@ -756,9 +775,10 @@ HWND GetWindow( HWND hwnd, WORD rel ) WND * parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ); return parentPtr->hwndChild; } - else return firstWindow; + else return 0; case GW_HWNDLAST: + if (!wndPtr->hwndParent) return 0; /* Desktop window */ while (wndPtr->hwndNext) { hwnd = wndPtr->hwndNext; @@ -778,7 +798,7 @@ HWND GetWindow( HWND hwnd, WORD rel ) WND * parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ); hwndPrev = parentPtr->hwndChild; } - else hwndPrev = firstWindow; + else return 0; /* Desktop window */ if (hwndPrev == hwnd) return 0; while (hwndPrev) { @@ -825,25 +845,16 @@ HWND GetNextWindow( HWND hwnd, WORD flag ) * * o if wndenumprc returns 0 exit * - * * remove the HAS_DESKTOP_WINDOW ifdef when the GetDesktopWindow() call - * is fixed to actually return the desktop window - * */ BOOL EnumWindows(FARPROC wndenumprc, LPARAM lParam) { - HWND hwnd = GetDesktopWindow(); + HWND hwnd = GetTopWindow( GetDesktopWindow() ); WND *wndPtr; int result; #ifdef DEBUG_ENUM printf("EnumWindows\n"); #endif -#ifdef HAS_DESKTOP_WINDOW - if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0; - hwnd = wndPtr->hwndChild; -#else - hwnd = firstWindow; -#endif while (hwnd) { char *ptr; @@ -856,8 +867,12 @@ BOOL EnumWindows(FARPROC wndenumprc, LPARAM lParam) printf("found a window (%s)\n", ptr); else printf("found nameless parent window\n"); -#endif +#endif +#ifdef WINELIB + (*wndenumprc)(hwnd, lParam); +#else result = CallBack16(wndenumprc, 2, lParam, (int) hwnd); +#endif if ( ! result ) { return 0; } @@ -899,7 +914,11 @@ static BOOL WIN_EnumChildWin(HWND hwnd, FARPROC wndenumprc, LPARAM lParam) return 0; } #endif +#ifdef WINELIB + if (!(*wndenumprc, 2, lParam, (int) hwnd)) { +#else if (!CallBack16(wndenumprc, 2, lParam, (int) hwnd)) { +#endif return 0; } if (!WIN_EnumChildWin(wndPtr->hwndChild, wndenumprc, lParam)) { diff --git a/windows/winpos.c b/windows/winpos.c index 49d091fa6f4..ee37ecb2850 100644 --- a/windows/winpos.c +++ b/windows/winpos.c @@ -24,7 +24,7 @@ void GetWindowRect( HWND hwnd, LPRECT rect ) if (!wndPtr) return; *rect = wndPtr->rectWindow; - if (wndPtr->hwndParent) + if (wndPtr->dwStyle & WS_CHILD) MapWindowPoints( wndPtr->hwndParent, 0, (POINT *)rect, 2 ); } @@ -69,7 +69,7 @@ void ScreenToClient( HWND hwnd, LPPOINT lppnt ) HWND WindowFromPoint( POINT pt ) { RECT rect; - HWND hwnd = firstWindow; + HWND hwnd = GetTopWindow( GetDesktopWindow() ); while (hwnd) { GetWindowRect( hwnd, &rect ); @@ -117,7 +117,7 @@ void MapWindowPoints( HWND hwndFrom, HWND hwndTo, LPPOINT lppt, WORD count ) wndPtr = WIN_FindWndPtr( hwndFrom ); origin.x += wndPtr->rectClient.left; origin.y += wndPtr->rectClient.top; - hwndFrom = wndPtr->hwndParent; + hwndFrom = (wndPtr->dwStyle & WS_CHILD) ? wndPtr->hwndParent : 0; } /* Translate origin to destination window coords */ @@ -126,7 +126,7 @@ void MapWindowPoints( HWND hwndFrom, HWND hwndTo, LPPOINT lppt, WORD count ) wndPtr = WIN_FindWndPtr( hwndTo ); origin.x -= wndPtr->rectClient.left; origin.y -= wndPtr->rectClient.top; - hwndTo = wndPtr->hwndParent; + hwndTo = (wndPtr->dwStyle & WS_CHILD) ? wndPtr->hwndParent : 0; } /* Translate points */ @@ -375,6 +375,13 @@ void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos, } else pMinMax = &MinMax; + /* Some sanity checks */ + + pMinMax->ptMaxTrackSize.x = max( pMinMax->ptMaxTrackSize.x, + pMinMax->ptMinTrackSize.x ); + pMinMax->ptMaxTrackSize.y = max( pMinMax->ptMaxTrackSize.y, + pMinMax->ptMinTrackSize.y ); + if (maxSize) *maxSize = pMinMax->ptMaxSize; if (maxPos) *maxPos = pMinMax->ptMaxPosition; if (minTrack) *minTrack = pMinMax->ptMinTrackSize; @@ -486,7 +493,7 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, short x, short y, /* Make sure hwndInsertAfter is a sibling of hwnd */ if ((hwndInsertAfter != HWND_TOP) && (hwndInsertAfter != HWND_BOTTOM)) - if (wndPtr->hwndParent != GetParent(hwndInsertAfter)) goto Abort; + if (GetParent(hwnd) != GetParent(hwndInsertAfter)) goto Abort; WIN_UnlinkWindow( hwnd ); WIN_LinkWindow( hwnd, hwndInsertAfter ); @@ -531,7 +538,7 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, short x, short y, WND * parentPtr; winChanges.x = newWindowRect.left; winChanges.y = newWindowRect.top; - if (wndPtr->hwndParent) + if (wndPtr->dwStyle & WS_CHILD) { parentPtr = WIN_FindWndPtr(wndPtr->hwndParent); winChanges.x += parentPtr->rectClient.left-parentPtr->rectWindow.left;