opt: optimize xwayland focus ignore judge
This commit is contained in:
@@ -402,7 +402,22 @@ static inline void client_set_suspended(Client *c, int suspended) {
|
|||||||
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
|
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int client_should_ignore_focus(Client *c) {
|
static inline int client_should_ignore_focus_always(Client *c) {
|
||||||
|
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
if (client_is_x11(c)) {
|
||||||
|
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||||
|
|
||||||
|
if (!surface->hints)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return !surface->hints->input;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int client_should_ignore_focus_open(Client *c) {
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c)) {
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ int focuslast(const Arg *arg) {
|
|||||||
wl_list_for_each(c, &fstack, flink) {
|
wl_list_for_each(c, &fstack, flink) {
|
||||||
if (c->iskilling || c->isminied || c->isunglobal ||
|
if (c->iskilling || c->isminied || c->isunglobal ||
|
||||||
!client_surface(c)->mapped || client_is_unmanaged(c) ||
|
!client_surface(c)->mapped || client_is_unmanaged(c) ||
|
||||||
client_should_ignore_focus(c))
|
client_should_ignore_focus_open(c))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (selmon && !selmon->sel) {
|
if (selmon && !selmon->sel) {
|
||||||
@@ -1460,7 +1460,7 @@ int toggleoverview(const Arg *arg) {
|
|||||||
wl_list_for_each(c, &clients,
|
wl_list_for_each(c, &clients,
|
||||||
link) if (c && c->mon == selmon &&
|
link) if (c && c->mon == selmon &&
|
||||||
!client_is_unmanaged(c) &&
|
!client_is_unmanaged(c) &&
|
||||||
!client_should_ignore_focus(c) &&
|
!client_should_ignore_focus_open(c) &&
|
||||||
!c->isminied && !c->isunglobal) {
|
!c->isminied && !c->isunglobal) {
|
||||||
visible_client_number++;
|
visible_client_number++;
|
||||||
}
|
}
|
||||||
@@ -1484,14 +1484,15 @@ int toggleoverview(const Arg *arg) {
|
|||||||
if (selmon->isoverview) {
|
if (selmon->isoverview) {
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (c && c->mon == selmon && !client_is_unmanaged(c) &&
|
if (c && c->mon == selmon && !client_is_unmanaged(c) &&
|
||||||
!client_should_ignore_focus(c) && !c->isunglobal)
|
!client_should_ignore_focus_open(c) && !c->isunglobal)
|
||||||
overview_backup(c);
|
overview_backup(c);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (c && c->mon == selmon && !c->iskilling &&
|
if (c && c->mon == selmon && !c->iskilling &&
|
||||||
!client_is_unmanaged(c) && !c->isunglobal &&
|
!client_is_unmanaged(c) && !c->isunglobal &&
|
||||||
!client_should_ignore_focus(c) && client_surface(c)->mapped)
|
!client_should_ignore_focus_open(c) &&
|
||||||
|
client_surface(c)->mapped)
|
||||||
overview_restore(c, &(Arg){.ui = target});
|
overview_restore(c, &(Arg){.ui = target});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void grid(Monitor *m) {
|
|||||||
? 0
|
? 0
|
||||||
: borderpx;
|
: borderpx;
|
||||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||||
((m->isoverview && !client_should_ignore_focus(c)) ||
|
((m->isoverview && !client_should_ignore_focus_open(c)) ||
|
||||||
ISTILED(c))) {
|
ISTILED(c))) {
|
||||||
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
||||||
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
||||||
@@ -55,7 +55,7 @@ void grid(Monitor *m) {
|
|||||||
? 0
|
? 0
|
||||||
: borderpx;
|
: borderpx;
|
||||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||||
((m->isoverview && !client_should_ignore_focus(c)) ||
|
((m->isoverview && !client_should_ignore_focus_open(c)) ||
|
||||||
ISTILED(c))) {
|
ISTILED(c))) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
c->geom.x = m->w.x + target_gappo;
|
c->geom.x = m->w.x + target_gappo;
|
||||||
@@ -106,7 +106,8 @@ void grid(Monitor *m) {
|
|||||||
? 0
|
? 0
|
||||||
: borderpx;
|
: borderpx;
|
||||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||||
((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) {
|
((m->isoverview && !client_should_ignore_focus_open(c)) ||
|
||||||
|
ISTILED(c))) {
|
||||||
cx = m->w.x + (i % cols) * (cw + target_gappi);
|
cx = m->w.x + (i % cols) * (cw + target_gappi);
|
||||||
cy = m->w.y + (i / cols) * (ch + target_gappi);
|
cy = m->w.y + (i / cols) * (ch + target_gappi);
|
||||||
if (overcols && i >= n - overcols) {
|
if (overcols && i >= n - overcols) {
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ void vertical_grid(Monitor *m) {
|
|||||||
? 0
|
? 0
|
||||||
: borderpx;
|
: borderpx;
|
||||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||||
((m->isoverview && !client_should_ignore_focus(c)) ||
|
((m->isoverview && !client_should_ignore_focus_open(c)) ||
|
||||||
ISTILED(c))) {
|
ISTILED(c))) {
|
||||||
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
||||||
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
||||||
@@ -338,7 +338,7 @@ void vertical_grid(Monitor *m) {
|
|||||||
? 0
|
? 0
|
||||||
: borderpx;
|
: borderpx;
|
||||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||||
((m->isoverview && !client_should_ignore_focus(c)) ||
|
((m->isoverview && !client_should_ignore_focus_open(c)) ||
|
||||||
ISTILED(c))) {
|
ISTILED(c))) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo;
|
c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo;
|
||||||
@@ -385,7 +385,8 @@ void vertical_grid(Monitor *m) {
|
|||||||
? 0
|
? 0
|
||||||
: borderpx;
|
: borderpx;
|
||||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||||
((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) {
|
((m->isoverview && !client_should_ignore_focus_open(c)) ||
|
||||||
|
ISTILED(c))) {
|
||||||
cx = m->w.x + (i / rows) * (cw + target_gappi);
|
cx = m->w.x + (i / rows) * (cw + target_gappi);
|
||||||
cy = m->w.y + (i % rows) * (ch + target_gappi);
|
cy = m->w.y + (i % rows) * (ch + target_gappi);
|
||||||
if (overrows && i >= n - overrows) {
|
if (overrows && i >= n - overrows) {
|
||||||
|
|||||||
11
src/mango.c
11
src/mango.c
@@ -1305,7 +1305,7 @@ void applyrules(Client *c) {
|
|||||||
// if no geom rule hit and is normal winodw, use the center pos and record
|
// if no geom rule hit and is normal winodw, use the center pos and record
|
||||||
// the hit size
|
// the hit size
|
||||||
if (!hit_rule_pos &&
|
if (!hit_rule_pos &&
|
||||||
(!client_is_x11(c) || !client_should_ignore_focus(c))) {
|
(!client_is_x11(c) || !client_should_ignore_focus_open(c))) {
|
||||||
c->float_geom = c->geom = setclient_coordinate_center(c, c->geom, 0, 0);
|
c->float_geom = c->geom = setclient_coordinate_center(c, c->geom, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3080,9 +3080,8 @@ void focusclient(Client *c, int lift) {
|
|||||||
if (c && !client_surface(c)->mapped)
|
if (c && !client_surface(c)->mapped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (c && client_should_ignore_focus(c)) {
|
if (c && client_should_ignore_focus_always(c))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* Raise client in stacking order if requested */
|
/* Raise client in stacking order if requested */
|
||||||
if (c && lift)
|
if (c && lift)
|
||||||
@@ -3598,7 +3597,7 @@ mapnotify(struct wl_listener *listener, void *data) {
|
|||||||
init_client_properties(c);
|
init_client_properties(c);
|
||||||
|
|
||||||
// set special window properties
|
// set special window properties
|
||||||
if (client_is_unmanaged(c) || client_should_ignore_focus(c)) {
|
if (client_is_unmanaged(c) || client_should_ignore_focus_open(c)) {
|
||||||
c->bw = 0;
|
c->bw = 0;
|
||||||
c->isnoborder = 1;
|
c->isnoborder = 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -4399,7 +4398,7 @@ setfloating(Client *c, int floating) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重新计算居中的坐标
|
// 重新计算居中的坐标
|
||||||
if (!client_is_x11(c) || !client_should_ignore_focus(c))
|
if (!client_is_x11(c) || !client_should_ignore_focus_open(c))
|
||||||
target_box = setclient_coordinate_center(c, target_box, 0, 0);
|
target_box = setclient_coordinate_center(c, target_box, 0, 0);
|
||||||
backup_box = c->geom;
|
backup_box = c->geom;
|
||||||
hit = applyrulesgeom(c);
|
hit = applyrulesgeom(c);
|
||||||
@@ -4708,7 +4707,7 @@ void setmon(Client *c, Monitor *m, unsigned int newtags, bool focus) {
|
|||||||
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (focus) {
|
if (focus && !client_should_ignore_focus_open(c)) {
|
||||||
focusclient(focustop(selmon), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user