crispy rendering

This commit is contained in:
FelixKratz 2021-09-21 11:19:58 +02:00
parent ce04676ea0
commit 0460c00b96
3 changed files with 13 additions and 4 deletions

View file

@ -6,7 +6,7 @@
//extern CFArrayRef SLSHWCaptureWindowList(uint32_t cid, uint32_t* wid, uint32_t count, uint32_t flags); //extern CFArrayRef SLSHWCaptureWindowList(uint32_t cid, uint32_t* wid, uint32_t count, uint32_t flags);
void print_all_menu_items() { void print_all_menu_items() {
CFArrayRef window_list = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); CFArrayRef window_list = CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID);
int window_count = CFArrayGetCount(window_list); int window_count = CFArrayGetCount(window_list);
for (int i = 0; i < window_count; ++i) { for (int i = 0; i < window_count; ++i) {
@ -14,20 +14,24 @@ void print_all_menu_items() {
if (!dictionary) continue; if (!dictionary) continue;
CFStringRef owner_ref = CFDictionaryGetValue(dictionary, kCGWindowOwnerName); CFStringRef owner_ref = CFDictionaryGetValue(dictionary, kCGWindowOwnerName);
CFNumberRef owner_pid_ref = CFDictionaryGetValue(dictionary, kCGWindowOwnerPID);
CFStringRef name_ref = CFDictionaryGetValue(dictionary, kCGWindowName); CFStringRef name_ref = CFDictionaryGetValue(dictionary, kCGWindowName);
if (!name_ref) continue; if (!name_ref) continue;
if (!owner_ref) continue; if (!owner_ref) continue;
if (!owner_pid_ref) continue;
CFNumberRef layer_ref = CFDictionaryGetValue(dictionary, kCGWindowLayer); CFNumberRef layer_ref = CFDictionaryGetValue(dictionary, kCGWindowLayer);
if (!layer_ref) continue; if (!layer_ref) continue;
uint64_t layer = 0; uint64_t layer = 0;
CFNumberGetValue(layer_ref, CFNumberGetType(layer_ref), &layer); CFNumberGetValue(layer_ref, CFNumberGetType(layer_ref), &layer);
uint64_t owner_pid = 0;
CFNumberGetValue(owner_pid_ref, CFNumberGetType(owner_pid_ref), &owner_pid);
if (layer != MENUBAR_LAYER) continue; if (layer != MENUBAR_LAYER) continue;
char* owner = cfstring_copy(owner_ref); char* owner = cfstring_copy(owner_ref);
char* name = cfstring_copy(name_ref); char* name = cfstring_copy(name_ref);
printf("Menu Item -> Owner: %s, Name: %s \n", owner, name); printf("Menu Item -> Owner: %s; with PID:%llu, Name: %s \n", owner, owner_pid, name);
free(owner); free(owner);
free(name); free(name);
@ -50,7 +54,7 @@ void alias_init(struct alias* alias, char* owner, char* name) {
} }
void alias_find_window(struct alias* alias) { void alias_find_window(struct alias* alias) {
CFArrayRef window_list = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); CFArrayRef window_list = CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID);
int window_count = CFArrayGetCount(window_list); int window_count = CFArrayGetCount(window_list);
for (int i = 0; i < window_count; ++i) { for (int i = 0; i < window_count; ++i) {
@ -58,6 +62,7 @@ void alias_find_window(struct alias* alias) {
if (!dictionary) continue; if (!dictionary) continue;
CFStringRef owner_ref = CFDictionaryGetValue(dictionary, kCGWindowOwnerName); CFStringRef owner_ref = CFDictionaryGetValue(dictionary, kCGWindowOwnerName);
CFNumberRef owner_pid_ref = CFDictionaryGetValue(dictionary, kCGWindowOwnerPID);
CFStringRef name_ref = CFDictionaryGetValue(dictionary, kCGWindowName); CFStringRef name_ref = CFDictionaryGetValue(dictionary, kCGWindowName);
if (!name_ref) continue; if (!name_ref) continue;
if (!owner_ref) continue; if (!owner_ref) continue;
@ -75,6 +80,8 @@ void alias_find_window(struct alias* alias) {
CFNumberGetValue(layer_ref, CFNumberGetType(layer_ref), &layer); CFNumberGetValue(layer_ref, CFNumberGetType(layer_ref), &layer);
if (layer != MENUBAR_LAYER) continue; if (layer != MENUBAR_LAYER) continue;
CFNumberGetValue(owner_pid_ref, CFNumberGetType(owner_pid_ref), &alias->pid);
CFNumberRef window_id_ref = CFDictionaryGetValue(dictionary, kCGWindowNumber); CFNumberRef window_id_ref = CFDictionaryGetValue(dictionary, kCGWindowNumber);
if (!window_id_ref) continue; if (!window_id_ref) continue;
CFNumberGetValue(window_id_ref, CFNumberGetType(window_id_ref), &alias->wid); CFNumberGetValue(window_id_ref, CFNumberGetType(window_id_ref), &alias->wid);
@ -105,7 +112,7 @@ bool alias_update_image(struct alias* alias) {
}*/ }*/
alias->image_ref = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, alias->image_ref = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow,
alias->wid, kCGWindowImageBestResolution); alias->wid, kCGWindowImageBestResolution | kCGWindowImageBoundsIgnoreFraming);
if (!alias->image_ref) { if (!alias->image_ref) {
alias->size.x = 0; alias->size.x = 0;
alias->size.y = 0; alias->size.y = 0;

View file

@ -8,6 +8,7 @@ struct alias {
bool permission; bool permission;
char* name; char* name;
char* owner; char* owner;
uint64_t pid;
uint32_t wid; uint32_t wid;
CGImageRef image_ref; CGImageRef image_ref;
CGPoint size; CGPoint size;

View file

@ -315,6 +315,7 @@ struct bar *bar_create(uint32_t did) {
SLSSetMouseEventEnableFlags(g_connection, bar->id, false); SLSSetMouseEventEnableFlags(g_connection, bar->id, false);
SLSSetWindowLevel(g_connection, bar->id, g_bar_manager.window_level); SLSSetWindowLevel(g_connection, bar->id, g_bar_manager.window_level);
bar->context = SLWindowContextCreate(g_connection, bar->id, 0); bar->context = SLWindowContextCreate(g_connection, bar->id, 0);
CGContextSetInterpolationQuality(bar->context, kCGInterpolationNone);
return bar; return bar;
} }