Release 940405

Tue Apr  5 14:36:59 1994  Bob Amstadt  (bob@pooh)

	* [include/mdi.h] [windows/mdi.c]
	Use WM_PARENTNOTIFY messages to activate children.
	Generate WM_CHILDACTIVATE messages.
	Beginnings handler for maxmized child window.
	Clean up when children are destroyed.

	* [windows/message.c] [windows/nonclient.c] [windows/winpos.c]
	Removed code add 94/03/26.

Apr 4, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [control/menu.c]
	Make mouse menu navigation working again. :-))
	(be carefull, clicking outside menus (ie.: clientrect) 
	not resolved yet)

	* [windows/nonclient.c]  [controls/scroll.c]
	Bugs fix in NCTrackScrollBars().

	* [misc/dos_fs.c]
	Bug fix in 'ToDos()' in conversion for '/',
		(example: '/window/' was translated to 'WINDOWs').

	* [miscemu/int21.c]
	Function ChangeDir() extract possible drive before DOS_ChangeDir().

	* [loader/library.c]  [loader/wine.c]
	Playing around moving function GetProcAddress() and put some code in.

Mon Apr  4 21:39:07 1994  Alexandre Julliard (julliard@lamisun.epfl.ch)

	* [misc/main.c]
	Better explanation of command-line options.

	* [objects/dib.c]
	Implemented SetDIBitsToDevice().

	* [windows/dc.c]
	Bug fix in SetDCState().

	* [windows/event.c]
	Removed WS_DISABLED handling (now done in message.c).

	* [windows/message.c]
	Added sending a WM_PARENTNOTIFY message in MSG_TranslateMouseMsg().
	Use WindowFromPoint() to find the window for mouse events, taking
	into account disabled windows.

	* [windows/painting.c]
	Bug fix in BeginPaint() to allow calling it at other times than
	on WM_PAINT (Solitaire needs it...)

	* [windows/win.c]
	Implemented FindWindow().
	Rewritten EnableWindow() to behave more like Windows.

	* [windows/winpos.c]
	Rewritten WindowFromPoint() to also search child windows.

Mon Apr  4 17:36:32 1994  Erik Bos (erik@trashcan.hacktic.nl)

	* [include/int21.h] -> [msdos.h]
	renamed.

	* [miscemu/int10.h] [miscemu/int25.h] [miscemu/int26.h] 
	new, added for int 10, 25 and 26.

	* [miscemu/ioports.c]
	new, added to allow win apps to use ioports.

	* [loader/signal.c]
	Added support for in, inb, out, outb instructions.

Sun Mar 27 13:40:25 1994  Bob Amstadt  (bob@pooh)

	* controls/menu.c (InsertMenu): Changed to use FindMenuItem().

Sat Mar 26 21:23:55 1994  Bob Amstadt  (bob@pooh)

	* [windows/mdi.c]
	Window list properly updated.

	* [windows/message.c]
	Call WINPOS_ChildActivate() when mouse pressed.

	* [windows/nonclient.c]
	Use WINPOS_IsAnActiveWindow() instead of GetActiveWindow() in
	NC_HandleNCPaint().

	* [windows/winpos.c]
	Created functions WINPOS_IsAnActiveWindow() and WINPOS_ActivateChild()

Thu Mar 24 14:49:17 1994  Bob Amstadt  (bob@pooh)

	* controls/menu.c (DeleteMenu): Changed to use FindMenuItem
	(DeleteMenu): Many bug fixes.

	* [controls/menu.c]
	Created function FindMenuItem().

Thu Mar 24 14:17:24 1994  Bob Amstadt  (bob@pooh)

	* [windows/win.c]
	Removed incorrect MDI handling code from CreateWindowEx().

	* [controls/menu.c]
	MF_STRING items needed to allocate a private copy of string.

	* [controls/menu.c]
	Fixed buggy calls to GlobalFree().

	* [memory/global.c]
	Eliminated some redundant code with function call.

Wed Mar 23 1994 Pentti Moilanen (pentti.moilanen@ntc.nokia.com)

	* [windows/timer.c]
	timer list pointers looped in InsertTimer

Tue Mar 29 13:32:08 MET DST 1994  julliard@di.epfl.ch (Alexandre Julliard)

	* [misc/cursor.c]
	A few changes for desktop window support.

	* [misc/main.c]
	Added -depth option.

	* [misc/rect.c]
	Yet another bug fix in SubtractRect().

	* [objects/bitmap.c]
	Changes to use only one depth (specified with -depth)
	for color bitmaps.

	* [objects/brush.c]
	Added support for dithered solid brushes.

	* [objects/color.c]
	Use the same 20 system colors as in Windows.
	System palette initialisation now done in COLOR_InitPalette().
	Added support for a color mapping table to map logical color
	indexes to X colormap entries.
	Implemented GetNearestColor() and RealizeDefaultPalette().

	* [objects/dib.c]
	Added support for color mapping table.

	* [objects/dither.c]  (New file)
	Implemented solid color dithering.

	* [objects/palette.c]
	Implemented GetSystemPaletteEntries() and SelectPalette().

	* [windows/class.c]
	Make a copy of the menu name in RegisterClass().

	* [windows/dc.c]
	Fixed device caps when using a desktop window.
	Added support for the color mapping table in DCs.

	* [windows/event.c]
	Added ConfigureNotify handler on desktop window.

	* [windows/message.c]
	Removed call to XTranslateCoordinates() on every mouse motion
	New function MSG_Synchronize() to synchronize with the X server.

	* [windows/syscolor.c]
	Rewritten SYSCOLOR_Init() to read the system colors from WIN.INI.

	* [windows/winpos.c]
	Added synchronization on window mapping. Solves the double redraw
	problem when starting Solitaire.

Mar 27, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [control/menu.c]	* [windows/defwnd.c]
	Make keyboard navigation working with menubar,
	but temporarely inserted a bug in menubar mouse handling ... :-((
	(it will be fix next week !)

	* [windows/defwnd.c]
	Connect VK_MENU to menubar navigation.

	* [loader/library.c]
	GetModuleHandle() return 'fictive 0xF000+ handles' for built-in DLLs.

Sun Mar 20 22:32:13 1994 Erik Bos (erik@trashcan.hacktic.nl)

	* [misc/main.c]
	Added Copy(). Added a check for `-h' to show usage.

	* [misc/dos_fs.c]
	Fixed bug in FindFile(), to load directories as dlls.

	* [misc/dos_fs.c]
	Fixed ToUnix() and ToDos() again, as my previous patch
	didn't make it.

	* [misc/dos_fs.c] [miscemu/int21.c]
	Bug fixes, should be able to handle all winfile and progman int21
	requests now except for a few small things.

Tue Mar 29 06:25:54 1994  crw@harris.mlb.semi.harris.com (Carl Williams)

	* [memory/heap.c]
	Implemented GetFreeSystemResources().

Mon Mar 21 17:32:25 1994  Bob Amstadt  (bob@pooh)

	* controls/menu.c (GetSubMenu): Function did not return correct value

	* [windows/mdi.c]
	Beginnings of menu handling.

Thu Mar 10 11:32:06 1994  Stefan (SAM) Muenzel  (muenzel@tat.physik.uni-tuebingen.de)

	* [objects/font.c]
	if font.width equals zero use asterix instead.

Mon Mar 21 17:23:37 MET 1994  julliard@di.epfl.ch (Alexandre Julliard)

	* [objects/bitmap.c]
	Rewritten bitmap code to use exclusively X pixmaps; *much* faster.

	* [objects/brush.c]
	Some changes with pattern brushes because of the new bitmap code.

	* [objects/color.c]
	Added function COLOR_ToPhysical for better color mapping.

	* [objects/dib.c]
	Heavily optimized SetDIBits().

	* [windows/dc.c]
	Opimized SetDCState() and DC_SetupGC*() functions.
	Added stub for CreateIC().

Mar 20, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [misc/message.c]
	Call SetFocus() after closing box to give back focus to previous owner.

	* [misc/files.c]
	Small bug fix in GetTempFilename() : replace a '\' to '\\'.

	* [control/scroll.c]
	Calls to BitBlt() replace by StretchBlt().

	* [control/menu.c]
	Call SetFocus() to previous owner after closing Popups.	
	Fill stub DeleteMenu().

	* [control/listbox.c]
	* [control/combo.c]
	Use SetFocus() in WM_LBUTTONDOWN.
	Close ComboBox List upon WM_KILLFOCUS.
	Early development of WM_MEASUREITEM mecanism.

	* [windows/defwnd.c]
	Early development of WM_MEASUREITEM mecanism.

Tue Mar 22 10:44:57 1994  Miguel de Icaza  (miguel@xochitl)

	* [misc/atom.c]
	Fixed sintaxis problem when building the library.

Tue Mar 15 13:11:56 1994  Bob Amstadt  (bob@pooh)

	* [include/windows.h]
	Added message types and structures for MDI

	* [include/mdi.h]
	Created internal structures for handling MDI

	* [windows/mdi.c]
	Began creating MDI support

Thu Mar 10 16:51:46 1994  Bob Amstadt  (bob@pooh)

	* [loader/wine.c] [include/wine.h]
	Added new field to "struct w_files" to hold the "name table"
	resource for Windows 3.0 programs

	* [loader/resource.c]
	Added code to handle programs with a "name table" resource.
	LoadResourceByName() modified to check for the existence of
	this resource.

Mon Mar 14 22:31:42 MET 1994  julliard@di.epfl.ch (Alexandre Julliard)

	* [objects/color.c]
	Added installing the private colormap on the desktop window.

	* [windows/event.c]
	Cleaned up focus event handling (see focus.c).
	Use GetFocus() to direct key events to the correct window.

	* [windows/focus.c]
	Rewritten SetFocus() to:
	- only set X focus on top-level windows
	- send WM_SETFOCUS and WM_KILLFOCUS messages (was done in event.c)
	- prevent setting focus to disabled windows
	- install private colormap so -privatemap option works again

	* [windows/message.c] [windows/timer.c]
	Changed timer management to no longer use PostMessage(), but
	to generate timer messages on the fly. Also fixed a related bug
	in GetMessage() which could cause busy-waiting.

	* [windows/win.c]
	Only select focus events on top-level windows.

	* [windows/winpos.c]
	Added some sanity checks for desktop window.

Fri Mar  4 20:42:01 1994  Erik Bos (erik@trashcan.hacktic.nl)

	* [misc/dos_fs.c]
	bug fixes in ToUnix(), WinIniFileName(), GetUnixFileName(). 
	Support for tilde symbol added for rootdirectories in [drives]
	section of wine's configfile.

	* [misc/file.c]
	hread(), hwrite() added.

	* [misc/main.c]
	hmemcpy() added.

	* [if1632/stress.spec] [include/stress.h] [misc/stress.c]
	Added STRESS.DLL, an useless dll used to stress a windows system.

	* [*/*]
	Added missing #includes, fixed prototypes for prototype checking.

	* [include/prototypes.h]

	Added prototypes for loader/*c, if1632/*c.

Tue Mar  8 09:54:34 1994  Bob Amstadt  (bob@pooh)

	* [Configure]
	Added reminder to set WINEPATH, if it is not set.

	* [Imakefile]
	Removed #elif's

	* [controls/button.c]
	Added BN_CLICKED notification for owner-draw buttons.

	* [if1632/kernel.spec] [memory/heap.c]
	Changed Local* functions to WIN16_Local* to prevent unconcious use
	of these functions.

	* [if1632/relay.c]
	Push old Stack16Frame on stack before setting.

	* [include/atom.h] [misc/atom.c] [include/heap.h] [memory/local.c]
	Added multiple local heap handling in Atom* functions.

	* [include/regfunc.h] [miscemu/int21.c]
	Rewrote DOS3Call() use context frame that is already on the stack.

	* [misc/profile.c]
	Fixed to allow leading ";" to mark comments.

	* [misc/spy.c]
	Fixed bugs and added support for "include" and "exclude" filters.

	* [misc/user.c]
	Rearranged calls in InitApp().

	* [misc/font.c]
	Fixed font handling to create system fonts, if they are used.

	* [windows/dc.c]
	If text drawn on window with no font specified, then default the
	font to the system font.

Mon Mar  7 20:32:09 MET 1994  julliard@di.epfl.ch (Alexandre Julliard)

	* [controls/desktop.c]
	Added handling of WM_NCCREATE and WM_ERASEBKGND functions.
	Implemented SetDeskPattern().

	* [misc/main.c]
	Added -desktop option to get a large desktop window with
	everything inside it.
	Added -name option.

	* [misc/rect.c]
	Bug fix in SubtractRect().

	* [objects/*.c]
	Replaced the DefaultRootWindow() macro by the rootWindow variable.

	* [windows/event.c] [windows/message.c]
	  [windows/nonclient.c] [windows/win.c]
	A few changes to accomodate the new desktop window.

 Tue Mar  8 11:13:03 1994  Miguel de Icaza  (miguel@xochitl.nuclecu.unam.mx)
 
 	* [toolkit/arch.c] --New file-- 
 	Routines for converting little endian data structures to
 	big-endian data structures, currently only BITMAP structures are 
 	converted.
 
 	* [misc/atom.c]
 	When used as part of the WineLib, the code is much simpler.
 	Doesn't depend on alignement.
 
 	* [loader/wine.c]
 	Ifdefed Emulator dependent code if compiling WineLib.
 
 	* [loader/resource.c]
 	Moved misc/resource.c to loader/resource.c.
 
 	* [loader/dump.c,ldt.c,ldtlib.c,library,c,selector.c,signal.c]
 	Ifdefed whole code if compiling WINELIB.
 
 	* [include/winsock.h]
 	Added compilation define to allow compilation on SunOS.
 
 	* [include/wine.h]
 	Removed load_typeinfo and load_nameinfo prototypes, they belong
 	to neexe.h
 
 	* [include/neexe.h]
 	Added load_typeinfo and load_nameinfo prototypes.
 
 	* [include/arch.h]
 	Fixed some bugs in the conversion routines.
 	Added macros for Bitmap loading.

Tue Mar  8 12:52:05 1994  crw@maniac.mlb.semi.harris.com (Carl Williams)
 	
	* [if1632/kernel.spec] [memory/global.c]
	Implemented GetFreeSpace()

	* [if1632/user.spec] [loader/resource.c]
	Implemented CreateIcon()
This commit is contained in:
Alexandre Julliard 1994-04-05 21:42:43 +00:00
parent fb9a919f8a
commit 8d24ae6d31
126 changed files with 9661 additions and 4591 deletions

4
BUGS
View File

@ -1 +1,5 @@
- EBP and ESP are sometimes corrupted while running 16-bit code. - EBP and ESP are sometimes corrupted while running 16-bit code.
- Dialog Boxes created by WM_CREATE handler aren't visible
- RegisterClass() with hbrBackground = COLOR_APPWORKSPACE+1 does not work.
- MDI client area needs to resize when frame does
- Need to generate WM_CHILDACTIVATE

449
ChangeLog
View File

@ -1,3 +1,452 @@
----------------------------------------------------------------------
Tue Apr 5 14:36:59 1994 Bob Amstadt (bob@pooh)
* [include/mdi.h] [windows/mdi.c]
Use WM_PARENTNOTIFY messages to activate children.
Generate WM_CHILDACTIVATE messages.
Beginnings handler for maxmized child window.
Clean up when children are destroyed.
* [windows/message.c] [windows/nonclient.c] [windows/winpos.c]
Removed code add 94/03/26.
Apr 4, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [control/menu.c]
Make mouse menu navigation working again. :-))
(be carefull, clicking outside menus (ie.: clientrect)
not resolved yet)
* [windows/nonclient.c] [controls/scroll.c]
Bugs fix in NCTrackScrollBars().
* [misc/dos_fs.c]
Bug fix in 'ToDos()' in conversion for '/',
(example: '/window/' was translated to 'WINDOWs').
* [miscemu/int21.c]
Function ChangeDir() extract possible drive before DOS_ChangeDir().
* [loader/library.c] [loader/wine.c]
Playing around moving function GetProcAddress() and put some code in.
Mon Apr 4 21:39:07 1994 Alexandre Julliard (julliard@lamisun.epfl.ch)
* [misc/main.c]
Better explanation of command-line options.
* [objects/dib.c]
Implemented SetDIBitsToDevice().
* [windows/dc.c]
Bug fix in SetDCState().
* [windows/event.c]
Removed WS_DISABLED handling (now done in message.c).
* [windows/message.c]
Added sending a WM_PARENTNOTIFY message in MSG_TranslateMouseMsg().
Use WindowFromPoint() to find the window for mouse events, taking
into account disabled windows.
* [windows/painting.c]
Bug fix in BeginPaint() to allow calling it at other times than
on WM_PAINT (Solitaire needs it...)
* [windows/win.c]
Implemented FindWindow().
Rewritten EnableWindow() to behave more like Windows.
* [windows/winpos.c]
Rewritten WindowFromPoint() to also search child windows.
Mon Apr 4 17:36:32 1994 Erik Bos (erik@trashcan.hacktic.nl)
* [include/int21.h] -> [msdos.h]
renamed.
* [miscemu/int10.h] [miscemu/int25.h] [miscemu/int26.h]
new, added for int 10, 25 and 26.
* [miscemu/ioports.c]
new, added to allow win apps to use ioports.
* [loader/signal.c]
Added support for in, inb, out, outb instructions.
----------------------------------------------------------------------
Sun Mar 27 13:40:25 1994 Bob Amstadt (bob@pooh)
* controls/menu.c (InsertMenu): Changed to use FindMenuItem().
Sat Mar 26 21:23:55 1994 Bob Amstadt (bob@pooh)
* [windows/mdi.c]
Window list properly updated.
* [windows/message.c]
Call WINPOS_ChildActivate() when mouse pressed.
* [windows/nonclient.c]
Use WINPOS_IsAnActiveWindow() instead of GetActiveWindow() in
NC_HandleNCPaint().
* [windows/winpos.c]
Created functions WINPOS_IsAnActiveWindow() and WINPOS_ActivateChild()
Thu Mar 24 14:49:17 1994 Bob Amstadt (bob@pooh)
* controls/menu.c (DeleteMenu): Changed to use FindMenuItem
(DeleteMenu): Many bug fixes.
* [controls/menu.c]
Created function FindMenuItem().
Thu Mar 24 14:17:24 1994 Bob Amstadt (bob@pooh)
* [windows/win.c]
Removed incorrect MDI handling code from CreateWindowEx().
* [controls/menu.c]
MF_STRING items needed to allocate a private copy of string.
* [controls/menu.c]
Fixed buggy calls to GlobalFree().
* [memory/global.c]
Eliminated some redundant code with function call.
Wed Mar 23 1994 Pentti Moilanen (pentti.moilanen@ntc.nokia.com)
* [windows/timer.c]
timer list pointers looped in InsertTimer
Tue Mar 29 13:32:08 MET DST 1994 julliard@di.epfl.ch (Alexandre Julliard)
* [misc/cursor.c]
A few changes for desktop window support.
* [misc/main.c]
Added -depth option.
* [misc/rect.c]
Yet another bug fix in SubtractRect().
* [objects/bitmap.c]
Changes to use only one depth (specified with -depth)
for color bitmaps.
* [objects/brush.c]
Added support for dithered solid brushes.
* [objects/color.c]
Use the same 20 system colors as in Windows.
System palette initialisation now done in COLOR_InitPalette().
Added support for a color mapping table to map logical color
indexes to X colormap entries.
Implemented GetNearestColor() and RealizeDefaultPalette().
* [objects/dib.c]
Added support for color mapping table.
* [objects/dither.c] (New file)
Implemented solid color dithering.
* [objects/palette.c]
Implemented GetSystemPaletteEntries() and SelectPalette().
* [windows/class.c]
Make a copy of the menu name in RegisterClass().
* [windows/dc.c]
Fixed device caps when using a desktop window.
Added support for the color mapping table in DCs.
* [windows/event.c]
Added ConfigureNotify handler on desktop window.
* [windows/message.c]
Removed call to XTranslateCoordinates() on every mouse motion
New function MSG_Synchronize() to synchronize with the X server.
* [windows/syscolor.c]
Rewritten SYSCOLOR_Init() to read the system colors from WIN.INI.
* [windows/winpos.c]
Added synchronization on window mapping. Solves the double redraw
problem when starting Solitaire.
Mar 27, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [control/menu.c] * [windows/defwnd.c]
Make keyboard navigation working with menubar,
but temporarely inserted a bug in menubar mouse handling ... :-((
(it will be fix next week !)
* [windows/defwnd.c]
Connect VK_MENU to menubar navigation.
* [loader/library.c]
GetModuleHandle() return 'fictive 0xF000+ handles' for built-in DLLs.
Sun Mar 20 22:32:13 1994 Erik Bos (erik@trashcan.hacktic.nl)
* [misc/main.c]
Added Copy(). Added a check for `-h' to show usage.
* [misc/dos_fs.c]
Fixed bug in FindFile(), to load directories as dlls.
* [misc/dos_fs.c]
Fixed ToUnix() and ToDos() again, as my previous patch
didn't make it.
* [misc/dos_fs.c] [miscemu/int21.c]
Bug fixes, should be able to handle all winfile and progman int21
requests now except for a few small things.
Tue Mar 29 06:25:54 1994 crw@harris.mlb.semi.harris.com (Carl Williams)
* [memory/heap.c]
Implemented GetFreeSystemResources().
----------------------------------------------------------------------
Mon Mar 21 17:32:25 1994 Bob Amstadt (bob@pooh)
* controls/menu.c (GetSubMenu): Function did not return correct value
* [windows/mdi.c]
Beginnings of menu handling.
Thu Mar 10 11:32:06 1994 Stefan (SAM) Muenzel (muenzel@tat.physik.uni-tuebingen.de)
* [objects/font.c]
if font.width equals zero use asterix instead.
Mon Mar 21 17:23:37 MET 1994 julliard@di.epfl.ch (Alexandre Julliard)
* [objects/bitmap.c]
Rewritten bitmap code to use exclusively X pixmaps; *much* faster.
* [objects/brush.c]
Some changes with pattern brushes because of the new bitmap code.
* [objects/color.c]
Added function COLOR_ToPhysical for better color mapping.
* [objects/dib.c]
Heavily optimized SetDIBits().
* [windows/dc.c]
Opimized SetDCState() and DC_SetupGC*() functions.
Added stub for CreateIC().
Mar 20, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [misc/message.c]
Call SetFocus() after closing box to give back focus to previous owner.
* [misc/files.c]
Small bug fix in GetTempFilename() : replace a '\' to '\\'.
* [control/scroll.c]
Calls to BitBlt() replace by StretchBlt().
* [control/menu.c]
Call SetFocus() to previous owner after closing Popups.
Fill stub DeleteMenu().
* [control/listbox.c]
* [control/combo.c]
Use SetFocus() in WM_LBUTTONDOWN.
Close ComboBox List upon WM_KILLFOCUS.
Early development of WM_MEASUREITEM mecanism.
* [windows/defwnd.c]
Early development of WM_MEASUREITEM mecanism.
Tue Mar 22 10:44:57 1994 Miguel de Icaza (miguel@xochitl)
* [misc/atom.c]
Fixed sintaxis problem when building the library.
----------------------------------------------------------------------
Tue Mar 15 13:11:56 1994 Bob Amstadt (bob@pooh)
* [include/windows.h]
Added message types and structures for MDI
* [include/mdi.h]
Created internal structures for handling MDI
* [windows/mdi.c]
Began creating MDI support
Thu Mar 10 16:51:46 1994 Bob Amstadt (bob@pooh)
* [loader/wine.c] [include/wine.h]
Added new field to "struct w_files" to hold the "name table"
resource for Windows 3.0 programs
* [loader/resource.c]
Added code to handle programs with a "name table" resource.
LoadResourceByName() modified to check for the existence of
this resource.
Mon Mar 14 22:31:42 MET 1994 julliard@di.epfl.ch (Alexandre Julliard)
* [objects/color.c]
Added installing the private colormap on the desktop window.
* [windows/event.c]
Cleaned up focus event handling (see focus.c).
Use GetFocus() to direct key events to the correct window.
* [windows/focus.c]
Rewritten SetFocus() to:
- only set X focus on top-level windows
- send WM_SETFOCUS and WM_KILLFOCUS messages (was done in event.c)
- prevent setting focus to disabled windows
- install private colormap so -privatemap option works again
* [windows/message.c] [windows/timer.c]
Changed timer management to no longer use PostMessage(), but
to generate timer messages on the fly. Also fixed a related bug
in GetMessage() which could cause busy-waiting.
* [windows/win.c]
Only select focus events on top-level windows.
* [windows/winpos.c]
Added some sanity checks for desktop window.
Fri Mar 4 20:42:01 1994 Erik Bos (erik@trashcan.hacktic.nl)
* [misc/dos_fs.c]
bug fixes in ToUnix(), WinIniFileName(), GetUnixFileName().
Support for tilde symbol added for rootdirectories in [drives]
section of wine's configfile.
* [misc/file.c]
hread(), hwrite() added.
* [misc/main.c]
hmemcpy() added.
* [if1632/stress.spec] [include/stress.h] [misc/stress.c]
Added STRESS.DLL, an useless dll used to stress a windows system.
* [*/*]
Added missing #includes, fixed prototypes for prototype checking.
* [include/prototypes.h]
Added prototypes for loader/*c, if1632/*c.
----------------------------------------------------------------------
Tue Mar 8 09:54:34 1994 Bob Amstadt (bob@pooh)
* [Configure]
Added reminder to set WINEPATH, if it is not set.
* [Imakefile]
Removed #elif's
* [controls/button.c]
Added BN_CLICKED notification for owner-draw buttons.
* [if1632/kernel.spec] [memory/heap.c]
Changed Local* functions to WIN16_Local* to prevent unconcious use
of these functions.
* [if1632/relay.c]
Push old Stack16Frame on stack before setting.
* [include/atom.h] [misc/atom.c] [include/heap.h] [memory/local.c]
Added multiple local heap handling in Atom* functions.
* [include/regfunc.h] [miscemu/int21.c]
Rewrote DOS3Call() use context frame that is already on the stack.
* [misc/profile.c]
Fixed to allow leading ";" to mark comments.
* [misc/spy.c]
Fixed bugs and added support for "include" and "exclude" filters.
* [misc/user.c]
Rearranged calls in InitApp().
* [misc/font.c]
Fixed font handling to create system fonts, if they are used.
* [windows/dc.c]
If text drawn on window with no font specified, then default the
font to the system font.
Mon Mar 7 20:32:09 MET 1994 julliard@di.epfl.ch (Alexandre Julliard)
* [controls/desktop.c]
Added handling of WM_NCCREATE and WM_ERASEBKGND functions.
Implemented SetDeskPattern().
* [misc/main.c]
Added -desktop option to get a large desktop window with
everything inside it.
Added -name option.
* [misc/rect.c]
Bug fix in SubtractRect().
* [objects/*.c]
Replaced the DefaultRootWindow() macro by the rootWindow variable.
* [windows/event.c] [windows/message.c]
[windows/nonclient.c] [windows/win.c]
A few changes to accomodate the new desktop window.
Tue Mar 8 11:13:03 1994 Miguel de Icaza (miguel@xochitl.nuclecu.unam.mx)
* [toolkit/arch.c] --New file--
Routines for converting little endian data structures to
big-endian data structures, currently only BITMAP structures are
converted.
* [misc/atom.c]
When used as part of the WineLib, the code is much simpler.
Doesn't depend on alignement.
* [loader/wine.c]
Ifdefed Emulator dependent code if compiling WineLib.
* [loader/resource.c]
Moved misc/resource.c to loader/resource.c.
* [loader/dump.c,ldt.c,ldtlib.c,library,c,selector.c,signal.c]
Ifdefed whole code if compiling WINELIB.
* [include/winsock.h]
Added compilation define to allow compilation on SunOS.
* [include/wine.h]
Removed load_typeinfo and load_nameinfo prototypes, they belong
to neexe.h
* [include/neexe.h]
Added load_typeinfo and load_nameinfo prototypes.
* [include/arch.h]
Fixed some bugs in the conversion routines.
Added macros for Bitmap loading.
Tue Mar 8 12:52:05 1994 crw@maniac.mlb.semi.harris.com (Carl Williams)
* [if1632/kernel.spec] [memory/global.c]
Implemented GetFreeSpace()
* [if1632/user.spec] [loader/resource.c]
Implemented CreateIcon()
---------------------------------------------------------------------- ----------------------------------------------------------------------
Tue Mar 1 11:30:21 1994 Bob Amstadt (bob@pooh) Tue Mar 1 11:30:21 1994 Bob Amstadt (bob@pooh)

View File

@ -2,12 +2,13 @@
ALLDEFINES='' ALLDEFINES=''
echo
echo -n 'Build Wine as emulator or library (E/L) [E]? ' echo -n 'Build Wine as emulator or library (E/L) [E]? '
read input read input
if [ "$input" = 'l' -o "$input" = 'L' ] if [ "$input" = 'l' -o "$input" = 'L' ]
then then
WINELIB='#define WineLib -DWINELIB' WINELIB='#define WINELIB -DWINELIB'
ALLDEFINES=$ALLDEFINES -DWINELIB ALLDEFINES="$ALLDEFINES -DWINELIB"
else else
WINELIB='' WINELIB=''
fi fi
@ -17,14 +18,40 @@ read input
if [ "$input" = 'y' -o "$input" = 'Y' ] if [ "$input" = 'y' -o "$input" = 'Y' ]
then then
SHORTNAMES='#define ShortNames -DSHORTNAMES' SHORTNAMES='#define ShortNames -DSHORTNAMES'
ALLDEFINES=$ALLDEFINES -DSHORTNAMES ALLDEFINES="$ALLDEFINES -DSHORTNAMES"
else else
SHORTNAMES='' SHORTNAMES=''
fi fi
echo -n 'Global configfile name [/usr/local/etc/wine.conf]? '
read input
if [ "$input" = '' ]
then
WINE_INI_GLOBAL='#define WINE_INI_GLOBAL "/usr/local/etc/wine.conf"'
else
WINE_INI_GLOBAL='#define WINE_INI_GLOBAL "'$input'"'
fi
if [ "`(domainname)`" = 'amscons.com' ]
then
echo -n 'New build program (Y/N) [N]? '
read input
if [ "$input" = 'y' -o "$input" = 'Y' ]
then
NEWBUILD='#define NewBuild -DNEWBUILD'
ALLDEFINES="$ALLDEFINES -DNEWBUILD"
else
NEWBUILD=''
fi
else
NEWBUILD=''
fi
echo '/* autoconf.h generated automatically. Run Configure. */' > autoconf.h echo '/* autoconf.h generated automatically. Run Configure. */' > autoconf.h
echo $WINELIB >> autoconf.h echo $WINELIB >> autoconf.h
echo $SHORTNAMES >> autoconf.h echo $SHORTNAMES >> autoconf.h
echo $NEWBUILD >> autoconf.h
echo $WINE_INI_GLOBAL >> autoconf.h
echo "#define AutoDefines $ALLDEFINES" >> autoconf.h echo "#define AutoDefines $ALLDEFINES" >> autoconf.h
xmkmf -a xmkmf -a

View File

@ -12,8 +12,9 @@ SUBMITTING YOUR WORK:
Submissions of code for inclussion into Wine should be sent to Submissions of code for inclussion into Wine should be sent to
bob@amscons.com (Bob Amstadt). You MUST provide a suitable bob@amscons.com (Bob Amstadt). You MUST provide a suitable
ChangeLog entry for any work that you submit. I prefer new code ChangeLog entry for any work that you submit. I prefer new code
to be submitted as diffs off of the latest release. Releases are to be submitted as unified diffs (diff -u) off of the latest release.
every Tuesday evening (approximately 19:00 PST or Wednesday 03:00 GMT). Releases are every Tuesday evening (approximately 17:00 PST or
Wednesday 01:00 GMT).
MEMORY AND SEGMENTS: MEMORY AND SEGMENTS:
@ -78,4 +79,11 @@ the "build" program to create dll_*.s and dll_tab_*.c. The dll_*.s
files contain the entry point code for each API call, and the dll_tab_*.s files contain the entry point code for each API call, and the dll_tab_*.s
files contain tables used by relay.c to translate arguments and transfer files contain tables used by relay.c to translate arguments and transfer
control to the proper handler. The format of the *.spec files is control to the proper handler. The format of the *.spec files is
documented in the file "tools/build-spec.txt". documented in the file "tools/build-spec.txt".
REGISTER FUNCTIONS:
Some functions are defined as type "register" in the DLL specification files.
Inorder to return values in the registers to the WIN16 program, the handler
function must exit by calling ReturnFromRegisterFunc(). Look at the function
DOS3Call() for an example of how this works.

View File

@ -27,6 +27,7 @@ COMMONSUBDIRS = \
controls \ controls \
etc \ etc \
include \ include \
loader \
misc \ misc \
objects \ objects \
test \ test \
@ -36,7 +37,6 @@ EMUSUBDIRS = \
tools \ tools \
debugger \ debugger \
if1632 \ if1632 \
loader \
memory \ memory \
miscemu miscemu
@ -47,6 +47,7 @@ WINEDIR = $(LIBDIR)/wine
COMMONOBJS = \ COMMONOBJS = \
controls.o \ controls.o \
loader.o \
misc.o \ misc.o \
objects.o \ objects.o \
windows.o windows.o
@ -58,7 +59,6 @@ COMMONOBJS = \
EMUOBJS = \ EMUOBJS = \
if1632.o \ if1632.o \
debugger.o \ debugger.o \
loader.o \
memory.o \ memory.o \
miscemu.o \ miscemu.o \
readline.o readline.o
@ -74,11 +74,13 @@ SUBDIRS = $(COMMONSUBDIRS) $(LIBSUBDIRS)
OBJS = $(COMMONOBJS) $(LIBOBJS) OBJS = $(COMMONOBJS) $(LIBOBJS)
#endif #endif
#if defined(i386BsdArchitecture) #ifdef i386BsdArchitecture
SYSLIBS = -ll -lm -li386 -lgnumalloc SYSLIBS = -ll -lm -li386 -lgnumalloc
#elif defined(i386FreeBsd) #endif
#ifdef i386FreeBsd
SYSLIBS = -ll -lm -lgnumalloc SYSLIBS = -ll -lm -lgnumalloc
#elif defined(LinuxArchitecture) #endif
#ifdef LinuxArchitecture
SYSLIBS = -lm -lg SYSLIBS = -lm -lg
#endif #endif

219
README
View File

@ -2,7 +2,9 @@ Copyright Robert J. Amstadt, 1993. All code is provided without
warranty. All code is covered by the license contained in the file warranty. All code is covered by the license contained in the file
LICENSE unless explicitly stated in the individual source file. LICENSE unless explicitly stated in the individual source file.
INSTALLATION:
1. COMPILATION:
You must have one of: You must have one of:
@ -11,21 +13,103 @@ You must have one of:
FreeBSD-current or FreeBSD 1.1 FreeBSD-current or FreeBSD 1.1
To build Wine, first do a "./Configure" 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' executable "wine" will be built. "wine" will load and run 16-bit
executables. You must have a file "wine.ini" in the current directory, Windows' executables.
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!
You must specify the entire path to the executable, or a filename only
(using the path= statement in wine.ini as the search path)
2. SETUP:
Wine requires you to have a file /usr/local/etc/wine.conf (you can
supply a different name when configuring wine) or a file called .winerc
in your homedirectory.
The formatstyle of this config file is just like a windows .ini file.
Here's an explanation of each section:
* [drives]
format: <driveletter> = <rootdirectory>
default: none
This section is used to specify the root directory of each `dos'drive
as windows' applications require a dos/mswindows based diskdrive &
directory scheme.
If you mounted you dos-partition as /dos and installed microsoft windows
in c:\windows than you should specify c=/dos in the drives section.
* [wine]
format: windows = <directory>
default: c:\windows
Used to specify an different windows directory.
format: system = <directory>
default: c:\windows\system
Used to specify an different system directory.
format: temp = <directory>
default: c:\temp
Used to specify a directory where windows applications can store temporary
files.
format: path = <directories separated by semi-colons>
default: c:\windows;c:\windows\system
Used to specify the path which will be used to find executables and DLL's.
format: systemresources = <filename>
default: c:\temp
Used to specify the name of sysres.dll, a dll which is used by wine itself.
* [serialports]
format: com[12345678] = <devicename>
default: none
Used to specify the devices which are used as com1 - com8.
* [parallelports]
format: lpt[12345678] = <devicename>
default: none
Used to specify the devices which are used as lpt1 - lpt8.
* [spy]
format: file = <filename or CON when logging to stdout>
default: none
used to specify the file which will be used as logfile.
format: exclude = <message names separated by semicolons>
default: none
Used to specify which messages will be excluded from the logfile.
format: include = <message names separated by semicolons>
default: none
Used to specify which messages will be included in the logfile.
3. RUNNING PROGRAMS
When invoking wine, you must specify the entire path to the executable,
or a filename only.
For example: to run Windows' solitaire: For example: to run Windows' solitaire:
export WINEPATH=/etc;/usr/windows wine sol (using the searchpath to locate the file)
wine sol.exe
wine sol (using the path= statement in wine.ini
wine sol.exe as the search path)
wine c:\\windows\\sol.exe (using a dosfilename) wine c:\\windows\\sol.exe (using a dosfilename)
@ -34,6 +118,93 @@ For example: to run Windows' solitaire:
Have a nice game of solitaire, but be careful. Emulation isn't perfect. Have a nice game of solitaire, but be careful. Emulation isn't perfect.
So, occassionally it will crash. So, occassionally it will crash.
4. EXAMPLE CONFIGFILE
----------------------------------------------------------------------------
[drives]
a=/mnt/fd0
c=/dos
d=~/Wine
[wine]
windows=c:\windows
system=c:\windows\system
temp=c:\temp
path=c:\windows;c:\windows\system;c:\winapps\word\;c:\winapps\pctools
systemresources=./sysres.dll
[serialports]
com1=/dev/cua1
com2=/dev/cua1
[parallelports]
lpt1=/dev/lp0
[spy]
;File=CON
;File=spy.log
Exclude=WM_TIMER;WM_SETCURSOR;WM_MOUSEMOVE;WM_NCHITTEST;WM_NCACTIVATE;WM_GETDLGCODE;
Include=WM_COMMAND;
----------------------------------------------------------------------------
5. BUILD:
The documentation for the build program is in the file build-spec.txt
6. FINALE:
Good luck,
If you successfully add anything, please send me a copy.
Bob Amstadt
bob@amscons.com
7. WHAT'S NEW
WHAT'S NEW with Wine-940405: (see ChangeLog for details)
- Mouse activation of menus working again
- GetprocAddress()
- SetDIBitsToDevice()
- FindWindow()
- int 10hm 25h and 26h
- in, inb, out, outb emulation
- and many many bug fixes!
WHAT'S NEW with Wine-940329: (see ChangeLog for details)
- MDI: child windows can be created, activated and cascaded.
- -depth option
- support for dithered brushes
- GetNearestColor(), RealizeDefaultPalette(),
GetSystemPaletteEntries(), and SelectPalette()
- System colors read from WIN.INI
- Keyboard menu manipulation (mouse is temporarily broken)
- GetFreeSystemResources()
- and many many bug fixes!
WHAT'S NEW with Wine-940322: (see ChangeLog for details)
- Speed improvements in bitmaps and mouse messages
- More MDI support. More to come next week...
- and many many bug fixes!
WHAT'S NEW with Wine-940315: (see ChangeLog for details)
- Beginnings of MDI support. More to come next week...
- Stress DLL
- and many many bug fixes!
WHAT'S NEW with Wine-940309: (see ChangeLog for details)
- New "exclude" and "include" filters for spy feature. See sample
wine.ini for details.
- -desktop and -name options (see ChangeLog)
- GetFreeSpace() and CreateIcon()
- and many many bug fixes!
WHAT'S NEW with Wine-940301: (see ChangeLog for details) WHAT'S NEW with Wine-940301: (see ChangeLog for details)
- NEW Configure script to set compile time options! - NEW Configure script to set compile time options!
- Support for filesystems with short (less than 14 chars) filenames. - Support for filesystems with short (less than 14 chars) filenames.
@ -299,27 +470,3 @@ WHAT'S NEW with version 0.0.1:
library routines. A brief description of how to build these library routines. A brief description of how to build these
specifications is included in the file "build-spec.txt". specifications is included in the file "build-spec.txt".
- The code to dispatch builtin DLL calls is complete, but untested. - The code to dispatch builtin DLL calls is complete, but untested.
TODO:
- Segment fixup code completion.
- Trap and handle DOS and DPMI calls.
- GlobalAlloc of code segments.
- Rewrite global memory support including kernel mods to allow
application to mess with page map.
- Handle self-loading applications.
- Resource loading
- Lots and lots of API fiunctions.
BUILD:
The documentation for the build program is in the file build-spec.txt
FINALE:
Good luck,
If you successfully add anything, please send me a copy.
Bob Amstadt
bob@amscons.com

View File

@ -1,26 +1,36 @@
XCOMM $Id$ XCOMM $Id$
INCLUDES = -I$(TOP)/include INCLUDES = -I$(TOP)/include -I$(TOP)
XCOMM Imake rules go here XCOMM Imake rules go here
XCOMM First, dll description to files etc XCOMM First, dll description to files etc
#ifndef MakeDllFromSpec #ifndef MakeDllFromSpec
#ifndef NewBuild
#ifndef ShortNames #ifndef ShortNames
#define MakeDllFromSpec(name,objfile) @@\ #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 @@\ Concat(dll_,name.S) Concat3(dll_,name,_tab.c): name.spec $(TOP)/tools/build @@\
$(TOP)/tools/build name.spec @@\ $(TOP)/tools/build name.spec @@\
#else #else /* ShortNames */
#define MakeDllFromSpec(name,objfile) @@\ #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 @@\
@@\
Concat(dll_,name.S) Concat(dtb_,name.c): name.spec $(TOP)/tools/build @@\
$(TOP)/tools/build name.spec @@\ $(TOP)/tools/build name.spec @@\
#endif /* SHORTNAMES */ #endif /* ShortNames */
#else /* NewBuild */
#ifndef ShortNames
#define MakeDllFromSpec(name,objfile) @@\
Concat(dll_,name.S) Concat(rly_,name.S) Concat3(dll_,name,_tab.c): name.spec $(TOP)/tools/newbuild @@\
$(TOP)/tools/newbuild name.spec @@\
#else /* ShortNames */
#define MakeDllFromSpec(name,objfile) @@\
Concat(dll_,name.S) Concat(rly_,name.S) Concat(dtb_,name.c): name.spec $(TOP)/tools/newbuild @@\
$(TOP)/tools/newbuild name.spec @@\
#endif /* ShortNames */
#endif /* NewBuild */
#endif /* MakeDllFromSpec */ #endif /* MakeDllFromSpec */
/* /*

View File

@ -963,7 +963,10 @@ static LONG UB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam)
ReleaseCapture(); ReleaseCapture();
GetClientRect(hWnd, &rc); GetClientRect(hWnd, &rc);
if (PtInRect(&rc, MAKEPOINT(lParam))) if (PtInRect(&rc, MAKEPOINT(lParam)))
{
NOTIFY_PARENT(hWnd, BN_CLICKED);
NOTIFY_PARENT(hWnd, BN_UNHILITE); NOTIFY_PARENT(hWnd, BN_UNHILITE);
}
InvalidateRect(hWnd, NULL, FALSE); InvalidateRect(hWnd, NULL, FALSE);
UpdateWindow(hWnd); UpdateWindow(hWnd);
} }

View File

@ -11,13 +11,16 @@
static char Copyright[] = "Copyright Martin Ayotte, 1993"; static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "windows.h" #include "windows.h"
#include "combo.h" #include "combo.h"
#include "heap.h" #include "heap.h"
#include "win.h" #include "win.h"
#include <sys/types.h> #include "prototypes.h"
#include <dirent.h>
#include <sys/stat.h>
HBITMAP hComboBit = 0; HBITMAP hComboBit = 0;
@ -45,275 +48,290 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
switch(message) switch(message)
{ {
case WM_CREATE: case WM_CREATE:
wndPtr = WIN_FindWndPtr(hwnd); wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr == NULL) return 0; if (wndPtr == NULL) return 0;
#ifdef DEBUG_COMBO #ifdef DEBUG_COMBO
printf("Combo WM_CREATE %lX !\n", lphc); printf("Combo WM_CREATE %lX !\n", lphc);
#endif #endif
if (hComboBit == (HBITMAP)NULL) if (hComboBit == (HBITMAP)NULL)
hComboBit = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_COMBO)); hComboBit = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_COMBO));
GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm); GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm);
wndPtr->dwStyle &= 0xFFFFFFFFL ^ (WS_VSCROLL | WS_HSCROLL); wndPtr->dwStyle &= 0xFFFFFFFFL ^ (WS_VSCROLL | WS_HSCROLL);
GetWindowRect(hwnd, &rect); GetWindowRect(hwnd, &rect);
width = rect.right - rect.left; width = rect.right - rect.left;
height = rect.bottom - rect.top; height = rect.bottom - rect.top;
SetWindowPos(hwnd, 0, 0, 0, width + bm.bmHeight, bm.bmHeight, SetWindowPos(hwnd, 0, 0, 0, width + bm.bmHeight, bm.bmHeight,
SWP_NOMOVE | SWP_NOZORDER); SWP_NOMOVE | SWP_NOZORDER);
CreateComboStruct(hwnd); CreateComboStruct(hwnd);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0; if (lphc == NULL) return 0;
if (wndPtr->dwStyle & CBS_SIMPLE) if (wndPtr->dwStyle & CBS_SIMPLE)
/* lphc->hWndEdit = CreateWindow("EDIT", "", */ /* lphc->hWndEdit = CreateWindow("EDIT", "", */
lphc->hWndEdit = CreateWindow("STATIC", "", lphc->hWndEdit = CreateWindow("STATIC", "",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT,
0, 0, width - bm.bmHeight, bm.bmHeight, 0, 0, width - bm.bmHeight, bm.bmHeight,
hwnd, 1, wndPtr->hInstance, 0L); hwnd, 1, wndPtr->hInstance, 0L);
else else
lphc->hWndEdit = CreateWindow("STATIC", "", lphc->hWndEdit = CreateWindow("STATIC", "",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT,
0, 0, width - bm.bmHeight, bm.bmHeight, 0, 0, width - bm.bmHeight, bm.bmHeight,
hwnd, 1, wndPtr->hInstance, 0L); hwnd, 1, wndPtr->hInstance, 0L);
lphc->hWndLBox = CreateWindow("LISTBOX", "", lphc->hWndLBox = CreateWindow("LISTBOX", "",
WS_CHILD | WS_CLIPCHILDREN | WS_BORDER | WS_VSCROLL | LBS_NOTIFY, WS_CHILD | WS_CLIPCHILDREN | WS_BORDER | WS_VSCROLL | LBS_NOTIFY,
wndPtr->rectClient.left, wndPtr->rectClient.top + bm.bmHeight, wndPtr->rectClient.left, wndPtr->rectClient.top + bm.bmHeight,
width, height, wndPtr->hwndParent, 1, width, height, wndPtr->hwndParent, 1,
wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd)); wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd));
ShowWindow(lphc->hWndLBox, SW_HIDE); ShowWindow(lphc->hWndLBox, SW_HIDE);
#ifdef DEBUG_COMBO #ifdef DEBUG_COMBO
printf("Combo Creation LBox=%X!\n", lphc->hWndLBox); printf("Combo Creation LBox=%X!\n", lphc->hWndLBox);
#endif #endif
return 0; return 0;
case WM_DESTROY: case WM_DESTROY:
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
if (lphc == 0) return 0; if (lphc == 0) return 0;
/* /*
DestroyWindow(lphc->hWndEdit); DestroyWindow(lphc->hWndEdit);
*/ */
DestroyWindow(lphc->hWndLBox); DestroyWindow(lphc->hWndLBox);
free(lphc); free(lphc);
/* /*
*((LPHEADCOMBO *)&wndPtr->wExtra[1]) = 0; *((LPHEADCOMBO *)&wndPtr->wExtra[1]) = 0;
printf("Combo WM_DESTROY after clearing wExtra !\n"); printf("Combo WM_DESTROY after clearing wExtra !\n");
*/ */
#ifdef DEBUG_COMBO #ifdef DEBUG_COMBO
printf("Combo WM_DESTROY %lX !\n", lphc); printf("Combo WM_DESTROY %lX !\n", lphc);
#endif #endif
return DefWindowProc( hwnd, message, wParam, lParam ); return DefWindowProc( hwnd, message, wParam, lParam );
case WM_COMMAND: case WM_COMMAND:
wndPtr = WIN_FindWndPtr(hwnd); wndPtr = WIN_FindWndPtr(hwnd);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0; if (lphc == NULL) return 0;
if (LOWORD(lParam) == lphc->hWndLBox) { if (LOWORD(lParam) == lphc->hWndLBox) {
switch(HIWORD(lParam)) switch(HIWORD(lParam)) {
{ case LBN_SELCHANGE:
case LBN_SELCHANGE: lphc->dwState = lphc->dwState & (CB_SHOWDROPDOWN ^ 0xFFFFFFFFL);
lphc->dwState = lphc->dwState & (CB_SHOWDROPDOWN ^ 0xFFFFFFFFL); ShowWindow(lphc->hWndLBox, SW_HIDE);
ShowWindow(lphc->hWndLBox, SW_HIDE); y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); if (y != LB_ERR) {
if (y != LB_ERR) { SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); }
} SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu, MAKELONG(hwnd, CBN_SELCHANGE));
MAKELONG(hwnd, CBN_SELCHANGE)); break;
break; case LBN_DBLCLK:
case LBN_DBLCLK: SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu, MAKELONG(hwnd, CBN_DBLCLK));
MAKELONG(hwnd, CBN_DBLCLK)); break;
break; }
}
} }
break; break;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
printf("Combo WM_LBUTTONDOWN wParam=%x lParam=%lX !\n", wParam, lParam); printf("Combo WM_LBUTTONDOWN wParam=%x lParam=%lX !\n", wParam, lParam);
GetClientRect(hwnd, &rect); GetClientRect(hwnd, &rect);
rect.left = rect.right - (rect.bottom - rect.top); rect.left = rect.right - (rect.bottom - rect.top);
hDC = GetDC(hwnd); hDC = GetDC(hwnd);
InflateRect(&rect, -1, -1); InflateRect(&rect, -1, -1);
DrawReliefRect(hDC, rect, 1, 1); DrawReliefRect(hDC, rect, 1, 1);
ReleaseDC(hwnd, hDC); ReleaseDC(hwnd, hDC);
wndPtr = WIN_FindWndPtr(hwnd); wndPtr = WIN_FindWndPtr(hwnd);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN; lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
ShowWindow(lphc->hWndLBox, SW_SHOW); ShowWindow(lphc->hWndLBox, SW_SHOW);
else { SetFocus(lphc->hWndLBox);
/* }
SetFocus(lphc->hWndEdit); else {
*/ SetFocus(lphc->hWndEdit);
ShowWindow(lphc->hWndLBox, SW_HIDE); ShowWindow(lphc->hWndLBox, SW_HIDE);
y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
if (y != LB_ERR) { if (y != LB_ERR) {
SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
} }
} }
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
printf("Combo WM_LBUTTONUP wParam=%x lParam=%lX !\n", wParam, lParam); printf("Combo WM_LBUTTONUP wParam=%x lParam=%lX !\n", wParam, lParam);
GetClientRect(hwnd, &rect); GetClientRect(hwnd, &rect);
rect.left = rect.right - (rect.bottom - rect.top); rect.left = rect.right - (rect.bottom - rect.top);
hDC = GetDC(hwnd); hDC = GetDC(hwnd);
InflateRect(&rect, -1, -1); InflateRect(&rect, -1, -1);
DrawReliefRect(hDC, rect, 1, 0); DrawReliefRect(hDC, rect, 1, 0);
ReleaseDC(hwnd, hDC); ReleaseDC(hwnd, hDC);
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:
wndPtr = WIN_FindWndPtr(hwnd); wndPtr = WIN_FindWndPtr(hwnd);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
count = SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L);
printf("COMBOBOX // GetKeyState(VK_MENU)=%d\n", GetKeyState(VK_MENU));
if (GetKeyState(VK_MENU) < 0) {
lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
ShowWindow(lphc->hWndLBox, SW_SHOW);
}
else {
ShowWindow(lphc->hWndLBox, SW_HIDE);
y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
if (y != LB_ERR) { count = SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L);
SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); printf("COMBOBOX // GetKeyState(VK_MENU)=%d\n", GetKeyState(VK_MENU));
SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); if (GetKeyState(VK_MENU) < 0) {
lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
ShowWindow(lphc->hWndLBox, SW_SHOW);
SetFocus(lphc->hWndLBox);
}
else {
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);
}
}
} }
} else {
} switch(wParam) {
else case VK_HOME:
{ y = 0;
switch(wParam) { break;
case VK_HOME: case VK_END:
y = 0; y = count - 1;
break; break;
case VK_END: case VK_UP:
y = count - 1; y--;
break; break;
case VK_UP: case VK_DOWN:
y--; y++;
break; break;
case VK_DOWN: }
y++; if (y < 0) y = 0;
break; if (y >= count) y = count - 1;
} SendMessage(lphc->hWndLBox, LB_SETCURSEL, y, 0L);
if (y < 0) y = 0; SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
if (y >= count) y = count - 1; SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
SendMessage(lphc->hWndLBox, LB_SETCURSEL, y, 0L); SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); MAKELONG(hwnd, CBN_SELCHANGE));
SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); }
SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu, break;
MAKELONG(hwnd, CBN_SELCHANGE)); case WM_MEASUREITEM:
} printf("ComboBoxWndProc WM_MEASUREITEM !\n");
break; return(SendMessage(GetParent(hwnd), WM_MEASUREITEM, wParam, lParam));
case WM_CTLCOLOR: case WM_CTLCOLOR:
return(SendMessage(GetParent(hwnd), WM_CTLCOLOR, wParam, lParam)); return(SendMessage(GetParent(hwnd), WM_CTLCOLOR, wParam, lParam));
case WM_PAINT: case WM_PAINT:
GetClientRect(hwnd, &rect); GetClientRect(hwnd, &rect);
hDC = BeginPaint(hwnd, &paintstruct); hDC = BeginPaint(hwnd, &paintstruct);
hMemDC = CreateCompatibleDC(hDC); hMemDC = CreateCompatibleDC(hDC);
GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm); GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm);
SelectObject(hMemDC, hComboBit); SelectObject(hMemDC, hComboBit);
BitBlt(hDC, rect.right - bm.bmWidth, 0, BitBlt(hDC, rect.right - bm.bmWidth, 0,
bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC); DeleteDC(hMemDC);
EndPaint(hwnd, &paintstruct); EndPaint(hwnd, &paintstruct);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
InvalidateRect(lphc->hWndEdit, NULL, TRUE); InvalidateRect(lphc->hWndEdit, NULL, TRUE);
UpdateWindow(lphc->hWndEdit); UpdateWindow(lphc->hWndEdit);
if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) { if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
InvalidateRect(lphc->hWndLBox, NULL, TRUE); InvalidateRect(lphc->hWndLBox, NULL, TRUE);
UpdateWindow(lphc->hWndLBox); UpdateWindow(lphc->hWndLBox);
} }
break; break;
case CB_ADDSTRING: case WM_SETFOCUS:
lphc = ComboGetStorageHeader(hwnd);
SetFocus(lphc->hWndEdit);
break;
case WM_KILLFOCUS:
lphc = ComboGetStorageHeader(hwnd);
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 CB_ADDSTRING:
#ifdef DEBUG_COMBO #ifdef DEBUG_COMBO
printf("CB_ADDSTRING '%s' !\n", (LPSTR)lParam); printf("CB_ADDSTRING '%s' !\n", (LPSTR)lParam);
#endif #endif
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_ADDSTRING, wParam, lParam)); return(SendMessage(lphc->hWndLBox, LB_ADDSTRING, wParam, lParam));
case CB_GETLBTEXT: case CB_GETLBTEXT:
printf("CB_GETLBTEXT #%u !\n", wParam); printf("CB_GETLBTEXT #%u !\n", wParam);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETTEXT, wParam, lParam)); return(SendMessage(lphc->hWndLBox, LB_GETTEXT, wParam, lParam));
case CB_GETLBTEXTLEN: case CB_GETLBTEXTLEN:
printf("CB_GETLBTEXTLEN !\n"); printf("CB_GETLBTEXTLEN !\n");
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETTEXTLEN, wParam, lParam)); return(SendMessage(lphc->hWndLBox, LB_GETTEXTLEN, wParam, lParam));
case CB_INSERTSTRING: case CB_INSERTSTRING:
printf("CB_INSERTSTRING '%s' !\n", (LPSTR)lParam); printf("CB_INSERTSTRING '%s' !\n", (LPSTR)lParam);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam)); return(SendMessage(lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam));
case CB_DELETESTRING: case CB_DELETESTRING:
printf("CB_DELETESTRING #%u !\n", wParam); printf("CB_DELETESTRING #%u !\n", wParam);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_DELETESTRING, wParam, 0L)); return(SendMessage(lphc->hWndLBox, LB_DELETESTRING, wParam, 0L));
case CB_RESETCONTENT: case CB_RESETCONTENT:
printf("CB_RESETCONTENT !\n"); printf("CB_RESETCONTENT !\n");
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_RESETCONTENT, 0, 0L)); return(SendMessage(lphc->hWndLBox, LB_RESETCONTENT, 0, 0L));
case CB_DIR: case CB_DIR:
printf("ComboBox CB_DIR !\n"); printf("ComboBox CB_DIR !\n");
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_DIR, wParam, lParam)); return(SendMessage(lphc->hWndLBox, LB_DIR, wParam, lParam));
case CB_FINDSTRING: case CB_FINDSTRING:
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_FINDSTRING, wParam, lParam)); return(SendMessage(lphc->hWndLBox, LB_FINDSTRING, wParam, lParam));
case CB_GETCOUNT: case CB_GETCOUNT:
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L)); return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L));
case CB_GETCURSEL: case CB_GETCURSEL:
printf("ComboBox CB_GETCURSEL !\n"); printf("ComboBox CB_GETCURSEL !\n");
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L)); return(SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L));
case CB_SETCURSEL: case CB_SETCURSEL:
printf("ComboBox CB_SETCURSEL wParam=%X !\n", wParam); printf("ComboBox CB_SETCURSEL wParam=%X !\n", wParam);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_SETCURSEL, wParam, 0L)); return(SendMessage(lphc->hWndLBox, LB_SETCURSEL, wParam, 0L));
case CB_GETEDITSEL: case CB_GETEDITSEL:
printf("ComboBox CB_GETEDITSEL !\n"); printf("ComboBox CB_GETEDITSEL !\n");
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
/* return(SendMessage(lphc->hWndEdit, EM_GETSEL, 0, 0L)); */ /* return(SendMessage(lphc->hWndEdit, EM_GETSEL, 0, 0L)); */
break; break;
case CB_SETEDITSEL: case CB_SETEDITSEL:
printf("ComboBox CB_SETEDITSEL lParam=%lX !\n", lParam); printf("ComboBox CB_SETEDITSEL lParam=%lX !\n", lParam);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
/* return(SendMessage(lphc->hWndEdit, EM_SETSEL, 0, lParam)); */ /* return(SendMessage(lphc->hWndEdit, EM_SETSEL, 0, lParam)); */
break; break;
case CB_SELECTSTRING: case CB_SELECTSTRING:
printf("ComboBox CB_SELECTSTRING !\n"); printf("ComboBox CB_SELECTSTRING !\n");
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
break; break;
case CB_SHOWDROPDOWN: case CB_SHOWDROPDOWN:
printf("ComboBox CB_SHOWDROPDOWN !\n"); printf("ComboBox CB_SHOWDROPDOWN !\n");
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
lphc->dwState = lphc->dwState | CB_SHOWDROPDOWN; lphc->dwState = lphc->dwState | CB_SHOWDROPDOWN;
if (wParam != 0) { if (wParam != 0) {
ShowWindow(lphc->hWndLBox, SW_SHOW); ShowWindow(lphc->hWndLBox, SW_SHOW);
} }
else { else {
lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN; lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
ShowWindow(lphc->hWndLBox, SW_HIDE); ShowWindow(lphc->hWndLBox, SW_HIDE);
SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu, SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
MAKELONG(hwnd, CBN_DROPDOWN)); MAKELONG(hwnd, CBN_DROPDOWN));
} }
break; break;
case CB_GETITEMDATA: case CB_GETITEMDATA:
printf("ComboBox CB_GETITEMDATA wParam=%X !\n", wParam); printf("ComboBox CB_GETITEMDATA wParam=%X !\n", wParam);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETITEMDATA, wParam, 0L)); return(SendMessage(lphc->hWndLBox, LB_GETITEMDATA, wParam, 0L));
break; break;
case CB_SETITEMDATA: case CB_SETITEMDATA:
printf("ComboBox CB_SETITEMDATA wParam=%X lParam=%lX !\n", wParam, lParam); printf("ComboBox CB_SETITEMDATA wParam=%X lParam=%lX !\n", wParam, lParam);
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam)); return(SendMessage(lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam));
break; break;
case CB_LIMITTEXT: case CB_LIMITTEXT:
printf("ComboBox CB_LIMITTEXT !\n"); printf("ComboBox CB_LIMITTEXT !\n");
lphc = ComboGetStorageHeader(hwnd); lphc = ComboGetStorageHeader(hwnd);
/* return(SendMessage(lphc->hWndEdit, EM_LIMITTEXT, wParam, 0L)); */ /* return(SendMessage(lphc->hWndEdit, EM_LIMITTEXT, wParam, 0L)); */
break; break;
default: default:
return DefWindowProc( hwnd, message, wParam, lParam ); return DefWindowProc( hwnd, message, wParam, lParam );
} }
return 0; return 0;
} }

View File

@ -6,16 +6,108 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1994"; static char Copyright[] = "Copyright Alexandre Julliard, 1994";
#include "windows.h" #include <stdio.h>
#include <string.h>
#include "win.h"
#include "desktop.h"
/***********************************************************************
* DESKTOP_DoEraseBkgnd
*
* Handle the WM_ERASEBKGND message.
*/
static LONG DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc, DESKTOPINFO *infoPtr )
{
RECT rect;
/* Set colors in case pattern is a monochrome bitmap */
SetBkColor( hdc, RGB(0,0,0) );
SetTextColor( hdc, GetSysColor(COLOR_BACKGROUND) );
GetClientRect( hwnd, &rect );
FillRect( hdc, &rect, infoPtr->hbrushPattern );
return 1;
}
/***********************************************************************
* DesktopWndProc
*
* Window procedure for the desktop window.
*/
LONG DesktopWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam ) LONG DesktopWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam )
{ {
WND *wndPtr = WIN_FindWndPtr( hwnd );
DESKTOPINFO *infoPtr = (DESKTOPINFO *)wndPtr->wExtra;
/* Most messages are ignored (we DON'T call DefWindowProc) */ /* Most messages are ignored (we DON'T call DefWindowProc) */
switch(message) switch(message)
{ {
/* Warning: this message is sent directly by */
/* WIN_CreateDesktopWindow() and does not contain a valid lParam */
case WM_NCCREATE:
infoPtr->hbrushPattern = 0;
infoPtr->hbitmapWallPaper = 0;
SetDeskPattern();
break;
case WM_ERASEBKGND:
if (rootWindow == DefaultRootWindow(display)) return 1;
return DESKTOP_DoEraseBkgnd( hwnd, (HDC)wParam, infoPtr );
} }
return 0; return 0;
} }
/***********************************************************************
* SetDeskPattern (USER.279)
*/
BOOL SetDeskPattern()
{
char buffer[100];
GetProfileString( "desktop", "Pattern", "(None)", buffer, 100 );
return DESKTOP_SetPattern( buffer );
}
/***********************************************************************
* SetDeskWallPaper (USER.285)
*/
BOOL SetDeskWallPaper( LPSTR filename )
{
return TRUE;
}
/***********************************************************************
* DESKTOP_SetPattern
*
* Set the desktop pattern.
*/
BOOL DESKTOP_SetPattern(char *pattern )
{
WND *wndPtr = WIN_FindWndPtr( GetDesktopWindow() );
DESKTOPINFO *infoPtr = (DESKTOPINFO *)wndPtr->wExtra;
int pat[8];
if (infoPtr->hbrushPattern) DeleteObject( infoPtr->hbrushPattern );
memset( pat, 0, sizeof(pat) );
if (pattern && sscanf( pattern, " %d %d %d %d %d %d %d %d",
&pat[0], &pat[1], &pat[2], &pat[3],
&pat[4], &pat[5], &pat[6], &pat[7] ))
{
WORD pattern[8];
HBITMAP hbitmap;
int i;
for (i = 0; i < 8; i++) pattern[i] = pat[i] & 0xffff;
hbitmap = CreateBitmap( 8, 8, 1, 1, pattern );
infoPtr->hbrushPattern = CreatePatternBrush( hbitmap );
DeleteObject( hbitmap );
}
else infoPtr->hbrushPattern = CreateSolidBrush( GetSysColor(COLOR_BACKGROUND) );
return TRUE;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -10,14 +10,16 @@
*/ */
static char Copyright[] = "Copyright Martin Ayotte, 1993"; static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "windows.h" #include "windows.h"
#include "sysmetrics.h" #include "sysmetrics.h"
#include "scroll.h" #include "scroll.h"
#include "heap.h" #include "heap.h"
#include "win.h" #include "win.h"
#include <sys/types.h> #include "prototypes.h"
#include <dirent.h>
#include <sys/stat.h>
HBITMAP hUpArrow = 0; HBITMAP hUpArrow = 0;
HBITMAP hDnArrow = 0; HBITMAP hDnArrow = 0;
@ -142,174 +144,212 @@ return(0);
void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y) void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y)
{ {
LPHEADSCROLL lphs; LPHEADSCROLL lphs;
HWND hWndParent; HWND hWndParent;
RECT rect, rect2; RECT rect, rect2;
int width, height; int width, height;
LONG dwOwner; LONG dwOwner;
lphs = GetScrollObjectStruct(hWnd, nBar); lphs = GetScrollObjectStruct(hWnd, nBar);
if (nBar == SB_CTL) {
hWndParent = GetParent(hWnd);
dwOwner = MAKELONG(0, lphs->hWndOwner);
#ifdef DEBUG_SCROLL #ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown // x=%d y=%d\n", x, y); printf("ScrollBarButtonDown SB_CTL // x=%d y=%d\n", x, y);
#endif #endif
if (nBar == SB_CTL) { }
hWndParent = GetParent(hWnd); else {
dwOwner = MAKELONG(0, lphs->hWndOwner); hWndParent = hWnd;
} dwOwner = 0L;
else { #ifdef DEBUG_SCROLL
hWndParent = hWnd; printf("ScrollBarButtonDown SB_?SCROLL // x=%d y=%d\n", x, y);
dwOwner = 0L; #endif
} }
/* /*
SetFocus(lphs->hWndOwner); SetFocus(lphs->hWndOwner);
*/ */
CopyRect(&rect, &lphs->rect); CopyRect(&rect, &lphs->rect);
#ifdef DEBUG_SCROLL #ifdef DEBUG_SCROLL
printf("ScrollDown / x=%d y=%d left=%d top=%d right=%d bottom=%d \n", 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); x, y, rect.left, rect.top, rect.right, rect.bottom);
#endif #endif
if (lphs->Direction == WM_VSCROLL) { if (lphs->Direction == WM_VSCROLL) {
width = rect.right - rect.left; width = rect.right - rect.left;
if (y < (lphs->CurPix + width)) { if (y < (lphs->CurPix + width)) {
if (y < width) { if (y < width) {
lphs->ButtonDown = 1; lphs->ButtonDown = 1;
CopyRect(&rect2, &rect); CopyRect(&rect2, &rect);
rect2.bottom = rect2.top + width; rect2.bottom = rect2.top + width;
InvalidateRect(lphs->hWndOwner, &rect2, TRUE); InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
SendMessage(hWndParent, lphs->Direction,
SB_LINEUP, dwOwner);
}
else {
lphs->ButtonDown = 5;
SendMessage(hWndParent, lphs->Direction,
SB_PAGEUP, dwOwner);
}
}
if (y > (lphs->CurPix + (width << 1))) {
if (y > (rect.bottom - rect.top - width)) {
lphs->ButtonDown = 2;
CopyRect(&rect2, &rect);
rect2.top = rect2.bottom - width;
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
SendMessage(hWndParent, lphs->Direction,
SB_LINEDOWN, dwOwner);
}
else {
lphs->ButtonDown = 6;
SendMessage(hWndParent, lphs->Direction,
SB_PAGEDOWN, dwOwner);
}
}
if ((y > (lphs->CurPix + width)) &&
(y < (lphs->CurPix + (width << 1)))) {
lphs->ThumbActive = TRUE;
#ifdef DEBUG_SCROLL #ifdef DEBUG_SCROLL
printf("THUMB DOWN !\n"); printf("ScrollBarButtonDown send SB_LINEUP\n");
#endif #endif
} SendMessage(hWndParent, lphs->Direction,
} SB_LINEUP, dwOwner);
else { }
height = rect.bottom - rect.top; else {
if (x < (lphs->CurPix + height)) { lphs->ButtonDown = 5;
if (x < height) {
lphs->ButtonDown = 3;
CopyRect(&rect2, &rect);
rect2.right = rect2.left + height;
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
SendMessage(hWndParent, lphs->Direction,
SB_LINEUP, dwOwner);
}
else {
lphs->ButtonDown = 5;
SendMessage(hWndParent, lphs->Direction,
SB_PAGEUP, dwOwner);
}
}
if (x > (lphs->CurPix + (height << 1))) {
if (x > (rect.right - rect.left - height)) {
lphs->ButtonDown = 4;
CopyRect(&rect2, &rect);
rect2.left = rect2.right - height;
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
SendMessage(hWndParent, lphs->Direction,
SB_LINEDOWN, dwOwner);
}
else {
lphs->ButtonDown = 6;
SendMessage(hWndParent, lphs->Direction,
SB_PAGEDOWN, dwOwner);
}
}
if ((x > (lphs->CurPix + height)) &&
(x < (lphs->CurPix + (height << 1)))) {
lphs->ThumbActive = TRUE;
#ifdef DEBUG_SCROLL #ifdef DEBUG_SCROLL
printf("THUMB DOWN !\n"); printf("ScrollBarButtonDown send SB_PAGEUP\n");
#endif #endif
} SendMessage(hWndParent, lphs->Direction,
} SB_PAGEUP, dwOwner);
if (lphs->ButtonDown != 0) { }
UpdateWindow(lphs->hWndOwner); }
if (!lphs->TimerPending && nBar == SB_CTL) { if (y > (lphs->CurPix + (width << 1))) {
lphs->TimerPending = TRUE; if (y > (rect.bottom - rect.top - width)) {
SetTimer(lphs->hWndOwner, 1, 500, NULL); lphs->ButtonDown = 2;
} CopyRect(&rect2, &rect);
} rect2.top = rect2.bottom - width;
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_LINEDOWN\n");
#endif
SendMessage(hWndParent, lphs->Direction,
SB_LINEDOWN, dwOwner);
}
else {
lphs->ButtonDown = 6;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_PAGEDOWN\n");
#endif
SendMessage(hWndParent, lphs->Direction,
SB_PAGEDOWN, dwOwner);
}
}
if ((y > (lphs->CurPix + width)) &&
(y < (lphs->CurPix + (width << 1)))) {
lphs->ThumbActive = TRUE;
#ifdef DEBUG_SCROLL
printf("THUMB DOWN !\n");
#endif
}
}
else {
height = rect.bottom - rect.top;
if (x < (lphs->CurPix + height)) {
if (x < height) {
lphs->ButtonDown = 3;
CopyRect(&rect2, &rect);
rect2.right = rect2.left + height;
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_LINEUP\n");
#endif
SendMessage(hWndParent, lphs->Direction,
SB_LINEUP, dwOwner);
}
else {
lphs->ButtonDown = 5;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_PAGEUP\n");
#endif
SendMessage(hWndParent, lphs->Direction,
SB_PAGEUP, dwOwner);
}
}
if (x > (lphs->CurPix + (height << 1))) {
if (x > (rect.right - rect.left - height)) {
lphs->ButtonDown = 4;
CopyRect(&rect2, &rect);
rect2.left = rect2.right - height;
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_LINEDOWN\n");
#endif
SendMessage(hWndParent, lphs->Direction,
SB_LINEDOWN, dwOwner);
}
else {
lphs->ButtonDown = 6;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_PAGEDOWN\n");
#endif
SendMessage(hWndParent, lphs->Direction,
SB_PAGEDOWN, dwOwner);
}
}
if ((x > (lphs->CurPix + height)) &&
(x < (lphs->CurPix + (height << 1)))) {
lphs->ThumbActive = TRUE;
#ifdef DEBUG_SCROLL
printf("THUMB DOWN !\n");
#endif
}
}
if (lphs->ButtonDown != 0) {
UpdateWindow(lphs->hWndOwner);
if (!lphs->TimerPending && nBar == SB_CTL) {
lphs->TimerPending = TRUE;
SetTimer(lphs->hWndOwner, 1, 500, NULL);
}
}
} }
void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y) void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y)
{ {
LPHEADSCROLL lphs; LPHEADSCROLL lphs;
RECT rect, rect2; RECT rect, rect2;
HDC hDC;
#ifdef DEBUG_SCROLL #ifdef DEBUG_SCROLL
printf("ScrollBarButtonUp // x=%d y=%d\n", x, y); printf("ScrollBarButtonUp // x=%d y=%d\n", x, y);
#endif #endif
lphs = GetScrollObjectStruct(hWnd, nBar); lphs = GetScrollObjectStruct(hWnd, nBar);
lphs->ThumbActive = FALSE; lphs->ThumbActive = FALSE;
if (lphs->ButtonDown != 0) { if (lphs->ButtonDown != 0) {
lphs->ButtonDown = 0; lphs->ButtonDown = 0;
GetClientRect(lphs->hWndOwner, &rect); GetClientRect(lphs->hWndOwner, &rect);
InvalidateRect(lphs->hWndOwner, &rect, TRUE); if (nBar == SB_CTL) {
UpdateWindow(lphs->hWndOwner); InvalidateRect(lphs->hWndOwner, &rect, TRUE);
} UpdateWindow(lphs->hWndOwner);
}
else {
hDC = GetWindowDC(lphs->hWndOwner);
StdDrawScrollBar(lphs->hWndOwner, hDC, nBar, &lphs->rect, lphs);
ReleaseDC(lphs->hWndOwner, hDC);
}
}
} }
void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y) void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y)
{ {
LPHEADSCROLL lphs; LPHEADSCROLL lphs;
HWND hWndParent; HWND hWndParent;
HWND hWndOwner; HWND hWndOwner;
LONG dwOwner; LONG dwOwner;
if ((wParam & MK_LBUTTON) == 0) return; if ((wParam & MK_LBUTTON) == 0) return;
lphs = GetScrollObjectStruct(hWnd, nBar);
if (lphs->ThumbActive == 0) return;
if (nBar == SB_CTL) {
hWndParent = GetParent(hWnd);
hWndOwner = lphs->hWndOwner;
#ifdef DEBUG_SCROLL #ifdef DEBUG_SCROLL
printf("ScrollBarButtonMove // w=%04X x=%d y=%d \n", wParam, x, y); printf("ScrollBarButtonMove SB_CTL // x=%d y=%d\n", x, y);
#endif #endif
lphs = GetScrollObjectStruct(hWnd, nBar); }
if (lphs->ThumbActive == 0) return; else {
if (nBar == SB_CTL) { hWndParent = hWnd;
hWndParent = GetParent(hWnd); hWndOwner = 0;
hWndOwner = lphs->hWndOwner;
}
else {
hWndParent = hWnd;
hWndOwner = 0;
}
if (lphs->Direction == WM_VSCROLL) {
int butsiz = lphs->rect.right - lphs->rect.left;
y = y - butsiz - (butsiz >> 1);
}
else {
int butsiz = lphs->rect.bottom - lphs->rect.top;
y = x - butsiz - (butsiz >> 1);
}
x = (y * (lphs->MaxVal - lphs->MinVal) /
lphs->MaxPix) + lphs->MinVal;
#ifdef DEBUG_SCROLL #ifdef DEBUG_SCROLL
printf("Scroll WM_MOUSEMOVE val=%d pix=%d\n", x, y); printf("ScrollBarButtonMove SB_?SCROLL // x=%d y=%d\n", x, y);
#endif #endif
SendMessage(hWndParent, lphs->Direction, }
SB_THUMBTRACK, MAKELONG(x, hWndOwner)); if (lphs->Direction == WM_VSCROLL) {
int butsiz = lphs->rect.right - lphs->rect.left;
y = y - butsiz - (butsiz >> 1);
}
else {
int butsiz = lphs->rect.bottom - lphs->rect.top;
y = x - butsiz - (butsiz >> 1);
}
x = (y * (lphs->MaxVal - lphs->MinVal) /
lphs->MaxPix) + lphs->MinVal;
#ifdef DEBUG_SCROLL
printf("Scroll WM_MOUSEMOVE val=%d pix=%d\n", x, y);
#endif
SendMessage(hWndParent, lphs->Direction,
SB_THUMBTRACK, MAKELONG(x, hWndOwner));
} }
@ -341,6 +381,7 @@ LPHEADSCROLL ScrollBarGetStorageHeader(HWND hWnd)
} }
void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL lphs) void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL lphs)
{ {
HWND hWndParent; HWND hWndParent;
@ -385,19 +426,15 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL
SelectObject(hMemDC, hUpArrowD); SelectObject(hMemDC, hUpArrowD);
else else
SelectObject(hMemDC, hUpArrow); SelectObject(hMemDC, hUpArrow);
BitBlt(hDC, rect.left, rect.top, StretchBlt(hDC, rect.left, rect.top, w, w, hMemDC,
bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
/*
StretchBlt(hDC, 0, 0, lpdis->rcItem.right, lpdis->rcItem.right,
hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
*/
GetObject(hDnArrow, sizeof(BITMAP), (LPSTR)&bm); GetObject(hDnArrow, sizeof(BITMAP), (LPSTR)&bm);
if (lphs->ButtonDown == 2) if (lphs->ButtonDown == 2)
SelectObject(hMemDC, hDnArrowD); SelectObject(hMemDC, hDnArrowD);
else else
SelectObject(hMemDC, hDnArrow); SelectObject(hMemDC, hDnArrow);
BitBlt(hDC, rect.left, rect.bottom - bm.bmHeight, StretchBlt(hDC, rect.left, rect.bottom - w, w, w, hMemDC,
bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
rect.top += w; rect.top += w;
rect.bottom -= w; rect.bottom -= w;
} }
@ -407,15 +444,15 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL
SelectObject(hMemDC, hLfArrowD); SelectObject(hMemDC, hLfArrowD);
else else
SelectObject(hMemDC, hLfArrow); SelectObject(hMemDC, hLfArrow);
BitBlt(hDC, rect.left, rect.top, StretchBlt(hDC, rect.left, rect.top, h, h, hMemDC,
bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
GetObject(hRgArrow, sizeof(BITMAP), (LPSTR)&bm); GetObject(hRgArrow, sizeof(BITMAP), (LPSTR)&bm);
if (lphs->ButtonDown == 4) if (lphs->ButtonDown == 4)
SelectObject(hMemDC, hRgArrowD); SelectObject(hMemDC, hRgArrowD);
else else
SelectObject(hMemDC, hRgArrow); SelectObject(hMemDC, hRgArrow);
BitBlt(hDC, rect.right - bm.bmWidth, rect.top, StretchBlt(hDC, rect.right - h, rect.top, h, h, hMemDC,
bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
rect.left += h; rect.left += h;
rect.right -= h; rect.right -= h;
} }
@ -549,7 +586,6 @@ void NC_CreateScrollBars(HWND hWnd)
LPHEADSCROLL GetScrollObjectStruct(HWND hWnd, int nBar) LPHEADSCROLL GetScrollObjectStruct(HWND hWnd, int nBar)
{ {
WND *wndPtr; WND *wndPtr;
LPHEADSCROLL lphs;
if (nBar != SB_CTL) { if (nBar != SB_CTL) {
wndPtr = WIN_FindWndPtr(hWnd); wndPtr = WIN_FindWndPtr(hWnd);
if (nBar == SB_VERT) return (LPHEADSCROLL)wndPtr->VScroll; if (nBar == SB_VERT) return (LPHEADSCROLL)wndPtr->VScroll;
@ -565,13 +601,14 @@ LPHEADSCROLL GetScrollObjectStruct(HWND hWnd, int nBar)
*/ */
int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw) int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw)
{ {
int nRet; LPHEADSCROLL lphs;
LPHEADSCROLL lphs; HDC hDC;
lphs = GetScrollObjectStruct(hWnd, nBar); int nRet;
if (lphs == NULL) return 0; lphs = GetScrollObjectStruct(hWnd, nBar);
nRet = lphs->CurVal; if (lphs == NULL) return 0;
lphs->CurVal = (short)nPos; nRet = lphs->CurVal;
if (lphs->MaxVal != lphs->MinVal) lphs->CurVal = (short)nPos;
if (lphs->MaxVal != lphs->MinVal)
lphs->CurPix = lphs->MaxPix * (abs((short)nPos) - abs(lphs->MinVal)) / lphs->CurPix = lphs->MaxPix * (abs((short)nPos) - abs(lphs->MinVal)) /
(abs(lphs->MaxVal) - abs(lphs->MinVal)); (abs(lphs->MaxVal) - abs(lphs->MinVal));
if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix; if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
@ -582,8 +619,17 @@ int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw)
lphs->MinVal, lphs->MaxVal); lphs->MinVal, lphs->MaxVal);
#endif #endif
if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) { if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) {
InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE); if (nBar == SB_CTL) {
UpdateWindow(lphs->hWndOwner); InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE);
UpdateWindow(lphs->hWndOwner);
}
else {
if (lphs->rect.right != 0 && lphs->rect.bottom != 0) {
hDC = GetWindowDC(lphs->hWndOwner);
StdDrawScrollBar(lphs->hWndOwner, hDC, nBar, &lphs->rect, lphs);
ReleaseDC(lphs->hWndOwner, hDC);
}
}
} }
return nRet; return nRet;
} }
@ -609,6 +655,7 @@ int GetScrollPos(HWND hWnd, int nBar)
void SetScrollRange(HWND hWnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw) void SetScrollRange(HWND hWnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw)
{ {
LPHEADSCROLL lphs; LPHEADSCROLL lphs;
HDC hDC;
lphs = GetScrollObjectStruct(hWnd, nBar); lphs = GetScrollObjectStruct(hWnd, nBar);
if (lphs == NULL) return; if (lphs == NULL) return;
lphs->MinVal = (short)MinPos; lphs->MinVal = (short)MinPos;
@ -622,8 +669,17 @@ void SetScrollRange(HWND hWnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw)
printf("SetScrollRange min=%d max=%d\n", lphs->MinVal, lphs->MaxVal); printf("SetScrollRange min=%d max=%d\n", lphs->MinVal, lphs->MaxVal);
#endif #endif
if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) { if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) {
InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE); if (nBar == SB_CTL) {
UpdateWindow(lphs->hWndOwner); InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE);
UpdateWindow(lphs->hWndOwner);
}
else {
if (lphs->rect.right != 0 && lphs->rect.bottom != 0) {
hDC = GetWindowDC(lphs->hWndOwner);
StdDrawScrollBar(lphs->hWndOwner, hDC, nBar, &lphs->rect, lphs);
ReleaseDC(lphs->hWndOwner, hDC);
}
}
} }
} }

View File

@ -7,6 +7,7 @@
static char Copyright[] = "Copyright David W. Metcalfe, 1993"; static char Copyright[] = "Copyright David W. Metcalfe, 1993";
#include <stdio.h>
#include <windows.h> #include <windows.h>
#include "win.h" #include "win.h"
#include "user.h" #include "user.h"

View File

@ -7,7 +7,9 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1993"; static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "win.h" #include "win.h"
#include "desktop.h"
#include "mdi.h"
#include "gdi.h"
LONG ButtonWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ); LONG ButtonWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam );
LONG StaticWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ); LONG StaticWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam );
@ -16,6 +18,7 @@ LONG ListBoxWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam );
LONG ComboBoxWndProc ( 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 PopupMenuWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam );
LONG DesktopWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam ); LONG DesktopWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam );
LONG MDIClientWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam );
static WNDCLASS WIDGETS_BuiltinClasses[] = static WNDCLASS WIDGETS_BuiltinClasses[] =
@ -32,10 +35,12 @@ static WNDCLASS WIDGETS_BuiltinClasses[] =
0, 0, 0, 0, NULL, "COMBOBOX" }, 0, 0, 0, 0, NULL, "COMBOBOX" },
{ CS_GLOBALCLASS, (LONG(*)())PopupMenuWndProc, 0, 8, { CS_GLOBALCLASS, (LONG(*)())PopupMenuWndProc, 0, 8,
0, 0, 0, 0, NULL, "POPUPMENU" }, 0, 0, 0, 0, NULL, "POPUPMENU" },
{ CS_GLOBALCLASS, (LONG(*)())DesktopWndProc, 0, 0, { CS_GLOBALCLASS, (LONG(*)())DesktopWndProc, 0, sizeof(DESKTOPINFO),
0, 0, 0, 0, NULL, DESKTOP_CLASS_NAME }, 0, 0, 0, 0, NULL, DESKTOP_CLASS_NAME },
{ CS_GLOBALCLASS, (LONG(*)())DefDlgProc, 0, DLGWINDOWEXTRA, { CS_GLOBALCLASS, (LONG(*)())DefDlgProc, 0, DLGWINDOWEXTRA,
0, 0, 0, 0, NULL, DIALOG_CLASS_NAME } 0, 0, 0, 0, NULL, DIALOG_CLASS_NAME },
{ CS_GLOBALCLASS, (LONG(*)())MDIClientWndProc, 0, sizeof(MDICLIENTINFO),
0, 0, 0, STOCK_LTGRAY_BRUSH, NULL, "MDICLIENT" }
}; };
#define NB_BUILTIN_CLASSES \ #define NB_BUILTIN_CLASSES \
@ -47,7 +52,7 @@ static WNDCLASS WIDGETS_BuiltinClasses[] =
* *
* Initialize the built-in window classes. * Initialize the built-in window classes.
*/ */
BOOL WIDGETS_Init() BOOL WIDGETS_Init(void)
{ {
int i; int i;
for (i = 0; i < NB_BUILTIN_CLASSES; i++) for (i = 0; i < NB_BUILTIN_CLASSES; i++)

View File

@ -8,15 +8,25 @@ SRCS = \
callback.c \ callback.c \
relay.c relay.c
/* DLLOBJS = \
* Hack alert. There appear to be no object files, 'cause a very dll_gdi.o \
* nasty rule below links *.o together, which is a generally bad idea, dll_kernel.o \
* but I can't see how else to do it. dll_keyboard.o \
*/ dll_shell.o \
OBJS = \ dll_sound.o \
call.o \ dll_stress.o \
callback.o \ dll_unixlib.o \
relay.o dll_user.o \
dll_win87em.o \
dll_winsock.o
OBJS1= $(SRCS:.S=.o)
#ifndef NewBuild
OBJS = $(DLLOBJS) $(OBJS1:.c=.o) $(DLLOBJS:.o=_tab.o)
#else
OBJS = $(DLLOBJS) $(OBJS1:.c=.o) $(DLLOBJS:.o=_tab.o) $(DLLOBJS:dll_.rly_)
#endif
/* /*
* If you add a new spec file, copy one of these lines * If you add a new spec file, copy one of these lines
@ -26,21 +36,19 @@ MakeDllFromSpec(kernel,$(TOP)/$(MODULE))
MakeDllFromSpec(keyboard,$(TOP)/$(MODULE)) MakeDllFromSpec(keyboard,$(TOP)/$(MODULE))
MakeDllFromSpec(shell,$(TOP)/$(MODULE)) MakeDllFromSpec(shell,$(TOP)/$(MODULE))
MakeDllFromSpec(sound,$(TOP)/$(MODULE)) MakeDllFromSpec(sound,$(TOP)/$(MODULE))
MakeDllFromSpec(stress,$(TOP)/$(MODULE))
MakeDllFromSpec(unixlib,$(TOP)/$(MODULE)) MakeDllFromSpec(unixlib,$(TOP)/$(MODULE))
MakeDllFromSpec(user,$(TOP)/$(MODULE)) MakeDllFromSpec(user,$(TOP)/$(MODULE))
MakeDllFromSpec(win87em,$(TOP)/$(MODULE)) MakeDllFromSpec(win87em,$(TOP)/$(MODULE))
MakeDllFromSpec(winsock,$(TOP)/$(MODULE)) MakeDllFromSpec(winsock,$(TOP)/$(MODULE))
/* WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
* Yes I know *.o is not very clever, but can you do it cleaner ? DependTarget()
*/ CleanTarget()
WineRelocatableTarget($(TOP)/$(MODULE),*.o,)
$(TOP)/$(MODULE).o: $(OBJS) includes::
install::
clean:: clean::
$(RM) dll* dtb* $(RM) dll* dtb*
depend::
includes::

View File

@ -105,7 +105,7 @@ _CallToInit16:
movw $UDATASEL,%ax movw $UDATASEL,%ax
movw %ax,%fs movw %ax,%fs
movw %ax,%gs movw %ax,%gs
movw %ds,%ax /* movw %ds,%ax */
/* /*
* Call entry point * Call entry point

View File

@ -126,6 +126,8 @@ length 490
148 pascal SetBrushOrg(word s_word s_word) SetBrushOrg(1 2 3) 148 pascal SetBrushOrg(word s_word s_word) SetBrushOrg(1 2 3)
149 pascal GetBrushOrg(word) GetBrushOrg(1) 149 pascal GetBrushOrg(word) GetBrushOrg(1)
150 pascal UnrealizeObject(word) UnrealizeObject(1) 150 pascal UnrealizeObject(word) UnrealizeObject(1)
153 pascal CreateIC(ptr ptr ptr ptr) CreateIC(1 2 3 4)
154 pascal GetNearestColor(word long) GetNearestColor(1 2)
161 pascal PtInRegion(word s_word s_word) PtInRegion(1 2 3) 161 pascal PtInRegion(word s_word s_word) PtInRegion(1 2 3)
162 pascal GetBitmapDimension(word) GetBitmapDimension(1) 162 pascal GetBitmapDimension(word) GetBitmapDimension(1)
163 pascal SetBitmapDimension(word s_word s_word) SetBitmapDimension(1 2 3) 163 pascal SetBitmapDimension(word s_word s_word) SetBitmapDimension(1 2 3)
@ -134,6 +136,7 @@ length 490
179 pascal GetDCState(word) GetDCState(1) 179 pascal GetDCState(word) GetDCState(1)
180 pascal SetDCState(word word) SetDCState(1 2) 180 pascal SetDCState(word word) SetDCState(1 2)
181 pascal RectInRegionOld(word ptr) RectInRegion(1 2) 181 pascal RectInRegionOld(word ptr) RectInRegion(1 2)
250 pascal Copy(ptr ptr word) Copy(1 2 3)
345 pascal GetTextAlign(word) GetTextAlign(1) 345 pascal GetTextAlign(word) GetTextAlign(1)
346 pascal SetTextAlign(word word) SetTextAlign(1 2) 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) 348 pascal Chord(word s_word s_word s_word s_word s_word s_word s_word s_word)
@ -141,14 +144,21 @@ length 490
349 pascal SetMapperFlags(word word) SetMapperFlags(1 2) 349 pascal SetMapperFlags(word word) SetMapperFlags(1 2)
350 pascal GetCharWidth(word word word ptr) GetCharWidth(1 2 3 4) 350 pascal GetCharWidth(word word word ptr) GetCharWidth(1 2 3 4)
360 pascal CreatePalette(ptr) CreatePalette(1) 360 pascal CreatePalette(ptr) CreatePalette(1)
361 pascal GDISelectPalette(word word) GDISelectPalette(1 2)
362 pascal GDIRealizePalette(word) GDIRealizePalette(1)
363 pascal GetPaletteEntries(word word word ptr) GetPaletteEntries(1 2 3 4) 363 pascal GetPaletteEntries(word word word ptr) GetPaletteEntries(1 2 3 4)
364 pascal SetPaletteEntries(word word word ptr) SetPaletteEntries(1 2 3 4) 364 pascal SetPaletteEntries(word word word ptr) SetPaletteEntries(1 2 3 4)
365 pascal RealizeDefaultPalette(word) RealizeDefaultPalette(1)
370 pascal GetNearestPaletteIndex(word long) GetNearestPaletteIndex(1 2) 370 pascal GetNearestPaletteIndex(word long) GetNearestPaletteIndex(1 2)
375 pascal GetSystemPaletteEntries(word word word ptr)
GetSystemPaletteEntries(1 2 3 4)
411 pascal GetCurLogFont(word) GetCurLogFont(1) 411 pascal GetCurLogFont(word) GetCurLogFont(1)
440 pascal SetDIBits(word word word word ptr ptr word) SetDIBits(1 2 3 4 5 6 7) 440 pascal SetDIBits(word word word word ptr ptr word) SetDIBits(1 2 3 4 5 6 7)
441 pascal GetDIBits(word word word word ptr ptr word) GetDIBits(1 2 3 4 5 6 7) 441 pascal GetDIBits(word word word word ptr ptr word) GetDIBits(1 2 3 4 5 6 7)
442 pascal CreateDIBitmap(word ptr long ptr ptr word) 442 pascal CreateDIBitmap(word ptr long ptr ptr word)
CreateDIBitmap(1 2 3 4 5 6) CreateDIBitmap(1 2 3 4 5 6)
443 pascal SetDIBitsToDevice(word s_word s_word word word word word word word ptr ptr word)
SetDIBitsToDevice(1 2 3 4 5 6 7 8 9 10 11 12)
444 pascal CreateRoundRectRgn(s_word s_word s_word s_word s_word s_word) 444 pascal CreateRoundRectRgn(s_word s_word s_word s_word s_word s_word)
CreateRoundRectRgn(1 2 3 4 5 6) CreateRoundRectRgn(1 2 3 4 5 6)
445 pascal CreateDIBPatternBrush(word word) CreateDIBPatternBrush(1 2) 445 pascal CreateDIBPatternBrush(word word) CreateDIBPatternBrush(1 2)

View File

@ -6,16 +6,16 @@ length 415
3 pascal GetVersion() GetVersion() 3 pascal GetVersion() GetVersion()
#return GetVersion 0 0x301 #return GetVersion 0 0x301
4 pascal LocalInit(word word word) LocalInit(1 2 3) 4 pascal LocalInit(word word word) WIN16_LocalInit(1 2 3)
5 pascal LocalAlloc(word word) LocalAlloc(1 2) 5 pascal LocalAlloc(word word) WIN16_LocalAlloc(1 2)
6 pascal LocalReAlloc(word word word) LocalReAlloc(1 2 3) 6 pascal LocalReAlloc(word word word) WIN16_LocalReAlloc(1 2 3)
7 pascal LocalFree(word) LocalFree(1) 7 pascal LocalFree(word) WIN16_LocalFree(1)
8 pascal LocalLock(word) LocalLock(1) 8 pascal LocalLock(word) WIN16_LocalLock(1)
9 pascal LocalUnlock(word) LocalUnlock(1) 9 pascal LocalUnlock(word) WIN16_LocalUnlock(1)
10 pascal LocalSize(word) LocalSize(1) 10 pascal LocalSize(word) WIN16_LocalSize(1)
11 pascal LocalHandle(word) ReturnArg(1) 11 pascal LocalHandle(word) ReturnArg(1)
12 pascal LocalFlags(word) LocalFlags(1) 12 pascal LocalFlags(word) WIN16_LocalFlags(1)
13 pascal LocalCompact(word) LocalCompact(1) 13 pascal LocalCompact(word) WIN16_LocalCompact(1)
14 return LocalNotify 4 0 14 return LocalNotify 4 0
15 pascal GlobalAlloc(word long) GlobalAlloc(1 2) 15 pascal GlobalAlloc(word long) GlobalAlloc(1 2)
16 pascal GlobalReAlloc(word long word) GlobalReAlloc(1 2 3) 16 pascal GlobalReAlloc(word long word) GlobalReAlloc(1 2 3)
@ -89,6 +89,7 @@ length 415
163 pascal GlobalLRUOldest(word) ReturnArg(1) 163 pascal GlobalLRUOldest(word) ReturnArg(1)
164 pascal GlobalLRUNewest(word) ReturnArg(1) 164 pascal GlobalLRUNewest(word) ReturnArg(1)
166 pascal WinExec(ptr word) WinExec(1 2) 166 pascal WinExec(ptr word) WinExec(1 2)
169 pascal GetFreeSpace(word) GetFreeSpace(1)
170 pascal AllocCStoDSAlias(word) AllocDStoCSAlias(1) 170 pascal AllocCStoDSAlias(word) AllocDStoCSAlias(1)
171 pascal AllocDStoCSAlias(word) AllocDStoCSAlias(1) 171 pascal AllocDStoCSAlias(word) AllocDStoCSAlias(1)
175 pascal AllocSelector(word) AllocSelector(1) 175 pascal AllocSelector(word) AllocSelector(1)

View File

@ -3,6 +3,7 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
@ -14,6 +15,7 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <linux/segment.h> #include <linux/segment.h>
#endif #endif
#include <errno.h> #include <errno.h>
#include "neexe.h" #include "neexe.h"
#include "segmem.h" #include "segmem.h"
#include "prototypes.h" #include "prototypes.h"
@ -22,7 +24,7 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#define DEBUG_RELAY /* */ #define DEBUG_RELAY /* */
#define N_BUILTINS 9 #define N_BUILTINS 10
struct dll_name_table_entry_s dll_builtin_table[N_BUILTINS] = struct dll_name_table_entry_s dll_builtin_table[N_BUILTINS] =
{ {
@ -35,6 +37,7 @@ struct dll_name_table_entry_s dll_builtin_table[N_BUILTINS] =
{ "SOUND", SOUND_table, 20, 7 }, { "SOUND", SOUND_table, 20, 7 },
{ "KEYBOARD",KEYBOARD_table,137, 8 }, { "KEYBOARD",KEYBOARD_table,137, 8 },
{ "WINSOCK", WINSOCK_table, 155, 9 }, { "WINSOCK", WINSOCK_table, 155, 9 },
{ "STRESS", STRESS_table, 15,10 },
}; };
unsigned short *Stack16Frame; unsigned short *Stack16Frame;
@ -65,6 +68,7 @@ int
DLLRelay(unsigned int func_num, unsigned int seg_off) DLLRelay(unsigned int func_num, unsigned int seg_off)
{ {
struct dll_table_entry_s *dll_p; struct dll_table_entry_s *dll_p;
unsigned short *saved_Stack16Frame;
unsigned int segment; unsigned int segment;
unsigned int offset; unsigned int offset;
unsigned int dll_id; unsigned int dll_id;
@ -78,6 +82,7 @@ DLLRelay(unsigned int func_num, unsigned int seg_off)
/* /*
* Determine address of arguments. * Determine address of arguments.
*/ */
saved_Stack16Frame = Stack16Frame;
Stack16Frame = (unsigned short *) seg_off; Stack16Frame = (unsigned short *) seg_off;
arg_ptr = (void *) (seg_off + 0x18); arg_ptr = (void *) (seg_off + 0x18);
@ -138,7 +143,11 @@ DLLRelay(unsigned int func_num, unsigned int seg_off)
* if we choose. * if we choose.
*/ */
if (dll_p->n_args == 0) if (dll_p->n_args == 0)
return (*func_ptr)(arg_ptr); {
ret_val = (*func_ptr)(arg_ptr);
Stack16Frame = saved_Stack16Frame;
return ret_val;
}
/* /*
* Getting this far means we need to convert the 16-bit argument stack. * Getting this far means we need to convert the 16-bit argument stack.
@ -197,6 +206,7 @@ DLLRelay(unsigned int func_num, unsigned int seg_off)
} }
#endif #endif
Stack16Frame = saved_Stack16Frame;
return ret_val; return ret_val;
} }

18
if1632/stress.spec Normal file
View File

@ -0,0 +1,18 @@
# summary: resource modification dll
#
name stress
id 10
length 15
2 pascal allocmem(long) AllocMem(1)
3 pascal freeallmem() FreeAllMem()
6 pascal allocfilehandles(word) AllocFileHandles(1)
7 pascal unallocfilehandles() UnAllocFileHandles()
8 pascal getfreefilehandles() GetFreeFileHandles()
10 pascal allocdiskspace(long word) AllocDiskSpace(1 2)
11 pascal unallocdiskspace(word) UnAllocDiskSpace(1)
12 pascal allocusermem(word) AllocUserMem(1)
13 pascal freeallusermem() FreeAllUserMem()
14 pascal allocgdimem(word) AllocGDIMem(1)
15 pascal freeallgdimem() FreeAllGDIMem()

View File

@ -152,7 +152,7 @@ length 540
167 pascal ShowCaret(word) ShowCaret(1) 167 pascal ShowCaret(word) ShowCaret(1)
168 pascal SetCaretBlinkTime(word) SetCaretBlinkTime(1) 168 pascal SetCaretBlinkTime(word) SetCaretBlinkTime(1)
169 pascal GetCaretBlinkTime() GetCaretBlinkTime() 169 pascal GetCaretBlinkTime() GetCaretBlinkTime()
171 pascal WinHelp(word word long) WinHelp(1 2 3) 171 pascal WinHelp(word ptr word long) WinHelp(1 2 3 4)
173 pascal LoadCursor(word ptr) LoadCursor(1 2) 173 pascal LoadCursor(word ptr) LoadCursor(1 2)
174 pascal LoadIcon(word ptr) LoadIcon(1 2) 174 pascal LoadIcon(word ptr) LoadIcon(1 2)
175 pascal LoadBitmap(word ptr) LoadBitmap(1 2) 175 pascal LoadBitmap(word ptr) LoadBitmap(1 2)
@ -215,6 +215,7 @@ length 540
277 pascal GetDlgCtrlID(word) GetDlgCtrlID(1) 277 pascal GetDlgCtrlID(word) GetDlgCtrlID(1)
282 pascal SelectPalette(word word word) SelectPalette(1 2 3) 282 pascal SelectPalette(word word word) SelectPalette(1 2 3)
283 pascal RealizePalette(word) RealizePalette(1) 283 pascal RealizePalette(word) RealizePalette(1)
284 pascal GetFreeSystemResources(word) GetFreeSystemResources(1)
286 pascal GetDesktopWindow() GetDesktopWindow() 286 pascal GetDesktopWindow() GetDesktopWindow()
288 pascal GetMessageExtraInfo() GetMessageExtraInfo() 288 pascal GetMessageExtraInfo() GetMessageExtraInfo()
290 pascal RedrawWindow(word ptr word word) RedrawWindow(1 2 3 4) 290 pascal RedrawWindow(word ptr word word) RedrawWindow(1 2 3 4)
@ -235,6 +236,8 @@ length 540
404 pascal GetClassInfo(word ptr ptr) GetClassInfo(1 2 3) 404 pascal GetClassInfo(word ptr ptr) GetClassInfo(1 2 3)
406 pascal CreateCursor(word word word word word ptr ptr) 406 pascal CreateCursor(word word word word word ptr ptr)
CreateCursor(1 2 3 4 5 6 7) CreateCursor(1 2 3 4 5 6 7)
407 pascal CreateIcon(word word word byte byte ptr ptr)
CreateIcon(1 2 3 4 5 6 7)
410 pascal InsertMenu(word word word word ptr) InsertMenu(1 2 3 4 5) 410 pascal InsertMenu(word word word word ptr) InsertMenu(1 2 3 4 5)
411 pascal AppendMenu(word word word ptr) AppendMenu(1 2 3 4) 411 pascal AppendMenu(word word word ptr) AppendMenu(1 2 3 4)
412 pascal RemoveMenu(word word word) RemoveMenu(1 2 3) 412 pascal RemoveMenu(word word word) RemoveMenu(1 2 3)
@ -257,6 +260,9 @@ length 540
436 pascal IsCharLower(byte) IsCharLower(1) 436 pascal IsCharLower(byte) IsCharLower(1)
437 pascal AnsiUpperBuff(ptr word) AnsiUpperBuff(1 2) 437 pascal AnsiUpperBuff(ptr word) AnsiUpperBuff(1 2)
438 pascal AnsiLowerBuff(ptr word) AnsiLowerBuff(1 2) 438 pascal AnsiLowerBuff(ptr word) AnsiLowerBuff(1 2)
445 pascal DefFrameProc(word word word word long) DefFrameProc(1 2 3 4 5)
447 pascal DefMDIChildProc(word word word long) DefMDIChildProc(1 2 3 4)
451 pascal TranslateMDISysAccel(word ptr) TranslateMDISysAccel(1 2)
452 pascal CreateWindowEx(long ptr ptr long s_word s_word s_word s_word 452 pascal CreateWindowEx(long ptr ptr long s_word s_word s_word s_word
word word word ptr) word word word ptr)
CreateWindowEx(1 2 3 4 5 6 7 8 9 10 11 12) CreateWindowEx(1 2 3 4 5 6 7 8 9 10 11 12)

View File

@ -5,13 +5,20 @@
*/ */
#if defined (mc68000) || defined (sparc) #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_LONG(a) (((a)&0xFF) << 24) | (((a) & 0xFF00) << 8) | (((unsigned long)(a) & 0xFF0000) >> 8) | ((unsigned long)((a)&0xFF000000) >> 24)
#define CONV_CHAR_TO_LONG(x) ((x) >> 24) #define CONV_SHORT(a) (((a) & 0xFF) << 8) | (((unsigned long)(a) & 0xFF00) >> 8)
#define CONV_SHORT_TO_LONG(x) ((x) >> 16) #define CONV_CHAR_TO_LONG(x) ((unsigned long)(x) >> 24)
#define CONV_SHORT_TO_LONG(x) ((unsigned long)(x) >> 16)
#define CONV_BITMAPINFO ARCH_ConvBitmapInfo
#define CONV_BITMAPCOREHEADER ARCH_ConvCoreHeader
#else #else
#define CONV_LONG(a) (a) #define CONV_LONG(a) (a)
#define CONV_SHORT(a) (a) #define CONV_SHORT(a) (a)
#define CONV_CHAR_TO_LONG(a) (a) #define CONV_CHAR_TO_LONG(a) (a)
#define CONV_SHORT_TO_LONG(a) (a) #define CONV_SHORT_TO_LONG(a) (a)
#define CONV_BITMAPINFO
#define CONV_BITMAPCOREHEADER
#endif #endif

View File

@ -9,7 +9,6 @@
#include "windows.h" #include "windows.h"
typedef struct typedef struct
{ {
HANDLE next; HANDLE next;
@ -27,7 +26,10 @@ typedef struct
#ifdef WINELIB #ifdef WINELIB
#define LocalAlign(flags,bytes) LocalAlloc (flags|LMEM_WINE_ALIGN,bytes) #define LocalAlign(flags,bytes) LocalAlloc (flags|LMEM_WINE_ALIGN,bytes)
#else #else
#define LocalAlign(flags,bytes) LocalAlloc (flags,bytes) #define LocalAlign(flags,bytes) WIN16_LocalAlloc((flags),(bytes))
#define LocalAlloc WIN16_LocalAlloc
#define LocalLock WIN16_LocalLock
#define LocalFree WIN16_LocalFree
#endif #endif
#endif /* ATOM_H */ #endif /* ATOM_H */

22
include/bitmap.h Normal file
View File

@ -0,0 +1,22 @@
/*
* GDI bitmap definitions
*
* Copyright 1993 Alexandre Julliard
*/
#ifndef BITMAP_H
#define BITMAP_H
#include <X11/Xlib.h>
#include "windows.h"
/* Handle of the bitmap selected by default in a memory DC */
extern HBITMAP BITMAP_hbitmapMemDC;
/* GCs used for B&W and color bitmap operations */
extern GC BITMAP_monoGC, BITMAP_colorGC;
#define BITMAP_GC(bmp) \
(((bmp)->bitmap.bmBitsPixel == 1) ? BITMAP_monoGC : BITMAP_colorGC)
#endif /* BITMAP_H */

20
include/desktop.h Normal file
View File

@ -0,0 +1,20 @@
/*
* Desktop window definitions.
*
* Copyright 1994 Alexandre Julliard
*/
#ifndef DESKTOP_H
#define DESKTOP_H
#include "windows.h"
typedef struct
{
HBRUSH hbrushPattern;
HBITMAP hbitmapWallPaper;
} DESKTOPINFO;
extern BOOL DESKTOP_SetPattern(char *pattern );
#endif /* DESKTOP_H */

View File

@ -63,5 +63,6 @@ extern struct dll_table_entry_s SHELL_table[];
extern struct dll_table_entry_s SOUND_table[]; extern struct dll_table_entry_s SOUND_table[];
extern struct dll_table_entry_s KEYBOARD_table[]; extern struct dll_table_entry_s KEYBOARD_table[];
extern struct dll_table_entry_s WINSOCK_table[]; extern struct dll_table_entry_s WINSOCK_table[];
extern struct dll_table_entry_s STRESS_table[];
#endif /* DLLS_H */ #endif /* DLLS_H */

View File

@ -69,10 +69,9 @@ typedef struct tagFONTOBJ
typedef struct tagBITMAPOBJ typedef struct tagBITMAPOBJ
{ {
GDIOBJHDR header; GDIOBJHDR header;
HANDLE hBitmap; BITMAP bitmap;
BOOL bSelected; Pixmap pixmap;
HDC hdc; SIZE size; /* For SetBitmapDimension() */
SIZE size;
} BITMAPOBJ; } BITMAPOBJ;
typedef struct tagRGNOBJ typedef struct tagRGNOBJ
@ -152,7 +151,6 @@ typedef struct
short breakExtra; /* breakTotalExtra / breakCount */ short breakExtra; /* breakTotalExtra / breakCount */
short breakRem; /* breakTotalExtra % breakCount */ short breakRem; /* breakTotalExtra % breakCount */
BYTE planes;
BYTE bitsPerPixel; BYTE bitsPerPixel;
WORD MapMode; WORD MapMode;
@ -179,6 +177,8 @@ typedef struct
int style; int style;
int pixel; int pixel;
int width; int width;
char * dashes;
int dash_len;
} X_PHYSPEN; } X_PHYSPEN;
/* X physical brush */ /* X physical brush */
@ -197,6 +197,13 @@ typedef struct
TEXTMETRIC metrics; TEXTMETRIC metrics;
} X_PHYSFONT; } X_PHYSFONT;
/* X physical palette information */
typedef struct
{
HANDLE hMapping;
WORD mappingSize;
} X_PHYSPALETTE;
/* X-specific DC information */ /* X-specific DC information */
typedef struct typedef struct
{ {
@ -205,6 +212,7 @@ typedef struct
X_PHYSFONT font; X_PHYSFONT font;
X_PHYSPEN pen; X_PHYSPEN pen;
X_PHYSBRUSH brush; X_PHYSBRUSH brush;
X_PHYSPALETTE pal;
} X_DC_INFO; } X_DC_INFO;
@ -282,7 +290,7 @@ typedef struct tagDC
extern MDESC *GDI_Heap; extern MDESC *GDI_Heap;
#define GDI_HEAP_ALLOC(f,size) ((int)HEAP_Alloc(&GDI_Heap,f,size) & 0xffff) #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_ADDR(handle) ((void *)((handle)|((int)GDI_Heap & 0xffff0000)))
#define GDI_HEAP_FREE(handle) (HEAP_Free(&GDI_Heap,GDI_HEAP_ADDR(handle))) #define GDI_HEAP_FREE(handle) (HEAP_Free(&GDI_Heap,GDI_HEAP_ADDR(handle)))
#endif #endif
@ -296,5 +304,7 @@ extern Screen * XT_screen; /* Will be removed */
extern Display * display; extern Display * display;
extern Screen * screen; extern Screen * screen;
extern Window rootWindow;
extern int screenWidth, screenHeight, screenDepth;
#endif /* GDI_H */ #endif /* GDI_H */

View File

@ -6,6 +6,10 @@
#ifndef HEAP_H #ifndef HEAP_H
#define HEAP_H #define HEAP_H
#include "segmem.h"
#include "regfunc.h"
#include "atom.h"
/********************************************************************** /**********************************************************************
* LOCAL HEAP STRUCTURES AND FUNCTIONS * LOCAL HEAP STRUCTURES AND FUNCTIONS
*/ */
@ -17,11 +21,24 @@ typedef struct heap_mem_desc_s
unsigned char flags; unsigned char flags;
} MDESC; } MDESC;
typedef struct heap_local_heap_s
{
struct heap_local_heap_s *next;
MDESC *free_list;
ATOMTABLE *local_table;
unsigned short selector;
} LHEAP;
extern void HEAP_Init(MDESC **free_list, void *start, int length); extern void HEAP_Init(MDESC **free_list, void *start, int length);
extern void *HEAP_Alloc(MDESC **free_list, int flags, int bytes); extern void *HEAP_Alloc(MDESC **free_list, int flags, int bytes);
extern int HEAP_Free(MDESC **free_list, void *block); extern int HEAP_Free(MDESC **free_list, void *block);
extern void *HEAP_ReAlloc(MDESC **free_list, void *old_block, extern void *HEAP_ReAlloc(MDESC **free_list, void *old_block,
int new_size, unsigned int flags); int new_size, unsigned int flags);
extern LHEAP *HEAP_LocalFindHeap(unsigned short owner);
#define HEAP_OWNER (Segments[Stack16Frame[11] >> 3].owner)
#define LOCALHEAP() (&HEAP_LocalFindHeap(HEAP_OWNER)->free_list)
#define LOCALATOMTABLE() (&HEAP_LocalFindHeap(HEAP_OWNER)->local_table)
/********************************************************************** /**********************************************************************
* GLOBAL HEAP STRUCTURES AND FUNCTIONS: * GLOBAL HEAP STRUCTURES AND FUNCTIONS:

33
include/mdi.h Normal file
View File

@ -0,0 +1,33 @@
/* MDI.H
*
* Copyright 1994, Bob Amstadt
*
* MDI structure definitions.
*/
#ifndef MDI_H
#define MDI_H
#include "windows.h"
#define MDI_MAXLISTLENGTH 64
typedef struct mdi_child_info_s
{
struct mdi_child_info_s *next, *prev;
HWND hwnd;
} MDICHILDINFO;
typedef struct
{
HMENU hWindowMenu;
MDICHILDINFO *infoActiveChildren;
WORD nActiveChildren;
WORD idFirstChild;
HWND hwndActiveChild;
HWND hwndHitTest;
BOOL flagMenuAltered;
BOOL flagChildMaximized;
} MDICLIENTINFO;
#endif /* MDI_H */

View File

@ -28,15 +28,17 @@ typedef struct tagMENUITEM
typedef struct tagPOPUPMENU typedef struct tagPOPUPMENU
{ {
HWND hWnd; /* PopupMenu window handle */ HWND hWnd; /* PopupMenu window handle */
HWND hWndParent; /* Parent opupMenu window handle */ HWND hWndParent; /* Parent PopupMenu window handle */
HWND ownerWnd; /* Owner window */ HWND ownerWnd; /* Owner window */
WORD nItems; /* Number of items on menu */ HWND hWndPrev; /* Previous Window Focus Owner */
WORD nItems; /* Number of items on menu */
MENUITEM *firstItem; MENUITEM *firstItem;
WORD FocusedItem; WORD FocusedItem;
WORD MouseFlags; WORD MouseFlags;
WORD BarFlags; BOOL BarFlag; /* TRUE if menu is a MENUBAR */
BOOL SysFlag; BOOL SysFlag; /* TRUE if menu is a SYSMENU */
BOOL ChildFlag; /* TRUE if child of other menu */
WORD Width; WORD Width;
WORD Height; WORD Height;
WORD CheckWidth; WORD CheckWidth;
@ -64,7 +66,7 @@ typedef struct
} MENUITEMTEMPLATE; } MENUITEMTEMPLATE;
void StdDrawMenuBar(HDC hDC, LPRECT lprect, LPPOPUPMENU lppop); void StdDrawMenuBar(HDC hDC, LPRECT lprect, LPPOPUPMENU lppop);
void MenuButtonDown(HWND hWnd, LPPOPUPMENU lppop, int x, int y); BOOL MenuButtonDown(HWND hWnd, LPPOPUPMENU lppop, int x, int y);
void MenuButtonUp(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 MenuMouseMove(HWND hWnd, LPPOPUPMENU lppop, WORD wParam, int x, int y);
extern void NC_TrackSysMenu(HWND hwnd); extern void NC_TrackSysMenu(HWND hwnd);

View File

@ -48,9 +48,10 @@ extern void MSG_IncPaintCount( HANDLE hQueue );
extern void MSG_DecPaintCount( HANDLE hQueue ); extern void MSG_DecPaintCount( HANDLE hQueue );
extern void MSG_IncTimerCount( HANDLE hQueue ); extern void MSG_IncTimerCount( HANDLE hQueue );
extern void MSG_DecTimerCount( HANDLE hQueue ); extern void MSG_DecTimerCount( HANDLE hQueue );
extern void MSG_Synchronize();
extern BOOL MSG_CreateSysMsgQueue( int size ); extern BOOL MSG_CreateSysMsgQueue( int size );
extern void hardware_event(HWND hwnd, WORD message, WORD wParam, LONG lParam, extern void hardware_event( WORD message, WORD wParam, LONG lParam,
WORD xPos, WORD yPos, DWORD time, DWORD extraInfo); int xPos, int yPos, DWORD time, DWORD extraInfo );
extern BOOL MSG_GetHardwareMessage( LPMSG msg ); extern BOOL MSG_GetHardwareMessage( LPMSG msg );
#endif /* MESSAGE_H */ #endif /* MESSAGE_H */

View File

@ -1,6 +1,7 @@
#ifndef INT21_H #ifndef __MSDOS_H
#define INT21_H #define __MSDOS_H
#include <dirent.h> #include <dirent.h>
#include <windows.h>
struct dosdirent { struct dosdirent {
int inuse; int inuse;
@ -11,20 +12,9 @@ struct dosdirent {
char attribute; char attribute;
long filesize; long filesize;
long filetime; long filetime;
long filedate;
}; };
struct diskinfo { #define DOSVERSION 0x0330;
unsigned int infolevel;
unsigned long serialnumber;
char label[11];
char fstype[8];
};
#define DosVersion 0x0303;
#define SectorSize 0x200;
#define SectorsPerCluster 0x04;
#define EAX context->sc_eax #define EAX context->sc_eax
#define EBX context->sc_ebx #define EBX context->sc_ebx
@ -45,13 +35,39 @@ struct diskinfo {
#define EFL context->sc_efl #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 (EFL |= 0x00000001L) #define SetCflag (EFL |= 0x00000001L)
#define ResetCflag (EFL &= 0xfffffffeL) #define ResetCflag (EFL &= 0xfffffffeL)
#define pointer(a,b) (BYTE*)(((WORD) a << 16) | b)
#define segment(a) ((DWORD)a >> 16)
#define offset(a) ((DWORD)a & 0xffff)
#define setword(a,b) *(BYTE*)a = b & 0xff; \
*((BYTE*)a + 1) = (b>>8) & 0xff;
#define setdword(a,b) *(BYTE*)a = b & 0xff; \
*((BYTE*)a + 1) = (b>>8) & 0xff; \
*((BYTE*)a + 2) = (b>>16) & 0xff; \
*((BYTE*)a + 3) = (b>>24) & 0xff;
#define getword(a) (WORD) *(BYTE*)a + \
(*((BYTE*)a + 1) << 8)
#define getdword(a) (DWORD) (*(BYTE*)a + \
(*((BYTE*)a + 1) << 8) + \
(*((BYTE*)a + 2) << 16) + \
(*((BYTE*)a + 3) << 24))
/* dos file attributes */
#define FA_NORMAL 0x00 /* Normal file, no attributes */
#define FA_RDONLY 0x01 /* Read only attribute */
#define FA_HIDDEN 0x02 /* Hidden file */
#define FA_SYSTEM 0x04 /* System file */
#define FA_LABEL 0x08 /* Volume label */
#define FA_DIREC 0x10 /* Directory */
#define FA_ARCH 0x20 /* Archive */
/* extended error codes */ /* extended error codes */
#define NoError 0x00 #define NoError 0x00
@ -113,4 +129,4 @@ struct diskinfo {
#define EL_Network 0x03 #define EL_Network 0x03
#define EL_Memory 0x05 #define EL_Memory 0x05
#endif /* INT21_H */ #endif /* __MSDOS_H */

View File

@ -220,4 +220,7 @@ struct resource_typeinfo_s
#define NE_RSCTYPE_RCDATA 0x800a #define NE_RSCTYPE_RCDATA 0x800a
#define NE_RSCTYPE_STRING 0x8006 #define NE_RSCTYPE_STRING 0x8006
int load_typeinfo (int, struct resource_typeinfo_s *);
int load_nameinfo (int, struct resource_nameinfo_s *);
#endif /* NEEXE_H */ #endif /* NEEXE_H */

View File

@ -10,6 +10,8 @@
struct options struct options
{ {
char * spyFilename; char * spyFilename;
char * desktopGeometry; /* NULL when no desktop */
char * programName; /* To use when loading resources */
int usePrivateMap; int usePrivateMap;
int synchronous; int synchronous;
short cmdShow; short cmdShow;

View File

@ -3,54 +3,259 @@
/* /*
* Copyright Robert J. Amstadt, 1993 * Copyright Robert J. Amstadt, 1993
*/ */
#ifndef PROTOTYPES_H #ifndef _WINE_PROTOTYPES_H
#define PROTOTYPES_H #define _WINE_PROTOTYPES_H
#include <sys/types.h> #include <sys/types.h>
#include "neexe.h" #include "neexe.h"
#include "segmem.h" #include "segmem.h"
#include "wine.h" #include "wine.h"
#include "int21.h" #include "heap.h"
#include "msdos.h"
#include "windows.h"
#ifndef WINELIB #ifndef WINELIB
extern struct segment_descriptor_s *
CreateSelectors(struct w_files *); /* loader/dump.c */
extern void PrintFileHeader(struct ne_header_s *ne_header); extern void PrintFileHeader(struct ne_header_s *ne_header);
extern void PrintSegmentTable(struct ne_segment_table_entry_s *seg_table, extern void PrintSegmentTable(struct ne_segment_table_entry_s *seg_table,
int nentries); int nentries);
extern void PrintRelocationTable(char *exe_ptr, extern void PrintRelocationTable(char *exe_ptr,
struct ne_segment_table_entry_s *seg_entry_p, struct ne_segment_table_entry_s *seg_entry_p,
int segment); int segment);
extern int FixupSegment(struct w_files * wpnt, int segment_num);
extern struct dll_table_entry_s *FindDLLTable(char *dll_name);
extern unsigned int GetEntryPointFromOrdinal(struct w_files * wpnt,
int ordinal);
extern struct segment_descriptor_s *GetNextSegment(unsigned int flags, /* loader/ldtlib.c */
unsigned int limit);
extern struct segment_descriptor_s *CreateNewSegments(int code_flag, struct segment_descriptor *
int read_only, make_sd(unsigned base, unsigned limit, int contents, int read_exec_only, int seg32, int inpgs);
int length, int get_ldt(void *buffer);
int n_segments); int set_ldt_entry(int entry, unsigned long base, unsigned int limit,
int seg_32bit_flag, int contents, int read_only_flag,
int limit_in_pages_flag);
/* loader/resource.c */
extern int OpenResourceFile(HANDLE instance);
extern HBITMAP ConvertCoreBitmap( HDC hdc, BITMAPCOREHEADER * image );
extern HBITMAP ConvertInfoBitmap( HDC hdc, BITMAPINFO * image );
extern int FindResourceByNumber(struct resource_nameinfo_s *result_p,
int type_id, int resource_id);
extern int FindResourceByName(struct resource_nameinfo_s *result_p,
int type_id, char *resource_name);
extern HICON LoadIcon(HANDLE instance, LPSTR icon_name);
extern HANDLE RSC_LoadResource(int instance, char *rsc_name, int type,
int *image_size_ret);
extern int LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen);
extern HANDLE RSC_LoadMenu(HANDLE instance, LPSTR menu_name);
extern HBITMAP LoadBitmap(HANDLE instance, LPSTR bmp_name);
/* loader/selector.c */
extern int FindUnusedSelectors(int n_selectors);
extern int IPCCopySelector(int i_old, unsigned long new, int swap_type);
extern WORD AllocSelector(WORD old_selector);
extern unsigned int PrestoChangoSelector(unsigned src_selector, unsigned dst_selector);
extern WORD AllocDStoCSAlias(WORD ds_selector);
extern WORD FreeSelector(WORD sel);
extern SEGDESC *CreateNewSegments(int code_flag, int read_only, int length,
int n_segments);
extern SEGDESC *GetNextSegment(unsigned int flags, unsigned int limit);
extern unsigned int GetEntryDLLName(char *dll_name, char *function, int *sel,
int *addr);
extern unsigned int GetEntryDLLOrdinal(char *dll_name, int ordinal, int *sel,
int *addr);
extern unsigned int GetEntryPointFromOrdinal(struct w_files * wpnt,
int ordinal);
extern SEGDESC *CreateSelectors(struct w_files * wpnt);
/* loader/signal.c */
extern int init_wine_signals(void);
/* loader/wine.c */
extern void myerror(const char *s);
extern void load_mz_header (int, struct mz_header_s *);
extern void load_ne_header (int, struct ne_header_s *);
extern char *GetFilenameFromInstance(unsigned short instance);
extern struct w_files *GetFileInfo(unsigned short instance);
extern HINSTANCE LoadImage(char *modulename, int filetype);
extern int _WinMain(int argc, char **argv);
extern void InitializeLoadedDLLs();
extern int FixupSegment(struct w_files * wpnt, int segment_num);
/*
extern struct mz_header_s *CurrentMZHeader; extern struct mz_header_s *CurrentMZHeader;
extern struct ne_header_s *CurrentNEHeader; extern struct ne_header_s *CurrentNEHeader;
extern int CurrentNEFile; extern int CurrentNEFile;
extern do_int1A(struct sigcontext_struct * context); */
extern do_int21(struct sigcontext_struct * context);
extern void GetUnixDirName(char *rootdir, char *name); /* if1632/relay.c */
extern char *GetDirectUnixFileName(char *dosfilename);
extern int CallBack16(void *func, int n_args, ...);
extern void *CALLBACK_MakeProcInstance(void *func, int instance);
extern void CallLineDDAProc(FARPROC func, short xPos, short yPos, long lParam);
extern void winestat(void);
/* if1632/callback.c */
extern int DLLRelay(unsigned int func_num, unsigned int seg_off);
extern struct dll_table_entry_s *FindDLLTable(char *dll_name);
extern int FindOrdinalFromName(struct dll_table_entry_s *dll_table, char *func_name);
extern int ReturnArg(int arg);
/* miscemu/int1a.c */
extern do_int1A(struct sigcontext_struct *context);
/* miscemu/int21.c */
extern do_int21(struct sigcontext_struct *context);
/* miscemu/kernel.c */
extern int KERNEL_LockSegment(int segment);
extern int KERNEL_UnlockSegment(int segment);
extern KERNEL_InitTask();
extern int KERNEL_WaitEvent(int task);
/* misc/comm.c */
void Comm_Init(void);
void Comm_DeInit(void);
/* misc/dos_fs.c */
extern void DOS_InitFS(void);
extern WORD DOS_GetEquipment(void);
extern int DOS_ValidDrive(int drive);
extern int DOS_GetDefaultDrive(void);
extern void DOS_SetDefaultDrive(int drive);
extern void ToUnix(char *s);
extern void ToDos(char *s);
extern void ChopOffSlash(char *string);
extern int DOS_DisableDrive(int drive);
extern int DOS_EnableDrive(int drive);
extern char *GetUnixFileName(char *dosfilename); extern char *GetUnixFileName(char *dosfilename);
extern char *DOS_GetCurrentDir(int drive);
extern int DOS_ChangeDir(int drive, char *dirname);
extern int DOS_MakeDir(int drive, char *dirname);
extern int DOS_GetSerialNumber(int drive, unsigned long *serialnumber);
extern int DOS_SetSerialNumber(int drive, unsigned long serialnumber);
extern char *DOS_GetVolumeLabel(int drive);
extern int DOS_SetVolumeLabel(int drive, char *label);
extern int DOS_GetFreeSpace(int drive, long *size, long *available);
extern char *FindFile(char *buffer, int buflen, char *rootname, char **extensions, char *path); extern char *FindFile(char *buffer, int buflen, char *rootname, char **extensions, char *path);
extern char *WineIniFileName(void); extern char *WineIniFileName(void);
extern char *WinIniFileName(void); extern char *WinIniFileName(void);
extern struct dosdirent *DOS_opendir(char *dosdirname); extern struct dosdirent *DOS_opendir(char *dosdirname);
extern struct dosdirent *DOS_readdir(struct dosdirent *de); extern struct dosdirent *DOS_readdir(struct dosdirent *de);
extern void DOS_closedir(struct dosdirent *de); extern void DOS_closedir(struct dosdirent *de);
#endif /* WINELIB */ /* misc/profile.c */
#endif /* PROTOTYPES_H */ extern void sync_profiles(void);
/* misc/spy.c */
extern void SpyInit(void);
/* controls/button.c */
extern LONG ButtonWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam);
/* controls/combo.c */
extern LONG ComboBoxWndProc(HWND hwnd, WORD message, WORD wParam, LONG lParam);
/* controls/desktop.c */
extern LONG DesktopWndProc (HWND hwnd, WORD message, WORD wParam, LONG lParam);
extern BOOL DESKTOP_SetPattern(char *pattern);
/* controls/listbox.c */
extern LONG ListBoxWndProc(HWND hwnd, WORD message, WORD wParam, LONG lParam);
/* controls/menu.c */
extern LONG PopupMenuWndProc(HWND hwnd, WORD message, WORD wParam, LONG lParam);
/* controls/scrollbar.c */
extern LONG ScrollBarWndProc(HWND hWnd, WORD message, WORD wParam, LONG lParam);
/* controls/static.c */
extern LONG StaticWndProc(HWND hwnd, WORD message, WORD wParam, LONG lParam);
/* controls/widget.c */
extern BOOL WIDGETS_Init(void);
/* memory/heap.c */
extern void HEAP_Init(MDESC **free_list, void *start, int length);
extern void *HEAP_Alloc(MDESC **free_list, int flags, int bytes);
extern void *HEAP_ReAlloc(MDESC **free_list, void *old_block, int new_size, unsigned int flags);
extern int HEAP_Free(MDESC **free_list, void *block);
extern LHEAP *HEAP_LocalFindHeap(unsigned short owner);
extern void HEAP_LocalInit(unsigned short owner, void *start, int length);
extern void *WIN16_LocalAlloc(int flags, int bytes);
extern int WIN16_LocalCompact(int min_free);
extern unsigned int WIN16_LocalFlags(unsigned int handle);
extern unsigned int WIN16_LocalFree(unsigned int handle);
extern unsigned int WIN16_LocalInit(unsigned int segment, unsigned int start, unsigned int end);
extern void *WIN16_LocalLock(unsigned int handle);
extern void *WIN16_LocalReAlloc(unsigned int handle, int flags, int bytes);
extern unsigned int WIN16_LocalSize(unsigned int handle);
extern unsigned int WIN16_LocalUnlock(unsigned int handle);
/* objects/bitmaps.c */
extern BOOL BITMAP_Init(void);
/* objects/color.c */
extern BOOL COLOR_Init(void);
/* objects/dib.c */
extern int DIB_BitmapInfoSize(BITMAPINFO *info, WORD coloruse);
/* objects/gdiobj.c */
extern BOOL GDI_Init(void);
/* objects/palette.c */
extern BOOL PALETTE_Init(void);
/* objects/region.c */
extern BOOL REGION_Init(void);
/* windows/graphic.c */
extern void DrawReliefRect(HDC hdc, RECT rect, int thickness, BOOL pressed);
/* windows/dce.c */
extern void DCE_Init(void);
/* windows/dialog.c */
extern BOOL DIALOG_Init(void);
/* windows/syscolor.c */
extern void SYSCOLOR_Init(void);
/* windows/sysmetrics.c */
extern void SYSMETRICS_Init(void);
#endif /* WINELIB */
#endif /* _WINE_PROTOTYPES_H */

View File

@ -6,6 +6,7 @@
extern unsigned short *Stack16Frame; extern unsigned short *Stack16Frame;
#define _CONTEXT &Stack16Frame[12]
#define _AX Stack16Frame[34] #define _AX Stack16Frame[34]
#define _BX Stack16Frame[28] #define _BX Stack16Frame[28]
#define _CX Stack16Frame[32] #define _CX Stack16Frame[32]

30
include/stress.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef __STRESS_H
#define __STRESS_H
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
#define EDS_WIN 1
#define EDS_CUR 2
#define EDS_TEMP 3
BOOL AllocGDIMem(UINT);
BOOL AllocMem(DWORD);
BOOL AllocUserMem(UINT);
int AllocDiskSpace(long, UINT);
int AllocFileHandles(int);
int GetFreeFileHandles(void);
void FreeAllGDIMem(void);
void FreeAllMem(void);
void FreeAllUserMem(void);
void UnAllocDiskSpace(UINT);
void UnAllocFileHandles(void);
#ifdef __cplusplus
}
#endif
#endif /* __STRESS_H */

View File

@ -25,7 +25,7 @@ extern MDESC *USER_Heap;
#define USER_HEAP_ALLOC(f,size) ((int)HEAP_Alloc(&USER_Heap,f,size) & 0xffff) #define USER_HEAP_ALLOC(f,size) ((int)HEAP_Alloc(&USER_Heap,f,size) & 0xffff)
#define USER_HEAP_REALLOC(handle,size,f) ((int)HEAP_ReAlloc(&USER_Heap, \ #define USER_HEAP_REALLOC(handle,size,f) ((int)HEAP_ReAlloc(&USER_Heap, \
USER_HEAP_ADDR(handle),size,f) & 0xffff) USER_HEAP_ADDR(handle),size,f) & 0xffff)
#define USER_HEAP_ADDR(handle) ((void *)(handle|((int)USER_Heap & 0xffff0000))) #define USER_HEAP_ADDR(handle) ((void *)((handle)|((int)USER_Heap&0xffff0000)))
#define USER_HEAP_FREE(handle) (HEAP_Free(&USER_Heap,USER_HEAP_ADDR(handle))) #define USER_HEAP_FREE(handle) (HEAP_Free(&USER_Heap,USER_HEAP_ADDR(handle)))
#endif /* WINELIB */ #endif /* WINELIB */

View File

@ -67,8 +67,11 @@ WND *WIN_FindWndPtr( HWND hwnd );
BOOL WIN_UnlinkWindow( HWND hwnd ); BOOL WIN_UnlinkWindow( HWND hwnd );
BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter ); BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter );
HWND WIN_FindWinToRepaint( HWND hwnd ); HWND WIN_FindWinToRepaint( HWND hwnd );
BOOL WINPOS_IsAnActiveWindow( HWND hwnd );
void WINPOS_ActivateChild( HWND hwnd );
extern Display * display; extern Display * display;
extern Screen * screen; extern Screen * screen;
extern Window rootWindow;
#endif /* WIN_H */ #endif /* WIN_H */

View File

@ -5,6 +5,7 @@
#ifndef _WINARGS #ifndef _WINARGS
typedef short INT;
typedef unsigned short UINT; typedef unsigned short UINT;
typedef unsigned short WORD; typedef unsigned short WORD;
typedef unsigned long DWORD; typedef unsigned long DWORD;
@ -218,6 +219,25 @@ typedef struct {
DWORD dwExStyle WINE_PACKED; DWORD dwExStyle WINE_PACKED;
} CREATESTRUCT, *LPCREATESTRUCT; } CREATESTRUCT, *LPCREATESTRUCT;
typedef struct
{
HMENU hWindowMenu;
WORD idFirstChild;
} CLIENTCREATESTRUCT, *LPCLIENTCREATESTRUCT;
typedef struct
{
LPSTR szClass;
LPSTR szTitle;
HANDLE hOwner;
short x;
short y;
short cx;
short cy;
LONG style WINE_PACKED;
LONG lParam WINE_PACKED;
} MDICREATESTRUCT, *LPMDICREATESTRUCT;
/* Offsets for GetWindowLong() and GetWindowWord() */ /* Offsets for GetWindowLong() and GetWindowWord() */
#define GWL_EXSTYLE (-20) #define GWL_EXSTYLE (-20)
#define GWL_STYLE (-16) #define GWL_STYLE (-16)
@ -466,7 +486,9 @@ typedef WORD ATOM;
typedef DWORD COLORREF; typedef DWORD COLORREF;
#define RGB(r,g,b) ((COLORREF)((r) | ((g) << 8) | ((b) << 16))) #define RGB(r,g,b) ((COLORREF)((r) | ((g) << 8) | ((b) << 16)))
#define PALETTERGB(r,g,b) (0x02000000 | RGB(r,g,b))
#define PALETTEINDEX(i) ((COLORREF)(0x01000000 | (WORD)(i)))
#define GetRValue(rgb) ((rgb) & 0xff) #define GetRValue(rgb) ((rgb) & 0xff)
#define GetGValue(rgb) (((rgb) >> 8) & 0xff) #define GetGValue(rgb) (((rgb) >> 8) & 0xff)
@ -987,6 +1009,8 @@ typedef OFSTRUCT *LPOFSTRUCT;
#define OF_SHARE_EXCLUSIVE 0x0010 #define OF_SHARE_EXCLUSIVE 0x0010
#define OF_VERIFY 0x0400 #define OF_VERIFY 0x0400
#define DRIVE_CANNOTDETERMINE 0
#define DRIVE_DOESNOTEXIST 1
#define DRIVE_REMOVABLE 2 #define DRIVE_REMOVABLE 2
#define DRIVE_FIXED 3 #define DRIVE_FIXED 3
#define DRIVE_REMOTE 4 #define DRIVE_REMOTE 4
@ -1378,6 +1402,18 @@ enum { WM_NULL, WM_CREATE, WM_DESTROY, WM_MOVE, WM_UNUSED0, WM_SIZE, WM_ACTIVATE
#define WM_PARENTNOTIFY 0x0210 #define WM_PARENTNOTIFY 0x0210
#define WM_MDICREATE 0x0220
#define WM_MDIDESTROY 0x0221
#define WM_MDIACTIVATE 0x0222
#define WM_MDIRESTORE 0x0223
#define WM_MDINEXT 0x0224
#define WM_MDIMAXIMIZE 0x0225
#define WM_MDITILE 0x0226
#define WM_MDICASCADE 0x0227
#define WM_MDIICONARRANGE 0x0228
#define WM_MDIGETACTIVE 0x0229
#define WM_MDISETMENU 0x0230
#define WM_ENTERSIZEMOVE 0x0231 #define WM_ENTERSIZEMOVE 0x0231
#define WM_EXITSIZEMOVE 0x0232 #define WM_EXITSIZEMOVE 0x0232
@ -2117,6 +2153,7 @@ int wsprintf(LPSTR a,LPSTR b,...);
F(HMENU,CreateMenu) F(HMENU,CreateMenu)
F(BOOL,GetInputState) F(BOOL,GetInputState)
F(BOOL,SetDeskPattern)
F(LPSTR,GetDOSEnvironment) F(LPSTR,GetDOSEnvironment)
F(DWORD,GetMessagePos) F(DWORD,GetMessagePos)
F(LONG,GetMessageTime) F(LONG,GetMessageTime)
@ -2199,9 +2236,11 @@ Fa(BOOL,DestroyWindow,HWND,a)
Fa(BOOL,EnableHardwareInput,BOOL,a) Fa(BOOL,EnableHardwareInput,BOOL,a)
Fa(BOOL,FreeModule,HANDLE,a) Fa(BOOL,FreeModule,HANDLE,a)
Fa(BOOL,FreeResource,HANDLE,a) Fa(BOOL,FreeResource,HANDLE,a)
#ifndef GLOBAL_SOURCE
Fa(BOOL,GlobalUnWire,HANDLE,a) Fa(BOOL,GlobalUnWire,HANDLE,a)
Fa(BOOL,GlobalUnfix,HANDLE,a) Fa(BOOL,GlobalUnfix,HANDLE,a)
Fa(BOOL,GlobalUnlock,HANDLE,a) Fa(BOOL,GlobalUnlock,HANDLE,a)
#endif
Fa(BOOL,InitAtomTable,WORD,a) Fa(BOOL,InitAtomTable,WORD,a)
Fa(BOOL,IsClipboardFormatAvailable,WORD,a) Fa(BOOL,IsClipboardFormatAvailable,WORD,a)
Fa(BOOL,IsIconic,HWND,a) Fa(BOOL,IsIconic,HWND,a)
@ -2215,6 +2254,7 @@ Fa(BOOL,LocalUnlock,HANDLE,a)
Fa(BOOL,OpenClipboard,HWND,a) Fa(BOOL,OpenClipboard,HWND,a)
Fa(BOOL,OpenIcon,HWND,a) Fa(BOOL,OpenIcon,HWND,a)
Fa(BOOL,RemoveFontResource,LPSTR,a) Fa(BOOL,RemoveFontResource,LPSTR,a)
Fa(BOOL,SetDeskWallPaper,LPSTR,a)
Fa(BOOL,SetErrorMode,WORD,a) Fa(BOOL,SetErrorMode,WORD,a)
Fa(BOOL,SwapMouseButton,BOOL,a) Fa(BOOL,SwapMouseButton,BOOL,a)
Fa(BOOL,UnrealizeObject,HBRUSH,a) Fa(BOOL,UnrealizeObject,HBRUSH,a)
@ -2232,9 +2272,11 @@ Fa(DWORD,GetViewportExt,HDC,a)
Fa(DWORD,GetViewportOrg,HDC,a) Fa(DWORD,GetViewportOrg,HDC,a)
Fa(DWORD,GetWindowExt,HDC,a) Fa(DWORD,GetWindowExt,HDC,a)
Fa(DWORD,GetWindowOrg,HDC,a) Fa(DWORD,GetWindowOrg,HDC,a)
#ifndef GLOBAL_SOURCE
Fa(DWORD,GlobalCompact,DWORD,a) Fa(DWORD,GlobalCompact,DWORD,a)
Fa(DWORD,GlobalHandle,WORD,a) Fa(DWORD,GlobalHandle,WORD,a)
Fa(DWORD,GlobalSize,HANDLE,a) Fa(DWORD,GlobalSize,HANDLE,a)
#endif
Fa(DWORD,OemKeyScan,WORD,a) Fa(DWORD,OemKeyScan,WORD,a)
Fa(FARPROC,LocalNotify,FARPROC,a) Fa(FARPROC,LocalNotify,FARPROC,a)
Fa(HANDLE,BeginDeferWindowPos,int,nNumWindows) Fa(HANDLE,BeginDeferWindowPos,int,nNumWindows)
@ -2248,9 +2290,11 @@ Fa(HANDLE,GetMetaFileBits,HANDLE,a)
Fa(HANDLE,GetModuleHandle,LPSTR,a) Fa(HANDLE,GetModuleHandle,LPSTR,a)
Fa(HANDLE,GetStockObject,int,a) Fa(HANDLE,GetStockObject,int,a)
Fa(HANDLE,GetWindowTask,HWND,a) Fa(HANDLE,GetWindowTask,HWND,a)
#ifndef GLOBAL_SOURCE
Fa(HANDLE,GlobalFree,HANDLE,a) Fa(HANDLE,GlobalFree,HANDLE,a)
Fa(HANDLE,GlobalLRUNewest,HANDLE,a) Fa(HANDLE,GlobalLRUNewest,HANDLE,a)
Fa(HANDLE,GlobalLRUOldest,HANDLE,a) Fa(HANDLE,GlobalLRUOldest,HANDLE,a)
#endif
Fa(HANDLE,LoadLibrary,LPSTR,a) Fa(HANDLE,LoadLibrary,LPSTR,a)
Fa(HANDLE,LocalFree,HANDLE,a) Fa(HANDLE,LocalFree,HANDLE,a)
Fa(HANDLE,LocalHandle,WORD,a) Fa(HANDLE,LocalHandle,WORD,a)
@ -2289,13 +2333,19 @@ Fa(LONG,SetSwapAreaSize,WORD,a)
Fa(LPSTR,AnsiLower,LPSTR,a) Fa(LPSTR,AnsiLower,LPSTR,a)
Fa(LPSTR,AnsiNext,LPSTR,a) Fa(LPSTR,AnsiNext,LPSTR,a)
Fa(LPSTR,AnsiUpper,LPSTR,a) Fa(LPSTR,AnsiUpper,LPSTR,a)
#ifndef GLOBAL_SOURCE
Fa(LPSTR,GlobalLock,HANDLE,a) Fa(LPSTR,GlobalLock,HANDLE,a)
Fa(LPSTR,GlobalWire,HANDLE,a) Fa(LPSTR,GlobalWire,HANDLE,a)
#endif
Fa(LPSTR,LockResource,HANDLE,a) Fa(LPSTR,LockResource,HANDLE,a)
#ifndef GLOBAL_SOURCE
Fa(void,GlobalFix,HANDLE,a) Fa(void,GlobalFix,HANDLE,a)
Fa(void,GlobalNotify,FARPROC,a) Fa(void,GlobalNotify,FARPROC,a)
#endif
Fa(void,LimitEmsPages,DWORD,a) Fa(void,LimitEmsPages,DWORD,a)
Fa(void,SetConvertHook,BOOL,a) Fa(void,SetConvertHook,BOOL,a)
Fa(UINT,GDIRealizePalette,HDC,a)
Fa(UINT,RealizePalette,HDC,a)
Fa(WORD,AllocDStoCSAlias,WORD,a) Fa(WORD,AllocDStoCSAlias,WORD,a)
Fa(WORD,AllocSelector,WORD,a) Fa(WORD,AllocSelector,WORD,a)
Fa(WORD,ArrangeIconicWindows,HWND,a) Fa(WORD,ArrangeIconicWindows,HWND,a)
@ -2305,13 +2355,15 @@ Fa(WORD,GetDriveType,int,a)
Fa(WORD,GetMenuItemCount,HMENU,a) Fa(WORD,GetMenuItemCount,HMENU,a)
Fa(WORD,GetTaskQueue,HANDLE,a) Fa(WORD,GetTaskQueue,HANDLE,a)
Fa(WORD,GetTextAlign,HDC,a) Fa(WORD,GetTextAlign,HDC,a)
#ifndef GLOBAL_SOURCE
Fa(WORD,GlobalFlags,HANDLE,a) Fa(WORD,GlobalFlags,HANDLE,a)
Fa(WORD,GlobalPageLock,HANDLE,a) Fa(WORD,GlobalPageLock,HANDLE,a)
Fa(WORD,GlobalPageUnlock,HANDLE,a) Fa(WORD,GlobalPageUnlock,HANDLE,a)
#endif
Fa(WORD,LocalCompact,WORD,a) Fa(WORD,LocalCompact,WORD,a)
Fa(WORD,LocalFlags,HANDLE,a) Fa(WORD,LocalFlags,HANDLE,a)
Fa(WORD,LocalSize,HANDLE,a) Fa(WORD,LocalSize,HANDLE,a)
Fa(int,RealizePalette,HDC,a) Fa(WORD,RealizeDefaultPalette,HDC,a)
Fa(WORD,RegisterClipboardFormat,LPCSTR,a) Fa(WORD,RegisterClipboardFormat,LPCSTR,a)
Fa(WORD,RegisterWindowMessage,LPCSTR,a) Fa(WORD,RegisterWindowMessage,LPCSTR,a)
Fa(WORD,SetHandleCount,WORD,a) Fa(WORD,SetHandleCount,WORD,a)
@ -2412,7 +2464,9 @@ Fb(FARPROC,MakeProcInstance,FARPROC,a,HANDLE,b)
Fb(FARPROC,SetWindowsHook,int,a,FARPROC,b) Fb(FARPROC,SetWindowsHook,int,a,FARPROC,b)
Fb(HANDLE,CopyMetaFile,HANDLE,a,LPSTR,b) Fb(HANDLE,CopyMetaFile,HANDLE,a,LPSTR,b)
Fb(HANDLE,GetProp,HWND,a,LPSTR,b) Fb(HANDLE,GetProp,HWND,a,LPSTR,b)
#ifndef GLOBAL_SOURCE
Fb(HANDLE,GlobalAlloc,WORD,a,DWORD,b) Fb(HANDLE,GlobalAlloc,WORD,a,DWORD,b)
#endif
Fb(HANDLE,LoadAccelerators,HANDLE,a,LPSTR,b) Fb(HANDLE,LoadAccelerators,HANDLE,a,LPSTR,b)
Fb(HANDLE,LoadModule,LPSTR,a,LPVOID,b) Fb(HANDLE,LoadModule,LPSTR,a,LPVOID,b)
Fb(HANDLE,LoadResource,HANDLE,a,HANDLE,b) Fb(HANDLE,LoadResource,HANDLE,a,HANDLE,b)
@ -2425,6 +2479,7 @@ Fb(HBRUSH,CreateDIBPatternBrush,HANDLE,a,WORD,b)
Fb(HBRUSH,CreateHatchBrush,short,a,COLORREF,b) Fb(HBRUSH,CreateHatchBrush,short,a,COLORREF,b)
Fb(HCURSOR,LoadCursor,HANDLE,a,LPSTR,b) Fb(HCURSOR,LoadCursor,HANDLE,a,LPSTR,b)
Fb(HICON,LoadIcon,HANDLE,a,LPSTR,b) Fb(HICON,LoadIcon,HANDLE,a,LPSTR,b)
Fb(HPALETTE,GDISelectPalette,HDC,a,HPALETTE,b)
Fb(HMENU,GetSubMenu,HMENU,a,short,b) Fb(HMENU,GetSubMenu,HMENU,a,short,b)
Fb(HMENU,GetSystemMenu,HWND,a,BOOL,b) Fb(HMENU,GetSystemMenu,HWND,a,BOOL,b)
Fb(HMENU,LoadMenu,HANDLE,a,LPSTR,b) Fb(HMENU,LoadMenu,HANDLE,a,LPSTR,b)
@ -2553,7 +2608,9 @@ Fc(DWORD,SetWindowOrg,HDC,a,short,b,short,c)
Fc(FARPROC,SetResourceHandler,HANDLE,a,LPSTR,b,FARPROC,c) Fc(FARPROC,SetResourceHandler,HANDLE,a,LPSTR,b,FARPROC,c)
Fc(HANDLE,AllocResource,HANDLE,a,HANDLE,b,DWORD,c) Fc(HANDLE,AllocResource,HANDLE,a,HANDLE,b,DWORD,c)
Fc(HANDLE,FindResource,HANDLE,a,LPSTR,b,LPSTR,c) Fc(HANDLE,FindResource,HANDLE,a,LPSTR,b,LPSTR,c)
#ifndef GLOBAL_SOURCE
Fc(HANDLE,GlobalReAlloc,HANDLE,a,DWORD,b,WORD,c) Fc(HANDLE,GlobalReAlloc,HANDLE,a,DWORD,b,WORD,c)
#endif
Fc(HANDLE,LocalReAlloc,HANDLE,a,WORD,b,WORD,c) Fc(HANDLE,LocalReAlloc,HANDLE,a,WORD,b,WORD,c)
Fc(HBITMAP,CreateCompatibleBitmap,HDC,a,short,b,short,c) Fc(HBITMAP,CreateCompatibleBitmap,HDC,a,short,b,short,c)
Fc(HBITMAP,CreateDiscardableBitmap,HDC,a,short,b,short,c) Fc(HBITMAP,CreateDiscardableBitmap,HDC,a,short,b,short,c)
@ -2737,7 +2794,7 @@ Fi(BOOL,Pie,HDC,a,int,xLeft,int,yTop,int,xRight,int,yBottom,int,xStart,int,yStar
Fk(HWND,CreateWindow,LPSTR,szAppName,LPSTR,Label,DWORD,ol,short,x,short,y,short,w,short,h,HWND,d,HMENU,e,,HANDLE i,LPSTR,g) Fk(HWND,CreateWindow,LPSTR,szAppName,LPSTR,Label,DWORD,ol,short,x,short,y,short,w,short,h,HWND,d,HMENU,e,,HANDLE i,LPSTR,g)
Fk(BOOL,StretchBlt,HDC,a,short,b,short,c,short,d,short,e,HDC,f,short,g,short,h,short,i,short,j,DWORD,k) Fk(BOOL,StretchBlt,HDC,a,short,b,short,c,short,d,short,e,HDC,f,short,g,short,h,short,i,short,j,DWORD,k)
Fl(HWND,CreateWindowEx,DWORD,a,LPSTR,b,LPSTR,c,DWORD,d,short,e,short,f,short,g,short,h,HWND,i,HMENU,j,HANDLE,k,LPSTR,l) Fl(HWND,CreateWindowEx,DWORD,a,LPSTR,b,LPSTR,c,DWORD,d,short,e,short,f,short,g,short,h,HWND,i,HMENU,j,HANDLE,k,LPSTR,l)
Fl(int,SetDIBitsToDevice,HDC,a,WORD,b,WORD,c,WORD,d,WORD,e,WORD,f,WORD,g,WORD,h,WORD,i,LPSTR,j,LPBITMAPINFO,k,WORD,l) Fl(int,SetDIBitsToDevice,HDC,a,short,b,short,c,WORD,d,WORD,e,WORD,f,WORD,g,WORD,h,WORD,i,LPSTR,j,LPBITMAPINFO,k,WORD,l)
Fm(int,StretchDIBits,HDC,a,WORD,b,WORD,c,WORD,d,WORD,e,WORD,f,WORD,g,WORD,h,WORD,i,LPSTR,j,LPBITMAPINFO,k,WORD,l,DWORD,m) Fm(int,StretchDIBits,HDC,a,WORD,b,WORD,c,WORD,d,WORD,e,WORD,f,WORD,g,WORD,h,WORD,i,LPSTR,j,LPBITMAPINFO,k,WORD,l,DWORD,m)
Fn(HFONT,CreateFont,int,a,int,b,int,c,int,d,int,e,BYTE,f,BYTE,g,BYTE,h,BYTE,i,BYTE,j,BYTE,k,BYTE,l,BYTE,m,LPSTR,n) Fn(HFONT,CreateFont,int,a,int,b,int,c,int,d,int,e,BYTE,f,BYTE,g,BYTE,h,BYTE,i,BYTE,j,BYTE,k,BYTE,l,BYTE,m,LPSTR,n)

View File

@ -3,28 +3,35 @@
#include "dlls.h" #include "dlls.h"
struct w_files{ #define MAX_NAME_LENGTH 64
struct w_files * next;
char * name; /* Name, as it appears in the windows binaries */ typedef struct resource_name_table
char * filename; /* Actual name of the unix file that satisfies this */ {
int fd; struct resource_name_table *next;
struct mz_header_s *mz_header; unsigned short type_ord;
struct ne_header_s *ne_header; unsigned short id_ord;
struct ne_segment_table_entry_s *seg_table; char id[MAX_NAME_LENGTH];
struct segment_descriptor_s *selector_table; } RESNAMTAB;
char * lookup_table;
char * nrname_table; struct w_files
char * rname_table; {
unsigned short hinstance; struct w_files * next;
char * name; /* Name, as it appears in the windows binaries */
char * filename; /* Actual name of the unix file that satisfies this */
int fd;
struct mz_header_s *mz_header;
struct ne_header_s *ne_header;
struct ne_segment_table_entry_s *seg_table;
struct segment_descriptor_s *selector_table;
char * lookup_table;
char * nrname_table;
char * rname_table;
unsigned short hinstance;
RESNAMTAB *resnamtab;
}; };
extern struct w_files * wine_files; extern struct w_files * wine_files;
extern char *GetFilenameFromInstance(unsigned short instance);
extern struct w_files *GetFileInfo(unsigned short instance);
extern char *WineIniFileName(void);
extern char *WinIniFileName(void);
#define MAX_DOS_DRIVES 26 #define MAX_DOS_DRIVES 26
#define WINE_INI WineIniFileName() #define WINE_INI WineIniFileName()
@ -63,9 +70,4 @@ struct sigcontext_struct {
#define HZ 100 #define HZ 100
#endif #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 */ #endif /* WINE_H */

View File

@ -63,6 +63,7 @@ typedef WSADATA FAR *LPWSADATA;
#endif #endif
#ifndef _SYS_SOCKET_H_ #ifndef _SYS_SOCKET_H_
#ifndef _sys_socket_h
/* /*
* Structure used by kernel to pass protocol * Structure used by kernel to pass protocol
* information in raw sockets. * information in raw sockets.
@ -72,6 +73,7 @@ struct sockproto {
u_short sp_protocol; /* protocol */ u_short sp_protocol; /* protocol */
}; };
#endif #endif
#endif
/* /*
* Maximum queue length specifiable by listen. * Maximum queue length specifiable by listen.

View File

@ -9,6 +9,7 @@ SRCS = \
selector.c \ selector.c \
signal.c \ signal.c \
library.c \ library.c \
resource.c \
wine.c wine.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)

View File

@ -1,3 +1,4 @@
#ifndef WINELIB
static char RCSId[] = "$Id: dump.c,v 1.2 1993/07/04 04:04:21 root Exp root $"; static char RCSId[] = "$Id: dump.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
@ -89,3 +90,4 @@ PrintRelocationTable(char *exe_ptr,
printf("TARGET %04.4x %04.4x\n", rep->target1, rep->target2); printf("TARGET %04.4x %04.4x\n", rep->target1, rep->target2);
} }
} }
#endif /* ifndef WINELIB */

View File

@ -1,11 +1,12 @@
#ifndef WINELIB
static char RCSId[] = "$Id: ldt.c,v 1.2 1993/07/04 04:04:21 root Exp root $"; static char RCSId[] = "$Id: ldt.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include "prototypes.h" #include "prototypes.h"
#if defined(__NetBSD__) || defined(__FreeBSD__) #if defined(__NetBSD__) || defined(__FreeBSD__)
#include <machine/segments.h> #include <machine/segments.h>
#endif #endif
@ -84,3 +85,5 @@ print_ldt()
} }
} }
} }
#endif /* ifndef WINELIB */

View File

@ -1,3 +1,4 @@
#ifndef WINELIB
static char RCSId[] = "$Id: ldtlib.c,v 1.2 1993/07/04 04:04:21 root Exp root $"; static char RCSId[] = "$Id: ldtlib.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
@ -90,3 +91,4 @@ set_ldt_entry(int entry, unsigned long base, unsigned int limit,
#endif #endif
} }
#endif /* ifndef WINELIB */

View File

@ -1,5 +1,7 @@
#ifndef WINELIB
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
@ -9,8 +11,18 @@
#include "wine.h" #include "wine.h"
#include "dlls.h" #include "dlls.h"
typedef struct module_table_entry
{
HINSTANCE hInst;
LPSTR name;
WORD count;
} MODULEENTRY;
extern struct w_files * wine_files; extern struct w_files * wine_files;
#define N_BUILTINS 10
extern struct dll_name_table_entry_s dll_builtin_table[N_BUILTINS];
/********************************************************************** /**********************************************************************
* GetCurrentTask [KERNEL.36] * GetCurrentTask [KERNEL.36]
@ -28,19 +40,27 @@ HTASK GetCurrentTask()
*/ */
HANDLE GetModuleHandle(LPSTR lpModuleName) HANDLE GetModuleHandle(LPSTR lpModuleName)
{ {
register struct w_files *w = wine_files; register struct w_files *w = wine_files;
printf("GetModuleHandle('%s');\n", lpModuleName); int i;
while (w) { printf("GetModuleHandle('%s');\n", lpModuleName);
printf("GetModuleHandle // '%s' \n", w->name); while (w) {
if (strcmp(w->name, lpModuleName) == 0) { /* printf("GetModuleHandle // '%s' \n", w->name); */
printf("GetModuleHandle('%s') return %04X \n", if (strcmp(w->name, lpModuleName) == 0) {
lpModuleName, w->hinstance); printf("GetModuleHandle('%s') return %04X \n",
return w->hinstance; lpModuleName, w->hinstance);
} return w->hinstance;
w = w->next; }
} w = w->next;
printf("GetModuleHandle('%s') not found !\n", lpModuleName); }
return 0; for (i = 0; i < N_BUILTINS; i++) {
if (strcmp(dll_builtin_table[i].dll_name, lpModuleName) == 0) {
printf("GetModuleHandle('%s') return %04X \n",
lpModuleName, 0xFF00 + i);
return (0xFF00 + i);
}
}
printf("GetModuleHandle('%s') not found !\n", lpModuleName);
return 0;
} }
@ -79,11 +99,11 @@ int GetModuleFileName(HANDLE hModule, LPSTR lpFileName, short nSize)
*/ */
HANDLE LoadLibrary(LPSTR libname) HANDLE LoadLibrary(LPSTR libname)
{ {
HANDLE hRet; HANDLE hModule;
printf("LoadLibrary '%s'\n", libname); printf("LoadLibrary '%s'\n", libname);
hRet = LoadImage(libname, DLL); hModule = LoadImage(libname, DLL);
printf("after LoadLibrary hRet=%04X\n", hRet); printf("LoadLibrary returned hModule=%04X\n", hModule);
return hRet; return hModule;
} }
@ -97,3 +117,64 @@ void FreeLibrary(HANDLE hLib)
} }
/**********************************************************************
* GetProcAddress [KERNEL.50]
*/
FARPROC GetProcAddress(HANDLE hModule, char *proc_name)
{
WORD wOrdin;
int sel, addr, ret;
register struct w_files *w = wine_files;
int ordinal, len;
char * cpnt;
char C[128];
if (hModule == 0) {
printf("GetProcAddress: Bad Module handle=%#04X\n", hModule);
return NULL;
}
if (hModule >= 0xF000) {
if ((int) proc_name & 0xffff0000) {
printf("GetProcAddress: builtin %#04x, '%s'\n", hModule, proc_name);
/* wOrdin = FindOrdinalFromName(struct dll_table_entry_s *dll_table, proc_name); */
}
else {
printf("GetProcAddress: builtin %#04x, %d\n", hModule, (int) proc_name);
}
return NULL;
}
while (w && w->hinstance != hModule) w = w->next;
printf("GetProcAddress // Module Found ! w->filename='%s'\n", w->filename);
if (w == NULL) return NULL;
if ((int) proc_name & 0xffff0000) {
AnsiUpper(proc_name);
printf("GetProcAddress: %#04x, '%s'\n", hModule, proc_name);
cpnt = w->nrname_table;
while(TRUE) {
if (((int) cpnt) - ((int)w->nrname_table) >
w->ne_header->nrname_tab_length) return NULL;
len = *cpnt++;
strncpy(C, cpnt, len);
C[len] = '\0';
printf("pointing Function '%s' !\n", C);
if (strncmp(cpnt, proc_name, len) == 0) break;
cpnt += len + 2;
};
ordinal = *((unsigned short *) (cpnt + len));
}
else {
printf("GetProcAddress: %#04x, %d\n", hModule, (int) proc_name);
ordinal = (int)proc_name;
}
ret = GetEntryPointFromOrdinal(w, ordinal);
if (ret == -1) {
printf("GetProcAddress // Function not found !\n");
return NULL;
}
addr = ret & 0xffff;
sel = (ret >> 16);
printf("GetProcAddress // ret=%08X sel=%04X addr=%04X\n", ret, sel, addr);
return ret;
}
#endif /* ifndef WINELIB */

View File

@ -1,14 +1,14 @@
#ifndef WINELIB
static char RCSId[] = "$Id: resource.c,v 1.4 1993/07/04 04:04:21 root Exp root $"; 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"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include "arch.h" #include "arch.h"
#include "prototypes.h" #include "prototypes.h"
#include "windows.h" #include "windows.h"
@ -17,6 +17,8 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include "icon.h" #include "icon.h"
#include "accel.h" #include "accel.h"
/* #define DEBUG_RESOURCE */
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b))
typedef struct resource_s typedef struct resource_s
@ -34,18 +36,105 @@ static struct w_files *ResourceFileInfo = NULL;
static RESOURCE *Top = NULL; static RESOURCE *Top = NULL;
extern HINSTANCE hSysRes; extern HINSTANCE hSysRes;
HANDLE RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret); HANDLE RSC_LoadResource(int instance, char *rsc_name, int type,
int *image_size_ret);
void RSC_LoadNameTable(void);
extern char *ProgramName; extern char *ProgramName;
/*****************************************************************************
* Super Patch, I promise to arrange things as soon as I can. /**********************************************************************
* * RSC_LoadNameTable
******************************************************************************/ */
#ifdef WINELIB #ifndef WINELIB
#include "../loader/wine.c" void
#endif RSC_LoadNameTable()
{
struct resource_typeinfo_s typeinfo;
struct resource_nameinfo_s nameinfo;
unsigned short size_shift;
RESNAMTAB *top, *new;
char read_buf[1024];
char *p;
int i;
unsigned short len;
off_t rtoff;
off_t saved_pos;
top = NULL;
/*
* Move to beginning of resource table.
*/
rtoff = (ResourceFileInfo->mz_header->ne_offset +
ResourceFileInfo->ne_header->resource_tab_offset);
lseek(ResourceFd, rtoff, SEEK_SET);
/*
* Read block size.
*/
if (read(ResourceFd, &size_shift, sizeof(size_shift)) !=
sizeof(size_shift))
{
return;
}
size_shift = CONV_SHORT(size_shift);
/*
* Find resource.
*/
typeinfo.type_id = 0xffff;
while (typeinfo.type_id != 0)
{
if (!load_typeinfo (ResourceFd, &typeinfo))
break;
if (typeinfo.type_id == 0)
break;
if (typeinfo.type_id == 0x800f)
{
for (i = 0; i < typeinfo.count; i++)
{
if (read(ResourceFd, &nameinfo, sizeof(nameinfo)) !=
sizeof(nameinfo))
{
break;
}
saved_pos = lseek(ResourceFd, 0, SEEK_CUR);
lseek(ResourceFd, (long) nameinfo.offset << size_shift,
SEEK_SET);
read(ResourceFd, &len, sizeof(len));
while (len)
{
new = (RESNAMTAB *) GlobalQuickAlloc(sizeof(*new));
new->next = top;
top = new;
read(ResourceFd, &new->type_ord, 2);
read(ResourceFd, &new->id_ord, 2);
read(ResourceFd, read_buf, len - 6);
p = read_buf + strlen(read_buf) + 1;
strncpy(new->id, p, MAX_NAME_LENGTH);
new->id[MAX_NAME_LENGTH - 1] = '\0';
read(ResourceFd, &len, sizeof(len));
}
lseek(ResourceFd, saved_pos, SEEK_SET);
}
break;
}
else
{
lseek(ResourceFd, (typeinfo.count * sizeof(nameinfo)), SEEK_CUR);
}
}
ResourceFileInfo->resnamtab = top;
}
#endif /* WINELIB */
/********************************************************************** /**********************************************************************
* OpenResourceFile * OpenResourceFile
@ -69,8 +158,15 @@ OpenResourceFile(HANDLE instance)
close(ResourceFd); close(ResourceFd);
ResourceInst = instance; ResourceInst = instance;
ResourceFd = open (res_file, O_RDONLY);
ResourceFd = open (res_file, O_RDONLY); #if 1
#ifndef WINELIB
if (w->resnamtab == (RESNAMTAB *) -1)
{
RSC_LoadNameTable();
}
#endif
#endif
#ifdef DEBUG_RESOURCE #ifdef DEBUG_RESOURCE
printf("OpenResourceFile(%04X) // file='%s' hFile=%04X !\n", printf("OpenResourceFile(%04X) // file='%s' hFile=%04X !\n",
@ -241,6 +337,25 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
int i; int i;
off_t rtoff; off_t rtoff;
/*
* Check for loaded name table.
*/
if (ResourceFileInfo->resnamtab != NULL)
{
RESNAMTAB *e;
for (e = ResourceFileInfo->resnamtab; e != NULL; e = e->next)
{
if (e->type_ord == (type_id & 0x000f) &&
strcasecmp(e->id, resource_name) == 0)
{
return FindResourceByNumber(result_p, type_id, e->id_ord);
}
}
return -1;
}
/* /*
* Move to beginning of resource table. * Move to beginning of resource table.
*/ */
@ -311,9 +426,7 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
typeinfo.type_id, i + 1, typeinfo.count, typeinfo.type_id, i + 1, typeinfo.count,
name, resource_name); name, resource_name);
#endif #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)); memcpy(result_p, &nameinfo, sizeof(nameinfo));
return size_shift; return size_shift;
@ -794,6 +907,10 @@ LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen)
HANDLE HANDLE
RSC_LoadMenu(HANDLE instance, LPSTR menu_name) RSC_LoadMenu(HANDLE instance, LPSTR menu_name)
{ {
#ifdef DEBUG_RESOURCE
printf("RSC_LoadMenu: instance = %04x, name = '%s'\n",
instance, menu_name);
#endif
return RSC_LoadResource(instance, menu_name, NE_RSCTYPE_MENU, NULL); return RSC_LoadResource(instance, menu_name, NE_RSCTYPE_MENU, NULL);
} }
@ -808,7 +925,8 @@ LoadBitmap(HANDLE instance, LPSTR bmp_name)
HDC hdc; HDC hdc;
long *lp; long *lp;
int image_size; int image_size;
int size;
#ifdef DEBUG_RESOURCE #ifdef DEBUG_RESOURCE
printf("LoadBitmap: instance = %04x, name = %08x\n", printf("LoadBitmap: instance = %04x, name = %08x\n",
instance, bmp_name); instance, bmp_name);
@ -828,14 +946,73 @@ LoadBitmap(HANDLE instance, LPSTR bmp_name)
GlobalFree(rsc_mem); GlobalFree(rsc_mem);
return 0; return 0;
} }
if (*lp == sizeof(BITMAPCOREHEADER)) size = CONV_LONG (*lp);
if (size == sizeof(BITMAPCOREHEADER)){
CONV_BITMAPCOREHEADER (lp);
hbitmap = ConvertCoreBitmap( hdc, (BITMAPCOREHEADER *) lp ); hbitmap = ConvertCoreBitmap( hdc, (BITMAPCOREHEADER *) lp );
else if (*lp == sizeof(BITMAPINFOHEADER)) } else if (size == sizeof(BITMAPINFOHEADER)){
CONV_BITMAPINFO (lp);
hbitmap = ConvertInfoBitmap( hdc, (BITMAPINFO *) lp ); hbitmap = ConvertInfoBitmap( hdc, (BITMAPINFO *) lp );
else hbitmap = 0; } else hbitmap = 0;
GlobalFree(rsc_mem); GlobalFree(rsc_mem);
ReleaseDC( 0, hdc ); ReleaseDC( 0, hdc );
return hbitmap; return hbitmap;
} }
/**********************************************************************
* CreateIcon [USER.407]
*/
HICON CreateIcon(HANDLE hInstance, int nWidth, int nHeight,
BYTE nPlanes, BYTE nBitsPixel, LPSTR lpANDbits,
LPSTR lpXORbits)
{
HICON hIcon;
ICONALLOC *lpico;
#ifdef DEBUG_RESOURCE
printf("CreateIcon: hInstance = %04x, nWidth = %08x, nHeight = %08x \n",
hInstance, nWidth, nHeight);
printf(" nPlanes = %04x, nBitsPixel = %04x,",nPlanes, nBitsPixel);
printf(" lpANDbits= %04x, lpXORbits = %04x, \n",lpANDbits, lpXORbits);
#endif
if (hInstance == (HANDLE)NULL) {
printf("CreateIcon / hInstance %04x not Found!\n",hInstance);
return 0;
}
hIcon = GlobalAlloc(GMEM_MOVEABLE, sizeof(ICONALLOC) + 1024);
if (hIcon == (HICON)NULL) {
printf("Can't allocate memory for Icon in CreateIcon\n");
return 0;
}
lpico= (ICONALLOC *)GlobalLock(hIcon);
lpico->descriptor.Width=nWidth;
lpico->descriptor.Height=nHeight;
lpico->descriptor.ColorCount=16; /* Dummy Value */
lpico->descriptor.Reserved1=0;
lpico->descriptor.Reserved2=nPlanes;
lpico->descriptor.Reserved3=nWidth*nHeight;
/* either nPlanes and/or nBitCount is set to one */
lpico->descriptor.icoDIBSize=nWidth*nHeight*nPlanes*nBitsPixel;
lpico->descriptor.icoDIBOffset=0;
if( !(lpico->hBitmap=CreateBitmap(nWidth, nHeight, nPlanes, nBitsPixel,
lpXORbits)) ) {
printf("CreateIcon: couldn't create the XOR bitmap\n");
return(0);
}
/* the AND BitMask is always monochrome */
if( !(lpico->hBitMask=CreateBitmap(nWidth, nHeight, 1, 1, lpANDbits)) ) {
printf("CreateIcon: couldn't create the AND bitmap\n");
return(0);
}
GlobalUnlock(hIcon);
#ifdef DEBUG_RESOURCE
printf("CreateIcon Alloc hIcon=%X\n", hIcon);
#endif
return hIcon;
}

View File

@ -1,12 +1,16 @@
#ifndef WINELIB
static char RCSId[] = "$Id: selector.c,v 1.3 1993/07/04 04:04:21 root Exp root $"; static char RCSId[] = "$Id: selector.c,v 1.3 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
#ifdef __linux__ #ifdef __linux__
#include <linux/unistd.h> #include <linux/unistd.h>
#include <linux/head.h> #include <linux/head.h>
@ -16,14 +20,16 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#endif #endif
#if defined(__NetBSD__) || defined(__FreeBSD__) #if defined(__NetBSD__) || defined(__FreeBSD__)
#include <sys/mman.h> #include <sys/mman.h>
#include <machine/segments.h>
#endif #endif
#include <errno.h>
#include "neexe.h" #include "neexe.h"
#include "segmem.h" #include "segmem.h"
#include "prototypes.h"
#include "wine.h" #include "wine.h"
#include "windows.h"
#include "prototypes.h"
/* #define DEBUG_SELECTORS /* */ /* #define DEBUG_SELECTORS */
#ifdef linux #ifdef linux
#define DEV_ZERO #define DEV_ZERO
@ -31,7 +37,6 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#endif #endif
#if defined(__NetBSD__) || defined(__FreeBSD__) #if defined(__NetBSD__) || defined(__FreeBSD__)
#include <machine/segments.h>
#define PAGE_SIZE getpagesize() #define PAGE_SIZE getpagesize()
#define MODIFY_LDT_CONTENTS_DATA 0 #define MODIFY_LDT_CONTENTS_DATA 0
#define MODIFY_LDT_CONTENTS_STACK 1 #define MODIFY_LDT_CONTENTS_STACK 1
@ -214,8 +219,7 @@ IPCCopySelector(int i_old, unsigned long new, int swap_type)
* This is very bad!!! This function is implemented for Windows * This is very bad!!! This function is implemented for Windows
* compatibility only. Do not call this from the emulation library. * compatibility only. Do not call this from the emulation library.
*/ */
unsigned int WORD AllocSelector(WORD old_selector)
AllocSelector(unsigned int old_selector)
{ {
SEGDESC *s_new, *s_old; SEGDESC *s_new, *s_old;
int i_new, i_old; int i_new, i_old;
@ -382,7 +386,7 @@ unsigned int PrestoChangoSelector(unsigned src_selector, unsigned dst_selector)
/********************************************************************** /**********************************************************************
* AllocCStoDSAlias * AllocCStoDSAlias
*/ */
AllocDStoCSAlias(unsigned int ds_selector) WORD AllocDStoCSAlias(WORD ds_selector)
{ {
unsigned int cs_selector; unsigned int cs_selector;
@ -396,7 +400,7 @@ AllocDStoCSAlias(unsigned int ds_selector)
/********************************************************************** /**********************************************************************
* FreeSelector * FreeSelector
*/ */
unsigned int FreeSelector(unsigned int sel) WORD FreeSelector(WORD sel)
{ {
SEGDESC *s; SEGDESC *s;
int sel_idx; int sel_idx;
@ -694,10 +698,9 @@ GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal)
/********************************************************************** /**********************************************************************
* GetDOSEnvironment * GetDOSEnvironment
*/ */
void * LPSTR GetDOSEnvironment(void)
GetDOSEnvironment()
{ {
return EnvironmentSelector->base_addr; return (LPSTR) EnvironmentSelector->base_addr;
} }
/********************************************************************** /**********************************************************************
@ -916,3 +919,4 @@ CreateSelectors(struct w_files * wpnt)
return selectors; return selectors;
} }
#endif /* ifndef WINELIB */

View File

@ -1,6 +1,8 @@
#include <signal.h> #ifndef WINELIB
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <time.h> #include <time.h>
#if defined(__NetBSD__) || defined(__FreeBSD__) #if defined(__NetBSD__) || defined(__FreeBSD__)
@ -8,14 +10,14 @@
#else #else
#include <syscall.h> #include <syscall.h>
#endif #endif
#include <signal.h>
#include <errno.h>
#ifdef linux #ifdef linux
#include <linux/sched.h> #include <linux/sched.h>
#include <asm/system.h> #include <asm/system.h>
#endif #endif
#include "wine.h" #include "wine.h"
#include "segmem.h" #include "segmem.h"
#include "prototypes.h"
char * cstack[4096]; char * cstack[4096];
struct sigaction segv_act; struct sigaction segv_act;
@ -40,92 +42,145 @@ wine_sigaction(int sig,struct sigaction * new, struct sigaction * old)
} }
#ifdef linux #ifdef linux
static void win_fault(int signal, struct sigcontext_struct context){ static void win_fault(int signal, struct sigcontext_struct context)
struct sigcontext_struct *scp = &context; {
struct sigcontext_struct *scp = &context;
#else #else
static void win_fault(int signal, int code, struct sigcontext *scp){ static void win_fault(int signal, int code, struct sigcontext *scp)
{
#endif #endif
unsigned char * instr; unsigned char * instr;
unsigned char intno; unsigned int * dump;
unsigned int * dump; int i;
int i;
/* First take care of a few preliminaries */ /* First take care of a few preliminaries */
#ifdef linux #ifdef linux
if(signal != SIGSEGV) exit(1); if(signal != SIGSEGV)
if((scp->sc_cs & 7) != 7){ exit(1);
if((scp->sc_cs & 7) != 7)
{
#endif #endif
#if defined(__NetBSD__) || defined(__FreeBSD__) #if defined(__NetBSD__) || defined(__FreeBSD__)
/* set_es(0x27); set_ds(0x27); */ /* set_es(0x27); set_ds(0x27); */
if(signal != SIGBUS) exit(1); if(signal != SIGBUS)
if(scp->sc_cs == 0x1f){
#endif
fprintf(stderr,
"Segmentation fault in Wine program (%x:%x)."
" Please debug\n",
scp->sc_cs, scp->sc_eip);
goto oops;
};
/* Now take a look at the actual instruction where the program
bombed */
instr = (char *) SAFEMAKEPTR(scp->sc_cs, scp->sc_eip);
if(*instr != 0xcd) {
fprintf(stderr,
"Unexpected Windows program segfault"
" - opcode = %x\n", *instr);
#if 0
return;
#else
goto oops;
#endif
};
instr++;
intno = *instr;
switch(intno){
case 0x21:
if(!do_int21(scp)) goto oops;
break;
case 0x11:
scp->sc_eax = (scp->sc_eax & 0xffff0000L) | DOS_GetEquipment();
break;
case 0x12:
scp->sc_eax = (scp->sc_eax & 0xffff0000L) | 640L;
break; /* get base mem size */
case 0x1A:
if(!do_int1A(scp)) goto oops;
break;
default:
fprintf(stderr,"Unexpected Windows interrupt %x\n", intno);
goto oops;
};
/* OK, done handling the interrupt */
scp->sc_eip += 2; /* Bypass the int instruction */
return;
oops:
fprintf(stderr,"In win_fault %x:%x\n", scp->sc_cs, scp->sc_eip);
#ifdef linux
wine_debug(scp); /* Enter our debugger */
#else
fprintf(stderr,"Stack: %x:%x\n", scp->sc_ss, scp->sc_esp);
dump = (int*) scp;
for(i=0; i<22; i++)
{
fprintf(stderr," %8.8x", *dump++);
if ((i % 8) == 7)
fprintf(stderr,"\n");
}
fprintf(stderr,"\n");
exit(1); exit(1);
if(scp->sc_cs == 0x1f)
{
#endif
fprintf(stderr,
"Segmentation fault in Wine program (%x:%x)."
" Please debug\n",
scp->sc_cs, scp->sc_eip);
goto oops;
};
/* Now take a look at the actual instruction where the program
bombed */
instr = (unsigned char *) SAFEMAKEPTR(scp->sc_cs, scp->sc_eip);
switch(*instr)
{
case 0xcd: /* int <XX> */
instr++;
switch(*instr)
{
case 0x10:
if(!do_int10(scp))
goto oops;
break;
case 0x11:
scp->sc_eax = (scp->sc_eax & 0xffff0000L) | DOS_GetEquipment();
break;
case 0x12:
scp->sc_eax = (scp->sc_eax & 0xffff0000L) | 640L;
break; /* get base mem size */
case 0x1A:
if(!do_int1A(scp))
goto oops;
break;
case 0x21:
if (!do_int21(scp))
goto oops;
break;
case 0x22:
scp->sc_eax = 0x1234;
scp->sc_ebx = 0x5678;
scp->sc_ecx = 0x9abc;
scp->sc_edx = 0xdef0;
break;
case 0x25:
if (!do_int25(scp))
goto oops;
break;
case 0x26:
if (!do_int26(scp))
goto oops;
break;
default:
fprintf(stderr,"Unexpected Windows interrupt %x\n", *instr);
goto oops;
}
scp->sc_eip += 2; /* Bypass the int instruction */
break;
case 0xec: /* inb al,dx */
inportb(scp);
scp->sc_eip++;
break;
case 0xed: /* in ax,dx */
inport(scp);
scp->sc_eip++;
break;
case 0xee: /* outb dx,al */
outportb(scp);
scp->sc_eip++;
break;
case 0xef: /* out dx,ax */
outport(scp);
scp->sc_eip++;
break;
default:
fprintf(stderr, "Unexpected Windows program segfault"
" - opcode = %x\n", *instr);
goto oops;
}
/* OK, done handling the interrupt */
return;
oops:
fprintf(stderr,"In win_fault %x:%x\n", scp->sc_cs, scp->sc_eip);
#ifdef linux
wine_debug(scp); /* Enter our debugger */
#else
fprintf(stderr,"Stack: %x:%x\n", scp->sc_ss, scp->sc_esp);
dump = (int*) scp;
for(i=0; i<22; i++)
{
fprintf(stderr," %8.8x", *dump++);
if ((i % 8) == 7)
fprintf(stderr,"\n");
}
fprintf(stderr,"\n");
exit(1);
#endif #endif
} }
int int init_wine_signals(void)
init_wine_signals(){ {
#ifdef linux #ifdef linux
segv_act.sa_handler = (__sighandler_t) win_fault; segv_act.sa_handler = (__sighandler_t) win_fault;
/* Point to the top of the stack, minus 4 just in case, and make /* Point to the top of the stack, minus 4 just in case, and make
@ -155,3 +210,4 @@ init_wine_signals(){
#endif #endif
} }
#endif /* ifndef WINELIB */

View File

@ -49,7 +49,6 @@ HINSTANCE hSysRes;
static char *DLL_Extensions[] = { "dll", "exe", NULL }; static char *DLL_Extensions[] = { "dll", "exe", NULL };
static char *EXE_Extensions[] = { "exe", NULL }; static char *EXE_Extensions[] = { "exe", NULL };
static char *WinePath = NULL;
FILE *SpyFp = NULL; FILE *SpyFp = NULL;
@ -137,7 +136,7 @@ HINSTANCE LoadImage(char *modulename, int filetype)
if (FindFile(buffer, sizeof(buffer), modulename, (filetype == EXE ? if (FindFile(buffer, sizeof(buffer), modulename, (filetype == EXE ?
EXE_Extensions : DLL_Extensions), WindowsPath) ==NULL) EXE_Extensions : DLL_Extensions), WindowsPath) ==NULL)
{ {
fprintf(stderr,"LoadImage: I can't find %s !\n",modulename); fprintf(stderr, "LoadImage: I can't find %s.dll | %s.exe !\n",modulename, modulename);
return (HINSTANCE) NULL; return (HINSTANCE) NULL;
} }
fprintf(stderr,"LoadImage: loading %s (%s)\n", modulename, buffer); fprintf(stderr,"LoadImage: loading %s (%s)\n", modulename, buffer);
@ -155,6 +154,7 @@ HINSTANCE LoadImage(char *modulename, int filetype)
wpnt1->next = wpnt; wpnt1->next = wpnt;
}; };
wpnt->next = NULL; wpnt->next = NULL;
wpnt->resnamtab = (RESNAMTAB *) -1;
/* /*
* Open file for reading. * Open file for reading.
@ -248,8 +248,6 @@ HINSTANCE LoadImage(char *modulename, int filetype)
*/ */
for(i=0; i<wpnt->ne_header->n_mod_ref_tab; i++){ for(i=0; i<wpnt->ne_header->n_mod_ref_tab; i++){
char buff[14]; char buff[14];
char buff2[256];
int fd, j;
GetModuleName(wpnt, i + 1, buff); GetModuleName(wpnt, i + 1, buff);
#ifndef WINELIB #ifndef WINELIB
@ -265,37 +263,26 @@ return(wpnt->hinstance);
} }
#ifndef WINELIB
/********************************************************************** /**********************************************************************
* main * main
*/ */
_WinMain(int argc, char **argv) int _WinMain(int argc, char **argv)
{ {
int segment; int segment;
char *p; char *p;
char *sysresname; char *sysresname;
char filename[100]; char filename[100];
char syspath[256];
char exe_path[256];
#ifdef WINESTAT #ifdef WINESTAT
char * cp; char * cp;
#endif #endif
struct w_files * wpnt; struct w_files * wpnt;
int cs_reg, ds_reg, ss_reg, ip_reg, sp_reg; int cs_reg, ds_reg, ss_reg, ip_reg, sp_reg;
int i;
int rv; int rv;
Argc = argc - 1; Argc = argc - 1;
Argv = argv + 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 ) { if (LoadImage(Argv[0], EXE) == (HINSTANCE) NULL ) {
fprintf(stderr, "wine: can't find %s!.\n", Argv[0]); fprintf(stderr, "wine: can't find %s!.\n", Argv[0]);
exit(1); exit(1);
@ -393,6 +380,7 @@ void InitializeLoadedDLLs()
} }
} }
} }
#endif
/********************************************************************** /**********************************************************************
@ -402,10 +390,8 @@ char *
GetImportedName(int fd, struct mz_header_s *mz_header, GetImportedName(int fd, struct mz_header_s *mz_header,
struct ne_header_s *ne_header, int name_offset, char *buffer) struct ne_header_s *ne_header, int name_offset, char *buffer)
{ {
char *p;
int length; int length;
int status; int status;
int i;
status = lseek(fd, mz_header->ne_offset + ne_header->iname_tab_offset + status = lseek(fd, mz_header->ne_offset + ne_header->iname_tab_offset +
name_offset, SEEK_SET); name_offset, SEEK_SET);
@ -426,7 +412,6 @@ GetModuleName(struct w_files * wpnt, int index, char *buffer)
int fd = wpnt->fd; int fd = wpnt->fd;
struct mz_header_s *mz_header = wpnt->mz_header; struct mz_header_s *mz_header = wpnt->mz_header;
struct ne_header_s *ne_header = wpnt->ne_header; struct ne_header_s *ne_header = wpnt->ne_header;
char *p;
int length; int length;
WORD name_offset, status; WORD name_offset, status;
int i; int i;
@ -714,16 +699,4 @@ FixupSegment(struct w_files * wpnt, int segment_num)
return 0; return 0;
} }
/**********************************************************************
* GetProcAddress
*/
FARPROC GetProcAddress(HINSTANCE hinstance, char *proc_name)
{
if ((int) proc_name & 0xffff0000)
printf("GetProcAddress: %#04x, '%s'\n", hinstance, proc_name);
else
printf("GetProcAddress: %#04x, %d\n", hinstance, (int) proc_name);
return NULL;
}
#endif #endif

View File

@ -1,8 +1,11 @@
static char RCSId[] = "$Id: global.c,v 1.2 1993/07/04 04:04:21 root Exp root $"; static char RCSId[] = "$Id: global.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#define GLOBAL_SOURCE
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "prototypes.h" #include "prototypes.h"
#include "heap.h" #include "heap.h"
#include "segmem.h" #include "segmem.h"
@ -153,7 +156,7 @@ GlobalGetFreeSegments(unsigned int flags, int n_segments)
/********************************************************************** /**********************************************************************
* GlobalAlloc * GlobalAlloc
*/ */
unsigned int HANDLE
GlobalAlloc(unsigned int flags, unsigned long size) GlobalAlloc(unsigned int flags, unsigned long size)
{ {
GDESC *g; GDESC *g;
@ -258,7 +261,7 @@ GlobalAlloc(unsigned int flags, unsigned long size)
* Windows programs will pass a handle in the "block" parameter, but * Windows programs will pass a handle in the "block" parameter, but
* this function will also accept a 32-bit address. * this function will also accept a 32-bit address.
*/ */
unsigned int HANDLE
GlobalFree(unsigned int block) GlobalFree(unsigned int block)
{ {
GDESC *g; GDESC *g;
@ -269,18 +272,7 @@ GlobalFree(unsigned int block)
/* /*
* Find GDESC for this block. * Find GDESC for this block.
*/ */
if (block & 0xffff0000) g = GlobalGetGDesc(block);
{
for (g = GlobalList; g != NULL; g = g->next)
if (g->handle > 0 && (unsigned int) g->addr == block)
break;
}
else
{
for (g = GlobalList; g != NULL; g = g->next)
if (g->handle == block)
break;
}
if (g == NULL) if (g == NULL)
return block; return block;
@ -556,12 +548,7 @@ GlobalReAlloc(unsigned int block, unsigned int new_size, unsigned int flags)
/* /*
* Find GDESC for this block. * Find GDESC for this block.
*/ */
for (g = GlobalList; g != NULL; g = g->next) g = GlobalGetGDesc(block);
{
if (g->handle == block)
break;
}
if (g == NULL) if (g == NULL)
return 0; return 0;
@ -733,6 +720,70 @@ GlobalHandleFromPointer(void *block)
else else
return g->handle; return g->handle;
} }
/**********************************************************************
* GetFreeSpace (kernel.169)
*/
DWORD GetFreeSpace(UINT wFlags)
/* windows 3.1 doesn't use the wFlags parameter !!
(so I won't either) */
{
GDESC *g;
unsigned char free_map[512];
unsigned int max_selector_used = 0;
unsigned int i;
unsigned int selector;
int total_free;
/*
* Initialize free list to all items not controlled by GlobalAlloc()
*/
for (i = 0; i < 512; i++)
free_map[i] = -1;
/*
* Traverse table looking for used and free selectors.
*/
for (g = GlobalList; g != NULL; g = g->next)
{
/*
* Check for free segments.
*/
if (g->sequence == -1)
{
free_map[g->handle >> 3] = 1;
if (g->handle > max_selector_used)
max_selector_used = g->handle;
}
/*
* Check for heap allocated segments.
*/
else if (g->handle == 0)
{
selector = (unsigned int) g->addr >> 16;
free_map[selector >> 3] = 0;
if (selector > max_selector_used)
max_selector_used = selector;
}
}
/*
* All segments past the biggest selector used are free.
*/
for (i = (max_selector_used >> 3) + 1; i < 512; i++)
free_map[i] = 1;
/*
* Add up the total free segments (obviously this amount of memory
may not be contiguous, use GlobalCompact to get largest contiguous
memory available).
*/
total_free=0;
for (i = 0; i < 512; i++)
if (free_map[i] == 1)
total_free++;
return total_free << 16;
}

View File

@ -3,17 +3,13 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "prototypes.h" #include "prototypes.h"
#include "segmem.h" #include "segmem.h"
#include "heap.h" #include "heap.h"
#include "regfunc.h" #include "regfunc.h"
typedef struct heap_local_heap_s /* #define DEBUG_HEAP */
{
struct heap_local_heap_s *next;
MDESC *free_list;
unsigned short selector;
} LHEAP;
LHEAP *LocalHeaps = NULL; LHEAP *LocalHeaps = NULL;
@ -23,6 +19,9 @@ LHEAP *LocalHeaps = NULL;
void void
HEAP_Init(MDESC **free_list, void *start, int length) HEAP_Init(MDESC **free_list, void *start, int length)
{ {
if (length < 2 * sizeof(MDESC))
return;
*free_list = (MDESC *) start; *free_list = (MDESC *) start;
(*free_list)->prev = NULL; (*free_list)->prev = NULL;
(*free_list)->next = NULL; (*free_list)->next = NULL;
@ -302,8 +301,6 @@ HEAP_LocalFindHeap(unsigned short owner)
return NULL; return NULL;
} }
#define LOCALHEAP() (&HEAP_LocalFindHeap(Segments[Stack16Frame[11] >> 3].owner)->free_list)
/********************************************************************** /**********************************************************************
* HEAP_LocalInit * HEAP_LocalInit
*/ */
@ -316,43 +313,47 @@ HEAP_LocalInit(unsigned short owner, void *start, int length)
printf("HEAP_LocalInit: owner %04x, start %08x, length %04x\n", printf("HEAP_LocalInit: owner %04x, start %08x, length %04x\n",
owner, start, length); owner, start, length);
#endif #endif
if (length < 2 * sizeof(MDESC))
return;
lh = (LHEAP *) malloc(sizeof(*lh)); lh = (LHEAP *) malloc(sizeof(*lh));
if (lh == NULL) if (lh == NULL)
return; return;
lh->selector = owner; lh->next = LocalHeaps;
lh->next = LocalHeaps; lh->selector = owner;
lh->local_table = NULL;
HEAP_Init(&lh->free_list, start, length); HEAP_Init(&lh->free_list, start, length);
LocalHeaps = lh; LocalHeaps = lh;
} }
/********************************************************************** /**********************************************************************
* LocalAlloc * WIN16_LocalAlloc
*/ */
void * void *
LocalAlloc(int flags, int bytes) WIN16_LocalAlloc(int flags, int bytes)
{ {
void *m; void *m;
#ifdef DEBUG_HEAP #ifdef DEBUG_HEAP
printf("LocalAlloc: flags %x, bytes %d\n", flags, bytes); printf("WIN16_LocalAlloc: flags %x, bytes %d\n", flags, bytes);
printf(" called from segment %04x\n", Stack16Frame[11]); printf(" called from segment %04x\n", Stack16Frame[11]);
#endif #endif
m = HEAP_Alloc(LOCALHEAP(), flags, bytes); m = HEAP_Alloc(LOCALHEAP(), flags, bytes);
#ifdef DEBUG_HEAP #ifdef DEBUG_HEAP
printf("LocalAlloc: returning %x\n", (int) m); printf("WIN16_LocalAlloc: returning %x\n", (int) m);
#endif #endif
return m; return m;
} }
/********************************************************************** /**********************************************************************
* LocalCompact * WIN16_LocalCompact
*/ */
int int
LocalCompact(int min_free) WIN16_LocalCompact(int min_free)
{ {
MDESC *m; MDESC *m;
int max_block; int max_block;
@ -366,10 +367,10 @@ LocalCompact(int min_free)
} }
/********************************************************************** /**********************************************************************
* LocalFlags * WIN16_LocalFlags
*/ */
unsigned int unsigned int
LocalFlags(unsigned int handle) WIN16_LocalFlags(unsigned int handle)
{ {
MDESC *m; MDESC *m;
@ -382,10 +383,10 @@ LocalFlags(unsigned int handle)
} }
/********************************************************************** /**********************************************************************
* LocalFree * WIN16_LocalFree
*/ */
unsigned int unsigned int
LocalFree(unsigned int handle) WIN16_LocalFree(unsigned int handle)
{ {
unsigned int addr; unsigned int addr;
@ -397,12 +398,12 @@ LocalFree(unsigned int handle)
} }
/********************************************************************** /**********************************************************************
* LocalInit * WIN16_LocalInit
*/ */
unsigned int unsigned int
LocalInit(unsigned int segment, unsigned int start, unsigned int end) WIN16_LocalInit(unsigned int segment, unsigned int start, unsigned int end)
{ {
unsigned short owner = Segments[Stack16Frame[11] >> 3].owner; unsigned short owner = HEAP_OWNER;
LHEAP *lh = HEAP_LocalFindHeap(owner); LHEAP *lh = HEAP_LocalFindHeap(owner);
if (segment == 0) if (segment == 0)
@ -426,10 +427,10 @@ LocalInit(unsigned int segment, unsigned int start, unsigned int end)
} }
/********************************************************************** /**********************************************************************
* LocalLock * WIN16_LocalLock
*/ */
void * void *
LocalLock(unsigned int handle) WIN16_LocalLock(unsigned int handle)
{ {
MDESC *m; MDESC *m;
@ -443,10 +444,10 @@ LocalLock(unsigned int handle)
} }
/********************************************************************** /**********************************************************************
* LocalReAlloc * WIN16_LocalReAlloc
*/ */
void * void *
LocalReAlloc(unsigned int handle, int flags, int bytes) WIN16_LocalReAlloc(unsigned int handle, int flags, int bytes)
{ {
void *m; void *m;
@ -458,10 +459,10 @@ LocalReAlloc(unsigned int handle, int flags, int bytes)
} }
/********************************************************************** /**********************************************************************
* LocalSize * WIN16_LocalSize
*/ */
unsigned int unsigned int
LocalSize(unsigned int handle) WIN16_LocalSize(unsigned int handle)
{ {
MDESC *m; MDESC *m;
@ -474,10 +475,10 @@ LocalSize(unsigned int handle)
} }
/********************************************************************** /**********************************************************************
* LocalUnlock * WIN16_LocalUnlock
*/ */
unsigned int unsigned int
LocalUnlock(unsigned int handle) WIN16_LocalUnlock(unsigned int handle)
{ {
MDESC *m; MDESC *m;
@ -491,3 +492,49 @@ LocalUnlock(unsigned int handle)
return 0; return 0;
} }
/**********************************************************************
* GetFreeSystemResources (user.284)
*/
#define USERRESOURCES 2
#define GDIRESOURCES 1
#define SYSTEMRESOURCES 0
#include <user.h>
#include <gdi.h>
WORD GetFreeSystemResources(WORD SystemResourceType)
{
unsigned int GdiFree=0,GdiResult=0;
unsigned int UserFree=0,UserResult=0;
unsigned int result=0;
MDESC *m;
printf("GetFreeSystemResources(%u)\n",SystemResourceType);
switch(SystemResourceType) {
case(USERRESOURCES):
for (m = USER_Heap; m != NULL; m = m->next) /* add up free area in heap */
UserFree += m->length;
result=(UserFree*100)/65516; /* 65516 == 64K */
break;
case(GDIRESOURCES):
for (m = GDI_Heap; m != NULL; m = m->next)
GdiFree += m->length;
result=(GdiFree*100)/65516;
break;
case(SYSTEMRESOURCES):
for (m = USER_Heap; m != NULL; m = m->next)
UserFree += m->length;
UserResult=(UserFree*100)/65516;
for (m = GDI_Heap; m != NULL; m = m->next)
GdiFree += m->length;
GdiResult=(GdiFree*100)/65516;
result=(UserResult < GdiResult) ? UserResult:GdiResult;
break;
default:
result=0;
break;
}
return(result);
}

View File

@ -3,6 +3,7 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1994";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "prototypes.h" #include "prototypes.h"
#include "heap.h" #include "heap.h"
#include "segmem.h" #include "segmem.h"

View File

@ -16,9 +16,9 @@ SRCS = \
message.c \ message.c \
profile.c \ profile.c \
rect.c \ rect.c \
resource.c \
sound.c \ sound.c \
spy.c \ spy.c \
stress.c \
user.c \ user.c \
winsocket.c winsocket.c

View File

@ -7,13 +7,6 @@
/* /*
* Current limitations: * Current limitations:
* *
* - This code should work fine when called from the emulation library,
* but probably not when called from the Windows program. The reason
* is that everything is allocated on the current local heap, instead
* of taking into account the DS register. Correcting this will also
* require some changes in the local heap management to bring it closer
* to Windows.
*
* - The code assumes that LocalAlloc() returns a block aligned on a * - The code assumes that LocalAlloc() returns a block aligned on a
* 4-bytes boundary (because of the shifting done in HANDLETOATOM). * 4-bytes boundary (because of the shifting done in HANDLETOATOM).
* If this is not the case, the allocation code will have to be changed. * If this is not the case, the allocation code will have to be changed.
@ -30,22 +23,35 @@
* aligned block. Needed to test the Library. * aligned block. Needed to test the Library.
*/ */
#include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include "user.h" #include "user.h"
#include "atom.h" #include "atom.h"
#include "prototypes.h"
#ifndef WINELIB
#include "heap.h"
#endif
#define DEFAULT_ATOMTABLE_SIZE 37 #define DEFAULT_ATOMTABLE_SIZE 37
#define MIN_STR_ATOM 0xc000 #define MIN_STR_ATOM 0xc000
#ifdef WINELIB
#define ATOMTOHANDLE
#define HANDLETOATOM
#else
#define ATOMTOHANDLE(atom) ((HANDLE)(atom) << 2) #define ATOMTOHANDLE(atom) ((HANDLE)(atom) << 2)
#define HANDLETOATOM(handle) ((ATOM)(0xc000 | ((handle) >> 2))) #define HANDLETOATOM(handle) ((ATOM)(0xc000 | ((handle) >> 2)))
#endif
#ifdef WINELIB
static ATOMTABLE * localTable = NULL; static ATOMTABLE * localTable = NULL;
#undef LOCALATOMTABLE
#define LOCALATOMTABLE() &localTable
#endif
static ATOMTABLE * globalTable = NULL; static ATOMTABLE * globalTable = NULL;
@ -56,18 +62,31 @@ static BOOL ATOM_InitTable( ATOMTABLE ** table, WORD entries )
{ {
int i; int i;
HANDLE handle; HANDLE handle;
if (table == &globalTable)
{
handle = USER_HEAP_ALLOC(LMEM_MOVEABLE, sizeof(ATOMTABLE) +
(entries-1) * sizeof(HANDLE) );
if (!handle)
return FALSE;
*table = (ATOMTABLE *) USER_HEAP_ADDR( handle );
}
else
{
handle = LocalAlign ( LMEM_MOVEABLE, sizeof(ATOMTABLE) +
(entries-1) * sizeof(HANDLE) );
if (!handle)
return FALSE;
*table = (ATOMTABLE *) LocalLock( handle );
}
handle = LocalAlign ( LMEM_MOVEABLE, sizeof(ATOMTABLE) +
(entries-1) * sizeof(HANDLE) );
if (!handle) return FALSE;
*table = (ATOMTABLE *) LocalLock( handle );
(*table)->size = entries; (*table)->size = entries;
for (i = 0; i < entries; i++) (*table)->entries[i] = 0; for (i = 0; i < entries; i++)
(*table)->entries[i] = 0;
return TRUE; return TRUE;
} }
/*********************************************************************** /***********************************************************************
* ATOM_Init * ATOM_Init
* *
@ -87,7 +106,11 @@ BOOL ATOM_Init()
*/ */
static ATOMENTRY * ATOM_MakePtr( ATOMTABLE * table, HANDLE handle ) static ATOMENTRY * ATOM_MakePtr( ATOMTABLE * table, HANDLE handle )
{ {
#ifdef WINELIB
return (ATOMENTRY *) LocalLock (handle);
#else
return (ATOMENTRY *) (((int)table & 0xffff0000) | (int)handle); return (ATOMENTRY *) (((int)table & 0xffff0000) | (int)handle);
#endif
} }
@ -132,8 +155,18 @@ static ATOM ATOM_AddAtom( ATOMTABLE * table, LPCSTR str )
} }
entry = entryPtr->next; entry = entryPtr->next;
} }
if (table == globalTable)
{
entry = (int) USER_HEAP_ALLOC(LMEM_MOVEABLE,
sizeof(ATOMENTRY)+len-1 ) & 0xffff;
}
else
{
entry = (int) LocalAlign(LMEM_MOVEABLE,
sizeof(ATOMENTRY)+len-1 ) & 0xffff;
}
entry = (int)LocalAlign( LMEM_MOVEABLE, sizeof(ATOMENTRY)+len-1 ) & 0xffff;
if (!entry) return 0; if (!entry) return 0;
entryPtr = ATOM_MakePtr( table, entry ); entryPtr = ATOM_MakePtr( table, entry );
entryPtr->next = table->entries[hash]; entryPtr->next = table->entries[hash];
@ -173,7 +206,10 @@ static ATOM ATOM_DeleteAtom( ATOMTABLE * table, ATOM atom )
if (--entryPtr->refCount == 0) if (--entryPtr->refCount == 0)
{ {
*prevEntry = entryPtr->next; *prevEntry = entryPtr->next;
USER_HEAP_FREE( entry ); if (table == globalTable)
USER_HEAP_FREE(entry);
else
LocalFree( entry );
} }
return 0; return 0;
} }
@ -246,7 +282,7 @@ static WORD ATOM_GetAtomName( ATOMTABLE * table, ATOM atom,
*/ */
BOOL InitAtomTable( WORD entries ) BOOL InitAtomTable( WORD entries )
{ {
return ATOM_InitTable( &localTable, entries ); return ATOM_InitTable( LOCALATOMTABLE(), entries );
} }
@ -265,8 +301,8 @@ HANDLE GetAtomHandle( ATOM atom )
*/ */
ATOM AddAtom( LPCSTR str ) ATOM AddAtom( LPCSTR str )
{ {
if (!localTable) InitAtomTable( DEFAULT_ATOMTABLE_SIZE ); if (!*LOCALATOMTABLE()) InitAtomTable( DEFAULT_ATOMTABLE_SIZE );
return ATOM_AddAtom( localTable, str ); return ATOM_AddAtom( *LOCALATOMTABLE(), str );
} }
@ -275,8 +311,8 @@ ATOM AddAtom( LPCSTR str )
*/ */
ATOM DeleteAtom( ATOM atom ) ATOM DeleteAtom( ATOM atom )
{ {
if (!localTable) InitAtomTable( DEFAULT_ATOMTABLE_SIZE ); if (!*LOCALATOMTABLE()) InitAtomTable( DEFAULT_ATOMTABLE_SIZE );
return ATOM_DeleteAtom( localTable, atom ); return ATOM_DeleteAtom( *LOCALATOMTABLE(), atom );
} }
@ -285,8 +321,8 @@ ATOM DeleteAtom( ATOM atom )
*/ */
ATOM FindAtom( LPCSTR str ) ATOM FindAtom( LPCSTR str )
{ {
if (!localTable) InitAtomTable( DEFAULT_ATOMTABLE_SIZE ); if (!*LOCALATOMTABLE()) InitAtomTable( DEFAULT_ATOMTABLE_SIZE );
return ATOM_FindAtom( localTable, str ); return ATOM_FindAtom( *LOCALATOMTABLE(), str );
} }
@ -295,8 +331,8 @@ ATOM FindAtom( LPCSTR str )
*/ */
WORD GetAtomName( ATOM atom, LPSTR buffer, short count ) WORD GetAtomName( ATOM atom, LPSTR buffer, short count )
{ {
if (!localTable) InitAtomTable( DEFAULT_ATOMTABLE_SIZE ); if (!*LOCALATOMTABLE()) InitAtomTable( DEFAULT_ATOMTABLE_SIZE );
return ATOM_GetAtomName( localTable, atom, buffer, count ); return ATOM_GetAtomName( *LOCALATOMTABLE(), atom, buffer, count );
} }

View File

@ -10,6 +10,8 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994";
#define DEBUG_CLIPBOARD #define DEBUG_CLIPBOARD
*/ */
#include <stdlib.h>
#include <stdio.h>
#include <windows.h> #include <windows.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>

View File

@ -8,11 +8,14 @@
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <ctype.h>
#include <sys/stat.h> #include <sys/stat.h>
#if defined(__NetBSD__) || defined(__FreeBSD__) #if defined(__NetBSD__) || defined(__FreeBSD__)
#include <errno.h> #include <errno.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif
#include <unistd.h>
#include "wine.h" #include "wine.h"
#include "windows.h" #include "windows.h"
@ -38,7 +41,7 @@ void Comm_DeInit(void);
void Comm_Init(void) void Comm_Init(void)
{ {
int x, serial = 0, parallel = 0; int x, serial = 0, parallel = 0;
char option[10], temp[256], *ptr; char option[10], temp[256];
struct stat st; struct stat st;
for (x=0; x!=MAX_PORTS; x++) { for (x=0; x!=MAX_PORTS; x++) {
@ -145,10 +148,10 @@ int BuildCommDCB(LPSTR device, DCB FAR *lpdcb)
/* 012345 */ /* 012345 */
int port; int port;
char *ptr, *ptr2, temp[256],temp2[10]; char *ptr, temp[256];
#ifdef DEBUG_COMM #ifdef DEBUG_COMM
fprintf(stderr,"BuildCommDCB: (%s), ptr %d\n", device, lpdcb); fprintf(stderr,"BuildCommDCB: (%s), ptr %d\n", device, (long) lpdcb);
#endif #endif
commerror = 0; commerror = 0;
@ -296,8 +299,6 @@ fprintf(stderr,"OpenComm: %s, %d, %d\n", device, cbInQueue, cbOutQueue);
int CloseComm(int fd) int CloseComm(int fd)
{ {
int status;
#ifdef DEBUG_COMM #ifdef DEBUG_COMM
fprintf(stderr,"CloseComm: fd %d\n", fd); fprintf(stderr,"CloseComm: fd %d\n", fd);
#endif #endif
@ -477,7 +478,7 @@ int SetCommState(DCB FAR *lpdcb)
struct termios port; struct termios port;
#ifdef DEBUG_COMM #ifdef DEBUG_COMM
fprintf(stderr,"SetCommState: fd %d, ptr %d\n", lpdcb->Id, lpdcb); fprintf(stderr,"SetCommState: fd %d, ptr %d\n", lpdcb->Id, (long) lpdcb);
#endif #endif
if (tcgetattr(lpdcb->Id, &port) == -1) { if (tcgetattr(lpdcb->Id, &port) == -1) {
@ -666,7 +667,7 @@ int GetCommState(int fd, DCB FAR *lpdcb)
struct termios port; struct termios port;
#ifdef DEBUG_COMM #ifdef DEBUG_COMM
fprintf(stderr,"GetCommState: fd %d, ptr %d\n", fd, lpdcb); fprintf(stderr,"GetCommState: fd %d, ptr %d\n", fd, (long) lpdcb);
#endif #endif
if (tcgetattr(fd, &port) == -1) { if (tcgetattr(fd, &port) == -1) {
@ -836,7 +837,7 @@ int ReadComm(int fd, LPSTR lpvBuf, int cbRead)
struct DosDeviceStruct *ptr; struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM #ifdef DEBUG_COMM
fprintf(stderr,"ReadComm: fd %d, ptr %d, length %d\n", fd, lpvBuf, cbRead); fprintf(stderr,"ReadComm: fd %d, ptr %d, length %d\n", fd, (long) lpvBuf, cbRead);
#endif #endif
if ((ptr = GetDeviceStruct(fd)) == NULL) { if ((ptr = GetDeviceStruct(fd)) == NULL) {
@ -875,7 +876,7 @@ int WriteComm(int fd, LPSTR lpvBuf, int cbWrite)
struct DosDeviceStruct *ptr; struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM #ifdef DEBUG_COMM
fprintf(stderr,"WriteComm: fd %d, ptr %d, length %d\n", fd, lpvBuf, cbWrite); fprintf(stderr,"WriteComm: fd %d, ptr %d, length %d\n", fd, (long) lpvBuf, cbWrite);
#endif #endif
if ((ptr = GetDeviceStruct(fd)) == NULL) { if ((ptr = GetDeviceStruct(fd)) == NULL) {

View File

@ -7,14 +7,15 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993";
#define DEBUG_CURSOR #define DEBUG_CURSOR
*/ */
#include <X11/cursorfont.h>
#include <X11/Xlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <X11/cursorfont.h>
#include <X11/Xlib.h>
#include "prototypes.h" #include "prototypes.h"
#include "windows.h" #include "windows.h"
#include "win.h" #include "win.h"
@ -28,6 +29,7 @@ static HCURSOR hEmptyCursor = 0;
RECT ClipCursorRect; RECT ClipCursorRect;
extern HINSTANCE hSysRes; extern HINSTANCE hSysRes;
extern Window winHasCursor; extern Window winHasCursor;
extern int desktopX, desktopY; /* misc/main.c */
static struct { LPSTR name; HCURSOR cursor; } system_cursor[] = static struct { LPSTR name; HCURSOR cursor; } system_cursor[] =
{ {
@ -116,6 +118,11 @@ HCURSOR LoadCursor(HANDLE instance, LPSTR cursor_name)
lpcur->xcursor = XCreateFontCursor(XT_display, XC_sb_h_double_arrow); lpcur->xcursor = XCreateFontCursor(XT_display, XC_sb_h_double_arrow);
GlobalUnlock(hCursor); GlobalUnlock(hCursor);
return hCursor; return hCursor;
case IDC_SIZENWSE:
case IDC_SIZENESW:
lpcur->xcursor = XCreateFontCursor(XT_display, XC_fleur);
GlobalUnlock(hCursor);
return hCursor;
default: default:
break; break;
} }
@ -358,19 +365,10 @@ HCURSOR SetCursor(HCURSOR hCursor)
*/ */
void SetCursorPos(short x, short y) void SetCursorPos(short x, short y)
{ {
Window root, child;
int rootX, rootY;
int childX, childY;
unsigned int mousebut;
#ifdef DEBUG_CURSOR #ifdef DEBUG_CURSOR
printf("SetCursorPos // x=%d y=%d\n", x, y); printf("SetCursorPos // x=%d y=%d\n", x, y);
#endif #endif
XQueryPointer(XT_display, DefaultRootWindow(XT_display), XWarpPointer( display, None, rootWindow, 0, 0, 0, 0, x, y );
&root, &child, &rootX, &rootY, &childX, &childY, &mousebut);
XWarpPointer(XT_display, child, root, 0, 0,
DisplayWidth(XT_display, DefaultScreen(XT_display)),
DisplayHeight(XT_display, DefaultScreen(XT_display)),
(int)x, (int)y);
} }
@ -383,15 +381,19 @@ void GetCursorPos(LPPOINT lpRetPoint)
int rootX, rootY; int rootX, rootY;
int childX, childY; int childX, childY;
unsigned int mousebut; unsigned int mousebut;
if (lpRetPoint != NULL) {
XQueryPointer(XT_display, DefaultRootWindow(XT_display), if (!lpRetPoint) return;
&root, &child, &rootX, &rootY, &childX, &childY, &mousebut); if (!XQueryPointer( display, rootWindow, &root, &child,
&rootX, &rootY, &childX, &childY, &mousebut ))
lpRetPoint->x = lpRetPoint->y = 0;
else
{
lpRetPoint->x = rootX + desktopX;
lpRetPoint->y = rootY + desktopY;
}
#ifdef DEBUG_CURSOR #ifdef DEBUG_CURSOR
printf("GetCursorPos // x=%d y=%d\n", rootX, rootY); printf("GetCursorPos // x=%d y=%d\n", lpRetPoint->x, lpRetPoint->y);
#endif #endif
lpRetPoint->x = rootX;
lpRetPoint->y = rootY;
}
} }

View File

@ -10,6 +10,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <pwd.h>
#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
#if defined(__linux__) || defined(sun) #if defined(__linux__) || defined(sun)
#include <sys/vfs.h> #include <sys/vfs.h>
#endif #endif
@ -17,27 +22,23 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/mount.h> #include <sys/mount.h>
#endif #endif
#include <dirent.h>
#include "windows.h"
#include "wine.h"
#include "int21.h"
/* #include "windows.h"
#define DEBUG #include "msdos.h"
*/ #include "prototypes.h"
#include "autoconf.h"
/* #define DEBUG */
#define WINE_INI_USER "~/.winerc"
#define MAX_OPEN_DIRS 16 #define MAX_OPEN_DIRS 16
#define MAX_DOS_DRIVES 26
extern char WindowsDirectory[256], SystemDirectory[256],TempDirectory[256]; extern char WindowsDirectory[256], SystemDirectory[256],TempDirectory[256];
char WindowsPath[256]; char WindowsPath[256];
void DOS_DeInitFS(void); static int CurrentDrive = 2;
int DOS_SetDefaultDrive(int);
char *GetDirectUnixFileName(char *);
void ToDos(char *);
void ToUnix(char *);
int CurrentDrive = 2;
struct DosDriveStruct { /* eg: */ struct DosDriveStruct { /* eg: */
char *rootdir; /* /usr/windows */ char *rootdir; /* /usr/windows */
@ -47,9 +48,35 @@ struct DosDriveStruct { /* eg: */
int disabled; /* 0 */ int disabled; /* 0 */
}; };
struct DosDriveStruct DosDrives[MAX_DOS_DRIVES]; static struct DosDriveStruct DosDrives[MAX_DOS_DRIVES];
static struct dosdirent DosDirs[MAX_OPEN_DIRS];
struct dosdirent DosDirs[MAX_OPEN_DIRS]; static void ExpandTildeString(char *s)
{
struct passwd *entry;
char temp[1024], *ptr = temp;
strcpy(temp, s);
while (*ptr)
{
if (*ptr != '~') {
*s++ = *ptr++;
continue;
}
ptr++;
if ( (entry = getpwuid(getuid())) == NULL) {
continue;
}
strcpy(s, entry->pw_dir);
s += strlen(entry->pw_dir);
}
}
void ChopOffSlash(char *path)
{
if (path[strlen(path)-1] == '/' || path[strlen(path)-1] == '\\')
path[strlen(path)-1] = '\0';
}
void DOS_InitFS(void) void DOS_InitFS(void)
{ {
@ -68,10 +95,17 @@ void DOS_InitFS(void)
GetPrivateProfileString("wine", "path", "c:\\windows;c:\\windows\\system", GetPrivateProfileString("wine", "path", "c:\\windows;c:\\windows\\system",
WindowsPath, sizeof(WindowsPath), WINE_INI); WindowsPath, sizeof(WindowsPath), WINE_INI);
ChopOffSlash(WindowsDirectory);
ToDos(WindowsDirectory); ToDos(WindowsDirectory);
ChopOffSlash(SystemDirectory);
ToDos(SystemDirectory); ToDos(SystemDirectory);
ChopOffSlash(TempDirectory);
ToDos(TempDirectory); ToDos(TempDirectory);
ToDos(WindowsPath); ToDos(WindowsPath);
ExpandTildeString(WindowsPath);
for (x=0; x!=MAX_DOS_DRIVES; x++) { for (x=0; x!=MAX_DOS_DRIVES; x++) {
DosDrives[x].serialnumber = (0xEB0500L | x); DosDrives[x].serialnumber = (0xEB0500L | x);
@ -86,16 +120,15 @@ void DOS_InitFS(void)
DosDrives[x].disabled = 1; DosDrives[x].disabled = 1;
continue; continue;
} }
ExpandTildeString(temp);
if ((ptr = (char *) malloc(strlen(temp)+1)) == NULL) { if ((ptr = (char *) malloc(strlen(temp)+1)) == NULL) {
fprintf(stderr,"DOSFS: can't malloc for drive info!"); fprintf(stderr,"DOSFS: can't malloc for drive info!");
continue; continue;
} }
if (temp[strlen(temp)-1] == '/') ChopOffSlash(temp);
temp[strlen(temp)] = '\0';
DosDrives[x].rootdir = ptr; DosDrives[x].rootdir = ptr;
strcpy(DosDrives[x].rootdir, temp); strcpy(DosDrives[x].rootdir, temp);
strcpy(DosDrives[x].cwd, "/"); strcpy(DosDrives[x].cwd, "/windows/");
strcpy(DosDrives[x].label, "DRIVE-"); strcpy(DosDrives[x].label, "DRIVE-");
strcat(DosDrives[x].label, drive); strcat(DosDrives[x].label, drive);
DosDrives[x].disabled = 0; DosDrives[x].disabled = 0;
@ -130,27 +163,6 @@ void DOS_InitFS(void)
#endif #endif
} }
void DOS_DeInitFS(void)
{
int x;
for (x=0; x!=MAX_DOS_DRIVES ; x++)
if (DosDrives[x].rootdir != NULL) {
#ifdef DEBUG
fprintf(stderr, "DOSFS: %c: => %s %s %s %X %d\n",
'A'+x,
DosDrives[x].rootdir,
DosDrives[x].cwd,
DosDrives[x].label,
DosDrives[x].serialnumber,
DosDrives[x].disabled
);
free(DosDrives[x].rootdir);
#endif
}
}
WORD DOS_GetEquipment(void) WORD DOS_GetEquipment(void)
{ {
WORD equipment; WORD equipment;
@ -214,40 +226,51 @@ int DOS_GetDefaultDrive(void)
return( CurrentDrive); return( CurrentDrive);
} }
int DOS_SetDefaultDrive(int drive) void DOS_SetDefaultDrive(int drive)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"SetDefaultDrive to %c:\n",'A'+drive); fprintf(stderr,"SetDefaultDrive to %c:\n",'A'+drive);
#endif #endif
if (!DOS_ValidDrive(drive)) if (DOS_ValidDrive(drive))
return 1; CurrentDrive = drive;
CurrentDrive = drive;
} }
void ToUnix(char *s) void ToUnix(char *s)
{ {
while (*s) { /* \WINDOWS\\SYSTEM => /windows/system */
if (*s == '/')
break; char *p;
if (*s == '\\')
*s = '/'; for (p = s; *p; p++)
if (isupper(*s)) {
*s = tolower(*s); if (*p != '\\')
s++; *s++ = tolower(*p);
else {
*s++ = '/';
if (*(p+1) == '/' || *(p+1) == '\\')
p++;
}
} }
*s = '\0';
} }
void ToDos(char *s) void ToDos(char *s)
{ {
while (*s) { /* /windows//system => \WINDOWS\SYSTEM */
if (*s == '/')
*s = '\\'; char *p;
if (islower(*s)) for (p = s; *p; p++)
*s = toupper(*s); {
s++; if (*p != '/')
*s++ = toupper(*p);
else {
*s++ = '\\';
if (*s == '/' || *s == '\\')
p++;
}
} }
*s = '\0';
} }
int DOS_DisableDrive(int drive) int DOS_DisableDrive(int drive)
@ -272,9 +295,9 @@ int DOS_EnableDrive(int drive)
return 1; return 1;
} }
void GetUnixDirName(char *rootdir, char *name) static void GetUnixDirName(char *rootdir, char *name)
{ {
int filename; int filename = 1;
char *nameptr, *cwdptr; char *nameptr, *cwdptr;
cwdptr = rootdir + strlen(rootdir); cwdptr = rootdir + strlen(rootdir);
@ -299,7 +322,6 @@ void GetUnixDirName(char *rootdir, char *name)
*(cwdptr+1) = '\0'; *(cwdptr+1) = '\0';
goto next; goto next;
} }
} }
goto next; goto next;
} }
@ -330,13 +352,12 @@ void GetUnixDirName(char *rootdir, char *name)
*/ */
} }
char *GetDirectUnixFileName(char *dosfilename) char *GetUnixFileName(char *dosfilename)
{ {
/* a:\windows\system.ini => /dos/windows/system.ini */ /* a:\windows\system.ini => /dos/windows/system.ini */
static char temp[256]; char temp[256];
int drive; int drive;
char x;
if (dosfilename[1] == ':') if (dosfilename[1] == ':')
{ {
@ -349,59 +370,22 @@ char *GetDirectUnixFileName(char *dosfilename)
} else } else
drive = CurrentDrive; drive = CurrentDrive;
strcpy(temp,DosDrives[drive].rootdir); strcpy(temp, DosDrives[drive].rootdir);
strcat(temp, DosDrives[drive].cwd); strcat(temp, DosDrives[drive].cwd);
GetUnixDirName(temp + strlen(DosDrives[drive].rootdir), dosfilename); GetUnixDirName(temp + strlen(DosDrives[drive].rootdir), dosfilename);
ToUnix(temp); ToUnix(temp);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"GetDirectUnixFileName: %c:%s => %s\n",'A'+ drive, dosfilename, temp); fprintf(stderr,"GetUnixFileName: %s => %s\n", dosfilename, temp);
#endif #endif
return(temp); return(temp);
} }
char *GetUnixFileName(char *dosfilename) char *DOS_GetCurrentDir(int drive)
{
char *dirname, *unixname, workingpath[256], temp[256];
/* check if program specified a path */
if (*dosfilename == '.' || *dosfilename == '\\')
return( GetDirectUnixFileName(dosfilename) );
/* nope, lets find it */
#ifdef DEBUG
fprintf(stderr,"GetUnixFileName: %s\n",dosfilename);
#endif
strcpy(workingpath, WindowsPath);
for(dirname = strtok(workingpath, ";") ;
dirname != NULL;
dirname = strtok(NULL, ";"))
{
strcpy(temp,dirname);
if (temp[strlen(temp)-1] != '\\')
strcat(temp,"\\");
strcat(temp,dosfilename);
#ifdef DEBUG
fprintf(stderr,"trying %s\n",temp);
#endif
if ( (unixname = GetDirectUnixFileName(temp)) != NULL)
return unixname;
}
puts("FAILED!");
return NULL;
}
char *DOS_GetCurrentDir(int drive, char *dirname)
{ {
/* should return 'windows\system' */ /* should return 'WINDOWS\SYSTEM' */
char temp[256]; char temp[256];
@ -410,25 +394,29 @@ char *DOS_GetCurrentDir(int drive, char *dirname)
strcpy(temp, DosDrives[drive].cwd); strcpy(temp, DosDrives[drive].cwd);
ToDos(temp); ToDos(temp);
fprintf(stderr, "2 %s\n", temp);
if (temp[strlen(temp)-1] == '\\') ChopOffSlash(temp);
temp[strlen(temp)] = '\0';
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"DOS_GetCWD: %c:\%s",'A'+drive, temp+1); fprintf(stderr,"DOS_GetCWD: %c: %s\n",'A'+drive, temp + 1);
#endif #endif
return (temp+1); return (temp + 1);
} }
int DOS_ChangeDir(int drive, char *dirname) int DOS_ChangeDir(int drive, char *dirname)
{ {
char temp[256];
if (!DOS_ValidDrive(drive)) if (!DOS_ValidDrive(drive))
return 0; return 0;
GetUnixDirName(DosDrives[drive].cwd, dirname); strcpy(temp, dirname);
ToUnix(temp);
GetUnixDirName(DosDrives[drive].cwd, temp);
strcat(DosDrives[drive].cwd,"/"); strcat(DosDrives[drive].cwd,"/");
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"DOS_SetCWD: %c:\%s",'A'+drive, DosDrives[drive].cwd); fprintf(stderr,"DOS_SetCWD: %c: %s\n",'A'+drive, DosDrives[drive].cwd);
#endif #endif
return 1; return 1;
} }
@ -450,35 +438,9 @@ int DOS_MakeDir(int drive, char *dirname)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"DOS_MakeDir: %c:\%s => %s",'A'+drive, dirname, temp); fprintf(stderr,"DOS_MakeDir: %c:\%s => %s",'A'+drive, dirname, temp);
#endif #endif
return 1;
} }
/*
void main(void)
{
strcpy(DosDrives[0].cwd, "1/2/3/");
puts(DosDrives[0].cwd);
ChangeDir(0,"..");
puts(DosDrives[0].cwd);
ChangeDir(0,"..\\..");
puts(DosDrives[0].cwd);
ChangeDir(0,".");
puts(DosDrives[0].cwd);
ChangeDir(0,"test");
puts(DosDrives[0].cwd);
ChangeDir(0,"\\qwerty\\ab");
puts(DosDrives[0].cwd);
ChangeDir(0,"erik\\.\\bos\\..\\24");
puts(DosDrives[0].cwd);
}
*/
int DOS_GetSerialNumber(int drive, unsigned long *serialnumber) int DOS_GetSerialNumber(int drive, unsigned long *serialnumber)
{ {
if (!DOS_ValidDrive(drive)) if (!DOS_ValidDrive(drive))
@ -497,6 +459,23 @@ int DOS_SetSerialNumber(int drive, unsigned long serialnumber)
return 1; return 1;
} }
char *DOS_GetVolumeLabel(int drive)
{
if (!DOS_ValidDrive(drive))
return NULL;
return (DosDrives[drive].label);
}
int DOS_SetVolumeLabel(int drive, char *label)
{
if (!DOS_ValidDrive(drive))
return 0;
strncpy(DosDrives[drive].label, label, 8);
return 1;
}
int DOS_GetFreeSpace(int drive, long *size, long *available) int DOS_GetFreeSpace(int drive, long *size, long *available)
{ {
struct statfs info; struct statfs info;
@ -515,50 +494,39 @@ int DOS_GetFreeSpace(int drive, long *size, long *available)
return 1; return 1;
} }
char *FindFile(char *buffer, int buflen, char *rootname, char **extensions, char *FindFile(char *buffer, int buflen, char *filename, char **extensions,
char *path) char *path)
{ {
char *workingpath; char *workingpath, *dirname, *rootname, **e;
char *dirname;
DIR *d; DIR *d;
struct dirent *f; struct dirent *f;
char **e; int rootnamelen, found = 0;
int rootnamelen; struct stat filestat;
int found = 0;
if (strchr(filename, '\\') != NULL)
if (strchr(rootname, '\\') != NULL)
{ {
strncpy(buffer, GetDirectUnixFileName(rootname), buflen); strncpy(buffer, GetUnixFileName(filename), buflen);
ToUnix(buffer); ToUnix(buffer);
#ifdef DEBUG
fprintf(stderr,"FindFile: %s -> %s\n",rootname,buffer);
#endif
return buffer; return buffer;
} }
if (strchr(rootname, '/') != NULL) if (strchr(filename, '/') != NULL)
{ {
strncpy(buffer, rootname, buflen); strncpy(buffer, filename, buflen);
#ifdef DEBUG
fprintf(stderr,"FindFile: %s -> %s\n",rootname,buffer);
#endif
return buffer; return buffer;
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"FindFile: looking for %s\n",rootname); fprintf(stderr,"FindFile: looking for %s\n", filename);
#endif #endif
rootnamelen = strlen(filename);
if ((rootname = malloc(rootnamelen + 1)) == NULL)
return NULL;
strcpy(rootname, filename);
ToUnix(rootname); ToUnix(rootname);
rootnamelen = strlen(rootname); if ((workingpath = malloc(strlen(path) + 1)) == NULL)
workingpath = malloc(strlen(path) + 1);
if (workingpath == NULL)
return NULL; return NULL;
strcpy(workingpath, path); strcpy(workingpath, path);
@ -566,8 +534,8 @@ fprintf(stderr,"FindFile: looking for %s\n",rootname);
dirname != NULL; dirname != NULL;
dirname = strtok(NULL, ";")) dirname = strtok(NULL, ";"))
{ {
if (strchr(dirname, '\\')!=NULL) if (strchr(dirname, '\\') != NULL)
d = opendir( GetDirectUnixFileName(dirname) ); d = opendir( GetUnixFileName(dirname) );
else else
d = opendir( dirname ); d = opendir( dirname );
@ -583,38 +551,37 @@ fprintf(stderr,"FindFile: looking for %s\n",rootname);
{ {
if (extensions == NULL || if (extensions == NULL ||
strcasecmp(rootname, f->d_name) == 0) strcasecmp(rootname, f->d_name) == 0)
{ found = 1;
found = 1; else
} if (f->d_name[rootnamelen] == '.')
else if (f->d_name[rootnamelen] == '.')
{
for (e = extensions; *e != NULL; e++) for (e = extensions; *e != NULL; e++)
{
if (strcasecmp(*e, f->d_name + rootnamelen + 1) if (strcasecmp(*e, f->d_name + rootnamelen + 1)
== 0) == 0)
{ {
found = 1; found = 1;
break; break;
} }
}
}
if (found) if (found)
{ {
if (strchr(dirname, '\\')!=NULL) if (strchr(dirname, '\\') != NULL)
strncpy(buffer, GetDirectUnixFileName(dirname), buflen); strncpy(buffer, GetUnixFileName(dirname), buflen);
else else
strncpy(buffer, dirname, buflen); strncpy(buffer, dirname, buflen);
if (buffer[strlen(buffer)-1]!='/') strncat(buffer, "/", buflen - strlen(buffer));
strncat(buffer, "/", buflen - strlen(buffer));
strncat(buffer, f->d_name, buflen - strlen(buffer)); strncat(buffer, f->d_name, buflen - strlen(buffer));
closedir(d);
ToUnix(buffer); fprintf(stderr,"$$%s$$\n", buffer);
return buffer; stat(buffer, &filestat);
if (S_ISREG(filestat.st_mode)) {
closedir(d);
free(rootname);
ToUnix(buffer);
return buffer;
} else
found = 0;
} }
} }
} }
@ -629,52 +596,52 @@ fprintf(stderr,"FindFile: looking for %s\n",rootname);
*/ */
char *WineIniFileName(void) char *WineIniFileName(void)
{ {
static char *IniName = NULL, *env; int fd;
static char *filename = NULL;
char name[256];
char inipath[256]; if (filename)
return filename;
if (IniName)
return IniName;
getcwd(inipath, 256); strcpy(name, WINE_INI_USER);
ExpandTildeString(name);
if ((env = getenv("HOME")) !=NULL) { if ((fd = open(name, O_RDONLY)) != -1) {
strcat(inipath, ";"); close(fd);
strcat(inipath, env); filename = malloc(strlen(name) + 1);
} strcpy(filename, name);
if ((env = getenv("WINEPATH")) !=NULL) { return(filename);
strcat(inipath, ";"); }
strcat(inipath, env); if ((fd = open(WINE_INI_GLOBAL, O_RDONLY)) != -1) {
} close(fd);
filename = malloc(strlen(WINE_INI_GLOBAL) + 1);
IniName = malloc(1024); strcpy(filename, WINE_INI_GLOBAL);
if (FindFile(IniName, 1024, "wine.ini", NULL, inipath) == NULL) return(filename);
{ }
free(IniName); fprintf(stderr,"wine: can't open configuration file %s or %s !\n",
IniName = NULL; WINE_INI_GLOBAL, WINE_INI_USER);
return NULL; exit(1);
}
IniName = realloc(IniName, strlen(IniName) + 1);
ToUnix(IniName);
return IniName;
} }
char *WinIniFileName() char *WinIniFileName(void)
{ {
static char name[256]; static char *name = NULL;
strcpy(name,GetDirectUnixFileName(WindowsDirectory)); if (name)
strcat(name,"win.ini"); return name;
name = malloc(1024);
strcpy(name, GetUnixFileName(WindowsDirectory));
strcat(name, "/");
strcat(name, "win.ini");
ToUnix(name); ToUnix(name);
name = realloc(name, strlen(name) + 1);
return name; return name;
} }
int match(char *filename, char *filemask) static int match(char *filename, char *filemask)
{ {
int x, masklength = strlen(filemask); int x, masklength = strlen(filemask);
@ -683,10 +650,8 @@ int match(char *filename, char *filemask)
#endif #endif
for (x = 0; x != masklength ; x++) { for (x = 0; x != masklength ; x++) {
#ifdef DEBUG /* printf("(%c%c) ", *filename, filemask[x]);
printf("(%c%c) ", *filename, filemask[x]); */
#endif
if (!*filename) if (!*filename)
/* stop if EOFname */ /* stop if EOFname */
return 1; return 1;
@ -723,12 +688,10 @@ struct dosdirent *DOS_opendir(char *dosdirname)
if (x == MAX_OPEN_DIRS) if (x == MAX_OPEN_DIRS)
return NULL; return NULL;
if ((unixdirname = GetDirectUnixFileName(dosdirname)) == NULL) if ((unixdirname = GetUnixFileName(dosdirname)) == NULL)
return NULL; return NULL;
strcpy(temp, unixdirname); strcpy(temp, unixdirname);
y = strlen(temp); y = strlen(temp);
while (y--) while (y--)
{ {
@ -779,15 +742,18 @@ struct dosdirent *DOS_readdir(struct dosdirent *de)
ToDos(de->filename); ToDos(de->filename);
} while ( !match(de->filename, de->filemask) ); } while ( !match(de->filename, de->filemask) );
de->attribute = 0x0;
strcpy(temp,de->unixpath); strcpy(temp,de->unixpath);
strcat(temp,"/"); strcat(temp,"/");
strcat(temp,de->filename); strcat(temp,de->filename);
ToUnix(temp); ToUnix(temp);
stat (temp, &st); stat (temp, &st);
de->attribute = 0x0;
if S_ISDIR(st.st_mode) if S_ISDIR(st.st_mode)
de->attribute |= 0x08; de->attribute |= FA_DIREC;
de->filesize = st.st_size;
de->filetime = st.st_mtime;
return de; return de;
} }

View File

@ -3,6 +3,10 @@
* *
*/ */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "windows.h" #include "windows.h"
#define HELP_CONTEXT 0x0001 #define HELP_CONTEXT 0x0001
@ -23,79 +27,65 @@
WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow) WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow)
{ {
int X, X2, C; int X, X2, C;
char *ArgV[20]; char *ArgV[20];
printf("WinExec('%s', %04X)\n", lpCmdLine, nCmdShow); printf("WinExec('%s', %04X)\n", lpCmdLine, nCmdShow);
for (X = X2 = C = 0; X < strlen(lpCmdLine) + 1; X++) { ArgV[0] = "wine";
if ((lpCmdLine[X] == ' ') || (lpCmdLine[X] == '\0')) { C = 1;
ArgV[C] = (char *)malloc(X - X2 + 1); for (X = X2 = 0; X < strlen(lpCmdLine) + 1; X++) {
strncpy(ArgV[C], &lpCmdLine[X2], X - X2); if ((lpCmdLine[X] == ' ') || (lpCmdLine[X] == '\0')) {
ArgV[C][X - X2] = '\0'; ArgV[C] = (char *)malloc(X - X2 + 1);
C++; X2 = X + 1; strncpy(ArgV[C], &lpCmdLine[X2], X - X2);
} ArgV[C][X - X2] = '\0';
} C++; X2 = X + 1;
ArgV[C] = NULL; }
for (C = 0; ; C++) { }
if (ArgV[C] == NULL) break; ArgV[C] = NULL;
printf("--> '%s' \n", ArgV[C]); for (C = 0; ; C++) {
} if (ArgV[C] == NULL) break;
switch(fork()) { printf("--> '%s' \n", ArgV[C]);
case -1: }
printf("Can't 'fork' process !\n"); switch(fork()) {
break; case -1:
case 0: printf("Can't 'fork' process !\n");
printf("New process started !\n"); break;
execvp(ArgV[0], ArgV); case 0:
printf("Child process died !\n"); printf("New process started !\n");
exit(1); execvp(ArgV[0], ArgV);
break; printf("Child process died !\n");
default: exit(1);
printf("Main process stay alive !\n"); break;
break; default:
} printf("Main process stay alive !\n");
for (C = 0; ; C++) { break;
if (ArgV[C] == NULL) break; }
free(ArgV[C]); for (C = 0; ; C++) {
} if (ArgV[C] == NULL) break;
return(TRUE); free(ArgV[C]);
}
return(TRUE);
} }
BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData) BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
{ {
char *ArgV[6]; char str[256];
char str[32]; printf("WinHelp(%s, %u, %lu)\n", lpHelpFile, wCommand, dwData);
printf("WinHelp(%s, %u, %lu)\n", lpHelpFile, wCommand, dwData); switch(wCommand) {
switch(fork()) { case 0:
case -1: case HELP_HELPONHELP:
printf("Can't 'fork' process !\n"); GetWindowsDirectory(str, sizeof(str));
break; strcat(str, "\\winhelp.exe");
case 0: printf("'%s'\n", str);
printf("New process started !\n"); break;
ArgV[0] = "wine"; case HELP_INDEX:
ArgV[1] = "winhelp.exe"; GetWindowsDirectory(str, sizeof(str));
ArgV[2] = lpHelpFile; strcat(str, "\\winhelp.exe");
switch (wCommand) { printf("'%s'\n", str);
case HELP_CONTEXT: break;
case HELP_KEY: default:
case HELP_SETINDEX: return FALSE;
sprintf(str, "%lu", dwData); }
ArgV[3] = str; WinExec(str, SW_SHOWNORMAL);
default: return(TRUE);
ArgV[3] = NULL;
}
ArgV[4] = NULL;
if (wCommand == HELP_HELPONHELP) ArgV[2] = NULL;
/*
_WinMain(ArgV, 2);
*/
execvp(ArgV[0], ArgV);
printf("Child process died !\n");
exit(1);
break;
default:
printf("Main process stay alive !\n");
break;
}
return(TRUE);
} }

View File

@ -19,16 +19,16 @@
#define DEBUG_FILE #define DEBUG_FILE
#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <unistd.h> #include <unistd.h>
#include <time.h>
#include <windows.h>
#include "prototypes.h" #include "prototypes.h"
char WindowsDirectory[256], SystemDirectory[256], TempDirectory[256]; char WindowsDirectory[256], SystemDirectory[256], TempDirectory[256];
/*************************************************************************** /***************************************************************************
_lopen _lopen
@ -40,12 +40,12 @@ int _lopen (LPSTR lpPathName, int iReadWrite)
char *UnixFileName; char *UnixFileName;
#ifdef DEBUG_FILE #ifdef DEBUG_FILE
fprintf (stderr, "_lopen: open %s\n", lpPathName); fprintf (stderr, "_lopen: open('%s', %X);\n", lpPathName, iReadWrite);
#endif #endif
if ((UnixFileName = GetUnixFileName(lpPathName)) == NULL) if ((UnixFileName = GetUnixFileName(lpPathName)) == NULL)
return HFILE_ERROR; return HFILE_ERROR;
iReadWrite &= 0x000F;
handle = open (UnixFileName, iReadWrite); handle = open (UnixFileName, iReadWrite);
#ifdef DEBUG_FILE #ifdef DEBUG_FILE
@ -67,7 +67,7 @@ WORD _lread (int hFile, LPSTR lpBuffer, int wBytes)
#ifdef DEBUG_FILE #ifdef DEBUG_FILE
fprintf(stderr, "_lread: handle %d, buffer = %ld, length = %d\n", fprintf(stderr, "_lread: handle %d, buffer = %ld, length = %d\n",
hFile, lpBuffer, wBytes); hFile, (int) lpBuffer, wBytes);
#endif #endif
result = read (hFile, lpBuffer, wBytes); result = read (hFile, lpBuffer, wBytes);
@ -87,7 +87,7 @@ WORD _lwrite (int hFile, LPSTR lpBuffer, int wBytes)
#ifdef DEBUG_FILE #ifdef DEBUG_FILE
fprintf(stderr, "_lwrite: handle %d, buffer = %ld, length = %d\n", fprintf(stderr, "_lwrite: handle %d, buffer = %ld, length = %d\n",
hFile, lpBuffer, wBytes); hFile, (int) lpBuffer, wBytes);
#endif #endif
result = write (hFile, lpBuffer, wBytes); result = write (hFile, lpBuffer, wBytes);
@ -103,10 +103,12 @@ WORD _lwrite (int hFile, LPSTR lpBuffer, int wBytes)
int _lclose (int hFile) int _lclose (int hFile)
{ {
#ifdef DEBUG_FILE #ifdef DEBUG_FILE
fprintf(stderr, "_lclose: handle %d\n", hFile); fprintf(stderr, "_lclose: handle %d\n", hFile);
#endif #endif
if (close (hFile))
close (hFile); return HFILE_ERROR;
else
return 0;
} }
/************************************************************************** /**************************************************************************
@ -221,12 +223,12 @@ UINT GetDriveType(int drive)
#endif #endif
if (!DOS_ValidDrive(drive)) if (!DOS_ValidDrive(drive))
return 0; return DRIVE_DOESNOTEXIST;
if (drive == 0 || drive == 1) if (drive == 0 || drive == 1)
return DRIVE_REMOVABLE; return DRIVE_REMOVABLE;
return DRIVE_REMOTE; return DRIVE_REMOVABLE;
} }
/*************************************************************************** /***************************************************************************
@ -254,6 +256,7 @@ UINT GetWindowsDirectory(LPSTR lpszSysPath, UINT cbSysPath)
fprintf(stderr,"GetWindowsDirectory (%s)\n",lpszSysPath); fprintf(stderr,"GetWindowsDirectory (%s)\n",lpszSysPath);
#endif #endif
ChopOffSlash(lpszSysPath);
return(strlen(lpszSysPath)); return(strlen(lpszSysPath));
} }
/*************************************************************************** /***************************************************************************
@ -270,6 +273,7 @@ UINT GetSystemDirectory(LPSTR lpszSysPath, UINT cbSysPath)
fprintf(stderr,"GetSystemDirectory (%s)\n",lpszSysPath); fprintf(stderr,"GetSystemDirectory (%s)\n",lpszSysPath);
#endif #endif
ChopOffSlash(lpszSysPath);
return(strlen(lpszSysPath)); return(strlen(lpszSysPath));
} }
/*************************************************************************** /***************************************************************************
@ -288,7 +292,7 @@ int GetTempFileName(BYTE bDriveLetter, LPCSTR lpszPrefixString, UINT uUnique, LP
strcpy(tempname,lpszPrefixString); strcpy(tempname,lpszPrefixString);
tempname[3]='\0'; tempname[3]='\0';
sprintf(lpszTempFileName,"%s\%s%d.tmp",WindowsDirectory, tempname, sprintf(lpszTempFileName,"%s\\%s%d.tmp",WindowsDirectory, tempname,
unique); unique);
ToDos(lpszTempFileName); ToDos(lpszTempFileName);
@ -308,3 +312,52 @@ WORD SetErrorMode(WORD x)
{ {
fprintf(stderr,"wine: SetErrorMode %4x (ignored)\n",x); fprintf(stderr,"wine: SetErrorMode %4x (ignored)\n",x);
} }
/***************************************************************************
_hread
***************************************************************************/
long _hread(int hf, void FAR *hpvBuffer, long cbBuffer)
{
long dataread = 0;
size_t status, size;
while (cbBuffer)
{
size = cbBuffer < 30000 ? cbBuffer : 30000;
status = read(hf, hpvBuffer, size);
if (status == -1)
return HFILE_ERROR;
if (status == 0)
return dataread;
dataread += status;
hpvBuffer += status;
cbBuffer -= status;
}
return dataread;
}
/***************************************************************************
_hwrite
***************************************************************************/
long _hwrite(int hf, const void FAR *hpvBuffer, long cbBuffer)
{
long datawritten = 0;
size_t status, size;
while (cbBuffer)
{
size = cbBuffer < 30000 ? cbBuffer : 30000;
status = write(hf, hpvBuffer, size);
if (status == -1)
return HFILE_ERROR;
if (status == 0)
return datawritten;
datawritten += status;
hpvBuffer += status;
cbBuffer -= status;
}
return datawritten;
}

View File

@ -1,6 +1,8 @@
static char RCSId[] = "$Id: keyboard.c,v 1.2 1993/09/13 18:52:02 scott Exp $"; static char RCSId[] = "$Id: keyboard.c,v 1.2 1993/09/13 18:52:02 scott Exp $";
static char Copyright[] = "Copyright Scott A. Laird, 1993"; static char Copyright[] = "Copyright Scott A. Laird, 1993";
#include <stdlib.h>
#include <stdio.h>
#include "prototypes.h" #include "prototypes.h"
#include "windows.h" #include "windows.h"

View File

@ -6,6 +6,7 @@ static char Copyright[] = "Copyright Yngvi Sigurjonsson (yngvi@hafro.is), 1993"
#include <ctype.h> #include <ctype.h>
#include <sys/types.h> #include <sys/types.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#include "prototypes.h" #include "prototypes.h"
#include "regfunc.h" #include "regfunc.h"

View File

@ -7,24 +7,36 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1994"; static char Copyright[] = "Copyright Alexandre Julliard, 1994";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xresource.h> #include <X11/Xresource.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include "msdos.h"
#include "windows.h" #include "windows.h"
#include "options.h" #include "options.h"
#include "prototypes.h"
#define WINE_CLASS "Wine" /* Class name for resources */
Display * XT_display; /* To be removed */ Display * XT_display; /* To be removed */
Screen * XT_screen; /* To be removed */ Screen * XT_screen; /* To be removed */
Display * display; Display *display;
Screen * screen; Screen *screen;
Window rootWindow;
int screenWidth = 0, screenHeight = 0; /* Desktop window dimensions */
int screenDepth = 0; /* Screen depth to use */
int desktopX = 0, desktopY = 0; /* Desktop window position (if any) */
char *ProgramName; /* Used by resource.c with WINELIB */ char *ProgramName; /* Used by resource.c with WINELIB */
struct options Options = struct options Options =
{ /* default options */ { /* default options */
NULL, /* spyFilename */ NULL, /* spyFilename */
NULL, /* desktopGeometry */
NULL, /* programName */
FALSE, /* usePrivateMap */ FALSE, /* usePrivateMap */
FALSE, /* synchronous */ FALSE, /* synchronous */
SW_SHOWNORMAL, /* cmdShow */ SW_SHOWNORMAL, /* cmdShow */
@ -34,8 +46,11 @@ struct options Options =
static XrmOptionDescRec optionsTable[] = static XrmOptionDescRec optionsTable[] =
{ {
{ "-desktop", ".desktop", XrmoptionSepArg, (caddr_t)NULL },
{ "-depth", ".depth", XrmoptionSepArg, (caddr_t)NULL },
{ "-display", ".display", XrmoptionSepArg, (caddr_t)NULL }, { "-display", ".display", XrmoptionSepArg, (caddr_t)NULL },
{ "-iconic", ".iconic", XrmoptionNoArg, (caddr_t)"on" }, { "-iconic", ".iconic", XrmoptionNoArg, (caddr_t)"on" },
{ "-name", ".name", XrmoptionSepArg, (caddr_t)NULL },
{ "-privatemap", ".privatemap", XrmoptionNoArg, (caddr_t)"on" }, { "-privatemap", ".privatemap", XrmoptionNoArg, (caddr_t)"on" },
{ "-synchronous", ".synchronous", XrmoptionNoArg, (caddr_t)"on" }, { "-synchronous", ".synchronous", XrmoptionNoArg, (caddr_t)"on" },
{ "-spy", ".spy", XrmoptionSepArg, (caddr_t)NULL }, { "-spy", ".spy", XrmoptionSepArg, (caddr_t)NULL },
@ -44,19 +59,78 @@ static XrmOptionDescRec optionsTable[] =
#define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0])) #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
#define USAGE \
"Usage: %s [options] program_name [arguments]\n" \
"\n" \
"Options:\n" \
" -depth n Change the depth to use for multiple-depth screens\n" \
" -desktop geom Use a desktop window of the given geometry\n" \
" -display name Use the specified display\n" \
" -iconic Start as an icon\n" \
" -name name Set the application name\n" \
" -privatemap Use a private color map\n" \
" -synchronous Turn on synchronous display mode\n" \
" -spy file Turn on message spying to the specified file\n" \
" -relaydbg Display call relay information\n"
/*********************************************************************** /***********************************************************************
* MAIN_Usage * MAIN_Usage
*/ */
static void MAIN_Usage( char *name ) static void MAIN_Usage( char *name )
{ {
fprintf( stderr,"Usage: %s [-display name] [-iconic] [-privatemap]\n" fprintf( stderr, USAGE, name );
" [-synchronous] [-spy file] program [arguments]\n",
name );
exit(1); exit(1);
} }
/***********************************************************************
* MAIN_GetProgramName
*
* Get the program name. The name is specified by (in order of precedence):
* - the option '-name'.
* - the environment variable 'WINE_NAME'.
* - the last component of argv[0].
*/
static char *MAIN_GetProgramName( int argc, char *argv[] )
{
int i;
char *p;
for (i = 1; i < argc-1; i++)
if (!strcmp( argv[i], "-name" )) return argv[i+1];
if ((p = getenv( "WINE_NAME" )) != NULL) return p;
if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
return argv[0];
}
/***********************************************************************
* MAIN_GetResource
*
* Fetch the value of resource 'name' using the correct instance name.
* 'name' must begin with '.' or '*'
*/
static int MAIN_GetResource( XrmDatabase db, char *name, XrmValue *value )
{
char *buff_instance, *buff_class;
char *dummy;
int retval;
buff_instance = (char *)malloc(strlen(Options.programName)+strlen(name)+1);
buff_class = (char *)malloc( strlen(WINE_CLASS) + strlen(name) + 1 );
strcpy( buff_instance, Options.programName );
strcat( buff_instance, name );
strcpy( buff_class, WINE_CLASS );
strcat( buff_class, name );
retval = XrmGetResource( db, buff_instance, buff_class, &dummy, value );
free( buff_instance );
free( buff_class );
return retval;
}
/*********************************************************************** /***********************************************************************
* MAIN_ParseOptions * MAIN_ParseOptions
* *
@ -64,18 +138,25 @@ static void MAIN_Usage( char *name )
*/ */
static void MAIN_ParseOptions( int *argc, char *argv[] ) static void MAIN_ParseOptions( int *argc, char *argv[] )
{ {
char *dummy, *display_name; char *display_name;
XrmValue value; XrmValue value;
XrmDatabase db = NULL; XrmDatabase db = NULL;
XrmParseCommand( &db, optionsTable, NB_OPTIONS, "wine", argc, argv ); /* Parse command line */
Options.programName = MAIN_GetProgramName( *argc, argv );
XrmParseCommand( &db, optionsTable, NB_OPTIONS,
Options.programName, argc, argv );
#ifdef WINELIB #ifdef WINELIB
/* Need to assemble command line and pass it to WinMain */ /* Need to assemble command line and pass it to WinMain */
#else #else
if (*argc < 2) MAIN_Usage( argv[0] ); if (*argc < 2 || strcasecmp(argv[1], "-h") == 0)
MAIN_Usage( argv[0] );
#endif #endif
if (XrmGetResource( db, "wine.display", "Wine.display", &dummy, &value ))
display_name = value.addr; /* Open display */
if (MAIN_GetResource( db, ".display", &value )) display_name = value.addr;
else display_name = NULL; else display_name = NULL;
if (!(display = XOpenDisplay( display_name ))) if (!(display = XOpenDisplay( display_name )))
@ -85,50 +166,98 @@ static void MAIN_ParseOptions( int *argc, char *argv[] )
exit(1); exit(1);
} }
if (XrmGetResource(db,"wine.iconic","Wine.iconic",&dummy,&value)) /* Get all options */
if (MAIN_GetResource( db, ".iconic", &value ))
Options.cmdShow = SW_SHOWMINIMIZED; Options.cmdShow = SW_SHOWMINIMIZED;
if (XrmGetResource(db,"wine.privatemap","Wine.privatemap",&dummy,&value)) if (MAIN_GetResource( db, ".privatemap", &value ))
Options.usePrivateMap = TRUE; Options.usePrivateMap = TRUE;
if (XrmGetResource(db,"wine.synchronous","Wine.synchronous",&dummy,&value)) if (MAIN_GetResource( db, ".synchronous", &value ))
Options.synchronous = TRUE; Options.synchronous = TRUE;
if (XrmGetResource(db,"wine.relaydbg","Wine.relaydbg",&dummy,&value)) if (MAIN_GetResource( db, ".relaydbg", &value ))
Options.relay_debug = TRUE; Options.relay_debug = TRUE;
if (XrmGetResource(db,"wine.spy","Wine.spy",&dummy,&value)) if (MAIN_GetResource( db, ".spy", &value))
Options.spyFilename = value.addr; Options.spyFilename = value.addr;
if (MAIN_GetResource( db, ".depth", &value))
screenDepth = atoi( value.addr );
if (MAIN_GetResource( db, ".desktop", &value))
Options.desktopGeometry = value.addr;
} }
/*********************************************************************** /***********************************************************************
* main * MAIN_CreateDesktop
*/ */
int main( int argc, char *argv[] ) static void MAIN_CreateDesktop( int argc, char *argv[] )
{ {
int ret_val; int flags;
XKeyboardState keyboard_state; unsigned int width = 640, height = 480; /* Default size = 640x480 */
XKeyboardControl keyboard_value; char *name = "Wine desktop";
XSizeHints size_hints;
XrmInitialize(); XWMHints wm_hints;
XClassHint class_hints;
MAIN_ParseOptions( &argc, argv ); XSetWindowAttributes win_attr;
XTextProperty window_name;
screen = DefaultScreenOfDisplay( display ); flags = XParseGeometry( Options.desktopGeometry,
XT_display = display; &desktopX, &desktopY, &width, &height );
XT_screen = screen; screenWidth = width;
if (Options.synchronous) XSynchronize( display, True ); screenHeight = height;
/* Create window */
win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
PointerMotionMask | ButtonPressMask |
ButtonReleaseMask | EnterWindowMask |
StructureNotifyMask;
win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );
rootWindow = XCreateWindow( display, DefaultRootWindow(display),
desktopX, desktopY, width, height, 0,
CopyFromParent, InputOutput, CopyFromParent,
CWEventMask | CWCursor, &win_attr );
/* Set window manager properties */
size_hints.min_width = size_hints.max_width = width;
size_hints.min_height = size_hints.max_height = height;
size_hints.flags = PMinSize | PMaxSize;
if (flags & (XValue | YValue)) size_hints.flags |= USPosition;
if (flags & (WidthValue | HeightValue)) size_hints.flags |= USSize;
else size_hints.flags |= PSize;
wm_hints.flags = InputHint | StateHint;
wm_hints.input = True;
wm_hints.initial_state = NormalState;
class_hints.res_name = argv[0];
class_hints.res_class = "Wine";
XStringListToTextProperty( &name, 1, &window_name );
XSetWMProperties( display, rootWindow, &window_name, &window_name,
argv, argc, &size_hints, &wm_hints, &class_hints );
/* Map window */
XMapWindow( display, rootWindow );
}
XKeyboardState keyboard_state;
/***********************************************************************
* MAIN_SaveSetup
*/
static void MAIN_SaveSetup(void)
{
XGetKeyboardControl(display, &keyboard_state); XGetKeyboardControl(display, &keyboard_state);
}
ProgramName = argv [0]; /***********************************************************************
DOS_InitFS(); * MAIN_RestoreSetup
Comm_Init(); */
static void MAIN_RestoreSetup(void)
ret_val = _WinMain( argc, argv ); {
XKeyboardControl keyboard_value;
Comm_DeInit ();
DOS_DeInitFS ();
sync_profiles ();
/* restore sounds/keyboard settings */
keyboard_value.key_click_percent = keyboard_state.key_click_percent; keyboard_value.key_click_percent = keyboard_state.key_click_percent;
keyboard_value.bell_percent = keyboard_state.bell_percent; keyboard_value.bell_percent = keyboard_state.bell_percent;
@ -138,6 +267,65 @@ int main( int argc, char *argv[] )
XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent | XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent |
KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value); KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
}
static void called_at_exit(void)
{
Comm_DeInit();
sync_profiles();
MAIN_RestoreSetup();
}
/***********************************************************************
* main
*/
int main( int argc, char *argv[] )
{
int ret_val;
int depth_count, i;
int *depth_list;
XrmInitialize();
MAIN_ParseOptions( &argc, argv );
screen = DefaultScreenOfDisplay( display );
screenWidth = WidthOfScreen( screen );
screenHeight = HeightOfScreen( screen );
XT_display = display;
XT_screen = screen;
if (screenDepth) /* -depth option specified */
{
depth_list = XListDepths(display,DefaultScreen(display),&depth_count);
for (i = 0; i < depth_count; i++)
if (depth_list[i] == screenDepth) break;
XFree( depth_list );
if (i >= depth_count)
{
fprintf( stderr, "%s: Depth %d not supported on this screen.\n",
Options.programName, screenDepth );
exit(1);
}
}
else screenDepth = DefaultDepthOfScreen( screen );
if (Options.synchronous) XSynchronize( display, True );
if (Options.desktopGeometry) MAIN_CreateDesktop( argc, argv );
else rootWindow = DefaultRootWindow( display );
ProgramName = argv [0];
MAIN_SaveSetup();
DOS_InitFS();
Comm_Init();
#ifndef sun
atexit(called_at_exit);
#endif
ret_val = _WinMain( argc, argv );
#ifdef sunos
called_at_exit();
#endif
return ret_val; return ret_val;
} }
@ -145,7 +333,7 @@ int main( int argc, char *argv[] )
/*********************************************************************** /***********************************************************************
* MessageBeep (USER.104) * MessageBeep (USER.104)
*/ */
void MessageBeep( WORD i ) void MessageBeep(WORD i)
{ {
XBell(display, 100); XBell(display, 100);
} }
@ -155,7 +343,7 @@ void MessageBeep( WORD i )
*/ */
LONG GetVersion(void) LONG GetVersion(void)
{ {
return (0x04001003); /* dos version 4.00, win ver 3.1 */ return( 0x03300a03 ); /* dos 3.30 & win 3.10 */
} }
/*********************************************************************** /***********************************************************************
@ -179,9 +367,12 @@ LONG GetTimerResolution(void)
*/ */
BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT fuWinIni) BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT fuWinIni)
{ {
int timeout, temp;
char buffer[256];
XKeyboardState keyboard_state; XKeyboardState keyboard_state;
XKeyboardControl keyboard_value; XKeyboardControl keyboard_value;
fprintf(stderr, "SystemParametersInfo: action %d, param %x, flag %x\n", fprintf(stderr, "SystemParametersInfo: action %d, param %x, flag %x\n",
uAction, uParam, fuWinIni); uAction, uParam, fuWinIni);
@ -195,7 +386,7 @@ BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT f
break; break;
case SPI_GETBORDER: case SPI_GETBORDER:
*(int *) lpvParam = 1; *(INT *) lpvParam = 1;
break; break;
case SPI_GETFASTTASKSWITCH: case SPI_GETFASTTASKSWITCH:
@ -203,7 +394,7 @@ BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT f
break; break;
case SPI_GETGRIDGRANULARITY: case SPI_GETGRIDGRANULARITY:
*(int *) lpvParam = 1; *(INT *) lpvParam = 1;
break; break;
case SPI_GETICONTITLEWRAP: case SPI_GETICONTITLEWRAP:
@ -211,7 +402,7 @@ BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT f
break; break;
case SPI_GETKEYBOARDDELAY: case SPI_GETKEYBOARDDELAY:
*(int *) lpvParam = 1; *(INT *) lpvParam = 1;
break; break;
case SPI_GETKEYBOARDSPEED: case SPI_GETKEYBOARDSPEED:
@ -223,25 +414,26 @@ BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT f
break; break;
case SPI_GETSCREENSAVEACTIVE: case SPI_GETSCREENSAVEACTIVE:
*(WORD *) lpvParam = FALSE; *(BOOL *) lpvParam = FALSE;
break; break;
case SPI_GETSCREENSAVETIMEOUT: case SPI_GETSCREENSAVETIMEOUT:
*(int *) lpvParam = 0; XGetScreenSaver(display, &timeout, &temp,&temp,&temp);
*(INT *) lpvParam = timeout * 1000;
break; break;
case SPI_ICONHORIZONTALSPACING: case SPI_ICONHORIZONTALSPACING:
if (lpvParam == NULL) if (lpvParam == NULL)
fprintf(stderr, "SystemParametersInfo: Horizontal icon spacing set to %d\n.", uParam); fprintf(stderr, "SystemParametersInfo: Horizontal icon spacing set to %d\n.", uParam);
else else
*(int *) lpvParam = 50; *(INT *) lpvParam = 50;
break; break;
case SPI_ICONVERTICALSPACING: case SPI_ICONVERTICALSPACING:
if (lpvParam == NULL) if (lpvParam == NULL)
fprintf(stderr, "SystemParametersInfo: Vertical icon spacing set to %d\n.", uParam); fprintf(stderr, "SystemParametersInfo: Vertical icon spacing set to %d\n.", uParam);
else else
*(int *) lpvParam = 50; *(INT *) lpvParam = 50;
break; break;
case SPI_SETBEEP: case SPI_SETBEEP:
@ -265,10 +457,22 @@ BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT f
DefaultExposures); DefaultExposures);
break; break;
case SPI_SETDESKWALLPAPER:
return (SetDeskWallPaper((LPSTR) lpvParam));
break;
case SPI_SETDESKPATTERN:
if ((INT) uParam == -1) {
GetProfileString("Desktop", "Pattern",
"170 85 170 85 170 85 170 85",
buffer, sizeof(buffer) );
return (DESKTOP_SetPattern((LPSTR) buffer));
} else
return (DESKTOP_SetPattern((LPSTR) lpvParam));
break;
case SPI_LANGDRIVER: case SPI_LANGDRIVER:
case SPI_SETBORDER: case SPI_SETBORDER:
case SPI_SETDESKPATTERN:
case SPI_SETDESKWALLPAPER:
case SPI_SETDOUBLECLKHEIGHT: case SPI_SETDOUBLECLKHEIGHT:
case SPI_SETDOUBLECLICKTIME: case SPI_SETDOUBLECLICKTIME:
case SPI_SETDOUBLECLKWIDTH: case SPI_SETDOUBLECLKWIDTH:
@ -280,7 +484,33 @@ BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT f
default: default:
fprintf(stderr, "SystemParametersInfo: unknown option %d.\n", uParam); fprintf(stderr, "SystemParametersInfo: unknown option %d.\n", uParam);
break; break;
} }
return 1; return 1;
} }
/***********************************************************************
* HMEMCPY (KERNEL.348)
*/
void hmemcpy(void FAR *hpvDest, const void FAR *hpvSource, long cbCopy)
{
size_t copysize;
while (cbCopy)
{
copysize = cbCopy < 30000 ? cbCopy : 30000;
memcpy(hpvDest, hpvSource, copysize);
hpvDest += copysize;
hpvSource += copysize;
cbCopy -= copysize;
}
}
/***********************************************************************
* COPY (GDI.250)
*/
void Copy(LPVOID lpSource, LPVOID lpDest, WORD nBytes)
{
memcpy(lpDest, lpSource, nBytes);
}

View File

@ -8,6 +8,9 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993";
#define DEBUG_MSGBOX #define DEBUG_MSGBOX
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <windows.h> #include <windows.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -43,53 +46,55 @@ LONG SystemMessageBoxProc(HWND hwnd, WORD message, WORD wParam, LONG lParam);
int MessageBox(HWND hWnd, LPSTR str, LPSTR title, WORD type) int MessageBox(HWND hWnd, LPSTR str, LPSTR title, WORD type)
{ {
HWND hDlg; HWND hDlg, hWndOld;
WND *wndPtr; WND *wndPtr;
WNDCLASS wndClass; WNDCLASS wndClass;
MSG msg; MSG msg;
MSGBOX mb; MSGBOX mb;
DWORD dwStyle; DWORD dwStyle;
HINSTANCE hInst; HINSTANCE hInst;
wndPtr = WIN_FindWndPtr(hWnd); wndPtr = WIN_FindWndPtr(hWnd);
#ifdef DEBUG_MSGBOX #ifdef DEBUG_MSGBOX
printf( "MessageBox: '%s'\n", str ); printf( "MessageBox: '%s'\n", str );
#endif #endif
if (wndPtr == NULL) if (wndPtr == NULL)
hInst = hSysRes; hInst = hSysRes;
else else
hInst = wndPtr->hInstance; hInst = wndPtr->hInstance;
wndClass.style = CS_HREDRAW | CS_VREDRAW ; wndClass.style = CS_HREDRAW | CS_VREDRAW ;
wndClass.lpfnWndProc = (WNDPROC)SystemMessageBoxProc; wndClass.lpfnWndProc = (WNDPROC)SystemMessageBoxProc;
wndClass.cbClsExtra = 0; wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0; wndClass.cbWndExtra = 0;
wndClass.hInstance = hInst; wndClass.hInstance = hInst;
wndClass.hIcon = (HICON)NULL; wndClass.hIcon = (HICON)NULL;
wndClass.hCursor = LoadCursor((HANDLE)NULL, IDC_ARROW); wndClass.hCursor = LoadCursor((HANDLE)NULL, IDC_ARROW);
wndClass.hbrBackground = GetStockObject(WHITE_BRUSH); wndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL; wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = "MESSAGEBOX"; wndClass.lpszClassName = "MESSAGEBOX";
if (!RegisterClass(&wndClass)) return 0; if (!RegisterClass(&wndClass)) return 0;
memset(&mb, 0, sizeof(MSGBOX)); memset(&mb, 0, sizeof(MSGBOX));
mb.Title = title; mb.Title = title;
mb.Str = str; mb.Str = str;
mb.wType = type; mb.wType = type;
mb.ActiveFlg = TRUE; mb.ActiveFlg = TRUE;
dwStyle = WS_POPUP | WS_DLGFRAME | WS_VISIBLE; dwStyle = WS_POPUP | WS_DLGFRAME | WS_VISIBLE;
if ((type & (MB_SYSTEMMODAL | MB_TASKMODAL)) == 0) dwStyle |= WS_CAPTION; if ((type & (MB_SYSTEMMODAL | MB_TASKMODAL)) == 0) dwStyle |= WS_CAPTION;
hDlg = CreateWindow("MESSAGEBOX", title, dwStyle, 100, 150, 400, 120, hWndOld = GetFocus();
(HWND)NULL, (HMENU)NULL, hInst, (LPSTR)&mb); hDlg = CreateWindow("MESSAGEBOX", title, dwStyle, 100, 150, 400, 120,
if (hDlg == 0) return 0; (HWND)NULL, (HMENU)NULL, hInst, (LPSTR)&mb);
while(TRUE) { if (hDlg == 0) return 0;
if (!mb.ActiveFlg) break; while(TRUE) {
if (!GetMessage(&msg, (HWND)NULL, 0, 0)) break; if (!mb.ActiveFlg) break;
TranslateMessage(&msg); if (!GetMessage(&msg, (HWND)NULL, 0, 0)) break;
DispatchMessage(&msg); TranslateMessage(&msg);
} DispatchMessage(&msg);
if (!UnregisterClass("MESSAGEBOX", hInst)) return 0; }
SetFocus(hWndOld);
if (!UnregisterClass("MESSAGEBOX", hInst)) return 0;
#ifdef DEBUG_MSGBOX #ifdef DEBUG_MSGBOX
printf( "MessageBox return %04X !\n", mb.wRetVal); printf( "MessageBox return %04X !\n", mb.wRetVal);
#endif #endif
return(mb.wRetVal); return(mb.wRetVal);
} }
LPMSGBOX MsgBoxGetStorageHeader(HWND hwnd) LPMSGBOX MsgBoxGetStorageHeader(HWND hwnd)
@ -110,113 +115,113 @@ LPMSGBOX MsgBoxGetStorageHeader(HWND hwnd)
LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam) LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
{ {
WND *wndPtr; WND *wndPtr;
CREATESTRUCT *createStruct; CREATESTRUCT *createStruct;
PAINTSTRUCT ps; PAINTSTRUCT ps;
HDC hDC; HDC hDC;
RECT rect; RECT rect;
LPMSGBOX lpmb; LPMSGBOX lpmb;
LPMSGBOX lpmbInit; LPMSGBOX lpmbInit;
BITMAP bm; BITMAP bm;
HBITMAP hBitMap; HBITMAP hBitMap;
HDC hMemDC; HDC hMemDC;
HICON hIcon; HICON hIcon;
HINSTANCE hInst2; HINSTANCE hInst2;
int x; int x;
switch(message) { switch(message) {
case WM_CREATE: case WM_CREATE:
#ifdef DEBUG_MSGBOX #ifdef DEBUG_MSGBOX
printf("MessageBox WM_CREATE !\n"); printf("MessageBox WM_CREATE !\n");
#endif #endif
wndPtr = WIN_FindWndPtr(hWnd); wndPtr = WIN_FindWndPtr(hWnd);
createStruct = (CREATESTRUCT *)lParam; createStruct = (CREATESTRUCT *)lParam;
lpmbInit = (LPMSGBOX)createStruct->lpCreateParams; lpmbInit = (LPMSGBOX)createStruct->lpCreateParams;
if (lpmbInit == 0) break; if (lpmbInit == 0) break;
*((LPMSGBOX *)&wndPtr->wExtra[1]) = lpmbInit; *((LPMSGBOX *)&wndPtr->wExtra[1]) = lpmbInit;
lpmb = MsgBoxGetStorageHeader(hWnd); lpmb = MsgBoxGetStorageHeader(hWnd);
GetClientRect(hWnd, &rect); GetClientRect(hWnd, &rect);
CopyRect(&lpmb->rectStr, &rect); CopyRect(&lpmb->rectStr, &rect);
lpmb->rectStr.bottom -= 32; lpmb->rectStr.bottom -= 32;
switch(lpmb->wType & MB_TYPEMASK) { switch(lpmb->wType & MB_TYPEMASK) {
case MB_OK : case MB_OK :
lpmb->hWndYes = CreateWindow("BUTTON", "&Ok", lpmb->hWndYes = CreateWindow("BUTTON", "&Ok",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 30, rect.bottom - 25, rect.right / 2 - 30, rect.bottom - 25,
60, 18, hWnd, IDOK, wndPtr->hInstance, 0L); 60, 18, hWnd, IDOK, wndPtr->hInstance, 0L);
break; break;
case MB_OKCANCEL : case MB_OKCANCEL :
lpmb->hWndYes = CreateWindow("BUTTON", "&Ok", lpmb->hWndYes = CreateWindow("BUTTON", "&Ok",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 65, rect.bottom - 25, rect.right / 2 - 65, rect.bottom - 25,
60, 18, hWnd, IDOK, wndPtr->hInstance, 0L); 60, 18, hWnd, IDOK, wndPtr->hInstance, 0L);
lpmb->hWndCancel = CreateWindow("BUTTON", "&Cancel", lpmb->hWndCancel = CreateWindow("BUTTON", "&Cancel",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 5, rect.bottom - 25, rect.right / 2 + 5, rect.bottom - 25,
60, 18, hWnd, IDCANCEL, wndPtr->hInstance, 0L); 60, 18, hWnd, IDCANCEL, wndPtr->hInstance, 0L);
break; break;
case MB_ABORTRETRYIGNORE : case MB_ABORTRETRYIGNORE :
lpmb->hWndYes = CreateWindow("BUTTON", "&Retry", lpmb->hWndYes = CreateWindow("BUTTON", "&Retry",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 100, rect.bottom - 25, rect.right / 2 - 100, rect.bottom - 25,
60, 18, hWnd, IDRETRY, wndPtr->hInstance, 0L); 60, 18, hWnd, IDRETRY, wndPtr->hInstance, 0L);
lpmb->hWndNo = CreateWindow("BUTTON", "&Ignore", lpmb->hWndNo = CreateWindow("BUTTON", "&Ignore",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 30, rect.bottom - 25, rect.right / 2 - 30, rect.bottom - 25,
60, 18, hWnd, IDIGNORE, wndPtr->hInstance, 0L); 60, 18, hWnd, IDIGNORE, wndPtr->hInstance, 0L);
lpmb->hWndCancel = CreateWindow("BUTTON", "&Abort", lpmb->hWndCancel = CreateWindow("BUTTON", "&Abort",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 40, rect.bottom - 25, rect.right / 2 + 40, rect.bottom - 25,
60, 18, hWnd, IDABORT, wndPtr->hInstance, 0L); 60, 18, hWnd, IDABORT, wndPtr->hInstance, 0L);
break; break;
case MB_YESNO : case MB_YESNO :
lpmb->hWndYes = CreateWindow("BUTTON", "&Yes", lpmb->hWndYes = CreateWindow("BUTTON", "&Yes",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 65, rect.bottom - 25, rect.right / 2 - 65, rect.bottom - 25,
60, 18, hWnd, IDYES, wndPtr->hInstance, 0L); 60, 18, hWnd, IDYES, wndPtr->hInstance, 0L);
lpmb->hWndNo = CreateWindow("BUTTON", "&No", lpmb->hWndNo = CreateWindow("BUTTON", "&No",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 5, rect.bottom - 25, rect.right / 2 + 5, rect.bottom - 25,
60, 18, hWnd, IDNO, wndPtr->hInstance, 0L); 60, 18, hWnd, IDNO, wndPtr->hInstance, 0L);
break; break;
case MB_YESNOCANCEL : case MB_YESNOCANCEL :
lpmb->hWndYes = CreateWindow("BUTTON", "&Yes", lpmb->hWndYes = CreateWindow("BUTTON", "&Yes",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 100, rect.bottom - 25, rect.right / 2 - 100, rect.bottom - 25,
60, 18, hWnd, IDYES, wndPtr->hInstance, 0L); 60, 18, hWnd, IDYES, wndPtr->hInstance, 0L);
lpmb->hWndNo = CreateWindow("BUTTON", "&No", lpmb->hWndNo = CreateWindow("BUTTON", "&No",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 30, rect.bottom - 25, rect.right / 2 - 30, rect.bottom - 25,
60, 18, hWnd, IDNO, wndPtr->hInstance, 0L); 60, 18, hWnd, IDNO, wndPtr->hInstance, 0L);
lpmb->hWndCancel = CreateWindow("BUTTON", "&Cancel", lpmb->hWndCancel = CreateWindow("BUTTON", "&Cancel",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 40, rect.bottom - 25, rect.right / 2 + 40, rect.bottom - 25,
60, 18, hWnd, IDCANCEL, wndPtr->hInstance, 0L); 60, 18, hWnd, IDCANCEL, wndPtr->hInstance, 0L);
break; break;
} }
switch(lpmb->wType & MB_ICONMASK) { switch(lpmb->wType & MB_ICONMASK) {
case MB_ICONEXCLAMATION: case MB_ICONEXCLAMATION:
printf("MsgBox LoadIcon Exclamation !\n"); printf("MsgBox LoadIcon Exclamation !\n");
lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_EXCLAMATION); lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_EXCLAMATION);
break; break;
case MB_ICONQUESTION: case MB_ICONQUESTION:
printf("MsgBox LoadIcon Question !\n"); printf("MsgBox LoadIcon Question !\n");
lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_QUESTION); lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_QUESTION);
break; break;
case MB_ICONASTERISK: case MB_ICONASTERISK:
printf("MsgBox LoadIcon Asterisk !\n"); printf("MsgBox LoadIcon Asterisk !\n");
lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_ASTERISK); lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_ASTERISK);
break; break;
case MB_ICONHAND: case MB_ICONHAND:
printf("MsgBox LoadIcon Hand !\n"); printf("MsgBox LoadIcon Hand !\n");
lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_HAND); lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_HAND);
break; break;
} }
if (lpmb->hIcon != (HICON)NULL) { if (lpmb->hIcon != (HICON)NULL) {
SetRect(&lpmb->rectIcon, 16, SetRect(&lpmb->rectIcon, 16,
lpmb->rectStr.bottom / 2 - 16, 48, lpmb->rectStr.bottom / 2 - 16, 48,
lpmb->rectStr.bottom / 2 + 16); lpmb->rectStr.bottom / 2 + 16);
lpmb->rectStr.left += 64; lpmb->rectStr.left += 64;
} }
break; break;
case WM_PAINT: case WM_PAINT:
#ifdef DEBUG_MSGBOX #ifdef DEBUG_MSGBOX
@ -259,6 +264,37 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
#endif #endif
PostMessage(hWnd, WM_CLOSE, 0, 0L); PostMessage(hWnd, WM_CLOSE, 0, 0L);
break; break;
case WM_CHAR:
lpmb = MsgBoxGetStorageHeader(hWnd);
if (wParam >= 'a' || wParam <= 'z') wParam -= 'a' - 'A';
switch(wParam) {
case 'Y':
lpmb->wRetVal = IDYES;
break;
case 'O':
lpmb->wRetVal = IDOK;
break;
case 'R':
lpmb->wRetVal = IDRETRY;
break;
case 'A':
lpmb->wRetVal = IDABORT;
break;
case 'N':
lpmb->wRetVal = IDNO;
break;
case 'I':
lpmb->wRetVal = IDIGNORE;
break;
case 'C':
case VK_ESCAPE:
lpmb->wRetVal = IDCANCEL;
break;
default:
return 0;
}
PostMessage(hWnd, WM_CLOSE, 0, 0L);
break;
default: default:
return DefWindowProc(hWnd, message, wParam, lParam ); return DefWindowProc(hWnd, message, wParam, lParam );
} }

View File

@ -14,9 +14,12 @@
static char Copyright [] = "Copyright (C) 1993 Miguel de Icaza"; static char Copyright [] = "Copyright (C) 1993 Miguel de Icaza";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "windows.h"
#include "wine.h" #include "wine.h"
#include "windows.h"
#include "prototypes.h"
/* #define DEBUG */ /* #define DEBUG */
@ -121,12 +124,18 @@ static TSecHeader *load (char *file)
} }
if (state == FirstBrace) /* On first pass, don't allow dangling keys */ if (state == FirstBrace) /* On first pass, don't allow dangling keys */
break; break;
if (c == ' ' || c == '\t') if (c == ' ' || c == '\t')
break; break;
if (c == '\n' || c == ';' || overflow) /* Abort Definition */ if (c == '\n' || c == ';' || overflow) /* Abort Definition */
next = CharBuffer; next = CharBuffer;
if (c == ';')
{
state = IgnoreToEOL;
break;
}
if (c == '=' || overflow){ if (c == '=' || overflow){
TKeys *temp; TKeys *temp;
@ -165,7 +174,7 @@ static TSecHeader *load (char *file)
return SecHeader; return SecHeader;
} }
static new_key (TSecHeader *section, char *KeyName, char *Value) static void new_key (TSecHeader *section, char *KeyName, char *Value)
{ {
TKeys *key; TKeys *key;

View File

@ -150,6 +150,12 @@ BOOL EqualRect( LPRECT rect1, LPRECT rect2 )
BOOL SubtractRect( LPRECT dest, LPRECT src1, LPRECT src2 ) BOOL SubtractRect( LPRECT dest, LPRECT src1, LPRECT src2 )
{ {
RECT tmp; RECT tmp;
if (IsRectEmpty( src1 ))
{
SetRectEmpty( dest );
return FALSE;
}
*dest = *src1; *dest = *src1;
if (IntersectRect( &tmp, src1, src2 )) if (IntersectRect( &tmp, src1, src2 ))
{ {
@ -160,13 +166,13 @@ BOOL SubtractRect( LPRECT dest, LPRECT src1, LPRECT src2 )
} }
if ((tmp.top == dest->top) && (tmp.bottom == dest->bottom)) if ((tmp.top == dest->top) && (tmp.bottom == dest->bottom))
{ {
if (tmp.left == dest->left) dest->right = tmp.right; if (tmp.left == dest->left) dest->left = tmp.right;
else if (tmp.right == dest->right) dest->left = tmp.left; else if (tmp.right == dest->right) dest->right = tmp.left;
} }
else if ((tmp.left == dest->left) && (tmp.right == dest->right)) else if ((tmp.left == dest->left) && (tmp.right == dest->right))
{ {
if (tmp.top == dest->top) dest->bottom = tmp.bottom; if (tmp.top == dest->top) dest->top = tmp.bottom;
else if (tmp.bottom == dest->bottom) dest->top = tmp.top; else if (tmp.bottom == dest->bottom) dest->bottom = tmp.top;
} }
} }
return TRUE; return TRUE;

View File

@ -1,6 +1,8 @@
static char RCSId[] = "$Id: heap.c,v 1.3 1993/07/04 04:04:21 root Exp root $"; static char RCSId[] = "$Id: heap.c,v 1.3 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdlib.h>
#include <stdio.h>
#include "prototypes.h" #include "prototypes.h"
int OpenSound(void) int OpenSound(void)

View File

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xresource.h> #include <X11/Xresource.h>
#include <string.h>
#include "wineopts.h" #include "wineopts.h"
#include "windows.h" #include "windows.h"
#include "wine.h" #include "wine.h"
@ -14,7 +15,7 @@
#ifndef NOSPY #ifndef NOSPY
#define SPY_MAX_MSGNUM 0x0210 #define SPY_MAX_MSGNUM 0x0232
const char *MessageTypeNames[SPY_MAX_MSGNUM + 1] = const char *MessageTypeNames[SPY_MAX_MSGNUM + 1] =
{ {
@ -92,7 +93,9 @@ const char *MessageTypeNames[SPY_MAX_MSGNUM + 1] =
"WM_NCCREATE", /* 0x0081 */ "WM_NCCREATE", /* 0x0081 */
"WM_NCDESTROY", /* 0x0082 */ "WM_NCDESTROY", /* 0x0082 */
"WM_NCCALCSIZE", /* 0x0083 */ "WM_NCCALCSIZE", /* 0x0083 */
NULL, NULL, NULL, "WM_NCHITTEST", /* 0x0084 */
"WM_NCPAINT", /* 0x0085 */
"WM_NCACTIVATE", /* 0x0086 */
"WM_GETDLGCODE", /* 0x0087 */ "WM_GETDLGCODE", /* 0x0087 */
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@ -135,9 +138,9 @@ const char *MessageTypeNames[SPY_MAX_MSGNUM + 1] =
"WM_KEYLAST", /* 0x0108 */ "WM_KEYLAST", /* 0x0108 */
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
"WM_INITDIALOG", /* 0x0110 */ "WM_INITDIALOG", /* 0x0110 */
"WM_COMMAND", /* 0x0111 */ "WM_COMMAND", /* 0x0111 */
NULL, "WM_SYSCOMMAND", /* 0x0112 */
"WM_TIMER", /* 0x0113 */ "WM_TIMER", /* 0x0113 */
"WM_HSCROLL", /* 0x0114 */ "WM_HSCROLL", /* 0x0114 */
"WM_VSCROLL", /* 0x0115 */ "WM_VSCROLL", /* 0x0115 */
@ -211,9 +214,26 @@ const char *MessageTypeNames[SPY_MAX_MSGNUM + 1] =
"WM_MBUTTONDOWN", /* 0x0207 */ "WM_MBUTTONDOWN", /* 0x0207 */
"WM_MBUTTONUP", /* 0x0208 */ "WM_MBUTTONUP", /* 0x0208 */
"WM_MBUTTONDBLCLK", /* 0x0209 */ "WM_MBUTTONDBLCLK", /* 0x0209 */
NULL, NULL, NULL, NULL, NULL, NULL,
"WM_PARENTNOTIFY", /* 0x0210 */ "WM_PARENTNOTIFY", /* 0x0210 */
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
/* 0x0220 */
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, /* 0x0230 */
"WM_ENTERSIZEMOVE", /* 0x0231 */
"WM_EXITSIZEMOVE" /* 0x0232 */
}; };
char SpyFilters[256];
char SpyIncludes[256];
#endif /* NOSPY */ #endif /* NOSPY */
/********************************************************************** /**********************************************************************
@ -222,18 +242,24 @@ const char *MessageTypeNames[SPY_MAX_MSGNUM + 1] =
void SpyMessage(HWND hwnd, WORD msg, WORD wParam, LONG lParam) void SpyMessage(HWND hwnd, WORD msg, WORD wParam, LONG lParam)
{ {
#ifndef NOSPY #ifndef NOSPY
char msg_name[80];
if (SpyFp == NULL) if (SpyFp == NULL)
return; return;
if (msg > SPY_MAX_MSGNUM || MessageTypeNames[msg] == NULL) if (msg > SPY_MAX_MSGNUM || MessageTypeNames[msg] == NULL)
{ msg_name[0] = '\0';
fprintf(SpyFp, "%04.4x %04.4x %04.4x %08.8x\n",
hwnd, msg, wParam, lParam);
}
else else
strcpy(msg_name, MessageTypeNames[msg]);
strcat(msg_name, ";");
if ((strlen(SpyIncludes) == 0 || strstr(SpyIncludes, msg_name) != NULL) &&
strstr(SpyFilters, msg_name) == NULL)
{ {
fprintf(SpyFp, "%04.4x %20.20s %04.4x %08.8x\n", msg_name[strlen(msg_name) - 1] = '\0';
hwnd, MessageTypeNames[msg], wParam, lParam); fprintf(SpyFp, "%04.4x %20.20s %04.4x %04.4x %08.8x\n",
hwnd, msg_name, msg, wParam, lParam);
} }
#endif #endif
} }
@ -245,7 +271,7 @@ void SpyInit(void)
{ {
char filename[100]; char filename[100];
if (SpyFp == NULL) if (SpyFp != NULL)
return; return;
if (Options.spyFilename == NULL) if (Options.spyFilename == NULL)
@ -261,5 +287,13 @@ void SpyInit(void)
else if (strlen(filename)) else if (strlen(filename))
SpyFp = fopen(filename, "a"); SpyFp = fopen(filename, "a");
else else
{
SpyFp = NULL; SpyFp = NULL;
return;
}
GetPrivateProfileString("spy", "exclude", "", SpyFilters,
sizeof(SpyFilters), WINE_INI);
GetPrivateProfileString("spy", "include", "", SpyIncludes,
sizeof(SpyIncludes), WINE_INI);
} }

109
misc/stress.c Normal file
View File

@ -0,0 +1,109 @@
#include <stdio.h>
#include <limits.h>
#include "windows.h"
#include "stress.h"
#define STRESS_DEBUG
int AllocDiskSpace(long lLeft, UINT uDrive)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: AllocDiskSpace %d, %ld\n", uDrive, lLeft);
#endif
return 1;
}
int AllocFileHandles(int Left)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: AllocFileHandles %d\n", Left);
#endif
if (Left < 0)
return -1;
else
return 1;
}
BOOL AllocGDIMem(UINT uLeft)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: AllocGDIMem %d\n", uLeft);
#endif
return 1;
}
BOOL AllocMem(DWORD dwLeft)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: AllocMem %ld\n", dwLeft);
#endif
return 1;
}
BOOL AllocUserMem(UINT uContig)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: AllocUserMem %d\n", uContig);
#endif
return 1;
}
void FreeAllMem(void)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: FreeAllMem\n");
#endif
}
void FreeAllGDIMem(void)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: FreeAllGDIMem\n");
#endif
}
void FreeAllUserMem(void)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: FreeAllUserMem\n");
#endif
}
void GetFreeAllUserMem(void)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: GetFreeAllUserMem\n");
#endif
}
int GetFreeFileHandles(void)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: GetFreeFileHandles\n");
#endif
#ifndef OPEN_MAX
return _POSIX_OPEN_MAX
#else
return OPEN_MAX;
#endif
}
void UnAllocDiskSpace(UINT drive)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: UnAllocDiskSpace %d\n", drive);
#endif
}
void UnAllocFileHandles(void)
{
#ifdef STRESS_DEBUG
fprintf(stderr, "stress.dll: GetFreeAllUserMem\n");
#endif
}

View File

@ -17,6 +17,7 @@ MDESC *USER_Heap = NULL;
extern BOOL ATOM_Init(); extern BOOL ATOM_Init();
extern BOOL GDI_Init(); extern BOOL GDI_Init();
extern void SYSMETRICS_Init(); extern void SYSMETRICS_Init();
extern BOOL WIN_CreateDesktopWindow();
#ifndef WINELIB #ifndef WINELIB
/*********************************************************************** /***********************************************************************
@ -44,6 +45,11 @@ USER_InitApp(int hInstance)
SpyInit(); SpyInit();
#ifndef WINELIB
/* Create USER heap */
if (!USER_HeapInit()) return 0;
#endif
/* Global atom table initialisation */ /* Global atom table initialisation */
if (!ATOM_Init()) return 0; if (!ATOM_Init()) return 0;
@ -54,11 +60,6 @@ USER_InitApp(int hInstance)
SYSMETRICS_Init(); SYSMETRICS_Init();
SYSCOLOR_Init(); SYSCOLOR_Init();
#ifndef WINELIB
/* Create USER heap */
if (!USER_HeapInit()) return 0;
#endif
/* Create the DCEs */ /* Create the DCEs */
DCE_Init(); DCE_Init();
@ -76,9 +77,14 @@ USER_InitApp(int hInstance)
queueSize = GetProfileInt( "windows", "DefaultQueueSize", 8 ); queueSize = GetProfileInt( "windows", "DefaultQueueSize", 8 );
if (!SetMessageQueue( queueSize )) return 0; if (!SetMessageQueue( queueSize )) return 0;
/* Create desktop window */
if (!WIN_CreateDesktopWindow()) return 0;
#if 1
#ifndef WINELIB #ifndef WINELIB
/* Initialize DLLs */ /* Initialize DLLs */
InitializeLoadedDLLs(); InitializeLoadedDLLs();
#endif
#endif #endif
return 1; return 1;

View File

@ -1,18 +1,19 @@
/* /*
* based on Windows Sockets 1.1 specs * based on Windows Sockets 1.1 specs
* (ftp.microsoft.com:/Advsys/winsock/spec11/WINSOCK.TXT) * (ftp.microsoft.com:/Advsys/winsock/spec11/WINSOCK.TXT)
*
* (C) 1993,1994 John Brezak, Erik Bos.
*/ */
#include <netdb.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#if defined(__FreeBSD__)
#include <netinet/in.h> #include <netinet/in.h>
#endif
#include <arpa/inet.h> #include <arpa/inet.h>
#include <errno.h> #include <errno.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h>
#include "winsock.h" #include "winsock.h"
#define DEBUG_WINSOCK #define DEBUG_WINSOCK
@ -47,12 +48,12 @@ WORD errno_to_wsaerrno(int errno)
sys_errlist[errno], errno); sys_errlist[errno], errno);
#else #else
fprintf(stderr, "winsock: errno_to_wsaerrno translation failure.\n\t: %s (%d)\n", fprintf(stderr, "winsock: errno_to_wsaerrno translation failure.\n\t: %s (%d)\n",
strerror [errno], errno); strerror[errno], errno);
#endif #endif
#else #else
fprintf (stderr, "winsock: errno_to_wsaerrno translation failure.\n"); fprintf (stderr, "winsock: errno_to_wsaerrno translation failure.\n");
#endif #endif
break; return WSAENETDOWN;
} }
} }

View File

@ -4,8 +4,12 @@ MODULE = miscemu
SRCS = \ SRCS = \
emulate.c \ emulate.c \
int10.c \
int1a.c \ int1a.c \
int21.c \ int21.c \
int25.c \
int26.c \
ioports.c \
kernel.c kernel.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)

View File

@ -1,6 +1,8 @@
static char RCSId[] = "$Id: heap.c,v 1.3 1993/07/04 04:04:21 root Exp root $"; static char RCSId[] = "$Id: heap.c,v 1.3 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdlib.h>
#include <stdio.h>
#include "prototypes.h" #include "prototypes.h"
#include "regfunc.h" #include "regfunc.h"
@ -13,9 +15,6 @@ struct Win87EmInfoStruct {
unsigned short Unused; unsigned short Unused;
}; };
int int
WIN87_fpmath() WIN87_fpmath()
{ {
@ -49,5 +48,3 @@ WIN87_WinEm87Save(void *pWin87EmSaveArea, int cbWin87EmSaveArea)
{ {
printf( "__WinEm87Save(%p,%d)\n",pWin87EmSaveArea,cbWin87EmSaveArea); printf( "__WinEm87Save(%p,%d)\n",pWin87EmSaveArea,cbWin87EmSaveArea);
} }

36
miscemu/int10.c Normal file
View File

@ -0,0 +1,36 @@
#include <stdio.h>
#include "msdos.h"
#include "wine.h"
static void Barf(struct sigcontext_struct *context)
{
fprintf(stderr, "int10: unknown/not implemented parameters:\n");
fprintf(stderr, "int10: 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);
}
int do_int10(struct sigcontext_struct *context)
{
switch((context->sc_eax >> 8) & 0xff)
{
case 0x0f:
EAX = (EAX & 0xffffff00) | 0x5b;
break;
case 0x12:
if ((EBX & 0xff) == 0x10) {
EBX = (EBX & 0xffff0000) | 0x0003;
ECX = (ECX & 0xffff0000) | 0x0009;
}
break;
case 0x1a:
EBX = (EBX & 0xffff0000) | 0x0008;
break;
default:
Barf(context);
};
return 1;
}

View File

@ -1,5 +1,6 @@
#include <time.h> #include <time.h>
#include <stdio.h> #include <stdio.h>
#include "msdos.h"
#include "wine.h" #include "wine.h"
#ifdef linux #ifdef linux

File diff suppressed because it is too large Load Diff

30
miscemu/int25.c Normal file
View File

@ -0,0 +1,30 @@
#include <stdio.h>
#include "msdos.h"
#include "wine.h"
int do_int25(struct sigcontext_struct *context)
{
BYTE *dataptr = pointer(DS, BX);
DWORD begin, length;
if( (ECX & 0xffff) == 0xffff)
{
begin = getdword(dataptr);
length = getword(&dataptr[4]);
dataptr = (BYTE *) getdword(&dataptr[6]);
fprintf(stderr, "int25: abs diskread, drive %d, sector %d, "
"count %d, buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
}
begin = EDX & 0xffff;
length = ECX & 0xffff;
fprintf(stderr,"int25: abs diskread-2, drive %d, sector %d, count %d,"
" buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
ResetCflag;
return 1;
}

28
miscemu/int26.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include "msdos.h"
#include "wine.h"
int do_int26(struct sigcontext_struct *context)
{
BYTE *dataptr = pointer(DS, BX);
DWORD begin, length;
if( (ECX & 0xffff) == 0xffff)
{
begin = getdword(dataptr);
length = getword(&dataptr[4]);
dataptr = (BYTE *) getdword(&dataptr[6]);
fprintf(stderr, "int26: abs diskread, drive %d, sector %d, "
"count %d, buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
}
begin = EDX & 0xffff;
length = ECX & 0xffff;
fprintf(stderr,"int26: abs diskread-2, drive %d, sector %d, count %d,"
" buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
ResetCflag;
return 1;
}

60
miscemu/ioports.c Normal file
View File

@ -0,0 +1,60 @@
#include <stdio.h>
#include <time.h>
#include "msdos.h"
#include "wine.h"
static BYTE cmosaddress;
static BYTE cmosimage[64] = {
0x27, 0x34, 0x31, 0x47, 0x16, 0x15, 0x00, 0x01,
0x04, 0x94, 0x26, 0x02, 0x50, 0x80, 0x00, 0x00,
0x40, 0xb1, 0x00, 0x9c, 0x01, 0x80, 0x02, 0x00,
0x1c, 0x00, 0x00, 0xad, 0x02, 0x10, 0x00, 0x00,
0x08, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x03, 0x58,
0x00, 0x1c, 0x19, 0x81, 0x00, 0x0e, 0x00, 0x80,
0x1b, 0x7b, 0x21, 0x00, 0x00, 0x00, 0x05, 0x5f };
void inportb(struct sigcontext_struct *context)
{
fprintf(stderr, "IO: inb (%x)\n", EDX & 0xffff);
switch(EDX & 0xffff)
{
case 0x70:
EAX = (EAX & 0xffffff00L) | cmosaddress;
break;
case 0x71:
EAX = (EAX & 0xffffff00L) | cmosimage[cmosaddress & 0x3f];
break;
default:
}
}
void inport(struct sigcontext_struct *context)
{
fprintf(stderr, "IO: in (%x)\n", EDX & 0xffff);
EAX = (EAX & 0xffff0000L) | 0xffff;
}
void outportb(struct sigcontext_struct *context)
{
fprintf(stderr, "IO: outb (%x), %x\n", EDX & 0xffff, EAX & 0xff);
switch (EDX & 0xffff)
{
case 0x70:
cmosaddress = EAX & 0xff;
break;
case 0x71:
cmosimage[cmosaddress & 0x3f] = EAX & 0xff;
break;
default:
}
}
void outport(struct sigcontext_struct *context)
{
fprintf(stderr, "IO: out (%x), %x\n", EDX & 0xffff, EAX & 0xffff);
}

View File

@ -16,7 +16,8 @@ SRCS = \
clipping.c \ clipping.c \
bitblt.c \ bitblt.c \
linedda.c \ linedda.c \
color.c color.c \
dither.c
OBJS = \ OBJS = \
bitmap.o \ bitmap.o \
@ -32,7 +33,8 @@ OBJS = \
clipping.o \ clipping.o \
bitblt.o \ bitblt.o \
linedda.o \ linedda.o \
color.o color.o \
dither.o
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget() DependTarget()

View File

@ -314,7 +314,7 @@ BOOL StretchBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short h
sxi = XGetImage(display, dcSrc->u.x.drawable, xs1, ys1, sxi = XGetImage(display, dcSrc->u.x.drawable, xs1, ys1,
widthSrc, heightSrc, AllPlanes, ZPixmap); widthSrc, heightSrc, AllPlanes, ZPixmap);
dxi = XCreateImage(display, DefaultVisualOfScreen(screen), dxi = XCreateImage(display, DefaultVisualOfScreen(screen),
DefaultDepthOfScreen(screen), ZPixmap, screenDepth, ZPixmap,
0, NULL, widthDest, heightDest, 0, NULL, widthDest, heightDest,
32, 0); 32, 0);
dxi->data = malloc(dxi->bytes_per_line * heightDest); dxi->data = malloc(dxi->bytes_per_line * heightDest);

View File

@ -6,22 +6,18 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1993"; static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "gdi.h" #include "gdi.h"
#include "bitmap.h"
/* A GDI bitmap object contains a handle to a packed BITMAP,
* which is stored on the global heap.
* A packed BITMAP is a BITMAP structure followed by the bitmap bits.
*/
/* Handle of the bitmap selected by default in a memory DC */ /* Handle of the bitmap selected by default in a memory DC */
HBITMAP BITMAP_hbitmapMemDC; HBITMAP BITMAP_hbitmapMemDC = 0;
/* List of supported depths */ /* GCs used for B&W and color bitmap operations */
static int depthCount; GC BITMAP_monoGC = 0, BITMAP_colorGC = 0;
static int * depthList;
/* List of GC used for bitmap to pixmap operations (one for each depth) */
static GC * bitmapGC;
/*********************************************************************** /***********************************************************************
@ -29,27 +25,25 @@ static GC * bitmapGC;
*/ */
BOOL BITMAP_Init() BOOL BITMAP_Init()
{ {
int i;
Pixmap tmpPixmap; Pixmap tmpPixmap;
depthList = XListDepths( XT_display, DefaultScreen(XT_display),
&depthCount );
if (!depthList || !depthCount) return FALSE;
if (!(bitmapGC = (GC *) malloc( depthCount * sizeof(GC) ))) return FALSE;
/* Create the necessary GCs */ /* Create the necessary GCs */
for (i = 0; i < depthCount; i++) if ((tmpPixmap = XCreatePixmap( display, rootWindow, 1, 1, 1 )))
{ {
tmpPixmap = XCreatePixmap( XT_display, DefaultRootWindow(XT_display), BITMAP_monoGC = XCreateGC( display, tmpPixmap, 0, NULL );
1, 1, depthList[i] ); XSetGraphicsExposures( display, BITMAP_monoGC, False );
if (tmpPixmap) XFreePixmap( display, tmpPixmap );
}
if (screenDepth != 1)
{
if ((tmpPixmap = XCreatePixmap(display, rootWindow, 1,1,screenDepth)))
{ {
bitmapGC[i] = XCreateGC( XT_display, tmpPixmap, 0, NULL ); BITMAP_colorGC = XCreateGC( display, tmpPixmap, 0, NULL );
XSetGraphicsExposures( XT_display, bitmapGC[i], False ); XSetGraphicsExposures( display, BITMAP_colorGC, False );
XFreePixmap( XT_display, tmpPixmap ); XFreePixmap( display, tmpPixmap );
} }
else bitmapGC[i] = 0;
} }
BITMAP_hbitmapMemDC = CreateBitmap( 1, 1, 1, 1, NULL ); BITMAP_hbitmapMemDC = CreateBitmap( 1, 1, 1, 1, NULL );
@ -57,27 +51,14 @@ BOOL BITMAP_Init()
} }
/***********************************************************************
* BITMAP_FindGCForDepth
*
* Return a GC appropriate for operations with the given depth.
*/
GC BITMAP_FindGCForDepth( int depth )
{
int i;
for (i = 0; i < depthCount; i++)
if (depthList[i] == depth) return bitmapGC[i];
return 0;
}
/*********************************************************************** /***********************************************************************
* BITMAP_BmpToImage * BITMAP_BmpToImage
* *
* Create an XImage pointing to the bitmap data. * Create an XImage pointing to the bitmap data.
*/ */
XImage * BITMAP_BmpToImage( BITMAP * bmp, void * bmpData ) static XImage *BITMAP_BmpToImage( BITMAP * bmp, void * bmpData )
{ {
extern void _XInitImageFuncPtrs( XImage* );
XImage * image; XImage * image;
image = XCreateImage( XT_display, DefaultVisualOfScreen(XT_screen), image = XCreateImage( XT_display, DefaultVisualOfScreen(XT_screen),
@ -92,57 +73,6 @@ XImage * BITMAP_BmpToImage( BITMAP * bmp, void * bmpData )
} }
/***********************************************************************
* BITMAP_CopyToPixmap
*
* Copy the content of the bitmap to the pixmap. Both must have the same depth.
*/
BOOL BITMAP_CopyToPixmap( BITMAP * bmp, Pixmap pixmap,
int x, int y, int width, int height )
{
GC gc;
XImage * image;
gc = BITMAP_FindGCForDepth( bmp->bmBitsPixel );
if (!gc) return FALSE;
image = BITMAP_BmpToImage( bmp, ((char *)bmp) + sizeof(BITMAP) );
if (!image) return FALSE;
#ifdef DEBUG_GDI
printf( "BITMAP_CopyToPixmap: %dx%d %d colors -> %d,%d %dx%d\n",
bmp->bmWidth, bmp->bmHeight, 1 << bmp->bmBitsPixel, x, y, width, height );
#endif
XPutImage(XT_display, pixmap, gc, image, 0, 0, x, y, width, height);
image->data = NULL;
XDestroyImage( image );
return TRUE;
}
/***********************************************************************
* BITMAP_CopyFromPixmap
*
* Copy the content of the pixmap to the bitmap. Both must have
* the same dimensions and depth.
*/
BOOL BITMAP_CopyFromPixmap( BITMAP * bmp, Pixmap pixmap )
{
XImage *image = BITMAP_BmpToImage( bmp, ((char *)bmp) + sizeof(BITMAP) );
if (!image) return FALSE;
#ifdef DEBUG_GDI
printf( "BITMAP_CopyFromPixmap: %dx%d %d colors\n",
bmp->bmWidth, bmp->bmHeight, 1 << bmp->bmBitsPixel );
#endif
XGetSubImage( XT_display, pixmap, 0, 0, bmp->bmWidth, bmp->bmHeight,
AllPlanes, ZPixmap, image, 0, 0 );
image->data = NULL;
XDestroyImage( image );
return TRUE;
}
/*********************************************************************** /***********************************************************************
* CreateBitmap (GDI.48) * CreateBitmap (GDI.48)
*/ */
@ -154,9 +84,6 @@ HBITMAP CreateBitmap( short width, short height,
printf( "CreateBitmap: %dx%d, %d colors\n", printf( "CreateBitmap: %dx%d, %d colors\n",
width, height, 1 << (planes*bpp) ); width, height, 1 << (planes*bpp) );
#endif #endif
if (!width || !height) return 0;
if ((planes != 1) && (bpp != 1)) return 0;
bitmap.bmWidthBytes = (width * bpp + 15) / 16 * 2;
return CreateBitmapIndirect( &bitmap ); return CreateBitmapIndirect( &bitmap );
} }
@ -166,15 +93,12 @@ HBITMAP CreateBitmap( short width, short height,
*/ */
HBITMAP CreateCompatibleBitmap( HDC hdc, short width, short height ) HBITMAP CreateCompatibleBitmap( HDC hdc, short width, short height )
{ {
HBITMAP hbitmap;
DC * dc; DC * dc;
#ifdef DEBUG_GDI #ifdef DEBUG_GDI
printf( "CreateCompatibleBitmap: %d %dx%d\n", hdc, width, height ); printf( "CreateCompatibleBitmap: %d %dx%d\n", hdc, width, height );
#endif #endif
dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
if (!dc) return 0; return CreateBitmap( width, height, 1, dc->w.bitsPerPixel, NULL );
hbitmap = CreateBitmap( width, height, dc->w.planes, dc->w.bitsPerPixel, NULL);
return hbitmap;
} }
@ -184,72 +108,34 @@ HBITMAP CreateCompatibleBitmap( HDC hdc, short width, short height )
HBITMAP CreateBitmapIndirect( BITMAP * bmp ) HBITMAP CreateBitmapIndirect( BITMAP * bmp )
{ {
BITMAPOBJ * bmpObjPtr; BITMAPOBJ * bmpObjPtr;
char * bmpPtr;
HBITMAP hbitmap; HBITMAP hbitmap;
int size = bmp->bmPlanes * bmp->bmHeight * bmp->bmWidthBytes;
/* Create the BITMAPOBJ */
/* Check parameters */
if (!bmp->bmHeight || !bmp->bmWidth) return 0;
if (bmp->bmPlanes != 1) return 0;
if ((bmp->bmBitsPixel != 1) && (bmp->bmBitsPixel != screenDepth)) return 0;
/* Create the BITMAPOBJ */
hbitmap = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC ); hbitmap = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC );
if (!hbitmap) return 0; if (!hbitmap) return 0;
bmpObjPtr = (BITMAPOBJ *) GDI_HEAP_ADDR( hbitmap ); bmpObjPtr = (BITMAPOBJ *) GDI_HEAP_ADDR( hbitmap );
/* Create the bitmap in global heap */
bmpObjPtr->hBitmap = GlobalAlloc( GMEM_MOVEABLE, sizeof(BITMAP) + size ); bmpObjPtr->size.cx = 0;
if (!bmpObjPtr->hBitmap) bmpObjPtr->size.cy = 0;
bmpObjPtr->bitmap = *bmp;
bmpObjPtr->bitmap.bmBits = NULL;
bmpObjPtr->bitmap.bmWidthBytes = (bmp->bmWidth*bmp->bmBitsPixel+15)/16 * 2;
/* Create the pixmap */
bmpObjPtr->pixmap = XCreatePixmap( display, rootWindow, bmp->bmWidth,
bmp->bmHeight, bmp->bmBitsPixel );
if (!bmpObjPtr->pixmap)
{ {
GDI_FreeObject( hbitmap ); GDI_HEAP_FREE( hbitmap );
return 0; hbitmap = 0;
} }
bmpPtr = (char *) GlobalLock( bmpObjPtr->hBitmap ); else if (bmp->bmBits) /* Set bitmap bits */
memcpy( bmpPtr, bmp, sizeof(BITMAP) ); SetBitmapBits( hbitmap, bmp->bmHeight*bmp->bmWidthBytes, bmp->bmBits );
((BITMAP *)bmpPtr)->bmBits = NULL;
if (bmp->bmBits) memcpy( bmpPtr + sizeof(BITMAP), bmp->bmBits, size );
GlobalUnlock( bmpObjPtr->hBitmap );
bmpObjPtr->bSelected = FALSE;
bmpObjPtr->hdc = 0;
bmpObjPtr->size.cx = 0;
bmpObjPtr->size.cy = 0;
return hbitmap;
}
/***********************************************************************
* BITMAP_GetSetBitmapBits
*/
LONG BITMAP_GetSetBitmapBits( HBITMAP hbitmap, LONG count,
LPSTR buffer, int set )
{
BITMAPOBJ * bmpObjPtr;
BITMAP * bmp;
DC * dc = NULL;
int maxSize;
if (!count) return 0;
bmpObjPtr = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if (!bmpObjPtr) return 0;
if (!(bmp = (BITMAP *) GlobalLock( bmpObjPtr->hBitmap ))) return 0;
if (bmpObjPtr->bSelected)
dc = (DC *) GDI_GetObjPtr( bmpObjPtr->hdc, DC_MAGIC );
maxSize = bmp->bmPlanes * bmp->bmHeight * bmp->bmWidthBytes;
if (count > maxSize) count = maxSize;
if (set)
{
memcpy( bmp+1, buffer, count );
if (dc) BITMAP_CopyToPixmap( bmp, dc->u.x.drawable,
0, 0, bmp->bmWidth, bmp->bmHeight );
}
else
{
if (dc) BITMAP_CopyFromPixmap( bmp, dc->u.x.drawable );
memcpy( buffer, bmp+1, count );
}
GlobalUnlock( bmpObjPtr->hBitmap );
return hbitmap; return hbitmap;
} }
@ -259,7 +145,29 @@ LONG BITMAP_GetSetBitmapBits( HBITMAP hbitmap, LONG count,
*/ */
LONG GetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer ) LONG GetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
{ {
return BITMAP_GetSetBitmapBits( hbitmap, count, buffer, 0 ); BITMAPOBJ * bmp;
LONG height;
XImage * image;
bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if (!bmp) return 0;
#ifdef DEBUG_BITMAP
printf( "GetBitmapBits: %dx%d %d colors %p\n",
bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
1 << bmp->bitmap.bmBitsPixel, buffer );
#endif
/* Only get entire lines */
height = count / bmp->bitmap.bmWidthBytes;
if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
if (!height) return 0;
if (!(image = BITMAP_BmpToImage( &bmp->bitmap, buffer ))) return 0;
XGetSubImage( display, bmp->pixmap, 0, 0, bmp->bitmap.bmWidth, height,
AllPlanes, ZPixmap, image, 0, 0 );
image->data = NULL;
XDestroyImage( image );
return height * bmp->bitmap.bmWidthBytes;
} }
@ -268,7 +176,29 @@ LONG GetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
*/ */
LONG SetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer ) LONG SetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
{ {
return BITMAP_GetSetBitmapBits( hbitmap, count, buffer, 1 ); BITMAPOBJ * bmp;
LONG height;
XImage * image;
bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if (!bmp) return 0;
#ifdef DEBUG_BITMAP
printf( "SetBitmapBits: %dx%d %d colors %p\n",
bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
1 << bmp->bitmap.bmBitsPixel, buffer );
#endif
/* Only set entire lines */
height = count / bmp->bitmap.bmWidthBytes;
if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
if (!height) return 0;
if (!(image = BITMAP_BmpToImage( &bmp->bitmap, buffer ))) return 0;
XPutImage( display, bmp->pixmap, BITMAP_GC(bmp), image, 0, 0,
0, 0, bmp->bitmap.bmWidth, height );
image->data = NULL;
XDestroyImage( image );
return height * bmp->bitmap.bmWidthBytes;
} }
@ -277,8 +207,7 @@ LONG SetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
*/ */
BOOL BMP_DeleteObject( HBITMAP hbitmap, BITMAPOBJ * bitmap ) BOOL BMP_DeleteObject( HBITMAP hbitmap, BITMAPOBJ * bitmap )
{ {
/* Free bitmap on global heap */ XFreePixmap( display, bitmap->pixmap );
GlobalFree( bitmap->hBitmap );
return GDI_FreeObject( hbitmap ); return GDI_FreeObject( hbitmap );
} }
@ -286,95 +215,39 @@ BOOL BMP_DeleteObject( HBITMAP hbitmap, BITMAPOBJ * bitmap )
/*********************************************************************** /***********************************************************************
* BMP_GetObject * BMP_GetObject
*/ */
int BMP_GetObject( BITMAPOBJ * bitmap, int count, LPSTR buffer ) int BMP_GetObject( BITMAPOBJ * bmp, int count, LPSTR buffer )
{ {
char * bmpPtr = (char *) GlobalLock( bitmap->hBitmap );
if (count > sizeof(BITMAP)) count = sizeof(BITMAP); if (count > sizeof(BITMAP)) count = sizeof(BITMAP);
memcpy( buffer, bmpPtr, count ); memcpy( buffer, &bmp->bitmap, count );
GlobalUnlock( bitmap->hBitmap );
return count; return count;
} }
/***********************************************************************
* BITMAP_UnselectBitmap
*
* Unselect the bitmap from the DC. Used by SelectObject and DeleteDC.
*/
BOOL BITMAP_UnselectBitmap( DC * dc )
{
BITMAPOBJ * bmp;
BITMAP * bmpPtr;
if (!dc->w.hBitmap) return TRUE;
bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap, BITMAP_MAGIC );
if (!bmp) return FALSE;
if (!(bmpPtr = (BITMAP *) GlobalLock( bmp->hBitmap ))) return FALSE;
BITMAP_CopyFromPixmap( bmpPtr, dc->u.x.drawable );
XFreePixmap( XT_display, dc->u.x.drawable );
bmp->bSelected = FALSE;
bmp->hdc = 0;
GlobalUnlock( bmp->hBitmap );
return TRUE;
}
/*********************************************************************** /***********************************************************************
* BITMAP_SelectObject * BITMAP_SelectObject
*/ */
HBITMAP BITMAP_SelectObject( HDC hdc, DC * dc, HBITMAP hbitmap, HBITMAP BITMAP_SelectObject( HDC hdc, DC * dc, HBITMAP hbitmap,
BITMAPOBJ * bitmap ) BITMAPOBJ * bmp )
{ {
BITMAP * bmp;
HBITMAP prevHandle = dc->w.hBitmap; HBITMAP prevHandle = dc->w.hBitmap;
if (!(dc->w.flags & DC_MEMORY)) return 0; if (!(dc->w.flags & DC_MEMORY)) return 0;
if (bitmap->bSelected && hbitmap != BITMAP_hbitmapMemDC) return 0; dc->u.x.drawable = bmp->pixmap;
if (!(bmp = (BITMAP *) GlobalLock( bitmap->hBitmap ))) return 0; dc->w.DCSizeX = bmp->bitmap.bmWidth;
dc->w.DCSizeY = bmp->bitmap.bmHeight;
/* Make sure the bitmap has the right format */ dc->w.hBitmap = hbitmap;
if ((bmp->bmPlanes != 1) || !BITMAP_FindGCForDepth( bmp->bmBitsPixel ))
{
GlobalUnlock( bitmap->hBitmap );
return 0;
}
/* Unselect the previous bitmap */
if (!BITMAP_UnselectBitmap( dc ))
{
GlobalUnlock( bitmap->hBitmap );
return 0;
}
/* Create the pixmap */
dc->u.x.drawable = XCreatePixmap( XT_display,
DefaultRootWindow( XT_display ),
bmp->bmWidth, bmp->bmHeight,
bmp->bmBitsPixel );
dc->w.DCSizeX = bmp->bmWidth;
dc->w.DCSizeY = bmp->bmHeight;
BITMAP_CopyToPixmap( bmp, dc->u.x.drawable,
0, 0, bmp->bmWidth, bmp->bmHeight );
/* Change GC depth if needed */ /* Change GC depth if needed */
if (dc->w.bitsPerPixel != bmp->bmBitsPixel) if (dc->w.bitsPerPixel != bmp->bitmap.bmBitsPixel)
{ {
XFreeGC( XT_display, dc->u.x.gc ); XFreeGC( display, dc->u.x.gc );
dc->u.x.gc = XCreateGC( XT_display, dc->u.x.drawable, 0, NULL ); dc->u.x.gc = XCreateGC( display, dc->u.x.drawable, 0, NULL );
dc->w.bitsPerPixel = bmp->bmBitsPixel; dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
DC_SetDeviceInfo( hdc, dc ); /* Re-select objects with changed depth */
SelectObject( hdc, dc->w.hPen );
SelectObject( hdc, dc->w.hBrush );
} }
GlobalUnlock( bitmap->hBitmap );
dc->w.hBitmap = hbitmap;
bitmap->bSelected = TRUE;
bitmap->hdc = hdc;
return prevHandle; return prevHandle;
} }

View File

@ -7,6 +7,8 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1993"; static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "gdi.h" #include "gdi.h"
#include "bitmap.h"
#include "prototypes.h"
#define NB_HATCH_STYLES 6 #define NB_HATCH_STYLES 6
@ -21,7 +23,8 @@ static char HatchBrushes[NB_HATCH_STYLES][8] =
{ 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 } /* HS_DIAGCROSS */ { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 } /* HS_DIAGCROSS */
}; };
extern XImage * BITMAP_BmpToImage( BITMAP *, void * ); extern WORD COLOR_ToPhysical( DC *dc, COLORREF color );
/*********************************************************************** /***********************************************************************
* CreateBrushIndirect (GDI.50) * CreateBrushIndirect (GDI.50)
@ -57,23 +60,21 @@ HBRUSH CreateHatchBrush( short style, COLORREF color )
HBRUSH CreatePatternBrush( HBITMAP hbitmap ) HBRUSH CreatePatternBrush( HBITMAP hbitmap )
{ {
LOGBRUSH logbrush = { BS_PATTERN, 0, 0 }; LOGBRUSH logbrush = { BS_PATTERN, 0, 0 };
BITMAPOBJ * bmpObj; BITMAPOBJ *bmp, *newbmp;
BITMAP * bmp;
#ifdef DEBUG_GDI #ifdef DEBUG_GDI
printf( "CreatePatternBrush: %d\n", hbitmap ); printf( "CreatePatternBrush: %d\n", hbitmap );
#endif #endif
/* Make a copy of the bitmap */ /* Make a copy of the bitmap */
if (!(bmpObj = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) if (!(bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
return 0; return 0;
if (!(bmp = (BITMAP *) GlobalLock( bmpObj->hBitmap ))) return 0; logbrush.lbHatch = CreateBitmapIndirect( &bmp->bitmap );
logbrush.lbHatch = CreateBitmap( bmp->bmWidth, bmp->bmHeight, newbmp = (BITMAPOBJ *) GDI_GetObjPtr( logbrush.lbHatch, BITMAP_MAGIC );
bmp->bmPlanes, bmp->bmBitsPixel, if (!newbmp) return 0;
((char *)bmp) + sizeof(BITMAP) ); XCopyArea( display, bmp->pixmap, newbmp->pixmap, BITMAP_GC(bmp),
GlobalUnlock( bmpObj->hBitmap ); 0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight, 0, 0 );
if (!logbrush.lbHatch) return 0;
return CreateBrushIndirect( &logbrush ); return CreateBrushIndirect( &logbrush );
} }
@ -171,33 +172,47 @@ int BRUSH_GetObject( BRUSHOBJ * brush, int count, LPSTR buffer )
} }
/***********************************************************************
* BRUSH_MakeSolidBrush
*/
static void BRUSH_SelectSolidBrush( DC *dc, COLORREF color )
{
if ((dc->w.bitsPerPixel > 1) && !COLOR_IsSolid( color ))
{
/* Dithered brush */
dc->u.x.brush.pixmap = DITHER_DitherColor( dc, color );
dc->u.x.brush.fillStyle = FillTiled;
dc->u.x.brush.pixel = 0;
}
else
{
/* Solid brush */
dc->u.x.brush.pixel = COLOR_ToPhysical( dc, color );
dc->u.x.brush.fillStyle = FillSolid;
}
}
/*********************************************************************** /***********************************************************************
* BRUSH_SelectPatternBrush * BRUSH_SelectPatternBrush
*/ */
BOOL BRUSH_SelectPatternBrush( DC * dc, HBITMAP hbitmap ) static BOOL BRUSH_SelectPatternBrush( DC * dc, HBITMAP hbitmap )
{ {
BITMAPOBJ * bmpObjPtr; BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
BITMAP * bmp; if (!bmp) return FALSE;
dc->u.x.brush.pixmap = XCreatePixmap( display, rootWindow,
8, 8, bmp->bitmap.bmBitsPixel );
XCopyArea( display, bmp->pixmap, dc->u.x.brush.pixmap,
BITMAP_GC(bmp), 0, 0, 8, 8, 0, 0 );
bmpObjPtr = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ); if (bmp->bitmap.bmBitsPixel > 1)
if (!bmpObjPtr) return FALSE;
if (!(bmp = (BITMAP *) GlobalLock( bmpObjPtr->hBitmap ))) return FALSE;
dc->u.x.brush.pixmap = XCreatePixmap( XT_display,
DefaultRootWindow(XT_display),
8, 8, bmp->bmBitsPixel );
BITMAP_CopyToPixmap( bmp, dc->u.x.brush.pixmap, 0, 0, 8, 8 );
if (bmp->bmBitsPixel > 1)
{ {
dc->u.x.brush.fillStyle = FillTiled; dc->u.x.brush.fillStyle = FillTiled;
XSetTile( XT_display, dc->u.x.gc, dc->u.x.brush.pixmap );
dc->u.x.brush.pixel = 0; /* Ignored */ dc->u.x.brush.pixel = 0; /* Ignored */
} }
else else
{ {
dc->u.x.brush.fillStyle = FillOpaqueStippled; dc->u.x.brush.fillStyle = FillOpaqueStippled;
XSetStipple( XT_display, dc->u.x.gc, dc->u.x.brush.pixmap );
dc->u.x.brush.pixel = -1; /* Special case (see DC_SetupGCForBrush) */ dc->u.x.brush.pixel = -1; /* Special case (see DC_SetupGCForBrush) */
} }
return TRUE; return TRUE;
@ -218,28 +233,24 @@ HBRUSH BRUSH_SelectObject( HDC hdc, DC * dc, HBRUSH hbrush, BRUSHOBJ * brush )
if (dc->u.x.brush.pixmap) if (dc->u.x.brush.pixmap)
{ {
XFreePixmap( XT_display, dc->u.x.brush.pixmap ); XFreePixmap( display, dc->u.x.brush.pixmap );
dc->u.x.brush.pixmap = 0; dc->u.x.brush.pixmap = 0;
} }
dc->u.x.brush.style = brush->logbrush.lbStyle; dc->u.x.brush.style = brush->logbrush.lbStyle;
switch(brush->logbrush.lbStyle) switch(brush->logbrush.lbStyle)
{ {
case BS_SOLID:
case BS_NULL: case BS_NULL:
dc->u.x.brush.pixel = GetNearestPaletteIndex( dc->w.hPalette, break;
brush->logbrush.lbColor );
dc->u.x.brush.fillStyle = FillSolid; case BS_SOLID:
BRUSH_SelectSolidBrush( dc, brush->logbrush.lbColor );
break; break;
case BS_HATCHED: case BS_HATCHED:
dc->u.x.brush.pixel = GetNearestPaletteIndex( dc->w.hPalette, dc->u.x.brush.pixel = COLOR_ToPhysical( dc, brush->logbrush.lbColor );
brush->logbrush.lbColor ); dc->u.x.brush.pixmap = XCreateBitmapFromData( display, rootWindow,
dc->u.x.brush.pixmap = XCreateBitmapFromData(XT_display, HatchBrushes[brush->logbrush.lbHatch], 8, 8 );
DefaultRootWindow(XT_display),
HatchBrushes[brush->logbrush.lbHatch],
8, 8 );
XSetStipple( XT_display, dc->u.x.gc, dc->u.x.brush.pixmap );
dc->u.x.brush.fillStyle = FillStippled; dc->u.x.brush.fillStyle = FillStippled;
break; break;
@ -264,5 +275,3 @@ HBRUSH BRUSH_SelectObject( HDC hdc, DC * dc, HBRUSH hbrush, BRUSHOBJ * brush )
return prevHandle; return prevHandle;
} }

View File

@ -11,55 +11,46 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "windows.h" #include "windows.h"
#include "options.h" #include "options.h"
#include "gdi.h"
extern Display * display;
extern Screen * screen;
Colormap COLOR_WinColormap = 0; Colormap COLOR_WinColormap = 0;
/* System palette static colors */
/* System colors */ #define NB_RESERVED_COLORS 20
static const char * SysColors[] = /* The first and last eight colors are EGA colors */
static PALETTEENTRY COLOR_sysPaletteEntries[NB_RESERVED_COLORS] =
{ {
/* Low pixel values (0..7) */ /* red green blue flags */
{ 0x00, 0x00, 0x00, 0 },
{ 0x80, 0x00, 0x00, 0 },
{ 0x00, 0x80, 0x00, 0 },
{ 0x80, 0x80, 0x00, 0 },
{ 0x00, 0x00, 0x80, 0 },
{ 0x80, 0x00, 0x80, 0 },
{ 0x00, 0x80, 0x80, 0 },
{ 0xc0, 0xc0, 0xc0, 0 },
{ 0xc0, 0xdc, 0xc0, 0 },
{ 0xa6, 0xca, 0xf0, 0 },
"black", "red4", "green4", "yellow4", { 0xff, 0xfb, 0xf0, 0 },
"blue4", "magenta4", "cyan4", "gray50", { 0xa0, 0xa0, 0xa4, 0 },
{ 0x80, 0x80, 0x80, 0 },
/* High pixel values (max-7..max) */ { 0xff, 0x00, 0x00, 0 },
{ 0x00, 0xff, 0x00, 0 },
"gray75", "red", "green", "yellow", { 0xff, 0xff, 0x00, 0 },
"blue", "magenta", "cyan", "white" { 0x00, 0x00, 0xff, 0 },
{ 0xff, 0x00, 0xff, 0 },
{ 0x00, 0xff, 0xff, 0 },
{ 0xff, 0xff, 0xff, 0 }
}; };
#define NB_SYS_COLORS (sizeof(SysColors) / sizeof(SysColors[0])) static HANDLE hSysColorTranslation = 0;
/* Map an EGA index (0..15) to a pixel value. Used for dithering. */
/*********************************************************************** int COLOR_mapEGAPixel[16];
* COLOR_FillDefaultMap
*
* Try to allocate colors from default screen map (used when we
* don't want to or can't use a private map).
*/
static int COLOR_FillDefaultMap()
{
XColor color;
int i, total = 0;
for (i = 0; i < NB_SYS_COLORS; i++)
{
if (XParseColor( display, DefaultColormapOfScreen( screen ),
SysColors[i], &color ))
{
if (XAllocColor( display, DefaultColormapOfScreen( screen ),
&color ))
total++;
}
}
return total;
}
/*********************************************************************** /***********************************************************************
@ -70,50 +61,108 @@ static int COLOR_FillDefaultMap()
static BOOL COLOR_BuildMap( Colormap map, int depth, int size ) static BOOL COLOR_BuildMap( Colormap map, int depth, int size )
{ {
XColor color; XColor color;
int i; int r, g, b, red_incr, green_incr, blue_incr;
int index = 0;
/* Fill the whole map with a range of colors */ /* Fill the whole map with a range of colors */
if ((1 << depth) > NB_SYS_COLORS) blue_incr = 0x10000 >> (depth / 3);
{ red_incr = 0x10000 >> ((depth + 1) / 3);
int red_incr, green_incr, blue_incr; green_incr = 0x10000 >> ((depth + 2) / 3);
int r, g, b;
blue_incr = 0x10000 >> (depth / 3);
red_incr = 0x10000 >> ((depth + 1) / 3);
green_incr = 0x10000 >> ((depth + 2) / 3);
for (i = 0, r = red_incr - 1; r < 0x10000; r += red_incr) for (r = red_incr - 1; r < 0x10000; r += red_incr)
for (g = green_incr - 1; g < 0x10000; g += green_incr) for (g = green_incr - 1; g < 0x10000; g += green_incr)
for (b = blue_incr - 1; b < 0x10000; b += blue_incr) for (b = blue_incr - 1; b < 0x10000; b += blue_incr)
{ {
if (i >= size) break; if (index >= size) break;
color.pixel = i++; color.pixel = index++;
color.red = r; color.red = r;
color.green = g; color.green = g;
color.blue = b; color.blue = b;
XStoreColor( display, map, &color ); XStoreColor( display, map, &color );
} }
}
/* Store the system palette colors */
for (i = 0; i < NB_SYS_COLORS; i++)
{
if (!XParseColor( display, map, SysColors[i], &color ))
color.red = color.green = color.blue = color.flags = 0;
if (i < NB_SYS_COLORS/2) color.pixel = i;
else color.pixel = (1 << depth) - NB_SYS_COLORS + i;
if (color.pixel < size) XStoreColor( display, map, &color );
}
return TRUE; return TRUE;
} }
/*********************************************************************** /***********************************************************************
* COLOR_Init * COLOR_InitPalette
*
* Create the system palette.
*/ */
BOOL COLOR_Init() static HPALETTE COLOR_InitPalette()
{
int i, size;
XColor color;
HPALETTE hpalette;
LOGPALETTE * palPtr;
WORD *colorTranslation;
if (!(hSysColorTranslation = GDI_HEAP_ALLOC( GMEM_MOVEABLE,
sizeof(WORD)*NB_RESERVED_COLORS ))) return FALSE;
colorTranslation = (WORD *) GDI_HEAP_ADDR( hSysColorTranslation );
size = DefaultVisual( display, DefaultScreen(display) )->map_entries;
for (i = 0; i < NB_RESERVED_COLORS; i++)
{
color.red = COLOR_sysPaletteEntries[i].peRed * 65535 / 255;
color.green = COLOR_sysPaletteEntries[i].peGreen * 65535 / 255;
color.blue = COLOR_sysPaletteEntries[i].peBlue * 65535 / 255;
color.flags = DoRed | DoGreen | DoBlue;
if (COLOR_WinColormap != DefaultColormapOfScreen(screen))
{
if (i < NB_RESERVED_COLORS/2)
{
/* Bottom half of the colormap */
color.pixel = i;
if (color.pixel >= size/2) continue;
}
else
{
/* Top half of the colormap */
color.pixel = size - NB_RESERVED_COLORS + i;
if (color.pixel < size/2) continue;
}
XStoreColor( display, COLOR_WinColormap, &color );
}
else if (!XAllocColor( display, COLOR_WinColormap, &color ))
{
printf( "Warning: Not enough free colors. Try using the -privatemap option.\n" );
color.pixel = color.red = color.green = color.blue = 0;
}
colorTranslation[i] = color.pixel;
#if 0
/* Put the allocated colors back in the list */
COLOR_sysPaletteEntries[i].peRed = color.red >> 8;
COLOR_sysPaletteEntries[i].peGreen = color.green >> 8;
COLOR_sysPaletteEntries[i].peBlue = color.blue >> 8;
#endif
/* Set EGA mapping if color in the first or last eight */
if (i < 8)
COLOR_mapEGAPixel[i] = color.pixel;
else if (i >= NB_RESERVED_COLORS-8)
COLOR_mapEGAPixel[i - (NB_RESERVED_COLORS-16)] = color.pixel;
}
palPtr = malloc( sizeof(LOGPALETTE) + (NB_RESERVED_COLORS-1)*sizeof(PALETTEENTRY) );
if (!palPtr) return FALSE;
palPtr->palVersion = 0x300;
palPtr->palNumEntries = NB_RESERVED_COLORS;
memcpy( palPtr->palPalEntry, COLOR_sysPaletteEntries,
sizeof(COLOR_sysPaletteEntries) );
hpalette = CreatePalette( palPtr );
free( palPtr );
return hpalette;
}
/***********************************************************************
* COLOR_Init
*
* Initialize color map and system palette.
*/
HPALETTE COLOR_Init()
{ {
Visual * visual = DefaultVisual( display, DefaultScreen(display) ); Visual * visual = DefaultVisual( display, DefaultScreen(display) );
@ -124,14 +173,19 @@ BOOL COLOR_Init()
case DirectColor: case DirectColor:
if (Options.usePrivateMap) if (Options.usePrivateMap)
{ {
COLOR_WinColormap = XCreateColormap( display, COLOR_WinColormap = XCreateColormap( display, rootWindow,
DefaultRootWindow(display),
visual, AllocAll ); visual, AllocAll );
if (COLOR_WinColormap) if (COLOR_WinColormap)
{ {
COLOR_BuildMap(COLOR_WinColormap, COLOR_BuildMap( COLOR_WinColormap, screenDepth,
DefaultDepth(display, DefaultScreen(display)), visual->map_entries );
visual->map_entries ); if (rootWindow != DefaultRootWindow(display))
{
XSetWindowAttributes win_attr;
win_attr.colormap = COLOR_WinColormap;
XChangeWindowAttributes( display, rootWindow,
CWColormap, &win_attr );
}
break; break;
} }
} }
@ -139,9 +193,109 @@ BOOL COLOR_Init()
case StaticGray: case StaticGray:
case StaticColor: case StaticColor:
case TrueColor: case TrueColor:
COLOR_FillDefaultMap();
COLOR_WinColormap = DefaultColormapOfScreen( screen ); COLOR_WinColormap = DefaultColormapOfScreen( screen );
break; break;
} }
return TRUE; return COLOR_InitPalette();
}
/***********************************************************************
* COLOR_IsSolid
*
* Check whether 'color' can be represented with a solid color.
*/
BOOL COLOR_IsSolid( COLORREF color )
{
int i;
PALETTEENTRY *pEntry = COLOR_sysPaletteEntries;
if (color & 0xff000000) return TRUE;
if (!color || (color == 0xffffff)) return TRUE;
for (i = NB_RESERVED_COLORS; i > 0; i--, pEntry++)
{
if ((GetRValue(color) == pEntry->peRed) &&
(GetGValue(color) == pEntry->peGreen) &&
(GetBValue(color) == pEntry->peBlue)) return TRUE;
}
return FALSE;
}
/***********************************************************************
* COLOR_ToPhysical
*
* Return the physical color closest to 'color'.
*/
WORD COLOR_ToPhysical( DC *dc, COLORREF color )
{
WORD index = 0;
WORD *mapping;
if (!dc->u.x.pal.hMapping) return 0;
switch(color & 0xff000000)
{
case 0: /* RGB */
index = GetNearestPaletteIndex( STOCK_DEFAULT_PALETTE, color );
break;
case 1: /* PALETTEINDEX */
index = color & 0xffff;
break;
case 2: /* PALETTERGB */
index = GetNearestPaletteIndex( dc->w.hPalette, color );
break;
}
if (index >= dc->u.x.pal.mappingSize) return 0;
mapping = (WORD *) GDI_HEAP_ADDR( dc->u.x.pal.hMapping );
return mapping[index];
}
/***********************************************************************
* COLOR_SetMapping
*
* Set the color-mapping table in a DC.
*/
void COLOR_SetMapping( DC *dc, HANDLE map, WORD size )
{
WORD *pmap, *pnewmap;
if (dc->u.x.pal.hMapping && (dc->u.x.pal.hMapping != hSysColorTranslation))
GDI_HEAP_FREE( dc->u.x.pal.hMapping );
if (map && (map != hSysColorTranslation))
{
/* Copy mapping table */
dc->u.x.pal.hMapping = GDI_HEAP_ALLOC(GMEM_MOVEABLE,sizeof(WORD)*size);
pmap = (WORD *) GDI_HEAP_ADDR( map );
pnewmap = (WORD *) GDI_HEAP_ADDR( dc->u.x.pal.hMapping );
memcpy( pnewmap, pmap, sizeof(WORD)*size );
}
else dc->u.x.pal.hMapping = map;
dc->u.x.pal.mappingSize = size;
}
/***********************************************************************
* GetNearestColor (GDI.154)
*/
COLORREF GetNearestColor( HDC hdc, COLORREF color )
{
WORD index;
DC *dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return 0;
index = COLOR_ToPhysical( dc, color & 0xffffff );
return PALETTEINDEX( index );
}
/***********************************************************************
* RealizeDefaultPalette (GDI.365)
*/
WORD RealizeDefaultPalette( HDC hdc )
{
DC *dc;
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
dc->w.hPalette = STOCK_DEFAULT_PALETTE;
COLOR_SetMapping( dc, hSysColorTranslation, NB_RESERVED_COLORS );
return NB_RESERVED_COLORS;
} }

View File

@ -40,7 +40,6 @@ const WIN_DC_INFO DCVAL_defaultValues =
0, /* breakCount */ 0, /* breakCount */
0, /* breakExtra */ 0, /* breakExtra */
0, /* breakRem */ 0, /* breakRem */
1, /* planes */
1, /* bitsPerPixel */ 1, /* bitsPerPixel */
MM_TEXT, /* MapMode */ MM_TEXT, /* MapMode */
0, /* DCOrgX */ 0, /* DCOrgX */

View File

@ -8,13 +8,13 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "gdi.h" #include "gdi.h"
#include "bitmap.h"
#include "icon.h" #include "icon.h"
extern WORD COLOR_ToPhysical( DC *dc, COLORREF color ); /* color.c */
extern XImage * BITMAP_BmpToImage( BITMAP *, void * );
/*********************************************************************** /***********************************************************************
* DIB_BitmapInfoSize * DIB_BitmapInfoSize
@ -39,8 +39,9 @@ int DIB_BitmapInfoSize( BITMAPINFO * info, WORD coloruse )
* *
* Create an XImage pointing to the bitmap data. * Create an XImage pointing to the bitmap data.
*/ */
XImage * DIB_DIBmpToImage( BITMAPINFOHEADER * bmp, void * bmpData ) static XImage *DIB_DIBmpToImage( BITMAPINFOHEADER * bmp, void * bmpData )
{ {
extern void _XInitImageFuncPtrs( XImage* );
XImage * image; XImage * image;
int bytesPerLine = (bmp->biWidth * bmp->biBitCount + 31) / 32 * 4; int bytesPerLine = (bmp->biWidth * bmp->biBitCount + 31) / 32 * 4;
@ -56,6 +57,198 @@ XImage * DIB_DIBmpToImage( BITMAPINFOHEADER * bmp, void * bmpData )
} }
/***********************************************************************
* DIB_SetImageBits_1
*
* SetDIBits for a 1-bit deep DIB.
*/
static void DIB_SetImageBits_1( WORD lines, BYTE *bits, WORD width,
WORD *colors, XImage *bmpImage )
{
WORD i, x;
BYTE pad, pix;
if (!(width & 31)) pad = 0;
else pad = ((32 - (width & 31)) + 7) / 8;
while (lines--)
{
for (i = width/8, x = 0; (i > 0); i--)
{
pix = *bits++;
XPutPixel( bmpImage, x++, lines, colors[pix >> 7] );
XPutPixel( bmpImage, x++, lines, colors[(pix >> 6) & 1] );
XPutPixel( bmpImage, x++, lines, colors[(pix >> 5) & 1] );
XPutPixel( bmpImage, x++, lines, colors[(pix >> 4) & 1] );
XPutPixel( bmpImage, x++, lines, colors[(pix >> 3) & 1] );
XPutPixel( bmpImage, x++, lines, colors[(pix >> 2) & 1] );
XPutPixel( bmpImage, x++, lines, colors[(pix >> 1) & 1] );
XPutPixel( bmpImage, x++, lines, colors[pix & 1] );
}
pix = *bits;
switch(width & 7)
{
case 7: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
case 6: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
case 5: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
case 4: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
case 3: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
case 2: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
case 1: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] );
}
bits += pad;
}
}
/***********************************************************************
* DIB_SetImageBits_4
*
* SetDIBits for a 4-bit deep DIB.
*/
static void DIB_SetImageBits_4( WORD lines, BYTE *bits, WORD width,
WORD *colors, XImage *bmpImage )
{
WORD i, x;
BYTE pad;
if (!(width & 7)) pad = 0;
else pad = ((8 - (width & 7)) + 1) / 2;
while (lines--)
{
for (i = width/2, x = 0; i > 0; i--)
{
BYTE pix = *bits++;
XPutPixel( bmpImage, x++, lines, colors[pix >> 4] );
XPutPixel( bmpImage, x++, lines, colors[pix & 0x0f] );
}
if (width & 1) XPutPixel( bmpImage, x, lines, colors[*bits >> 4] );
bits += pad;
}
}
/***********************************************************************
* DIB_SetImageBits_8
*
* SetDIBits for an 8-bit deep DIB.
*/
static void DIB_SetImageBits_8( WORD lines, BYTE *bits, WORD width,
WORD *colors, XImage *bmpImage )
{
WORD x;
BYTE pad = (4 - (width & 3)) & 3;
while (lines--)
{
for (x = 0; x < width; x++)
XPutPixel( bmpImage, x, lines, colors[*bits++] );
bits += pad;
}
}
/***********************************************************************
* DIB_SetImageBits_24
*
* SetDIBits for a 24-bit deep DIB.
*/
static void DIB_SetImageBits_24( WORD lines, BYTE *bits, WORD width,
DC *dc, XImage *bmpImage )
{
WORD x;
BYTE pad = (4 - ((width*3) & 3)) & 3;
while (lines--)
{
for (x = 0; x < width; x++, bits += 3)
{
XPutPixel( bmpImage, x, lines,
COLOR_ToPhysical( dc, RGB(bits[0],bits[1],bits[2]) ));
}
bits += pad;
}
}
/***********************************************************************
* DIB_SetImageBits
*
* Transfer the bits to an X image.
* Helper function for SetDIBits() and SetDIBitsToDevice().
*/
static int DIB_SetImageBits( DC *dc, WORD lines, WORD depth, LPSTR bits,
BITMAPINFO *info, WORD coloruse,
Drawable drawable, GC gc, int xSrc, int ySrc,
int xDest, int yDest, int width, int height )
{
WORD *colorMapping;
XImage *bmpImage;
void *bmpData;
int i, colors, widthBytes;
/* Build the color mapping table */
if (info->bmiHeader.biBitCount == 24) colorMapping = NULL;
else
{
colors = info->bmiHeader.biClrUsed;
if (!colors) colors = 1 << info->bmiHeader.biBitCount;
if (!(colorMapping = (WORD *)malloc( colors * sizeof(WORD) )))
return 0;
if (coloruse == DIB_RGB_COLORS)
{
RGBQUAD * rgbPtr = info->bmiColors;
for (i = 0; i < colors; i++, rgbPtr++)
colorMapping[i] = COLOR_ToPhysical( dc, RGB(rgbPtr->rgbRed,
rgbPtr->rgbGreen,
rgbPtr->rgbBlue) );
}
else
{
WORD * index = (WORD *)info->bmiColors;
for (i = 0; i < colors; i++, index++)
colorMapping[i] = COLOR_ToPhysical( dc, PALETTEINDEX(*index) );
}
}
/* Transfer the pixels */
widthBytes = (info->bmiHeader.biWidth * depth + 31) / 32 * 4;
bmpData = malloc( lines * widthBytes );
bmpImage = XCreateImage( display, DefaultVisualOfScreen(screen),
depth, ZPixmap, 0, bmpData,
info->bmiHeader.biWidth, lines, 32, widthBytes );
switch(info->bmiHeader.biBitCount)
{
case 1:
DIB_SetImageBits_1( lines, bits, info->bmiHeader.biWidth,
colorMapping, bmpImage );
break;
case 4:
DIB_SetImageBits_4( lines, bits, info->bmiHeader.biWidth,
colorMapping, bmpImage );
break;
case 8:
DIB_SetImageBits_8( lines, bits, info->bmiHeader.biWidth,
colorMapping, bmpImage );
break;
case 24:
DIB_SetImageBits_24( lines, bits, info->bmiHeader.biWidth,
dc, bmpImage );
break;
}
if (colorMapping) free(colorMapping);
XPutImage( display, drawable, gc, bmpImage, xSrc, ySrc,
xDest, yDest, width, height );
XDestroyImage( bmpImage );
return lines;
}
/*********************************************************************** /***********************************************************************
* SetDIBits (GDI.440) * SetDIBits (GDI.440)
*/ */
@ -63,64 +256,53 @@ int SetDIBits( HDC hdc, HBITMAP hbitmap, WORD startscan, WORD lines,
LPSTR bits, BITMAPINFO * info, WORD coloruse ) LPSTR bits, BITMAPINFO * info, WORD coloruse )
{ {
DC * dc; DC * dc;
BITMAPOBJ * bmpObj; BITMAPOBJ * bmp;
BITMAP * bmp;
WORD * colorMapping; /* Check parameters */
RGBQUAD * rgbPtr;
XImage * bmpImage, * dibImage;
int i, x, y, pixel, colors;
if (!lines) return 0;
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0; if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
if (!(bmpObj = (BITMAPOBJ *)GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) if (!(bmp = (BITMAPOBJ *)GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
return 0; return 0;
if (!(bmp = (BITMAP *) GlobalLock( bmpObj->hBitmap ))) return 0; if (!lines || (startscan >= (WORD)info->bmiHeader.biHeight)) return 0;
if (startscan+lines > info->bmiHeader.biHeight)
lines = info->bmiHeader.biHeight - startscan;
/* Build the color mapping table */ return DIB_SetImageBits( dc, lines, bmp->bitmap.bmBitsPixel,
bits, info, coloruse, bmp->pixmap, BITMAP_GC(bmp),
0, 0, 0, startscan, bmp->bitmap.bmWidth, lines );
}
if (info->bmiHeader.biBitCount == 24) colorMapping = NULL;
else if (coloruse == DIB_RGB_COLORS)
{
colors = info->bmiHeader.biClrUsed;
if (!colors) colors = 1 << info->bmiHeader.biBitCount;
if (!(colorMapping = (WORD *)malloc( colors * sizeof(WORD) )))
{
GlobalUnlock( bmpObj->hBitmap );
return 0;
}
for (i = 0, rgbPtr = info->bmiColors; i < colors; i++, rgbPtr++)
colorMapping[i] = GetNearestPaletteIndex( dc->w.hPalette,
RGB(rgbPtr->rgbRed,
rgbPtr->rgbGreen,
rgbPtr->rgbBlue) );
}
else colorMapping = (WORD *)info->bmiColors;
/* Transfer the pixels (very slow...) */ /***********************************************************************
* SetDIBitsToDevice (GDI.443)
*/
int SetDIBitsToDevice( HDC hdc, short xDest, short yDest, WORD cx, WORD cy,
WORD xSrc, WORD ySrc, WORD startscan, WORD lines,
LPSTR bits, BITMAPINFO * info, WORD coloruse )
{
DC * dc;
bmpImage = BITMAP_BmpToImage( bmp, ((char *)bmp) + sizeof(BITMAP) ); /* Check parameters */
dibImage = DIB_DIBmpToImage( &info->bmiHeader, bits );
for (y = 0; y < lines; y++) if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
{ if (!lines || (startscan >= info->bmiHeader.biHeight)) return 0;
for (x = 0; x < info->bmiHeader.biWidth; x++) if (startscan+lines > info->bmiHeader.biHeight)
{ lines = info->bmiHeader.biHeight - startscan;
pixel = XGetPixel( dibImage, x, y ); if (ySrc < startscan) ySrc = startscan;
if (colorMapping) pixel = colorMapping[pixel]; else if (ySrc >= startscan+lines) return 0;
else pixel = GetNearestPaletteIndex(dc->w.hPalette,(COLORREF)pixel); if (xSrc >= info->bmiHeader.biWidth) return 0;
XPutPixel( bmpImage, x, bmp->bmHeight - startscan - y - 1, pixel ); if (ySrc+cy >= startscan+lines) cy = startscan + lines - ySrc;
} if (xSrc+cx >= info->bmiHeader.biWidth) cx = info->bmiHeader.biWidth-xSrc;
} if (!cx || !cy) return 0;
bmpImage->data = NULL; DC_SetupGCForText( dc ); /* To have the correct ROP */
dibImage->data = NULL; return DIB_SetImageBits( dc, lines, dc->w.bitsPerPixel,
XDestroyImage( bmpImage ); bits, info, coloruse,
XDestroyImage( dibImage ); dc->u.x.drawable, dc->u.x.gc,
xSrc, ySrc - startscan,
if (colorMapping && (coloruse == DIB_RGB_COLORS)) free(colorMapping); dc->w.DCOrgX + XLPTODP( dc, xDest ),
dc->w.DCOrgY + YLPTODP( dc, yDest ),
GlobalUnlock( bmpObj->hBitmap ); cx, cy );
return lines;
} }
@ -131,8 +313,7 @@ int GetDIBits( HDC hdc, HBITMAP hbitmap, WORD startscan, WORD lines,
LPSTR bits, BITMAPINFO * info, WORD coloruse ) LPSTR bits, BITMAPINFO * info, WORD coloruse )
{ {
DC * dc; DC * dc;
BITMAPOBJ * bmpObj; BITMAPOBJ * bmp;
BITMAP * bmp;
PALETTEENTRY * palEntry; PALETTEENTRY * palEntry;
PALETTEOBJ * palette; PALETTEOBJ * palette;
XImage * bmpImage, * dibImage; XImage * bmpImage, * dibImage;
@ -140,11 +321,10 @@ int GetDIBits( HDC hdc, HBITMAP hbitmap, WORD startscan, WORD lines,
if (!lines) return 0; if (!lines) return 0;
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0; if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
if (!(bmpObj = (BITMAPOBJ *)GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) if (!(bmp = (BITMAPOBJ *)GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
return 0; return 0;
if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC ))) if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
return 0; return 0;
if (!(bmp = (BITMAP *) GlobalLock( bmpObj->hBitmap ))) return 0;
/* Transfer color info */ /* Transfer color info */
@ -165,7 +345,8 @@ int GetDIBits( HDC hdc, HBITMAP hbitmap, WORD startscan, WORD lines,
if (bits) if (bits)
{ {
bmpImage = BITMAP_BmpToImage( bmp, ((char *)bmp) + sizeof(BITMAP) ); bmpImage = XGetImage( display, bmp->pixmap, 0, 0, bmp->bitmap.bmWidth,
bmp->bitmap.bmHeight, AllPlanes, ZPixmap );
dibImage = DIB_DIBmpToImage( &info->bmiHeader, bits ); dibImage = DIB_DIBmpToImage( &info->bmiHeader, bits );
for (y = 0; y < lines; y++) for (y = 0; y < lines; y++)
@ -173,18 +354,15 @@ int GetDIBits( HDC hdc, HBITMAP hbitmap, WORD startscan, WORD lines,
for (x = 0; x < info->bmiHeader.biWidth; x++) for (x = 0; x < info->bmiHeader.biWidth; x++)
{ {
XPutPixel( dibImage, x, y, XPutPixel( dibImage, x, y,
XGetPixel(bmpImage, x, bmp->bmHeight-startscan-y-1) ); XGetPixel(bmpImage, x, bmp->bitmap.bmHeight-startscan-y-1) );
} }
} }
bmpImage->data = NULL;
dibImage->data = NULL; dibImage->data = NULL;
XDestroyImage( bmpImage );
XDestroyImage( dibImage ); XDestroyImage( dibImage );
XDestroyImage( bmpImage );
} }
GlobalUnlock( bmpObj->hBitmap );
return lines; return lines;
} }

140
objects/dither.c Normal file
View File

@ -0,0 +1,140 @@
/*
* Dithering functions
*
* Copyright 1994 Alexandre Julliard
*/
static char Copyright[] = "Copyright Alexandre Julliard, 1994";
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "gdi.h"
#include "bitmap.h"
/* Levels of each primary */
#define PRIMARY_LEVELS 3
#define TOTAL_LEVELS (PRIMARY_LEVELS*PRIMARY_LEVELS*PRIMARY_LEVELS)
/* Dithering matrix size */
#define MATRIX_SIZE 8
#define MATRIX_SIZE_2 (MATRIX_SIZE*MATRIX_SIZE)
/* Total number of possible levels for a dithered primary color */
#define DITHER_LEVELS (MATRIX_SIZE_2 * (PRIMARY_LEVELS-1) + 1)
/* Dithering matrix */
static const int dither_matrix[MATRIX_SIZE_2] =
{
0, 32, 8, 40, 2, 34, 10, 42,
48, 16, 56, 24, 50, 18, 58, 26,
12, 44, 4, 36, 14, 46, 6, 38,
60, 28, 52, 20, 62, 30, 54, 22,
3, 35, 11, 43, 1, 33, 9, 41,
51, 19, 59, 27, 49, 17, 57, 25,
15, 47, 7, 39, 13, 45, 5, 37,
63, 31, 55, 23, 61, 29, 53, 21
};
/* Mapping between (R,G,B) triples and EGA colors */
static const int EGAmapping[TOTAL_LEVELS] =
{
0, /* 000000 -> 000000 */
4, /* 00007f -> 000080 */
12, /* 0000ff -> 0000ff */
2, /* 007f00 -> 008000 */
6, /* 007f7f -> 008080 */
6, /* 007fff -> 008080 */
10, /* 00ff00 -> 00ff00 */
6, /* 00ff7f -> 008080 */
14, /* 00ffff -> 00ffff */
1, /* 7f0000 -> 800000 */
5, /* 7f007f -> 800080 */
5, /* 7f00ff -> 800080 */
3, /* 7f7f00 -> 808000 */
8, /* 7f7f7f -> 808080 */
7, /* 7f7fff -> c0c0c0 */
3, /* 7fff00 -> 808000 */
7, /* 7fff7f -> c0c0c0 */
7, /* 7fffff -> c0c0c0 */
9, /* ff0000 -> ff0000 */
5, /* ff007f -> 800080 */
13, /* ff00ff -> ff00ff */
3, /* ff7f00 -> 808000 */
7, /* ff7f7f -> c0c0c0 */
7, /* ff7fff -> c0c0c0 */
11, /* ffff00 -> ffff00 */
7, /* ffff7f -> c0c0c0 */
15 /* ffffff -> ffffff */
};
/* Map an EGA index (0..15) to a pixel value */
extern int COLOR_mapEGAPixel[16]; /* in color.c */
#define PIXEL_VALUE(r,g,b) \
COLOR_mapEGAPixel[EGAmapping[((r)*PRIMARY_LEVELS+(g))*PRIMARY_LEVELS+(b)]]
/* X image for building dithered pixmap */
static XImage *ditherImage = NULL;
static char *imageData = NULL;
/***********************************************************************
* DITHER_Init
*
* Create the X image used for dithering.
*/
BOOL DITHER_Init()
{
int bytes_per_line = (screenDepth * MATRIX_SIZE + 7) / 8;
if (!(imageData = (char *) malloc( bytes_per_line * MATRIX_SIZE )))
return FALSE;
ditherImage = XCreateImage( display, DefaultVisualOfScreen(screen),
screenDepth, ZPixmap, 0, imageData,
MATRIX_SIZE, MATRIX_SIZE, 8, bytes_per_line );
return (ditherImage != NULL);
}
/***********************************************************************
* DITHER_DitherColor
*/
Pixmap DITHER_DitherColor( DC *dc, COLORREF color )
{
static COLORREF prevColor = 0xffffffff;
unsigned int x, y;
Pixmap pixmap;
/* printf( "Dither: %x\n", color ); */
if (color != prevColor)
{
int r = GetRValue( color ) * DITHER_LEVELS;
int g = GetGValue( color ) * DITHER_LEVELS;
int b = GetBValue( color ) * DITHER_LEVELS;
const int *pmatrix = dither_matrix;
WORD *mapping = (WORD *) GDI_HEAP_ADDR( dc->u.x.pal.hMapping );
for (y = 0; y < MATRIX_SIZE; y++)
{
for (x = 0; x < MATRIX_SIZE; x++)
{
int d = *pmatrix++ * 256;
int dr = ((r + d) / MATRIX_SIZE_2) / 256;
int dg = ((g + d) / MATRIX_SIZE_2) / 256;
int db = ((b + d) / MATRIX_SIZE_2) / 256;
XPutPixel( ditherImage, x, y, PIXEL_VALUE(dr,dg,db) );
}
}
prevColor = color;
}
pixmap = XCreatePixmap( display, rootWindow,
MATRIX_SIZE, MATRIX_SIZE, screenDepth );
XPutImage( display, pixmap, BITMAP_colorGC, ditherImage, 0, 0,
0, 0, MATRIX_SIZE, MATRIX_SIZE );
return pixmap;
}

View File

@ -8,6 +8,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include "gdi.h" #include "gdi.h"
@ -17,7 +18,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
* *
* Find a X font matching the logical font. * Find a X font matching the logical font.
*/ */
XFontStruct * FONT_MatchFont( DC * dc, LOGFONT * font ) static XFontStruct * FONT_MatchFont( LOGFONT * font )
{ {
char pattern[100]; char pattern[100];
char *family, *weight, *charset; char *family, *weight, *charset;
@ -44,8 +45,16 @@ XFontStruct * FONT_MatchFont( DC * dc, LOGFONT * font )
default: family = "*"; break; default: family = "*"; break;
} }
sprintf( pattern, "-*-%s-%s-%c-normal--*-%d-*-*-%c-%d-%s", /* Width==0 seems not to be a valid wildcard on SGI's, using * instead */
family, weight, slant, height, spacing, width, charset ); if ( width == 0 )
sprintf( pattern, "-*-%s-%s-%c-normal--*-%d-*-*-%c-*-%s",
family, weight, slant, height, spacing, charset
);
else
sprintf( pattern, "-*-%s-%s-%c-normal--*-%d-*-*-%c-%d-%s",
family, weight, slant, height, spacing, width, charset
);
#ifdef DEBUG_FONT #ifdef DEBUG_FONT
printf( "FONT_MatchFont: '%s'\n", pattern ); printf( "FONT_MatchFont: '%s'\n", pattern );
#endif #endif
@ -166,13 +175,24 @@ HFONT FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font )
/* Load font if necessary */ /* Load font if necessary */
if (!font)
{
HFONT hnewfont;
hnewfont = CreateFont(10, 7, 0, 0, FW_DONTCARE,
FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
DEFAULT_QUALITY, FF_DONTCARE, "*" );
font = (FONTOBJ *) GDI_HEAP_ADDR( hnewfont );
}
if ((hfont >= FIRST_STOCK_FONT) && (hfont <= LAST_STOCK_FONT)) if ((hfont >= FIRST_STOCK_FONT) && (hfont <= LAST_STOCK_FONT))
stockPtr = &stockFonts[hfont - FIRST_STOCK_FONT]; stockPtr = &stockFonts[hfont - FIRST_STOCK_FONT];
else stockPtr = NULL; else
stockPtr = NULL;
if (!stockPtr || !stockPtr->fstruct) if (!stockPtr || !stockPtr->fstruct)
{ {
fontStruct = FONT_MatchFont( dc, &font->logfont ); fontStruct = FONT_MatchFont( &font->logfont );
} }
else else
{ {

View File

@ -6,11 +6,14 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1993"; static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <stdlib.h>
#include <stdio.h>
#include "gdi.h" #include "gdi.h"
#include "prototypes.h"
MDESC *GDI_Heap = NULL; MDESC *GDI_Heap = NULL;
extern HPALETTE COLOR_Init(); /* color.c */
/*********************************************************************** /***********************************************************************
* GDI stock objects * GDI stock objects
@ -130,12 +133,10 @@ static GDIOBJHDR * StockObjects[NB_STOCK_OBJECTS] =
(GDIOBJHDR *) &AnsiVarFont, (GDIOBJHDR *) &AnsiVarFont,
(GDIOBJHDR *) &SystemFont, (GDIOBJHDR *) &SystemFont,
(GDIOBJHDR *) &DeviceDefaultFont, (GDIOBJHDR *) &DeviceDefaultFont,
NULL, /* DEFAULT_PALETTE created by PALETTE_Init */ NULL, /* DEFAULT_PALETTE created by COLOR_Init */
(GDIOBJHDR *) &SystemFixedFont (GDIOBJHDR *) &SystemFixedFont
}; };
extern GDIOBJHDR * PALETTE_systemPalette;
/*********************************************************************** /***********************************************************************
* GDI_Init * GDI_Init
@ -144,6 +145,7 @@ extern GDIOBJHDR * PALETTE_systemPalette;
*/ */
BOOL GDI_Init() BOOL GDI_Init()
{ {
HPALETTE hpalette;
struct segment_descriptor_s * s; struct segment_descriptor_s * s;
#ifndef WINELIB #ifndef WINELIB
@ -156,9 +158,8 @@ BOOL GDI_Init()
/* Create default palette */ /* Create default palette */
COLOR_Init(); if (!(hpalette = COLOR_Init())) return FALSE;
PALETTE_Init(); StockObjects[DEFAULT_PALETTE] = (GDIOBJHDR *) GDI_HEAP_ADDR( hpalette );
StockObjects[DEFAULT_PALETTE] = PALETTE_systemPalette;
/* Create default bitmap */ /* Create default bitmap */
@ -168,6 +169,10 @@ BOOL GDI_Init()
if (!REGION_Init()) return FALSE; if (!REGION_Init()) return FALSE;
/* Initialise dithering */
if (!DITHER_Init()) return FALSE;
return TRUE; return TRUE;
} }
@ -217,7 +222,6 @@ HANDLE GDI_AllocObject( WORD size, WORD magic )
BOOL GDI_FreeObject( HANDLE handle ) BOOL GDI_FreeObject( HANDLE handle )
{ {
GDIOBJHDR * object; GDIOBJHDR * object;
HANDLE prev;
/* Can't free stock objects */ /* Can't free stock objects */
if (handle >= FIRST_STOCK_HANDLE) return FALSE; if (handle >= FIRST_STOCK_HANDLE) return FALSE;

View File

@ -1,62 +1,32 @@
/* /*
* GDI palette objects * GDI palette objects
* *
* Copyright 1993 Alexandre Julliard * Copyright 1993,1994 Alexandre Julliard
*/ */
static char Copyright[] = "Copyright Alexandre Julliard, 1993"; static char Copyright[] = "Copyright Alexandre Julliard, 1993,1994";
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <limits.h>
/*
#ifdef linux #ifdef linux
#include <values.h> #include <values.h>
#endif #endif
*/
#if !defined (MAXINT) #if !defined (MAXINT)
#include <limits.h> #include <limits.h>
#define MAXINT INT_MAX #define MAXINT INT_MAX
#endif #endif
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include "gdi.h" #include "gdi.h"
extern void COLOR_SetMapping( DC *dc, HANDLE map, WORD size ); /* color.c */
extern Colormap COLOR_WinColormap; extern Colormap COLOR_WinColormap;
GDIOBJHDR * PALETTE_systemPalette;
/***********************************************************************
* PALETTE_Init
*/
BOOL PALETTE_Init()
{
int i, size;
XColor color;
HPALETTE hpalette;
LOGPALETTE * palPtr;
size = DefaultVisual( display, DefaultScreen(display) )->map_entries;
palPtr = malloc( sizeof(LOGPALETTE) + (size-1)*sizeof(PALETTEENTRY) );
if (!palPtr) return FALSE;
palPtr->palVersion = 0x300;
palPtr->palNumEntries = size;
memset( palPtr->palPalEntry, 0xff, size*sizeof(PALETTEENTRY) );
for (i = 0; i < size; i++)
{
color.pixel = i;
XQueryColor( display, COLOR_WinColormap, &color );
palPtr->palPalEntry[i].peRed = color.red >> 8;
palPtr->palPalEntry[i].peGreen = color.green >> 8;
palPtr->palPalEntry[i].peBlue = color.blue >> 8;
palPtr->palPalEntry[i].peFlags = 0;
}
hpalette = CreatePalette( palPtr );
PALETTE_systemPalette = (GDIOBJHDR *) GDI_HEAP_ADDR( hpalette );
free( palPtr );
return TRUE;
}
/*********************************************************************** /***********************************************************************
* CreatePalette (GDI.360) * CreatePalette (GDI.360)
@ -116,6 +86,33 @@ WORD SetPaletteEntries( HPALETTE hpalette, WORD start, WORD count,
} }
/***********************************************************************
* GetSystemPaletteEntries (GDI.375)
*/
WORD GetSystemPaletteEntries( HDC hdc, WORD start, WORD count,
LPPALETTEENTRY entries )
{
WORD i;
DC *dc;
XColor color;
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
if (start >= dc->w.devCaps->sizePalette) return 0;
if (start+count >= dc->w.devCaps->sizePalette)
count = dc->w.devCaps->sizePalette - start;
for (i = 0; i < count; i++)
{
color.pixel = start + i;
XQueryColor( display, COLOR_WinColormap, &color );
entries[i].peRed = color.red >> 8;
entries[i].peGreen = color.green >> 8;
entries[i].peBlue = color.blue >> 8;
entries[i].peFlags = 0;
}
return count;
}
/*********************************************************************** /***********************************************************************
* GetNearestPaletteIndex (GDI.370) * GetNearestPaletteIndex (GDI.370)
*/ */
@ -143,7 +140,8 @@ WORD GetNearestPaletteIndex( HPALETTE hpalette, COLORREF color )
b = GetBValue(color); b = GetBValue(color);
entry = palPtr->logpalette.palPalEntry; entry = palPtr->logpalette.palPalEntry;
for (i = 0, minDist = MAXINT; i < palPtr->logpalette.palNumEntries; i++) for (i = 0, minDist = MAXINT; minDist !=0 &&
i < palPtr->logpalette.palNumEntries ; i++)
{ {
if (entry->peFlags != 0xff) if (entry->peFlags != 0xff)
{ {
@ -177,19 +175,52 @@ int PALETTE_GetObject( PALETTEOBJ * palette, int count, LPSTR buffer )
} }
/***********************************************************************
* GDISelectPalette (GDI.361)
*/
HPALETTE GDISelectPalette( HDC hdc, HPALETTE hpal )
{
HPALETTE prev;
DC *dc;
#ifdef DEBUG_PALETTE
printf( "GDISelectPalette: %d %d\n", hdc, hpal );
#endif
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
prev = dc->w.hPalette;
dc->w.hPalette = hpal;
if (hpal != STOCK_DEFAULT_PALETTE) COLOR_SetMapping( dc, 0, 0 );
else RealizeDefaultPalette( hdc ); /* Always realize default palette */
return prev;
}
/***********************************************************************
* GDIRealizePalette (GDI.362)
*/
UINT GDIRealizePalette( HDC hdc )
{
#ifdef DEBUG_PALETTE
printf( "GDIRealizePalette: %d\n", hdc );
#endif
return 0;
}
/*********************************************************************** /***********************************************************************
* SelectPalette (USER.282) * SelectPalette (USER.282)
*/ */
HPALETTE SelectPalette(HDC hDC, HPALETTE hPal, BOOL bForceBackground) HPALETTE SelectPalette(HDC hDC, HPALETTE hPal, BOOL bForceBackground)
{ {
return (HPALETTE)NULL; return GDISelectPalette( hDC, hPal );
} }
/*********************************************************************** /***********************************************************************
* RealizePalette (USER.283) * RealizePalette (USER.283)
*/ */
int RealizePalette(HDC hDC) UINT RealizePalette(HDC hDC)
{ {
return 0; return GDIRealizePalette( hDC );
} }

View File

@ -8,6 +8,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "gdi.h" #include "gdi.h"
extern WORD COLOR_ToPhysical( DC *dc, COLORREF color );
/*********************************************************************** /***********************************************************************
* CreatePen (GDI.61) * CreatePen (GDI.61)
@ -68,21 +69,24 @@ HPEN PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen )
/ dc->w.WndExtX; / dc->w.WndExtX;
if (dc->u.x.pen.width < 0) dc->u.x.pen.width = -dc->u.x.pen.width; if (dc->u.x.pen.width < 0) dc->u.x.pen.width = -dc->u.x.pen.width;
if (dc->u.x.pen.width == 1) dc->u.x.pen.width = 0; /* Faster */ if (dc->u.x.pen.width == 1) dc->u.x.pen.width = 0; /* Faster */
dc->u.x.pen.pixel = GetNearestPaletteIndex( dc->w.hPalette, dc->u.x.pen.pixel = COLOR_ToPhysical( dc, pen->logpen.lopnColor );
pen->logpen.lopnColor );
switch(pen->logpen.lopnStyle) switch(pen->logpen.lopnStyle)
{ {
case PS_DASH: case PS_DASH:
XSetDashes( XT_display, dc->u.x.gc, 0, dash_dash, 2 ); dc->u.x.pen.dashes = dash_dash;
dc->u.x.pen.dash_len = 2;
break; break;
case PS_DOT: case PS_DOT:
XSetDashes( XT_display, dc->u.x.gc, 0, dash_dot, 2 ); dc->u.x.pen.dashes = dash_dot;
dc->u.x.pen.dash_len = 2;
break; break;
case PS_DASHDOT: case PS_DASHDOT:
XSetDashes( XT_display, dc->u.x.gc, 0, dash_dashdot, 4 ); dc->u.x.pen.dashes = dash_dashdot;
dc->u.x.pen.dash_len = 4;
break; break;
case PS_DASHDOTDOT: case PS_DASHDOTDOT:
XSetDashes( XT_display, dc->u.x.gc, 0, dash_dashdotdot, 6 ); dc->u.x.pen.dashes = dash_dashdotdot;
dc->u.x.pen.dash_len = 6;
break; break;
} }

View File

@ -8,13 +8,13 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "gdi.h" #include "gdi.h"
/* GC used for region operations */ /* GC used for region operations */
static GC regionGC = 0; static GC regionGC = 0;
/*********************************************************************** /***********************************************************************
* REGION_Init * REGION_Init
*/ */
@ -23,8 +23,7 @@ BOOL REGION_Init()
Pixmap tmpPixmap; Pixmap tmpPixmap;
/* CreateGC needs a drawable */ /* CreateGC needs a drawable */
tmpPixmap = XCreatePixmap( XT_display, DefaultRootWindow(XT_display), tmpPixmap = XCreatePixmap( display, rootWindow, 1, 1, 1 );
1, 1, 1 );
if (tmpPixmap) if (tmpPixmap)
{ {
regionGC = XCreateGC( XT_display, tmpPixmap, 0, NULL ); regionGC = XCreateGC( XT_display, tmpPixmap, 0, NULL );
@ -68,8 +67,7 @@ static BOOL REGION_SetRect( HRGN hrgn, LPRECT rect )
/* Create pixmap */ /* Create pixmap */
region->pixmap = XCreatePixmap( XT_display, DefaultRootWindow(XT_display), region->pixmap = XCreatePixmap( display, rootWindow, width, height, 1 );
width, height, 1 );
if (!region->pixmap) return FALSE; if (!region->pixmap) return FALSE;
/* Fill pixmap */ /* Fill pixmap */
@ -576,8 +574,19 @@ int CombineRgn( HRGN hDest, HRGN hSrc1, HRGN hSrc2, short mode )
width = region->box.right - region->box.left; width = region->box.right - region->box.left;
height = region->box.bottom - region->box.top; height = region->box.bottom - region->box.top;
region->pixmap = XCreatePixmap( XT_display, DefaultRootWindow(XT_display), if (!width || !height)
width, height, 1 ); {
printf( "CombineRgn: width or height is 0. Please report this.\n" );
printf( "src1=%d,%d-%d,%d src2=%d,%d-%d,%d dst=%d,%d-%d,%d op=%d\n",
src1Obj->region.box.left, src1Obj->region.box.top,
src1Obj->region.box.right, src1Obj->region.box.bottom,
src2Obj->region.box.left, src2Obj->region.box.top,
src2Obj->region.box.right, src2Obj->region.box.bottom,
region->box.left, region->box.top,
region->box.right, region->box.bottom, mode );
exit(1);
}
region->pixmap = XCreatePixmap( display, rootWindow, width, height, 1 );
switch(mode) switch(mode)
{ {

View File

@ -221,7 +221,6 @@ int DrawText( HDC hdc, LPSTR str, int count, LPRECT rect, WORD flags )
(rect->bottom - rect->top) / 2 - size.cy / 2; (rect->bottom - rect->top) / 2 - size.cy / 2;
else if (flags & DT_BOTTOM) y = rect->bottom - size.cy; else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
} }
if (!(flags & DT_CALCRECT)) if (!(flags & DT_CALCRECT))
if (!TextOut(hdc, x, y, line, len)) return 0; if (!TextOut(hdc, x, y, line, len)) return 0;
if (prefix_offset != -1) if (prefix_offset != -1)

BIN
test/blandmdi.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More