Skip to content

Commit

Permalink
refactor: use gdk_display_beep() on Linux (electron#44734)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ckerr authored Nov 20, 2024
1 parent 15c3064 commit 85e2622
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
5 changes: 4 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
1 change: 1 addition & 0 deletions shell/browser/ui/electron_gdk.sigs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void gdk_display_beep(GdkDisplay* display);
7 changes: 0 additions & 7 deletions shell/browser/ui/electron_gtk.sigs

This file was deleted.

14 changes: 5 additions & 9 deletions shell/common/platform_util_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <string>
#include <vector>

#include <gdk/gdk.h>

#include "base/cancelable_callback.h"
#include "base/containers/contains.h"
#include "base/environment.h"
Expand All @@ -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"

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 85e2622

Please sign in to comment.