summaryrefslogtreecommitdiff
path: root/src/corelib/x11/fpg_x11.pas
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2010-09-14 23:04:12 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-09-23 16:24:34 +0200
commitb9936034e3e017ec35d4220d86db70b72dd22236 (patch)
treef17e5389a37d62cfc7e9c292a3975b45d7ac78aa /src/corelib/x11/fpg_x11.pas
parentf97be77054ec360f41cefb9a0b3193415a0c4b43 (diff)
downloadfpGUI-b9936034e3e017ec35d4220d86db70b72dd22236.tar.xz
Adds implementation for handling XdndSelection message.
Diffstat (limited to 'src/corelib/x11/fpg_x11.pas')
-rw-r--r--src/corelib/x11/fpg_x11.pas54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/corelib/x11/fpg_x11.pas b/src/corelib/x11/fpg_x11.pas
index a16d0ede..30f64ee6 100644
--- a/src/corelib/x11/fpg_x11.pas
+++ b/src/corelib/x11/fpg_x11.pas
@@ -276,6 +276,7 @@ type
procedure HandleDNDleave(ATopLevelWindow: TfpgX11Window; const ASource: TWindow);
procedure HandleDNDposition(ATopLevelWindow: TfpgX11Window; const ASource: TWindow; const x_root: integer; const y_root: integer; const AAction: TAtom; const ATimestamp: x.TTime);
procedure HandleDNDdrop(ATopLevelWindow: TfpgX11Window; const ASource: TWindow; const ATimestamp: x.TTime);
+ procedure HandleDNDSelection(const ev: TXEvent);
protected
FDisplay: PXDisplay;
DisplayDepth: integer;
@@ -1023,6 +1024,51 @@ begin
ResetDNDVariables;
end;
+procedure TfpgX11Application.HandleDNDSelection(const ev: TXEvent);
+var
+ actualtype: TAtom;
+ actualformat: cint;
+ count, remaining, dummy: culong;
+ s: TfpgString;
+ data: PChar;
+begin
+ {$IFDEF DNDDEBUG}
+ writeln('XdndSelection message received!');
+ {$ENDIF}
+ { do not get data yet, just see how much there is }
+ XGetWindowProperty(FDisplay, ev.xselection.requestor,
+ ev.xselection._property, 0, 0,
+ TBool(false),
+ AnyPropertyType,
+ @actualtype, @actualformat, @count, @remaining,
+ @data);
+
+ { we handle the DND selection here }
+ {$IFDEF DNDDEBUG}
+ s := XGetAtomName(FDisplay, actualtype);
+ writeln(Format(' ActualType: %s (%d)', [s, ActualType]));
+ writeln(' Actualformat = ', ActualFormat);
+ writeln(' count = ', count);
+ writeln(' remaining = ', remaining);
+ writeln('-----------------');
+ {$ENDIF}
+
+ if remaining > 0 then { we have data - now fetch it! }
+ begin
+ XGetWindowProperty(FDisplay, ev.xselection.requestor,
+ ev.xselection._property, 0, remaining,
+ TBool(false),
+ AnyPropertyType,
+ @actualtype, @actualformat, @count, @dummy,
+ @data);
+ s := data;
+ end;
+
+ {$IFDEF DNDDEBUG}
+ writeln(' s = ', s);
+ {$ENDIF}
+end;
+
function TfpgX11Application.DoGetFontFaceList: TStringList;
var
pfs: PFcFontSet;
@@ -1611,7 +1657,13 @@ begin
X.SelectionNotify:
begin
- ProcessSelection(ev);
+ { Handle XDND data }
+ if ev.xselection._property = XdndSelection then
+ begin
+ HandleDNDSelection(ev);
+ end
+ else { Handle X Selections - clipboard data }
+ ProcessSelection(ev);
end;
X.SelectionRequest: