Fix root change handling when screen is unredirected
If screen is not redirected, we don't need to reinitialize the backend when we got a root change event. Fixes #189 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
863e2c82ec
commit
5a034ea169
@ -747,31 +747,30 @@ static bool initialize_backend(session_t *ps) {
|
|||||||
/// Handle configure event of a root window
|
/// Handle configure event of a root window
|
||||||
void configure_root(session_t *ps, int width, int height) {
|
void configure_root(session_t *ps, int width, int height) {
|
||||||
log_info("Root configuration changed, new geometry: %dx%d", width, height);
|
log_info("Root configuration changed, new geometry: %dx%d", width, height);
|
||||||
// On root window changes
|
|
||||||
bool has_root_change = false;
|
bool has_root_change = false;
|
||||||
if (ps->o.experimental_backends) {
|
if (ps->redirected) {
|
||||||
has_root_change = ps->backend_data->ops->root_change != NULL;
|
// On root window changes
|
||||||
} else {
|
if (ps->o.experimental_backends) {
|
||||||
// Old backend can handle root change
|
assert(ps->backend_data);
|
||||||
has_root_change = true;
|
has_root_change = ps->backend_data->ops->root_change != NULL;
|
||||||
}
|
} else {
|
||||||
|
// Old backend can handle root change
|
||||||
|
has_root_change = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!has_root_change) {
|
if (!has_root_change) {
|
||||||
// deinit/reinit backend and free up resources if the backend
|
// deinit/reinit backend and free up resources if the backend
|
||||||
// cannot handle root change
|
// cannot handle root change
|
||||||
destroy_backend(ps);
|
destroy_backend(ps);
|
||||||
|
}
|
||||||
|
free_paint(ps, &ps->tgt_buffer);
|
||||||
}
|
}
|
||||||
free_paint(ps, &ps->tgt_buffer);
|
|
||||||
|
|
||||||
ps->root_width = width;
|
ps->root_width = width;
|
||||||
ps->root_height = height;
|
ps->root_height = height;
|
||||||
|
|
||||||
rebuild_screen_reg(ps);
|
rebuild_screen_reg(ps);
|
||||||
rebuild_shadow_exclude_reg(ps);
|
rebuild_shadow_exclude_reg(ps);
|
||||||
for (int i = 0; i < ps->ndamage; i++) {
|
|
||||||
pixman_region32_clear(&ps->damage_ring[i]);
|
|
||||||
}
|
|
||||||
ps->damage = ps->damage_ring + ps->ndamage - 1;
|
|
||||||
|
|
||||||
// Invalidate reg_ignore from the top
|
// Invalidate reg_ignore from the top
|
||||||
auto top_w = win_stack_find_next_managed(ps, &ps->window_stack);
|
auto top_w = win_stack_find_next_managed(ps, &ps->window_stack);
|
||||||
@ -780,30 +779,36 @@ void configure_root(session_t *ps, int width, int height) {
|
|||||||
top_w->reg_ignore_valid = false;
|
top_w->reg_ignore_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ps->redirected) {
|
||||||
|
for (int i = 0; i < ps->ndamage; i++) {
|
||||||
|
pixman_region32_clear(&ps->damage_ring[i]);
|
||||||
|
}
|
||||||
|
ps->damage = ps->damage_ring + ps->ndamage - 1;
|
||||||
#ifdef CONFIG_OPENGL
|
#ifdef CONFIG_OPENGL
|
||||||
// GLX root change callback
|
// GLX root change callback
|
||||||
if (BKEND_GLX == ps->o.backend && !ps->o.experimental_backends) {
|
if (BKEND_GLX == ps->o.backend && !ps->o.experimental_backends) {
|
||||||
glx_on_root_change(ps);
|
glx_on_root_change(ps);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (has_root_change) {
|
if (has_root_change) {
|
||||||
if (ps->backend_data != NULL) {
|
if (ps->backend_data != NULL) {
|
||||||
ps->backend_data->ops->root_change(ps->backend_data, ps);
|
ps->backend_data->ops->root_change(ps->backend_data, ps);
|
||||||
}
|
}
|
||||||
// Old backend's root_change is not a specific function
|
// Old backend's root_change is not a specific function
|
||||||
} else {
|
} else {
|
||||||
if (!initialize_backend(ps)) {
|
if (!initialize_backend(ps)) {
|
||||||
log_fatal("Failed to re-initialize backend after root "
|
log_fatal("Failed to re-initialize backend after root "
|
||||||
"change, aborting...");
|
"change, aborting...");
|
||||||
ps->quit = true;
|
ps->quit = true;
|
||||||
// TODO only event handlers should request ev_break,
|
// TODO only event handlers should request ev_break,
|
||||||
// otherwise it's too hard to keep track of what can break
|
// otherwise it's too hard to keep track of what can break
|
||||||
// the event loop
|
// the event loop
|
||||||
ev_break(ps->loop, EVBREAK_ALL);
|
ev_break(ps->loop, EVBREAK_ALL);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
force_repaint(ps);
|
||||||
}
|
}
|
||||||
force_repaint(ps);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user