Skip to content

Commit

Permalink
#1801 fix weird segfault with cached mouse event
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Feb 22, 2024
1 parent 3004430 commit 57fe4f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/mouse_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ static MOUSE_HANDLER(mouse_handler)
uint8_t mod = mouse_mod_from_cgflags(CGEventGetFlags(event));
event_loop_post(&g_event_loop, MOUSE_DOWN, (void *) CFRetain(event), mod);

mouse_state->consume_mouse_click = mod == mouse_state->modifier;
if (mouse_state->consume_mouse_click) {
if (mod == mouse_state->modifier) {
mouse_state->consume_mouse_click = true;
mouse_state->consumed_event = (CGEventRef) CFRetain(event);
return NULL;
}
Expand All @@ -72,8 +72,9 @@ static MOUSE_HANDLER(mouse_handler)
CGEventTapPostEvent(proxy, event);
}

CFRelease(mouse_state->consumed_event);
mouse_state->drag_detected = false;
mouse_state->consume_mouse_click = false;
CFRelease(mouse_state->consumed_event);
return NULL;
}
} break;
Expand Down

0 comments on commit 57fe4f5

Please sign in to comment.