----------------------------------------------------------------------------- }\r
\r
//this unit provides a rough approximation of windows messages on linux\r
-//it is usefull for multithreaded applications on linux to communicate back to\r
+//it is useful for multithreaded applications on linux to communicate back to\r
//the main lcore thread\r
//This unit is *nix only, on windows you should use the real thing\r
\r
const\r
WS_EX_TOOLWINDOW = $80;\r
WS_POPUP = longint($80000000);\r
+ CW_USEDEFAULT=$80000000;\r
hinstance=nil;\r
PM_REMOVE = 1;\r
WM_USER = 1024;\r
WM_TIMER = 275;\r
INFINITE = syncobjs.infinite;\r
+\r
function getwindowlongptr(ahwnd:hwnd;nindex:integer) : taddrint;\r
function setwindowlongptr(ahwnd:hwnd;nindex:integer;dwNewLong : taddrint) : taddrint;\r
function DefWindowProc(ahWnd:HWND; auMsg:Integer; awParam:WPARAM; alParam:LPARAM):Integer; stdcall;\r
\r
implementation\r
uses\r
- baseunix,unix,lcore,unixutil,ltimevalstuff;//,safewriteln;\r
+ baseunix,unix,lcore,unixutil,ltimevalstuff,sockets;//,safewriteln;\r
{$i unixstuff.inc}\r
\r
type\r
+ \r
tmessageintransit = class\r
msg : tmsg;\r
next : tmessageintransit;\r
waiting : boolean;\r
lcorethread : boolean;\r
nexttimer : ttimeval;\r
- threadid : integer;\r
+ threadid : tthreadid;\r
end;\r
twindow=class\r
hwnd : hwnd;\r
lcorelinkpiperecv : tlasio;\r
windows : thashtable;\r
//I would rather things crash immediately\r
- //if they use an insufficiant size type\r
+ //if they use an insufficient size type\r
//than crash after over four billion\r
//windows have been made ;)\r
nextwindowhandle : qword = $100000000;\r
-
+\r
\r
//findthreaddata should only be called while holding the structurelock\r
-function findthreaddata(threadid : integer) : tthreaddata;\r
+function findthreaddata(threadid : tthreadid) : tthreaddata;\r
begin\r
- result := tthreaddata(findtree(@threaddata,inttostr(threadid)));\r
+ result := tthreaddata(findtree(@threaddata,inttostr(taddrint(threadid))));\r
if result = nil then begin\r
result := tthreaddata.create;\r
result.messageevent := teventobject.create(nil,false,false,inttostr(taddrint(result)));\r
result.nexttimer := tv_invalidtimebig;\r
result.threadid := threadid;\r
- addtree(@threaddata,inttostr(threadid),result);\r
+ addtree(@threaddata,inttostr(taddrint(threadid)),result);\r
end;\r
end;\r
\r
//writeln('freeing thread data object');\r
athreaddata.free;\r
//writeln('deleting thread data object from hashtable');\r
- deltree(@threaddata,inttostr(athreaddata.threadid));\r
+ deltree(@threaddata,inttostr(taddrint(athreaddata.threadid)));\r
//writeln('finished deleting thread data');\r
end else begin\r
//writeln('thread data is not unused');\r
//swriteln('duplicate window class registered with different settings');\r
raise exception.create('duplicate window class registered with different settings');\r
end else begin\r
- //swriteln('duplicate window class registered with same settings, tollerated');\r
+ //swriteln('duplicate window class registered with same settings, tolerated');\r
end;\r
end else begin\r
//swriteln('about to allocate memory for new windowclass');\r
window := twindow(findtree(@windows,inttostr(ahwnd)));\r
if window <> nil then begin\r
freemem(window.extrawindowmemory);\r
- //writeln('aboute to delete window from windows structure');\r
+ //writeln('about to delete window from windows structure');\r
deltree(@windows,inttostr(ahwnd));\r
//writeln('deleted window from windows structure');\r
- windowthreaddata := tthreaddata(findtree(@threaddata,inttostr(window.threadid)));\r
+ windowthreaddata := tthreaddata(findtree(@threaddata,inttostr(taddrint(window.threadid))));\r
\r
if windowthreaddata <> nil then begin\r
//writeln('found thread data scanning for messages to clean up');\r