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

Support notch_display_height property #626

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ void bar_calculate_bounds(struct bar* bar) {
static CGRect bar_get_frame(struct bar *bar) {
bool is_builtin = CGDisplayIsBuiltin(bar->did);
int notch_offset = is_builtin ? g_bar_manager.notch_offset : 0;
int notch_display_height = is_builtin ? g_bar_manager.notch_display_height : 0;


CGRect bounds = display_bounds(bar->did);
Expand Down Expand Up @@ -507,8 +508,15 @@ static CGRect bar_get_frame(struct bar *bar) {
origin.y += menu.size.height;
}


if (notch_display_height > 0) {
return (CGRect) {{origin.x, origin.y},
{bounds.size.width,
g_bar_manager.notch_display_height}};
}

return (CGRect) {{origin.x, origin.y},
{bounds.size.width,
{bounds.size.width,
g_bar_manager.background.bounds.size.height}};
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/bar_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void bar_manager_init(struct bar_manager* bar_manager) {
bar_manager->topmost = false;
bar_manager->notch_width = 200;
bar_manager->notch_offset = 0;
bar_manager->notch_display_height = 0;
bar_manager->active_adid = display_active_display_adid();
bar_manager->might_need_clipping = false;

Expand Down Expand Up @@ -242,6 +243,14 @@ bool bar_manager_set_notch_offset(struct bar_manager* bar_manager, uint32_t offs
return true;
}

bool bar_manager_set_notch_display_height(struct bar_manager* bar_manager, uint32_t offset) {
if (bar_manager->notch_display_height == offset) return false;

bar_manager->notch_display_height = offset;
bar_manager->bar_needs_resize = true;
return true;
}

bool bar_manager_set_font_smoothing(struct bar_manager* bar_manager, bool smoothing) {
if (bar_manager->font_smoothing == smoothing) return false;
bar_manager->font_smoothing = smoothing;
Expand Down
2 changes: 2 additions & 0 deletions src/bar_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct bar_manager {
uint32_t blur_radius;
uint32_t notch_width;
uint32_t notch_offset;
uint32_t notch_display_height;
uint32_t active_adid;
uint32_t window_level;

Expand Down Expand Up @@ -79,6 +80,7 @@ bool bar_manager_set_shadow(struct bar_manager* bar_manager, bool shadow);
bool bar_manager_set_font_smoothing(struct bar_manager* bar_manager, bool smoothing);
bool bar_manager_set_notch_width(struct bar_manager* bar_manager, uint32_t width);
bool bar_manager_set_notch_offset(struct bar_manager* bar_manager, uint32_t offset);
bool bar_manager_set_notch_display_height(struct bar_manager* bar_manager, uint32_t offset);
void bar_manager_sort(struct bar_manager* bar_manager, struct bar_item** ordering, uint32_t count);

struct bar_item* bar_manager_get_item_by_point(struct bar_manager* bar_manager, CGPoint point, struct window** window_out);
Expand Down
6 changes: 6 additions & 0 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,12 @@ static bool handle_domain_bar(FILE *rsp, struct token domain, char *message) {
&g_bar_manager,
g_bar_manager.notch_offset,
token_to_int(token) );
} else if (token_equals(command, PROPERTY_NOTCH_DISPLAY_HEIGHT)) {
struct token token = get_token(&message);
ANIMATE(bar_manager_set_notch_display_height,
&g_bar_manager,
g_bar_manager.notch_display_height,
token_to_int(token) );
} else if (token_equals(command, PROPERTY_HIDDEN)) {
struct token state = get_token(&message);
uint32_t adid = 0;
Expand Down
1 change: 1 addition & 0 deletions src/misc/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
#define PROPERTY_ALIGN "align"
#define PROPERTY_NOTCH_WIDTH "notch_width"
#define PROPERTY_NOTCH_OFFSET "notch_offset"
#define PROPERTY_NOTCH_DISPLAY_HEIGHT "notch_display_height"
#define PROPERTY_HORIZONTAL "horizontal"

#define DOMAIN_SUBSCRIBE "--subscribe"
Expand Down