mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-20 05:34:39 -04:00
opt: optimize layer focus change logic
This commit is contained in:
parent
6cc7d16281
commit
263b1845bb
1 changed files with 23 additions and 14 deletions
37
src/mango.c
37
src/mango.c
|
|
@ -1690,7 +1690,7 @@ void focuslayer(LayerSurface *l) {
|
||||||
client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
|
client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_exclusive_layer(Monitor *m) {
|
void reset_exclusive_layers_focus(Monitor *m) {
|
||||||
LayerSurface *l = NULL;
|
LayerSurface *l = NULL;
|
||||||
int32_t i;
|
int32_t i;
|
||||||
bool neet_change_focus_to_client = false;
|
bool neet_change_focus_to_client = false;
|
||||||
|
|
@ -1704,7 +1704,7 @@ void reset_exclusive_layer(Monitor *m) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < (int32_t)LENGTH(layers_above_shell); i++) {
|
for (i = 0; i < (int32_t)LENGTH(layers_above_shell); i++) {
|
||||||
wl_list_for_each_reverse(l, &m->layers[layers_above_shell[i]], link) {
|
wl_list_for_each(l, &m->layers[layers_above_shell[i]], link) {
|
||||||
if (l == exclusive_focus &&
|
if (l == exclusive_focus &&
|
||||||
l->layer_surface->current.keyboard_interactive !=
|
l->layer_surface->current.keyboard_interactive !=
|
||||||
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) {
|
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) {
|
||||||
|
|
@ -1714,6 +1714,12 @@ void reset_exclusive_layer(Monitor *m) {
|
||||||
neet_change_focus_to_client = true;
|
neet_change_focus_to_client = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (l->layer_surface->surface ==
|
||||||
|
seat->keyboard_state.focused_surface &&
|
||||||
|
l->being_unmapped) {
|
||||||
|
neet_change_focus_to_client = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (l->layer_surface->current.keyboard_interactive ==
|
if (l->layer_surface->current.keyboard_interactive ==
|
||||||
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE &&
|
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE &&
|
||||||
l->layer_surface->surface ==
|
l->layer_surface->surface ==
|
||||||
|
|
@ -1724,11 +1730,14 @@ void reset_exclusive_layer(Monitor *m) {
|
||||||
if (locked ||
|
if (locked ||
|
||||||
l->layer_surface->current.keyboard_interactive !=
|
l->layer_surface->current.keyboard_interactive !=
|
||||||
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE ||
|
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE ||
|
||||||
!l->mapped || l == exclusive_focus)
|
l->being_unmapped)
|
||||||
continue;
|
continue;
|
||||||
/* Deactivate the focused client. */
|
/* Deactivate the focused client. */
|
||||||
exclusive_focus = l;
|
exclusive_focus = l;
|
||||||
focuslayer(l);
|
neet_change_focus_to_client = false;
|
||||||
|
if (l->layer_surface->surface !=
|
||||||
|
seat->keyboard_state.focused_surface)
|
||||||
|
focuslayer(l);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1757,9 +1766,6 @@ void arrangelayers(Monitor *m) {
|
||||||
/* Arrange non-exlusive surfaces from top->bottom */
|
/* Arrange non-exlusive surfaces from top->bottom */
|
||||||
for (i = 3; i >= 0; i--)
|
for (i = 3; i >= 0; i--)
|
||||||
arrangelayer(m, &m->layers[i], &usable_area, 0);
|
arrangelayer(m, &m->layers[i], &usable_area, 0);
|
||||||
|
|
||||||
/* Find topmost keyboard interactive layer, if such a layer exists */
|
|
||||||
reset_exclusive_layer(m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void // 鼠标滚轮事件
|
void // 鼠标滚轮事件
|
||||||
|
|
@ -2395,6 +2401,7 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
// 刷新布局,让窗口能感应到exclude_zone变化以及设置独占表面
|
// 刷新布局,让窗口能感应到exclude_zone变化以及设置独占表面
|
||||||
arrangelayers(l->mon);
|
arrangelayers(l->mon);
|
||||||
|
reset_exclusive_layers_focus(l->mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
|
|
@ -2414,7 +2421,6 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
l->layer_surface->current = l->layer_surface->pending;
|
l->layer_surface->current = l->layer_surface->pending;
|
||||||
arrangelayers(l->mon);
|
arrangelayers(l->mon);
|
||||||
l->layer_surface->current = old_state;
|
l->layer_surface->current = old_state;
|
||||||
|
|
||||||
// 按需交互layer只在map之前设置焦点
|
// 按需交互layer只在map之前设置焦点
|
||||||
if (!exclusive_focus &&
|
if (!exclusive_focus &&
|
||||||
l->layer_surface->current.keyboard_interactive ==
|
l->layer_surface->current.keyboard_interactive ==
|
||||||
|
|
@ -2482,6 +2488,7 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
arrangelayers(l->mon);
|
arrangelayers(l->mon);
|
||||||
|
reset_exclusive_layers_focus(l->mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void commitnotify(struct wl_listener *listener, void *data) {
|
void commitnotify(struct wl_listener *listener, void *data) {
|
||||||
|
|
@ -3340,7 +3347,7 @@ void destroylocksurface(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
if (lock_surface->surface != seat->keyboard_state.focused_surface) {
|
if (lock_surface->surface != seat->keyboard_state.focused_surface) {
|
||||||
if (exclusive_focus && !locked) {
|
if (exclusive_focus && !locked) {
|
||||||
reset_exclusive_layer(m);
|
reset_exclusive_layers_focus(m);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -3349,8 +3356,7 @@ void destroylocksurface(struct wl_listener *listener, void *data) {
|
||||||
surface = wl_container_of(cur_lock->surfaces.next, surface, link);
|
surface = wl_container_of(cur_lock->surfaces.next, surface, link);
|
||||||
client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat));
|
client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat));
|
||||||
} else if (!locked) {
|
} else if (!locked) {
|
||||||
reset_exclusive_layer(selmon);
|
reset_exclusive_layers_focus(selmon);
|
||||||
focusclient(focustop(selmon), 1);
|
|
||||||
} else {
|
} else {
|
||||||
wlr_seat_keyboard_clear_focus(seat);
|
wlr_seat_keyboard_clear_focus(seat);
|
||||||
}
|
}
|
||||||
|
|
@ -5846,17 +5852,20 @@ void unmaplayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
init_fadeout_layers(l);
|
init_fadeout_layers(l);
|
||||||
|
|
||||||
wlr_scene_node_set_enabled(&l->scene->node, false);
|
wlr_scene_node_set_enabled(&l->scene->node, false);
|
||||||
|
|
||||||
if (l == exclusive_focus)
|
if (l == exclusive_focus)
|
||||||
exclusive_focus = NULL;
|
exclusive_focus = NULL;
|
||||||
|
|
||||||
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
|
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
|
||||||
arrangelayers(l->mon);
|
arrangelayers(l->mon);
|
||||||
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
|
||||||
focusclient(focustop(selmon), 1);
|
reset_exclusive_layers_focus(l->mon);
|
||||||
|
|
||||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||||
l->being_unmapped = false;
|
|
||||||
layer_flush_blur_background(l);
|
layer_flush_blur_background(l);
|
||||||
wlr_scene_node_destroy(&l->shadow->node);
|
wlr_scene_node_destroy(&l->shadow->node);
|
||||||
l->shadow = NULL;
|
l->shadow = NULL;
|
||||||
|
l->being_unmapped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unmapnotify(struct wl_listener *listener, void *data) {
|
void unmapnotify(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue