Wayland: only show ui after stupid fullscreen animation has stopped

This commit is contained in:
dec05eba
2025-01-19 12:35:08 +01:00
parent 0d6d7a7459
commit 92401d8bc8
2 changed files with 48 additions and 25 deletions

View File

@@ -170,5 +170,8 @@ namespace gsr {
mgl::vec2i window_size = { 1280, 720 };
mgl::vec2i window_pos = { 0, 0 };
mgl::Clock show_overlay_clock;
double show_overlay_timeout_seconds = 0.0;
};
}

View File

@@ -584,8 +584,11 @@ namespace gsr {
//force_window_on_top();
window->clear(bg_color);
const bool draw_ui = show_overlay_clock.get_elapsed_time_seconds() >= show_overlay_timeout_seconds;
window->clear(draw_ui ? bg_color : mgl::Color(0, 0, 0, 0));
if(draw_ui) {
if(window_texture_sprite.get_texture() && window_texture.texture_id) {
window->draw(window_texture_sprite);
window->draw(bg_screenshot_overlay);
@@ -606,8 +609,6 @@ namespace gsr {
window->draw(cursor_sprite);
}
window->display();
if(!drawn_first_frame) {
drawn_first_frame = true;
mgl::Event event;
@@ -616,6 +617,9 @@ namespace gsr {
event.mouse_move.y = window->get_mouse_position().y;
on_event(event);
}
}
window->display();
return true;
}
@@ -774,6 +778,8 @@ namespace gsr {
if(!window->create("gsr ui", window_create_params))
fprintf(stderr, "error: failed to create window\n");
//window->set_low_latency(true);
unsigned char data = 2; // Prefer being composed to allow transparency
XChangeProperty(display, window->get_system_handle(), XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False), XA_CARDINAL, 32, PropModeReplace, &data, 1);
@@ -1030,6 +1036,10 @@ namespace gsr {
if(paused)
update_ui_recording_paused();
show_overlay_timeout_seconds = prevent_game_minimizing ? 0.0 : 0.15;
show_overlay_clock.restart();
draw();
}
void Overlay::hide() {
@@ -1093,6 +1103,16 @@ namespace gsr {
}
if(window) {
if(show_overlay_timeout_seconds > 0.0001) {
window->clear(mgl::Color(0, 0, 0, 0));
window->display();
mgl_context *context = mgl_get_context();
context->gl.glFlush();
context->gl.glFinish();
usleep(50 * 1000); // EGL doesn't do an immediate flush for some reason
}
window->set_visible(false);
window.reset();
}