mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-26 13:20:24 +00:00
less aggressive display event handling (#336)
This commit is contained in:
parent
e704e95d04
commit
6d2b3c2a34
8 changed files with 54 additions and 16 deletions
|
@ -138,7 +138,7 @@ static void bar_check_for_clip_updates(struct bar* bar) {
|
|||
}
|
||||
}
|
||||
|
||||
void bar_draw(struct bar* bar) {
|
||||
void bar_draw(struct bar* bar, bool forced) {
|
||||
if (bar->sid < 1 || bar->adid < 1) return;
|
||||
|
||||
if (g_bar_manager.might_need_clipping)
|
||||
|
@ -182,7 +182,8 @@ void bar_draw(struct bar* bar) {
|
|||
bar );
|
||||
}
|
||||
|
||||
if (!window_apply_frame(window) && !bar_item->needs_update) continue;
|
||||
if (!window_apply_frame(window, false) && !bar_item->needs_update)
|
||||
continue;
|
||||
|
||||
if (bar_item->update_mask & UPDATE_MOUSE_ENTERED
|
||||
|| bar_item->update_mask & UPDATE_MOUSE_EXITED) {
|
||||
|
@ -488,7 +489,7 @@ static CGRect bar_get_frame(struct bar *bar) {
|
|||
void bar_resize(struct bar* bar) {
|
||||
if (bar->hidden) return;
|
||||
window_set_frame(&bar->window, bar_get_frame(bar));
|
||||
if (window_apply_frame(&bar->window)) {
|
||||
if (window_apply_frame(&bar->window, false)) {
|
||||
window_assign_mouse_tracking_area(&bar->window, bar->window.frame);
|
||||
g_bar_manager.bar_needs_update = true;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ void bar_destroy(struct bar* bar);
|
|||
void bar_set_hidden(struct bar* bar, bool hidden);
|
||||
void bar_calculate_bounds(struct bar* bar);
|
||||
void bar_resize(struct bar* bar);
|
||||
void bar_draw(struct bar* bar);
|
||||
void bar_draw(struct bar* bar, bool forced);
|
||||
void bar_order_item_windows(struct bar* bar);
|
||||
|
||||
bool bar_draws_item(struct bar* bar, struct bar_item* bar_item);
|
||||
|
|
|
@ -403,7 +403,7 @@ void bar_manager_refresh(struct bar_manager* bar_manager, bool forced) {
|
|||
if (forced
|
||||
|| bar_manager_bar_needs_redraw(bar_manager, bar_manager->bars[i])) {
|
||||
bar_calculate_bounds(bar_manager->bars[i]);
|
||||
bar_draw(bar_manager->bars[i]);
|
||||
bar_draw(bar_manager->bars[i], false);
|
||||
if (bar_manager->needs_ordering) {
|
||||
bar_order_item_windows(bar_manager->bars[i]);
|
||||
}
|
||||
|
@ -703,6 +703,38 @@ void bar_manager_custom_events_trigger(struct bar_manager* bar_manager, char* na
|
|||
}
|
||||
}
|
||||
|
||||
void bar_manager_display_resized(struct bar_manager* bar_manager, uint32_t did) {
|
||||
for (int i = 0; i < bar_manager->bar_count; i++) {
|
||||
if (bar_manager->bars[i]->did == did) {
|
||||
bar_resize(bar_manager->bars[i]);
|
||||
}
|
||||
}
|
||||
bar_manager_refresh(bar_manager, false);
|
||||
}
|
||||
|
||||
void bar_manager_display_moved(struct bar_manager* bar_manager, uint32_t did) {
|
||||
for (int i = 0; i < bar_manager->bar_count; i++) {
|
||||
struct bar* bar = bar_manager->bars[i];
|
||||
if (bar->did == did) {
|
||||
bar_resize(bar);
|
||||
bar->adid = display_arrangement(bar->did);
|
||||
bar->dsid = display_space_id(bar->did);
|
||||
bar->sid = mission_control_index(bar->dsid);
|
||||
}
|
||||
}
|
||||
bar_manager->needs_ordering = true;
|
||||
bar_manager_refresh(bar_manager, true);
|
||||
bar_manager_handle_display_change(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_display_removed(struct bar_manager* bar_manager, uint32_t did) {
|
||||
bar_manager_display_changed(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_display_added(struct bar_manager* bar_manager, uint32_t did) {
|
||||
bar_manager_display_changed(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_display_changed(struct bar_manager* bar_manager) {
|
||||
bar_manager->active_adid = display_arrangement(display_active_display_id());
|
||||
|
||||
|
@ -711,6 +743,7 @@ void bar_manager_display_changed(struct bar_manager* bar_manager) {
|
|||
bar_manager_unfreeze(bar_manager);
|
||||
bar_manager_refresh(bar_manager, true);
|
||||
|
||||
bar_manager_handle_display_change(bar_manager);
|
||||
bar_manager_handle_space_change(bar_manager, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,10 @@ void bar_manager_freeze(struct bar_manager* bar_manager);
|
|||
void bar_manager_unfreeze(struct bar_manager* bar_manager);
|
||||
|
||||
void bar_manager_display_changed(struct bar_manager* bar_manager);
|
||||
void bar_manager_display_resized(struct bar_manager* bar_manager, uint32_t did);
|
||||
void bar_manager_display_moved(struct bar_manager* bar_manager, uint32_t did);
|
||||
void bar_manager_display_removed(struct bar_manager* bar_manager, uint32_t did);
|
||||
void bar_manager_display_added(struct bar_manager* bar_manager, uint32_t did);
|
||||
void bar_manager_refresh(struct bar_manager* bar_manager, bool forced);
|
||||
void bar_manager_resize(struct bar_manager* bar_manager);
|
||||
|
||||
|
|
16
src/event.c
16
src/event.c
|
@ -41,26 +41,26 @@ EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_CHANGED) {
|
|||
}
|
||||
|
||||
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_ADDED) {
|
||||
bar_manager_handle_display_change(&g_bar_manager);
|
||||
bar_manager_display_changed(&g_bar_manager);
|
||||
uint32_t did = (uint32_t)(intptr_t)context;
|
||||
bar_manager_display_added(&g_bar_manager, did);
|
||||
return EVENT_SUCCESS;
|
||||
}
|
||||
|
||||
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_REMOVED) {
|
||||
bar_manager_handle_display_change(&g_bar_manager);
|
||||
bar_manager_display_changed(&g_bar_manager);
|
||||
uint32_t did = (uint32_t)(intptr_t)context;
|
||||
bar_manager_display_removed(&g_bar_manager, did);
|
||||
return EVENT_SUCCESS;
|
||||
}
|
||||
|
||||
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_MOVED) {
|
||||
bar_manager_handle_display_change(&g_bar_manager);
|
||||
bar_manager_display_changed(&g_bar_manager);
|
||||
uint32_t did = (uint32_t)(intptr_t)context;
|
||||
bar_manager_display_moved(&g_bar_manager, did);
|
||||
return EVENT_SUCCESS;
|
||||
}
|
||||
|
||||
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_RESIZED) {
|
||||
bar_manager_handle_display_change(&g_bar_manager);
|
||||
bar_manager_display_changed(&g_bar_manager);
|
||||
uint32_t did = (uint32_t)(intptr_t)context;
|
||||
bar_manager_display_resized(&g_bar_manager, did);
|
||||
return EVENT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -327,7 +327,7 @@ void popup_draw(struct popup* popup) {
|
|||
|
||||
if (!popup->window.id) popup_create_window(popup);
|
||||
|
||||
window_apply_frame(&popup->window);
|
||||
window_apply_frame(&popup->window, false);
|
||||
CGContextClearRect(popup->window.context, popup->background.bounds);
|
||||
|
||||
window_assign_mouse_tracking_area(&popup->window, popup->window.frame);
|
||||
|
|
|
@ -131,7 +131,7 @@ void window_move(struct window* window, CGPoint point) {
|
|||
}
|
||||
}
|
||||
|
||||
bool window_apply_frame(struct window* window) {
|
||||
bool window_apply_frame(struct window* window, bool forced) {
|
||||
windows_freeze();
|
||||
if (window->needs_resize) {
|
||||
CFTypeRef frame_region = window_create_region(window, window->frame);
|
||||
|
|
|
@ -86,7 +86,7 @@ void window_clear(struct window* window);
|
|||
|
||||
void window_move(struct window* window, CGPoint point);
|
||||
void window_set_frame(struct window* window, CGRect frame);
|
||||
bool window_apply_frame(struct window* window);
|
||||
bool window_apply_frame(struct window* window, bool forced);
|
||||
void window_send_to_space(struct window* window, uint64_t dsid);
|
||||
|
||||
void window_set_blur_radius(struct window* window, uint32_t blur_radius);
|
||||
|
|
Loading…
Reference in a new issue