mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-23 20:03:10 +00:00
use original window bounds to draw image
This commit is contained in:
parent
6170ff34f7
commit
53ea4c913c
3 changed files with 6 additions and 2 deletions
|
@ -87,6 +87,9 @@ void alias_find_window(struct alias* alias) {
|
|||
|
||||
CFNumberRef window_id_ref = CFDictionaryGetValue(dictionary, kCGWindowNumber);
|
||||
if (!window_id_ref) continue;
|
||||
CFDictionaryRef bounds = CFDictionaryGetValue(dictionary, kCGWindowBounds);
|
||||
if (!bounds) continue;
|
||||
CGRectMakeWithDictionaryRepresentation(bounds, &alias->bounds);
|
||||
CFNumberGetValue(window_id_ref, CFNumberGetType(window_id_ref), &alias->wid);
|
||||
|
||||
CFRelease(window_list);
|
||||
|
@ -113,7 +116,7 @@ bool alias_update_image(struct alias* alias) {
|
|||
else {
|
||||
tmp_ref = NULL;
|
||||
}*/
|
||||
SLSCaptureWindowsContentsToRectWithOptions(g_connection, &alias->wid, true, CGRectNull, 1 << 9 | 1 << 11, &tmp_ref);
|
||||
SLSCaptureWindowsContentsToRectWithOptions(g_connection, &alias->wid, true, CGRectNull, 1 << 8, &tmp_ref);
|
||||
|
||||
//CGImageRef tmp_ref = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow,
|
||||
// alias->wid, kCGWindowImageBestResolution | kCGWindowImageBoundsIgnoreFraming);
|
||||
|
|
|
@ -12,6 +12,7 @@ struct alias {
|
|||
uint32_t wid;
|
||||
CGImageRef image_ref;
|
||||
CGPoint size;
|
||||
CGRect bounds;
|
||||
};
|
||||
|
||||
void print_all_menu_items();
|
||||
|
|
|
@ -158,7 +158,7 @@ void bar_draw_item_background(struct bar* bar, struct bar_item* bar_item, uint32
|
|||
|
||||
void bar_draw_alias(struct bar* bar, struct bar_item* bar_item, uint32_t x) {
|
||||
if (!bar_item->has_alias || !bar_item->alias.image_ref) return;
|
||||
CGRect bounds = {{x, (bar->frame.size.height - bar_item->alias.size.y) / 2},{bar_item->alias.size.x, bar_item->alias.size.y}};
|
||||
CGRect bounds = {{x, (bar->frame.size.height - bar_item->alias.bounds.size.height) / 2},{bar_item->alias.bounds.size.width, bar_item->alias.bounds.size.height}};
|
||||
CGContextDrawImage(bar->context, bounds, bar_item->alias.image_ref);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue