diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index 8960ef25f3..1e12466338 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -4799,24 +4799,27 @@ var i: integer; AWinControl: TWinControl; begin + ///DebugLn(['TWinControl.DestroyHandle START ',DbgSName(Self)]); if not HandleAllocated then begin DebugLn('Warning: TWinControl.DestroyHandle ',Name,':',ClassName,' Handle not Allocated'); //RaiseGDBException(''); end; // First destroy all children handles + //DebugLn(['TWinControl.DestroyHandle DESTROY CHILDS ',DbgSName(Self)]); Include(FControlState, csDestroyingHandle); if FWinControls <> nil then begin for i:= 0 to FWinControls.Count - 1 do begin - //DebugLn([' i=',i]); - //DebugLn([' ',TWinControl(FWinControls[i]).Name,':',TWinControl(FWinControls[i]).ClassName]); + //DebugLn([' ',i,' ',DbgSName(TObject(FWinControls[i]))]); AWinControl:=TWinControl(FWinControls[i]); if AWinControl.HandleAllocated then AWinControl.DestroyHandle; end; end; + //DebugLn(['TWinControl.DestroyHandle DESTROY SELF ',DbgSName(Self)]); DestroyWnd; Exclude(FControlState, csDestroyingHandle); + //DebugLn(['TWinControl.DestroyHandle END ',DbgSName(Self)]); end; {------------------------------------------------------------------------------ @@ -7012,9 +7015,9 @@ begin TWSWinControlClass(WidgetSetClass).DestroyHandle(Self); Handle := 0; - // We don't know why we here. Maybe because handle is not needed at moment - // but later it will be created once again. To propely initialize control - // after we need to restore color and font. Therefore request update here. + // Maybe handle is not needed at moment but later it will be created once + // again. To propely initialize control after we need to restore color + // and font. Request update. FWinControlFlags := FWinControlFlags + [wcfColorChanged, wcfFontChanged]; end; end; diff --git a/lcl/interfaces/gtk/gtkcallback.inc b/lcl/interfaces/gtk/gtkcallback.inc index 4619055275..52f31ae4db 100644 --- a/lcl/interfaces/gtk/gtkcallback.inc +++ b/lcl/interfaces/gtk/gtkcallback.inc @@ -1530,17 +1530,19 @@ var CaptureWidget: PGtkWidget; EventXY: TPoint; MappedXY: TPoint; + AWinControl: TWinControl; begin Result := CallBackDefaultReturn; MousePositionValid := False; + AWinControl:=TWinControl(Data); {$IFDEF VerboseMouseBugfix} DebugLn(''); DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstMousePress); DebugLn('[gtkMouseBtnPress] ', - DbgSName(TObject(Data)), + DbgSName(AWinControl, ' Widget=',DbgS(Widget), - ' ControlWidget=',DbgS(TWinControl(Data).Handle), + ' ControlWidget=',DbgS(AWinControl.Handle), ' DSO='+dbgs(DesignOnlySignal), ' '+dbgs(TruncToInt(Event^.X)),',',dbgs(TruncToInt(Event^.Y)), ' Type='+dbgs(gdk_event_get_type(Event))); @@ -1562,19 +1564,22 @@ begin if DesignOnlySignal then exit; if not ControlGetsMouseDownBefore(TControl(Data), Widget) then Exit; - CaptureWidget := PGtkWidget(TWinControl(Data).Handle); + CaptureWidget := PGtkWidget(AWinControl.Handle); if Event^.button = 1 then begin EventXY := Point(TruncToInt(Event^.X), TruncToInt(Event^.Y)); MappedXY := TranslateGdkPointToClientArea(Event^.Window, EventXY, CaptureWidget); - SetCaptureControl(TWinControl(Data), MappedXY); + {$IFDEF Gtk1} + // gtk2: the LCL will capture itself if DragMode=dmAutomatic + SetCaptureControl(AWinControl, MappedXY); + {$ENDIF} //CaptureMouseForWidget(CaptureWidget,mctGTKIntf); end else // how to skip default right click handling? LCL can tell only on mouse up // if handling can be skiped but gtk needs on mouse down if (Event^.button = 3) and - ((TWinControl(Data).PopupMenu <> nil) or + ((AWinControl.PopupMenu <> nil) or (TWinControlAccess(Data).OnContextPopup <> nil)) then begin {$IFDEF GTK1} if (TControl(Data) is TCustomNoteBook) then diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index b14ac3cb3c..fc6ed96125 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -4835,8 +4835,8 @@ begin if GtkWidgetIsA(Info^.CoreWidget, gtk_list_get_type) then begin // Paul Ishenin: - // listbox grabs pointer and other control for itself, when we click on lisebox item - // aslo it change its state to drag_selection + // listbox grabs pointer and other control for itself, when we click on listbox item + // also it changes its state to drag_selection // this is not expected in LCL and as result cause bugs, such as 7892 // so we need end drag selection manually OldMouseCaptureWidget := Info^.CoreWidget; diff --git a/lcl/interfaces/gtk2/gtk2wscalendar.pp b/lcl/interfaces/gtk2/gtk2wscalendar.pp index 92df2eb295..a567214c32 100644 --- a/lcl/interfaces/gtk2/gtk2wscalendar.pp +++ b/lcl/interfaces/gtk2/gtk2wscalendar.pp @@ -146,18 +146,7 @@ end; class procedure TGtk2WSCustomCalendar.DestroyHandle( const AWinControl: TWinControl); -var - CalendarCtrl: TCustomCalendar; - CalendarWidget: PGtkCalendar; begin - // When the user drags a day number, the gtk2 starts a mouse capture. - // when the TCalendar is on a TDateEdit, the LCL destroys the widget while the - // gtk is still capturing. Result: The capture hangs. - // thaw it: - CalendarCtrl:=TCustomCalendar(AWinControl); - CalendarWidget:=GetCalendar(CalendarCtrl); - gtk_calendar_thaw(CalendarWidget); - TGtk2WSWinControl.DestroyHandle(AWinControl); //inherited DestroyHandle(AWinControl); end;