mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-17 06:45:11 -05:00
Added a Window Selector for Linux.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@87 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
2a00089fc6
commit
7806e9ceac
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,8 @@ uses
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, LResources, Window, files, MufasaTypes, Client, TestUnit, finder,
|
||||
MMLThread, mmlpsthread, bitmaps, colour_conv, plugins, DTM, colourpicker;
|
||||
MMLThread, mmlpsthread, bitmaps, colour_conv, plugins, DTM, colourpicker,
|
||||
windowselector;
|
||||
|
||||
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
object Form1: TForm1
|
||||
Left = 1128
|
||||
Left = 1103
|
||||
Height = 541
|
||||
Top = 149
|
||||
Top = 82
|
||||
Width = 763
|
||||
ActiveControl = SynEdit1
|
||||
Caption = 'Mufasa v2'
|
||||
@ -794,8 +794,8 @@ object Form1: TForm1
|
||||
Left = 168
|
||||
Top = 2
|
||||
Caption = 'TB_SelectClient'
|
||||
Enabled = False
|
||||
ImageIndex = 7
|
||||
OnMouseDown = Selector_DOWN
|
||||
end
|
||||
object ToolButton8: TToolButton
|
||||
Left = 191
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,8 @@ uses
|
||||
mmlpsthread,
|
||||
mmlthread,
|
||||
window, // for the comp picker and selector
|
||||
colourpicker
|
||||
colourpicker,
|
||||
windowselector
|
||||
;
|
||||
|
||||
type
|
||||
@ -47,11 +48,14 @@ type
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure MenuItemRunClick(Sender: TObject);
|
||||
procedure PickColorEvent(Sender: TObject);
|
||||
procedure Selector_DOWN(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
Window: TMWindow;
|
||||
Picker: TMColorPicker;
|
||||
Selector: TMWindowSelector;
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
@ -91,6 +95,7 @@ procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Window := TMWindow.Create;
|
||||
Picker := TMColorPicker.Create(Window);
|
||||
Selector := TMWindowSelector.Create(Window);
|
||||
|
||||
MainDir:= ExtractFileDir(Application.ExeName);
|
||||
PluginsGlob := TMPlugins.Create;
|
||||
@ -100,6 +105,7 @@ end;
|
||||
|
||||
procedure TForm1.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
Selector.Free;
|
||||
Picker.Free;
|
||||
Window.Free;
|
||||
PluginsGlob.Free;
|
||||
@ -118,6 +124,13 @@ begin
|
||||
writeln('Picked colour: ' + inttostr(c) + ' at (' + inttostr(x) + ', ' + inttostr(y) + ')');
|
||||
end;
|
||||
|
||||
procedure TForm1.Selector_DOWN(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
Window.SetTarget(Selector.Drag);
|
||||
writeln('New window: ' + IntToStr(Window.CurWindow));
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
{$I testunit.lrs}
|
||||
|
107
Units/MMLAddon/windowselector.pas
Normal file
107
Units/MMLAddon/windowselector.pas
Normal file
@ -0,0 +1,107 @@
|
||||
unit windowselector;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
ctypes,
|
||||
window, windowutil,
|
||||
{$IFNDEF MSWINDOWS}x, xlib
|
||||
{$ELSE}
|
||||
windows
|
||||
{$ENDIF}
|
||||
|
||||
;
|
||||
|
||||
type
|
||||
TMWindowSelector = class(TObject)
|
||||
constructor Create(aWindow: TMWindow);
|
||||
destructor Destroy; override;
|
||||
|
||||
{$IFDEF LINUX}
|
||||
function Drag: x.TWindow;
|
||||
{$ELSE}
|
||||
function Drag: Hwnd;
|
||||
{$ENDIF}
|
||||
|
||||
public
|
||||
Window: TMWindow;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
constructor TMWindowSelector.Create(aWindow: TMWindow);
|
||||
begin
|
||||
inherited create;
|
||||
|
||||
Self.Window := aWindow;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
destructor TMWindowSelector.Destroy;
|
||||
begin
|
||||
|
||||
inherited;
|
||||
end;
|
||||
|
||||
{$IFDEF LINUX}
|
||||
function TMWindowSelector.Drag: x.TWindow;
|
||||
var
|
||||
Tempwindow : x.TWindow;
|
||||
root : x.TWindow;
|
||||
subwindow : x.TWindow;
|
||||
x_root, y_root : cint;
|
||||
xmask : cuint;
|
||||
x, y : cint;
|
||||
Old_Handler : TXErrorHandler;
|
||||
|
||||
begin
|
||||
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
|
||||
|
||||
Result := 0;
|
||||
|
||||
repeat
|
||||
XQueryPointer(Window.XDisplay, Window.DesktopWindow, @root,
|
||||
@Tempwindow, @x_root, @y_root,
|
||||
@x, @y, @xmask);
|
||||
subwindow:= Tempwindow;
|
||||
|
||||
while subwindow <> 0 do
|
||||
begin
|
||||
Tempwindow := subwindow;
|
||||
XQueryPointer(Window.XDisplay, Tempwindow, @root,
|
||||
@subwindow, @x_root, @y_root,
|
||||
@x, @y, @xmask);
|
||||
end;
|
||||
if Result <> Tempwindow then
|
||||
begin
|
||||
WriteLn('Changing Window to: ' + IntToStr(Tempwindow));
|
||||
Result := Tempwindow;
|
||||
end;
|
||||
|
||||
Sleep(16);
|
||||
|
||||
until (xmask and Button1Mask) = 0;
|
||||
|
||||
XSetErrorHandler(Old_handler);
|
||||
end;
|
||||
|
||||
{$ELSE}
|
||||
|
||||
function TMWindowSelector.Drag: Hwnd;
|
||||
|
||||
begin
|
||||
// Moet jij maar ff doen, ray.
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
|
||||
end.
|
||||
|
@ -190,7 +190,7 @@ begin
|
||||
{$IFDEF WINDOWS}
|
||||
Self.SetTarget(Window.TargetHandle, Window.TargetMode);
|
||||
{$ELSE}
|
||||
writeln('TMWindow.SetWindow - HDC not supported');
|
||||
writeln('TMWindow.SetWindow - Handle not supported');
|
||||
{$ENDIF}
|
||||
|
||||
// I don't think array can ever be set at this point.
|
||||
|
@ -17,7 +17,6 @@ uses
|
||||
{$IFDEF LINUX}
|
||||
Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage);
|
||||
function MufasaXErrorHandler(para1:PDisplay; para2:PXErrorEvent):cint;cdecl;
|
||||
function MouseWindow: x.TWindow;
|
||||
{$ENDIF}
|
||||
Procedure ArrDataToRawImage(Ptr: PRGB32; Size: TPoint; Var RawImage: TRawImage);
|
||||
|
||||
@ -129,17 +128,6 @@ Begin
|
||||
RawImage.Data := PByte(Ptr);
|
||||
|
||||
End;
|
||||
{$IFDEF LINUX}
|
||||
function MouseWindow: x.TWindow;
|
||||
var
|
||||
Old_Handler: TXErrorHandler;
|
||||
begin
|
||||
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
|
||||
|
||||
|
||||
XSetErrorHandler(Old_Handler);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user