formatting

This commit is contained in:
Felix Kratz 2023-11-30 12:14:44 +01:00
parent 1fbf855930
commit aad9d9aac4
7 changed files with 16 additions and 27 deletions

View file

@ -102,9 +102,6 @@ struct animation {
struct animation* animation_create();
void animation_setup(struct animation* animation, void* target, animator_function* update_function, int initial_value, int final_value, uint32_t duration, char interp_function);
#define ANIMATOR_CALLBACK(name) void name(CFRunLoopTimerRef timer, void *context)
typedef ANIMATOR_CALLBACK(animator_callback);
struct animator {
CVDisplayLinkRef display_link;
@ -116,11 +113,14 @@ struct animator {
};
void animator_init(struct animator* animator);
void animator_renew_display_link(struct animator* animator);
void animator_add(struct animator* animator, struct animation* animation);
bool animator_cancel(struct animator* animator, void* target, animator_function* function);
void animator_cancel_locked(struct animator* animator, void* target, animator_function* function);
bool animator_update(struct animator* animator);
void animator_lock(struct animator* animator);
void animator_destroy(struct animator* animator);
void animator_renew_display_link(struct animator* animator);
void animator_destroy_display_link(struct animator* animator);

View file

@ -43,8 +43,7 @@ void app_windows_add(struct app_windows* windows, struct app_window* window) {
void app_windows_clear_space(struct app_windows* windows, uint64_t sid) {
for (int i = 0; i < windows->num_windows; i++) {
if (windows->windows[i].sid == sid)
app_window_clear(windows->windows + i);
if (windows->windows[i].sid == sid) app_window_clear(windows->windows + i);
}
}
@ -72,9 +71,7 @@ static bool app_window_suitable(struct app_window* window) {
CFTypeRef iterator = SLSWindowQueryResultCopyWindows(query);
if (iterator && SLSWindowIteratorGetCount(iterator) > 0) {
if (SLSWindowIteratorAdvance(iterator)) {
if (iterator_window_suitable(iterator)) {
suitable = true;
}
if (iterator_window_suitable(iterator)) suitable = true;
}
}
if (iterator) CFRelease(iterator);
@ -173,9 +170,7 @@ static void app_windows_update_space(struct app_windows* windows, uint64_t sid,
pid_t pid = 0;
SLSConnectionGetPID(wid_cid, &pid);
struct app_window window = { .wid = wid,
.sid = sid,
.pid = pid };
struct app_window window = {.wid = wid, .sid = sid, .pid = pid};
app_windows_add(windows, &window);
}
}
@ -205,11 +200,8 @@ static void window_spawn_handler(uint32_t event, struct window_spawn_data* data,
if (event == 1325 && app_window_suitable(&window)) {
app_windows_update_space(&g_windows, sid, false);
} else if (event == 1326) {
bool found = app_windows_find(&g_windows, &window);
if (found) {
app_windows_update_space(&g_windows, sid, false);
}
} else if (event == 1326 && app_windows_find(&g_windows, &window)) {
app_windows_update_space(&g_windows, sid, false);
}
}

View file

@ -25,6 +25,5 @@ struct app_windows {
uint32_t num_windows;
};
void begin_receiving_space_window_events();
void forced_space_windows_event();

View file

@ -1,8 +1,6 @@
#pragma once
#include "image.h"
struct bar;
struct background {
bool enabled;
float clip;
@ -24,6 +22,8 @@ struct background {
uint32_t num_clips;
};
struct bar;
void background_init(struct background* background);
void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y, uint32_t width, uint32_t height);
@ -34,6 +34,7 @@ bool background_set_padding_left(struct background* background, uint32_t pad);
bool background_set_padding_right(struct background* background, uint32_t pad);
void background_draw(struct background* background, CGContextRef context);
struct background* background_get_clip(struct background* background, uint32_t adid);
void background_clip_bar(struct background* background, int offset, struct bar* bar);
bool background_clip_needs_update(struct background* background, struct bar* bar);

View file

@ -10,7 +10,8 @@ static void brightness_handler(void* notification_center, uint32_t did, void* na
float b = 0;
float* brightness = &b;
DisplayServicesGetBrightness(did, brightness);
if (g_last_brightness < *brightness - 1e-2 || g_last_brightness > *brightness + 1e-2) {
if (g_last_brightness < *brightness - 1e-2
|| g_last_brightness > *brightness + 1e-2) {
g_last_brightness = *brightness;
struct event event = { (void*) brightness, BRIGHTNESS_CHANGED };
event_post(&event);

View file

@ -50,9 +50,7 @@ void mach_receive_message(mach_port_t port, struct mach_buffer* buffer, bool tim
}
char* mach_send_message(mach_port_t port, char* message, uint32_t len, bool await_response) {
if (!message || !port) {
return NULL;
}
if (!message || !port) return NULL;
mach_port_t response_port;
mach_port_name_t task = mach_task_self();

View file

@ -16,7 +16,7 @@ void window_init(struct window* window) {
window->order_mode = W_ABOVE;
}
static CFTypeRef window_create_region(struct window *window, CGRect frame) {
static CFTypeRef window_create_region(struct window* window, CGRect frame) {
CFTypeRef frame_region;
CGSNewRegionWithRect(&frame, &frame_region);
return frame_region;
@ -92,14 +92,12 @@ void windows_unfreeze() {
void window_set_frame(struct window* window, CGRect frame) {
if (window->needs_move
|| !CGPointEqualToPoint(window->origin, frame.origin)) {
window->needs_move = true;
window->origin = frame.origin;
}
if (window->needs_resize
|| !CGSizeEqualToSize(window->frame.size, frame.size)) {
window->needs_resize = true;
window->frame.size = frame.size;
}