From c867ac9117472bafe897ed4b66f87afe242d5dc0 Mon Sep 17 00:00:00 2001 From: ryancog <170381220+ryancog@users.noreply.github.com> Date: Tue, 23 Jun 2026 15:33:50 -0400 Subject: [PATCH 1/2] wxOSX/Cocoa add wxWindowMac::MacInvalidateInsetCache() --- include/wx/osx/window.h | 4 ++++ src/osx/window_osx.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/wx/osx/window.h b/include/wx/osx/window.h index a575e5cfba..3f867c66a5 100644 --- a/include/wx/osx/window.h +++ b/include/wx/osx/window.h @@ -204,6 +204,10 @@ public: virtual long MacGetTopBorderSize() const; virtual long MacGetBottomBorderSize() const; + // Must be called whenever window style changes result in changes to layout + // insets (`-[NSView alignmentRectInsets:]`, used for MacGetBorderSize()) + virtual void MacInvalidateInsetCache() const; + virtual void MacSuperChangedPosition() ; // absolute coordinates of this window's root have changed diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 33aee0f387..76efdff7d9 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -2344,6 +2344,11 @@ long wxWindowMac::MacGetBottomBorderSize() const { return MacGetBorderSize().bottom; } +void wxWindowMac::MacInvalidateInsetCache() const { + if ( GetPeer() ) + GetPeer()->InvalidateLayoutInset(); +} + long wxWindowMac::MacRemoveBordersFromStyle( long style ) { return style & ~wxBORDER_MASK ; From fb64a2c4ae2bf53f0b0af87066eed8a0600a9852 Mon Sep 17 00:00:00 2001 From: ryancog <170381220+ryancog@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:38:59 -0400 Subject: [PATCH 2/2] wxOSX/Cocoa add -[wxNSButton setBezelStyle:] to handle inset cache --- src/osx/cocoa/button.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/osx/cocoa/button.mm b/src/osx/cocoa/button.mm index c2211cb171..982fb5296b 100644 --- a/src/osx/cocoa/button.mm +++ b/src/osx/cocoa/button.mm @@ -66,6 +66,19 @@ } } +- (void) setBezelStyle: (NSBezelStyle) s +{ + [super setBezelStyle:s]; + + // Setting the bezel style may change the layout insets, so the cache + // needs to be invalidated to avoid incorrect layout. + // Done here so it's handled for both internal wx usage and application + // code when accessed with `wxWindow::GetHandle()` + auto *impl{wxWidgetImpl::FindFromWXWidget(self)}; + if (impl) + impl->InvalidateLayoutInset(); +} + - (void) setTrackingTag: (NSTrackingRectTag)tag { rectTag = tag;