diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-01-29 23:20:46 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-01-29 23:20:46 +0100 |
commit | 3092718388433b6a8762a88db8141e09f3289a67 (patch) | |
tree | 5cca6de6a1406e7d5c474d3f17257ba270e60c88 /src | |
parent | 219b6f0c6983e7e98b17ab0da3ed2729181fce8d (diff) |
Show error when trying to capture window that no longer exists
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index e12958e..6c41e14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1711,6 +1711,16 @@ static void debug_print_args(const char **args) { fprintf(stderr, "\n"); } +static bool validate_window(GtkApplication *app, Window window) { + XWindowAttributes attr; + if(XGetWindowAttributes(dpy, window, &attr)) { + return true; + } else { + show_notification(app, "GPU Screen Recorder", "The window you are trying to record no longer exists", G_NOTIFICATION_PRIORITY_URGENT); + return false; + } +} + static gboolean on_start_replay_button_click(GtkButton *button, gpointer userdata) { GtkApplication *app = (GtkApplication*)userdata; const gchar *dir = gtk_button_get_label(replay_file_chooser_button); @@ -1772,6 +1782,8 @@ static gboolean on_start_replay_button_click(GtkButton *button, gpointer userdat return true; } window_str = std::to_string(select_window_userdata.selected_window); + if(!validate_window(app, select_window_userdata.selected_window)) + return true; } else if(window_str == "focused") { follow_focused = true; } @@ -1968,6 +1980,8 @@ static gboolean on_start_recording_button_click(GtkButton *button, gpointer user return true; } window_str = std::to_string(select_window_userdata.selected_window); + if(!validate_window(app, select_window_userdata.selected_window)) + return true; } else if(window_str == "focused") { follow_focused = true; } @@ -2130,6 +2144,8 @@ static gboolean on_start_streaming_button_click(GtkButton *button, gpointer user return true; } window_str = std::to_string(select_window_userdata.selected_window); + if(!validate_window(app, select_window_userdata.selected_window)) + return true; } else if(window_str == "focused") { follow_focused = true; } |