From e851eebad5dbfa1f76f3ae3138a73362e8341954 Mon Sep 17 00:00:00 2001 From: Felix Kratz Date: Sat, 2 Jul 2022 12:12:04 +0200 Subject: [PATCH] remove ax api playground for now --- makefile | 2 +- src/ax.c | 62 -------------------------------------------------------- src/ax.h | 14 ------------- 3 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 src/ax.c delete mode 100644 src/ax.h diff --git a/makefile b/makefile index 8a3fd2b..b4992f0 100644 --- a/makefile +++ b/makefile @@ -4,7 +4,7 @@ ODIR = bin SRC = src _OBJ = alias.o background.o bar_item.o custom_events.o event.o graph.o \ - image.o mouse.o shadow.o text.o message.o mouse.o ax.o bar.o window.o \ + image.o mouse.o shadow.o text.o message.o mouse.o bar.o window.o \ bar_manager.o display.o event_loop.o group.o mach.o popup.o \ animation.o workspace.om OBJ = $(patsubst %, $(ODIR)/%, $(_OBJ)) diff --git a/src/ax.c b/src/ax.c deleted file mode 100644 index 65cf420..0000000 --- a/src/ax.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "ax.h" - -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 }; - - 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; - -} - -void ax_perform_click(AXUIElementRef element) { - if (!element) return; - - AXUIElementPerformAction(element, kAXPressAction); -} - -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; - - AXUIElementRef app = AXUIElementCreateApplication(pid); - AXError error = AXUIElementCopyAttributeValue(app, - kAXExtrasMenuBarAttribute, - (CFTypeRef*)&extra_menus_ref); - if (app) CFRelease(app); - - if (error == kAXErrorSuccess) { - error = AXUIElementCopyAttributeValue(extra_menus_ref, - kAXVisibleChildrenAttribute, - (CFTypeRef*)&children_ref); - - uint32_t count = CFArrayGetCount(children_ref); - - if (count == 1 || (count > 0 && !name)) { - extra_menu = CFRetain(CFArrayGetValueAtIndex(children_ref, 0)); - } else { - // Loop through array and find correct item via name... - } - CFRelease(extra_menus_ref); - CFRelease(children_ref); - } - return extra_menu; -} - -void ax_clear(struct ax* ax) { - for (int i = 0; i < ax->element_count; i++) { - if (ax->elements[i]) CFRelease(ax->elements[i]); - } - if (ax->elements) free(ax->elements); -} diff --git a/src/ax.h b/src/ax.h deleted file mode 100644 index bc9d375..0000000 --- a/src/ax.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include - -struct ax { - bool is_privileged; - - uint32_t element_count; - AXUIElementRef* elements; -}; - -struct ax g_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);