mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-09-20 14:01:56 +00:00
fix some more scaling problems with app icon images
This commit is contained in:
parent
10f6a110c4
commit
dc73334f4b
2 changed files with 10 additions and 2 deletions
|
@ -40,6 +40,7 @@ bool image_load(struct image* image, char* path, FILE* rsp) {
|
|||
if (app_kv.key && app_kv.value && strcmp(app_kv.key, "app") == 0) {
|
||||
CGImageRef app_icon = workspace_icon_for_app(app_kv.value);
|
||||
scale = workspace_get_scale();
|
||||
scale *= scale;
|
||||
if (app_icon) new_image_ref = app_icon;
|
||||
else {
|
||||
respond(rsp, "[!] Image: Invalid application name: '%s'\n", app_kv.value);
|
||||
|
|
|
@ -9,7 +9,14 @@
|
|||
@end
|
||||
|
||||
float workspace_get_scale() {
|
||||
return [[NSScreen mainScreen] backingScaleFactor];
|
||||
float scale = 1.f;
|
||||
NSArray* screens = [NSScreen screens];
|
||||
for (int i = 0; i < [screens count]; i++) {
|
||||
NSScreen* screen = screens[i];
|
||||
float screen_scale = [screen backingScaleFactor];
|
||||
if (screen_scale > scale) scale = screen_scale;
|
||||
}
|
||||
return scale;
|
||||
}
|
||||
|
||||
void workspace_event_handler_init(void **context) {
|
||||
|
@ -74,7 +81,7 @@ CGImageRef workspace_icon_for_app(char* app) {
|
|||
if (!image) return NULL;
|
||||
|
||||
float scale = workspace_get_scale();
|
||||
NSRect rect = NSMakeRect( 0, 0, 16 * scale, 16 * scale);
|
||||
NSRect rect = NSMakeRect( 0, 0, 32 * scale, 32 * scale);
|
||||
return (CGImageRef)CFRetain([image CGImageForProposedRect: &rect
|
||||
context: NULL
|
||||
hints: NULL]);
|
||||
|
|
Loading…
Reference in a new issue