-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Nullable annotations for X11 #17814
base: master
Are you sure you want to change the base?
Nullable annotations for X11 #17814
Conversation
You can test this PR using the following package version. |
} | ||
} | ||
|
||
return null; | ||
return new FallBackScreen(default, _x11); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's not a valid behavior to return a fake screen for invalid parameter here. It's a problem of the calling code to handle a missing screen properly.
{ | ||
var data = new DataObject(); | ||
data.Set(DataFormats.Text, text); | ||
|
||
if (text is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check how we've previously handled this scenario, I think we were responding with an empty string to selection query
new X11PlatformOptions())); | ||
{ | ||
var options = AvaloniaLocator.Current.GetService<X11PlatformOptions>() ?? new X11PlatformOptions(); | ||
_ = new AvaloniaX11Platform(options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a static Initialize method? Relying on ctor side effects outside of the class itself seems a bit out of place
@@ -309,11 +304,9 @@ private void OnDeviceEvent(IXI2Client client, ParsedDeviceEvent ev) | |||
{ | |||
var pixelPoint = new PixelPoint((int)ev.RootPosition.X, (int)ev.RootPosition.Y); | |||
var screen = _platform.Screens.ScreenFromPoint(pixelPoint); | |||
var screenBoundsFromPoint = screen?.Bounds; | |||
Debug.Assert(screenBoundsFromPoint != null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why is this assert here, but maybe keep it? Sounds useful for debugging the particular condition it's checking for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general
What does the pull request do?
This PR enables and fixes nullable annotations for the Avalonia.X11 project.
Remarks
While most of the changes are straightforward,
X11Screens.Randr15ScreensImpl.CreateScreenFromKey()
has been changed to return an emptyFallBackScreen
instead ofnull
in case of failure. This code path is called fromScreensBase<TKey,TScreen>.EnsureScreens()
, where null is definitely not expected, as that would insert a null screen intoAllScreens
, causing NREs:Avalonia/src/Avalonia.Controls/Platform/IScreenImpl.cs
Line 164 in 33bd02c