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

Added support for coloring unfocused windows different. #37

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bsneed
Copy link

@bsneed bsneed commented Jul 20, 2024

  • Added additional value for unfocused_border_color.
  • Added color selection to preferences for unfocused_border_color.
  • Applies the appropriate border color on redraw.
  • Applies the appropriate border color on focus change.

image

Closes #41

@flexagoon
Copy link
Owner

Could you please add a mention of this feature in the readme?

@bsneed
Copy link
Author

bsneed commented Jul 21, 2024

Definitely!

@flexagoon
Copy link
Owner

The manager code was changed in 0c41e83 so there is a conflict now, can you please update your changes? Sorry for the inconvenience

@bsneed
Copy link
Author

bsneed commented Jul 22, 2024

Thanks Pavel! Yeah, I'll push an update this evening when I finish up some other things.

@bsneed
Copy link
Author

bsneed commented Jul 23, 2024

That was a rough merge, haha. I ended up just re-applying the changes.

src/manager/event_handlers.ts Outdated Show resolved Hide resolved
@bsneed
Copy link
Author

bsneed commented Jul 31, 2024

Reminder this is here :D

@flexagoon
Copy link
Owner

Don't worry, I'm remember, I'm just on vacation rn and can't really use my laptop, I'll get to this in a week or so

@@ -385,6 +386,7 @@ function refreshShadow(actor: ExtensionsWindowActor) {
const {border_radius, padding} = getRoundedCornersCfg(win);

updateShadowActorStyle(win, shadow, border_radius, shadowSettings, padding);
refreshRoundedCorners(actor);
Copy link
Owner

Choose a reason for hiding this comment

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

Why are you refreshing rounded corners in refreshShadow? Since this only has to be called when window focus is changed, you should instead change the definition of onFocusChanged to something like this:

export function onFocusChanged(actor: ExtensionsWindowActor) {
  refreshShadow(actor);
  refreshRoundedCorners(actor);
}

It's also possible to only update the border color uniform without recalculating everything else (see implementation of RoundedCornersEffect.update_uniforms for details), but I think that would just add a bunch of unnecessary functions and abstraction level mixing. Though if you think it may be a good option you can still try and see if you like how it feels.

@@ -418,14 +420,19 @@ function refreshRoundedCorners(actor: ExtensionsWindowActor): void {

const windowContentOffset = computeWindowContentsOffset(win);

const focused = win.appears_focused;
const border_color = focused
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
const border_color = focused
const borderColor = focused

The JS convention is to use lowerCamelCase for variable names, GNOME code uses snake_case for some reason so @yilozt probably went with snake case as well to be consistent with it, but I think it's better to just use the JS convention when possible

@@ -442,6 +449,6 @@ function refreshRoundedCorners(actor: ExtensionsWindowActor): void {

/** Refresh rounded corners settings for all windows. */
function refreshAllRoundedCorners() {
global.get_window_actors().forEach(refreshRoundedCorners);
global.get_window_actors().forEach(actor => refreshRoundedCorners(actor));
Copy link
Owner

Choose a reason for hiding this comment

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

I already fixed this in 98096c7, you should rebase on top of the latest commit

@@ -23,6 +23,7 @@ export const General = GObject.registerClass(
'skip_libhandy',
'border_width',
'border_color',
'unfocused_border_color',
Copy link
Owner

Choose a reason for hiding this comment

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

If you're calling this unfocused_border_color it probably makes sense to rename the other one to focused_border_color

@flexagoon
Copy link
Owner

@bsneed could you please update this?

@edgarsilva
Copy link

  • Added additional value for unfocused_border_color.
  • Added color selection to preferences for unfocused_border_color.
  • Applies the appropriate border color on redraw.
  • Applies the appropriate border color on focus change.

image

Closes #41

I was about to ask if something like this existed, this is great 👍🏽

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.

Feature Request: Border only on and/or alternate color for focused window
3 participants