Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/platform/wayland_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace bongocat::platform::wayland {
// max. windows to track for fullscreen detection
inline static constexpr size_t MAX_TOP_LEVELS = 128;
inline static constexpr size_t MAX_TOP_LEVELS = 512;
inline static constexpr size_t MAX_OUTPUTS = 8; // Maximum monitor outputs to store
inline static constexpr size_t OUTPUT_NAME_SIZE = 128;

Expand Down
33 changes: 15 additions & 18 deletions src/graphics/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3862,8 +3862,8 @@ anim_custom_idle_next_frame(animation_thread_context_t& ctx, const platform::inp
if (conditions.is_moving) {
if (conditions.go_next_frame) {
animation_result = anim_custom_start_or_process_animation(
ctx, animation_state_row_t::FallASleepIdle, animation_state_row_t::IdleSleep, new_animation_result,
new_state, current_state, current_frames, current_config);
ctx, animation_state_row_t::FallASleepIdle, animation_state_row_t::IdleSleep,
new_animation_result, new_state, current_state, current_frames, current_config);
}
} else {
animation_result = anim_custom_restart_animation(
Expand Down Expand Up @@ -4356,14 +4356,12 @@ static anim_next_frame_result_t anim_custom_working_next_frame(animation_thread_
if (animation_result.row_state != animation_state_row_t::IdleSleep) {
ctx.shm->last_wakeup_timestamp = platform::get_current_time_ms();
}
BONGOCAT_LOG_VERBOSE("Start Working: %d %d; %d%%", above_threshold, lower_threshold,
update_shm.avg_cpu_usage);
BONGOCAT_LOG_VERBOSE("Start Working: %d %d; %d%%", above_threshold, lower_threshold, update_shm.avg_cpu_usage);
} else if (start_above_threshold && conditions.ready_to_work) {
anim_custom_restart_animation(ctx, animation_state_row_t::StartWorking, animation_state_row_t::Working,
animation_state_row_t::EndWorking, new_animation_result, new_state,
current_state, current_frames, current_config);
BONGOCAT_LOG_VERBOSE("Start Working: %d %d; %d%%", above_threshold, lower_threshold,
update_shm.avg_cpu_usage);
animation_state_row_t::EndWorking, new_animation_result, new_state, current_state,
current_frames, current_config);
BONGOCAT_LOG_VERBOSE("Start Working: %d %d; %d%%", above_threshold, lower_threshold, update_shm.avg_cpu_usage);
} else if (above_threshold) {
if (conditions.is_working) {
if (update_shm.cpu_active && current_state.row_state == animation_state_row_t::StartWorking) {
Expand Down Expand Up @@ -4464,21 +4462,20 @@ static anim_next_frame_result_t anim_custom_running_next_frame(animation_thread_

if (start_above_threshold && conditions.ready_to_work) {
anim_custom_restart_animation(ctx, animation_state_row_t::StartRunning, animation_state_row_t::Running,
animation_state_row_t::EndRunning, new_animation_result, new_state,
current_state, current_frames, current_config);
BONGOCAT_LOG_VERBOSE("Start Running: %d %d; %d%%", above_threshold, lower_threshold,
update_shm.avg_cpu_usage);
animation_state_row_t::EndRunning, new_animation_result, new_state, current_state,
current_frames, current_config);
BONGOCAT_LOG_VERBOSE("Start Running: %d %d; %d%%", above_threshold, lower_threshold, update_shm.avg_cpu_usage);
} else if (above_threshold && conditions.is_running) {
if (update_shm.cpu_active && current_state.row_state == animation_state_row_t::StartRunning) {
anim_custom_start_or_process_animation(ctx, animation_state_row_t::Running,
animation_state_row_t::EndRunning, new_animation_result, new_state,
current_state, current_frames, current_config);
anim_custom_start_or_process_animation(ctx, animation_state_row_t::Running, animation_state_row_t::EndRunning,
new_animation_result, new_state, current_state, current_frames,
current_config);
} else if (!update_shm.cpu_active && (current_state.row_state == animation_state_row_t::StartRunning ||
state.row_state == animation_state_row_t::Running)) {
// end running, cool down
anim_custom_start_or_process_animation(ctx, animation_state_row_t::EndRunning,
animation_state_row_t::Running, new_animation_result, new_state,
current_state, current_frames, current_config);
anim_custom_start_or_process_animation(ctx, animation_state_row_t::EndRunning, animation_state_row_t::Running,
new_animation_result, new_state, current_state, current_frames,
current_config);
} else if (!update_shm.cpu_active && current_state.row_state == animation_state_row_t::EndRunning) {
// back to idle
anim_custom_start_or_process_animation(ctx, animation_state_row_t::Idle, new_animation_result, new_state,
Expand Down
4 changes: 3 additions & 1 deletion src/graphics/bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,9 @@ static bool draw_bar_on_buffer(platform::wayland::wayland_context_t& ctx,
}
/// @TODO: add option for disablen/enablen alpha threshold
overwrite_drawing_options =
current_config.enable_antialiasing >= 1 ? flag_add(overwrite_drawing_options, draw_sprite_overwrite_option_t::DisableThresholdAlpha) : flag_remove(overwrite_drawing_options, draw_sprite_overwrite_option_t::DisableThresholdAlpha);
current_config.enable_antialiasing >= 1
? flag_add(overwrite_drawing_options, draw_sprite_overwrite_option_t::DisableThresholdAlpha)
: flag_remove(overwrite_drawing_options, draw_sprite_overwrite_option_t::DisableThresholdAlpha);

draw_sprite(ctx, shm_buffer, sheet, col, row, overwrite_drawing_options);
}
Expand Down
4 changes: 2 additions & 2 deletions src/graphics/drawing_images.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ void blit_image_scaled(uint8_t *dest, size_t dest_size, int dest_w, int dest_h,
const drawing_get_pixel_result_t pixel =
(is_downscaling) ? drawing_get_box_filtered_pixel(src, src_size, src_w, src_h, src_channels, fx, fy)
: drawing_get_interpolated_pixel(src, src_size, src_w, src_h, src_channels, fx, fy);
drawing_blend_pixel(dest, dest_channels, dest_idx, pixel.r, pixel.g, pixel.b, pixel.a, 4, options, dest_order,
blit_image_color_order_t::RGBA);
drawing_blend_pixel(dest, dest_channels, dest_idx, pixel.r, pixel.g, pixel.b, pixel.a, 4, options,
dest_order, blit_image_color_order_t::RGBA);
}
}
} else {
Expand Down
35 changes: 20 additions & 15 deletions src/platform/wayland_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,21 @@ namespace hyprland {
static int fs_update_state(wayland_context_t& ctx) {
if (wayland::hyprland::window_info_t win; wayland::hyprland::get_active_window(win)) {
bool find_output = false;
wl_output *found_wl_output = nullptr;
for (size_t i = 0; i < ctx.output_count; i++) {
if (ctx.outputs[i].hypr_id == win.monitor_id) {
if (ctx.thread_context.output == ctx.outputs[i].wl_output) {
found_wl_output = ctx.outputs[i].wl_output;
find_output = true;
break;
}
}
}
if (find_output) {
details::fs_update_state(ctx, { .is_fullscreen = win.fullscreen, .is_activated = true });
return win.fullscreen ? 1 : 0;
if (find_output && ctx.thread_context.output == found_wl_output) {
details::fs_update_state(ctx, {.is_fullscreen = win.fullscreen, .is_activated = true});
return win.fullscreen ? 2 : 1;
}

details::fs_update_state(ctx, { .is_fullscreen = false, .is_activated = true });
return 0;
}

Expand Down Expand Up @@ -263,15 +264,15 @@ void fs_update_state_fallback(wayland_context_t& ctx) {
if (tracked.is_fullscreen) {
// Only update overlay if on our output
if (tracked.output == ctx.thread_context.output) {
fs_update_state(ctx, { .is_fullscreen = true, .is_activated = true });
fs_update_state(ctx, {.is_fullscreen = true, .is_activated = true});
return;
}
}
}

const bool new_fullscreen = fs_check_status(ctx);
if (new_fullscreen != ctx.thread_context._fullscreen_detected) {
fs_update_state(ctx, { .is_fullscreen = new_fullscreen, .is_activated = true });
fs_update_state(ctx, {.is_fullscreen = new_fullscreen, .is_activated = true});
}
}

Expand All @@ -280,7 +281,8 @@ struct update_fullscreen_state_toplevel_result_t {
bool changed{false};
};
static update_fullscreen_state_toplevel_result_t
update_fullscreen_state_toplevel(wayland_context_t& ctx, tracked_toplevel_t& tracked, update_fullscreen_state_toplevel_state_t state) {
update_fullscreen_state_toplevel(wayland_context_t& ctx, tracked_toplevel_t& tracked,
update_fullscreen_state_toplevel_state_t state) {
bool state_changed = tracked.is_fullscreen != state.is_fullscreen || tracked.is_activated != state.is_activated;
tracked.is_fullscreen = state.is_fullscreen;
tracked.is_activated = state.is_activated;
Expand All @@ -289,8 +291,8 @@ update_fullscreen_state_toplevel(wayland_context_t& ctx, tracked_toplevel_t& tra
// Only trigger overlay update if this fullscreen window is on our output
if (tracked.output == ctx.thread_context.output && state_changed) {
state_changed = fs_update_state(ctx, state);
BONGOCAT_LOG_VERBOSE("Fullscreen state updated for window %p: (fullscreen=%d;activated=%d)", static_cast<void *>(tracked.handle),
state.is_fullscreen, state.is_activated);
BONGOCAT_LOG_VERBOSE("Fullscreen state updated for window %p: (fullscreen=%d;activated=%d)",
static_cast<void *>(tracked.handle), state.is_fullscreen, state.is_activated);
return {.output_found = true, .changed = state_changed};
}

Expand Down Expand Up @@ -325,10 +327,12 @@ void fs_handle_toplevel_state(void *data, [[maybe_unused]] zwlr_foreign_toplevel
/// @NOTE: tracked.output can always be NULL when no output.enter/output.leave event were triggert
for (size_t i = 0; i < ctx.num_toplevels; ++i) {
if (ctx.tracked_toplevels[i].handle == handle) {
auto [output_found, changed] = update_fullscreen_state_toplevel(ctx, ctx.tracked_toplevels[i], { .is_fullscreen = is_fullscreen, .is_activated = is_activated });
auto [output_found, changed] = update_fullscreen_state_toplevel(
ctx, ctx.tracked_toplevels[i], {.is_fullscreen = is_fullscreen, .is_activated = is_activated});
if (output_found) {
if (changed) {
BONGOCAT_LOG_VERBOSE("fs_handle_toplevel.state: Update fullscreen state: (fullscreen=%d;activated=%d)", is_fullscreen, is_activated);
BONGOCAT_LOG_VERBOSE("fs_handle_toplevel.state: Update fullscreen state: (fullscreen=%d;activated=%d)",
is_fullscreen, is_activated);
}
return;
}
Expand All @@ -342,9 +346,10 @@ void fs_handle_toplevel_state(void *data, [[maybe_unused]] zwlr_foreign_toplevel
}

// Fallback for when no toplevel was found
const bool changed = fs_update_state(ctx, { .is_fullscreen = is_fullscreen, .is_activated = is_activated });
const bool changed = fs_update_state(ctx, {.is_fullscreen = is_fullscreen, .is_activated = is_activated});
if (changed) {
BONGOCAT_LOG_VERBOSE("fs_handle_toplevel.state: Update fullscreen state: (fullscreen=%d;activated=%d)", is_fullscreen, is_activated);
BONGOCAT_LOG_VERBOSE("fs_handle_toplevel.state: Update fullscreen state: (fullscreen=%d;activated=%d)",
is_fullscreen, is_activated);
}
}

Expand Down Expand Up @@ -417,7 +422,7 @@ void fs_handle_output_enter(void *data, [[maybe_unused]] zwlr_foreign_toplevel_h
tracked.output = output;
if (tracked.is_fullscreen) {
if (tracked.output == ctx.thread_context.output) {
fs_update_state(ctx, { .is_fullscreen = true, .is_activated = true });
fs_update_state(ctx, {.is_fullscreen = true, .is_activated = true});
}
}
break;
Expand All @@ -440,7 +445,7 @@ void fs_handle_output_leave(void *data, [[maybe_unused]] zwlr_foreign_toplevel_h
if (tracked.handle == handle && tracked.output == output) {
BONGOCAT_LOG_VERBOSE("fs_toplevel_listener.output_leave: update tracked_toplevels[%i] output", i);
if (tracked.is_fullscreen && tracked.output == ctx.thread_context.output) {
fs_update_state(ctx, { .is_fullscreen = false, .is_activated = false });
fs_update_state(ctx, {.is_fullscreen = false, .is_activated = false});
}
tracked.output = BONGOCAT_NULLPTR;
break;
Expand Down