-
-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix misc MacVim warnings #1303
Merged
Merged
Fix misc MacVim warnings #1303
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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).
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.
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.
The list of warnings fixed: - Fix misc AppKit control states enums that got renamed and deprecated. - NSFindPboardType -> NSPasteboardTypeFind deprecation. - Fix usage of deprecated "graphicsPort" API to use CGContext instead. - Use NSFontChanging protocol if it's available. - Move MMCoreTextView's setcmdheight to the correct section in the private implementation category.
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).
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.
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.
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.
ychin
added
the
Non User Facing
Non-user facing change. These issues do no need to show up in release notes.
label
Oct 22, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
-sep-
tool bar items and apparently they haven't been working for a loong time. They will be addressed in a future PR which will introduce toolbar/menu/touch bar changes like SF symbol support.commit c41e05b
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 dc1ad36
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 94564fd
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 2faa285
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 cd32577
Fix MacVim warnings: enum renames, graphicsPort, setcmdheight
The list of warnings fixed:
commit 2e67bf4
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 2a6dea1
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 e9e1290
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).