diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-06-04 19:31:09 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-06-04 19:32:27 +0200 |
commit | a74b562056459551d3493c9760e7cd6ea4db62e7 (patch) | |
tree | c74639e0f7845bc0adb40e9d8b9ff6663f75efa3 | |
parent | 6994fb10fa61ad6d8af0a3958a6332d64915d799 (diff) |
Auto register hotkeys on gnome wayland, so they work without having to press change hotkeys everytime
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | project.conf | 2 | ||||
-rw-r--r-- | src/main.cpp | 40 |
4 files changed, 32 insertions, 17 deletions
@@ -4,6 +4,9 @@ GTK frontend for [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/about/).\ There is a new alternative UI for GPU Screen Recorder in the style of ShadowPlay available here: [GPU Screen Recorder UI](https://git.dec05eba.com/gpu-screen-recorder-ui/). +## Notes +The program has to be launched from your application launcher or hotkeys may not work properly in your Wayland compositor (this is the case with GNOME). + ## Deprecation This project is no longer being developed as it has been superseded by [GPU Screen Recorder UI](https://git.dec05eba.com/gpu-screen-recorder-ui/) which has more features. This project will remain available until GPU Screen Recorder UI can run as a regular window, just like GPU Screen Recorder GTK does.\ The `com.dec05eba.gpu_screen_recorder.appdata.xml` file has been moved to the [AppData](https://git.dec05eba.com/gpu-screen-recorder-appdata/) repository. @@ -11,7 +14,7 @@ The `com.dec05eba.gpu_screen_recorder.appdata.xml` file has been moved to the [A # Installation If you are using an Arch Linux based distro then you can find gpu screen recorder gtk on aur under the name gpu-screen-recorder-gtk (`yay -S gpu-screen-recorder-gtk`).\ If you are running another distro then you can run `sudo ./install.sh`, but you need to manually install the dependencies, as described below.\ -You can also install gpu screen recorder from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder). This flatpak includes both this UI and gpu-screen-recorder so no need to install that first. +You can also install gpu screen recorder from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder) which includes this UI. # Dependencies GPU Screen Recorder GTK uses meson build system so you need to install `meson` to build GPU Screen Recorder GTK. diff --git a/meson.build b/meson.build index 2d091ea..5ec5848 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('gpu-screen-recorder-gtk', ['c', 'cpp'], version : '5.7.0', default_options : ['warning_level=2']) +project('gpu-screen-recorder-gtk', ['c', 'cpp'], version : '5.7.1', default_options : ['warning_level=2']) add_project_arguments('-Wshadow', language : ['c', 'cpp']) if get_option('buildtype') == 'debug' diff --git a/project.conf b/project.conf index f981333..65280dd 100644 --- a/project.conf +++ b/project.conf @@ -1,7 +1,7 @@ [package] name = "gpu-screen-recorder-gtk" type = "executable" -version = "5.7.0" +version = "5.7.1" platforms = ["posix"] [config] diff --git a/src/main.cpp b/src/main.cpp index 5eef1f4..78f46f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3482,13 +3482,17 @@ static void add_wayland_global_hotkeys_ui(GtkGrid *grid, int &row, int width) { gtk_grid_attach(grid, GTK_WIDGET(aa_grid), 0, row++, width, 1); gtk_grid_set_column_spacing(aa_grid, 10); - gtk_grid_attach(aa_grid, gtk_label_new("On Wayland hotkeys are managed externally by the Wayland compositor, click here to change hotkeys:"), 0, 0, 1, 1); - - GtkButton *register_hotkeys_button = GTK_BUTTON(gtk_button_new_with_label("Change hotkeys")); - gtk_widget_set_hexpand(GTK_WIDGET(register_hotkeys_button), true); - //gtk_widget_set_halign(GTK_WIDGET(register_hotkeys_button), GTK_ALIGN_START); - g_signal_connect(register_hotkeys_button, "clicked", G_CALLBACK(on_register_hotkeys_button_clicked), nullptr); - gtk_grid_attach(aa_grid, GTK_WIDGET(register_hotkeys_button), 1, 0, 1, 1); + if(wayland_compositor == WaylandCompositor::KDE) { + gtk_grid_attach(aa_grid, gtk_label_new("Hotkeys are managed externally on KDE Plasma Wayland. Click here to change hotkeys:"), 0, 0, 1, 1); + + GtkButton *register_hotkeys_button = GTK_BUTTON(gtk_button_new_with_label("Change hotkeys")); + gtk_widget_set_hexpand(GTK_WIDGET(register_hotkeys_button), true); + //gtk_widget_set_halign(GTK_WIDGET(register_hotkeys_button), GTK_ALIGN_START); + g_signal_connect(register_hotkeys_button, "clicked", G_CALLBACK(on_register_hotkeys_button_clicked), nullptr); + gtk_grid_attach(aa_grid, GTK_WIDGET(register_hotkeys_button), 1, 0, 1, 1); + } else { + gtk_grid_attach(aa_grid, gtk_label_new("Hotkeys are managed externally on Wayland. Go into your system application/hotkey settings to change hotkeys."), 0, 0, 1, 1); + } row++; gtk_grid_attach(grid, gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), 0, row, width, 1); @@ -4290,6 +4294,12 @@ static void init_shortcuts_callback(bool success, void *userdata) { fprintf(stderr, "gsr error: failed to list shortcuts\n"); } gsr_global_shortcuts_subscribe_activated_signal(&global_shortcuts, deactivated_callback, shortcut_changed_callback, NULL); + + // On KDE plasma the shortcut menu popup will show up everytime this is used, so we dont want to call it everytime. + // On Hyprland the global shortcut desktop portal is broken on older versions and crashes the desktop portal. + // On GNOME this needs to be called everytime to register the shortcuts. The shortcut popup menu will show the first time only. + if(wayland_compositor == WaylandCompositor::UNKNOWN) + on_register_hotkeys_button_clicked(nullptr, nullptr); } else { gtk_widget_set_visible(GTK_WIDGET(recording_hotkeys_grid), false); gtk_widget_set_visible(GTK_WIDGET(replay_hotkeys_grid), false); @@ -4412,6 +4422,14 @@ static void activate(GtkApplication *app, gpointer) { gtk_window_set_default_icon_name(icon_name); gtk_window_set_icon_name(GTK_WINDOW(window), icon_name); + if(gsr_info.system_info.display_server == DisplayServer::WAYLAND) { + if(gdk_wayland_display_query_registry(gdk_display_get_default(), "hyprland_global_shortcuts_manager_v1")) { + wayland_compositor = WaylandCompositor::HYPRLAND; + } else if(gdk_wayland_display_query_registry(gdk_display_get_default(), "org_kde_plasma_shell")) { + wayland_compositor = WaylandCompositor::KDE; + } + } + select_window_userdata.app = app; audio_inputs = get_audio_devices(); application_audio = get_application_audio(); @@ -4461,12 +4479,6 @@ static void activate(GtkApplication *app, gpointer) { load_config(); if(gsr_info.system_info.display_server == DisplayServer::WAYLAND) { - if(gdk_wayland_display_query_registry(gdk_display_get_default(), "hyprland_global_shortcuts_manager_v1")) { - wayland_compositor = WaylandCompositor::HYPRLAND; - } else if(gdk_wayland_display_query_registry(gdk_display_get_default(), "org_kde_plasma_shell")) { - wayland_compositor = WaylandCompositor::KDE; - } - init_shortcuts_callback(false, nullptr); // TODO: // Disable global hotkeys on Hyprland for now. It crashes the hyprland desktop portal. @@ -4475,7 +4487,7 @@ static void activate(GtkApplication *app, gpointer) { // the desktop portal is restarted (when the computer is restarted for example). if(wayland_compositor == WaylandCompositor::HYPRLAND) { - const char *hotkeys_not_supported_text = "Global hotkeys have been disabled on your system because of a Hyprland bug.\nUse X11 or KDE Plasma on Wayland if you want to use hotkeys."; + const char *hotkeys_not_supported_text = "Hotkeys have been disabled on your system because of a Hyprland bug.\nUse X11 or KDE Plasma on Wayland if you want to use hotkeys."; gtk_label_set_text(GTK_LABEL(recording_hotkeys_not_supported_label), hotkeys_not_supported_text); gtk_label_set_text(GTK_LABEL(replay_hotkeys_not_supported_label), hotkeys_not_supported_text); gtk_label_set_text(GTK_LABEL(streaming_hotkeys_not_supported_label), hotkeys_not_supported_text); |