summaryrefslogtreecommitdiff
path: root/www-client/chromium/files/chromium-cursor-80.patch
blob: 49074527a4d4d77afcf1c531cb9e79f966b2640f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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: