macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.47k stars 680 forks source link

Fix misc MacVim warnings #1303

Closed ychin closed 1 year ago

ychin commented 1 year ago

MacVim currently has a lot of warnings, especially when compiling locally with a higher deployment target than 10.9 (which the CI uses). This PR fixes most of them to help reduce on the spam on the road to being able to turn on warnings as errors. Most of the warnings are deprecation warnings, and since we still support 10.9, the work needs to make sure to maintain compatibility with older versions of macOS and also code compatibility. This PR would also help make the build output be a lot less spammy once we move the main binary to build against 10.13 once Xcode 14.1 comes out and links against macOS 13.0 SDK (which only supports down to 10.13) instead of 12.0 SDK that we use now (which supports down to 10.9).

The PR is broken into a lot of smaller commits to make the work easier to follow and easier to revert if something goes wrong.

After this PR, there are a few items left:


commit c41e05baac96c0e26d8a593dd477fe4c292be115

Fix warning: zoomAll / makeWindowsPerform

Fix the deprecation warning on makeWindowsPerform. While we could simply replace it with the more updated form, one thing I noticed was that zoomAll: simply wasn't getting called. It appears that NSApplication has a native handler of it and would call zoom: on each window by itself, and as such there's no point in making our own zoomAll: method at all. I couldn't find out if this was the case in old macOS versions, and so just ifdef out the zoomAll function in newer versions of macOS which also fixes the deprecation warning.


commit dc1ad365ded0112ffd05e48aa3b192bf7bdb86dc

Fix NSFilenamesPboardType -> NSPasteboardTypeFileURL deprecation warning

This is a little tricky because it's not a simple map. With NSPasteboardTypeFileURL, we have to use readObjectsForClasses:options: to obtain a list of URL objects and then turn them into file path strings. Previously you could just get a list of file names directly with NSFilenamesPboardType. Also, this new enum was only defined in 10.13, so we have to maintain parallel paths to support both types of getting the list of file names from the pasteboard. Also refactored the code that use this to a function in Miscllaneous.m to avoid the headache. Note that the old NSFilenamesPboardType method still works today, so this is mostly to clean up old code and deprecation warnings.

Also made the "new file here" plugin accept both the old and new pasteboard types, just in case.


commit 94564fdc40d8008ac619e0d25490e8b7e93df911

Fix NSWindowStyleMaskTexturedBackground deprecation warning

Seems like the flag has been completely useless since macOS 11. We previously kept it around despite its deprecation status because it seems to make the title bar not show a black line, but since macOS 11 it has been showing that anyway, so remove usage of it. Also, clean up misc pre-Lion-era code and block them behind ifdef. Can remove those code in future if we want to clean up.


commit 2faa2855c475bd5673581cdc1d08af32eadf80dc

Fix MMTouchBarButton warning when calling "desc" function

Refactor the code so that the relevant class is in header and can be called. Also fix different places where I call NSClassFromString to use @available check instead, as I believe that's the recommended method and more efficient as well (due to it being native to the compiler).


commit cd325778997b794cecd643343129375e6de11661

Fix MacVim warnings: enum renames, graphicsPort, setcmdheight

The list of warnings fixed:


commit 2e67bf421a3d21af99ce3b73e98baa285244805b

Fix warnings due to usages of the deprecated NSStringPboardType

This turned out more complicated than I thoguht because the newer NSPasteboardTypeString (public.utf8-plain-text) is actually a different value from NSStringPboardType (NSStringPboardType), so it could potentially lead to behavior differences. The right-click Services menu in particular seems to not behave in the expected way, because writeSelectionToPasteboard: (called by the OS) is passing NSStringPboardType to us, even though we specifically only accept NSPasteboardTypeString in validRequestorForSendType:returnType:. Just fixed the code to ignore the passed in type.

Also update the Info.plist file to accept the public.utf8-plain-text for this service as well.


commit 2a6dea1b37cc64fc5b38a7a6e9f21ff7930f1a8a

Fix build phase dependency warnings

Make sure to specify the build phase (e.g. building locale files) input/output dependencies so they can be properly skipped during incremental builds if the input files haven't changed. Previously some of them were set to use dependency tracking, but with no input/output specified, therefore triggering a warning as Xcode had to run them every build.


commit e9e129017c167cda74669b901bbe9e847a1857f0

Fix MacVim compiler warnings (for Vim-process files)

Fix NSStringPboardType and NSFindPboard deprecation warnings.

Also, fix up an awkward use of colors in that we are loading the ARGB values of system colors using device calibrated space but CoreText renderer uses sRGB instead. Just load it as sRGB.

This should fix up all Vim-side compiler warnings except for the usage of NSConnection, which is a much larger task to tackle as we need to move to XPC. Note that the set of warnings differ depending on whether we have MACOSX_DEPLOYMENT_TARGET=10.9 set or not as Xcode will recommend different changes. With that set we currently do not throw any warnings on the Vim process side (since NSConnection was not deprecated at 10.9 yet).