1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-02-16 15:20:09 -05:00

Reworked input.pas to use TMWindow directly rather than TClient.

Added TargetValid to TMWindow. Appropriate changes in TClient.

Colourpicker now returns coordinates relative to the set Window.
If the window doesn't exist, it will default to desktop.



git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@364 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2010-01-03 03:45:02 +00:00
parent 5d9fc3b088
commit 803cd75a59
8 changed files with 181 additions and 123 deletions

View File

@ -10,7 +10,7 @@
<TargetFileExt Value=""/> <TargetFileExt Value=""/>
<Title Value="Simba"/> <Title Value="Simba"/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="7"/> <ActiveEditorIndexAtStart Value="5"/>
</General> </General>
<VersionInfo> <VersionInfo>
<ProjectVersion Value=""/> <ProjectVersion Value=""/>
@ -137,9 +137,9 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="TestUnit"/> <UnitName Value="TestUnit"/>
<CursorPos X="98" Y="424"/> <CursorPos X="64" Y="505"/>
<TopLine Value="417"/> <TopLine Value="462"/>
<EditorIndex Value="7"/> <EditorIndex Value="8"/>
<UsageCount Value="202"/> <UsageCount Value="202"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit13> </Unit13>
@ -194,8 +194,8 @@
<Filename Value="../../Units/MMLCore/client.pas"/> <Filename Value="../../Units/MMLCore/client.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="Client"/> <UnitName Value="Client"/>
<CursorPos X="27" Y="49"/> <CursorPos X="35" Y="64"/>
<TopLine Value="9"/> <TopLine Value="46"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<UsageCount Value="201"/> <UsageCount Value="201"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -227,8 +227,8 @@
<Filename Value="../../Units/MMLCore/window.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="Window"/> <UnitName Value="Window"/>
<CursorPos X="1" Y="208"/> <CursorPos X="68" Y="306"/>
<TopLine Value="188"/> <TopLine Value="287"/>
<EditorIndex Value="5"/> <EditorIndex Value="5"/>
<UsageCount Value="201"/> <UsageCount Value="201"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -252,9 +252,11 @@
<Unit28> <Unit28>
<Filename Value="../../Units/MMLCore/input.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<UnitName Value="Input"/> <UnitName Value="Input"/>
<CursorPos X="71" Y="274"/> <CursorPos X="17" Y="286"/>
<TopLine Value="242"/> <TopLine Value="266"/>
<UsageCount Value="84"/> <EditorIndex Value="11"/>
<UsageCount Value="85"/>
<Loaded Value="True"/>
</Unit28> </Unit28>
<Unit29> <Unit29>
<Filename Value="../../Units/MMLCore/finder.pas"/> <Filename Value="../../Units/MMLCore/finder.pas"/>
@ -282,9 +284,9 @@
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/> <Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="mmlpsthread"/> <UnitName Value="mmlpsthread"/>
<CursorPos X="79" Y="271"/> <CursorPos X="32" Y="182"/>
<TopLine Value="251"/> <TopLine Value="207"/>
<EditorIndex Value="6"/> <EditorIndex Value="7"/>
<UsageCount Value="202"/> <UsageCount Value="202"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit32> </Unit32>
@ -573,7 +575,7 @@
<UnitName Value="plugins"/> <UnitName Value="plugins"/>
<CursorPos X="40" Y="49"/> <CursorPos X="40" Y="49"/>
<TopLine Value="55"/> <TopLine Value="55"/>
<EditorIndex Value="10"/> <EditorIndex Value="12"/>
<UsageCount Value="200"/> <UsageCount Value="200"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit75> </Unit75>
@ -661,9 +663,9 @@
<Filename Value="../../Units/MMLAddon/colourpicker.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="colourpicker"/> <UnitName Value="colourpicker"/>
<CursorPos X="58" Y="184"/> <CursorPos X="76" Y="115"/>
<TopLine Value="167"/> <TopLine Value="101"/>
<EditorIndex Value="9"/> <EditorIndex Value="10"/>
<UsageCount Value="201"/> <UsageCount Value="201"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit88> </Unit88>
@ -1689,7 +1691,7 @@
<UnitName Value="about"/> <UnitName Value="about"/>
<CursorPos X="119" Y="11"/> <CursorPos X="119" Y="11"/>
<TopLine Value="4"/> <TopLine Value="4"/>
<UsageCount Value="184"/> <UsageCount Value="185"/>
</Unit235> </Unit235>
<Unit236> <Unit236>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/file.inc"/> <Filename Value="../../Units/MMLAddon/PSInc/Wrappers/file.inc"/>
@ -1703,7 +1705,7 @@
<UnitName Value="internets"/> <UnitName Value="internets"/>
<CursorPos X="5" Y="14"/> <CursorPos X="5" Y="14"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="178"/> <UsageCount Value="179"/>
</Unit237> </Unit237>
<Unit238> <Unit238>
<Filename Value="debugimageform.pas"/> <Filename Value="debugimageform.pas"/>
@ -1712,7 +1714,7 @@
<UnitName Value="debugimageform"/> <UnitName Value="debugimageform"/>
<CursorPos X="20" Y="1"/> <CursorPos X="20" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="165"/> <UsageCount Value="166"/>
</Unit238> </Unit238>
<Unit239> <Unit239>
<Filename Value="debugimage.pas"/> <Filename Value="debugimage.pas"/>
@ -1722,7 +1724,7 @@
<UnitName Value="debugimage"/> <UnitName Value="debugimage"/>
<CursorPos X="66" Y="17"/> <CursorPos X="66" Y="17"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="164"/> <UsageCount Value="165"/>
</Unit239> </Unit239>
<Unit240> <Unit240>
<Filename Value="debugimage.lrs"/> <Filename Value="debugimage.lrs"/>
@ -1844,7 +1846,7 @@
<UnitName Value="framefunctionlist"/> <UnitName Value="framefunctionlist"/>
<CursorPos X="56" Y="9"/> <CursorPos X="56" Y="9"/>
<TopLine Value="54"/> <TopLine Value="54"/>
<UsageCount Value="85"/> <UsageCount Value="86"/>
</Unit257> </Unit257>
<Unit258> <Unit258>
<Filename Value="../../../usr/local/share/lazarus/lcl/comctrls.pp"/> <Filename Value="../../../usr/local/share/lazarus/lcl/comctrls.pp"/>
@ -1899,7 +1901,7 @@
<UnitName Value="simpleanalyzer"/> <UnitName Value="simpleanalyzer"/>
<CursorPos X="52" Y="104"/> <CursorPos X="52" Y="104"/>
<TopLine Value="193"/> <TopLine Value="193"/>
<UsageCount Value="72"/> <UsageCount Value="73"/>
</Unit265> </Unit265>
<Unit266> <Unit266>
<Filename Value="../../Units/Misc/mPasLex.pas"/> <Filename Value="../../Units/Misc/mPasLex.pas"/>
@ -1931,9 +1933,11 @@
<Unit270> <Unit270>
<Filename Value="../../../../Documents/fpc/packages/x11/src/xlib.pp"/> <Filename Value="../../../../Documents/fpc/packages/x11/src/xlib.pp"/>
<UnitName Value="xlib"/> <UnitName Value="xlib"/>
<CursorPos X="4" Y="225"/> <CursorPos X="85" Y="1622"/>
<TopLine Value="207"/> <TopLine Value="1604"/>
<UsageCount Value="8"/> <EditorIndex Value="6"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit270> </Unit270>
<Unit271> <Unit271>
<Filename Value="../../../../Documents/fpc/packages/fcl-net/src/httpclient.pp"/> <Filename Value="../../../../Documents/fpc/packages/fcl-net/src/httpclient.pp"/>
@ -1981,8 +1985,8 @@
<UnitName Value="updater"/> <UnitName Value="updater"/>
<CursorPos X="10" Y="201"/> <CursorPos X="10" Y="201"/>
<TopLine Value="190"/> <TopLine Value="190"/>
<EditorIndex Value="11"/> <EditorIndex Value="13"/>
<UsageCount Value="45"/> <UsageCount Value="46"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit277> </Unit277>
<Unit278> <Unit278>
@ -1993,8 +1997,8 @@
<UnitName Value="updateform"/> <UnitName Value="updateform"/>
<CursorPos X="95" Y="141"/> <CursorPos X="95" Y="141"/>
<TopLine Value="104"/> <TopLine Value="104"/>
<EditorIndex Value="8"/> <EditorIndex Value="9"/>
<UsageCount Value="40"/> <UsageCount Value="41"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit278> </Unit278>
<Unit279> <Unit279>
@ -2070,7 +2074,7 @@
<CursorPos X="15" Y="899"/> <CursorPos X="15" Y="899"/>
<TopLine Value="870"/> <TopLine Value="870"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<UsageCount Value="12"/> <UsageCount Value="13"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit289> </Unit289>
<Unit290> <Unit290>
@ -2098,123 +2102,127 @@
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit293> </Unit293>
</Units> </Units>
<JumpHistory Count="29" HistoryIndex="28"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="testunit.pas"/> <Filename Value="updateform.pas"/>
<Caret Line="276" Column="31" TopLine="258"/> <Caret Line="126" Column="40" TopLine="100"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="429" Column="34" TopLine="411"/> <Caret Line="58" Column="9" TopLine="38"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="333" Column="1" TopLine="315"/> <Caret Line="57" Column="18" TopLine="35"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="105" Column="83" TopLine="93"/> <Caret Line="269" Column="33" TopLine="243"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="276" Column="31" TopLine="258"/> <Caret Line="293" Column="27" TopLine="267"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="436" Column="52" TopLine="416"/> <Caret Line="320" Column="42" TopLine="301"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/client.pas"/>
<Caret Line="275" Column="54" TopLine="258"/> <Caret Line="49" Column="27" TopLine="9"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="428" Column="5" TopLine="424"/> <Caret Line="257" Column="36" TopLine="244"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="updateform.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="52" Column="30" TopLine="34"/> <Caret Line="433" Column="80" TopLine="417"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="277" Column="31" TopLine="258"/> <Caret Line="85" Column="49" TopLine="61"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="updateform.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="58" Column="5" TopLine="41"/> <Caret Line="86" Column="32" TopLine="68"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="updateform.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="58" Column="9" TopLine="41"/> <Caret Line="87" Column="34" TopLine="68"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="updateform.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="57" Column="6" TopLine="41"/> <Caret Line="86" Column="43" TopLine="68"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="445" Column="30" TopLine="411"/> <Caret Line="125" Column="42" TopLine="101"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="425" Column="3" TopLine="423"/> <Caret Line="89" Column="1" TopLine="72"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="updateform.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="57" Column="70" TopLine="34"/> <Caret Line="271" Column="26" TopLine="248"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="updateform.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="58" Column="70" TopLine="34"/> <Caret Line="274" Column="20" TopLine="248"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="updateform.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="55" Column="7" TopLine="55"/> <Caret Line="120" Column="30" TopLine="101"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="updateform.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="9" Column="27" TopLine="1"/> <Caret Line="74" Column="33" TopLine="56"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="../../Units/MMLAddon/updater.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="95" Column="15" TopLine="78"/> <Caret Line="89" Column="94" TopLine="78"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="../../Units/MMLAddon/updater.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="70" Column="46" TopLine="34"/> <Caret Line="216" Column="16" TopLine="191"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="../../Units/MMLAddon/updater.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="57" Column="82" TopLine="39"/> <Caret Line="60" Column="37" TopLine="42"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="../../Units/MMLAddon/updater.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="70" Column="34" TopLine="39"/> <Caret Line="143" Column="41" TopLine="125"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="../../Units/MMLAddon/updater.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="57" Column="70" TopLine="39"/> <Caret Line="216" Column="19" TopLine="198"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="../../Units/MMLAddon/updater.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="37" Column="49" TopLine="28"/> <Caret Line="304" Column="19" TopLine="286"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="../../Units/MMLAddon/updater.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="198" Column="33" TopLine="180"/> <Caret Line="355" Column="56" TopLine="337"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="../../Units/MMLAddon/updater.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="35" Column="12" TopLine="10"/> <Caret Line="477" Column="13" TopLine="458"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="updateform.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="126" Column="40" TopLine="100"/> <Caret Line="12" Column="97" TopLine="1"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="58" Column="9" TopLine="38"/> <Caret Line="286" Column="17" TopLine="266"/>
</Position29> </Position29>
<Position30>
<Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="61" Column="36" TopLine="43"/>
</Position30>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -1,7 +1,7 @@
object Form1: TForm1 object Form1: TForm1
Left = 472 Left = 273
Height = 557 Height = 557
Top = 201 Top = 233
Width = 734 Width = 734
ActiveControl = ScriptPanel ActiveControl = ScriptPanel
Caption = 'THA FUKING MUFASA' Caption = 'THA FUKING MUFASA'

