mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	view: introduce view_matches_query()
Add new function view_matches_query() that will be required by If and ForEach actions in the future.
This commit is contained in:
		
							parent
							
								
									8988194785
								
							
						
					
					
						commit
						abb7c03c75
					
				
					 2 changed files with 53 additions and 0 deletions
				
			
		
							
								
								
									
										31
									
								
								src/view.c
									
										
									
									
									
								
							
							
						
						
									
										31
									
								
								src/view.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2,6 +2,7 @@
 | 
			
		|||
#include <assert.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <strings.h>
 | 
			
		||||
#include "common/match.h"
 | 
			
		||||
#include "common/mem.h"
 | 
			
		||||
#include "common/scene-helpers.h"
 | 
			
		||||
#include "labwc.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -51,6 +52,36 @@ view_from_wlr_surface(struct wlr_surface *surface)
 | 
			
		|||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
view_query_free(struct view_query *query)
 | 
			
		||||
{
 | 
			
		||||
	wl_list_remove(&query->link);
 | 
			
		||||
	free(query->identifier);
 | 
			
		||||
	free(query->title);
 | 
			
		||||
	free(query);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
view_matches_query(struct view *view, struct view_query *query)
 | 
			
		||||
{
 | 
			
		||||
	bool match = true;
 | 
			
		||||
	bool empty = true;
 | 
			
		||||
 | 
			
		||||
	const char *identifier = view_get_string_prop(view, "app_id");
 | 
			
		||||
	if (match && query->identifier) {
 | 
			
		||||
		empty = false;
 | 
			
		||||
		match &= match_glob(query->identifier, identifier);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const char *title = view_get_string_prop(view, "title");
 | 
			
		||||
	if (match && query->title) {
 | 
			
		||||
		empty = false;
 | 
			
		||||
		match &= match_glob(query->title, title);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return !empty && match;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool
 | 
			
		||||
matches_criteria(struct view *view, enum lab_view_criteria criteria)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue