mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-10 05:44:16 +00:00
enable -ffast-math optimization
This commit is contained in:
parent
294645679c
commit
cef53425b0
7 changed files with 36 additions and 36 deletions
2
makefile
2
makefile
|
@ -1,6 +1,6 @@
|
|||
FRAMEWORK_PATH = -F/System/Library/PrivateFrameworks
|
||||
FRAMEWORK = -framework Carbon -framework Cocoa -framework SkyLight
|
||||
BUILD_FLAGS = -std=c99 -Wall -DNDEBUG -Ofast -fvisibility=hidden
|
||||
BUILD_FLAGS = -std=c99 -Wall -DNDEBUG -Ofast -ffast-math -fvisibility=hidden
|
||||
BUILD_PATH = ./bin
|
||||
SKETCHYBAR_SRC = ./src/manifest.m
|
||||
UNIVERSAL_BINS = $(BUILD_PATH)/sketchybar
|
||||
|
|
|
@ -66,7 +66,6 @@ void alias_init(struct alias* alias) {
|
|||
alias->color = rgba_color_from_hex(0xffff0000);
|
||||
|
||||
image_init(&alias->image);
|
||||
// ax_init(&alias->ax);
|
||||
}
|
||||
|
||||
void alias_setup(struct alias* alias, char* owner, char* name) {
|
||||
|
@ -123,7 +122,6 @@ void alias_find_window(struct alias* alias) {
|
|||
CFNumberGetValue(window_id_ref, CFNumberGetType(window_id_ref), &alias->wid);
|
||||
|
||||
CFRelease(window_list);
|
||||
// ax_get_extra_menu_item(&alias->ax, alias->pid, alias->name);
|
||||
return;
|
||||
}
|
||||
alias->wid = 0;
|
||||
|
|
|
@ -15,7 +15,6 @@ struct alias {
|
|||
bool color_override;
|
||||
struct rgba_color color;
|
||||
struct image image;
|
||||
// struct ax ax;
|
||||
};
|
||||
|
||||
void alias_init(struct alias* alias);
|
||||
|
|
59
src/ax.c
59
src/ax.c
|
@ -1,52 +1,57 @@
|
|||
#include "ax.h"
|
||||
|
||||
void ax_init(struct ax* ax) {
|
||||
ax->element = NULL;
|
||||
void ax_init(struct ax* ax, bool check_privileges) {
|
||||
ax->elements = NULL;
|
||||
ax->element_count = 0;
|
||||
if (check_privileges) {
|
||||
const void *keys[] = { kAXTrustedCheckOptionPrompt };
|
||||
const void *values[] = { kCFBooleanTrue };
|
||||
|
||||
const void *keys[] = { kAXTrustedCheckOptionPrompt };
|
||||
const void *values[] = { kCFBooleanTrue };
|
||||
CFDictionaryRef options;
|
||||
options = CFDictionaryCreate(kCFAllocatorDefault,
|
||||
keys, values, sizeof(keys) / sizeof(*keys),
|
||||
&kCFCopyStringDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks );
|
||||
|
||||
CFDictionaryRef options;
|
||||
options = CFDictionaryCreate(kCFAllocatorDefault,
|
||||
keys, values, sizeof(keys) / sizeof(*keys),
|
||||
&kCFCopyStringDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks );
|
||||
ax->is_privileged = AXIsProcessTrustedWithOptions(options);
|
||||
CFRelease(options);
|
||||
} else ax->is_privileged = g_ax.is_privileged;
|
||||
|
||||
ax->is_privileged = AXIsProcessTrustedWithOptions(options);
|
||||
CFRelease(options);
|
||||
}
|
||||
|
||||
void ax_perform_click(struct ax* ax) {
|
||||
if (!ax->element) return;
|
||||
void ax_perform_click(AXUIElementRef element) {
|
||||
if (!element) return;
|
||||
|
||||
AXUIElementPerformAction(ax->element, kAXPressAction);
|
||||
AXUIElementPerformAction(element, kAXPressAction);
|
||||
}
|
||||
|
||||
void ax_get_extra_menu_item(struct ax* ax, pid_t pid, char* name) {
|
||||
AXUIElementRef menu_extras_ref = NULL;
|
||||
AXUIElementRef ax_get_extra_menu_item(struct ax* ax, pid_t pid, char* name) {
|
||||
AXUIElementRef extra_menus_ref = NULL;
|
||||
AXUIElementRef extra_menu = NULL;
|
||||
CFArrayRef children_ref = NULL;
|
||||
|
||||
ax->element = AXUIElementCreateApplication(pid);
|
||||
AXError error = AXUIElementCopyAttributeValue(ax->element, kAXExtrasMenuBarAttribute, (CFTypeRef*)&menu_extras_ref);
|
||||
if (ax->element) CFRelease(ax->element);
|
||||
ax->element = NULL;
|
||||
AXUIElementRef app = AXUIElementCreateApplication(pid);
|
||||
AXError error = AXUIElementCopyAttributeValue(app, kAXExtrasMenuBarAttribute, (CFTypeRef*)&extra_menus_ref);
|
||||
if (app) CFRelease(app);
|
||||
|
||||
if (error == kAXErrorSuccess) {
|
||||
error = AXUIElementCopyAttributeValue(menu_extras_ref, kAXVisibleChildrenAttribute, (CFTypeRef*)&children_ref);
|
||||
error = AXUIElementCopyAttributeValue(extra_menus_ref, kAXVisibleChildrenAttribute, (CFTypeRef*)&children_ref);
|
||||
uint32_t count = CFArrayGetCount(children_ref);
|
||||
|
||||
if (count == 1 || (count > 0 && !name)) {
|
||||
ax->element = CFArrayGetValueAtIndex(children_ref, 0);
|
||||
extra_menu = CFRetain(CFArrayGetValueAtIndex(children_ref, 0));
|
||||
} else {
|
||||
// Loop through array and find correct item via name...
|
||||
}
|
||||
CFRelease(extra_menus_ref);
|
||||
CFRelease(children_ref);
|
||||
}
|
||||
|
||||
CFRelease(menu_extras_ref);
|
||||
CFRelease(children_ref);
|
||||
return extra_menu;
|
||||
}
|
||||
|
||||
void ax_clear(struct ax* ax) {
|
||||
if (ax->element) CFRelease(ax->element);
|
||||
ax->element = NULL;
|
||||
for (int i = 0; i < ax->element_count; i++) {
|
||||
if (ax->elements[i]) CFRelease(ax->elements[i]);
|
||||
}
|
||||
if (ax->elements) free(ax->elements);
|
||||
}
|
||||
|
|
5
src/ax.h
5
src/ax.h
|
@ -4,11 +4,12 @@
|
|||
struct ax {
|
||||
bool is_privileged;
|
||||
|
||||
AXUIElementRef element;
|
||||
uint32_t element_count;
|
||||
AXUIElementRef* elements;
|
||||
};
|
||||
|
||||
struct ax g_ax;
|
||||
void ax_init(struct ax* ax);
|
||||
void ax_init(struct ax* ax, bool check_privileges);
|
||||
void ax_clear(struct ax* ax);
|
||||
void ax_get_menu_item(struct ax* ax, pid_t pid, char* name);
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@ void bar_draw(struct bar* bar) {
|
|||
CGRect tracking_rect = cgrect_mirror_y(bar_item_construct_bounding_rect(bar_item), bar->frame.size.height / 2.);
|
||||
tracking_rect.origin.y -= tracking_rect.size.height;
|
||||
SLSAddTrackingRect(g_connection, bar->id, tracking_rect);
|
||||
|
||||
|
||||
}
|
||||
|
||||
bar_item_set_bounding_rect_for_display(bar_item, bar->adid, bar->origin, bar->frame.size.height);
|
||||
|
|
|
@ -57,7 +57,6 @@ static int client_send_message(int argc, char **argv) {
|
|||
return EXIT_FAILURE;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static void acquire_lockfile(void) {
|
||||
|
|
Loading…
Reference in a new issue