diff --git a/trunk/Projects/SAMufasaGUI/project1.lpi b/trunk/Projects/SAMufasaGUI/project1.lpi
index 89413a5..de8e0d0 100644
--- a/trunk/Projects/SAMufasaGUI/project1.lpi
+++ b/trunk/Projects/SAMufasaGUI/project1.lpi
@@ -11,7 +11,7 @@
-
+
@@ -190,7 +190,7 @@
-
+
@@ -265,9 +265,9 @@
-
-
-
+
+
+
@@ -349,7 +349,7 @@
-
+
@@ -495,8 +495,10 @@
-
+
+
+
@@ -764,10 +766,10 @@
-
-
+
+
-
+
@@ -1540,7 +1542,7 @@
-
+
@@ -1590,7 +1592,7 @@
-
+
@@ -1618,7 +1620,7 @@
-
+
@@ -1647,7 +1649,7 @@
-
+
@@ -1705,10 +1707,10 @@
-
-
+
+
-
+
@@ -1724,7 +1726,7 @@
-
+
@@ -1735,7 +1737,7 @@
-
+
@@ -1856,7 +1858,7 @@
-
+
@@ -1894,7 +1896,7 @@
-
+
@@ -1951,7 +1953,7 @@
-
+
@@ -1997,19 +1999,19 @@
-
-
+
+
-
+
-
-
-
-
+
+
+
+
@@ -2022,10 +2024,10 @@
-
-
-
-
+
+
+
+
@@ -2048,7 +2050,7 @@
-
+
@@ -2061,8 +2063,8 @@
-
-
+
+
@@ -2084,127 +2086,131 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
diff --git a/trunk/Units/MMLAddon/PSInc/Wrappers/window.inc b/trunk/Units/MMLAddon/PSInc/Wrappers/window.inc
index 94cef68..af50495 100644
--- a/trunk/Units/MMLAddon/PSInc/Wrappers/window.inc
+++ b/trunk/Units/MMLAddon/PSInc/Wrappers/window.inc
@@ -26,14 +26,44 @@ begin;
CurrThread.Client.IOManager.SetDesktop;
end;
-procedure SetTargetArray(P: Integer; w, h: integer);
+function SetTargetArray(P: Integer; w, h: integer): integer;
begin
- CurrThread.Client.IOManager.SetTarget(PRGB32(P), classes.point(w,h));
+ result:= CurrThread.Client.IOManager.SetTarget(PRGB32(P), classes.point(w,h));
end;
-procedure SetTargetBitmap(bitmap: Integer);
+function SetTargetBitmap(bitmap: Integer): integer;
begin;
- CurrThread.Client.IOManager.SetTarget(CurrThread.Client.MBitmaps[Bitmap]);
+ result:= CurrThread.Client.IOManager.SetTarget(CurrThread.Client.MBitmaps[Bitmap]);
+end;
+
+function SetEIOSTarget(name: string; args: Variant): integer;
+begin
+ result:= CurrThread.Client.IOManager.SetTarget(name, @args);
+end;
+
+procedure SetImageTarget(idx: integer);
+begin
+ CurrThread.Client.IOManager.SetImageTarget(idx);
+end;
+
+procedure SetKeyMouseTarget(idx: integer);
+begin
+ CurrThread.Client.IOManager.SetKeyMouseTarget(idx);
+end;
+
+function GetImageTarget: integer;
+begin
+ CurrThread.Client.IOManager.GetImageTarget(result);
+end;
+
+function GetKeyMouseTarget: integer;
+begin
+ CurrThread.Client.IOManager.GetKeyMouseTarget(result);
+end;
+
+procedure FreeTarget(idx: integer);
+begin
+ CurrThread.Client.IOManager.FreeTarget(idx);
end;
procedure GetClientDimensions(out w, h: integer);
diff --git a/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc b/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc
index cf16b65..9f9aabd 100644
--- a/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc
+++ b/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc
@@ -63,9 +63,15 @@ SetCurrSection('Window');
AddFunction(@Freeze, 'function Freeze: boolean;');
AddFunction(@Unfreeze, 'function Unfreeze: boolean;');
AddFunction(@GetClientDimensions, 'procedure GetClientDimensions(var w, h:integer);');
-AddFunction(@SetTargetBitmap,'procedure SetTargetBitmap(Bitmap : integer);');
+AddFunction(@SetTargetBitmap,'function SetTargetBitmap(Bitmap : integer): integer;');
+AddFunction(@SetTargetArray, 'function SetTargetArray(P: Integer; w, h: integer): integer;');
+AddFunction(@SetEIOSTarget, 'function SetEIOSTarget(name: string; initargs: Variant): integer;');
+AddFunction(@SetImageTarget,'procedure SetImageTarget(idx: integer);');
+AddFunction(@SetKeyMouseTarget,'procedure SetKeyMouseTarget(idx: integer);');
+AddFunction(@GetImageTarget,'function GetImageTarget: integer;');
+AddFunction(@GetKeyMouseTarget,'function GetKeyMouseTarget: integer;');
+AddFunction(@FreeTarget,'procedure FreeTarget(idx: integer);');
AddFunction(@SetDesktopAsClient,'procedure SetDesktopAsClient');
-AddFunction(@SetTargetArray, 'procedure SetTargetArray(P: Integer; w, h: integer);');
AddFunction(@ActivateClient, 'procedure ActivateClient;');
AddFunction(@IsTargetValid, 'function IsTargetValid: boolean;');
diff --git a/trunk/Units/MMLCore/iomanager.pas b/trunk/Units/MMLCore/iomanager.pas
index 4ae2e9b..9580c58 100644
--- a/trunk/Units/MMLCore/iomanager.pas
+++ b/trunk/Units/MMLCore/iomanager.pas
@@ -223,21 +223,33 @@ interface
procedure SendText(text: string);
function isKeyDown(key: Word): Boolean;
- function GetImageTarget: TTarget;
+ function GetImageTarget: TTarget; overload;
+ function GetKeyMouseTarget: TTarget; overload;
+
+ procedure GetImageTarget(var idx: integer); overload;
+ procedure GetKeyMouseTarget(var idx: integer); overload;
+ procedure SetImageTarget(idx: integer);
+ procedure SetKeyMouseTarget(idx: integer);
+ procedure FreeTarget(idx: integer);
protected
+ function SetImageTarget(target: TTarget): integer;
+ function SetKeyMouseTarget(target: TTarget): integer;
+ function SetBothTargets(target: TTarget): integer;
+ procedure NativeInit; virtual; abstract;
+ procedure NativeFree; virtual; abstract;
+
+ private
keymouse: TTarget;
image: TTarget;
frozen: TTarget;
freezebuffer: prgb32;
bothsame: boolean;
-
- procedure SetImageTarget(target: TTarget);
- procedure SetKeyMouseTarget(target: TTarget);
- procedure SetBothTargets(target: TTarget);
- procedure NativeInit; virtual; abstract;
- procedure NativeFree; virtual; abstract;
+ idxarr: array of TTarget;
+
+ function GetTargetIdx(target: TTarget): integer;
+ function GetIdxTarget(idx: integer): TTarget;
end;
implementation
@@ -253,16 +265,13 @@ implementation
constructor TIOManager_Abstract.Create(plugin_dir: string);
begin
inherited Create;
+ SetLength(idxarr,0);
eios_controller.AddPath(plugin_dir);
keymouse:= nil;
image:= nil;
frozen:= nil;
NativeInit;
SetDesktop;
-{
- self.create;
- eios_controller.AddAndLoadPath(plugin_dir);
-}
end;
constructor TIOManager_Abstract.Create;
@@ -276,22 +285,61 @@ begin
end;
destructor TIOManager_Abstract.Destroy;
+var
+ i: integer;
begin
- if bothsame then keymouse.Destroy() else
- begin
- keymouse.Free();
- image.Free();
- end;
- if IsFrozen then frozen.Destroy();
+ for i:= high(idxarr) downto 0 do
+ idxarr[i].Free;
end;
-procedure TIOManager_Abstract.SetImageTarget(target: TTarget);
+procedure TIOManager_Abstract.FreeTarget(idx: integer);
+begin
+ if idx > high(idxarr) then
+ raise Exception.Create('Invalid target index');
+ if idxarr[idx] = nil then
+ raise Exception.Create('Double free of target');
+ idxarr[idx].Free;
+ idxarr[idx]:= nil;
+end;
+
+function TIOManager_Abstract.GetTargetIdx(target: TTarget): integer;
+var
+ i: integer;
+begin
+ result:= -1;
+ for i:= 0 to high(idxarr) do
+ begin
+ if idxarr[i] = target then
+ begin
+ result:= i;
+ exit;
+ end;
+ if (idxarr[i] = nil) and (result = -1) then
+ result:= i;
+ end;
+ if result = -1 then
+ begin
+ SetLength(idxarr,Length(idxarr) + 1);
+ result:= high(idxarr);
+ end;
+ idxarr[result]:= target;
+end;
+
+function TIOManager_Abstract.GetIdxTarget(idx: integer): TTarget;
+begin
+ if idx > high(idxarr) then
+ raise Exception.Create('Invalid target index');
+ if idxarr[idx] = nil then
+ raise Exception.Create('No target with specified index');
+ result:= idxarr[idx];
+end;
+
+function TIOManager_Abstract.SetImageTarget(target: TTarget): integer;
begin
if IsFrozen then
raise Exception.Create('You cannot set a target when Frozen');
- if not(bothsame) then image.Free();
+ result:= GetTargetIdx(target);
image:= target;
- bothsame:= false;
end;
function TIOManager_Abstract.GetImageTarget: TTarget;
@@ -299,24 +347,24 @@ begin
result := image;
end;
-procedure TIOManager_Abstract.SetKeyMouseTarget(target: TTarget);
+function TIOManager_Abstract.SetKeyMouseTarget(target: TTarget): integer;
begin
- if not(bothsame) then keymouse.Free();
+ result:= GetTargetIdx(target);
keymouse:= target;
- bothsame:= false;
end;
-procedure TIOManager_Abstract.SetBothTargets(target: TTarget);
+
+function TIOManager_Abstract.GetKeyMouseTarget: TTarget;
+begin
+ result := keymouse;
+end;
+
+function TIOManager_Abstract.SetBothTargets(target: TTarget): integer;
begin
if IsFrozen then
raise Exception.Create('You cannot set a target when Frozen');
- if bothsame then image.Destroy() else
- begin
- image.Free();
- keymouse.Free();
- end;
+ result:= GetTargetIdx(target);
image:= target;
keymouse:= target;
- bothsame:= true;
end;
procedure TIOManager_Abstract.SetFrozen(makefrozen: boolean);
@@ -326,9 +374,6 @@ var
begin
if (makefrozen) and (IsFrozen) then
raise Exception.Create('The window is already frozen.');
- //BenLand100 edit: I say we leave this exception out. POLS
- //if not(isfrozen) and (frozen = nil) then
- // raise Exception.Create('The window is not frozen.');
if makefrozen then //No need for the Frozen = nil check, already done above with the exception.
begin
frozen:= image;
@@ -364,11 +409,11 @@ end;
function TIOManager_Abstract.SetTarget(ArrPtr: PRGB32; Size: TPoint): integer;
begin
- SetImageTarget(TRawTarget.Create(ArrPtr,Size.X,Size.Y));
+ result:= SetImageTarget(TRawTarget.Create(ArrPtr,Size.X,Size.Y));
end;
function TIOManager_Abstract.SetTarget(bmp : TMufasaBitmap) : integer;
begin
- SetImageTarget(TRawTarget.Create(bmp.FData,bmp.width,bmp.height));
+ result:= SetImageTarget(TRawTarget.Create(bmp.FData,bmp.width,bmp.height));
end;
function TIOManager_Abstract.SetTarget(name: string; initargs: pointer): integer;
@@ -378,7 +423,29 @@ begin
if not eios_controller.ClientExists(name) then
raise Exception.Create('EIOS Client by specified name does not exist');
client:= eios_controller.GetClient(name);
- SetBothTargets(TEIOS_Target.Create(client, initargs));
+ result:= SetBothTargets(TEIOS_Target.Create(client, initargs));
+end;
+
+procedure TIOManager_Abstract.SetImageTarget(idx: integer);
+begin
+ image:= GetIdxTarget(idx);
+end;
+
+procedure TIOManager_Abstract.SetKeyMouseTarget(idx: integer);
+begin
+ keymouse:= GetIdxTarget(idx);
+end;
+
+procedure TIOManager_Abstract.GetImageTarget(var idx: integer);
+begin
+ if IsFrozen then
+ raise Exception.Create('Cannot get image target while frozen');
+ idx:= GetTargetIdx(image);
+end;
+
+procedure TIOManager_Abstract.GetKeyMouseTarget(var idx: integer);
+begin
+ idx:= GetTargetIdx(keymouse);
end;
function TIOManager_Abstract.TargetValid: Boolean;
diff --git a/trunk/Units/MMLCore/os_linux.pas b/trunk/Units/MMLCore/os_linux.pas
index 7bb6c32..c1e1d05 100644
--- a/trunk/Units/MMLCore/os_linux.pas
+++ b/trunk/Units/MMLCore/os_linux.pas
@@ -58,7 +58,7 @@ interface
procedure ReleaseKey(key: integer); override;
function IsKeyHeld(key: integer): boolean; override;
- function GetNativeWindow: x.TWindow;
+ function GetNativeWindow: TNativeWindow;
private
display: PDisplay;
screennum: integer;
@@ -134,7 +134,7 @@ implementation
inherited Destroy;
end;
- function TWindow.GetNativeWindow: x.TWindow;
+ function TWindow.GetNativeWindow: TNativeWindow;
begin
result := self.window;
end;
diff --git a/trunk/Units/MMLCore/os_windows.pas b/trunk/Units/MMLCore/os_windows.pas
index 91648c1..f3587d5 100644
--- a/trunk/Units/MMLCore/os_windows.pas
+++ b/trunk/Units/MMLCore/os_windows.pas
@@ -59,7 +59,7 @@ interface
procedure ReleaseKey(key: integer); override;
function IsKeyHeld(key: integer): boolean; override;
- function GetNativeWindow: Hwnd;
+ function GetNativeWindow: TNativeWindow;
private
handle: Hwnd;
dc: HDC;
@@ -74,7 +74,7 @@ interface
public
constructor Create;
constructor Create(plugin_dir: string);
- function SetTarget(target: Hwnd): integer; overload;
+ function SetTarget(target: TNativeWindow): integer; overload;
procedure SetDesktop; override;
protected
DesktopHWND : Hwnd;
@@ -162,7 +162,7 @@ implementation
inherited Destroy;
end;
- function TWindow.GetNativeWindow: Hwnd;
+ function TWindow.GetNativeWindow: TNativeWindow;
begin
result := handle;
end;
@@ -345,7 +345,7 @@ implementation
SetBothTargets(TWindow.Create(DesktopHWND));
end;
- function TIOManager.SetTarget(target: Hwnd): integer;
+ function TIOManager.SetTarget(target: TNativeWindow): integer;
begin
SetBothTargets(TWindow.Create(target));
end;