]> git.mdlowis.com Git - proto/labwc.git/commitdiff
theme: add theme_finish()
authorJohan Malm <jgm323@gmail.com>
Sun, 21 Feb 2021 22:03:14 +0000 (22:03 +0000)
committerJohan Malm <jgm323@gmail.com>
Sun, 21 Feb 2021 22:03:14 +0000 (22:03 +0000)
include/theme/theme.h
src/main.c
src/server.c
src/theme/theme.c

index 09d6955bc93eb948240b23b92c66c2f74cf3495d..1287c3cfcf134c54cceb6ae19647a36f540bdeca 100644 (file)
@@ -42,7 +42,7 @@ void parse_hexstr(const char *hex, float *rgba);
 
 /**
  * theme_init - read openbox theme and generate button textures
- * @theme: global theme struct
+ * @theme: theme data
  * @renderer: wlr_renderer for creating button textures
  * @theme_name: theme-name in <theme-dir>/<theme-name>/openbox-3/themerc
  * Note <theme-dir> is obtained in theme-dir.c
@@ -50,6 +50,12 @@ void parse_hexstr(const char *hex, float *rgba);
 void theme_init(struct theme *theme, struct wlr_renderer *renderer,
                const char *theme_name);
 
+/**
+ * theme_finish - free button textures
+ * @theme: theme data
+ */
+void theme_finish(struct theme *theme);
+
 /**
  * theme_builin - apply built-in theme similar to Clearlooks
  * Note: Only used if no theme can be found. Default values for individual
index 606759412682f9fbec6fb653adde9c5972ea3f42..35d16671cf2ed75c16a75314d9ffc3c30a8ea60c 100644 (file)
@@ -90,8 +90,10 @@ main(int argc, char *argv[])
        wl_display_run(server.wl_display);
 
        server_finish(&server);
+
+       menu_finish(&rootmenu);
+       theme_finish(&theme);
        rcxml_finish();
-       menu_finish(server.rootmenu);
        font_finish();
        return 0;
 }
index 83df7ff877e59822598070d0f27d717cd92aaf2b..7bd1da751bad1bcc414263d63e037c2e28c1f1a7 100644 (file)
@@ -27,6 +27,7 @@ reload_config_and_theme(void)
        /* TODO: use rc.config_path */
        rcxml_finish();
        rcxml_read(NULL);
+       theme_finish(g_server->theme);
        theme_init(g_server->theme, g_server->renderer, rc.theme_name);
        menu_reconfigure(g_server, g_server->rootmenu);
        damage_all_outputs(g_server);
index 05f837f40863da320e3fa97e640a0e48e818523b..ddf393bcb7f9a1dacef5a2a8a65e922a0601e0ba 100644 (file)
@@ -9,6 +9,7 @@
 #include "common/dir.h"
 #include "common/log.h"
 #include "common/string-helpers.h"
+#include "common/zfree.h"
 #include "theme/theme.h"
 #include "xbm/xbm.h"
 
@@ -135,3 +136,14 @@ theme_init(struct theme *theme, struct wlr_renderer *renderer,
        theme_read(theme, theme_name);
        xbm_load(theme, renderer);
 }
+
+void
+theme_finish(struct theme *theme)
+{
+       zfree(theme->xbm_close_active_unpressed);
+       zfree(theme->xbm_maximize_active_unpressed);
+       zfree(theme->xbm_iconify_active_unpressed);
+       zfree(theme->xbm_close_inactive_unpressed);
+       zfree(theme->xbm_maximize_inactive_unpressed);
+       zfree(theme->xbm_iconify_inactive_unpressed);
+}