Gtk2: reset LastWFPResult used by WindowFromPoint() in case when shown/hidden,enabled/disabled,moved,resized widget overlaps current cache.Fixes issue #17389

git-svn-id: trunk@28288 -
This commit is contained in:
zeljko 2010-11-17 08:59:09 +00:00
parent db41426263
commit 9815e521d3
5 changed files with 25 additions and 0 deletions

View File

@ -690,6 +690,26 @@ begin
Result := Info^.ChangeLock;
end;
{------------------------------------------------------------------------------
Reset cached LastWFPResult used by WindowFromPoint.LastWFPResult should be
invalidated when some control at LastWFPMousePos is hidden, shown, enabled,
disabled, moved.
------------------------------------------------------------------------------}
procedure InvalidateLastWFPResult(AControl: TWinControl; const ABounds: TRect);
begin
if PtInRect(ABounds, LastWFPMousePos) and
GTK_IS_OBJECT(Pointer(LastWFPResult)) then
begin
if (AControl <> nil) and (AControl.Handle = LastWFPResult) and
AControl.Enabled and AControl.Visible then
exit;
g_signal_handlers_disconnect_by_func(GPointer(LastWFPResult),
TGTKSignalFunc(@DestroyWindowFromPointCB), nil);
LastWFPResult := 0;
LastWFPMousePos := Point(High(Integer), High(Integer));
end;
end;
procedure SetFormShowInTaskbar(AForm: TCustomForm;
const AValue: TShowInTaskbar);
var

View File

@ -310,6 +310,7 @@ function WidgetIsDestroyingHandle(Widget: PGtkWidget): boolean;
procedure SetWidgetIsDestroyingHandle(Widget: PGtkWidget);
function ComponentIsDestroyingHandle(AWinControl: TWinControl): boolean;
function LockOnChange(GtkObject: PGtkObject; LockOffset: integer): integer;
procedure InvalidateLastWFPResult(AControl: TWinControl; const ABounds: TRect);
// glib
procedure MoveGListLinkBehind(First, Item, After: PGList);

View File

@ -2677,6 +2677,7 @@ begin
begin
Result := not GTK_WIDGET_SENSITIVE(PGtkWidget(HWND));
gtk_widget_set_sensitive(PGtkWidget(hWnd), bEnable);
InvalidateLastWFPResult(nil, RectFromGdkRect(PGtkWidget(HWND)^.allocation));
end;
end;

View File

@ -591,6 +591,7 @@ class procedure TGtk2WSWinControl.ShowHide(const AWinControl: TWinControl);
begin
// other methods use ShowHide also, can't move code
Gtk2WidgetSet.SetVisible(AWinControl, AWinControl.HandleObjectShouldBeVisible);
InvalidateLastWFPResult(AWinControl, AWinControl.BoundsRect);
end;
class procedure TGtk2WSWinControl.SetBounds(const AWinControl: TWinControl;
@ -600,6 +601,7 @@ begin
then Exit;
ResizeHandle(AWinControl);
InvalidateLastWFPResult(AWinControl, Rect(ALeft, ATop, AWidth, AHeight));
end;

View File

@ -620,6 +620,7 @@ begin
GtkWindowShowModal(GtkWindow);
end else
Gtk2WidgetSet.SetVisible(AWinControl, AForm.HandleObjectShouldBeVisible);
InvalidateLastWFPResult(AWinControl, AWinControl.BoundsRect);
end;
class procedure TGtk2WSCustomForm.ShowModal(const AForm: TCustomForm);