Unify the failed-map teardown in one place
4a98470483f96eb346c2e3eb6b3e91c04c830180
1 parent
7820356c
swm.c
+17 -14
| 4001 | 4001 | wlr_scene_node_set_enabled(&c->scene->node, client_is_unmanaged(c)); |
|
| 4002 | 4002 | c->scene_surface = c->type == XDG_SHELL |
|
| 4003 | 4003 | ? wlr_scene_xdg_surface_create(c->scene, c->surface.xdg) |
|
| 4004 | 4004 | : wlr_scene_subsurface_tree_create(c->scene, client_surface(c)); |
|
| 4005 | 4005 | ||
| 4006 | - | if (!c->scene_surface) { |
|
| 4007 | - | wlr_scene_node_destroy(&c->scene->node); |
|
| 4008 | - | c->scene = client_surface(c)->data = nullptr; |
|
| 4009 | - | client_send_close(c); |
|
| 4010 | - | return; |
|
| 4011 | - | } |
|
| 4006 | + | if (!c->scene_surface) |
|
| 4007 | + | goto fail; |
|
| 4012 | 4008 | c->scene->node.data = c->scene_surface->node.data = c; |
|
| 4013 | 4009 | ||
| 4014 | 4010 | client_get_geometry(c, &c->geom); |
|
| 4015 | 4011 | ||
| 4016 | 4012 | /* Handle unmanaged windows before creating borders. */ |
| 4028 | 4024 | } |
|
| 4029 | 4025 | for (i = 0; i < 4; i++) { |
|
| 4030 | 4026 | c->border[i] = |
|
| 4031 | 4027 | wlr_scene_rect_create(c->scene, 0, 0, c->is_urgent ? urgentcolor : bordercolor); |
|
| 4032 | 4028 | ||
| 4033 | - | if (!c->border[i]) { |
|
| 4034 | - | wlr_scene_node_destroy(&c->scene->node); |
|
| 4035 | - | memset(c->border, 0, sizeof(c->border)); |
|
| 4036 | - | c->scene = client_surface(c)->data = nullptr; |
|
| 4037 | - | client_send_close(c); |
|
| 4038 | - | return; |
|
| 4039 | - | } |
|
| 4029 | + | if (!c->border[i]) |
|
| 4030 | + | goto fail; |
|
| 4040 | 4031 | c->border[i]->node.data = c; |
|
| 4041 | 4032 | } |
|
| 4042 | 4033 | /* Include the border in the window's initial size. */ |
|
| 4043 | 4034 | client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); |
|
| 4044 | 4035 | c->geom.width += 2 * c->bw; |
| 4100 | 4091 | ||
| 4101 | 4092 | if (c->mon) |
|
| 4102 | 4093 | arrange(c->mon); |
|
| 4103 | 4094 | print_status(); |
|
| 4104 | 4095 | ||
| 4096 | + | /* A new parentless window takes over a fullscreen window's display. */ |
|
| 4097 | + | if (p) |
|
| 4098 | + | return; |
|
| 4105 | 4099 | m = c->mon ? c->mon : point_to_monitor(c->geom.x, c->geom.y); |
|
| 4106 | 4100 | wl_list_for_each(w, &clients, link) { |
|
| 4107 | - | if (!p && w != c && w->is_fullscreen && m == w->mon && w->ws == c->ws) { |
|
| 4101 | + | if (w != c && w->is_fullscreen && m == w->mon && w->ws == c->ws) { |
|
| 4108 | 4102 | inherit_fullscreen = 1; |
|
| 4109 | 4103 | set_fullscreen(w, 0); |
|
| 4110 | 4104 | } |
|
| 4111 | 4105 | } |
|
| 4112 | 4106 | if (inherit_fullscreen) |
|
| 4113 | 4107 | set_fullscreen(c, 1); |
|
| 4108 | + | return; |
|
| 4109 | + | ||
| 4110 | + | fail: |
|
| 4111 | + | /* Undo the partially built scene and let the window try again. */ |
|
| 4112 | + | wlr_scene_node_destroy(&c->scene->node); |
|
| 4113 | + | memset(c->border, 0, sizeof(c->border)); |
|
| 4114 | + | c->scene = client_surface(c)->data = nullptr; |
|
| 4115 | + | c->scene_surface = nullptr; |
|
| 4116 | + | client_send_close(c); |
|
| 4114 | 4117 | } |
|
| 4115 | 4118 | ||
| 4116 | 4119 | /* Acknowledge unsupported maximize requests from older applications. */ |
|
| 4117 | 4120 | void maximize_notify(struct wl_listener *listener, void *data) { |
|
| 4118 | 4121 | /* swm does not support maximization, but older applications may still ask |