mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	ipc: add window::mark event
This commit is contained in:
		
							parent
							
								
									dd6debf367
								
							
						
					
					
						commit
						317217f2c8
					
				
					 4 changed files with 21 additions and 5 deletions
				
			
		| 
						 | 
					@ -311,6 +311,8 @@ void view_clear_marks(struct sway_view *view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool view_has_mark(struct sway_view *view, char *mark);
 | 
					bool view_has_mark(struct sway_view *view, char *mark);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void view_add_mark(struct sway_view *view, char *mark);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_update_marks_textures(struct sway_view *view);
 | 
					void view_update_marks_textures(struct sway_view *view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
 | 
				
			||||||
	view_find_and_unmark(mark);
 | 
						view_find_and_unmark(mark);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!toggle || !had_mark) {
 | 
						if (!toggle || !had_mark) {
 | 
				
			||||||
		list_add(view->marks, strdup(mark));
 | 
							view_add_mark(view, mark);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	free(mark);
 | 
						free(mark);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -201,6 +201,15 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
 | 
				
			||||||
	bool urgent = c->type == C_VIEW ?
 | 
						bool urgent = c->type == C_VIEW ?
 | 
				
			||||||
		view_is_urgent(c->sway_view) : container_has_urgent_child(c);
 | 
							view_is_urgent(c->sway_view) : container_has_urgent_child(c);
 | 
				
			||||||
	json_object_object_add(object, "urgent", json_object_new_boolean(urgent));
 | 
						json_object_object_add(object, "urgent", json_object_new_boolean(urgent));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (c->type == C_VIEW) {
 | 
				
			||||||
 | 
							json_object *marks = json_object_new_array();
 | 
				
			||||||
 | 
							list_t *view_marks = c->sway_view->marks;
 | 
				
			||||||
 | 
							for (int i = 0; i < view_marks->length; ++i) {
 | 
				
			||||||
 | 
								json_object_array_add(marks, json_object_new_string(view_marks->items[i]));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							json_object_object_add(object, "marks", marks);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void focus_inactive_children_iterator(struct sway_container *c, void *data) {
 | 
					static void focus_inactive_children_iterator(struct sway_container *c, void *data) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -888,6 +888,7 @@ bool view_find_and_unmark(char *mark) {
 | 
				
			||||||
			free(view_mark);
 | 
								free(view_mark);
 | 
				
			||||||
			list_del(view->marks, i);
 | 
								list_del(view->marks, i);
 | 
				
			||||||
			view_update_marks_textures(view);
 | 
								view_update_marks_textures(view);
 | 
				
			||||||
 | 
								ipc_event_window(container, "mark");
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -895,11 +896,10 @@ bool view_find_and_unmark(char *mark) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_clear_marks(struct sway_view *view) {
 | 
					void view_clear_marks(struct sway_view *view) {
 | 
				
			||||||
	for (int i = 0; i < view->marks->length; ++i) {
 | 
						while (view->marks->length) {
 | 
				
			||||||
		free(view->marks->items[i]);
 | 
							list_del(view->marks, 0);
 | 
				
			||||||
 | 
							ipc_event_window(view->swayc, "mark");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	list_free(view->marks);
 | 
					 | 
				
			||||||
	view->marks = create_list();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool view_has_mark(struct sway_view *view, char *mark) {
 | 
					bool view_has_mark(struct sway_view *view, char *mark) {
 | 
				
			||||||
| 
						 | 
					@ -912,6 +912,11 @@ bool view_has_mark(struct sway_view *view, char *mark) {
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void view_add_mark(struct sway_view *view, char *mark) {
 | 
				
			||||||
 | 
						list_add(view->marks, strdup(mark));
 | 
				
			||||||
 | 
						ipc_event_window(view->swayc, "mark");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void update_marks_texture(struct sway_view *view,
 | 
					static void update_marks_texture(struct sway_view *view,
 | 
				
			||||||
		struct wlr_texture **texture, struct border_colors *class) {
 | 
							struct wlr_texture **texture, struct border_colors *class) {
 | 
				
			||||||
	struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
 | 
						struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue