Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MrJul
Copy link
Member

@MrJul MrJul commented Dec 21, 2024

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 empty FallBackScreen instead of null in case of failure. This code path is called from ScreensBase<TKey,TScreen>.EnsureScreens(), where null is definitely not expected, as that would insert a null screen into AllScreens, causing NREs:

var newScreen = CreateScreenFromKey(newScreenKey);

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0054059-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

}
}

return null;
return new FallBackScreen(default, _x11);
Copy link
Member

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)
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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

Copy link
Member

@kekekeks kekekeks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants