mirror of
https://github.com/FelixKratz/SketchyBar
synced 2025-02-17 04:58:28 +00:00
added background blur option
This commit is contained in:
parent
c4a946ff96
commit
d83c698fb8
6 changed files with 18 additions and 0 deletions
|
@ -13,6 +13,7 @@ Features:
|
||||||
* Create custom events and trigger them externaly
|
* Create custom events and trigger them externaly
|
||||||
* "click" events for the widgets, where a script can be specified to run on a mouse click
|
* "click" events for the widgets, where a script can be specified to run on a mouse click
|
||||||
* Cache the scripts in RAM to reduce I/O operations
|
* Cache the scripts in RAM to reduce I/O operations
|
||||||
|
* Offset the bar from its original location, rounded corners and background blur
|
||||||
* Performance friendly
|
* Performance friendly
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,6 +125,7 @@ where the settings currently are:
|
||||||
* *margin*: the screen padding around the bar itself
|
* *margin*: the screen padding around the bar itself
|
||||||
* *y_offset*: the y-offset in pixels from the default position
|
* *y_offset*: the y-offset in pixels from the default position
|
||||||
* *corner_radius*: the corner radius of the bar itself
|
* *corner_radius*: the corner radius of the bar itself
|
||||||
|
* *blur_radius*: the blur radius to be applied to the background of the bar itself
|
||||||
* *padding_left*: padding on the left before first item
|
* *padding_left*: padding on the left before first item
|
||||||
* *padding_right*: just as padding_right
|
* *padding_right*: just as padding_right
|
||||||
* *bar_color*: the color of the bar itself
|
* *bar_color*: the color of the bar itself
|
||||||
|
|
|
@ -290,6 +290,7 @@ struct bar *bar_create(uint32_t did) {
|
||||||
SLSSetWindowTags(g_connection, bar->id, set_tags, 64);
|
SLSSetWindowTags(g_connection, bar->id, set_tags, 64);
|
||||||
SLSClearWindowTags(g_connection, bar->id, clear_tags, 64);
|
SLSClearWindowTags(g_connection, bar->id, clear_tags, 64);
|
||||||
SLSSetWindowOpacity(g_connection, bar->id, 0);
|
SLSSetWindowOpacity(g_connection, bar->id, 0);
|
||||||
|
SLSSetWindowBackgroundBlurRadius(g_connection, bar->id, g_bar_manager.blur_radius);
|
||||||
SLSSetMouseEventEnableFlags(g_connection, bar->id, false);
|
SLSSetMouseEventEnableFlags(g_connection, bar->id, false);
|
||||||
SLSSetWindowLevel(g_connection, bar->id, CGWindowLevelForKey(4));
|
SLSSetWindowLevel(g_connection, bar->id, CGWindowLevelForKey(4));
|
||||||
bar->context = SLWindowContextCreate(g_connection, bar->id, 0);
|
bar->context = SLWindowContextCreate(g_connection, bar->id, 0);
|
||||||
|
|
|
@ -10,6 +10,7 @@ extern CGError SLSClearWindowTags(int cid, uint32_t wid, uint32_t tags[2], int t
|
||||||
extern CGError SLSSetWindowShape(int cid, uint32_t wid, float x_offset, float y_offset, CFTypeRef shape);
|
extern CGError SLSSetWindowShape(int cid, uint32_t wid, float x_offset, float y_offset, CFTypeRef shape);
|
||||||
extern CGError SLSSetWindowResolution(int cid, uint32_t wid, double res);
|
extern CGError SLSSetWindowResolution(int cid, uint32_t wid, double res);
|
||||||
extern CGError SLSSetWindowOpacity(int cid, uint32_t wid, bool isOpaque);
|
extern CGError SLSSetWindowOpacity(int cid, uint32_t wid, bool isOpaque);
|
||||||
|
extern CGError SLSSetWindowBackgroundBlurRadius(int cid, uint32_t wid, uint32_t radius);
|
||||||
extern CGError SLSSetMouseEventEnableFlags(int cid, uint32_t wid, bool shouldEnable);
|
extern CGError SLSSetMouseEventEnableFlags(int cid, uint32_t wid, bool shouldEnable);
|
||||||
extern CGError SLSOrderWindow(int cid, uint32_t wid, int mode, uint32_t relativeToWID);
|
extern CGError SLSOrderWindow(int cid, uint32_t wid, int mode, uint32_t relativeToWID);
|
||||||
extern CGError SLSSetWindowLevel(int cid, uint32_t wid, int level);
|
extern CGError SLSSetWindowLevel(int cid, uint32_t wid, int level);
|
||||||
|
|
|
@ -28,6 +28,13 @@ int bar_manager_get_item_index_by_address(struct bar_manager* bar_manager, struc
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bar_manager_set_background_blur(struct bar_manager* bar_manager, uint32_t radius) {
|
||||||
|
bar_manager->blur_radius = radius;
|
||||||
|
for (int i = 0; i < bar_manager->bar_count; i++) {
|
||||||
|
SLSSetWindowBackgroundBlurRadius(g_connection, bar_manager->bars[i]->id, radius);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void bar_manager_set_background_color(struct bar_manager *bar_manager, uint32_t color) {
|
void bar_manager_set_background_color(struct bar_manager *bar_manager, uint32_t color) {
|
||||||
bar_manager->background_color = rgba_color_from_hex(color);
|
bar_manager->background_color = rgba_color_from_hex(color);
|
||||||
bar_manager_refresh(bar_manager);
|
bar_manager_refresh(bar_manager);
|
||||||
|
@ -106,6 +113,7 @@ void bar_manager_init(struct bar_manager *bar_manager) {
|
||||||
bar_manager->height = 25;
|
bar_manager->height = 25;
|
||||||
bar_manager->y_offset = 0;
|
bar_manager->y_offset = 0;
|
||||||
bar_manager->corner_radius = 0;
|
bar_manager->corner_radius = 0;
|
||||||
|
bar_manager->blur_radius = 0;
|
||||||
bar_manager->margin = 0;
|
bar_manager->margin = 0;
|
||||||
bar_manager->padding_left = 20;
|
bar_manager->padding_left = 20;
|
||||||
bar_manager->padding_right = 20;
|
bar_manager->padding_right = 20;
|
||||||
|
|
|
@ -21,6 +21,7 @@ struct bar_manager {
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
uint32_t margin;
|
uint32_t margin;
|
||||||
uint32_t corner_radius;
|
uint32_t corner_radius;
|
||||||
|
uint32_t blur_radius;
|
||||||
uint32_t y_offset;
|
uint32_t y_offset;
|
||||||
uint32_t padding_left;
|
uint32_t padding_left;
|
||||||
uint32_t padding_right;
|
uint32_t padding_right;
|
||||||
|
@ -38,6 +39,7 @@ void bar_manager_handle_notification(struct bar_manager* bar_manager, char* cont
|
||||||
|
|
||||||
void bar_manager_script_update(struct bar_manager* bar_manager, bool forced);
|
void bar_manager_script_update(struct bar_manager* bar_manager, bool forced);
|
||||||
void bar_manager_update_components(struct bar_manager* bar_manager, uint32_t did, uint32_t sid);
|
void bar_manager_update_components(struct bar_manager* bar_manager, uint32_t did, uint32_t sid);
|
||||||
|
void bar_manager_set_background_blur(struct bar_manager* bar_manager, uint32_t radius);
|
||||||
void bar_manager_set_background_color(struct bar_manager *bar_manager, uint32_t color);
|
void bar_manager_set_background_color(struct bar_manager *bar_manager, uint32_t color);
|
||||||
void bar_manager_set_position(struct bar_manager *bar_manager, char *pos);
|
void bar_manager_set_position(struct bar_manager *bar_manager, char *pos);
|
||||||
void bar_manager_set_spaces(struct bar_manager *bar_manager, bool value);
|
void bar_manager_set_spaces(struct bar_manager *bar_manager, bool value);
|
||||||
|
|
|
@ -70,6 +70,7 @@ extern bool g_verbose;
|
||||||
#define COMMAND_CONFIG_BAR_YOFFSET "y_offset"
|
#define COMMAND_CONFIG_BAR_YOFFSET "y_offset"
|
||||||
#define COMMAND_CONFIG_BAR_MARGIN "margin"
|
#define COMMAND_CONFIG_BAR_MARGIN "margin"
|
||||||
#define COMMAND_CONFIG_BAR_CORNER_RADIUS "corner_radius"
|
#define COMMAND_CONFIG_BAR_CORNER_RADIUS "corner_radius"
|
||||||
|
#define COMMAND_CONFIG_BAR_BLUR_RADIUS "blur_radius"
|
||||||
#define COMMAND_CONFIG_BAR_PADDING_LEFT "padding_left"
|
#define COMMAND_CONFIG_BAR_PADDING_LEFT "padding_left"
|
||||||
#define COMMAND_CONFIG_BAR_PADDING_RIGHT "padding_right"
|
#define COMMAND_CONFIG_BAR_PADDING_RIGHT "padding_right"
|
||||||
#define COMMAND_CONFIG_BAR_DISPLAY "display"
|
#define COMMAND_CONFIG_BAR_DISPLAY "display"
|
||||||
|
@ -442,6 +443,9 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
|
||||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_CORNER_RADIUS)) {
|
} else if (token_equals(command, COMMAND_CONFIG_BAR_CORNER_RADIUS)) {
|
||||||
struct token token = get_token(&message);
|
struct token token = get_token(&message);
|
||||||
g_bar_manager.corner_radius = token_to_uint32t(token);
|
g_bar_manager.corner_radius = token_to_uint32t(token);
|
||||||
|
} else if (token_equals(command, COMMAND_CONFIG_BAR_BLUR_RADIUS)) {
|
||||||
|
struct token token = get_token(&message);
|
||||||
|
bar_manager_set_background_blur(&g_bar_manager, token_to_uint32t(token));
|
||||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_PADDING_LEFT)) {
|
} else if (token_equals(command, COMMAND_CONFIG_BAR_PADDING_LEFT)) {
|
||||||
struct token token = get_token(&message);
|
struct token token = get_token(&message);
|
||||||
bar_manager_set_padding_left(&g_bar_manager, atoi(token_to_string(token)));
|
bar_manager_set_padding_left(&g_bar_manager, atoi(token_to_string(token)));
|
||||||
|
|
Loading…
Add table
Reference in a new issue