core: just enable track_focuse

It's not an intensive task.

Simplifies logic.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-05-25 00:02:16 +01:00
parent 57f4a99940
commit 7d8a3e09be
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
9 changed files with 8 additions and 63 deletions

View File

@ -25,9 +25,6 @@ type_enum='uint16'
# List all window ID compton manages (except destroyed ones) # List all window ID compton manages (except destroyed ones)
dbus-send --print-reply --dest="$service" "$object" "${interface}.list_win" dbus-send --print-reply --dest="$service" "$object" "${interface}.list_win"
# Ensure we are tracking focus
dbus-send --print-reply --dest="$service" "$object" "${interface}.opts_set" string:track_focus boolean:true
# Get window ID of currently focused window # Get window ID of currently focused window
focused=$(dbus-send --print-reply --dest="$service" "$object" "${interface}.find_win" string:focused | $SED -n 's/^[[:space:]]*'${type_win}'[[:space:]]*\([[:digit:]]*\).*/\1/p') focused=$(dbus-send --print-reply --dest="$service" "$object" "${interface}.find_win" string:focused | $SED -n 's/^[[:space:]]*'${type_win}'[[:space:]]*\([[:digit:]]*\).*/\1/p')

View File

@ -43,7 +43,6 @@ if [ -z "$1" -o "$1" = "selected" ]; then
window=$(xwininfo -frame | sed -n 's/^xwininfo: Window id: \(0x[[:xdigit:]][[:xdigit:]]*\).*/\1/p') # Select window by mouse window=$(xwininfo -frame | sed -n 's/^xwininfo: Window id: \(0x[[:xdigit:]][[:xdigit:]]*\).*/\1/p') # Select window by mouse
elif [ "$1" = "focused" ]; then elif [ "$1" = "focused" ]; then
# Ensure we are tracking focus # Ensure we are tracking focus
${compton_dbus}opts_set string:track_focus boolean:true &
window=$(${compton_dbus}find_win string:focused | $SED -n 's/^[[:space:]]*'${type_win}'[[:space:]]*\([[:digit:]]*\).*/\1/p') # Query compton for the active window window=$(${compton_dbus}find_win string:focused | $SED -n 's/^[[:space:]]*'${type_win}'[[:space:]]*\([[:digit:]]*\).*/\1/p') # Query compton for the active window
elif echo "$1" | grep -Eiq '^([[:digit:]][[:digit:]]*|0x[[:xdigit:]][[:xdigit:]]*)$'; then elif echo "$1" | grep -Eiq '^([[:digit:]][[:digit:]]*|0x[[:xdigit:]][[:xdigit:]]*)$'; then
window="$1" # Accept user-specified window-id if the format is correct window="$1" # Accept user-specified window-id if the format is correct

View File

