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

Add shell.background-color.rgba to prefs #30488

Merged
merged 3 commits into from Oct 4, 2023
Merged

Conversation

wusyong
Copy link
Contributor

@wusyong wusyong commented Oct 4, 2023

With surfman#260, it's possible for all platforms to display transparent background now. This could let users to make more native-like interface as they wish. Right now, servo will still make viewport background white. And I hope it can add a config to toggle this to transparent background.

Based on feedbacks on zulip, this PR adds shell.background-color.rgba to prefs with the resource file prefs.json set to [1.0, 1.0, 1.0, 1.0] by default.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes doesn't fix any github issue.
  • These changes do not require tests because this is only a background for shell's viewport.

@mrobinson
Copy link
Member

I really think should allow setting a background color (which can be transparent) as that is what all other WebView APIs. do.

@wusyong
Copy link
Contributor Author

wusyong commented Oct 4, 2023

Alright, how about changing it to background_color: { r: f64, g: f64, b: f64, a: f64} (as I didn't see the option to set it as f32 in prefs).

@mrobinson
Copy link
Member

Alright, how about changing it to background_color: { r: f64, g: f64, b: f64, a: f64} (as I didn't see the option to set it as f32 in prefs).

That seems sensible. Thanks.

Comment on lines 113 to 116
"shell.background-color.alpha": 1.0,
"shell.background-color.blue": 1.0,
"shell.background-color.green": 1.0,
"shell.background-color.red": 1.0,
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to represent this as an array like:

"shell.background-color.red": [1.0, 1.0, 1.0, 1.0],

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'll need to add new variant like serde's Value::Array to PrefValue. I can try to add this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mrobinson I added new variant PrefValue and make sure other crates can handle it well.
It probably could add a macro to handle From trait between array and this vraint.
But I suppose it's better to wait until there's more configs that require array.
So we can implement more ergonomic one.

@wusyong wusyong changed the title Add shell.transparent-background.enabled to prefs Add shell.background-color.rgba to prefs Oct 4, 2023
@mrobinson
Copy link
Member

Nice.

@mrobinson mrobinson added this pull request to the merge queue Oct 4, 2023
Merged via the queue into servo:master with commit 38a325c Oct 4, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants