Clarify and make consistent "default" versus "inactive"

Prior to this commit, "default" opacity signified "default" in some places and signified "inactive" in other places.
This commit attempts to make clear and consistent usage and specify "inactive" where appropriate.
This commit is contained in:
fauxmight 2025-12-19 05:23:53 +01:00
parent 55061ce6cd
commit 6a8275950e

View File

@ -16,8 +16,8 @@ index 95c2afa..b3170d1 100644
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
+static const float default_opacity = 0.70;
+static const float default_opacity_active = 1.00;
+static const float default_opacity_inactive = 0.70;
+static const float default_opacity_active = 1.00;
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@ -30,8 +30,8 @@ index 95c2afa..b3170d1 100644
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, default_opacity, -1 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 1.0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, default_opacity_inactive, -1 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 1.00, -1 }, /* Start on ONLY tag "9" */
};
/* layout(s) */
@ -39,8 +39,8 @@ index 95c2afa..b3170d1 100644
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, setopacitydefault, {.f = +0.1f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, setopacitydefault, {.f = -0.1f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, setopacityinactive, {.f = +0.1f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, setopacityinactive, {.f = -0.1f} },
+ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT, XKB_KEY_K, setopacityactive, {.f = +0.1f} },
+ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT, XKB_KEY_J, setopacityactive, {.f = -0.1f} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
@ -56,7 +56,7 @@ index 12f441e..caafab1 100644
int isfloating, isurgent, isfullscreen;
+ float opacity;
+ float opacity_active;
+ float opacity_default;
+ float opacity_inactive;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@ -80,7 +80,7 @@ index 12f441e..caafab1 100644
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, uint32_t newtags);
+static void setopacitydefault(const Arg *arg);
+static void setopacityinactive(const Arg *arg);
+static void setopacityactive(const Arg *arg);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
@ -98,9 +98,9 @@ index 12f441e..caafab1 100644
c->surface.xdg = toplevel->base;
c->bw = borderpx;
+ /* Set default opacity*/
+ c->opacity_default = default_opacity;
+ c->opacity_inactive = default_opacity_inactive;
+ c->opacity_active = default_opacity_active;
+ c->opacity = default_opacity;
+ c->opacity = default_opacity_inactive;
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
@ -116,7 +116,7 @@ index 12f441e..caafab1 100644
client_set_border_color(old_c, bordercolor);
client_activate_surface(old, 0);
+ old_c->opacity = old_c->opacity_default;
+ old_c->opacity = old_c->opacity_inactive;
}
}
printstatus();
@ -158,7 +158,7 @@ index 12f441e..caafab1 100644
+
+void
+setopacitydefault(const Arg *arg)
+setopacityinactive(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (!sel)