]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Support inactive unpressed icons
authorJohan Malm <jgm323@gmail.com>
Fri, 21 Aug 2020 19:35:06 +0000 (20:35 +0100)
committerJohan Malm <jgm323@gmail.com>
Fri, 21 Aug 2020 19:35:06 +0000 (20:35 +0100)
data/themes/labwc-default/openbox-3/themerc
include/theme/theme.h
src/deco.c
src/output.c
src/theme/theme.c
src/theme/xbm/xbm.c

index 1a1c033c8d8c469898d0e8513d15215286fe0499..6b5057079aeed5ff8fddd12c9776af0b294e93fc 100644 (file)
@@ -4,4 +4,5 @@ window.active.handle.bg.color: #3c7cb7
 window.inactive.title.bg.color: #efece6
 
 window.active.button.unpressed.image.color = #ffffff
+window.inactive.button.unpressed.image.color = #000000
 
index 558f6df135d1230455cff32acd81b903cbd419ba..351b136270277914a138256decad1d1ec20b1c96 100644 (file)
 struct theme {
        float window_active_title_bg_color[4];
        float window_active_handle_bg_color[4];
+
        float window_inactive_title_bg_color[4];
+
        float window_active_button_unpressed_image_color[4];
-       struct wlr_texture *xbm_close;
-       struct wlr_texture *xbm_maximize;
-       struct wlr_texture *xbm_iconify;
+       float window_inactive_button_unpressed_image_color[4];
+
+       struct wlr_texture *xbm_close_active_unpressed;
+       struct wlr_texture *xbm_maximize_active_unpressed;
+       struct wlr_texture *xbm_iconify_active_unpressed;
+
+       struct wlr_texture *xbm_close_inactive_unpressed;
+       struct wlr_texture *xbm_maximize_inactive_unpressed;
+       struct wlr_texture *xbm_iconify_inactive_unpressed;
 };
 
 extern struct theme theme;
index 6ad7b82e86c345327aeeede3daecd754d00a0bac..62799e274b4065ac08b2a937b4c6a2bb49099f32 100644 (file)
@@ -42,23 +42,24 @@ struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
        }
        switch (deco_part) {
        case LAB_DECO_BUTTON_CLOSE:
-               wlr_texture_get_size(theme.xbm_close, &box.width, &box.height);
+               wlr_texture_get_size(theme.xbm_close_active_unpressed,
+                                    &box.width, &box.height);
                margin = (rc.title_height - box.height) / 2;
                box.x = view->x + view->surface->current.width + margin -
                        rc.title_height;
                box.y = view->y - rc.title_height + margin;
                break;
        case LAB_DECO_BUTTON_MAXIMIZE:
-               wlr_texture_get_size(theme.xbm_maximize, &box.width,
-                                    &box.height);
+               wlr_texture_get_size(theme.xbm_maximize_active_unpressed,
+                                    &box.width, &box.height);
                margin = (rc.title_height - box.height) / 2;
                box.x = view->x + view->surface->current.width + margin -
                        rc.title_height * 2;
                box.y = view->y - rc.title_height + margin;
                break;
        case LAB_DECO_BUTTON_ICONIFY:
-               wlr_texture_get_size(theme.xbm_iconify, &box.width,
-                                    &box.height);
+               wlr_texture_get_size(theme.xbm_iconify_active_unpressed,
+                                    &box.width, &box.height);
                margin = (rc.title_height - box.height) / 2;
                box.x = view->x + view->surface->current.width + margin -
                        rc.title_height * 3;
index 71708789ec7a1872322543c7b3023c8fc8cd5d10..756b2cdb89d43af72d0511a2aee933e9de01180b 100644 (file)
@@ -68,12 +68,21 @@ static void render_decorations(struct wlr_output *output, struct view *view)
                ddata.rgba = theme.window_inactive_title_bg_color;
        draw_rect(&ddata, deco_box(view, LAB_DECO_PART_TITLE));
 
-       render_icon(&ddata, deco_box(view, LAB_DECO_BUTTON_CLOSE),
-                   theme.xbm_close);
-       render_icon(&ddata, deco_box(view, LAB_DECO_BUTTON_MAXIMIZE),
-                   theme.xbm_maximize);
-       render_icon(&ddata, deco_box(view, LAB_DECO_BUTTON_ICONIFY),
-                   theme.xbm_iconify);
+       if (view_hasfocus(view)) {
+               render_icon(&ddata, deco_box(view, LAB_DECO_BUTTON_CLOSE),
+                           theme.xbm_close_active_unpressed);
+               render_icon(&ddata, deco_box(view, LAB_DECO_BUTTON_MAXIMIZE),
+                           theme.xbm_maximize_active_unpressed);
+               render_icon(&ddata, deco_box(view, LAB_DECO_BUTTON_ICONIFY),
+                           theme.xbm_iconify_active_unpressed);
+       } else {
+               render_icon(&ddata, deco_box(view, LAB_DECO_BUTTON_CLOSE),
+                           theme.xbm_close_inactive_unpressed);
+               render_icon(&ddata, deco_box(view, LAB_DECO_BUTTON_MAXIMIZE),
+                           theme.xbm_maximize_inactive_unpressed);
+               render_icon(&ddata, deco_box(view, LAB_DECO_BUTTON_ICONIFY),
+                           theme.xbm_iconify_inactive_unpressed);
+       }
 }
 
 struct render_data {
index d4ddd53616108aa7fe3f455478dc7d5a6bc6f8a1..4abb3621e6bdc71e472da607e3598ea0d0a7ad92 100644 (file)
@@ -39,6 +39,7 @@ static bool match(const gchar *pattern, const gchar *string)
        return (bool)g_pattern_match_simple(pattern, string);
 }
 
