From f90c864215c653e8bd31f5ae73ecfebd88244000 Mon Sep 17 00:00:00 2001 From: rich2014 Date: Wed, 21 Aug 2024 22:18:53 +0800 Subject: [PATCH] Cocoa/Config: turn Notification Config to the new Style --- lcl/interfaces/cocoa/cocoaconfig.inc | 8 ++++++++ lcl/interfaces/cocoa/cocoaconfig.pas | 11 ++++------- lcl/interfaces/cocoa/cocoatrayicon.inc | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoaconfig.inc b/lcl/interfaces/cocoa/cocoaconfig.inc index a56f574dba..a14d4d8cba 100644 --- a/lcl/interfaces/cocoa/cocoaconfig.inc +++ b/lcl/interfaces/cocoa/cocoaconfig.inc @@ -91,3 +91,11 @@ var ); ); +var + CocoaConfigNotification: TCocoaConfigNotification = ( + // by default on macOS, Notification is only Presented when the APP is + // in the background. + // when CocoaAlwaysPresentNotification is set to True, Notification is + // always Presented. + alwaysPresent: True; + ); diff --git a/lcl/interfaces/cocoa/cocoaconfig.pas b/lcl/interfaces/cocoa/cocoaconfig.pas index 10b239ea37..130e2507a9 100644 --- a/lcl/interfaces/cocoa/cocoaconfig.pas +++ b/lcl/interfaces/cocoa/cocoaconfig.pas @@ -139,7 +139,11 @@ type end; type + TCocoaConfigNotification = record + alwaysPresent: Boolean; + end; +type // on macOS, the FocusRing takes up extra space, which may cause strange // display in some cases. it may block other controls, or be partially cut off. // for example, in the Lazarus IDE - About dialog, the FocusRing of the @@ -164,13 +168,6 @@ type function getCocoaControlFocusRingStrategry( AClassName: NSString ): TCocoaFocusRingStrategy; var - // by default on macOS, Notification is only Presented when the APP is - // in the background. - // when CocoaAlwaysPresentNotification is set to True, Notification is - // always Presented. - CocoaAlwaysPresentNotification : Boolean = True; - - // for compatiblity with LCL 1.8 release. The macOS base is 72ppi CocoaBasePPI : Integer = 96; diff --git a/lcl/interfaces/cocoa/cocoatrayicon.inc b/lcl/interfaces/cocoa/cocoatrayicon.inc index e072b566dc..096f96a90c 100644 --- a/lcl/interfaces/cocoa/cocoatrayicon.inc +++ b/lcl/interfaces/cocoa/cocoatrayicon.inc @@ -202,7 +202,7 @@ begin message.setSoundName( NSUserNotificationDefaultSoundName ); nc:= NSUserNotificationCenter.defaultUserNotificationCenter; - if CocoaConfig.CocoaAlwaysPresentNotification then begin + if CocoaConfigNotification.alwaysPresent then begin if NOT Assigned(nc.delegate) then nc.setDelegate( TCocoaUserNotificationCenterDelegate.new ); end;