summaryrefslogtreecommitdiff
path: root/src/corelib/x11
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2010-09-15 00:31:48 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-09-23 16:24:41 +0200
commit4e5374377c16654392ad38cc7a1fcf7791542e72 (patch)
tree232718632a527f43a438560d6516f4a52fa9ea58 /src/corelib/x11
parent65ecd294231994dbb3633d0a058ce03cf58ad2bd (diff)
downloadfpGUI-4e5374377c16654392ad38cc7a1fcf7791542e72.tar.xz
Adds OnDragDrop event to TfpgWidget.
For now we hard-code the data type as TfpgString. Later this will change.
Diffstat (limited to 'src/corelib/x11')
-rw-r--r--src/corelib/x11/fpg_x11.pas24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/corelib/x11/fpg_x11.pas b/src/corelib/x11/fpg_x11.pas
index dbae54ef..d450d6a5 100644
--- a/src/corelib/x11/fpg_x11.pas
+++ b/src/corelib/x11/fpg_x11.pas
@@ -266,6 +266,7 @@ type
FDNDDataType: TAtom;
FSrcTimeStamp: clong;
FLastDropTarget: TfpgWinHandle;
+ FDropPos: TPoint;
function ConvertShiftState(AState: Cardinal): TShiftState;
function KeySymToKeycode(KeySym: TKeySym): Word;
function StartComposing(const Event: TXEvent): TKeySym;
@@ -804,6 +805,8 @@ begin
FActionType := 0;
FSrcWinHandle := 0;
FLastDropTarget := 0;
+ FDropPos.X := 0;
+ FDropPos.Y := 0;
end;
procedure TfpgX11Application.HandleDNDenter(ATopLevelWindow: TfpgX11Window;
@@ -909,7 +912,7 @@ procedure TfpgX11Application.HandleDNDposition(ATopLevelWindow: TfpgX11Window; c
const x_root: integer; const y_root: integer; const AAction: TAtom; const ATimestamp: x.TTime);
var
Msg: TXEvent;
- dx, dy: cint;
+ dx, dy, dx2, dy2: cint;
child: TWindow;
s: string;
i: integer;
@@ -949,7 +952,13 @@ begin
{$ENDIF}
if child <> 0 then
- w := FindWindowByHandle(child)
+ begin
+ w := FindWindowByHandle(child);
+ dx2 := dx;
+ dy2 := dy;
+ XTranslateCoordinates(FDisplay, ATopLevelWindow.WinHandle, w.WinHandle,
+ dx2, dy2, @dx, @dy, @child);
+ end
else
w := ATopLevelWindow;
@@ -993,6 +1002,8 @@ begin
if lAccept then
begin
+ FDropPos.X := dx;
+ FDropPos.Y := dy;
fillchar(msgp, sizeof(msgp), 0);
msgp.mouse.x := dx;
msgp.mouse.y := dy;
@@ -1055,7 +1066,6 @@ begin
Msg.xclient.data.l[2] := FActionType; // this should be the action we accepted
XSendEvent(FDisplay, FSrcWinHandle, False, NoEventMask, @Msg);
- ResetDNDVariables;
end;
procedure TfpgX11Application.HandleDNDSelection(const ev: TXEvent);
@@ -1065,6 +1075,7 @@ var
count, remaining, dummy: culong;
s: TfpgString;
data: PChar;
+ wg: TfpgWidget;
begin
{$IFDEF DNDDEBUG}
writeln('XdndSelection message received!');
@@ -1098,9 +1109,16 @@ begin
s := data;
end;
+ if FLastDropTarget <> 0 then { 0 would be first time in, so there is no last window }
+ begin
+ wg := FindWindowByHandle(FLastDropTarget) as TfpgWidget;
+ if Assigned(wg.OnDragDrop) then
+ wg.OnDragDrop(nil, nil, FDropPos.X, FDropPos.Y, s);
+ end;
{$IFDEF DNDDEBUG}
writeln(' s = ', s);
{$ENDIF}
+ ResetDNDVariables;
end;
function TfpgX11Application.DoGetFontFaceList: TStringList;