]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/theme.c: minor code improvements
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 5 Feb 2024 14:16:16 +0000 (15:16 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 6 Feb 2024 15:47:05 +0000 (16:47 +0100)
src/theme.c

index a8bb44c6d83a17f178feb09170e23762fcf6c285..fda8b742c65aac9a15c03439cbf8c12bfccadab8 100644 (file)
@@ -65,7 +65,7 @@ struct rounded_corner_ctx {
 static struct lab_data_buffer *rounded_rect(struct rounded_corner_ctx *ctx);
 
 static void
-drop(struct lab_data_buffer **buffer)
+zdrop(struct lab_data_buffer **buffer)
 {
        if (*buffer) {
                wlr_buffer_drop(&(*buffer)->base);
@@ -275,8 +275,8 @@ load_buttons(struct theme *theme)
        for (size_t i = 0; i < ARRAY_SIZE(buttons); ++i) {
                struct button *b = &buttons[i];
 
-               drop(b->active.buffer);
-               drop(b->inactive.buffer);
+               zdrop(b->active.buffer);
+               zdrop(b->inactive.buffer);
 
                /* PNG */
                snprintf(filename, sizeof(filename), "%s-active.png", b->name);
@@ -342,7 +342,7 @@ load_buttons(struct theme *theme)
        }
 
        /*
-        * If hover-icons do not exist, add fallbacks by coping the non-hover
+        * If hover-icons do not exist, add fallbacks by copying the non-hover
         * variant (base) and then adding an overlay.
         */
        for (size_t i = 0; i < ARRAY_SIZE(buttons); i++) {
@@ -767,7 +767,7 @@ rounded_rect(struct rounded_corner_ctx *ctx)
 
        struct lab_data_buffer *buffer;
        /* TODO: scale */
-       buffer = buffer_create_cairo(w, h, 1, true);
+       buffer = buffer_create_cairo(w, h, 1, /*free_on_destroy*/ true);
 
        cairo_t *cairo = buffer->cairo;
        cairo_surface_t *surf = cairo_get_target(cairo);
@@ -1037,12 +1037,8 @@ theme_init(struct theme *theme, const char *theme_name)
 void
 theme_finish(struct theme *theme)
 {
-       wlr_buffer_drop(&theme->corner_top_left_active_normal->base);
-       wlr_buffer_drop(&theme->corner_top_left_inactive_normal->base);
-       wlr_buffer_drop(&theme->corner_top_right_active_normal->base);
-       wlr_buffer_drop(&theme->corner_top_right_inactive_normal->base);
-       theme->corner_top_left_active_normal = NULL;
-       theme->corner_top_left_inactive_normal = NULL;
-       theme->corner_top_right_active_normal = NULL;
-       theme->corner_top_right_inactive_normal = NULL;
+       zdrop(&theme->corner_top_left_active_normal);
+       zdrop(&theme->corner_top_left_inactive_normal);
+       zdrop(&theme->corner_top_right_active_normal);
+       zdrop(&theme->corner_top_right_inactive_normal);
 }