mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-23 11:53:02 +00:00
fix ghost bounding boxes
This commit is contained in:
parent
e157482375
commit
b53bd2bb28
6 changed files with 46 additions and 17 deletions
|
@ -200,7 +200,7 @@ void bar_redraw(struct bar* bar) {
|
|||
bar_item->label.line.bounds.origin = label_position;
|
||||
bar_item->icon.line.bounds.origin = icon_position;
|
||||
bar_item_append_associated_bar(bar_item, (1 << (adid - 1)));
|
||||
SLSAddTrackingRect(g_connection, bar->id, bar_item_construct_bounding_rect(bar_item));
|
||||
if (strlen(bar_item->click_script) > 0) SLSAddTrackingRect(g_connection, bar->id, CGRectInset(bar_item_construct_bounding_rect(bar_item), 1, 1));
|
||||
bar_item_set_bounding_rect_for_display(bar_item, adid, bar->origin);
|
||||
|
||||
bar_draw_group(bar, bar_item, adid);
|
||||
|
|
|
@ -101,16 +101,19 @@ bool bar_item_is_shown(struct bar_item* bar_item) {
|
|||
else return false;
|
||||
}
|
||||
|
||||
void bar_item_append_associated_bar(struct bar_item* bar_item, uint32_t bit) {
|
||||
bar_item->associated_bar |= bit;
|
||||
void bar_item_append_associated_bar(struct bar_item* bar_item, uint32_t adid) {
|
||||
bar_item->associated_bar |= (1 << (adid - 1));
|
||||
}
|
||||
|
||||
void bar_item_remove_associated_bar(struct bar_item* bar_item, uint32_t bit) {
|
||||
bar_item->associated_bar &= ~bit;
|
||||
void bar_item_remove_associated_bar(struct bar_item* bar_item, uint32_t adid) {
|
||||
bar_item->associated_bar &= ~(1 << (adid - 1));
|
||||
bar_item_remove_bounding_rect_for_display(bar_item, adid);
|
||||
}
|
||||
|
||||
void bar_item_reset_associated_bar(struct bar_item* bar_item) {
|
||||
bar_item->associated_bar = 0;
|
||||
for (uint32_t adid = 1; adid <= bar_item->num_rects; adid++)
|
||||
bar_item_remove_bounding_rect_for_display(bar_item, adid);
|
||||
}
|
||||
|
||||
bool bar_item_update(struct bar_item* bar_item, bool forced) {
|
||||
|
@ -233,6 +236,13 @@ uint32_t bar_item_get_height(struct bar_item* bar_item) {
|
|||
return label_height > icon_height ? label_height : icon_height;
|
||||
}
|
||||
|
||||
void bar_item_remove_bounding_rect_for_display(struct bar_item* bar_item, uint32_t adid) {
|
||||
if (bar_item->num_rects >= adid && bar_item->bounding_rects[adid - 1]) {
|
||||
free(bar_item->bounding_rects[adid - 1]);
|
||||
bar_item->bounding_rects[adid - 1] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CGRect bar_item_construct_bounding_rect(struct bar_item* bar_item) {
|
||||
CGRect bounding_rect;
|
||||
bounding_rect.origin = bar_item->icon.line.bounds.origin;
|
||||
|
|
|
@ -88,8 +88,8 @@ bool bar_item_is_shown(struct bar_item* bar_item);
|
|||
|
||||
void bar_item_append_associated_space(struct bar_item* bar_item, uint32_t bit);
|
||||
void bar_item_append_associated_display(struct bar_item* bar_item, uint32_t bit);
|
||||
void bar_item_append_associated_bar(struct bar_item* bar_item, uint32_t bit);
|
||||
void bar_item_remove_associated_bar(struct bar_item* bar_item, uint32_t bit);
|
||||
void bar_item_append_associated_bar(struct bar_item* bar_item, uint32_t adid);
|
||||
void bar_item_remove_associated_bar(struct bar_item* bar_item, uint32_t adid);
|
||||
void bar_item_reset_associated_bar(struct bar_item* bar_item);
|
||||
void bar_item_set_name(struct bar_item* bar_item, char* name);
|
||||
void bar_item_set_type(struct bar_item* bar_item, char type);
|
||||
|
@ -106,6 +106,7 @@ void bar_item_clear_needs_update(struct bar_item* bar_item);
|
|||
|
||||
void bar_item_on_click(struct bar_item* bar_item);
|
||||
|
||||
void bar_item_remove_bounding_rect_for_display(struct bar_item* bar_item, uint32_t adid);
|
||||
CGRect bar_item_construct_bounding_rect(struct bar_item* bar_item);
|
||||
void bar_item_set_bounding_rect_for_display(struct bar_item* bar_item, uint32_t adid, CGPoint bar_origin);
|
||||
|
||||
|
|
20
src/event.c
20
src/event.c
|
@ -110,14 +110,26 @@ static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_UP) {
|
|||
return EVENT_SUCCESS;
|
||||
}
|
||||
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_MOVED) {
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_ENTERED) {
|
||||
debug("%s\n", __FUNCTION__);
|
||||
CGPoint point = CGEventGetLocation(context);
|
||||
uint32_t adid = display_arrangement(display_active_display_id());
|
||||
printf("EVENT_HANDLER_MOUSE_MOVED: D#%d (x: %.0f, y: %.0f) -> ", adid, point.x, point.y);
|
||||
printf("EVENT_HANDLER_MOUSE_ENTERED: D#%d (x: %.0f, y: %.0f) -> ", adid, point.x, point.y);
|
||||
struct bar_item* bar_item = bar_manager_get_item_by_point(&g_bar_manager, point, adid);
|
||||
debug("item: %s\n", bar_item ? bar_item->name : "NULL");
|
||||
bar_item_on_click(bar_item);
|
||||
printf("item: %s\n", bar_item ? bar_item->name : "NULL");
|
||||
//bar_item_on_click(bar_item);
|
||||
CFRelease(context);
|
||||
return EVENT_SUCCESS;
|
||||
}
|
||||
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_EXITED) {
|
||||
debug("%s\n", __FUNCTION__);
|
||||
CGPoint point = CGEventGetLocation(context);
|
||||
uint32_t adid = display_arrangement(display_active_display_id());
|
||||
printf("EVENT_HANDLER_MOUSE_EXITED: D#%d (x: %.0f, y: %.0f) -> ", adid, point.x, point.y);
|
||||
struct bar_item* bar_item = bar_manager_get_item_by_point(&g_bar_manager, point, adid);
|
||||
printf("item: %s\n", bar_item ? bar_item->name : "NULL");
|
||||
//bar_item_on_click(bar_item);
|
||||
CFRelease(context);
|
||||
return EVENT_SUCCESS;
|
||||
}
|
||||
|
|
12
src/event.h
12
src/event.h
|
@ -18,7 +18,8 @@ static EVENT_CALLBACK(EVENT_HANDLER_SYSTEM_WOKE);
|
|||
static EVENT_CALLBACK(EVENT_HANDLER_SHELL_REFRESH);
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_DAEMON_MESSAGE);
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_UP);
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_MOVED);
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_ENTERED);
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_EXITED);
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_DISTRIBUTED_NOTIFICATION);
|
||||
#define EVENT_QUEUED 0x0
|
||||
#define EVENT_PROCESSED 0x1
|
||||
|
@ -44,7 +45,8 @@ enum event_type {
|
|||
SHELL_REFRESH,
|
||||
DAEMON_MESSAGE,
|
||||
MOUSE_UP,
|
||||
MOUSE_MOVED,
|
||||
MOUSE_ENTERED,
|
||||
MOUSE_EXITED,
|
||||
DISTRIBUTED_NOTIFICATION,
|
||||
|
||||
EVENT_TYPE_COUNT
|
||||
|
@ -65,7 +67,8 @@ static const char *event_type_str[] = {
|
|||
[SHELL_REFRESH] = "shell_refresh",
|
||||
[DAEMON_MESSAGE] = "daemon_message",
|
||||
[MOUSE_UP] = "mouse_up",
|
||||
[MOUSE_MOVED] = "mouse_moved",
|
||||
[MOUSE_ENTERED] = "mouse_entered",
|
||||
[MOUSE_EXITED] = "mouse_exited",
|
||||
[DISTRIBUTED_NOTIFICATION] = "distributed_notification",
|
||||
|
||||
[EVENT_TYPE_COUNT] = "event_type_count"
|
||||
|
@ -80,7 +83,8 @@ static event_callback *event_handler[] = {
|
|||
[DISPLAY_RESIZED] = EVENT_HANDLER_DISPLAY_RESIZED,
|
||||
[DISPLAY_CHANGED] = EVENT_HANDLER_DISPLAY_CHANGED,
|
||||
[MOUSE_UP] = EVENT_HANDLER_MOUSE_UP,
|
||||
[MOUSE_MOVED] = EVENT_HANDLER_MOUSE_MOVED,
|
||||
[MOUSE_ENTERED] = EVENT_HANDLER_MOUSE_ENTERED,
|
||||
[MOUSE_EXITED] = EVENT_HANDLER_MOUSE_EXITED,
|
||||
[DISTRIBUTED_NOTIFICATION] = EVENT_HANDLER_DISTRIBUTED_NOTIFICATION,
|
||||
|
||||
[MENU_BAR_HIDDEN_CHANGED] = EVENT_HANDLER_MENU_BAR_HIDDEN_CHANGED,
|
||||
|
|
|
@ -8,11 +8,13 @@ static pascal OSStatus mouse_handler(EventHandlerCallRef next, EventRef e, void
|
|||
break;
|
||||
}
|
||||
case kEventMouseEntered: {
|
||||
printf("entered event: %d \n", GetEventKind(e));
|
||||
struct event *event = event_create(&g_event_loop, MOUSE_ENTERED, (void *) CFRetain(CopyEventCGEvent(e)));
|
||||
event_loop_post(&g_event_loop, event);
|
||||
break;
|
||||
}
|
||||
case kEventMouseExited: {
|
||||
printf("xited event: %d \n", GetEventKind(e));
|
||||
struct event *event = event_create(&g_event_loop, MOUSE_EXITED, (void *) CFRetain(CopyEventCGEvent(e)));
|
||||
event_loop_post(&g_event_loop, event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue