diff options
-rw-r--r-- | gsr-window-name/main.c | 39 | ||||
-rwxr-xr-x | scripts/save-video-in-game-folder.sh | 1 | ||||
-rw-r--r-- | src/Overlay.cpp | 9 | ||||
-rw-r--r-- | src/main.cpp | 2 |
4 files changed, 21 insertions, 30 deletions
diff --git a/gsr-window-name/main.c b/gsr-window-name/main.c index a46aff2..8ebf1e0 100644 --- a/gsr-window-name/main.c +++ b/gsr-window-name/main.c @@ -48,15 +48,17 @@ static Window get_focused_window(Display *dpy, capture_type cap_type) { Window focused_window = None; if(cap_type == CAPTURE_TYPE_FOCUSED) { - Atom type = None; - int format = 0; - unsigned long num_items = 0; - unsigned long bytes_left = 0; - unsigned char *data = NULL; - XGetWindowProperty(dpy, DefaultRootWindow(dpy), net_active_window_atom, 0, 1, False, XA_WINDOW, &type, &format, &num_items, &bytes_left, &data); + // Atom type = None; + // int format = 0; + // unsigned long num_items = 0; + // unsigned long bytes_left = 0; + // unsigned char *data = NULL; + // XGetWindowProperty(dpy, DefaultRootWindow(dpy), net_active_window_atom, 0, 1, False, XA_WINDOW, &type, &format, &num_items, &bytes_left, &data); - if(type == XA_WINDOW && num_items == 1 && data) - return *(Window*)data; + // fprintf(stderr, "focused window: %p\n", (void*)data); + + // if(type == XA_WINDOW && num_items == 1 && data) + // return *(Window*)data; int revert_to = 0; XGetInputFocus(dpy, &focused_window, &revert_to); @@ -99,10 +101,6 @@ static char* get_window_title(Display *dpy, Window window) { return NULL; } -static bool is_steam_game(Display *dpy, Window window) { - return window_has_atom(dpy, window, XInternAtom(dpy, "STEAM_GAME", False)); -} - static const char* strip(const char *str, int *len) { int str_len = strlen(str); for(int i = 0; i < str_len; ++i) { @@ -171,20 +169,19 @@ int main(int argc, char **argv) { if(focused_window == None) exit(2); - if(!is_steam_game(dpy, focused_window)) { - XClassHint class_hint = {0}; - XGetClassHint(dpy, focused_window, &class_hint); - if(class_hint.res_class) { - print_str_strip(class_hint.res_class); - exit(0); - } - } - + // Window title is not always ideal (for example for a browser), but for games its pretty much required char *window_title = get_window_title(dpy, focused_window); if(window_title) { print_str_strip(window_title); exit(0); } + XClassHint class_hint = {0}; + XGetClassHint(dpy, focused_window, &class_hint); + if(class_hint.res_class) { + print_str_strip(class_hint.res_class); + exit(0); + } + return 2; } diff --git a/scripts/save-video-in-game-folder.sh b/scripts/save-video-in-game-folder.sh index 694c9d8..3d07d6a 100755 --- a/scripts/save-video-in-game-folder.sh +++ b/scripts/save-video-in-game-folder.sh @@ -7,6 +7,7 @@ file_name="$(basename "$filepath")" file_dir="$(dirname "$filepath")" game_name=$(gsr-window-name focused || echo "Game") +game_name="$(echo "$game_name" | tr '/\\' '_')" target_dir="$file_dir/$game_name" new_filepath="$target_dir/$file_name" diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 4028410..16dcfe4 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -1106,17 +1106,8 @@ namespace gsr { // Starting recording in 3... // 2... // 1... - // TODO: Do not run this is a daemon. Instead get the pid and when launching another notification close the current notification - // program and start another one. This can also be used to check when the notification has finished by checking with waitpid NOWAIT - // to see when the program has exit. if(config.record_config.show_recording_started_notifications) show_notification("Recording has started", 3.0, get_color_theme().tint_color, get_color_theme().tint_color, NotificationType::RECORD); - //exit(0); - // window->set_visible(false); - // window->close(); - - // TODO: Show notification with args: - // "Recording has started" 3.0 ./images/record.png 76b900 } static std::string streaming_get_url(const Config &config) { diff --git a/src/main.cpp b/src/main.cpp index c64fd60..16152cc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,6 +17,8 @@ // TODO: Keep track of gpu screen recorder run by other programs to not allow recording at the same time, or something. // TODO: Add systray by using org.kde.StatusNotifierWatcher/etc dbus directly. // TODO: Make sure the overlay always stays on top. Test with starting the overlay and then opening youtube in fullscreen. +// This is done in Overlay::force_window_on_top, but it's not called right now. It cant be used because the overlay will be on top of +// notifications. extern "C" { #include <mgl/mgl.h> |