@ -1031,7 +1031,6 @@ static bool c2_l_postprocess(session_t *ps, c2_l_t *pleaf) {
// Enable specific tracking options in compton if needed by the condition // Enable specific tracking options in compton if needed by the condition
// TODO: Add track_leader // TODO: Add track_leader
switch (pleaf->predef) { switch (pleaf->predef) {
case C2_L_PFOCUSED: ps->o.track_focus = true; break;
// case C2_L_PROUNDED: ps->o.detect_rounded_corners = true; break; // case C2_L_PROUNDED: ps->o.detect_rounded_corners = true; break;
case C2_L_PNAME: case C2_L_PNAME:
case C2_L_PCLASSG: case C2_L_PCLASSG:

View File

@ -491,9 +491,6 @@ void force_repaint(session_t *ps);
/** @name DBus hooks /** @name DBus hooks
*/ */
///@{ ///@{
void opts_init_track_focus(session_t *ps);
void opts_set_no_fading_openclose(session_t *ps, bool newval); void opts_set_no_fading_openclose(session_t *ps, bool newval);
//!@} //!@}
#endif #endif

View File

@ -297,8 +297,9 @@ uint32_t determine_evmask(session_t *ps, xcb_window_t wid, win_evmode_t mode) {
if (WIN_EVMODE_FRAME == mode || if (WIN_EVMODE_FRAME == mode ||
((w = find_managed_win(ps, wid)) && w->a.map_state == XCB_MAP_STATE_VIEWABLE)) { ((w = find_managed_win(ps, wid)) && w->a.map_state == XCB_MAP_STATE_VIEWABLE)) {
evmask |= XCB_EVENT_MASK_PROPERTY_CHANGE; evmask |= XCB_EVENT_MASK_PROPERTY_CHANGE;
if (ps->o.track_focus && !ps->o.use_ewmh_active_win) if (!ps->o.use_ewmh_active_win) {
evmask |= XCB_EVENT_MASK_FOCUS_CHANGE; evmask |= XCB_EVENT_MASK_FOCUS_CHANGE;
}
} }
// Check if it's a mapped client window // Check if it's a mapped client window
@ -807,36 +808,6 @@ void force_repaint(session_t *ps) {
*/ */
///@{ ///@{
/**
* Enable focus tracking.
*/
void opts_init_track_focus(session_t *ps) {
// Already tracking focus
if (ps->o.track_focus)
return;
ps->o.track_focus = true;
if (!ps->o.use_ewmh_active_win) {
// Start listening to FocusChange events
HASH_ITER2(ps->windows, w) {
if (!w->managed) {
continue;
}
auto mw = (struct managed_win *)w;
if (mw->a.map_state == XCB_MAP_STATE_VIEWABLE) {
xcb_change_window_attributes(
ps->c, w->id, XCB_CW_EVENT_MASK,
(const uint32_t[]){
determine_evmask(ps, w->id, WIN_EVMODE_FRAME)});
}
}
}
// Recheck focus
recheck_focus(ps);
}
/** /**
* Set no_fading_openclose option. * Set no_fading_openclose option.
* *
@ -1506,7 +1477,6 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
.detect_transient = false, .detect_transient = false,
.detect_client_leader = false, .detect_client_leader = false,
.track_focus = false,
.track_wdata = false, .track_wdata = false,
.track_leader = false, .track_leader = false,
}, },
@ -1991,9 +1961,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
} }
} }
if (ps->o.track_focus) { recheck_focus(ps);
recheck_focus(ps);
}
e = xcb_request_check(ps->c, xcb_ungrab_server(ps->c)); e = xcb_request_check(ps->c, xcb_ungrab_server(ps->c));
if (e) { if (e) {

View File

@ -217,8 +217,6 @@ typedef struct options_t {
bool detect_client_leader; bool detect_client_leader;
// === Calculated === // === Calculated ===
/// Whether compton needs to track focus changes.
bool track_focus;
/// Whether compton needs to track window name and class. /// Whether compton needs to track window name and class.
bool track_wdata; bool track_wdata;
/// Whether compton needs to track window leaders. /// Whether compton needs to track window leaders.

View File

@ -1042,7 +1042,7 @@ static bool cdbus_process_opts_get(session_t *ps, DBusMessage *msg) {
cdbus_m_opts_get_do(use_damage, cdbus_reply_bool); cdbus_m_opts_get_do(use_damage, cdbus_reply_bool);
#endif #endif
cdbus_m_opts_get_do(track_focus, cdbus_reply_bool); cdbus_m_opts_get_stub(track_focus, cdbus_reply_bool, true);
cdbus_m_opts_get_do(track_wdata, cdbus_reply_bool); cdbus_m_opts_get_do(track_wdata, cdbus_reply_bool);
cdbus_m_opts_get_do(track_leader, cdbus_reply_bool); cdbus_m_opts_get_do(track_leader, cdbus_reply_bool);
#undef cdbus_m_opts_get_do #undef cdbus_m_opts_get_do
@ -1128,18 +1128,12 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
} }
// clear_shadow // clear_shadow
if (!strcmp("clear_shadow", target)) if (!strcmp("clear_shadow", target)) {
goto cdbus_process_opts_set_success; goto cdbus_process_opts_set_success;
}
// track_focus // track_focus
if (!strcmp("track_focus", target)) { if (!strcmp("track_focus", target)) {
dbus_bool_t val = FALSE;
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_BOOLEAN, &val))
return false;
// You could enable this option, but never turn if off
if (val) {
opts_init_track_focus(ps);
}
goto cdbus_process_opts_set_success; goto cdbus_process_opts_set_success;
} }

View File

@ -266,9 +266,7 @@ static inline void ev_map_notify(session_t *ps, xcb_map_notify_event_t *ev) {
map_win_by_id(ps, ev->window); map_win_by_id(ps, ev->window);
// FocusIn/Out may be ignored when the window is unmapped, so we must // FocusIn/Out may be ignored when the window is unmapped, so we must
// recheck focus here // recheck focus here
if (ps->o.track_focus) { recheck_focus(ps);
recheck_focus(ps);
}
} }
static inline void ev_unmap_notify(session_t *ps, xcb_unmap_notify_event_t *ev) { static inline void ev_unmap_notify(session_t *ps, xcb_unmap_notify_event_t *ev) {
@ -402,7 +400,7 @@ static inline void ev_property_notify(session_t *ps, xcb_property_notify_event_t
} }
if (ps->root == ev->window) { if (ps->root == ev->window) {
if (ps->o.track_focus && ps->o.use_ewmh_active_win && if (ps->o.use_ewmh_active_win &&
ps->atoms->a_NET_ACTIVE_WINDOW == ev->atom) { ps->atoms->a_NET_ACTIVE_WINDOW == ev->atom) {
update_ewmh_active_win(ps); update_ewmh_active_win(ps);
} else { } else {

View File

@ -806,11 +806,6 @@ void get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
// Other variables determined by options // Other variables determined by options
// Determine whether we need to track focus changes
if (opt->inactive_opacity != opt->active_opacity || opt->inactive_dim > 0) {
opt->track_focus = true;
}
// Determine whether we track window grouping // Determine whether we track window grouping
if (opt->detect_transient || opt->detect_client_leader) { if (opt->detect_transient || opt->detect_client_leader) {
opt->track_leader = true; opt->track_leader = true;