Skip to content

monitor: refactor MonitorHandle to store dyn object#3927

Merged
kchibisov merged 2 commits intomasterfrom
kchibisov/dyn-monitor-handle
Mar 7, 2025
Merged

monitor: refactor MonitorHandle to store dyn object#3927
kchibisov merged 2 commits intomasterfrom
kchibisov/dyn-monitor-handle

Conversation

@kchibisov
Copy link
Copy Markdown
Member

@kchibisov kchibisov commented Sep 21, 2024

This also alters VideoMode to be a regular object and not reference the MonitorHandle, since it's a static data.

Given that VideoMode set may change during runtime keeping the reference as a some sort of validity may not be idea and propagating errors when changing video mode could be more reliable.

--

I'm not sure that I like how the monitor stuff looks, but I don't have a better idea. Ideally we want to have some sort of MonitorId which is more reliable in representing and split the MonitorHandle into Id and a way to get the data for the monitor, but I think I'd rather leave it for the future.

The native_id thing I've moved is already present on all the platforms, so I'd really see why not and usually platforms have some way to address the monitors and backends may build such addressing themselves.

It could make sense to change native_id() -> u64 to MonitorId(u64).

Part of #3433.

@kchibisov kchibisov force-pushed the kchibisov/dyn-monitor-handle branch from 42cbaa6 to c6e43dc Compare November 14, 2024 16:14
@kchibisov kchibisov marked this pull request as ready for review November 14, 2024 16:15
@kchibisov kchibisov requested review from notgull and removed request for notgull November 14, 2024 16:15
@kchibisov kchibisov force-pushed the kchibisov/dyn-monitor-handle branch 3 times, most recently from f2b84f4 to 84c9ae6 Compare November 14, 2024 17:08
@kchibisov
Copy link
Copy Markdown
Member Author

kchibisov commented Nov 14, 2024

I've removed docsrs build for platform for now, since types are simply not present in all backends, so build fails), and platform module will be soon gone anyway.

@kchibisov kchibisov force-pushed the kchibisov/dyn-monitor-handle branch 5 times, most recently from 9486937 to 4c94b55 Compare November 14, 2024 17:48
@madsmtm madsmtm added the C - nominated Nominated for discussion in the next meeting label Dec 2, 2024
Copy link
Copy Markdown
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

Procedurally, I would prefer if we did the "refactor VideoModeHandle to VideoMode with plain data" in a separate PR first, that would make this PR easier to thoroughly review - I just cannot deal with 49 changed files at once, sorry ;). (For my own part I've been dreading reviewing this for that reason, I suspect the other maintainers feel the same).

Also, I feel it's undesirable to remove the no-op monitors, at least at this point / in this PR? I think that would allow you to keep the docsrs stuff in platform?

If you're burned out on it, I can try to do it in a few days? I.e. splitting this PR into effectively three parts:

  • VideoModeHandle -> VideoMode
  • MonitorHandle -> trait
  • Remove no-op monitor handles

@kchibisov
Copy link
Copy Markdown
Member Author

  • I just cannot deal with 49 changed files at once, sorry ;

You need to look only into the top-level and the ones for your backend, and given that both are in the same file, you'll have 2 PRs with the 49 files changed, just twice or more.

If you feel like splitting then go ahead, I won't block on that, it's just way more work and by the time you've done it you'll review the PR. Probably not that bad in this context.

@kchibisov
Copy link
Copy Markdown
Member Author

Also, I feel it's undesirable to remove the no-op monitors, at least at this point / in this PR? I think that would allow you to keep the docsrs stuff in platform?

That's true, I guess, the issue is that certain types don't really exist sometimes and we still try to build, so I've removed since we generally want to remove platform, so point in keeping it doesn't bring any benefit in my opinion and just creates more work, which is not great. Like once the split is done, you won't have cfg at all.

@kchibisov
Copy link
Copy Markdown
Member Author

I've extracted video mode from it here #4060

@kchibisov kchibisov force-pushed the kchibisov/dyn-monitor-handle branch 2 times, most recently from 1436e3e to 2644af5 Compare February 8, 2025 11:31
@kchibisov kchibisov requested a review from madsmtm February 8, 2025 11:33
@kchibisov
Copy link
Copy Markdown
Member Author

Separated docsrs and monitor handle parts.

Copy link
Copy Markdown
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

I've opened #4138 to ensure that we don't forget to do something about the docs.rs situation before v0.31.

Thanks again for doing this, and sorry for the long delay in reviewing it. Have approved, the only real concern here is the u64 (native) vs. u128 (unique) ID comparisons, but that can also be fixed in a follow-up.

@kchibisov kchibisov force-pushed the kchibisov/dyn-monitor-handle branch 4 times, most recently from 551f496 to d55cc22 Compare March 3, 2025 12:06
@kchibisov kchibisov requested a review from madsmtm March 3, 2025 12:06
@kchibisov
Copy link
Copy Markdown
Member Author

@madsmtm please ensure the macOS impl, since I'm not sure if rebase was correct, I might have discarded something.

@kchibisov kchibisov force-pushed the kchibisov/dyn-monitor-handle branch from d55cc22 to 8217568 Compare March 3, 2025 12:22
Copy link
Copy Markdown
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

macOS rebase looks good (with comment fixed).

@kchibisov kchibisov force-pushed the kchibisov/dyn-monitor-handle branch from 8217568 to 644999a Compare March 3, 2025 16:34
@kchibisov kchibisov requested a review from madsmtm March 3, 2025 16:34
This also alters `VideoMode` to be a regular object and not reference
the `MonitorHandle`, since it's a static data.

Given that `VideoMode` set may change during runtime keeping the
reference as a some sort of validity may not be idea and propagating
errors when changing video mode could be more reliable.
Due to casts and use of platform specific crates in those modules
it's not really feasible to build docs for them.

After separating crates, thus should become way easier to navigate,
since backends information would be publicly available.
@kchibisov kchibisov force-pushed the kchibisov/dyn-monitor-handle branch from 644999a to 8750c88 Compare March 7, 2025 15:59
@madsmtm madsmtm added S - api Design and usability and removed C - nominated Nominated for discussion in the next meeting labels Mar 7, 2025
@kchibisov kchibisov merged commit b3dcfa1 into master Mar 7, 2025
57 checks passed
@kchibisov kchibisov deleted the kchibisov/dyn-monitor-handle branch March 7, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S - api Design and usability

Development

Successfully merging this pull request may close these issues.

2 participants