Nothing Special   »   [go: up one dir, main page]

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

overlay: make overlay's style and colors configurable #1702

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

tokyo4j
Copy link
Contributor
@tokyo4j tokyo4j commented Apr 11, 2024

This PR adds following theme settings:

  • snapping-preview.region.area.color
  • snapping-preview.edge.area.color
  • snapping-preview.region.rect-type (Auto|Area|Outlines)
  • snapping-preview.edge.rect-type (Auto|Area|Outlines)

I named the theme entry rect-type to make labwc-theme.5.scd easy to follow, but maybe it should be just type.

I restructured struct overlay to allow independent styles for region/edge snapping overlay.
I also added inactivate_overlay() as a refactoring.

In the future, maybe we can also make the colors of outlines configurable like:
snapping-preview.region.outlines.colors: #ffffff,#000000,#ffffff
In that case, I think the colors of OSD preview should also be configurable.

@Consolatis Consolatis added this to the 0.7.2 milestone Apr 11, 2024
@johanmalm
Copy link
Collaborator

Thanks. Looks good in general.

* `snapping-preview.region.area.color`
* `snapping-preview.edge.area.color`

For consistency with the rest of the themerc file I'd suggest bg instead of area.

snapping-preview.bg.color
snapping-preview.border.color

* `snapping-preview.region.rect-type` (`Auto|Area|Outlines`)
* `snapping-preview.edge.rect-type` (`Auto|Area|Outlines`)

I named the theme entry rect-type to make labwc-theme.5.scd easy to follow, but maybe it should be just type.

I'm fine with rect-type. If you want to consider something else, we could go with fill (yes|no|auto). Fill is consistent with cairo-speak (fill/stroke).

For reference, rc.xml uses <resize><drawContents> - although that feels slightly different.

In the future, maybe we can also make the colors of outlines configurable like: snapping-preview.region.outlines.colors: #ffffff,#000000,#ffffff In that case, I think the colors of OSD preview should also be configurable.

Good idea. Agree. Suggest calling it border rather than outlines for consistency.

@tokyo4j tokyo4j force-pushed the overlay-theme branch 2 times, most recently from 0516a19 to 214d650 Compare April 12, 2024 23:50
@tokyo4j
Copy link
Contributor Author
tokyo4j commented Apr 13, 2024

I implemented @johanmalm's suggestions, as they make sense to me. fill sounds straightforward rather than defining rect-type type, as long as we only support wlr_scene_rect and multi_rect. If we may support another rectangle style in the future, that should be reverted.

I also implemented snapping-preview.[region|edge].border.color, whose possible values are two colors separated by a comma like #ffffff,#000000 or auto keyword which falls back to OSD's background/text colors.

I haven't made OSD preview color configurable yet as it's not in the scope of this PR, but it should be an easy fix.

This change brings a subtle behavioral change that region overlay is hidden
immediately when the timer for edge overlay starts.
@tokyo4j tokyo4j force-pushed the overlay-theme branch 2 times, most recently from d903bee to 75e099a Compare April 13, 2024 18:34
@tokyo4j
Copy link
Contributor Author
tokyo4j commented Apr 13, 2024

I reorganized my commits and made some changes in snapping-preview.[region|edge].border.color.

snapping-preview.[region|edge].border.color now allows specifying 1-3 colors, and only single line rectangle is drawn when only one color is specified.
Its default value is now set to #ffffff,#000000,#ffffff rather than falling back to OSD's colors.

I also added snapping-preview.[region|edge].border.width.

@tokyo4j tokyo4j marked this pull request as ready for review April 13, 2024 19:01
docs/labwc-theme.5.scd Outdated Show resolved Hide resolved
docs/labwc-theme.5.scd Outdated Show resolved Hide resolved
docs/labwc-theme.5.scd Outdated Show resolved Hide resolved
docs/themerc Outdated Show resolved Hide resolved
@tokyo4j
Copy link
Contributor Author
tokyo4j commented Apr 14, 2024

Changes are:

  • Adding a/an/the and minor fixes in the documentation
  • Letting snapping-preview.*.border.width and snapping-preview.*.border.color fall back to OSD theme and fixing its documentation

@tokyo4j tokyo4j changed the title overlay: make overlay's style and filled color configurable overlay: make overlay's style and colors configurable Apr 15, 2024
@tokyo4j
Copy link
Contributor Author
tokyo4j commented Apr 15, 2024

I'm thinking of forcing outlines to be rendered when WLR_RENDERER=pixman.
I tried snapping-preview.*.fill: yes with WLR_RENDERER=pixman on my Ryzen 3 4300U laptop, and found it lags so badly (300ms~600ms in my sense).

So possible change would be like:

  • Possible values in snapping-preview.*.fill are just yes|no
  • The default value for snapping-preview.*.fill is yes
  • If the current rendering backend is pixman, outlines are always chosen

EDIT:
I implemented it as a fixup commit.

@Consolatis
Copy link
Member
Consolatis commented Apr 15, 2024

Had a look through the diff again and didn't see anything obvious.

  • tested Reconfigure while a preview was shown: it just hides and everything works as expected thereafter
  • tested xcalc &; sleep 5; kill $(pidof xcalc) and making xcalc show a preview: works as expected
  • tested setting border width
  • tested setting .fill to no on the gles2 renderer
  • tested colors for border and area

Only slight nitpick I can think of:
The snapping-preview. theme setting could be replaced by snapping.preview. (we had issues in the past where the user supplied - character used was actually some weird locale dependent unicode character and not the ASCII version thus we failed to parse it correctly).

Other than that this looks great!
After addressing the snapping-preview vs snapping.preview point, do you want to squash yourself or should I do so when merging?

@tokyo4j
Copy link
Contributor Author
tokyo4j commented Apr 15, 2024

Thank you!

I'm fine with snapping.preview.

Honestly, I don't think the unicode issue (#1098?) can be a strong reason to choose it over snapping-preview, but snapping.preview looks more natural as there's <snapping><preview> in rc.xml so I like it better.

After addressing the snapping-preview vs snapping.preview point, do you want to squash yourself or should I do so when merging?

I'll do it myself.

@Consolatis
Copy link
Member

The last Last commit contains snapping-overlay in the commit body and the subject is 75 characters wide, suggest something like overlay: add theme settings for colors and border width instead. The commit body of the 2nd to last commit is slightly outdated.

@tokyo4j
Copy link
Contributor Author
tokyo4j commented Apr 15, 2024

Thank you! I've learned so much from you about how to contribute to OSS!

This settings allows user to choose whether to draw a filled rectangle
or an outlined rectangle as the preview for window snapping.
adds theme settings like:
snapping.overlay.[region|edge].bg.color: #8080b380
snapping.overlay.[region|edge].border.color: #ffffff,#000000,#ffffff
snapping.overlay.[region|edge].border.width: 1
@Consolatis
Copy link
Member

Well, thank you for your great code and responsiveness to feedback. Really appreciated :)

I think the whole snapping overlay implementation is really nice out of the box but still flexible in case a user wants to change the behavior.

@Consolatis Consolatis merged commit 3b13f4c into labwc:master Apr 15, 2024
5 checks passed
@tokyo4j tokyo4j deleted the overlay-theme branch April 15, 2024 10:39
@tokyo4j
Copy link
Contributor Author
tokyo4j commented Apr 15, 2024

I'll also make the outline colors of window-switcher preview configurable in a follow-up PR.
It'll more likely to be worth changing from the default as its default colors are similar to that of window borders, which makes a bit harder to distinguish currently previewed window from others.

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.

3 participants