[libwnck/wip/muktupavels/icons: 1/16] util: move icon reloading to WnckHandle




commit c0cbba4c40c18cda7f9ee2bb56e3473da70dfa44
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Mar 14 13:25:49 2022 +0200

    util: move icon reloading to WnckHandle
    
    And do that for both icon sizes.

 libwnck/util.c        | 23 -----------------------
 libwnck/wnck-handle.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 24 deletions(-)
---
diff --git a/libwnck/util.c b/libwnck/util.c
index b1023585..6f6481ce 100644
--- a/libwnck/util.c
+++ b/libwnck/util.c
@@ -191,30 +191,7 @@ wnck_set_default_icon_size (gsize size)
 void
 wnck_set_default_mini_icon_size (gsize size)
 {
-  int default_screen;
-  WnckScreen *screen;
-  GList *l;
-
   _wnck_handle_set_default_mini_icon_size (_wnck_get_handle (), size);
-
-  default_screen = DefaultScreen (_wnck_get_default_display ());
-  screen = _wnck_handle_get_existing_screen (_wnck_get_handle (),
-                                             default_screen);
-
-  if (WNCK_IS_SCREEN (screen))
-    {
-      /* Make applications and icons to reload their icons */
-      for (l = wnck_screen_get_windows (screen); l; l = l->next)
-        {
-          WnckWindow *window = WNCK_WINDOW (l->data);
-          WnckApplication *application = wnck_window_get_application (window);
-
-          _wnck_window_load_icons (window);
-
-          if (WNCK_IS_APPLICATION (application))
-            _wnck_application_load_icons (application);
-        }
-    }
 }
 
 /**
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index 157aabea..980fd3e6 100644
--- a/libwnck/wnck-handle.c
+++ b/libwnck/wnck-handle.c
@@ -60,6 +60,43 @@ static GParamSpec *handle_properties[LAST_PROP] = { NULL };
 
 G_DEFINE_TYPE (WnckHandle, wnck_handle, G_TYPE_OBJECT)
 
+static void
+invalidate_icons (WnckHandle *self)
+{
+  Display *xdisplay;
+  int i;
+
+  xdisplay = _wnck_get_default_display ();
+
+  for (i = 0; i < ScreenCount (xdisplay); ++i)
+    {
+      WnckScreen *screen;
+      GList *windows;
+      GList *l;
+
+      screen = self->screens[i];
+
+      if (screen == NULL)
+        continue;
+
+      windows = wnck_screen_get_windows (screen);
+
+      for (l = windows; l != NULL; l = l->next)
+        {
+          WnckWindow *window;
+          WnckApplication *application;
+
+          window = WNCK_WINDOW (l->data);
+          application = wnck_window_get_application (window);
+
+          _wnck_window_load_icons (window);
+
+          if (application != NULL)
+            _wnck_application_load_icons (application);
+        }
+    }
+}
+
 static GdkFilterReturn
 filter_func (GdkXEvent *gdkxevent,
              GdkEvent  *event,
@@ -411,7 +448,12 @@ void
 _wnck_handle_set_default_icon_size (WnckHandle *self,
                                     gsize       icon_size)
 {
+  if (self->default_icon_size == icon_size)
+    return;
+
   self->default_icon_size = icon_size;
+
+  invalidate_icons (self);
 }
 
 gsize
@@ -424,7 +466,12 @@ void
 _wnck_handle_set_default_mini_icon_size (WnckHandle *self,
                                          gsize       icon_size)
 {
+  if (self->default_mini_icon_size == icon_size)
+    return;
+
   self->default_mini_icon_size = icon_size;
+
+  invalidate_icons (self);
 }
 
 gsize
@@ -433,7 +480,6 @@ _wnck_handle_get_default_mini_icon_size (WnckHandle *self)
   return self->default_mini_icon_size;
 }
 
-
 void
 _wnck_handle_insert_class_group (WnckHandle     *self,
                                  const char     *id,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]