Remove (x11 applications only) from screenshot for kwin and hyprland

This commit is contained in:
dec05eba
2026-01-26 13:41:29 +01:00
parent b48c971a8b
commit 3a57167d54
6 changed files with 22 additions and 25 deletions

View File

@@ -290,5 +290,7 @@ namespace gsr {
ClipboardFile clipboard_file;
std::unique_ptr<LedIndicator> led_indicator = nullptr;
bool supports_window_title = false;
};
}

View File

@@ -16,7 +16,7 @@ namespace gsr {
class ScreenshotSettingsPage : public StaticPage {
public:
ScreenshotSettingsPage(const GsrInfo *gsr_info, Config &config, PageStack *page_stack);
ScreenshotSettingsPage(const GsrInfo *gsr_info, Config &config, PageStack *page_stack, bool supports_window_title);
ScreenshotSettingsPage(const ScreenshotSettingsPage&) = delete;
ScreenshotSettingsPage& operator=(const ScreenshotSettingsPage&) = delete;
@@ -85,5 +85,7 @@ namespace gsr {
Entry *create_custom_script_screenshot_entry_ptr = nullptr;
PageStack *page_stack = nullptr;
bool supports_window_title = false;
};
}

View File

@@ -41,7 +41,7 @@ namespace gsr {
STREAM
};
SettingsPage(Type type, const GsrInfo *gsr_info, Config &config, PageStack *page_stack);
SettingsPage(Type type, const GsrInfo *gsr_info, Config &config, PageStack *page_stack, bool supports_window_title);
SettingsPage(const SettingsPage&) = delete;
SettingsPage& operator=(const SettingsPage&) = delete;

View File

@@ -539,9 +539,10 @@ namespace gsr {
else
fprintf(stderr, "Warning: XOpenDisplay failed to mapping notify\n");
if(this->gsr_info.system_info.display_server == DisplayServer::X11)
if(this->gsr_info.system_info.display_server == DisplayServer::X11) {
cursor_tracker = std::make_unique<CursorTrackerX11>((Display*)mgl_get_context()->connection);
else if(this->gsr_info.system_info.display_server == DisplayServer::WAYLAND) {
supports_window_title = true;
} else if(this->gsr_info.system_info.display_server == DisplayServer::WAYLAND) {
if(!this->gsr_info.gpu_info.card_path.empty())
cursor_tracker = std::make_unique<CursorTrackerWayland>(this->gsr_info.gpu_info.card_path.c_str(), wayland_dpy);
@@ -555,8 +556,10 @@ namespace gsr {
if (wm_name.find("Hyprland") != std::string::npos) {
start_hyprland_listener_thread();
supports_window_title = true;
} else if (wm_name == "KWin") {
start_kwin_helper_thread();
supports_window_title = true;
}
}
@@ -1281,7 +1284,7 @@ namespace gsr {
button->set_item_icon("settings", &get_theme().settings_extra_small_texture);
button->on_click = [this](const std::string &id) {
if(id == "settings") {
auto replay_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::REPLAY, &gsr_info, config, &page_stack);
auto replay_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::REPLAY, &gsr_info, config, &page_stack, supports_window_title);
replay_settings_page->on_config_changed = [this]() {
replay_startup_mode = replay_startup_string_to_type(config.replay_config.turn_on_replay_automatically_mode.c_str());
if(recording_status == RecordingStatus::REPLAY)
@@ -1315,7 +1318,7 @@ namespace gsr {
button->set_item_icon("settings", &get_theme().settings_extra_small_texture);
button->on_click = [this](const std::string &id) {
if(id == "settings") {
auto record_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::RECORD, &gsr_info, config, &page_stack);
auto record_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::RECORD, &gsr_info, config, &page_stack, supports_window_title);
record_settings_page->on_config_changed = [this]() {
if(recording_status == RecordingStatus::RECORD)
show_notification("Recording settings have been modified.\nYou may need to restart recording to apply the changes.", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
@@ -1342,7 +1345,7 @@ namespace gsr {
button->set_item_icon("settings", &get_theme().settings_extra_small_texture);
button->on_click = [this](const std::string &id) {
if(id == "settings") {
auto stream_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::STREAM, &gsr_info, config, &page_stack);
auto stream_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::STREAM, &gsr_info, config, &page_stack, supports_window_title);
stream_settings_page->on_config_changed = [this]() {
if(recording_status == RecordingStatus::STREAM)
show_notification("Streaming settings have been modified.\nYou may need to restart streaming to apply the changes.", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
@@ -1429,7 +1432,7 @@ namespace gsr {
button->set_icon(&get_theme().screenshot_texture);
button->set_icon_padding_scale(1.2f);
button->on_click = [&]() {
auto screenshot_settings_page = std::make_unique<ScreenshotSettingsPage>(&gsr_info, config, &page_stack);
auto screenshot_settings_page = std::make_unique<ScreenshotSettingsPage>(&gsr_info, config, &page_stack, supports_window_title);
screenshot_settings_page->on_config_changed = [this]() {
update_led_indicator_after_settings_change();
};

View File

@@ -11,11 +11,12 @@
#include "../../include/gui/FileChooser.hpp"
namespace gsr {
ScreenshotSettingsPage::ScreenshotSettingsPage(const GsrInfo *gsr_info, Config &config, PageStack *page_stack) :
ScreenshotSettingsPage::ScreenshotSettingsPage(const GsrInfo *gsr_info, Config &config, PageStack *page_stack, bool supports_window_title) :
StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()),
config(config),
gsr_info(gsr_info),
page_stack(page_stack)
page_stack(page_stack),
supports_window_title(supports_window_title)
{
capture_options = get_supported_capture_options(*gsr_info);
@@ -209,7 +210,7 @@ namespace gsr {
std::unique_ptr<CheckBox> ScreenshotSettingsPage::create_save_screenshot_in_game_folder() {
char text[256];
snprintf(text, sizeof(text), "Save screenshot in a folder based on the focused applications name%s", gsr_info->system_info.display_server == DisplayServer::X11 ? "" : " (X11 applications only)");
snprintf(text, sizeof(text), "Save screenshot in a folder based on the focused applications name%s", supports_window_title ? "" : " (X11 applications only)");
auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, text);
save_screenshot_in_game_folder_checkbox_ptr = checkbox.get();
return checkbox;

View File

@@ -10,13 +10,9 @@
#include "../../include/Theme.hpp"
#include "../../include/GsrInfo.hpp"
#include "../../include/Utils.hpp"
#include "../../include/WindowUtils.hpp"
#include <mglpp/window/Window.hpp>
#include <mglpp/window/Event.hpp>
extern "C" {
#include <mgl/mgl.h>
}
#include <algorithm>
#include <cmath>
@@ -40,25 +36,18 @@ namespace gsr {
return "";
}
SettingsPage::SettingsPage(Type type, const GsrInfo *gsr_info, Config &config, PageStack *page_stack) :
SettingsPage::SettingsPage(Type type, const GsrInfo *gsr_info, Config &config, PageStack *page_stack, bool supports_window_title) :
StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()),
type(type),
config(config),
gsr_info(gsr_info),
page_stack(page_stack)
page_stack(page_stack),
supports_window_title(supports_window_title)
{
audio_devices = get_audio_devices();
application_audio = get_application_audio();
capture_options = get_supported_capture_options(*gsr_info);
mgl_context *context = mgl_get_context();
Display *display = (Display*)context->connection;
const std::string wm_name = get_window_manager_name(display);
const bool is_hyprland = wm_name.find("Hyprland") != std::string::npos;
const bool is_kwin = wm_name == "KWin";
supports_window_title = gsr_info->system_info.display_server == DisplayServer::X11 || is_hyprland || is_kwin;
auto content_page = std::make_unique<GsrPage>(settings_page_type_to_title_text(type), "Settings");
content_page->add_button("Back", "back", get_color_theme().page_bg_color);
content_page->on_click = [page_stack](const std::string &id) {