diff --git a/trunk/Projects/SAMufasaGUI/project1.lpi b/trunk/Projects/SAMufasaGUI/project1.lpi
index 6a8a8e3..0463ab5 100644
--- a/trunk/Projects/SAMufasaGUI/project1.lpi
+++ b/trunk/Projects/SAMufasaGUI/project1.lpi
@@ -38,7 +38,7 @@
-
+
@@ -141,9 +141,7 @@
-
-
@@ -189,9 +187,9 @@
-
-
-
+
+
+
@@ -201,9 +199,7 @@
-
-
@@ -268,9 +264,9 @@
-
-
-
+
+
+
@@ -350,9 +346,11 @@
-
-
+
+
+
+
@@ -372,9 +370,7 @@
-
-
@@ -531,9 +527,7 @@
-
-
@@ -669,9 +663,7 @@
-
-
@@ -769,10 +761,10 @@
-
-
-
-
+
+
+
+
@@ -818,9 +810,7 @@
-
-
@@ -1204,9 +1194,7 @@
-
-
@@ -1375,9 +1363,7 @@
-
-
@@ -1599,7 +1585,7 @@
-
+
@@ -1654,7 +1640,7 @@
-
+
@@ -1712,9 +1698,9 @@
-
+
-
+
@@ -1731,7 +1717,7 @@
-
+
@@ -1742,7 +1728,7 @@
-
+
@@ -1863,7 +1849,7 @@
-
+
@@ -1901,7 +1887,7 @@
-
+
@@ -1958,7 +1944,7 @@
-
+
@@ -2004,19 +1990,19 @@
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
@@ -2029,10 +2015,10 @@
-
-
-
-
+
+
+
+
@@ -2055,7 +2041,7 @@
-
+
@@ -2066,10 +2052,10 @@
-
-
-
-
+
+
+
+
@@ -2077,132 +2063,48 @@
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/trunk/Units/MMLAddon/PSInc/Wrappers/window.inc b/trunk/Units/MMLAddon/PSInc/Wrappers/window.inc
index 5a55752..71e9901 100644
--- a/trunk/Units/MMLAddon/PSInc/Wrappers/window.inc
+++ b/trunk/Units/MMLAddon/PSInc/Wrappers/window.inc
@@ -26,10 +26,14 @@ begin;
CurrThread.Client.IOManager.SetDesktop;
end;
+procedure SetTargetArray(P: Integer; w, h: integer);
+begin
+ CurrThread.Client.IOManager.SetTarget(PRGB32(P), classes.point(w,h));
+end;
+
procedure SetTargetBitmap(bitmap: Integer);
begin;
- With CurrThread.Client do
- IOManager.SetTarget(MBitmaps.Bmp[Bitmap]);
+ CurrThread.Client.IOManager.SetTarget(CurrThread.Client.MBitmaps.Bmp[Bitmap]);
end;
procedure GetClientDimensions(out w, h: integer);
@@ -40,21 +44,21 @@ end;
function Freeze: boolean;
begin
CurrThread.Client.IOManager.SetFrozen(true);
- result := true;
+ result := true; //dunno what the result is supposed to mean
end;
function Unfreeze: boolean;
begin
CurrThread.Client.IOManager.SetFrozen(false);
- result := true;
+ result := true; //dunno what the result is supposed to mean
end;
-procedure SetTargetArray(P: Integer; w, h: integer);
-begin
- CurrThread.Client.IOManager.SetTarget(PRGB32(P), classes.point(w,h));
-end;
-
-procedure activateclient;
+procedure ActivateClient;
begin
CurrThread.Client.IOManager.ActivateClient;
end;
+
+function IsTargetValid: boolean;
+begin
+ result:= CurrThread.Client.IOManager.TargetValid;
+end;
diff --git a/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc b/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc
index 863de53..b3363c2 100644
--- a/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc
+++ b/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc
@@ -56,13 +56,14 @@ AddFunction(@ps_RandomRange,'function RandomRange(aFrom,aTo: Integer): Integer;'
{window}
SetCurrSection('Window');
-AddFunction(@Freeze, 'function Freeze:boolean;');
+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(@SetDesktopAsClient,'procedure SetDesktopAsClient');
AddFunction(@SetTargetArray, 'procedure SetTargetArray(P: Integer; w, h: integer);');
-AddFunction(@ActivateClient, 'procedure activateclient;');
+AddFunction(@ActivateClient, 'procedure ActivateClient;');
+AddFunction(@IsTargetValid, 'function IsTargetValid: boolean;');
{files}
SetCurrSection('Files');
diff --git a/trunk/Units/MMLAddon/mmlpsthread.pas b/trunk/Units/MMLAddon/mmlpsthread.pas
index 9dca303..771abd1 100644
--- a/trunk/Units/MMLAddon/mmlpsthread.pas
+++ b/trunk/Units/MMLAddon/mmlpsthread.pas
@@ -258,6 +258,7 @@ end;
{$I PSInc/Wrappers/other.inc}
{$I PSInc/Wrappers/bitmap.inc}
{$I PSInc/Wrappers/window.inc}
+
{$I PSInc/Wrappers/strings.inc}
{$I PSInc/Wrappers/colour.inc}
diff --git a/trunk/Units/MMLCore/iomanager.pas b/trunk/Units/MMLCore/iomanager.pas
index c6ec16e..8bd8540 100644
--- a/trunk/Units/MMLCore/iomanager.pas
+++ b/trunk/Units/MMLCore/iomanager.pas
@@ -44,6 +44,7 @@ interface
function ReturnData(xs, ys, width, height: Integer): TRetData; virtual;
procedure FreeReturnData; virtual;
procedure ActivateClient; virtual;
+ function TargetValid: boolean; virtual;
{ ONLY override the following methods if the target provides mouse functions, defaults to
| raise exceptions }
@@ -82,6 +83,7 @@ interface
procedure GetTargetDimensions(var w, h: integer); override; abstract;
function ReturnData(xs, ys, width, height: Integer): TRetData; override; abstract;
+ function TargetValid: boolean; override; abstract;
procedure ActivateClient; override; abstract;
procedure GetMousePosition(var x,y: integer); override; abstract;
procedure MoveMouse(x,y: integer); override; abstract;
@@ -313,10 +315,11 @@ implementation
//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
+ if not(makefrozen) then
begin
- image.Destroy();
+ image.Free();
image:= frozen;
+ frozen:= nil;
end else if frozen = nil then
begin
frozen:= image;
@@ -351,7 +354,11 @@ implementation
function TIOManager_Abstract.TargetValid: Boolean;
begin
- result:= (keymouse <> nil) and (image <> nil);
+ result:= false;
+ if (keymouse <> nil) and (image <> nil) then
+ begin
+
+ end;
end;
procedure TIOManager_Abstract.GetDimensions(var W, H: Integer); begin image.GetTargetDimensions(w,h) end;
@@ -386,6 +393,7 @@ implementation
function TTarget.ReturnData(xs, ys, width, height: Integer): TRetData; begin raise Exception.Create('ReturnData not avaliable for this target'); end;
procedure TTarget.FreeReturnData; begin {do nothing by default} end;
procedure TTarget.ActivateClient; begin raise Exception.Create('ActivateClient not avaliable for this target'); end;
+ function TTarget.TargetValid: boolean; begin result:= true; end;
procedure TTarget.GetMousePosition(var x,y: integer); begin raise Exception.Create('GetMousePosition not avaliable for this target'); end;
procedure TTarget.MoveMouse(x,y: integer); begin raise Exception.Create('MoveMouse not avaliable for this target'); end;
diff --git a/trunk/Units/MMLCore/os_linux.pas b/trunk/Units/MMLCore/os_linux.pas
index 8dc94e3..19c23f0 100644
--- a/trunk/Units/MMLCore/os_linux.pas
+++ b/trunk/Units/MMLCore/os_linux.pas
@@ -46,6 +46,7 @@ interface
function ReturnData(xs, ys, width, height: Integer): TRetData; override;
procedure FreeReturnData; override;
+ function TargetValid: boolean; override;
procedure ActivateClient; override;
procedure GetMousePosition(var x,y: integer); override;
procedure MoveMouse(x,y: integer); override;
@@ -154,6 +155,18 @@ implementation
XSetErrorHandler(Old_Handler);
end;
+ function TWindow.TargetValid: boolean;
+ var
+ old_handler: TXErrorHandler;
+ Attrib: TXWindowAttributes;
+ begin
+ old_handler := XSetErrorHandler(@MufasaXErrorHandler);
+ //This was in the repos, but it doesn't seem to work...
+ //Maybe I missed something?
+ result:= XGetWindowAttributes(display, window, @Attrib) <> 0;
+ XSetErrorHandler(old_handler);
+ end;
+
procedure TWindow.ActivateClient;
var
Old_Handler: TXErrorHandler;
diff --git a/trunk/Units/MMLCore/os_windows.pas b/trunk/Units/MMLCore/os_windows.pas
index b748f4f..79e4d17 100644
--- a/trunk/Units/MMLCore/os_windows.pas
+++ b/trunk/Units/MMLCore/os_windows.pas
@@ -47,6 +47,7 @@ interface
function ReturnData(xs, ys, width, height: Integer): TRetData; override;
function GetColor(x,y : integer) : TColor; override;
+ function TargetValid: boolean; override;
procedure ActivateClient; override;
procedure GetMousePosition(var x,y: integer); override;
procedure MoveMouse(x,y: integer); override;
@@ -159,6 +160,11 @@ implementation
inherited Destroy;
end;
+ function TWindow.TargetValid: boolean;
+ begin
+ result:= IsWindow(handle);
+ end;
+
procedure TWindow.ActivateClient;
begin
SetForegroundWindow(handle);