chore: bump chromium to 119.0.6045.0 (main) (#40076)
* chore: bump chromium in DEPS to 119.0.6045.0 * chore: update patches * 4864948: Remove legacy-legacy4864948
* 4907760: Remove ui/base/glib/glib_signal.h4907760
--------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
parent
83a928f6e3
commit
8f7a48879e
34 changed files with 472 additions and 173 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "base/files/file_enumerator.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "shell/browser/notifications/notification_delegate.h"
|
||||
|
@ -87,15 +88,16 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
|
|||
base::UTF16ToUTF8(options.title).c_str(),
|
||||
base::UTF16ToUTF8(options.msg).c_str(), nullptr);
|
||||
|
||||
g_signal_connect(notification_, "closed",
|
||||
G_CALLBACK(OnNotificationClosedThunk), this);
|
||||
signal_ = ScopedGSignal(
|
||||
notification_, "closed",
|
||||
base::BindRepeating(&LibnotifyNotification::OnNotificationClosed,
|
||||
base::Unretained(this)));
|
||||
|
||||
// NB: On Unity and on any other DE using Notify-OSD, adding a notification
|
||||
// action will cause the notification to display as a modal dialog box.
|
||||
if (NotifierSupportsActions()) {
|
||||
libnotify_loader_.notify_notification_add_action(
|
||||
notification_, "default", "View", OnNotificationViewThunk, this,
|
||||
nullptr);
|
||||
notification_, "default", "View", OnNotificationView, this, nullptr);
|
||||
}
|
||||
|
||||
NotifyUrgency urgency = NOTIFY_URGENCY_NORMAL;
|
||||
|
@ -175,8 +177,11 @@ void LibnotifyNotification::OnNotificationClosed(
|
|||
}
|
||||
|
||||
void LibnotifyNotification::OnNotificationView(NotifyNotification* notification,
|
||||
char* action) {
|
||||
NotificationClicked();
|
||||
char* action,
|
||||
gpointer user_data) {
|
||||
LibnotifyNotification* that = static_cast<LibnotifyNotification*>(user_data);
|
||||
DCHECK(that);
|
||||
that->NotificationClicked();
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "base/memory/raw_ptr_exclusion.h"
|
||||
#include "library_loaders/libnotify_loader.h"
|
||||
#include "shell/browser/notifications/notification.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/base/glib/scoped_gsignal.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -25,17 +25,14 @@ class LibnotifyNotification : public Notification {
|
|||
void Dismiss() override;
|
||||
|
||||
private:
|
||||
CHROMEG_CALLBACK_0(LibnotifyNotification,
|
||||
void,
|
||||
OnNotificationClosed,
|
||||
NotifyNotification*);
|
||||
CHROMEG_CALLBACK_1(LibnotifyNotification,
|
||||
void,
|
||||
OnNotificationView,
|
||||
NotifyNotification*,
|
||||
char*);
|
||||
void OnNotificationClosed(NotifyNotification* notification);
|
||||
static void OnNotificationView(NotifyNotification* notification,
|
||||
char* action,
|
||||
gpointer user_data);
|
||||
|
||||
RAW_PTR_EXCLUSION NotifyNotification* notification_ = nullptr;
|
||||
|
||||
ScopedGSignal signal_;
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/raw_ptr_exclusion.h"
|
||||
|
@ -17,7 +18,7 @@
|
|||
#include "shell/browser/ui/gtk_util.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/thread_restrictions.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/base/glib/scoped_gsignal.h"
|
||||
#include "ui/gtk/gtk_ui.h" // nogncheck
|
||||
#include "ui/gtk/gtk_util.h" // nogncheck
|
||||
|
||||
|
@ -121,8 +122,10 @@ class FileChooserDialog {
|
|||
// the update-preview signal or the preview widget will just be ignored.
|
||||
if (!electron::IsElectron_gtkInitialized()) {
|
||||
preview_ = gtk_image_new();
|
||||
g_signal_connect(dialog_, "update-preview",
|
||||
G_CALLBACK(OnUpdatePreviewThunk), this);
|
||||
signals_.emplace_back(
|
||||
dialog_, "update-preview",
|
||||
base::BindRepeating(&FileChooserDialog::OnUpdatePreview,
|
||||
base::Unretained(this)));
|
||||
gtk_file_chooser_set_preview_widget(dialog_, preview_);
|
||||
}
|
||||
}
|
||||
|
@ -165,8 +168,10 @@ class FileChooserDialog {
|
|||
}
|
||||
|
||||
void RunAsynchronous() {
|
||||
g_signal_connect(dialog_, "response", G_CALLBACK(OnFileDialogResponseThunk),
|
||||
this);
|
||||
signals_.emplace_back(
|
||||
GTK_WIDGET(dialog_), "response",
|
||||
base::BindRepeating(&FileChooserDialog::OnFileDialogResponse,
|
||||
base::Unretained(this)));
|
||||
if (electron::IsElectron_gtkInitialized()) {
|
||||
gtk_native_dialog_show(GTK_NATIVE_DIALOG(dialog_));
|
||||
} else {
|
||||
|
@ -210,11 +215,7 @@ class FileChooserDialog {
|
|||
return paths;
|
||||
}
|
||||
|
||||
CHROMEG_CALLBACK_1(FileChooserDialog,
|
||||
void,
|
||||
OnFileDialogResponse,
|
||||
GtkWidget*,
|
||||
int);
|
||||
void OnFileDialogResponse(GtkWidget* widget, int response);
|
||||
|
||||
GtkFileChooser* dialog() const { return dialog_; }
|
||||
|
||||
|
@ -231,7 +232,9 @@ class FileChooserDialog {
|
|||
std::unique_ptr<gin_helper::Promise<gin_helper::Dictionary>> open_promise_;
|
||||
|
||||
// Callback for when we update the preview for the selection.
|
||||
CHROMEG_CALLBACK_0(FileChooserDialog, void, OnUpdatePreview, GtkFileChooser*);
|
||||
void OnUpdatePreview(GtkFileChooser* chooser);
|
||||
|
||||
std::vector<ScopedGSignal> signals_;
|
||||
};
|
||||
|
||||
void FileChooserDialog::OnFileDialogResponse(GtkWidget* widget, int response) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "shell/browser/ui/gtk/menu_util.h"
|
||||
#include "ui/base/models/menu_model.h"
|
||||
|
||||
|
@ -15,8 +16,9 @@ MenuGtk::MenuGtk(ui::MenuModel* model)
|
|||
: menu_model_(model), gtk_menu_(TakeGObject(gtk_menu_new())) {
|
||||
if (menu_model_) {
|
||||
BuildSubmenuFromModel(menu_model_, gtk_menu_,
|
||||
G_CALLBACK(OnMenuItemActivatedThunk),
|
||||
&block_activation_, this);
|
||||
base::BindRepeating(&MenuGtk::OnMenuItemActivated,
|
||||
base::Unretained(this)),
|
||||
&block_activation_, &signals_);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/base/glib/scoped_gobject.h"
|
||||
#include "ui/base/glib/scoped_gsignal.h"
|
||||
|
||||
typedef struct _GtkMenu GtkMenu;
|
||||
typedef struct _GtkWidget GtkWidget;
|
||||
|
@ -31,12 +31,13 @@ class MenuGtk {
|
|||
|
||||
private:
|
||||
// Callback for when a menu item is activated.
|
||||
CHROMEG_CALLBACK_0(MenuGtk, void, OnMenuItemActivated, GtkWidget*);
|
||||
void OnMenuItemActivated(GtkWidget* menu_item);
|
||||
|
||||
raw_ptr<ui::MenuModel> menu_model_; // not owned
|
||||
ScopedGObject<GtkWidget> gtk_menu_;
|
||||
|
||||
bool block_activation_ = false;
|
||||
std::vector<ScopedGSignal> signals_;
|
||||
};
|
||||
|
||||
} // namespace electron::gtkui
|
||||
|
|
|
@ -109,8 +109,8 @@ GtkWidget* AppendMenuItemToMenu(int index,
|
|||
GtkWidget* menu_item,
|
||||
GtkWidget* menu,
|
||||
bool connect_to_activate,
|
||||
GCallback item_activated_cb,
|
||||
void* this_ptr) {
|
||||
MenuActivatedCallback item_activated_cb,
|
||||
std::vector<ScopedGSignal>* signals) {
|
||||
// Set the ID of a menu item.
|
||||
// Add 1 to the menu_id to avoid setting zero (null) to "menu-id".
|
||||
g_object_set_data(G_OBJECT(menu_item), "menu-id", GINT_TO_POINTER(index + 1));
|
||||
|
@ -118,7 +118,7 @@ GtkWidget* AppendMenuItemToMenu(int index,
|
|||
// Native menu items do their own thing, so only selectively listen for the
|
||||
// activate signal.
|
||||
if (connect_to_activate) {
|
||||
g_signal_connect(menu_item, "activate", item_activated_cb, this_ptr);
|
||||
signals->emplace_back(menu_item, "activate", item_activated_cb);
|
||||
}
|
||||
|
||||
// AppendMenuItemToMenu is used both internally when we control menu creation
|
||||
|
@ -158,9 +158,9 @@ void ExecuteCommand(ui::MenuModel* model, int id) {
|
|||
|
||||
void BuildSubmenuFromModel(ui::MenuModel* model,
|
||||
GtkWidget* menu,
|
||||
GCallback item_activated_cb,
|
||||
MenuActivatedCallback item_activated_cb,
|
||||
bool* block_activation,
|
||||
void* this_ptr) {
|
||||
std::vector<ScopedGSignal>* signals) {
|
||||
std::map<int, GtkWidget*> radio_groups;
|
||||
GtkWidget* menu_item = nullptr;
|
||||
for (size_t i = 0; i < model->GetItemCount(); ++i) {
|
||||
|
@ -221,7 +221,7 @@ void BuildSubmenuFromModel(ui::MenuModel* model,
|
|||
GtkWidget* submenu = gtk_menu_new();
|
||||
ui::MenuModel* submenu_model = model->GetSubmenuModelAt(i);
|
||||
BuildSubmenuFromModel(submenu_model, submenu, item_activated_cb,
|
||||
block_activation, this_ptr);
|
||||
block_activation, signals);
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu);
|
||||
|
||||
// Update all the menu item info in the newly-generated menu.
|
||||
|
@ -247,7 +247,7 @@ void BuildSubmenuFromModel(ui::MenuModel* model,
|
|||
|
||||
g_object_set_data(G_OBJECT(menu_item), "model", model);
|
||||
AppendMenuItemToMenu(i, model, menu_item, menu, connect_to_activate,
|
||||
item_activated_cb, this_ptr);
|
||||
item_activated_cb, signals);
|
||||
|
||||
menu_item = nullptr;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "ui/base/glib/scoped_gsignal.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
namespace ui {
|
||||
|
@ -17,6 +19,8 @@ class MenuModel;
|
|||
|
||||
namespace electron::gtkui {
|
||||
|
||||
using MenuActivatedCallback = base::RepeatingCallback<void(GtkWidget*)>;
|
||||
|
||||
// Builds GtkImageMenuItems.
|
||||
GtkWidget* BuildMenuItemWithImage(const std::string& label, GtkWidget* image);
|
||||
GtkWidget* BuildMenuItemWithImage(const std::string& label,
|
||||
|
@ -32,8 +36,8 @@ GtkWidget* AppendMenuItemToMenu(int index,
|
|||
GtkWidget* menu_item,
|
||||
GtkWidget* menu,
|
||||
bool connect_to_activate,
|
||||
GCallback item_activated_cb,
|
||||
void* this_ptr);
|
||||
MenuActivatedCallback item_activated_cb,
|
||||
std::vector<ScopedGSignal>* signals);
|
||||
|
||||
// Gets the ID of a menu item.
|
||||
// Returns true if the menu item has an ID.
|
||||
|
@ -47,9 +51,9 @@ void ExecuteCommand(ui::MenuModel* model, int id);
|
|||
// See comments in definition of SetMenuItemInfo for more info.
|
||||
void BuildSubmenuFromModel(ui::MenuModel* model,
|
||||
GtkWidget* menu,
|
||||
GCallback item_activated_cb,
|
||||
MenuActivatedCallback item_activated_cb,
|
||||
bool* block_activation,
|
||||
void* this_ptr);
|
||||
std::vector<ScopedGSignal>* signals);
|
||||
|
||||
// Sets the check mark, enabled/disabled state and dynamic labels on menu items.
|
||||
void SetMenuItemInfo(GtkWidget* widget, void* block_activation_ptr);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <map>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/raw_ptr_exclusion.h"
|
||||
|
@ -18,7 +19,7 @@
|
|||
#include "shell/browser/native_window_observer.h"
|
||||
#include "shell/browser/native_window_views.h"
|
||||
#include "shell/browser/ui/gtk_util.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/base/glib/scoped_gsignal.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
#include "ui/gtk/gtk_ui.h" // nogncheck
|
||||
#include "ui/gtk/gtk_util.h" // nogncheck
|
||||
|
@ -89,8 +90,10 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(dialog_));
|
||||
GtkWidget* check_button =
|
||||
gtk_check_button_new_with_label(settings.checkbox_label.c_str());
|
||||
g_signal_connect(check_button, "toggled",
|
||||
G_CALLBACK(OnCheckboxToggledThunk), this);
|
||||
signals_.emplace_back(
|
||||
check_button, "toggled",
|
||||
base::BindRepeating(&GtkMessageBox::OnCheckboxToggled,
|
||||
base::Unretained(this)));
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),
|
||||
settings.checkbox_checked);
|
||||
gtk_container_add(GTK_CONTAINER(message_area), check_button);
|
||||
|
@ -172,10 +175,11 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
void RunAsynchronous(MessageBoxCallback callback) {
|
||||
callback_ = std::move(callback);
|
||||
|
||||
g_signal_connect(dialog_, "delete-event",
|
||||
G_CALLBACK(gtk_widget_hide_on_delete), nullptr);
|
||||
g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseDialogThunk),
|
||||
this);
|
||||
signals_.emplace_back(dialog_, "delete-event",
|
||||
base::BindRepeating(gtk_widget_hide_on_delete));
|
||||
signals_.emplace_back(dialog_, "response",
|
||||
base::BindRepeating(&GtkMessageBox::OnResponseDialog,
|
||||
base::Unretained(this)));
|
||||
Show();
|
||||
}
|
||||
|
||||
|
@ -184,8 +188,8 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
parent_ = nullptr;
|
||||
}
|
||||
|
||||
CHROMEG_CALLBACK_1(GtkMessageBox, void, OnResponseDialog, GtkWidget*, int);
|
||||
CHROMEG_CALLBACK_0(GtkMessageBox, void, OnCheckboxToggled, GtkWidget*);
|
||||
void OnResponseDialog(GtkWidget* widget, int response);
|
||||
void OnCheckboxToggled(GtkWidget* widget);
|
||||
|
||||
private:
|
||||
// The id of the dialog.
|
||||
|
@ -199,6 +203,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
raw_ptr<NativeWindow> parent_;
|
||||
RAW_PTR_EXCLUSION GtkWidget* dialog_;
|
||||
MessageBoxCallback callback_;
|
||||
std::vector<ScopedGSignal> signals_;
|
||||
};
|
||||
|
||||
void GtkMessageBox::OnResponseDialog(GtkWidget* widget, int response) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "shell/browser/ui/gtk/menu_gtk.h"
|
||||
#include "shell/browser/ui/gtk_util.h"
|
||||
|
@ -15,9 +16,15 @@
|
|||
namespace electron {
|
||||
|
||||
StatusIconGtk::StatusIconGtk() : icon_(TakeGObject(gtk_status_icon_new())) {
|
||||
g_signal_connect(icon_, "activate", G_CALLBACK(OnClickThunk), this);
|
||||
g_signal_connect(icon_, "popup_menu", G_CALLBACK(OnContextMenuRequestedThunk),
|
||||
this);
|
||||
auto connect = [&](auto* sender, const char* detailed_signal, auto receiver) {
|
||||
// Unretained() is safe since StatusIconGtk will own the
|
||||
// ScopedGSignal.
|
||||
signals_.emplace_back(
|
||||
sender, detailed_signal,
|
||||
base::BindRepeating(receiver, base::Unretained(this)));
|
||||
};
|
||||
connect(icon_.get(), "activate", &StatusIconGtk::OnClick);
|
||||
connect(icon_.get(), "popup_menu", &StatusIconGtk::OnContextMenuRequested);
|
||||
}
|
||||
|
||||
StatusIconGtk::~StatusIconGtk() = default;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include <memory>
|
||||
|
||||
#include "ui/base/glib/glib_integers.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/base/glib/scoped_gobject.h"
|
||||
#include "ui/base/glib/scoped_gsignal.h"
|
||||
#include "ui/linux/status_icon_linux.h"
|
||||
|
||||
typedef struct _GtkStatusIcon GtkStatusIcon;
|
||||
|
@ -35,16 +35,14 @@ class StatusIconGtk : public ui::StatusIconLinux {
|
|||
void OnSetDelegate() override;
|
||||
|
||||
private:
|
||||
CHROMEG_CALLBACK_0(StatusIconGtk, void, OnClick, GtkStatusIcon*);
|
||||
CHROMEG_CALLBACK_2(StatusIconGtk,
|
||||
void,
|
||||
OnContextMenuRequested,
|
||||
GtkStatusIcon*,
|
||||
guint,
|
||||
guint);
|
||||
void OnClick(GtkStatusIcon* status_icon);
|
||||
void OnContextMenuRequested(GtkStatusIcon* status_icon,
|
||||
guint button,
|
||||
guint32 activate_time);
|
||||
|
||||
std::unique_ptr<gtkui::MenuGtk> menu_;
|
||||
ScopedGObject<GtkStatusIcon> icon_;
|
||||
std::vector<ScopedGSignal> signals_;
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -52,14 +52,11 @@ GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11() {
|
|||
nullptr, kAppMenuRegistrarName, kAppMenuRegistrarPath,
|
||||
kAppMenuRegistrarName,
|
||||
nullptr, // Probably want a real cancelable.
|
||||
static_cast<GAsyncReadyCallback>(OnProxyCreatedThunk), this);
|
||||
static_cast<GAsyncReadyCallback>(OnProxyCreated), this);
|
||||
}
|
||||
|
||||
GlobalMenuBarRegistrarX11::~GlobalMenuBarRegistrarX11() {
|
||||
if (registrar_proxy_) {
|
||||
g_signal_handlers_disconnect_by_func(
|
||||
registrar_proxy_, reinterpret_cast<void*>(OnNameOwnerChangedThunk),
|
||||
this);
|
||||
g_object_unref(registrar_proxy_);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +96,12 @@ void GlobalMenuBarRegistrarX11::UnregisterXWindow(x11::Window window) {
|
|||
}
|
||||
|
||||
void GlobalMenuBarRegistrarX11::OnProxyCreated(GObject* source,
|
||||
GAsyncResult* result) {
|
||||
GAsyncResult* result,
|
||||
gpointer user_data) {
|
||||
GlobalMenuBarRegistrarX11* that =
|
||||
static_cast<GlobalMenuBarRegistrarX11*>(user_data);
|
||||
DCHECK(that);
|
||||
|
||||
GError* error = nullptr;
|
||||
GDBusProxy* proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
|
||||
if (error) {
|
||||
|
@ -110,16 +112,21 @@ void GlobalMenuBarRegistrarX11::OnProxyCreated(GObject* source,
|
|||
// TODO(erg): Mozilla's implementation has a workaround for GDBus
|
||||
// cancellation here. However, it's marked as fixed. If there's weird
|
||||
// problems with cancelation, look at how they fixed their issues.
|
||||
that->SetRegistrarProxy(proxy);
|
||||
|
||||
registrar_proxy_ = proxy;
|
||||
|
||||
g_signal_connect(registrar_proxy_, "notify::g-name-owner",
|
||||
G_CALLBACK(OnNameOwnerChangedThunk), this);
|
||||
|
||||
OnNameOwnerChanged(nullptr, nullptr);
|
||||
that->OnNameOwnerChanged(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void GlobalMenuBarRegistrarX11::OnNameOwnerChanged(GObject* /* ignored */,
|
||||
void GlobalMenuBarRegistrarX11::SetRegistrarProxy(GDBusProxy* proxy) {
|
||||
registrar_proxy_ = proxy;
|
||||
|
||||
signal_ = ScopedGSignal(
|
||||
registrar_proxy_, "notify::g-name-owner",
|
||||
base::BindRepeating(&GlobalMenuBarRegistrarX11::OnNameOwnerChanged,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
void GlobalMenuBarRegistrarX11::OnNameOwnerChanged(GDBusProxy* /* ignored */,
|
||||
GParamSpec* /* ignored */) {
|
||||
// If the name owner changed, we need to reregister all the live x11::Window
|
||||
// with the system.
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/singleton.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/base/glib/scoped_gsignal.h"
|
||||
#include "ui/gfx/x/xproto.h"
|
||||
|
||||
// Advertises our menu bars to Unity.
|
||||
|
@ -43,22 +43,18 @@ class GlobalMenuBarRegistrarX11 {
|
|||
void RegisterXWindow(x11::Window window);
|
||||
void UnregisterXWindow(x11::Window window);
|
||||
|
||||
CHROMEG_CALLBACK_1(GlobalMenuBarRegistrarX11,
|
||||
void,
|
||||
OnProxyCreated,
|
||||
GObject*,
|
||||
GAsyncResult*);
|
||||
CHROMEG_CALLBACK_1(GlobalMenuBarRegistrarX11,
|
||||
void,
|
||||
OnNameOwnerChanged,
|
||||
GObject*,
|
||||
GParamSpec*);
|
||||
static void OnProxyCreated(GObject* source,
|
||||
GAsyncResult* result,
|
||||
gpointer user_data);
|
||||
void OnNameOwnerChanged(GDBusProxy* /* ignored */, GParamSpec* /* ignored */);
|
||||
void SetRegistrarProxy(GDBusProxy* proxy);
|
||||
|
||||
raw_ptr<GDBusProxy> registrar_proxy_ = nullptr;
|
||||
|
||||
// x11::Window which want to be registered, but haven't yet been because
|
||||
// we're waiting for the proxy to become available.
|
||||
std::set<x11::Window> live_windows_;
|
||||
ScopedGSignal signal_;
|
||||
};
|
||||
|
||||
#endif // ELECTRON_SHELL_BROWSER_UI_VIEWS_GLOBAL_MENU_BAR_REGISTRAR_X11_H_
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <dlfcn.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
|
@ -232,6 +233,13 @@ void GlobalMenuBarX11::OnWindowUnmapped() {
|
|||
|
||||
void GlobalMenuBarX11::BuildMenuFromModel(ElectronMenuModel* model,
|
||||
DbusmenuMenuitem* parent) {
|
||||
auto connect = [&](auto* sender, const char* detailed_signal, auto receiver) {
|
||||
// Unretained() is safe since GlobalMenuBarX11 will own the
|
||||
// ScopedGSignal.
|
||||
signals_.emplace_back(
|
||||
sender, detailed_signal,
|
||||
base::BindRepeating(receiver, base::Unretained(this)));
|
||||
};
|
||||
for (size_t i = 0; i < model->GetItemCount(); ++i) {
|
||||
DbusmenuMenuitem* item = menuitem_new();
|
||||
menuitem_property_set_bool(item, kPropertyVisible, model->IsVisibleAt(i));
|
||||
|
@ -250,15 +258,13 @@ void GlobalMenuBarX11::BuildMenuFromModel(ElectronMenuModel* model,
|
|||
|
||||
if (type == ElectronMenuModel::TYPE_SUBMENU) {
|
||||
menuitem_property_set(item, kPropertyChildrenDisplay, kDisplaySubmenu);
|
||||
g_signal_connect(item, "about-to-show", G_CALLBACK(OnSubMenuShowThunk),
|
||||
this);
|
||||
connect(item, "about-to-show", &GlobalMenuBarX11::OnSubMenuShow);
|
||||
} else {
|
||||
ui::Accelerator accelerator;
|
||||
if (model->GetAcceleratorAtWithParams(i, true, &accelerator))
|
||||
RegisterAccelerator(item, accelerator);
|
||||
|
||||
g_signal_connect(item, "item-activated",
|
||||
G_CALLBACK(OnItemActivatedThunk), this);
|
||||
connect(item, "item-activated", &GlobalMenuBarX11::OnItemActivated);
|
||||
|
||||
if (type == ElectronMenuModel::TYPE_CHECK ||
|
||||
type == ElectronMenuModel::TYPE_RADIO) {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "shell/browser/ui/electron_menu_model.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/base/glib/scoped_gsignal.h"
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
#include "ui/gfx/x/xproto.h"
|
||||
|
||||
|
@ -66,17 +66,14 @@ class GlobalMenuBarX11 {
|
|||
void RegisterAccelerator(DbusmenuMenuitem* item,
|
||||
const ui::Accelerator& accelerator);
|
||||
|
||||
CHROMEG_CALLBACK_1(GlobalMenuBarX11,
|
||||
void,
|
||||
OnItemActivated,
|
||||
DbusmenuMenuitem*,
|
||||
unsigned int);
|
||||
CHROMEG_CALLBACK_0(GlobalMenuBarX11, void, OnSubMenuShow, DbusmenuMenuitem*);
|
||||
void OnItemActivated(DbusmenuMenuitem* item, unsigned int timestamp);
|
||||
void OnSubMenuShow(DbusmenuMenuitem* item);
|
||||
|
||||
raw_ptr<NativeWindowViews> window_;
|
||||
x11::Window xwindow_;
|
||||
|
||||
raw_ptr<DbusmenuServer> server_ = nullptr;
|
||||
std::vector<ScopedGSignal> signals_;
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue