Repository navigation
Desktop: UI trait - #5071
Desktop: UI trait#5071timon-schelling wants to merge 2 commits into
Conversation
…embedded resources crate under it
|
This PR's title needs revising to follow the project's conventions:
Suggested titles: Editing the title reviews it again. |
There was a problem hiding this comment.
2 issues found across 22 files
Confidence score: 4/5
UiBackendindesktop/src/ui.rsstill exposes CEF types, so other backends must depend on CEF. MoveInputEventandCursorinto the desktop layer.- The PR title is not an imperative command and lacks a subsystem prefix. Use a title like “Desktop: Add UI trait”.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="desktop/src/ui.rs">
<violation number="1" location="desktop/src/ui.rs:8">
P2: Custom agent: **PR title enforcement**
The title “Desktop UI trait” is a noun phrase, not an imperative command. Use the subsystem prefix and an action, such as “Desktop: Add UI trait”.</violation>
<violation number="2" location="desktop/src/ui.rs:19">
P2: `UiCommand::Input` and `UiEvent::Cursor` carry `InputEvent` and `Cursor` from the CEF crate, so the backend-agnostic `UiBackend` still forces every backend to use CEF's types. Move these types into the desktop layer, or accept that the trait is CEF-specific.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| pub(crate) type UiError = Box<dyn std::error::Error + Send + Sync>; | ||
|
|
||
| pub(crate) enum UiCommand { | ||
| Input(InputEvent), |
There was a problem hiding this comment.
P2: UiCommand::Input and UiEvent::Cursor carry InputEvent and Cursor from the CEF crate, so the backend-agnostic UiBackend still forces every backend to use CEF's types. Move these types into the desktop layer, or accept that the trait is CEF-specific.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/src/ui.rs, line 19:
<comment>`UiCommand::Input` and `UiEvent::Cursor` carry `InputEvent` and `Cursor` from the CEF crate, so the backend-agnostic `UiBackend` still forces every backend to use CEF's types. Move these types into the desktop layer, or accept that the trait is CEF-specific.</comment>
<file context>
@@ -0,0 +1,32 @@
+pub(crate) type UiError = Box<dyn std::error::Error + Send + Sync>;
+
+pub(crate) enum UiCommand {
+ Input(InputEvent),
+ Resized { width: u32, height: u32 },
+ ScaleChanged(f64),
</file context>
There was a problem hiding this comment.
Should be winit types?
There was a problem hiding this comment.
@timon-schelling Yes — that works, and it's arguably the cleaner resolution. winit already owns the window/input layer in the desktop app, so the trait speaking winit types means no CEF types leak through the abstraction and you don't have to invent parallel input/cursor types in desktop/src/ui.rs.
The one consequence to keep in mind: the conversions move into the backend. The CEF implementation would map winit input events onto its InputEventBuilder (which is presumably where the multi-click/pinch/scroll constants in the re-export come from) and map CEF cursor changes back to winit::window::CursorIcon for the app to apply. Both are small conversions and they belong in desktop/src/ui/cef.rs, so the layering actually improves — app.rs stops dealing with CEF input specifics and just forwards winit events.
My original comment wasn't tied to the exact fix; the point was that UiCommand::Input(InputEvent) and UiEvent::Cursor(Cursor) currently pin the trait to the CEF crate. Using winit types resolves that just as well as moving the types up, and I'd say it's the better option given winit is already a core dependency here.
Tip: get faster answers by chatting with cubic’s review copilot in the review UI
| @@ -0,0 +1,32 @@ | |||
| use crate::preferences::DesktopPreferences; | |||
There was a problem hiding this comment.
P2: Custom agent: PR title enforcement
The title “Desktop UI trait” is a noun phrase, not an imperative command. Use the subsystem prefix and an action, such as “Desktop: Add UI trait”.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/src/ui.rs, line 8:
<comment>The title “Desktop UI trait” is a noun phrase, not an imperative command. Use the subsystem prefix and an action, such as “Desktop: Add UI trait”.</comment>
<file context>
@@ -0,0 +1,32 @@
+mod cef;
+pub(crate) use cef::*;
+
+pub(crate) trait UiBackend: Sized {
+ fn start(preferences: &DesktopPreferences, wgpu_context: &WgpuContext) -> Result<Self, UiError>;
+ fn send(&self, command: UiCommand);
</file context>
No description provided.