wxOSX/Cocoa add wxWindowMac::MacInvalidateInsetCache()
wxOSX/Cocoa add -[wxNSButton setBezelStyle:] to handle inset cache
Revert "Ensure the window origin is visible after DPI change" This reverts commit 75284bb8f05ab3fe8a87ea560788af4a31ec2068 because it doesn't always use the right window: at least under Windows 11 25H2 it is possible that the center of the window is still on the old display when we receive WM_DPICHANGED and so the window is moved to a wrong position because of the check added in that commit. Because this check was mostly needed to work around other issues that made the window become too big, it seems better to revert it rather than break something that worked correctly before. See #26604.
Scale wxSplitterWindow sash width by DPI factor Closes #26647.
Support switching to wxMSW dark mode in wxAuiToolBar On Windows, enable dark mode switching for wxAuiToolBar by updating m_themed upon system colour change. Closes #26648.
Merge branch 'osx-window-invalidate-inset-cache' of github.com:ryancog/wxWidgets Add wxWindow::MacInvalidateInsetCache() to wxOSX/Cocoa. See #26625. Closes #26622.
Reformat recently added wxOSX border code to follow wx style
Put "{" opening a block on its own line.
No real changes.
Fix dark mode border flicker Fix dark mode border flicker by using a clipping region when calling MSWDefWindowProc(). This prevents drawing the light mode border before the dark border is drawn. See #26646.
Explicitly draw dark mode border On Windows in dark mode, explicitly draw borders rather than relying on DrawThemeBackground(), which does not work well on older versions of Windows. Closes #26646.
Add missing functions for wxUSE_DARK_MODE=0 Stubs for these functions for this build variant should have been added when they themselves were but this was forgotten. Closes #26649.
Avoid buffer overflow when parsing AFM files Limit sscanf field widths to avoid overflowing fixed size buffers in wxPostScriptDC code. Closes #26645.
Avoid OOM in wxTarInputStream for very large extended header Don't try allocating arbitrarily large amounts of memory for the extended header in wxTarInputStream and impose a very big but still reasonable enough to not result in out of memory condition size for it by default. Allow changing this size via the newly added SetMaxExtendedHeaderSize() function for the applications that want to handle files with even bigger header or, on the contrary, want to avoid allocating even that much. This should fix running out of memory in OSS-Fuzz runs using the fuzzer for this class. Closes #26588. Closes #26607. Signed-off-by: Arthur Chan <arthu...@adalogics.com>
Add new fuzzer target fileconf for OSS-Fuzz Check for bugs in wxFileConfig. Closes #26597. Signed-off-by: Arthur Chan <arthu...@adalogics.com>
| ... | ... | @@ -79,6 +79,8 @@ public: |
| 79 | 79 | virtual int ShowDropDown(wxWindow* wnd,
|
| 80 | 80 | const wxAuiToolBarItemArray& items) override;
|
| 81 | 81 | |
| 82 | + virtual void UpdateColoursFromSystem() override;
|
|
| 83 | + |
|
| 82 | 84 | private:
|
| 83 | 85 | bool m_themed;
|
| 84 | 86 | wxSize m_buttonSize;
|
| ... | ... | @@ -204,6 +204,10 @@ public: |
| 204 | 204 | virtual long MacGetTopBorderSize() const;
|
| 205 | 205 | virtual long MacGetBottomBorderSize() const;
|
| 206 | 206 | |
| 207 | + // Must be called whenever window style changes result in changes to layout
|
|
| 208 | + // insets (`-[NSView alignmentRectInsets:]`, used for MacGetBorderSize())
|
|
| 209 | + virtual void MacInvalidateInsetCache() const;
|
|
| 210 | + |
|
| 207 | 211 | virtual void MacSuperChangedPosition() ;
|
| 208 | 212 | |
| 209 | 213 | // absolute coordinates of this window's root have changed
|
| ... | ... | @@ -166,6 +166,10 @@ public: |
| 166 | 166 | wxFileOffset GetLength() const override { return m_size; }
|
| 167 | 167 | bool IsSeekable() const override { return m_parent_i_stream->IsSeekable(); }
|
| 168 | 168 | |
| 169 | + // Limit on the extended header size, to avoid excessive allocation.
|
|
| 170 | + static size_t GetMaxExtendedHeaderSize() { return sm_maxExtendedHeaderSize; }
|
|
| 171 | + static void SetMaxExtendedHeaderSize(size_t size) { sm_maxExtendedHeaderSize = size; }
|
|
| 172 | + |
|
| 169 | 173 | protected:
|
| 170 | 174 | size_t OnSysRead(void *buffer, size_t size) override;
|
| 171 | 175 | wxFileOffset OnSysTell() const override { return m_pos; }
|
| ... | ... | @@ -199,6 +203,8 @@ private: |
| 199 | 203 | wxTarHeaderRecords *m_HeaderRecs;
|
| 200 | 204 | wxTarHeaderRecords *m_GlobalHeaderRecs;
|
| 201 | 205 | |
| 206 | + static size_t sm_maxExtendedHeaderSize;
|
|
| 207 | + |
|
| 202 | 208 | wxDECLARE_NO_COPY_CLASS(wxTarInputStream);
|
| 203 | 209 | };
|
| 204 | 210 |
| ... | ... | @@ -91,6 +91,25 @@ public: |
| 91 | 91 | seekable stream.
|
| 92 | 92 | */
|
| 93 | 93 | bool OpenEntry(wxTarEntry& entry);
|
| 94 | + |
|
| 95 | + /**
|
|
| 96 | + Returns the maximum allowed size of a tar extended header.
|
|
| 97 | + |
|
| 98 | + @see SetMaxExtendedHeaderSize()
|
|
| 99 | + |
|
| 100 | + @since 3.3.3
|
|
| 101 | + */
|
|
| 102 | + static size_t GetMaxExtendedHeaderSize();
|
|
| 103 | + |
|
| 104 | + /**
|
|
| 105 | + Sets the maximum allowed size of a tar extended header.
|
|
| 106 | + |
|
| 107 | + Extended headers larger than this are rejected to avoid excessive
|
|
| 108 | + memory allocation. The default is 10 MiB.
|
|
| 109 | + |
|
| 110 | + @since 3.3.3
|
|
| 111 | + */
|
|
| 112 | + static void SetMaxExtendedHeaderSize(size_t size);
|
|
| 94 | 113 | };
|
| 95 | 114 | |
| 96 | 115 |
| ... | ... | @@ -26,11 +26,8 @@ |
| 26 | 26 | |
| 27 | 27 | wxAuiMSWToolBarArt::wxAuiMSWToolBarArt()
|
| 28 | 28 | {
|
| 29 | - // Theme colours don't work in dark theme, so don't use them in this case.
|
|
| 30 | - if ( wxUxThemeIsActive() && !wxMSWDarkMode::IsActive() )
|
|
| 29 | + if ( wxUxThemeIsActive() )
|
|
| 31 | 30 | {
|
| 32 | - m_themed = true;
|
|
| 33 | - |
|
| 34 | 31 | // Determine sizes from theme
|
| 35 | 32 | wxWindow* window = static_cast<wxApp*>(wxApp::GetInstance())->GetTopWindow();
|
| 36 | 33 | wxUxThemeHandle hTheme(window, L"Rebar");
|
| ... | ... | @@ -51,8 +48,8 @@ wxAuiMSWToolBarArt::wxAuiMSWToolBarArt() |
| 51 | 48 | |
| 52 | 49 | m_buttonSize = hThemeToolbar.GetTrueSize(TP_BUTTON);
|
| 53 | 50 | }
|
| 54 | - else
|
|
| 55 | - m_themed = false;
|
|
| 51 | + |
|
| 52 | + UpdateColoursFromSystem();
|
|
| 56 | 53 | }
|
| 57 | 54 | |
| 58 | 55 | wxAuiToolBarArt* wxAuiMSWToolBarArt::Clone()
|
| ... | ... | @@ -432,4 +429,12 @@ int wxAuiMSWToolBarArt::ShowDropDown(wxWindow* wnd, |
| 432 | 429 | return wxAuiGenericToolBarArt::ShowDropDown(wnd, items);
|
| 433 | 430 | }
|
| 434 | 431 | |
| 432 | +void wxAuiMSWToolBarArt::UpdateColoursFromSystem()
|
|
| 433 | +{
|
|
| 434 | + wxAuiGenericToolBarArt::UpdateColoursFromSystem();
|
|
| 435 | + |
|
| 436 | + // Theme colours do not work in dark mode.
|
|
| 437 | + m_themed = wxUxThemeIsActive() && !wxMSWDarkMode::IsActive();
|
|
| 438 | +}
|
|
| 439 | + |
|
| 435 | 440 | #endif // wxUSE_AUI |
| ... | ... | @@ -622,6 +622,9 @@ void wxTarEntry::SetMode(int mode) |
| 622 | 622 | /////////////////////////////////////////////////////////////////////////////
|
| 623 | 623 | // Input stream
|
| 624 | 624 | |
| 625 | +// Default cap of 10 MiB; can be changed with SetMaxExtendedHeaderSize().
|
|
| 626 | +size_t wxTarInputStream::sm_maxExtendedHeaderSize = 10 * 1024 * 1024;
|
|
| 627 | + |
|
| 625 | 628 | wxTarInputStream::wxTarInputStream(wxInputStream& stream,
|
| 626 | 629 | wxMBConv& conv /*=wxConvLocal*/)
|
| 627 | 630 | : wxArchiveInputStream(stream, conv)
|
| ... | ... | @@ -909,8 +912,16 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs) |
| 909 | 912 | if (!recs)
|
| 910 | 913 | recs = new wxTarHeaderRecords;
|
| 911 | 914 | |
| 912 | - // round length up to a whole number of blocks
|
|
| 913 | 915 | size_t len = m_hdr->GetOctal(TAR_SIZE);
|
| 916 | + |
|
| 917 | + // reject an unreasonably large extended header to avoid excessive allocation
|
|
| 918 | + if (len > GetMaxExtendedHeaderSize())
|
|
| 919 | + {
|
|
| 920 | + wxLogError(_("Extended tar header size %zu is greater than maximum allowed."), len);
|
|
| 921 | + return false;
|
|
| 922 | + }
|
|
| 923 | + |
|
| 924 | + // round length up to a whole number of blocks
|
|
| 914 | 925 | size_t size = RoundUpSize(len);
|
| 915 | 926 | |
| 916 | 927 | // read in the whole header since it should be small
|
| ... | ... | @@ -2163,7 +2163,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, |
| 2163 | 2163 | /* A.) check for descender definition */
|
| 2164 | 2164 | if (strncmp(line,"Descender",9)==0)
|
| 2165 | 2165 | {
|
| 2166 | - if ((sscanf(line,"%s%d",descString,&lastDescender)!=2) ||
|
|
| 2166 | + if ((sscanf(line,"%19s%d",descString,&lastDescender)!=2) ||
|
|
| 2167 | 2167 | (strcmp(descString,"Descender")!=0))
|
| 2168 | 2168 | {
|
| 2169 | 2169 | wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad descender)"), afmName,line );
|
| ... | ... | @@ -2172,7 +2172,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, |
| 2172 | 2172 | /* JC 1.) check for UnderlinePosition */
|
| 2173 | 2173 | else if(strncmp(line,"UnderlinePosition",17)==0)
|
| 2174 | 2174 | {
|
| 2175 | - if ((sscanf(line,"%s%lf",upString,&UnderlinePosition)!=2) ||
|
|
| 2175 | + if ((sscanf(line,"%29s%lf",upString,&UnderlinePosition)!=2) ||
|
|
| 2176 | 2176 | (strcmp(upString,"UnderlinePosition")!=0))
|
| 2177 | 2177 | {
|
| 2178 | 2178 | wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad UnderlinePosition)"), afmName, line );
|
| ... | ... | @@ -2181,7 +2181,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, |
| 2181 | 2181 | /* JC 2.) check for UnderlineThickness */
|
| 2182 | 2182 | else if(strncmp(line,"UnderlineThickness",18)==0)
|
| 2183 | 2183 | {
|
| 2184 | - if ((sscanf(line,"%s%lf",utString,&UnderlineThickness)!=2) ||
|
|
| 2184 | + if ((sscanf(line,"%29s%lf",utString,&UnderlineThickness)!=2) ||
|
|
| 2185 | 2185 | (strcmp(utString,"UnderlineThickness")!=0))
|
| 2186 | 2186 | {
|
| 2187 | 2187 | wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad UnderlineThickness)"), afmName, line );
|
| ... | ... | @@ -2190,7 +2190,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, |
| 2190 | 2190 | /* JC 3.) check for EncodingScheme */
|
| 2191 | 2191 | else if(strncmp(line,"EncodingScheme",14)==0)
|
| 2192 | 2192 | {
|
| 2193 | - if ((sscanf(line,"%s%s",utString,encString)!=2) ||
|
|
| 2193 | + if ((sscanf(line,"%29s%49s",utString,encString)!=2) ||
|
|
| 2194 | 2194 | (strcmp(utString,"EncodingScheme")!=0))
|
| 2195 | 2195 | {
|
| 2196 | 2196 | wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad EncodingScheme)"), afmName, line );
|
| ... | ... | @@ -2204,7 +2204,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, |
| 2204 | 2204 | /* B.) check for char-width */
|
| 2205 | 2205 | else if(strncmp(line,"C ",2)==0)
|
| 2206 | 2206 | {
|
| 2207 | - if (sscanf(line,"%s%d%s%s%d",cString,&ascii,semiString,WXString,&cWidth)!=5)
|
|
| 2207 | + if (sscanf(line,"%9s%d%9s%9s%d",cString,&ascii,semiString,WXString,&cWidth)!=5)
|
|
| 2208 | 2208 | {
|
| 2209 | 2209 | wxLogDebug(wxT("AFM-file '%s': line '%s' has an error (bad character width)"),afmName,line);
|
| 2210 | 2210 | }
|
| ... | ... | @@ -824,6 +824,11 @@ bool IsActive() |
| 824 | 824 | return false;
|
| 825 | 825 | }
|
| 826 | 826 | |
| 827 | +bool HasChanged()
|
|
| 828 | +{
|
|
| 829 | + return false;
|
|
| 830 | +}
|
|
| 831 | + |
|
| 827 | 832 | void ConfigureTLW(HWND WXUNUSED(hwnd))
|
| 828 | 833 | {
|
| 829 | 834 | }
|
| ... | ... | @@ -867,6 +872,10 @@ HandleMenuMessage(WXLRESULT* WXUNUSED(result), |
| 867 | 872 | return false;
|
| 868 | 873 | }
|
| 869 | 874 | |
| 875 | +void NotifySysColorChange()
|
|
| 876 | +{
|
|
| 877 | +}
|
|
| 878 | + |
|
| 870 | 879 | } // namespace wxMSWDarkMode
|
| 871 | 880 | |
| 872 | 881 | #endif // wxUSE_DARK_MODE/!wxUSE_DARK_MODE
|
| ... | ... | @@ -34,7 +34,6 @@ |
| 34 | 34 | #include "wx/graphics.h"
|
| 35 | 35 | #endif // wxUSE_GRAPHICS_CONTEXT
|
| 36 | 36 | |
| 37 | -#include "wx/display.h"
|
|
| 38 | 37 | #include "wx/dynlib.h"
|
| 39 | 38 | #include "wx/msw/missing.h"
|
| 40 | 39 | #include "wx/msw/private/darkmode.h"
|
| ... | ... | @@ -339,14 +338,6 @@ bool wxNonOwnedWindow::HandleDPIChange(const wxSize& newDPI, const wxRect& newRe |
| 339 | 338 | // which it might have been just moved to this one, as doing this
|
| 340 | 339 | // would result in an infinite stream of WM_DPICHANGED messages.
|
| 341 | 340 | actualNewRect.Inflate(diff / 2);
|
| 342 | - |
|
| 343 | - // However still ensure that the window origin is visible on its
|
|
| 344 | - // display, we don't move to move it out of visible space.
|
|
| 345 | - const wxRect screenRect = wxDisplay(this).GetClientArea();
|
|
| 346 | - if ( actualNewRect.x < screenRect.x )
|
|
| 347 | - actualNewRect.x = screenRect.x;
|
|
| 348 | - if ( actualNewRect.y < screenRect.y )
|
|
| 349 | - actualNewRect.y = screenRect.y;
|
|
| 350 | 341 | }
|
| 351 | 342 | |
| 352 | 343 | SetSize(actualNewRect);
|
| ... | ... | @@ -1237,7 +1237,7 @@ wxRendererXP::GetSplitterParams(const wxWindow * win) |
| 1237 | 1237 | if ( win->HasFlag(wxSP_NO_XP_THEME) )
|
| 1238 | 1238 | return m_rendererNative.GetSplitterParams(win);
|
| 1239 | 1239 | else
|
| 1240 | - return wxSplitterRenderParams(SASH_WIDTH, 0, false);
|
|
| 1240 | + return wxSplitterRenderParams(win->FromDIP(SASH_WIDTH), 0, false);
|
|
| 1241 | 1241 | }
|
| 1242 | 1242 | |
| 1243 | 1243 | void
|
| ... | ... | @@ -1264,13 +1264,14 @@ wxRendererXP::DrawSplitterSash(wxWindow *win, |
| 1264 | 1264 | {
|
| 1265 | 1265 | wxDCPenChanger setPen(dc, *wxTRANSPARENT_PEN);
|
| 1266 | 1266 | wxDCBrushChanger setBrush(dc, wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
|
| 1267 | + const int sashWidth = win->FromDIP(SASH_WIDTH);
|
|
| 1267 | 1268 | if ( orient == wxVERTICAL )
|
| 1268 | 1269 | {
|
| 1269 | - dc.DrawRectangle(position, 0, SASH_WIDTH, size.y);
|
|
| 1270 | + dc.DrawRectangle(position, 0, sashWidth, size.y);
|
|
| 1270 | 1271 | }
|
| 1271 | 1272 | else // wxHORIZONTAL
|
| 1272 | 1273 | {
|
| 1273 | - dc.DrawRectangle(0, position, size.x, SASH_WIDTH);
|
|
| 1274 | + dc.DrawRectangle(0, position, size.x, sashWidth);
|
|
| 1274 | 1275 | }
|
| 1275 | 1276 | |
| 1276 | 1277 | return;
|
| ... | ... | @@ -3857,8 +3857,16 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result, |
| 3857 | 3857 | |
| 3858 | 3858 | if ( drawBorder )
|
| 3859 | 3859 | {
|
| 3860 | - // first ask the widget to paint its non-client area, such as scrollbars, etc.
|
|
| 3861 | - rc.result = MSWDefWindowProc(message, wParam, lParam);
|
|
| 3860 | + // Have the window draw its scrollbars, if any. To avoid flicker,
|
|
| 3861 | + // prevent the border from being drawn by specifing a clipping
|
|
| 3862 | + // region with everything inside the border. For simplicity,
|
|
| 3863 | + // ignore any existing clipping region in the wParam argument.
|
|
| 3864 | + RECT rcClip;
|
|
| 3865 | + ::GetWindowRect(m_hWnd, &rcClip);
|
|
| 3866 | + const auto thickness = MSWGetBorderThickness();
|
|
| 3867 | + ::InflateRect(&rcClip, -thickness, -thickness);
|
|
| 3868 | + AutoHRGN cliprgn = ::CreateRectRgnIndirect(&rcClip);
|
|
| 3869 | + rc.result = MSWDefWindowProc(message, (WXWPARAM)(HRGN)cliprgn, lParam);
|
|
| 3862 | 3870 | processed = true;
|
| 3863 | 3871 | |
| 3864 | 3872 | wxWindowDC dc((wxWindow *)this);
|
| ... | ... | @@ -3868,37 +3876,40 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result, |
| 3868 | 3876 | |
| 3869 | 3877 | // Exclude the client area and any scroll bars.
|
| 3870 | 3878 | RECT rcClient = rcBorder;
|
| 3871 | - const auto thickness = MSWGetBorderThickness();
|
|
| 3872 | 3879 | InflateRect(&rcClient, -thickness, -thickness);
|
| 3873 | 3880 | ::ExcludeClipRect(GetHdcOf(*impl), rcClient.left, rcClient.top,
|
| 3874 | 3881 | rcClient.right, rcClient.bottom);
|
| 3875 | 3882 | |
| 3876 | 3883 | // Draw the theme border and background.
|
| 3877 | - |
|
| 3878 | - // The EDIT class gives a good general purpose border in light mode.
|
|
| 3879 | - // There does not seem to be a dark mode EDIT class that looks good.
|
|
| 3880 | - // The ListView class below looks good in dark mode but was not
|
|
| 3881 | - // available until Windows 11 build 26200. The Button class below
|
|
| 3882 | - // looks OK in dark mode on older Windows.
|
|
| 3883 | - const auto darkClass = wxCheckOsVersion(10, 0, 26200) ?
|
|
| 3884 | - L"DarkMode_DarkTheme::ListView" :
|
|
| 3885 | - L"DarkMode_Explorer::Button";
|
|
| 3886 | - wxUxThemeHandle hTheme(this, L"EDIT", darkClass);
|
|
| 3887 | - |
|
| 3888 | - // The part and state values match for the themes we use.
|
|
| 3889 | - static_assert((int)EP_EDITTEXT == (int)LVP_LISTITEM, "parts differ?");
|
|
| 3890 | - static_assert((int)EP_EDITTEXT == (int)BP_PUSHBUTTON, "parts differ?");
|
|
| 3891 | - static_assert((int)ETS_NORMAL == (int)LISS_NORMAL, "states differ?");
|
|
| 3892 | - static_assert((int)ETS_NORMAL == (int)PBS_NORMAL, "states differ?");
|
|
| 3893 | - |
|
| 3894 | - // Make sure the background is in a proper state
|
|
| 3895 | - if (::IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
|
|
| 3884 | + if ( wxMSWDarkMode::IsActive() )
|
|
| 3885 | + {
|
|
| 3886 | + // There does not seem to be a theme class that draws a good
|
|
| 3887 | + // border on all supported versions of Windows. Manually draw a
|
|
| 3888 | + // 1-pixel thick border. Use the observed colour of the simple
|
|
| 3889 | + // border, WS_BORDER.
|
|
| 3890 | + AutoHBRUSH brushBorder(0x646464);
|
|
| 3891 | + ::FrameRect(GetHdcOf(*impl), &rcBorder, brushBorder);
|
|
| 3892 | + // Draw the background with consecutively smaller 1-pixel thick
|
|
| 3893 | + // rectangles.
|
|
| 3894 | + AutoHBRUSH brushBg(GetBackgroundColour().GetPixel());
|
|
| 3895 | + for (int count = 1; count < thickness; count++)
|
|
| 3896 | + {
|
|
| 3897 | + ::InflateRect(&rcBorder, -1, -1);
|
|
| 3898 | + ::FrameRect(GetHdcOf(*impl), &rcBorder, brushBg);
|
|
| 3899 | + }
|
|
| 3900 | + }
|
|
| 3901 | + else
|
|
| 3896 | 3902 | {
|
| 3897 | - ::DrawThemeParentBackground(GetHwnd(), GetHdcOf(*impl), &rcBorder);
|
|
| 3903 | + // The EDIT class gives a good general purpose border in light mode.
|
|
| 3904 | + wxUxThemeHandle hTheme(this, L"EDIT");
|
|
| 3905 | + // Make sure the background is in a proper state
|
|
| 3906 | + if (::IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
|
|
| 3907 | + {
|
|
| 3908 | + ::DrawThemeParentBackground(GetHwnd(), GetHdcOf(*impl), &rcBorder);
|
|
| 3909 | + }
|
|
| 3910 | + // Draw the border
|
|
| 3911 | + hTheme.DrawBackground(GetHdcOf(*impl), rcBorder, EP_EDITTEXT, ETS_NORMAL);
|
|
| 3898 | 3912 | }
|
| 3899 | - |
|
| 3900 | - // Draw the border
|
|
| 3901 | - hTheme.DrawBackground(GetHdcOf(*impl), rcBorder, EP_EDITTEXT, ETS_NORMAL);
|
|
| 3902 | 3913 | }
|
| 3903 | 3914 | }
|
| 3904 | 3915 | break;
|
| ... | ... | @@ -66,6 +66,19 @@ |
| 66 | 66 | }
|
| 67 | 67 | }
|
| 68 | 68 | |
| 69 | +- (void) setBezelStyle: (NSBezelStyle) s
|
|
| 70 | +{
|
|
| 71 | + [super setBezelStyle:s];
|
|
| 72 | + |
|
| 73 | + // Setting the bezel style may change the layout insets, so the cache
|
|
| 74 | + // needs to be invalidated to avoid incorrect layout.
|
|
| 75 | + // Done here so it's handled for both internal wx usage and application
|
|
| 76 | + // code when accessed with `wxWindow::GetHandle()`
|
|
| 77 | + auto *impl{wxWidgetImpl::FindFromWXWidget(self)};
|
|
| 78 | + if (impl)
|
|
| 79 | + impl->InvalidateLayoutInset();
|
|
| 80 | +}
|
|
| 81 | + |
|
| 69 | 82 | - (void) setTrackingTag: (NSTrackingRectTag)tag
|
| 70 | 83 | {
|
| 71 | 84 | rectTag = tag;
|
| ... | ... | @@ -946,7 +946,8 @@ void wxWindowMac::MacInvalidateBorders() |
| 946 | 946 | wxRect topupdate( tx-outerBorder, ty-outerBorder, tw + 2 * outerBorder, outerBorder );
|
| 947 | 947 | wxRect bottomupdate( tx-outerBorder, ty + th, tw + 2 * outerBorder, outerBorder );
|
| 948 | 948 | |
| 949 | - if (GetParent()) {
|
|
| 949 | + if (GetParent())
|
|
| 950 | + {
|
|
| 950 | 951 | GetParent()->GetPeer()->SetNeedsDisplay(&leftupdate);
|
| 951 | 952 | GetParent()->GetPeer()->SetNeedsDisplay(&rightupdate);
|
| 952 | 953 | GetParent()->GetPeer()->SetNeedsDisplay(&topupdate);
|
| ... | ... | @@ -2328,22 +2329,32 @@ wxMacBorderSize wxWindowMac::MacGetBorderSize() const |
| 2328 | 2329 | return border;
|
| 2329 | 2330 | }
|
| 2330 | 2331 | |
| 2331 | -long wxWindowMac::MacGetLeftBorderSize() const {
|
|
| 2332 | +long wxWindowMac::MacGetLeftBorderSize() const
|
|
| 2333 | +{
|
|
| 2332 | 2334 | return MacGetBorderSize().left;
|
| 2333 | 2335 | }
|
| 2334 | 2336 | |
| 2335 | -long wxWindowMac::MacGetRightBorderSize() const {
|
|
| 2337 | +long wxWindowMac::MacGetRightBorderSize() const
|
|
| 2338 | +{
|
|
| 2336 | 2339 | return MacGetBorderSize().right;
|
| 2337 | 2340 | }
|
| 2338 | 2341 | |
| 2339 | -long wxWindowMac::MacGetTopBorderSize() const {
|
|
| 2342 | +long wxWindowMac::MacGetTopBorderSize() const
|
|
| 2343 | +{
|
|
| 2340 | 2344 | return MacGetBorderSize().top;
|
| 2341 | 2345 | }
|
| 2342 | 2346 | |
| 2343 | -long wxWindowMac::MacGetBottomBorderSize() const {
|
|
| 2347 | +long wxWindowMac::MacGetBottomBorderSize() const
|
|
| 2348 | +{
|
|
| 2344 | 2349 | return MacGetBorderSize().bottom;
|
| 2345 | 2350 | }
|
| 2346 | 2351 | |
| 2352 | +void wxWindowMac::MacInvalidateInsetCache() const
|
|
| 2353 | +{
|
|
| 2354 | + if ( GetPeer() )
|
|
| 2355 | + GetPeer()->InvalidateLayoutInset();
|
|
| 2356 | +}
|
|
| 2357 | + |
|
| 2347 | 2358 | long wxWindowMac::MacRemoveBordersFromStyle( long style )
|
| 2348 | 2359 | {
|
| 2349 | 2360 | return style & ~wxBORDER_MASK ;
|
| 1 | +; sample wxFileConfig seed
|
|
| 2 | +[group1]
|
|
| 3 | +key1=value1
|
|
| 4 | +key2=hello\tworld
|
|
| 5 | +!immutable=1
|
|
| 6 | + |
|
| 7 | +[group1/subgroup]
|
|
| 8 | +nested=42
|
|
| 9 | +path=/usr/local/bin |
| 1 | +///////////////////////////////////////////////////////////////////////////////
|
|
| 2 | +// Name: tests/fuzz/fileconf.cpp
|
|
| 3 | +// Purpose: wxFileConfig parsing code fuzzing test
|
|
| 4 | +// Author: Arthur Chan
|
|
| 5 | +// Created: 2026-06-15
|
|
| 6 | +// Copyright: (c) 2026 Arthur Chan
|
|
| 7 | +///////////////////////////////////////////////////////////////////////////////
|
|
| 8 | + |
|
| 9 | +#include "wx/log.h"
|
|
| 10 | +#include "wx/mstream.h"
|
|
| 11 | +#include "wx/fileconf.h"
|
|
| 12 | + |
|
| 13 | +#if wxDEBUG_LEVEL
|
|
| 14 | + |
|
| 15 | +static void exitAssertHandler(const wxString& file,
|
|
| 16 | + int line,
|
|
| 17 | + const wxString& func,
|
|
| 18 | + const wxString& cond,
|
|
| 19 | + const wxString& msg);
|
|
| 20 | + |
|
| 21 | +static volatile wxAssertHandler_t
|
|
| 22 | + origAssertHandler = wxSetAssertHandler(exitAssertHandler);
|
|
| 23 | + |
|
| 24 | +static void exitAssertHandler(const wxString& file,
|
|
| 25 | + int line,
|
|
| 26 | + const wxString& func,
|
|
| 27 | + const wxString& cond,
|
|
| 28 | + const wxString& msg)
|
|
| 29 | +{
|
|
| 30 | + origAssertHandler(file, line, func, cond, msg);
|
|
| 31 | + |
|
| 32 | + exit(1);
|
|
| 33 | +}
|
|
| 34 | + |
|
| 35 | +#endif // wxDEBUG_LEVEL
|
|
| 36 | + |
|
| 37 | +extern "C" int LLVMFuzzerTestOneInput(const wxUint8 *data, size_t size)
|
|
| 38 | +{
|
|
| 39 | + wxLogNull noLog;
|
|
| 40 | + |
|
| 41 | + wxMemoryInputStream mis(data, size);
|
|
| 42 | + // The wxInputStream ctor reads the whole stream and runs the INI parser.
|
|
| 43 | + wxFileConfig config(mis);
|
|
| 44 | + |
|
| 45 | + // Walk the parsed entries and groups to exercise the read-back paths.
|
|
| 46 | + wxString name;
|
|
| 47 | + long index;
|
|
| 48 | + for ( bool more = config.GetFirstEntry(name, index);
|
|
| 49 | + more;
|
|
| 50 | + more = config.GetNextEntry(name, index) ) {
|
|
| 51 | + wxString value;
|
|
| 52 | + config.Read(name, &value);
|
|
| 53 | + }
|
|
| 54 | + |
|
| 55 | + for ( bool more = config.GetFirstGroup(name, index);
|
|
| 56 | + more;
|
|
| 57 | + more = config.GetNextGroup(name, index) ) {
|
|
| 58 | + }
|
|
| 59 | + |
|
| 60 | + return 0;
|
|
| 61 | +} |
| 1 | +[libfuzzer]
|
|
| 2 | +max_len = 65536 |
| ... | ... | @@ -12,6 +12,11 @@ $CXX $CXXFLAGS -o $OUT/tar tests/fuzz/tar.cpp \ |
| 12 | 12 | $LIB_FUZZING_ENGINE `./wx-config --cxxflags --libs base`
|
| 13 | 13 | cp tests/fuzz/tar.options $OUT/
|
| 14 | 14 | |
| 15 | +$CXX $CXXFLAGS -o $OUT/fileconf tests/fuzz/fileconf.cpp \
|
|
| 16 | + $LIB_FUZZING_ENGINE `./wx-config --cxxflags --libs base`
|
|
| 17 | +cp tests/fuzz/fileconf.options $OUT/
|
|
| 18 | + |
|
| 15 | 19 | # and copy their corpora
|
| 16 | 20 | zip -j $OUT/zip_seed_corpus.zip tests/fuzz/corpus/zip/*
|
| 17 | 21 | zip -j $OUT/tar_seed_corpus.zip tests/fuzz/corpus/tar/*
|
| 22 | +zip -j $OUT/fileconf_seed_corpus.zip tests/fuzz/corpus/fileconf/* |
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help