mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-26 03:02:15 -05:00
Lil updates!
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@369 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
b7f2cf6a61
commit
332e568042
@ -96,6 +96,8 @@ type
|
|||||||
FrozenData : PRGB32;
|
FrozenData : PRGB32;
|
||||||
FrozenSize : TPoint;
|
FrozenSize : TPoint;
|
||||||
TargetBitmap : TMufasaBitmap;
|
TargetBitmap : TMufasaBitmap;
|
||||||
|
{:Called before setting the NewTarget, deletes stuff related to OldTarget and sets the new targetmode}
|
||||||
|
procedure OnSetTarget(NewTarget,OldTarget : TTargetWindowMode);
|
||||||
public
|
public
|
||||||
// Target Window Mode.
|
// Target Window Mode.
|
||||||
TargetMode: TTargetWindowMode;
|
TargetMode: TTargetWindowMode;
|
||||||
@ -174,6 +176,8 @@ begin
|
|||||||
Self.ArrayPtr := nil;
|
Self.ArrayPtr := nil;
|
||||||
Self.ArraySize := Classes.Point(-1, -1);
|
Self.ArraySize := Classes.Point(-1, -1);
|
||||||
|
|
||||||
|
Self.TargetBitmap := nil;
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
Self.DrawBitmap := TBitmap.Create;
|
Self.DrawBitmap := TBitmap.Create;
|
||||||
Self.DrawBitmap.PixelFormat:= pf32bit;
|
Self.DrawBitmap.PixelFormat:= pf32bit;
|
||||||
@ -225,6 +229,24 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TMWindow.OnSetTarget(NewTarget,OldTarget : TTargetWindowMode);
|
||||||
|
begin
|
||||||
|
case OldTarget of
|
||||||
|
w_Window: begin
|
||||||
|
if not Self.TargetDC= Self.DesktopDC then
|
||||||
|
ReleaseDC(Self.TargetHandle,Self.TargetDC);
|
||||||
|
end;
|
||||||
|
w_XWindow: Self.FreeReturnData;
|
||||||
|
end;
|
||||||
|
//Set them to zero, just in case ;-).
|
||||||
|
if NewTarget <> w_BMP then
|
||||||
|
Self.TargetBitmap := nil;
|
||||||
|
if NewTarget <> w_ArrayPtr then
|
||||||
|
self.ArrayPtr := nil;
|
||||||
|
Self.TargetMode:= NewTarget;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMWindow.SetWindow(Window: TMWindow);
|
procedure TMWindow.SetWindow(Window: TMWindow);
|
||||||
begin
|
begin
|
||||||
case Window.TargetMode of
|
case Window.TargetMode of
|
||||||
@ -256,7 +278,9 @@ begin
|
|||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
Self.SetTarget(Self.DesktopWindow);
|
Self.SetTarget(Self.DesktopWindow);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Self.SetTarget(Self.DesktopHWND, w_Window);
|
OnSetTarget(w_window, Self.TargetMode);
|
||||||
|
Self.TargetDC:= DesktopDC;
|
||||||
|
Self.TargetHandle:= DesktopHWND;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -268,21 +292,24 @@ var
|
|||||||
Attrib: TXWindowAttributes;
|
Attrib: TXWindowAttributes;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
|
case Self.TargetMode of
|
||||||
|
w_BMP : result := TargetBitmap <> nil;
|
||||||
|
w_Window : result := IsWindow(self.TargetHandle);
|
||||||
|
w_ArrayPtr : result := ArrayPtr <> nil;
|
||||||
|
w_HDC : result := Self.TargetDC <> 0;
|
||||||
|
w_XWindow : begin
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
old_handler := XSetErrorHandler(@MufasaXErrorHandler);
|
old_handler := XSetErrorHandler(@MufasaXErrorHandler);
|
||||||
|
|
||||||
{ There must be a better way to do this, at least with less overhead. }
|
{ There must be a better way to do this, at least with less overhead. }
|
||||||
if XGetWindowAttributes(Self.XDisplay, Self.CurWindow, @Attrib) = 0 then
|
if XGetWindowAttributes(Self.XDisplay, Self.CurWindow, @Attrib) = 0 then
|
||||||
result := false
|
result := false
|
||||||
else
|
else
|
||||||
result := true;
|
result := true;
|
||||||
|
|
||||||
XSetErrorHandler(old_handler);
|
XSetErrorHandler(old_handler);
|
||||||
{$ELSE}
|
|
||||||
writeln('stub: TMWindow.TargetValid on Windows. Returning true.');
|
|
||||||
Exit(True);
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMWindow.OnTargetBitmapDestroy(Bitmap: TMufasaBitmap);
|
procedure TMWindow.OnTargetBitmapDestroy(Bitmap: TMufasaBitmap);
|
||||||
begin
|
begin
|
||||||
@ -454,8 +481,8 @@ begin
|
|||||||
raise Exception.CreateFMT('TMWindow.Unfreeze: The window is not frozen.',[]);
|
raise Exception.CreateFMT('TMWindow.Unfreeze: The window is not frozen.',[]);
|
||||||
FreeMem(Self.FrozenData);
|
FreeMem(Self.FrozenData);
|
||||||
Self.FrozenData := nil;
|
Self.FrozenData := nil;
|
||||||
Result := True;
|
|
||||||
Self.FreezeState:=False;
|
Self.FreezeState:=False;
|
||||||
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Set's input focus on Linux, does not mean the window will look `active', but
|
// Set's input focus on Linux, does not mean the window will look `active', but
|
||||||
@ -621,10 +648,8 @@ var
|
|||||||
begin
|
begin
|
||||||
if Self.Frozen then
|
if Self.Frozen then
|
||||||
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
||||||
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
|
OnSetTarget(w_XWindow,Self.TargetMode)
|
||||||
Self.CurWindow := XWindow;
|
Self.CurWindow := XWindow;
|
||||||
Self.TargetMode:= w_XWindow;
|
|
||||||
XSetErrorHandler(Old_Handler);
|
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
@ -635,18 +660,21 @@ begin
|
|||||||
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
||||||
if NewType in [ w_XWindow, w_ArrayPtr ] then
|
if NewType in [ w_XWindow, w_ArrayPtr ] then
|
||||||
raise Exception.createFMT('SetTarget: Invalid new type.', []);
|
raise Exception.createFMT('SetTarget: Invalid new type.', []);
|
||||||
|
OnSetTarget(NewType,self.TargetMode);
|
||||||
case NewType of
|
case NewType of
|
||||||
|
w_HDC :
|
||||||
|
begin
|
||||||
|
{$ifdef MSWindows}
|
||||||
|
Self.TargetDC:= Window;
|
||||||
|
{$else}
|
||||||
|
Raise Exception.Create('HDC not supported on linux (yet)');
|
||||||
|
{$endif}
|
||||||
|
end;
|
||||||
w_Window :
|
w_Window :
|
||||||
begin;
|
begin;
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
//We had the desktop as target -> Not freeing that DC!
|
//The old DC is free'd in OnSetTarget.
|
||||||
if not Self.TargetDC= Self.DesktopDC then
|
|
||||||
ReleaseDC(Self.TargetHandle,Self.TargetDC);
|
|
||||||
Self.TargetHandle := Window;
|
Self.TargetHandle := Window;
|
||||||
if Window = Self.DesktopHWND then
|
|
||||||
Self.TargetDC := DesktopDC
|
|
||||||
else
|
|
||||||
Self.TargetDC := GetWindowDC(Window);
|
Self.TargetDC := GetWindowDC(Window);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
@ -668,29 +696,20 @@ function TMWindow.SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; overload;
|
|||||||
begin
|
begin
|
||||||
if Self.Frozen then
|
if Self.Frozen then
|
||||||
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
||||||
If Self.TargetMode = w_XWindow then
|
OnSetTarget(w_ArrayPtr,self.TargetMode);
|
||||||
Self.FreeReturnData;
|
Self.SetDesktop;//Set the underlaying window to desktop for key-sending etc..
|
||||||
|
|
||||||
Self.ArrayPtr := ArrPtr;
|
Self.ArrayPtr := ArrPtr;
|
||||||
Self.ArraySize := Size;
|
Self.ArraySize := Size;
|
||||||
Self.TargetMode:= w_ArrayPtr;
|
|
||||||
|
|
||||||
{$IFDEF LINUX}
|
|
||||||
Self.CurWindow := Self.DesktopWindow;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
{$IFDEF WINDOWS}
|
|
||||||
Self.TargetHandle:= windows.GetDesktopWindow;
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Set target to Bitmap
|
// Set target to Bitmap, set desktop for keyinput/output
|
||||||
function TMWindow.SetTarget(Bitmap: TMufasaBitmap): integer;
|
function TMWindow.SetTarget(Bitmap: TMufasaBitmap): integer;
|
||||||
begin
|
begin
|
||||||
if Self.Frozen then
|
if Self.Frozen then
|
||||||
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
raise Exception.CreateFMT('You cannot set a target when Frozen',[]);
|
||||||
TargetBitmap := Bitmap;
|
OnSetTarget(w_BMP,self.TargetMode);
|
||||||
self.TargetMode:= w_BMP;
|
Self.SetDesktop;
|
||||||
|
Self.TargetBitmap := Bitmap;
|
||||||
Bitmap.OnDestroy:= @OnTargetBitmapDestroy;
|
Bitmap.OnDestroy:= @OnTargetBitmapDestroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user