Skip to content

Commit

Permalink
fix: re-register status item when status watcher is recreated
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Nov 15, 2022
1 parent 185d84b commit 8192041
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions patches/chromium/.patches
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,4 @@ fix_remove_caption-removing_style_call.patch
build_allow_electron_to_use_exec_script.patch
revert_use_accessibility_pkey_when_setting_page_access.patch
roll_clang_llvmorg-16-init-8189-g97196a2d-2.patch
fix_tray_icon_gone_on_lock_screen.patch
53 changes: 53 additions & 0 deletions patches/chromium/fix_tray_icon_gone_on_lock_screen.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Tue, 15 Nov 2022 09:38:25 +0900
Subject: Re-register status item when owner of status watcher is changed

https://chromium-review.googlesource.com/c/chromium/src/+/4022621

diff --git a/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc b/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc
index f3c9dfa9ca33496a9c45cd0c780d3d629aeb4663..7af4fbe75654729a9f42d661d1f0313b0c528664 100644
--- a/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc
+++ b/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc
@@ -270,6 +270,9 @@ void StatusIconLinuxDbus::OnNameHasOwnerResponse(dbus::Response* response) {

watcher_ = bus_->GetObjectProxy(kServiceStatusNotifierWatcher,
dbus::ObjectPath(kPathStatusNotifierWatcher));
+ watcher_->SetNameOwnerChangedCallback(
+ base::BindRepeating(&StatusIconLinuxDbus::NameOwnerChangedReceived,
+ weak_factory_.GetWeakPtr()));

dbus::MethodCall method_call(DBUS_INTERFACE_PROPERTIES, kMethodGet);
dbus::MessageWriter writer(&method_call);
@@ -396,6 +399,15 @@ void StatusIconLinuxDbus::OnRegistered(dbus::Response* response) {
delegate_->OnImplInitializationFailed();
}

+void StatusIconLinuxDbus::NameOwnerChangedReceived(
+ const std::string& old_owner,
+ const std::string& new_owner) {
+ // Re-register the item when the StatusNotifierWatcher has a new owner.
+ if (new_owner.empty())
+ return;
+ OnInitialized(true);
+}
+
void StatusIconLinuxDbus::OnActivate(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender sender) {
diff --git a/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h b/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h
index e7628de42f980fa3535cab9dfffd0deab30f8812..9bcc64bfcd5379111f5cfcf25e884c8e263120c2 100644
--- a/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h
+++ b/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h
@@ -78,6 +78,11 @@ class StatusIconLinuxDbus : public ui::StatusIconLinux,
// Step 5: register the StatusNotifierItem with the StatusNotifierWatcher.
void OnRegistered(dbus::Response* response);

+ // Called when the name owner of StatusNotifierWatcher has changed, which
+ // can happen when lock/unlock screen.
+ void NameOwnerChangedReceived(const std::string& old_owner,
+ const std::string& new_owner);
+
// DBus methods.
// Action -> KDE behavior:
// Left-click -> Activate

0 comments on commit 8192041

Please sign in to comment.