mirror of
https://github.com/yshui/picom.git
synced 2024-11-18 13:55:36 -05:00
Feature #4: Default active window opacity
- Add default active window opacity (--active-opacity). (#4) - Add win_focusin and win_focusout D-Bus signals.
This commit is contained in:
parent
9e607b2543
commit
dfd4dd1122
4 changed files with 56 additions and 1 deletions
|
@ -17,6 +17,7 @@ shadow-ignore-shaped = false;
|
||||||
# Opacity
|
# Opacity
|
||||||
menu-opacity = 0.8;
|
menu-opacity = 0.8;
|
||||||
inactive-opacity = 0.8;
|
inactive-opacity = 0.8;
|
||||||
|
# active-opacity = 0.8;
|
||||||
frame-opacity = 0.7;
|
frame-opacity = 0.7;
|
||||||
inactive-opacity-override = false;
|
inactive-opacity-override = false;
|
||||||
alpha-step = 0.06;
|
alpha-step = 0.06;
|
||||||
|
|
|
@ -424,6 +424,8 @@ typedef struct {
|
||||||
/// 32-bit integer with the format of _NET_WM_OPACITY. 0 stands for
|
/// 32-bit integer with the format of _NET_WM_OPACITY. 0 stands for
|
||||||
/// not enabled, default.
|
/// not enabled, default.
|
||||||
opacity_t inactive_opacity;
|
opacity_t inactive_opacity;
|
||||||
|
/// Default opacity for inactive windows.
|
||||||
|
opacity_t active_opacity;
|
||||||
/// Whether inactive_opacity overrides the opacity set by window
|
/// Whether inactive_opacity overrides the opacity set by window
|
||||||
/// attributes.
|
/// attributes.
|
||||||
bool inactive_opacity_override;
|
bool inactive_opacity_override;
|
||||||
|
@ -1711,6 +1713,12 @@ cdbus_ev_win_mapped(session_t *ps, win *w);
|
||||||
|
|
||||||
void
|
void
|
||||||
cdbus_ev_win_unmapped(session_t *ps, win *w);
|
cdbus_ev_win_unmapped(session_t *ps, win *w);
|
||||||
|
|
||||||
|
void
|
||||||
|
cdbus_ev_win_focusout(session_t *ps, win *w);
|
||||||
|
|
||||||
|
void
|
||||||
|
cdbus_ev_win_focusin(session_t *ps, win *w);
|
||||||
//!@}
|
//!@}
|
||||||
|
|
||||||
/** @name DBus hooks
|
/** @name DBus hooks
|
||||||
|
|
|
@ -2153,6 +2153,10 @@ calc_opacity(session_t *ps, win *w) {
|
||||||
&& (OPAQUE == opacity || ps->o.inactive_opacity_override)) {
|
&& (OPAQUE == opacity || ps->o.inactive_opacity_override)) {
|
||||||
opacity = ps->o.inactive_opacity;
|
opacity = ps->o.inactive_opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Respect active_opacity only when the window is physically focused
|
||||||
|
if (OPAQUE == opacity && ps->o.active_opacity && w->focused_real)
|
||||||
|
opacity = ps->o.active_opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
w->opacity_tgt = opacity;
|
w->opacity_tgt = opacity;
|
||||||
|
@ -3136,6 +3140,16 @@ win_set_focused(session_t *ps, win *w, bool focused) {
|
||||||
|
|
||||||
// Update everything related to conditions
|
// Update everything related to conditions
|
||||||
win_on_factor_change(ps, w);
|
win_on_factor_change(ps, w);
|
||||||
|
|
||||||
|
#ifdef CONFIG_DBUS
|
||||||
|
// Send D-Bus signal
|
||||||
|
if (ps->o.dbus) {
|
||||||
|
if (w->focused_real)
|
||||||
|
cdbus_ev_win_focusin(ps, w);
|
||||||
|
else
|
||||||
|
cdbus_ev_win_focusout(ps, w);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -4095,6 +4109,8 @@ usage(void) {
|
||||||
" Inactive opacity set by -i overrides value of _NET_WM_OPACITY.\n"
|
" Inactive opacity set by -i overrides value of _NET_WM_OPACITY.\n"
|
||||||
"--inactive-dim value\n"
|
"--inactive-dim value\n"
|
||||||
" Dim inactive windows. (0.0 - 1.0, defaults to 0)\n"
|
" Dim inactive windows. (0.0 - 1.0, defaults to 0)\n"
|
||||||
|
"--active-opacity opacity\n"
|
||||||
|
" Default opacity for active windows. (0.0 - 1.0)\n"
|
||||||
"--mark-wmwin-focused\n"
|
"--mark-wmwin-focused\n"
|
||||||
" Try to detect WM windows and mark them as active.\n"
|
" Try to detect WM windows and mark them as active.\n"
|
||||||
"--shadow-exclude condition\n"
|
"--shadow-exclude condition\n"
|
||||||
|
@ -4520,6 +4536,9 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
|
||||||
// -i (inactive_opacity)
|
// -i (inactive_opacity)
|
||||||
if (config_lookup_float(&cfg, "inactive-opacity", &dval))
|
if (config_lookup_float(&cfg, "inactive-opacity", &dval))
|
||||||
ps->o.inactive_opacity = normalize_d(dval) * OPAQUE;
|
ps->o.inactive_opacity = normalize_d(dval) * OPAQUE;
|
||||||
|
// --active_opacity
|
||||||
|
if (config_lookup_float(&cfg, "active-opacity", &dval))
|
||||||
|
ps->o.active_opacity = normalize_d(dval) * OPAQUE;
|
||||||
// -e (frame_opacity)
|
// -e (frame_opacity)
|
||||||
config_lookup_float(&cfg, "frame-opacity", &ps->o.frame_opacity);
|
config_lookup_float(&cfg, "frame-opacity", &ps->o.frame_opacity);
|
||||||
// -z (clear_shadow)
|
// -z (clear_shadow)
|
||||||
|
@ -4682,6 +4701,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
{ "benchmark-wid", required_argument, NULL, 294 },
|
{ "benchmark-wid", required_argument, NULL, 294 },
|
||||||
{ "glx-use-copysubbuffermesa", no_argument, NULL, 295 },
|
{ "glx-use-copysubbuffermesa", no_argument, NULL, 295 },
|
||||||
{ "blur-background-exclude", required_argument, NULL, 296 },
|
{ "blur-background-exclude", required_argument, NULL, 296 },
|
||||||
|
{ "active-opacity", required_argument, NULL, 297 },
|
||||||
// Must terminate with a NULL entry
|
// Must terminate with a NULL entry
|
||||||
{ NULL, 0, NULL, 0 },
|
{ NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
@ -4968,6 +4988,10 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
// --blur-background-exclude
|
// --blur-background-exclude
|
||||||
condlst_add(ps, &ps->o.blur_background_blacklist, optarg);
|
condlst_add(ps, &ps->o.blur_background_blacklist, optarg);
|
||||||
break;
|
break;
|
||||||
|
case 297:
|
||||||
|
// --active-opacity
|
||||||
|
ps->o.active_opacity = (normalize_d(atof(optarg)) * OPAQUE);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
|
@ -4993,6 +5017,9 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
if (OPAQUE == ps->o.inactive_opacity) {
|
if (OPAQUE == ps->o.inactive_opacity) {
|
||||||
ps->o.inactive_opacity = 0;
|
ps->o.inactive_opacity = 0;
|
||||||
}
|
}
|
||||||
|
if (OPAQUE == ps->o.active_opacity) {
|
||||||
|
ps->o.active_opacity = 0;
|
||||||
|
}
|
||||||
if (shadow_enable)
|
if (shadow_enable)
|
||||||
wintype_arr_enable(ps->o.wintype_shadow);
|
wintype_arr_enable(ps->o.wintype_shadow);
|
||||||
ps->o.wintype_shadow[WINTYPE_DESKTOP] = false;
|
ps->o.wintype_shadow[WINTYPE_DESKTOP] = false;
|
||||||
|
@ -5018,7 +5045,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
// Other variables determined by options
|
// Other variables determined by options
|
||||||
|
|
||||||
// Determine whether we need to track focus changes
|
// Determine whether we need to track focus changes
|
||||||
if (ps->o.inactive_opacity || ps->o.inactive_dim) {
|
if (ps->o.inactive_opacity || ps->o.active_opacity || ps->o.inactive_dim) {
|
||||||
ps->o.track_focus = true;
|
ps->o.track_focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5840,6 +5867,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
.wintype_opacity = { 0.0 },
|
.wintype_opacity = { 0.0 },
|
||||||
.inactive_opacity = 0,
|
.inactive_opacity = 0,
|
||||||
.inactive_opacity_override = false,
|
.inactive_opacity_override = false,
|
||||||
|
.active_opacity = 0,
|
||||||
.frame_opacity = 0.0,
|
.frame_opacity = 0.0,
|
||||||
.detect_client_opacity = false,
|
.detect_client_opacity = false,
|
||||||
.alpha_step = 0.03,
|
.alpha_step = 0.03,
|
||||||
|
|
18
src/dbus.c
18
src/dbus.c
|
@ -1033,6 +1033,12 @@ cdbus_process_introspect(session_t *ps, DBusMessage *msg) {
|
||||||
" <signal name='win_unmapped'>\n"
|
" <signal name='win_unmapped'>\n"
|
||||||
" <arg name='wid' type='" CDBUS_TYPE_WINDOW_STR "'/>\n"
|
" <arg name='wid' type='" CDBUS_TYPE_WINDOW_STR "'/>\n"
|
||||||
" </signal>\n"
|
" </signal>\n"
|
||||||
|
" <signal name='win_focusin'>\n"
|
||||||
|
" <arg name='wid' type='" CDBUS_TYPE_WINDOW_STR "'/>\n"
|
||||||
|
" </signal>\n"
|
||||||
|
" <signal name='win_focusout'>\n"
|
||||||
|
" <arg name='wid' type='" CDBUS_TYPE_WINDOW_STR "'/>\n"
|
||||||
|
" </signal>\n"
|
||||||
" <method name='reset' />\n"
|
" <method name='reset' />\n"
|
||||||
" </interface>\n"
|
" </interface>\n"
|
||||||
"</node>\n";
|
"</node>\n";
|
||||||
|
@ -1069,4 +1075,16 @@ cdbus_ev_win_unmapped(session_t *ps, win *w) {
|
||||||
if (ps->dbus_conn)
|
if (ps->dbus_conn)
|
||||||
cdbus_signal_wid(ps, "win_unmapped", w->id);
|
cdbus_signal_wid(ps, "win_unmapped", w->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cdbus_ev_win_focusout(session_t *ps, win *w) {
|
||||||
|
if (ps->dbus_conn)
|
||||||
|
cdbus_signal_wid(ps, "win_focusout", w->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cdbus_ev_win_focusin(session_t *ps, win *w) {
|
||||||
|
if (ps->dbus_conn)
|
||||||
|
cdbus_signal_wid(ps, "win_focusin", w->id);
|
||||||
|
}
|
||||||
//!@}
|
//!@}
|
||||||
|
|
Loading…
Reference in a new issue