FelixKratz / JankyBorders

A lightweight window border system for macOS
GNU General Public License v3.0
1k stars 18 forks source link

"Glowing" borders #32

Closed koekeishiya closed 8 months ago

koekeishiya commented 9 months ago

image

Source: https://www.reddit.com/r/unixporn/comments/w9s22b/hyprland_noble/

image

Source: https://www.reddit.com/r/unixporn/comments/zqyrqi/hyprland_glowy/?rdt=34170

image

(Bright spots are actually animated and moves around the border)

Source: https://www.reddit.com/r/unixporn/comments/17kx85t/hyprland_tokyo_night_nixos/?rdt=55754

--

I think this could look good when customized properly. Probably more useful for the active window than inactive ones. The static effect could likely be implemented by tweaking the border window shadow properties.

FelixKratz commented 9 months ago

Looks good. We could include this in the current configuration syntax as another special color argument e.g:

borders active_color=glow(0xAARRGGBB)

Or something like that.

I am still thinking about moving the drawing logic to a CALayer backed solution for GPU acceleration, where these animations could be included relatively easily, but I am not sure if that is worth the effort.

Maybe we start off with a static glow for now.

FelixKratz commented 9 months ago

I am not sure this can be achieved only by tweaking the window shadow properties, afaik there is no way to change the color of the shadow. I can change positioning density etc. via:

extern CGError SLSSetWindowShadowParameters(int cid, uint32_t wid, float std, float density, int x_offset, int y_offset);

and there are some other properties to be controlled via

extern CGError SLSWindowSetShadowProperties(uint32_t wid, CFDictionaryRef properties);

but I have not seen a way to change the actual shadow color.

koekeishiya commented 9 months ago

How about using https://developer.apple.com/documentation/coregraphics/1455205-cgcontextsetshadowwithcolor?language=objc

FelixKratz commented 9 months ago

I have added a subtle glow effect which can be actived by passing glow(0xAARRGGBB) to a <color> argument.

Bellavene commented 9 months ago

Was trying to install through --HEAD, and borders broke. They render somewhere outside the window. Reinstalled last release and it works ok.

FelixKratz commented 9 months ago

Should be fixed on master.

Bellavene commented 9 months ago

Thank you! I still believe that animation would be more interesting : )

FelixKratz commented 9 months ago

I will at some point explore simple animations on window focus/unfocus, but a permanently moving glow around the border is probably not something I am personally interested in.

If someone wants to give it a go, I will gladly accept a PR.

Bellavene commented 9 months ago

Thanks. Nah, I don't want permanently moving glow neither.

Bellavene commented 3 months ago

An attempt to animate yabai -m signal --add event=window_focused action="yabai-borders-select"

#!/bin/zsh
borders active_color='gradient(top_left=0xaaffa100,bottom_right=0xaaaa0033)' \
        inactive_color='gradient(top_left=0xaa00a100,bottom_right=0x550000aa)' \
        ax_focus=on \
        width=8 \
        order=above \
        background_color=0x00000000 \
        2>/dev/null 1>&2 &
        # style=square \
        # blur_radius=30.0 \
sleep 0.07
borders active_color='glow(0xffff5100)' 2>/dev/null 1>&2 &
sleep 0.07
borders active_color='glow(0xffff5100)' 2>/dev/null 1>&2 &
sleep 0.07
borders active_color='glow(0xffff0000)' 2>/dev/null 1>&2 &
sleep 0.07
borders active_color='glow(0xffff5100)' 2>/dev/null 1>&2 &
sleep 0.07
borders active_color='gradient(top_left=0xffffa100,bottom_right=0xffaa0033)' 2>/dev/null 1>&2 &

I've tried to animate the width, but no luck, there are graphical glitches when you change width so rapidly.