View File

@ -1,9 +1,9 @@
{ This is an automatically generated lazarus resource file } { This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[ LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#216#1#6'Height'#3'-'#2#3'Top'#3#201#0#5'W' 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#17#1#6'Height'#3'-'#2#3'Top'#3#233#0#5'Wi'
+'idth'#3#222#2#13'ActiveControl'#7#11'ScriptPanel'#7'Caption'#6#17'THA FUKIN' +'dth'#3#222#2#13'ActiveControl'#7#11'ScriptPanel'#7'Caption'#6#17'THA FUKING'
+'G MUFASA'#12'ClientHeight'#3#20#2#11'ClientWidth'#3#222#2#10'KeyPreview'#9#4 +' MUFASA'#12'ClientHeight'#3#20#2#11'ClientWidth'#3#222#2#10'KeyPreview'#9#4
+'Menu'#7#9'MainMenu1'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate' +'Menu'#7#9'MainMenu1'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate'
+#9'OnDestroy'#7#11'FormDestroy'#10'OnShortCut'#7#13'FormShortCuts'#8'Positio' +#9'OnDestroy'#7#11'FormDestroy'#10'OnShortCut'#7#13'FormShortCuts'#8'Positio'
+'n'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.29'#7'Visible'#9#0#8'TToolBa' +'n'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.29'#7'Visible'#9#0#8'TToolBa'

View File

@ -41,7 +41,7 @@ uses
ocr, updateform; ocr, updateform;
const const
SimbaVersion = 363; SimbaVersion = 364;
type type
@ -501,6 +501,7 @@ begin
// only copies the current set window handle. // only copies the current set window handle.
ScriptThread.Client.MWindow.SetWindow(Self.Window); ScriptThread.Client.MWindow.SetWindow(Self.Window);
// Copy our current fonts // Copy our current fonts
if not assigned(Self.OCR_Fonts) then if not assigned(Self.OCR_Fonts) then
begin begin
@ -509,10 +510,6 @@ begin
end; end;
ScriptThread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts); ScriptThread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
// writeln(IncludeTrailingPathDelimiter('TestUnit: OCR Path... ' +
{ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)) + DS + 'Fonts' + DS);
ScriptThread.Client.MOCR.InitTOCR(IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)) + 'Fonts' + DS, false);}
ScriptThread.OnTerminate:=@ScriptThreadTerminate; ScriptThread.OnTerminate:=@ScriptThreadTerminate;
ScriptState:= ss_Running; ScriptState:= ss_Running;
//Lets run it! //Lets run it!

