aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-11-02 11:56:01 +0100
committerdec05eba <dec05eba@protonmail.com>2024-11-02 11:56:01 +0100
commitbfadff61d2554b153d973b3cf150420ca60a4143 (patch)
tree24b948532a1987c8a7b2894f97a4184a6a712e81 /src
parent6fbd8b0dd369c704b21c8757c1f66e55dcf1cb91 (diff)
Force window always on top, even if restacking order changes
Diffstat (limited to 'src')
-rw-r--r--src/Overlay.cpp19
-rw-r--r--src/gui/SettingsPage.cpp2
-rw-r--r--src/main.cpp8
3 files changed, 19 insertions, 10 deletions
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
diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp
index 2ee1114..bf68500 100644
--- a/src/gui/SettingsPage.cpp
+++ b/src/gui/SettingsPage.cpp
@@ -526,7 +526,7 @@ namespace gsr {
}
std::unique_ptr<CheckBox> SettingsPage::create_start_replay_on_startup() {
- auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Start replay automatically");
+ auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Turn on replay automatically");
start_replay_automatically_ptr = checkbox.get();
return checkbox;
}
diff --git a/src/main.cpp b/src/main.cpp
index 51610aa..c64fd60 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,19 +15,13 @@
// TODO: Make keyboard controllable for steam deck (and other controllers).
// TODO: Keep track of gpu screen recorder run by other programs to not allow recording at the same time, or something.
-// TODO: Remove gpu-screen-recorder-overlay-daemon and handle that alt+z global hotkey here instead, to show/hide the window
-// without restaring the program. Or make the daemon handle gpu screen recorder program state and pass that to the overlay.
// TODO: Add systray by using org.kde.StatusNotifierWatcher/etc dbus directly.
-// TODO: Dont allow replay and record/stream at the same time. If we want to allow that then do that in gpu screen recorder instead
-// to make it more efficient by doing record/replay/stream with the same encoded packets.
// TODO: Make sure the overlay always stays on top. Test with starting the overlay and then opening youtube in fullscreen.
extern "C" {
#include <mgl/mgl.h>
}
-const mgl::Color bg_color(0, 0, 0, 100);
-
static sig_atomic_t running = 1;
static void sigint_handler(int signal) {
(void)signal;
@@ -99,7 +93,7 @@ int main(void) {
fprintf(stderr, "info: gsr ui is now ready, waiting for inputs. Press alt+z to show/hide the overlay\n");
- auto overlay = std::make_unique<gsr::Overlay>(resources_path, gsr_info, egl_funcs, bg_color);
+ auto overlay = std::make_unique<gsr::Overlay>(resources_path, gsr_info, egl_funcs);
//overlay.show();
gsr::GlobalHotkeysX11 global_hotkeys;