diff --git a/lcl/interfaces/carbon/carbonlclintf.inc b/lcl/interfaces/carbon/carbonlclintf.inc index c6a12549b7..e5c76ee20a 100644 --- a/lcl/interfaces/carbon/carbonlclintf.inc +++ b/lcl/interfaces/carbon/carbonlclintf.inc @@ -356,7 +356,17 @@ end; ------------------------------------------------------------------------------} procedure TCarbonWidgetSet.SetCaptureWidget(const AWidget: HWND); begin - FCaptureWidget := AWidget; + {$IFDEF VerboseLCLIntf} + DebugLn('TCarbonWidgetSet.SetCaptureWidget AWidget: ' + DbgS(AWidget)); + {$ENDIF} + + if AWidget <> FCaptureWidget then + begin + FCaptureWidget := AWidget; + + if FCaptureWidget <> 0 then + LCLSendCaptureChangedMsg(TCarbonWidget(FCaptureWidget).LCLObject); + end; end; //##apiwiz##eps## // Do not remove, no wizard declaration after this line diff --git a/lcl/interfaces/carbon/carbonmenus.pp b/lcl/interfaces/carbon/carbonmenus.pp index 9390699f93..be0ac9fbd0 100644 --- a/lcl/interfaces/carbon/carbonmenus.pp +++ b/lcl/interfaces/carbon/carbonmenus.pp @@ -196,8 +196,6 @@ end; Frees Carbon menu item ------------------------------------------------------------------------------} destructor TCarbonMenu.Destroy; -var - I: Integer; begin if Menu <> nil then begin diff --git a/lcl/interfaces/carbon/carbonprivate.pp b/lcl/interfaces/carbon/carbonprivate.pp index e6c26b2fb0..7c34655d5b 100644 --- a/lcl/interfaces/carbon/carbonprivate.pp +++ b/lcl/interfaces/carbon/carbonprivate.pp @@ -110,8 +110,6 @@ type { TCarbonWindow } TCarbonWindow = class(TCarbonWidget) - private - FBorderStyle: TFormBorderStyle; protected procedure RegisterEvents; override; procedure CreateWidget(const AParams: TCreateParams); override; diff --git a/lcl/interfaces/carbon/carbonprivatecommon.inc b/lcl/interfaces/carbon/carbonprivatecommon.inc index 5bd09c632e..7932d8c9e3 100644 --- a/lcl/interfaces/carbon/carbonprivatecommon.inc +++ b/lcl/interfaces/carbon/carbonprivatecommon.inc @@ -120,8 +120,8 @@ begin FillChar(Msg, SizeOf(TLMMouseMove), 0); Msg.Msg := LM_MOUSEMOVE; - Msg.XPos := P.Y; - Msg.YPos := P.X; + Msg.XPos := P.X; + Msg.YPos := P.Y; Msg.Keys := GetCarbonMsgKeyState; DeliverMessage(Widget.LCLObject, Msg); @@ -187,8 +187,6 @@ begin Msg.YPos := P.Y; Msg.Keys := GetCarbonMsgKeyState; - CarbonWidgetSet.SetCaptureWidget(0); // capture is released - if (AWidget is TCarbonControl) and (cceHit in (AWidget as TCarbonControl).GetValidEvents) then begin @@ -211,6 +209,7 @@ begin DeliverMessage(AWidget.LCLObject, Msg); NotifyApplicationUserInput(Msg.Msg); + CarbonWidgetSet.SetCaptureWidget(0); // capture is released end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/carbon/carbonprivatecontrol.inc b/lcl/interfaces/carbon/carbonprivatecontrol.inc index 8e8c5316cb..622c9e5e1d 100644 --- a/lcl/interfaces/carbon/carbonprivatecontrol.inc +++ b/lcl/interfaces/carbon/carbonprivatecontrol.inc @@ -46,6 +46,7 @@ begin DeliverMessage(AWidget.LCLObject, SavedMouseUpMsg); NotifyApplicationUserInput(SavedMouseUpMsg.Msg); + CarbonWidgetSet.SetCaptureWidget(0); // capture is released end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/carbon/carbonprivatewindow.inc b/lcl/interfaces/carbon/carbonprivatewindow.inc index e43e29ddd5..c462298c64 100644 --- a/lcl/interfaces/carbon/carbonprivatewindow.inc +++ b/lcl/interfaces/carbon/carbonprivatewindow.inc @@ -971,8 +971,6 @@ begin SetControlProperty(Content, LAZARUS_FOURCC, WIDGETINFO_FOURCC, SizeOf(Self), @Self), Self, SCreateWidget, SSetControlProp); - FBorderStyle := (LCLObject as TCustomForm).BorderStyle; - SetBounds(Bounds(AParams.X, AParams.Y, AParams.Width, AParams.Height)); SetText(AParams.Caption); DebugLn('TCarbonWindow.CreateWidget succeeds'); @@ -1465,21 +1463,17 @@ procedure TCarbonWindow.SetFormBorderStyle(AFormBorderStyle: TFormBorderStyle); var AttrsSet, AttrsRemove: WindowAttributes; begin - if AFormBorderStyle = FBorderStyle then Exit; - if (AFormBorderStyle = bsNone) or (FBorderStyle = bsNone) then - begin - RecreateWnd(LCLObject); - Exit; - end; + BeginUpdate(WindowRef(Widget)); + try + AttrsSet := FormBorderToWindowAttrs(AFormBorderStyle); + AttrsRemove := (kWindowNoTitleBarAttribute or kWindowCloseBoxAttribute or + kWindowCollapseBoxAttribute or kWindowFullZoomAttribute or + kWindowResizableAttribute) and (not AttrsSet); - AttrsSet := FormBorderToWindowAttrs(AFormBorderStyle); - AttrsRemove := (kWindowNoTitleBarAttribute or kWindowCloseBoxAttribute or - kWindowCollapseBoxAttribute or kWindowFullZoomAttribute or - kWindowResizableAttribute) and (not AttrsSet); - - if OSError( - ChangeWindowAttributes(WindowRef(Widget), AttrsSet, AttrsRemove), Self, - 'SetFormBorderStyle', SChangeWindowAttrs) then Exit; - - FBorderStyle := AFormBorderStyle; + if OSError( + ChangeWindowAttributes(WindowRef(Widget), AttrsSet, AttrsRemove), Self, + 'SetFormBorderStyle', SChangeWindowAttrs) then Exit; + finally + EndUpdate(WindowRef(Widget)); + end; end; diff --git a/lcl/interfaces/carbon/carbonwinapi.inc b/lcl/interfaces/carbon/carbonwinapi.inc index 7bf322b68d..5f3eb0dfee 100644 --- a/lcl/interfaces/carbon/carbonwinapi.inc +++ b/lcl/interfaces/carbon/carbonwinapi.inc @@ -2192,9 +2192,25 @@ begin Result:=inherited RegroupMenuItem(hndMenu, GroupIndex); end; +{------------------------------------------------------------------------------ + Method: ReleaseCapture + Returns: If the function succeeds + + Releases the mouse capture from a window and restores normal mouse input + processing + TODO: not only release capture indicator + ------------------------------------------------------------------------------} function TCarbonWidgetSet.ReleaseCapture: Boolean; begin - Result:=inherited ReleaseCapture; + Result := False; + + {$IFDEF VerboseWinAPI} + DebugLn('TCarbonWidgetSet.ReleaseCapture'); + {$ENDIF} + + SetCaptureWidget(0); + + Result := True; end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/carbon/carbonwsmenus.pp b/lcl/interfaces/carbon/carbonwsmenus.pp index e78c7d059a..64e2c9d543 100644 --- a/lcl/interfaces/carbon/carbonwsmenus.pp +++ b/lcl/interfaces/carbon/carbonwsmenus.pp @@ -261,7 +261,6 @@ end; Returns: If the function succeeds Sets the enabled of menu item in Carbon interface - TODO: disable menu bar items ------------------------------------------------------------------------------} class function TCarbonWSMenuItem.SetEnable(const AMenuItem: TMenuItem; const Enabled: boolean): boolean;