From bfadff61d2554b153d973b3cf150420ca60a4143 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 2 Nov 2024 11:56:01 +0100 Subject: Force window always on top, even if restacking order changes --- src/Overlay.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/Overlay.cpp') diff --git a/src/Overlay.cpp b/src/Overlay.cpp index a76a054..58ac325 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -28,6 +28,9 @@ extern "C" { } namespace gsr { + static const mgl::Color bg_color(0, 0, 0, 100); + static const double force_window_on_top_timeout_seconds = 1.0; + static mgl::Texture texture_from_ximage(XImage *img) { uint8_t *texture_data = (uint8_t*)malloc(img->width * img->height * 3); // TODO: @@ -185,11 +188,10 @@ namespace gsr { return XGetSelectionOwner(dpy, prop_atom) != None; } - Overlay::Overlay(std::string resources_path, GsrInfo gsr_info, egl_functions egl_funcs, mgl::Color bg_color) : + Overlay::Overlay(std::string resources_path, GsrInfo gsr_info, egl_functions egl_funcs) : resources_path(std::move(resources_path)), gsr_info(gsr_info), egl_funcs(egl_funcs), - bg_color(bg_color), bg_screenshot_overlay({0.0f, 0.0f}), top_bar_background({0.0f, 0.0f}), close_button_widget({0.0f, 0.0f}), @@ -297,6 +299,8 @@ namespace gsr { if(!window) return false; + force_window_on_top(); + window->clear(bg_color); if(window_texture_sprite.get_texture() && window_texture.texture_id) { @@ -1291,4 +1295,15 @@ namespace gsr { return true; } + + void Overlay::force_window_on_top() { + if(force_window_on_top_clock.get_elapsed_time_seconds() >= force_window_on_top_timeout_seconds) { + force_window_on_top_clock.restart(); + + mgl_context *context = mgl_get_context(); + Display *display = (Display*)context->connection; + XRaiseWindow(display, window->get_system_handle()); + XFlush(display); + } + } } \ No newline at end of file -- cgit v1.2.3