Skip to content

Commit

Permalink
#1887 rework window layer system
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Oct 10, 2023
1 parent 8c04df4 commit 015d704
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/border.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void border_create(struct window *window)
sls_window_disable_shadow(window->border.id);
SLSSetWindowResolution(g_connection, window->border.id, g_window_manager.border_resolution);
SLSSetWindowOpacity(g_connection, window->border.id, 0);
SLSSetWindowLevel(g_connection, window->border.id, window_level(window));
SLSSetWindowLevel(g_connection, window->border.id, window_level(window->id));

if (g_window_manager.border_blur) {
SLSSetWindowBackgroundBlurRadiusStyle(g_connection, window->border.id, 24, 1);
Expand Down
8 changes: 3 additions & 5 deletions src/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,7 @@ static EVENT_HANDLER(SLS_WINDOW_ORDER_CHANGED)

struct border *border = &window->border;
if (border->id && border_should_order_in(window)) {
int window_level = 0;
SLSGetWindowLevel(g_connection, window_id, &window_level);
SLSSetWindowLevel(g_connection, border->id, window_level);
SLSSetWindowLevel(g_connection, border->id, window_level(window_id));
SLSOrderWindow(g_connection, border->id, -1, window_id);
}
}
Expand Down Expand Up @@ -1214,8 +1212,8 @@ static EVENT_HANDLER(MOUSE_MOVED)
struct window *sub_window = window_manager_find_window(&g_window_manager, wid);
if (!sub_window) continue;

if (!window_check_flag(sub_window, WINDOW_FLOAT)) continue;
if (window_level(sub_window) != g_layer_below_window_level) continue;
if (!window_check_flag(sub_window, WINDOW_FLOAT)) continue;
if (window_level(sub_window->id) != g_layer_below_window_level) continue;

if (CGRectContainsRect(window->frame, sub_window->frame)) {
occludes_window = true;
Expand Down
2 changes: 1 addition & 1 deletion src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void insert_feedback_show(struct window_node *node)
sls_window_disable_shadow(node->feedback_window.id);
SLSSetWindowResolution(g_connection, node->feedback_window.id, 2.0f);
SLSSetWindowOpacity(g_connection, node->feedback_window.id, 0);
SLSSetWindowLevel(g_connection, node->feedback_window.id, g_layer_above_window_level);
SLSSetWindowLevel(g_connection, node->feedback_window.id, g_layer_below_window_level);
node->feedback_window.context = SLWindowContextCreate(g_connection, node->feedback_window.id, 0);
CGContextSetLineWidth(node->feedback_window.context, g_window_manager.border_width);
CGContextSetRGBFillColor(node->feedback_window.context,
Expand Down
10 changes: 5 additions & 5 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void window_serialize(FILE *rsp, struct window *window)
uint64_t sid = window_space(window);
int space = space_manager_mission_control_index(sid);
int display = display_arrangement(space_display_id(sid));
int level = window_level(window);
int level = window_level(window->id);
const char *layer = window_layer(level);
bool is_minimized = window_is_minimized(window);
bool visible = !is_minimized && !window->application->is_hidden && (window_check_flag(window, WINDOW_STICKY) || space_is_visible(sid));
Expand Down Expand Up @@ -341,12 +341,12 @@ float window_opacity(struct window *window)
return alpha;
}

int window_level(struct window *window)
int window_level(uint32_t wid)
{
int level = 0;

if (workspace_is_macos_ventura() || workspace_is_macos_sonoma()) {
CFArrayRef window_ref = cfarray_of_cfnumbers(&window->id, sizeof(uint32_t), 1, kCFNumberSInt32Type);
CFArrayRef window_ref = cfarray_of_cfnumbers(&wid, sizeof(uint32_t), 1, kCFNumberSInt32Type);

CFTypeRef query = SLSWindowQueryWindows(g_connection, window_ref, 1);
if (!query) goto err2;
Expand All @@ -364,7 +364,7 @@ int window_level(struct window *window)
err2:
CFRelease(window_ref);
} else {
SLSGetWindowLevel(g_connection, window->id, &level);
SLSGetWindowLevel(g_connection, wid, &level);
}

return level;
Expand Down Expand Up @@ -429,7 +429,7 @@ char *window_subrole_ts(struct window *window)

bool window_level_is_standard(struct window *window)
{
int level = window_level(window);
int level = window_level(window->id);
if (level == g_layer_below_window_level) return true;
if (level == g_layer_normal_window_level) return true;
if (level == g_layer_above_window_level) return true;
Expand Down
2 changes: 1 addition & 1 deletion src/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ char *window_title_ts(struct window *window);
CGPoint window_ax_origin(struct window *window);
CGRect window_ax_frame(struct window *window);
float window_opacity(struct window *window);
int window_level(struct window *window);
int window_level(uint32_t wid);
uint64_t window_tags(struct window *window);
CFStringRef window_role(struct window *window);
char *window_role_ts(struct window *window);
Expand Down
2 changes: 1 addition & 1 deletion src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ void window_manager_animate_window_list_async(struct window_capture *window_list

window_manager_destroy_window_proxy(context->animation_connection, &existing_animation->proxy);
} else {
SLSGetWindowLevel(context->animation_connection, context->animation_list[i].wid, &context->animation_list[i].proxy.level);
context->animation_list[i].proxy.level = window_level(context->animation_list[i].wid);
SLSGetWindowBounds(context->animation_connection, context->animation_list[i].wid, &context->animation_list[i].proxy.frame);
context->animation_list[i].proxy.image = SLSHWCaptureWindowList(context->animation_connection, &context->animation_list[i].wid, 1, (1 << 11) | (1 << 8));
window_manager_create_window_proxy(context->animation_connection, &context->animation_list[i].proxy);
Expand Down

0 comments on commit 015d704

Please sign in to comment.