mirror of
				https://codeberg.org/dwl/dwl.git
				synced 2025-11-04 05:54:14 +00:00 
			
		
		
		
	Fix subsurface commit crash + avoid needles check
Always start listening for commit events in mapnotify. This allows to avoid checking c->mon each commit and fixes the crash opening applications who commit subsurfaces before mapping them
This commit is contained in:
		
							parent
							
								
									7996bfa7cc
								
							
						
					
					
						commit
						18c12c1f11
					
				
							
								
								
									
										14
									
								
								dwl.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								dwl.c
									
									
									
									
									
								
							@ -806,8 +806,7 @@ commitnotify(struct wl_listener *listener, void *data)
 | 
				
			|||||||
		c->resize = 0;
 | 
							c->resize = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Damage the whole screen
 | 
						// Damage the whole screen
 | 
				
			||||||
	if (c->mon)
 | 
						wlr_output_damage_add_whole(c->mon->damage);
 | 
				
			||||||
		wlr_output_damage_add_whole(c->mon->damage);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
@ -934,7 +933,6 @@ createnotify(struct wl_listener *listener, void *data)
 | 
				
			|||||||
	wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP |
 | 
						wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP |
 | 
				
			||||||
			WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
 | 
								WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LISTEN(&xdg_surface->surface->events.commit, &c->commit, commitnotify);
 | 
					 | 
				
			||||||
	LISTEN(&xdg_surface->surface->events.new_subsurface, &c->new_sub, new_subnotify);
 | 
						LISTEN(&xdg_surface->surface->events.new_subsurface, &c->new_sub, new_subnotify);
 | 
				
			||||||
	LISTEN(&xdg_surface->events.map, &c->map, mapnotify);
 | 
						LISTEN(&xdg_surface->events.map, &c->map, mapnotify);
 | 
				
			||||||
	LISTEN(&xdg_surface->events.unmap, &c->unmap, unmapnotify);
 | 
						LISTEN(&xdg_surface->events.unmap, &c->unmap, unmapnotify);
 | 
				
			||||||
@ -1414,9 +1412,10 @@ mapnotify(struct wl_listener *listener, void *data)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef XWAYLAND
 | 
					#ifdef XWAYLAND
 | 
				
			||||||
	if (c->type != XDGShell)
 | 
						if (c->type != XDGShell)
 | 
				
			||||||
		if (c->surface.xwayland->surface)
 | 
							LISTEN(&c->surface.xwayland->surface->events.commit, &c->commit, commitnotifyx11);
 | 
				
			||||||
			LISTEN(&c->surface.xwayland->surface->events.commit, &c->commit, commitnotifyx11);
 | 
						else
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
							LISTEN(&c->surface.xdg->surface->events.commit, &c->commit, commitnotify);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (c->mon->fullscreenclient && c->mon->fullscreenclient == oldfocus
 | 
						if (c->mon->fullscreenclient && c->mon->fullscreenclient == oldfocus
 | 
				
			||||||
			&& !c->isfloating && c->mon->lt[c->mon->sellt]->arrange) {
 | 
								&& !c->isfloating && c->mon->lt[c->mon->sellt]->arrange) {
 | 
				
			||||||
@ -1433,6 +1432,7 @@ mapnotify_sub(struct wl_listener *listener, void *data)
 | 
				
			|||||||
	Subsurface *s = wl_container_of(listener, s, map);
 | 
						Subsurface *s = wl_container_of(listener, s, map);
 | 
				
			||||||
	wl_list_insert(&subsurfaces, &s->link);
 | 
						wl_list_insert(&subsurfaces, &s->link);
 | 
				
			||||||
	wlr_output_damage_add_whole(s->c->mon->damage);
 | 
						wlr_output_damage_add_whole(s->c->mon->damage);
 | 
				
			||||||
 | 
						LISTEN(&s->subsurface->surface->events.commit, &s->commit, commitnotify_sub);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1581,7 +1581,6 @@ new_subnotify(struct wl_listener *listener, void *data) {
 | 
				
			|||||||
	s->subsurface = subsurface;
 | 
						s->subsurface = subsurface;
 | 
				
			||||||
	s->c = wl_container_of(listener, s->c, new_sub);
 | 
						s->c = wl_container_of(listener, s->c, new_sub);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LISTEN(&s->subsurface->surface->events.commit, &s->commit, commitnotify_sub);
 | 
					 | 
				
			||||||
	LISTEN(&s->subsurface->events.map, &s->map, mapnotify_sub);
 | 
						LISTEN(&s->subsurface->events.map, &s->map, mapnotify_sub);
 | 
				
			||||||
	LISTEN(&s->subsurface->events.unmap, &s->unmap, unmapnotify_sub);
 | 
						LISTEN(&s->subsurface->events.unmap, &s->unmap, unmapnotify_sub);
 | 
				
			||||||
	LISTEN(&s->subsurface->events.destroy, &s->destroy, destroynotify_sub);
 | 
						LISTEN(&s->subsurface->events.destroy, &s->destroy, destroynotify_sub);
 | 
				
			||||||
@ -2573,8 +2572,7 @@ commitnotifyx11(struct wl_listener *listener, void *data)
 | 
				
			|||||||
	Client *c = wl_container_of(listener, c, commit);
 | 
						Client *c = wl_container_of(listener, c, commit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Damage the whole screen
 | 
						// Damage the whole screen
 | 
				
			||||||
	if (c->mon)
 | 
						wlr_output_damage_add_whole(c->mon->damage);
 | 
				
			||||||
		wlr_output_damage_add_whole(c->mon->damage);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Atom
 | 
					Atom
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user