summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-09-21 14:48:02 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-09-23 16:24:42 +0200
commit616e21fa0575d81aff9a0c468c7432c22170a23d (patch)
tree8ad65b64f5a302baadf37c4bbeeac6ea1ab14288 /src/corelib
parent2d93d52627353473f93a6295767aa23ec1a29a49 (diff)
downloadfpGUI-616e21fa0575d81aff9a0c468c7432c22170a23d.tar.xz
X11: delegate the DND events to the Drag object.
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/x11/fpg_x11.pas74
1 files changed, 59 insertions, 15 deletions
diff --git a/src/corelib/x11/fpg_x11.pas b/src/corelib/x11/fpg_x11.pas
index 49b250b8..ce5ed273 100644
--- a/src/corelib/x11/fpg_x11.pas
+++ b/src/corelib/x11/fpg_x11.pas
@@ -1153,7 +1153,7 @@ procedure TfpgX11Application.HandleDNDdrop(ATopLevelWindow: TfpgX11Window;
var
Msg: TXEvent;
begin
- {$IFDEF DEBUG}
+ {$IFDEF DNDDEBUG}
writeln('XdndDrop event received!');
{$ENDIF}
XConvertSelection(FDisplay, XdndSelection, FDNDDataType, XdndSelection, ATopLevelWindow.FWinHandle, ATimestamp);
@@ -1608,6 +1608,16 @@ begin
ClosePopups;
end;
end;
+ end
+ else
+ begin
+ if Assigned(Drag) then // button released
+ begin
+ Drag.SendDNDDrop;
+ { TODO: Start timeout in case XdndFinished is not received, so we can free Drag }
+// writeln('Freeing Drag Object');
+// FreeAndNil(FDrag);
+ end;
end;
w := FindWindowByHandle(ev.xbutton.window); // restore w
@@ -1688,20 +1698,27 @@ begin
until not XCheckTypedWindowEvent(display, ev.xmotion.window, X.MotionNotify, @ev);
w := FindWindowByHandle(ev.xmotion.window);
if not Assigned(w) then
- ReportLostWindow(ev);
- if xapplication.TopModalForm <> nil then
- begin
- ew := TfpgX11Window(WidgetParentForm(TfpgWidget(w)));
- if (ew <> nil) and (xapplication.TopModalForm <> ew) and (waUnblockableMessages in ew.WindowAttributes = False) then
- blockmsg := true;
- end;
- if not blockmsg then
+ ReportLostWindow(ev)
+ else
begin
- msgp.mouse.x := ev.xmotion.x;
- msgp.mouse.y := ev.xmotion.y;
- msgp.mouse.Buttons := (ev.xmotion.state and $FF00) shr 8;
- msgp.mouse.shiftstate := ConvertShiftState(ev.xmotion.state);
- fpgPostMessage(nil, FindWindowByHandle(ev.xmotion.window), FPGM_MOUSEMOVE, msgp);
+ if Assigned(Drag) then
+ begin
+ Drag.Dragging(ev);
+ end;
+ if xapplication.TopModalForm <> nil then
+ begin
+ ew := TfpgX11Window(WidgetParentForm(TfpgWidget(w)));
+ if (ew <> nil) and (xapplication.TopModalForm <> ew) and (waUnblockableMessages in ew.WindowAttributes = False) then
+ blockmsg := true;
+ end;
+ if not blockmsg then
+ begin
+ msgp.mouse.x := ev.xmotion.x;
+ msgp.mouse.y := ev.xmotion.y;
+ msgp.mouse.Buttons := (ev.xmotion.state and $FF00) shr 8;
+ msgp.mouse.shiftstate := ConvertShiftState(ev.xmotion.state);
+ fpgPostMessage(nil, w, FPGM_MOUSEMOVE, msgp);
+ end;
end;
end;
@@ -1755,6 +1772,18 @@ begin
{$IFDEF DNDDEBUG}
writeln('XdndStatus event received!');
{$ENDIF}
+ if Assigned(Drag) then
+ begin
+ Drag.HandleDNDStatus(
+ ev.xclient.data.l[0],
+ ev.xclient.data.l[1] and 1,
+ fpgRect(
+ (ev.xclient.data.l[2] shr 16) and $FFFF,
+ ev.xclient.data.l[2] and $FFFF,
+ (ev.xclient.data.l[3] shr 16) and $FFFF,
+ ev.xclient.data.l[3] and $FFFF),
+ ev.xclient.data.l[4]);
+ end;
end
{ XDND protocol - XdndLeave }
else if Assigned(w) and (ev.xclient.message_type = XdndLeave) then
@@ -1772,6 +1801,11 @@ begin
{$IFDEF DNDDEBUG}
writeln('XdndFinished event received!');
{$ENDIF}
+ if Assigned(Drag) then
+ begin
+ writeln('Freeing Drag Object');
+ FreeAndNil(FDrag);
+ end;
end;
end;
@@ -1824,7 +1858,17 @@ begin
X.SelectionRequest:
begin
- ProcessSelectionRequest(ev);
+ if ev.xselectionrequest.selection = XdndSelection then
+ begin
+ writeln('found a XdndSelection request');
+ if Assigned(Drag) then
+ Drag.HandleSelectionRequest(ev);
+ end
+ else
+ begin
+ writeln('found a clipboard selection request');
+ ProcessSelectionRequest(ev);
+ end;
end;
X.SelectionClear: