fix aliases not updating properly when the parent application is restarted (#377)

This commit is contained in:
Felix Kratz 2023-06-01 09:01:49 +02:00
parent 14c6381aa8
commit 4058ffef0b
3 changed files with 11 additions and 3 deletions

View file

@ -158,9 +158,14 @@ static bool alias_update_image(struct alias* alias, bool forced) {
if (alias->window.id == 0) alias_find_window(alias);
if (alias->window.id == 0) return false;
CGImageRef image_ref = window_capture(&alias->window);
bool disabled = false;
CGImageRef image_ref = window_capture(&alias->window, &disabled);
if (!image_ref) {
if (!disabled) {
alias->window.id = 0;
image_destroy(&alias->image);
}
return false;
}

View file

@ -241,18 +241,21 @@ void window_disable_shadow(struct window* window) {
CFRelease(shadow_props_cf);
}
CGImageRef window_capture(struct window* window) {
CGImageRef window_capture(struct window* window, bool* disabled) {
if (g_disable_capture) {
int64_t time = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW_APPROX);
if (g_disable_capture < 0) {
*disabled = true;
return NULL;
} else if (time - g_disable_capture > (1ULL << 30)) {
g_disable_capture = 0;
} else {
*disabled = true;
return NULL;
}
}
*disabled = false;
CGImageRef image_ref = NULL;
uint64_t wid = window->id;

View file

@ -95,7 +95,7 @@ void window_set_level(struct window* window, uint32_t level);
void window_order(struct window* window, struct window* parent, int mode);
void window_assign_mouse_tracking_area(struct window* window, CGRect rect);
CGImageRef window_capture(struct window* window);
CGImageRef window_capture(struct window* window, bool* disabled);
void context_set_font_smoothing(CGContextRef context, bool smoothing);