mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-02 06:46:29 -04:00
fix: crash when switch session
This commit is contained in:
parent
4c59533fad
commit
a032f817b4
2 changed files with 141 additions and 141 deletions
280
maomao.c
280
maomao.c
|
|
@ -2168,62 +2168,62 @@ cleanupkeyboard(struct wl_listener *listener, void *data) {
|
||||||
free(kb);
|
free(kb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void // 0.5 custom
|
void
|
||||||
cleanupmon(struct wl_listener *listener, void *data) {
|
cleanupmon(struct wl_listener *listener, void *data)
|
||||||
Monitor *m = wl_container_of(listener, m, destroy);
|
|
||||||
LayerSurface *l, *tmp;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
/* m->layers[i] are intentionally not unlinked */
|
|
||||||
for (i = 0; i < LENGTH(m->layers); i++) {
|
|
||||||
wl_list_for_each_safe(l, tmp, &m->layers[i], link)
|
|
||||||
wlr_layer_surface_v1_destroy(l->layer_surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_list_remove(&m->destroy.link);
|
|
||||||
wl_list_remove(&m->frame.link);
|
|
||||||
wl_list_remove(&m->link);
|
|
||||||
wl_list_remove(&m->request_state.link);
|
|
||||||
m->wlr_output->data = NULL;
|
|
||||||
wlr_output_layout_remove(output_layout, m->wlr_output);
|
|
||||||
wlr_scene_output_destroy(m->scene_output);
|
|
||||||
|
|
||||||
closemon(m);
|
|
||||||
// wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
|
||||||
free(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
void closemon(Monitor *m) // 0.5 custom
|
|
||||||
{
|
{
|
||||||
/* update selmon if needed and
|
Monitor *m = wl_container_of(listener, m, destroy);
|
||||||
* move closed monitor's clients to the focused one */
|
LayerSurface *l, *tmp;
|
||||||
Client *c;
|
size_t i;
|
||||||
int i = 0, nmons = wl_list_length(&mons);
|
|
||||||
if (!nmons) {
|
|
||||||
selmon = NULL;
|
|
||||||
} else if (m == selmon) {
|
|
||||||
do /* don't switch to disabled mons */
|
|
||||||
selmon = wl_container_of(mons.next, selmon, link);
|
|
||||||
while (!selmon->wlr_output->enabled && i++ < nmons);
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_list_for_each(c, &clients, link) {
|
/* m->layers[i] are intentionally not unlinked */
|
||||||
if (c->isfloating && c->geom.x > m->m.width)
|
for (i = 0; i < LENGTH(m->layers); i++) {
|
||||||
resize(c,
|
wl_list_for_each_safe(l, tmp, &m->layers[i], link)
|
||||||
(struct wlr_box){.x = c->geom.x - m->w.width,
|
wlr_layer_surface_v1_destroy(l->layer_surface);
|
||||||
.y = c->geom.y,
|
}
|
||||||
.width = c->geom.width,
|
|
||||||
.height = c->geom.height},
|
wl_list_remove(&m->destroy.link);
|
||||||
0);
|
wl_list_remove(&m->frame.link);
|
||||||
if (c->mon == m) {
|
wl_list_remove(&m->link);
|
||||||
setmon(c, selmon, c->tags);
|
wl_list_remove(&m->request_state.link);
|
||||||
reset_foreign_tolevel(c);
|
m->wlr_output->data = NULL;
|
||||||
}
|
wlr_output_layout_remove(output_layout, m->wlr_output);
|
||||||
}
|
wlr_scene_output_destroy(m->scene_output);
|
||||||
focusclient(focustop(selmon), 1);
|
|
||||||
printstatus();
|
closemon(m);
|
||||||
|
// wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||||
|
free(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
closemon(Monitor *m)
|
||||||
|
{
|
||||||
|
/* update selmon if needed and
|
||||||
|
* move closed monitor's clients to the focused one */
|
||||||
|
Client *c;
|
||||||
|
int i = 0, nmons = wl_list_length(&mons);
|
||||||
|
if (!nmons) {
|
||||||
|
selmon = NULL;
|
||||||
|
} else if (m == selmon) {
|
||||||
|
do /* don't switch to disabled mons */
|
||||||
|
selmon = wl_container_of(mons.next, selmon, link);
|
||||||
|
while (!selmon->wlr_output->enabled && i++ < nmons);
|
||||||
|
|
||||||
|
if (!selmon->wlr_output->enabled)
|
||||||
|
selmon = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_list_for_each(c, &clients, link) {
|
||||||
|
if (c->isfloating && c->geom.x > m->m.width)
|
||||||
|
resize(c, (struct wlr_box){.x = c->geom.x - m->w.width, .y = c->geom.y,
|
||||||
|
.width = c->geom.width, .height = c->geom.height}, 0);
|
||||||
|
if (c->mon == m)
|
||||||
|
setmon(c, selmon, c->tags);
|
||||||
|
}
|
||||||
|
focusclient(focustop(selmon), 1);
|
||||||
|
printstatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
LayerSurface *l = wl_container_of(listener, l, surface_commit);
|
LayerSurface *l = wl_container_of(listener, l, surface_commit);
|
||||||
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
|
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
|
||||||
|
|
@ -6252,110 +6252,110 @@ void unmapnotify(struct wl_listener *listener, void *data) {
|
||||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void // 0.5 custom
|
void
|
||||||
updatemons(struct wl_listener *listener, void *data) {
|
updatemons(struct wl_listener *listener, void *data)
|
||||||
/*
|
{
|
||||||
* Called whenever the output layout changes: adding or removing a
|
/*
|
||||||
* monitor, changing an output's mode or position, etc. This is where
|
* Called whenever the output layout changes: adding or removing a
|
||||||
* the change officially happens and we update geometry, window
|
* monitor, changing an output's mode or position, etc. This is where
|
||||||
* positions, focus, and the stored configuration in wlroots'
|
* the change officially happens and we update geometry, window
|
||||||
* output-manager implementation.
|
* positions, focus, and the stored configuration in wlroots'
|
||||||
*/
|
* output-manager implementation.
|
||||||
struct wlr_output_configuration_v1 *config =
|
*/
|
||||||
wlr_output_configuration_v1_create();
|
struct wlr_output_configuration_v1 *config
|
||||||
Client *c;
|
= wlr_output_configuration_v1_create();
|
||||||
struct wlr_output_configuration_head_v1 *config_head;
|
Client *c;
|
||||||
Monitor *m;
|
struct wlr_output_configuration_head_v1 *config_head;
|
||||||
|
Monitor *m;
|
||||||
|
|
||||||
/* First remove from the layout the disabled monitors */
|
/* First remove from the layout the disabled monitors */
|
||||||
wl_list_for_each(m, &mons, link) {
|
wl_list_for_each(m, &mons, link) {
|
||||||
if (m->wlr_output->enabled || m->asleep)
|
if (m->wlr_output->enabled || m->asleep)
|
||||||
continue;
|
continue;
|
||||||
config_head =
|
config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
|
||||||
wlr_output_configuration_head_v1_create(config, m->wlr_output);
|
config_head->state.enabled = 0;
|
||||||
config_head->state.enabled = 0;
|
/* Remove this output from the layout to avoid cursor enter inside it */
|
||||||
/* Remove this output from the layout to avoid cursor enter inside it */
|
wlr_output_layout_remove(output_layout, m->wlr_output);
|
||||||
wlr_output_layout_remove(output_layout, m->wlr_output);
|
closemon(m);
|
||||||
closemon(m);
|
m->m = m->w = (struct wlr_box){0};
|
||||||
m->m = m->w = (struct wlr_box){0};
|
}
|
||||||
}
|
/* Insert outputs that need to */
|
||||||
/* Insert outputs that need to */
|
wl_list_for_each(m, &mons, link) {
|
||||||
wl_list_for_each(m, &mons, link) {
|
if (m->wlr_output->enabled
|
||||||
if (m->wlr_output->enabled &&
|
&& !wlr_output_layout_get(output_layout, m->wlr_output))
|
||||||
!wlr_output_layout_get(output_layout, m->wlr_output))
|
wlr_output_layout_add_auto(output_layout, m->wlr_output);
|
||||||
wlr_output_layout_add_auto(output_layout, m->wlr_output);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Now that we update the output layout we can get its box */
|
/* Now that we update the output layout we can get its box */
|
||||||
wlr_output_layout_get_box(output_layout, NULL, &sgeom);
|
wlr_output_layout_get_box(output_layout, NULL, &sgeom);
|
||||||
|
|
||||||
/* Make sure the clients are hidden when dwl is locked */
|
// wlr_scene_node_set_position(&root_bg->node, sgeom.x, sgeom.y);
|
||||||
wlr_scene_node_set_position(&locked_bg->node, sgeom.x, sgeom.y);
|
// wlr_scene_rect_set_size(root_bg, sgeom.width, sgeom.height);
|
||||||
wlr_scene_rect_set_size(locked_bg, sgeom.width, sgeom.height);
|
|
||||||
|
|
||||||
wl_list_for_each(m, &mons, link) {
|
/* Make sure the clients are hidden when dwl is locked */
|
||||||
if (!m->wlr_output->enabled)
|
wlr_scene_node_set_position(&locked_bg->node, sgeom.x, sgeom.y);
|
||||||
continue;
|
wlr_scene_rect_set_size(locked_bg, sgeom.width, sgeom.height);
|
||||||
config_head =
|
|
||||||
wlr_output_configuration_head_v1_create(config, m->wlr_output);
|
|
||||||
|
|
||||||
/* Get the effective monitor geometry to use for surfaces */
|
wl_list_for_each(m, &mons, link) {
|
||||||
wlr_output_layout_get_box(output_layout, m->wlr_output, &m->m);
|
if (!m->wlr_output->enabled)
|
||||||
m->w = m->m;
|
continue;
|
||||||
wlr_scene_output_set_position(m->scene_output, m->m.x, m->m.y);
|
config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
|
||||||
|
|
||||||
// wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
|
/* Get the effective monitor geometry to use for surfaces */
|
||||||
// wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
|
wlr_output_layout_get_box(output_layout, m->wlr_output, &m->m);
|
||||||
|
m->w = m->m;
|
||||||
|
wlr_scene_output_set_position(m->scene_output, m->m.x, m->m.y);
|
||||||
|
|
||||||
if (m->lock_surface) {
|
// wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
|
||||||
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
|
// wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
|
||||||
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
|
|
||||||
wlr_session_lock_surface_v1_configure(m->lock_surface, m->m.width,
|
|
||||||
m->m.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calculate the effective monitor geometry to use for clients */
|
if (m->lock_surface) {
|
||||||
arrangelayers(m);
|
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
|
||||||
/* Don't move clients to the left output when plugging monitors */
|
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
|
||||||
arrange(m, false);
|
wlr_session_lock_surface_v1_configure(m->lock_surface, m->m.width, m->m.height);
|
||||||
/* make sure fullscreen clients have the right size */
|
}
|
||||||
if ((c = focustop(m)) && c->isfullscreen)
|
|
||||||
resize(c, m->m, 0);
|
/* Calculate the effective monitor geometry to use for clients */
|
||||||
|
arrangelayers(m);
|
||||||
|
/* Don't move clients to the left output when plugging monitors */
|
||||||
|
arrange(m,false);
|
||||||
|
/* make sure fullscreen clients have the right size */
|
||||||
|
if ((c = focustop(m)) && c->isfullscreen)
|
||||||
|
resize(c, m->m, 0);
|
||||||
|
|
||||||
/* Try to re-set the gamma LUT when updating monitors,
|
/* Try to re-set the gamma LUT when updating monitors,
|
||||||
* it's only really needed when enabling a disabled output, but meh. */
|
* it's only really needed when enabling a disabled output, but meh. */
|
||||||
m->gamma_lut_changed = 1;
|
m->gamma_lut_changed = 1;
|
||||||
|
|
||||||
config_head->state.x = m->m.x;
|
config_head->state.x = m->m.x;
|
||||||
config_head->state.y = m->m.y;
|
config_head->state.y = m->m.y;
|
||||||
if (!selmon) {
|
|
||||||
selmon = m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selmon && selmon->wlr_output->enabled) {
|
if (!selmon) {
|
||||||
wl_list_for_each(c, &clients, link) {
|
selmon = m;
|
||||||
if (!c->mon && client_surface(c)->mapped) {
|
}
|
||||||
setmon(c, selmon, c->tags);
|
}
|
||||||
reset_foreign_tolevel(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
focusclient(focustop(selmon), 1);
|
|
||||||
if (selmon->lock_surface) {
|
|
||||||
client_notify_enter(selmon->lock_surface->surface,
|
|
||||||
wlr_seat_get_keyboard(seat));
|
|
||||||
client_activate_surface(selmon->lock_surface->surface, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: figure out why the cursor image is at 0,0 after turning all
|
if (selmon && selmon->wlr_output->enabled) {
|
||||||
* the monitors on.
|
wl_list_for_each(c, &clients, link) {
|
||||||
* Move the cursor image where it used to be. It does not generate a
|
if (!c->mon && client_surface(c)->mapped)
|
||||||
* wl_pointer.motion event for the clients, it's only the image what it's
|
setmon(c, selmon, c->tags);
|
||||||
* at the wrong position after all. */
|
}
|
||||||
wlr_cursor_move(cursor, NULL, 0, 0);
|
focusclient(focustop(selmon), 1);
|
||||||
|
if (selmon->lock_surface) {
|
||||||
|
client_notify_enter(selmon->lock_surface->surface,
|
||||||
|
wlr_seat_get_keyboard(seat));
|
||||||
|
client_activate_surface(selmon->lock_surface->surface, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wlr_output_manager_v1_set_configuration(output_mgr, config);
|
/* FIXME: figure out why the cursor image is at 0,0 after turning all
|
||||||
|
* the monitors on.
|
||||||
|
* Move the cursor image where it used to be. It does not generate a
|
||||||
|
* wl_pointer.motion event for the clients, it's only the image what it's
|
||||||
|
* at the wrong position after all. */
|
||||||
|
wlr_cursor_move(cursor, NULL, 0, 0);
|
||||||
|
|
||||||
|
wlr_output_manager_v1_set_configuration(output_mgr, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updatetitle(struct wl_listener *listener, void *data) {
|
void updatetitle(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ double default_mfact = 0.55f; // master 窗口比例
|
||||||
double default_smfact = 0.5f; // 第一个stack窗口比例
|
double default_smfact = 0.5f; // 第一个stack窗口比例
|
||||||
unsigned int default_nmaster = 1; // 默认master数量
|
unsigned int default_nmaster = 1; // 默认master数量
|
||||||
/* logging */
|
/* logging */
|
||||||
int log_level = WLR_ERROR;
|
int log_level = WLR_DEBUG;
|
||||||
unsigned int numlockon = 1; // 是否打开右边小键盘
|
unsigned int numlockon = 1; // 是否打开右边小键盘
|
||||||
unsigned int capslock = 0; // 是否启用快捷键
|
unsigned int capslock = 0; // 是否启用快捷键
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue