blob: 49074527a4d4d77afcf1c531cb9e79f966b2640f (
plain) (
tree)
|
|
diff --git a/chrome/browser/ui/libgtkui/gtk_ui.cc b/chrome/browser/ui/libgtkui/gtk_ui.cc
index 1aea19a..cf38ee7 100644
--- a/chrome/browser/ui/libgtkui/gtk_ui.cc
+++ b/chrome/browser/ui/libgtkui/gtk_ui.cc
@@ -845,6 +845,8 @@
void GtkUi::OnCursorThemeNameChanged(GtkSettings* settings,
GtkParamSpec* param) {
std::string cursor_theme_name = GetCursorThemeName();
+ if (cursor_theme_name.empty())
+ return;
for (auto& observer : cursor_theme_observers())
observer.OnCursorThemeNameChanged(cursor_theme_name);
}
@@ -852,6 +854,8 @@
void GtkUi::OnCursorThemeSizeChanged(GtkSettings* settings,
GtkParamSpec* param) {
int cursor_theme_size = GetCursorThemeSize();
+ if (!cursor_theme_size)
+ return;
for (auto& observer : cursor_theme_observers())
observer.OnCursorThemeSizeChanged(cursor_theme_size);
}
diff --git a/ui/base/cursor/cursor_loader_x11.cc b/ui/base/cursor/cursor_loader_x11.cc
index efc6351..52ab54a 100644
--- a/ui/base/cursor/cursor_loader_x11.cc
+++ b/ui/base/cursor/cursor_loader_x11.cc
@@ -83,11 +83,8 @@
: display_(gfx::GetXDisplay()),
invisible_cursor_(CreateInvisibleCursor(), gfx::GetXDisplay()) {
auto* cursor_theme_manager = CursorThemeManagerLinux::GetInstance();
- if (cursor_theme_manager) {
+ if (cursor_theme_manager)
cursor_theme_observer_.Add(cursor_theme_manager);
- OnCursorThemeNameChanged(cursor_theme_manager->GetCursorThemeName());
- OnCursorThemeSizeChanged(cursor_theme_manager->GetCursorThemeSize());
- }
}
CursorLoaderX11::~CursorLoaderX11() {
diff --git a/ui/base/cursor/cursor_theme_manager_linux.cc b/ui/base/cursor/cursor_theme_manager_linux.cc
index fe8a97f..f825b74 100644
--- a/ui/base/cursor/cursor_theme_manager_linux.cc
+++ b/ui/base/cursor/cursor_theme_manager_linux.cc
@@ -26,6 +26,12 @@
void CursorThemeManagerLinux::AddObserver(
CursorThemeManagerLinuxObserver* observer) {
cursor_theme_observers_.AddObserver(observer);
+ std::string name = GetCursorThemeName();
+ if (!name.empty())
+ observer->OnCursorThemeNameChanged(name);
+ int size = GetCursorThemeSize();
+ if (size)
+ observer->OnCursorThemeSizeChanged(size);
}
void CursorThemeManagerLinux::RemoveObserver(
diff --git a/ui/base/cursor/cursor_theme_manager_linux.h b/ui/base/cursor/cursor_theme_manager_linux.h
index 5304867..464d397 100644
--- a/ui/base/cursor/cursor_theme_manager_linux.h
+++ b/ui/base/cursor/cursor_theme_manager_linux.h
@@ -22,9 +22,10 @@
static CursorThemeManagerLinux* GetInstance();
- virtual std::string GetCursorThemeName() = 0;
- virtual int GetCursorThemeSize() = 0;
+ // Adds |observer| and makes initial OnCursorThemNameChanged() and/or
+ // OnCursorThemeSizeChanged() calls if the respective settings were set.
void AddObserver(CursorThemeManagerLinuxObserver* observer);
+
void RemoveObserver(CursorThemeManagerLinuxObserver* observer);
protected:
@@ -35,6 +36,9 @@
return cursor_theme_observers_;
}
+ virtual std::string GetCursorThemeName() = 0;
+ virtual int GetCursorThemeSize() = 0;
+
private:
static CursorThemeManagerLinux* instance_;
diff --git a/ui/base/cursor/cursor_theme_manager_linux_observer.h b/ui/base/cursor/cursor_theme_manager_linux_observer.h
index 3d0c822..73a3b42 100644
--- a/ui/base/cursor/cursor_theme_manager_linux_observer.h
+++ b/ui/base/cursor/cursor_theme_manager_linux_observer.h
@@ -15,8 +15,11 @@
class UI_BASE_EXPORT CursorThemeManagerLinuxObserver
: public base::CheckedObserver {
public:
+ // |cursor_theme_name| will be nonempty.
virtual void OnCursorThemeNameChanged(
const std::string& cursor_theme_name) = 0;
+
+ // |cursor_theme_size| will be nonzero.
virtual void OnCursorThemeSizeChanged(int cursor_theme_size) = 0;
protected:
|