From 85e2622b6852b4528ee43282cadc2ab4db67c447 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 20 Nov 2024 15:24:59 -0600 Subject: [PATCH] refactor: use gdk_display_beep() on Linux (#44734) * refactor: use gdk_display_beep() to beep on Linux * chore: make a stub declaration for gdk_display_beep() * chore: remove unused file electron_gtk.sigs * chore: remove unused #includes to make gn check happy --- BUILD.gn | 5 ++++- shell/browser/ui/electron_gdk.sigs | 1 + shell/browser/ui/electron_gtk.sigs | 7 ------- shell/common/platform_util_linux.cc | 14 +++++--------- 4 files changed, 10 insertions(+), 17 deletions(-) create mode 100644 shell/browser/ui/electron_gdk.sigs delete mode 100644 shell/browser/ui/electron_gtk.sigs diff --git a/BUILD.gn b/BUILD.gn index 1e61506b29d67..fdd722ea68cca 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -84,7 +84,10 @@ if (is_linux) { # from the gtk library. Function signatures for which stubs are # required should be declared in the sig files. generate_stubs("electron_gtk_stubs") { - sigs = [ "shell/browser/ui/electron_gdk_pixbuf.sigs" ] + sigs = [ + "shell/browser/ui/electron_gdk.sigs", + "shell/browser/ui/electron_gdk_pixbuf.sigs", + ] extra_header = "shell/browser/ui/electron_gtk.fragment" output_name = "electron_gtk_stubs" public_deps = [ "//ui/gtk:gtk_config" ] diff --git a/shell/browser/ui/electron_gdk.sigs b/shell/browser/ui/electron_gdk.sigs new file mode 100644 index 0000000000000..cf8fb7dee2ab1 --- /dev/null +++ b/shell/browser/ui/electron_gdk.sigs @@ -0,0 +1 @@ +void gdk_display_beep(GdkDisplay* display); diff --git a/shell/browser/ui/electron_gtk.sigs b/shell/browser/ui/electron_gtk.sigs deleted file mode 100644 index 41f3890096e09..0000000000000 --- a/shell/browser/ui/electron_gtk.sigs +++ /dev/null @@ -1,7 +0,0 @@ -GtkFileChooserNative* gtk_file_chooser_native_new(const gchar* title, GtkWindow* parent, GtkFileChooserAction action, const gchar* accept_label, const gchar* cancel_label); -void gtk_native_dialog_set_modal(GtkNativeDialog* self, gboolean modal); -void gtk_native_dialog_show(GtkNativeDialog* self); -void gtk_native_dialog_hide(GtkNativeDialog* self); -gint gtk_native_dialog_run(GtkNativeDialog* self); -void gtk_native_dialog_destroy(GtkNativeDialog* self); -GType gtk_native_dialog_get_type(void); diff --git a/shell/common/platform_util_linux.cc b/shell/common/platform_util_linux.cc index 6bd80cc15b1eb..125b4d037a474 100644 --- a/shell/common/platform_util_linux.cc +++ b/shell/common/platform_util_linux.cc @@ -11,6 +11,8 @@ #include #include +#include + #include "base/cancelable_callback.h" #include "base/containers/contains.h" #include "base/environment.h" @@ -32,6 +34,7 @@ #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_proxy.h" + #include "shell/common/platform_util_internal.h" #include "url/gurl.h" @@ -408,15 +411,8 @@ bool PlatformTrashItem(const base::FilePath& full_path, std::string* error) { } // namespace internal void Beep() { - // echo '\a' > /dev/console - FILE* fp = fopen("/dev/console", "a"); - if (fp == nullptr) { - fp = fopen("/dev/tty", "a"); - } - if (fp != nullptr) { - fprintf(fp, "\a"); - fclose(fp); - } + auto* display = gdk_display_get_default(); + gdk_display_beep(display); } bool GetDesktopName(std::string* setme) {