+/* clang-format off */
 static void entry(const char *key, const char *value)
 {
        if (!key || !value)
@@ -51,7 +52,10 @@ static void entry(const char *key, const char *value)
                parse_hexstr(value, theme.window_inactive_title_bg_color);
        if (match(key, "window.active.button.unpressed.image.color"))
                parse_hexstr(value, theme.window_active_button_unpressed_image_color);
+       if (match(key, "window.inactive.button.unpressed.image.color"))
+               parse_hexstr(value, theme.window_inactive_button_unpressed_image_color);
 }
+/* clang-format on */
 
 static void rtrim(char **s)
 {
@@ -101,13 +105,16 @@ static void process_line(char *line)
  * this was a bit hard-line. People might want to try labwc without having
  * Openbox (and associated themes) installed.
  */
+/* clang-format off */
 void theme_builtin(void)
 {
        parse_hexstr("#589bda", theme.window_active_title_bg_color);
        parse_hexstr("#3c7cb7", theme.window_active_handle_bg_color);
        parse_hexstr("#efece6", theme.window_inactive_title_bg_color);
        parse_hexstr("#ffffff", theme.window_active_button_unpressed_image_color);
+       parse_hexstr("#000000", theme.window_inactive_button_unpressed_image_color);
 }
+/* clang-format on */
 
 void theme_read(const char *theme_name)
 {
index 85a6882620726fb903e4d2e00e2493b5e98d37d0..895047c5fce5d598db500acbc35997a1e015ab4d 100644 (file)
@@ -73,8 +73,13 @@ out:
 void xbm_load(struct wlr_renderer *r)
 {
        parse_set_color(theme.window_active_button_unpressed_image_color);
-       load_button(r, "close.xbm", &theme.xbm_close, close_button_normal);
-       load_button(r, "max.xbm", &theme.xbm_maximize, max_button_normal);
-       load_button(r, "iconify.xbm", &theme.xbm_iconify, iconify_button_normal);
+       load_button(r, "close.xbm", &theme.xbm_close_active_unpressed, close_button_normal);
+       load_button(r, "max.xbm", &theme.xbm_maximize_active_unpressed, max_button_normal);
+       load_button(r, "iconify.xbm", &theme.xbm_iconify_active_unpressed, iconify_button_normal);
+
+       parse_set_color(theme.window_inactive_button_unpressed_image_color);
+       load_button(r, "close.xbm", &theme.xbm_close_inactive_unpressed, close_button_normal);
+       load_button(r, "max.xbm", &theme.xbm_maximize_inactive_unpressed, max_button_normal);
+       load_button(r, "iconify.xbm", &theme.xbm_iconify_inactive_unpressed, iconify_button_normal);
 }
 /* clang-format on */