vcl/inc/osx/salnativewidgets.h |    2 -
 vcl/osx/salnativewidgets.cxx   |   68 +++++++++++++++++++++++++++++++++++++----
 2 files changed, 63 insertions(+), 7 deletions(-)

New commits:
commit 764799befcb927f68f78e904213e3db7195554cb
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Sat Aug 9 19:22:54 2025 -0400
Commit:     Patrick Luby <guibomac...@gmail.com>
CommitDate: Fri Aug 22 23:47:41 2025 +0200

    Adjust bounds of native controls for macOS Tahoe
    
    macOS Tahoe increased the width of push buttons, listboxes, and
    spin buttons. macOS Taho *only* uses the new sizes if the code is
    built with Xcode 26 or higher. The same code built on earlier
    versions of Xcode will display native controls with the pre-Tahoe
    sizes. Hence, the use of the following unwieldy style:
    
     #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000
         if (@available(macOS 26, *))
             ; // Do macOS Tahoe or later code
         else
     #endif
             ; // Do pre-macOS Tahoe or earlier code
    
    Eventually, when official builds are being done on macOS Tahoe,
    but still supporting pre-macOS Tahoe versions, the #if and #endif
    can be removed:
    
         if (@available(macOS 26, *))
             ; // Do macOS Tahoe or later code
         else
             ; // Do pre-macOS Tahoe or earlier code
    
    Also, adjusted the width of flexible push buttons and spin buttons
    so that the focus ring is not clipped on pre-macOS Tahoe versions.
    
    Change-Id: I2f86f73590a50751dc25000dfc1e9cccb4f4a962
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189282
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>
    Tested-by: Jenkins

diff --git a/vcl/inc/osx/salnativewidgets.h b/vcl/inc/osx/salnativewidgets.h
index 5c36ad8c8b08..002df75f1fcf 100644
--- a/vcl/inc/osx/salnativewidgets.h
+++ b/vcl/inc/osx/salnativewidgets.h
@@ -53,7 +53,7 @@
 #define LISTBOX_BORDER_WIDTH 1   // width of listbox border in pixels
 #define LISTBOX_TEXT_MARGIN 1    // left/right margin of text in pixels
 
-#define SPIN_BUTTON_WIDTH 13         // width of spin button without focus 
ring in pixels
+#define SPIN_BUTTON_WIDTH spinButtonWidth()  // width of spin button without 
focus ring in pixels
 #define SPIN_UPPER_BUTTON_HEIGHT 11  // height of upper spin button without 
focus ring in pixels
 #define SPIN_LOWER_BUTTON_HEIGHT 11  // height of lower spin button without 
focus ring in pixels
 
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index 499fc3e6f55b..c905fa9acf48 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -450,6 +450,16 @@ static void drawEditableBackground(CGContextRef context, 
const NSRect& rc)
     CGContextRestoreGState(context);
 }
 
+static constexpr int spinButtonWidth()
+{
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000
+    if (@available(macOS 26, *))
+        return 23;
+    else
+#endif
+        return 16;
+}
+
 // As seen in macOS 12.3.1. All a bit odd really.
 const int RoundedMargin[4] = { 6, 4, 0, 3 };
 
@@ -614,8 +624,31 @@ bool 
AquaGraphicsBackendBase::performDrawNativeControl(ControlType nType,
                     rc.origin.x -= nMargin;
                     rc.size.width += nMargin * 2;
 
-                    rc.origin.x += FOCUS_RING_WIDTH / 2;
-                    rc.size.width -= FOCUS_RING_WIDTH;
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000
+                    if (@available(macOS 26, *))
+                    {
+                        rc.origin.x += FOCUS_RING_WIDTH * 2;
+                        rc.size.width -= FOCUS_RING_WIDTH * 4;
+                        if (eBezelStyle == NSBezelStyleFlexiblePush)
+                        {
+                            rc.origin.y += 1;
+                            rc.size.height -= FOCUS_RING_WIDTH;
+                        }
+                    }
+                    else
+#endif
+                    {
+                        if (eBezelStyle == NSBezelStyleFlexiblePush)
+                        {
+                            rc.origin.x += FOCUS_RING_WIDTH;
+                            rc.size.width -= FOCUS_RING_WIDTH * 2;
+                        }
+                        else
+                        {
+                            rc.origin.x += FOCUS_RING_WIDTH / 2;
+                            rc.size.width -= FOCUS_RING_WIDTH;
+                        }
+                    }
                 }
 
                 const bool bFocused(nState & ControlState::FOCUSED);
@@ -997,7 +1030,12 @@ bool 
AquaGraphicsBackendBase::performDrawNativeControl(ControlType nType,
 
                 {
                     rc.origin.x += 2;
-                    rc.size.width -= 1;
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000
+                    if (@available(macOS 26, *))
+                        rc.size.width -= 4;
+                    else
+#endif
+                        rc.size.width -= 1;
                 }
 
                 drawEditableBackground(context, rc);
@@ -1028,6 +1066,14 @@ bool 
AquaGraphicsBackendBase::performDrawNativeControl(ControlType nType,
                     else
                         [pBtn setKeyEquivalent: @""];
 
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000
+                    if (@available(macOS 26, *))
+                    {
+                        rc.origin.x += 2;
+                        rc.size.width -= 4;
+                    }
+                    else
+#endif
                     {
                         rc.size.width += 1;
                     }
@@ -1097,9 +1143,14 @@ bool 
AquaGraphicsBackendBase::performDrawNativeControl(ControlType nType,
                     ControlState nLowerState = pSpinButtonVal->mnLowerState;
 
                     rc.origin.x += rc.size.width + FOCUS_RING_WIDTH + 1;
-                    rc.origin.y -= 1;
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000
+                    if (@available(macOS 26, *))
+                        ;
+                    else
+#endif
+                        rc.origin.y -= 1;
                     rc.size.width = SPIN_BUTTON_WIDTH;
-                    rc.size.height = SPIN_LOWER_BUTTON_HEIGHT + 
SPIN_LOWER_BUTTON_HEIGHT;
+                    rc.size.height = SPIN_UPPER_BUTTON_HEIGHT + 
SPIN_LOWER_BUTTON_HEIGHT;
 
                     NSStepperCell* pBtn = pInst->mpStepperCell;
 
@@ -1343,7 +1394,12 @@ bool AquaSalGraphics::getNativeControlRegion(ControlType 
nType,
             if (nPart == ControlPart::Entire)
             {
                 w = aCtrlBoundRect.GetWidth();
-                h = EDITBOX_HEIGHT + 2 * FOCUS_RING_WIDTH;
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000
+                if (@available(macOS 26, *))
+                    h = EDITBOX_HEIGHT + 2 * FOCUS_RING_WIDTH + 1;
+                else
+#endif
+                    h = EDITBOX_HEIGHT + 2 * FOCUS_RING_WIDTH;
                 x += SPINBOX_OFFSET;
                 rNativeBoundingRegion = tools::Rectangle(Point(x, y), Size(w, 
h));
                 rNativeContentRegion = tools::Rectangle(Point(x, y), Size(w, 
h));

Reply via email to