summaryrefslogtreecommitdiff
path: root/src/corelib/x11
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-26 17:29:33 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-26 17:29:33 +0200
commit13b80a4a295a7f69d61e2fb8d02d5f457dcebef7 (patch)
tree3eb11e38cab84163b972a65f0827ced3ffcd6272 /src/corelib/x11
parent60a7c674dc29a8f6fdbca1e163618d456a53a8d9 (diff)
downloadfpGUI-13b80a4a295a7f69d61e2fb8d02d5f457dcebef7.tar.xz
X11: in HandleDNDposition() we never recursed through all children
The bug was that it only checked for the immediate children of the toplevel window. It never recursed through all levels of children finding the correct child the mouse cursor is over. This is now fixed. This also allows embedded frames or forms to work with DND.
Diffstat (limited to 'src/corelib/x11')
-rw-r--r--src/corelib/x11/fpg_x11.pas36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/corelib/x11/fpg_x11.pas b/src/corelib/x11/fpg_x11.pas
index 0209af14..37c2b507 100644
--- a/src/corelib/x11/fpg_x11.pas
+++ b/src/corelib/x11/fpg_x11.pas
@@ -1021,6 +1021,13 @@ var
Msg: TXEvent;
dx, dy, dx2, dy2: cint;
child: TWindow;
+ prevchild: TWindow;
+
+ ret_root: TfpgWinHandle;
+ ret_child: TfpgWinHandle;
+ root_x, root_y: integer;
+ child_x, child_y: integer;
+
s: string;
i: integer;
lTargetWinHandle: TWindow;
@@ -1050,25 +1057,30 @@ begin
writeln(' x_root: ', x_root, ' y_root: ', y_root);
{$ENDIF}
- // query to see if we accept to be drop target
+ // Find window under cursor, and position of cursor inside that window
XTranslateCoordinates(FDisplay, XDefaultRootWindow(FDisplay), ATopLevelWindow.WinHandle,
- x_root, y_root, @dx, @dy, @child);
-
- {$IFDEF DNDDEBUG}
- writeln(Format('x:%d y:%d child:%d', [dx, dy, child]));
- {$ENDIF}
-
- if child <> 0 then
+ x_root, y_root, @dx, @dy, @ret_child);
+ child := ret_child;
+ prevchild := ATopLevelWindow.WinHandle;
+ while ret_child <> 0 do // If we have chidren, iterate until we reach the top most child
begin
- w := FindWindowByHandle(child);
+ child := ret_child;
dx2 := dx;
dy2 := dy;
- XTranslateCoordinates(FDisplay, ATopLevelWindow.WinHandle, w.WinHandle,
- dx2, dy2, @dx, @dy, @child);
- end
+ XTranslateCoordinates(FDisplay, prevchild, child,
+ dx2, dy2, @dx, @dy, @ret_child);
+ prevchild := child;
+ end;
+
+ if child <> 0 then
+ w := FindWindowByHandle(child)
else
w := ATopLevelWindow;
+ {$IFDEF DNDDEBUG}
+ writeln(Format('x:%d y:%d child:%d (%x)', [dx, dy, w.WinHandle, w.WinHandle]));
+ {$ENDIF}
+
if Assigned(w) then
begin
lTargetWinHandle := w.WinHandle;