View File

@ -30,7 +30,7 @@ interface
uses uses
Classes, SysUtils, LCLIntf,LCLType,InterfaceBase,Forms,Controls,ExtCtrls, Classes, SysUtils, LCLIntf,LCLType,InterfaceBase,Forms,Controls,ExtCtrls,
Graphics, Graphics,
Window,MufasaTypes, colourhistory,bitmaps Window,MufasaTypes, colourhistory,bitmaps,input
{$IFNDEF PICKER_CLIENT} {$IFNDEF PICKER_CLIENT}
{$IFDEF LINUX} {$IFDEF LINUX}
@ -55,6 +55,9 @@ type
// Will give us CopyClientToBitmap // Will give us CopyClientToBitmap
Window: TMWindow; Window: TMWindow;
// Created and freed in Pick.
Input: TMInput;
{ Form components } { Form components }
ScreenForm, InfoForm : TForm; ScreenForm, InfoForm : TForm;
ImageMain, ImageInfo: TImage; ImageMain, ImageInfo: TImage;
@ -77,8 +80,10 @@ type
implementation implementation
constructor TMColorPicker.Create(aWindow: TMWindow); constructor TMColorPicker.Create(aWindow: TMWindow);
begin begin
inherited Create; inherited Create;
Self.Window := aWindow; Self.Window := aWindow;
end; end;
@ -107,8 +112,21 @@ var
{$ENDIF} {$ENDIF}
bmp: TMufasaBitmap; bmp: TMufasaBitmap;
InputWindow: TMWindow;
begin begin
{ Disable both of the color pick buttons } { Disable both of the color pick buttons }
InputWindow := TMWindow.Create;
InputWindow.SetWindow(Self.Window);
{ If the Window is not valid, set it to the desktop }
if not InputWindow.TargetValid then
InputWindow.SetDesktop;
Input := TMInput.Create(InputWindow);
Application.MainForm.Enabled := False; Application.MainForm.Enabled := False;
ColourHistoryForm.Enabled := False; ColourHistoryForm.Enabled := False;
@ -232,6 +250,9 @@ begin
InfoForm.Free; InfoForm.Free;
ScreenForm.Free; ScreenForm.Free;
Input.Free;
InputWindow.Free;
{ Re-enable the color pick buttons } { Re-enable the color pick buttons }
Application.MainForm.Enabled := True; Application.MainForm.Enabled := True;
ColourHistoryForm.Enabled := True; ColourHistoryForm.Enabled := True;
@ -244,8 +265,10 @@ var
Data : TRetData; Data : TRetData;
R : TRect; R : TRect;
px, py : Integer; px, py : Integer;
MouseX, MouseY: Integer;
begin begin
{ Move the info form } { Move the info form }
Input.GetMousePos(MouseX, MouseY);
InfoForm.Left := Mouse.CursorPos.X + 5; InfoForm.Left := Mouse.CursorPos.X + 5;
InfoForm.Top := Mouse.CursorPos.Y - 15; InfoForm.Top := Mouse.CursorPos.Y - 15;
@ -264,7 +287,7 @@ begin
{ Draw the cursor and color info } { Draw the cursor and color info }
SetBkColor(InfoHandle, 14811135); SetBkColor(InfoHandle, 14811135);
Text := Format('Pos: %d, %d', [x, y]); Text := Format('Pos: %d, %d', [MouseX, MouseY]);
R := Rect(5, 6, 114, 18); R := Rect(5, 6, 114, 18);
ExtTextOut(InfoHandle, 5, 3, ETO_OPAQUE, @R, pchar(text), length(text), nil); ExtTextOut(InfoHandle, 5, 3, ETO_OPAQUE, @R, pchar(text), length(text), nil);
Text := Format('Color: %d', [Color]); Text := Format('Color: %d', [Color]);

View File

@ -61,7 +61,7 @@ begin
inherited Create; inherited Create;
MWindow := TMWindow.Create; MWindow := TMWindow.Create;
MInput := TMInput.Create(Self); MInput := TMInput.Create(MWindow);
MFiles := TMFiles.Create; MFiles := TMFiles.Create;
MFinder := TMFinder.Create(Self); MFinder := TMFinder.Create(Self);
MBitmaps := TMBitmaps.Create(self); MBitmaps := TMBitmaps.Create(self);

View File

@ -36,11 +36,11 @@ uses
// do non silent keys/mouse with XTest / TKeyInput. // do non silent keys/mouse with XTest / TKeyInput.
{Later on we should use xdotool, as it allows silent input} {Later on we should use xdotool, as it allows silent input}
{$ENDIF} {$ENDIF}
MMLKeyInput, lclintf,math; MMLKeyInput, lclintf,math,window;
type type
TMInput = class(TObject) TMInput = class(TObject)
constructor Create(Client: TObject); constructor Create(Window: TMWindow);
destructor Destroy; override; destructor Destroy; override;
procedure GetMousePos(out X, Y: Integer); procedure GetMousePos(out X, Y: Integer);
@ -65,7 +65,7 @@ type
function IsMouseButtonDown(mType: TClickType): Boolean; function IsMouseButtonDown(mType: TClickType): Boolean;
public public
Client: TObject; Window: TMWindow;
private private
// Not used yet. // Not used yet.
Silent: Boolean; Silent: Boolean;
@ -77,7 +77,7 @@ type
implementation implementation
uses uses
Client,{$IFDEF MSWINDOWS}windows, {$ENDIF}interfacebase,lcltype; {$IFDEF MSWINDOWS}windows, {$ENDIF}interfacebase,lcltype;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
type type
@ -127,10 +127,10 @@ const
function SendInput(cInputs: UINT; var pInputs: TInput; cbSize: Integer): UINT; stdcall; external user32 name 'SendInput'; function SendInput(cInputs: UINT; var pInputs: TInput; cbSize: Integer): UINT; stdcall; external user32 name 'SendInput';
{$ENDIF} {$ENDIF}
constructor TMInput.Create(Client: TObject); constructor TMInput.Create(Window: TMWindow);
begin begin
inherited Create; inherited Create;
Self.Client := Client; Self.Window := Window;
Self.KeyInput := TMMLKeyInput.Create; Self.KeyInput := TMMLKeyInput.Create;
end; end;
@ -219,6 +219,7 @@ function TMInput.isKeyDown(key: Word): Boolean;
{$ENDIF} {$ENDIF}
begin begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
raise Exception.CreateFmt('IsKeyDown isn''t implemented yet on Windows', []);
{$ELSE} {$ELSE}
raise Exception.CreateFmt('IsKeyDown isn''t implemented yet on Linux', []); raise Exception.CreateFmt('IsKeyDown isn''t implemented yet on Linux', []);
@ -259,13 +260,13 @@ var
begin begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
Windows.GetCursorPos(MousePoint); Windows.GetCursorPos(MousePoint);
GetWindowRect(TClient(Client).MWindow.TargetHandle,Rect); GetWindowRect(Window.TargetHandle,Rect);
x := MousePoint.x - Rect.Left; x := MousePoint.x - Rect.Left;
y := MousePoint.y - Rect.Top; y := MousePoint.y - Rect.Top;
{$ENDIF} {$ENDIF}
{$IFDEF LINUX} {$IFDEF LINUX}
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler); Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
XQueryPointer(TClient(Client).MWindow.XDisplay,TClient(Client).MWindow.CurWindow,@root,@child,@b,@b,@x,@y,@xmask); XQueryPointer(Window.XDisplay,Window.CurWindow,@root,@child,@b,@b,@x,@y,@xmask);
XSetErrorHandler(Old_Handler); XSetErrorHandler(Old_Handler);
{$ENDIF} {$ENDIF}
end; end;
@ -281,19 +282,20 @@ var
{$ENDIF} {$ENDIF}
w,h: integer; w,h: integer;
begin begin
TClient(Client).MWindow.GetDimensions(w, h); // This may be a bit too much overhead.
Window.GetDimensions(w, h);
if (x < 0) or (y < 0) or (x > w) or (y > h) then if (x < 0) or (y < 0) or (x > w) or (y > h) then
raise Exception.CreateFmt('SetMousePos: X, Y (%d, %d) is not valid', [x, y]); raise Exception.CreateFmt('SetMousePos: X, Y (%d, %d) is not valid', [x, y]);
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
GetWindowRect(TClient(Client).MWindow.TargetHandle, Rect); GetWindowRect(Window.TargetHandle, Rect);
Windows.SetCursorPos(x + Rect.Left, y + Rect.Top); Windows.SetCursorPos(x + Rect.Left, y + Rect.Top);
{$ENDIF} {$ENDIF}
{$IFDEF LINUX} {$IFDEF LINUX}
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler); Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
XWarpPointer(TClient(Client).MWindow.XDisplay, 0, TClient(Client).MWindow.CurWindow, 0, 0, 0, 0, X, Y); XWarpPointer(Window.XDisplay, 0, Window.CurWindow, 0, 0, 0, 0, X, Y);
XFlush(TClient(Client).MWindow.XDisplay); XFlush(Window.XDisplay);
XSetErrorHandler(Old_Handler); XSetErrorHandler(Old_Handler);
{$ENDIF} {$ENDIF}
@ -313,7 +315,7 @@ var
{$ENDIF} {$ENDIF}
begin begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
GetWindowRect(TClient(Client).MWindow.TargetHandle, Rect); GetWindowRect(Window.TargetHandle, Rect);
Input.Itype:= INPUT_MOUSE; Input.Itype:= INPUT_MOUSE;
FillChar(Input,Sizeof(Input),0); FillChar(Input,Sizeof(Input),0);
Input.mi.dx:= x + Rect.left; Input.mi.dx:= x + Rect.left;
@ -348,7 +350,7 @@ begin
mouse_Right: ButtonP := Button3; mouse_Right: ButtonP := Button3;
end; end;
XTestFakeButtonEvent(TClient(Client).MWindow.XDisplay, ButtonP, XTestFakeButtonEvent(Window.XDisplay, ButtonP,
_isPress, CurrentTime); _isPress, CurrentTime);
XSetErrorHandler(Old_Handler); XSetErrorHandler(Old_Handler);
@ -391,16 +393,16 @@ begin
event.xbutton.send_event := TBool(1); // true if this came from a "send event" event.xbutton.send_event := TBool(1); // true if this came from a "send event"
event.xbutton.same_screen:= TBool(1); event.xbutton.same_screen:= TBool(1);
event.xbutton.subwindow:= 0; // this can't be right. event.xbutton.subwindow:= 0; // this can't be right.
event.xbutton.root := TClient(Client).MWindow.DesktopWindow; event.xbutton.root := Window.DesktopWindow;
event.xbutton.window := TClient(Client).MWindow.CurWindow; event.xbutton.window := Window.CurWindow;
event.xbutton.x_root:= x; event.xbutton.x_root:= x;
event.xbutton.y_root:= y; event.xbutton.y_root:= y;
event.xbutton.x := x; event.xbutton.x := x;
event.xbutton.y := y; event.xbutton.y := y;
event.xbutton.state:= 0; event.xbutton.state:= 0;
if(XSendEvent(TClient(Client).MWindow.XDisplay, PointerWindow, True, $fff, @event) = 0) then if(XSendEvent(Window.XDisplay, PointerWindow, True, $fff, @event) = 0) then
Writeln('Errorrrr :-('); Writeln('Errorrrr :-(');
XFlush(TClient(Client).MWindow.XDisplay); XFlush(Window.XDisplay);
XSetErrorHandler(Old_Handler); XSetErrorHandler(Old_Handler);
{$ENDIF} {$ENDIF}
@ -440,7 +442,7 @@ begin
{$IFDEF LINUX} {$IFDEF LINUX}
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler); Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
XQueryPointer(TClient(Client).MWindow.XDisplay,TClient(Client).MWindow.CurWindow,@root,@child,@rootx,@rooty,@x,@y,@xmask); XQueryPointer(Window.XDisplay,Window.CurWindow,@root,@child,@rootx,@rooty,@x,@y,@xmask);
case mType of case mType of
mouse_Left: Result := (xmask and Button1Mask) <> 0; mouse_Left: Result := (xmask and Button1Mask) <> 0;

View File

@ -71,6 +71,7 @@ type
function SetTarget(Window: THandle; NewType: TTargetWindowMode): integer; overload; function SetTarget(Window: THandle; NewType: TTargetWindowMode): integer; overload;
function SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; overload; function SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; overload;
function SetTarget(Bitmap : TMufasaBitmap) : integer;overload; function SetTarget(Bitmap : TMufasaBitmap) : integer;overload;
function TargetValid: Boolean;
procedure SetWindow(Window: TMWindow); procedure SetWindow(Window: TMWindow);
procedure SetDesktop; procedure SetDesktop;
@ -211,6 +212,8 @@ begin
if FreezeState then if FreezeState then
if FrozenData <> nil then if FrozenData <> nil then
FreeMem(FrozenData); FreeMem(FrozenData);
FreeReturnData; // checks if it is freed or not. if it is not freed, it frees.
{$IFDEF LINUX} {$IFDEF LINUX}
XCloseDisplay(Self.XDisplay); XCloseDisplay(Self.XDisplay);
{$ENDIF} {$ENDIF}
@ -257,6 +260,30 @@ begin
{$ENDIF} {$ENDIF}
end; end;
function TMWindow.TargetValid: Boolean;
{$IFDEF LINUX}
var
old_handler: TXErrorHandler;
Attrib: TXWindowAttributes;
{$ENDIF}
begin
{$IFDEF LINUX}
old_handler := XSetErrorHandler(@MufasaXErrorHandler);
{ There must be a better way to do this, at least with less overhead. }
if XGetWindowAttributes(Self.XDisplay, Self.CurWindow, @Attrib) = 0 then
result := false
else
result := true;
XSetErrorHandler(old_handler);
{$ELSE}
writeln('stub: TMWindow.TargetValid on Windows. Returning true.');
Exit(True);
{$ENDIF}
end;
procedure TMWindow.OnTargetBitmapDestroy(Bitmap: TMufasaBitmap); procedure TMWindow.OnTargetBitmapDestroy(Bitmap: TMufasaBitmap);
begin begin
Self.SetDesktop; Self.SetDesktop;
@ -447,6 +474,8 @@ begin
if TargetMode = w_XWindow then if TargetMode = w_XWindow then
begin; begin;
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler); Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
{ TODO: Check if Window is valid? }
XSetInputFocus(Self.XDisplay,Self.CurWindow,RevertToParent,CurrentTime); XSetInputFocus(Self.XDisplay,Self.CurWindow,RevertToParent,CurrentTime);
XFlush(Self.XDisplay); XFlush(Self.XDisplay);
XSetErrorHandler(Old_Handler); XSetErrorHandler(Old_Handler);
@ -532,7 +561,6 @@ begin
end; end;
end; end;
// Make this use GetDimensions, ray...?
function TMWindow.GetDimensionBox(out Box : TBox) : boolean; function TMWindow.GetDimensionBox(out Box : TBox) : boolean;
function IntToTBox(x1,y1,x2,y2 : integer) : TBox;inline; function IntToTBox(x1,y1,x2,y2 : integer) : TBox;inline;
begin; begin;