mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Use scissor to render title texture
This allows the title's texture to always be the full width of the text, and clipped at render time according to the desired width (eg. tabs...). As an added bonus, the texture no longer needs to be updated when containers are arranged.
This commit is contained in:
		
							parent
							
								
									fbcbbb976c
								
							
						
					
					
						commit
						e83e5487be
					
				
					 3 changed files with 3 additions and 12 deletions
				
			
		| 
						 | 
					@ -308,12 +308,10 @@ static void render_container_simple_border_normal(struct sway_output *output,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Title text
 | 
						// Title text
 | 
				
			||||||
	if (title_texture) {
 | 
						if (title_texture) {
 | 
				
			||||||
		double x = (con->x + con->sway_view->border_thickness)
 | 
							wlr_renderer_scissor(renderer, &box);
 | 
				
			||||||
			* output->wlr_output->scale;
 | 
					 | 
				
			||||||
		double y = (con->y + con->sway_view->border_thickness)
 | 
					 | 
				
			||||||
			* output->wlr_output->scale;
 | 
					 | 
				
			||||||
		wlr_render_texture(renderer, title_texture,
 | 
							wlr_render_texture(renderer, title_texture,
 | 
				
			||||||
				output->wlr_output->transform_matrix, x, y, 1);
 | 
									output->wlr_output->transform_matrix, box.x, box.y, 1);
 | 
				
			||||||
 | 
							wlr_renderer_scissor(renderer, NULL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -203,7 +203,6 @@ void arrange_children_of(struct sway_container *parent) {
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			arrange_children_of(child);
 | 
								arrange_children_of(child);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		container_update_title_textures(child);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	container_damage_whole(parent);
 | 
						container_damage_whole(parent);
 | 
				
			||||||
	update_debug_tree();
 | 
						update_debug_tree();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -584,12 +584,6 @@ static void update_title_texture(struct sway_container *con,
 | 
				
			||||||
	get_text_size(c, config->font, &width, NULL, scale, false, "%s", con->name);
 | 
						get_text_size(c, config->font, &width, NULL, scale, false, "%s", con->name);
 | 
				
			||||||
	cairo_destroy(c);
 | 
						cairo_destroy(c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int borders = (con->type == C_VIEW ? con->sway_view->border_thickness :
 | 
					 | 
				
			||||||
			config->border_thickness) * 2 * scale;
 | 
					 | 
				
			||||||
	if (width > con->width * scale - borders) {
 | 
					 | 
				
			||||||
		width = con->width * scale - borders;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cairo_surface_t *surface = cairo_image_surface_create(
 | 
						cairo_surface_t *surface = cairo_image_surface_create(
 | 
				
			||||||
			CAIRO_FORMAT_ARGB32, width, height);
 | 
								CAIRO_FORMAT_ARGB32, width, height);
 | 
				
			||||||
	cairo_t *cairo = cairo_create(surface);
 | 
						cairo_t *cairo = cairo_create(surface);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue