mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Implement IPC_GET_MARKS
This commit is contained in:
		
							parent
							
								
									9731d080be
								
							
						
					
					
						commit
						a6d43ff746
					
				
					 1 changed files with 22 additions and 0 deletions
				
			
		| 
						 | 
					@ -22,6 +22,7 @@
 | 
				
			||||||
#include "sway/server.h"
 | 
					#include "sway/server.h"
 | 
				
			||||||
#include "sway/input/input-manager.h"
 | 
					#include "sway/input/input-manager.h"
 | 
				
			||||||
#include "sway/input/seat.h"
 | 
					#include "sway/input/seat.h"
 | 
				
			||||||
 | 
					#include "sway/tree/view.h"
 | 
				
			||||||
#include "list.h"
 | 
					#include "list.h"
 | 
				
			||||||
#include "log.h"
 | 
					#include "log.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -429,6 +430,16 @@ static void ipc_get_workspaces_callback(struct sway_container *workspace,
 | 
				
			||||||
			json_object_new_boolean(visible));
 | 
								json_object_new_boolean(visible));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void ipc_get_marks_callback(struct sway_container *con, void *data) {
 | 
				
			||||||
 | 
						json_object *marks = (json_object *)data;
 | 
				
			||||||
 | 
						if (con->type == C_VIEW && con->sway_view->marks) {
 | 
				
			||||||
 | 
							for (int i = 0; i < con->sway_view->marks->length; ++i) {
 | 
				
			||||||
 | 
								char *mark = (char *)con->sway_view->marks->items[i];
 | 
				
			||||||
 | 
								json_object_array_add(marks, json_object_new_string(mark));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ipc_client_handle_command(struct ipc_client *client) {
 | 
					void ipc_client_handle_command(struct ipc_client *client) {
 | 
				
			||||||
	if (!sway_assert(client != NULL, "client != NULL")) {
 | 
						if (!sway_assert(client != NULL, "client != NULL")) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -569,6 +580,17 @@ void ipc_client_handle_command(struct ipc_client *client) {
 | 
				
			||||||
		goto exit_cleanup;
 | 
							goto exit_cleanup;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						case IPC_GET_MARKS:
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							json_object *marks = json_object_new_array();
 | 
				
			||||||
 | 
							container_descendants(&root_container, C_VIEW, ipc_get_marks_callback,
 | 
				
			||||||
 | 
									marks);
 | 
				
			||||||
 | 
							const char *json_string = json_object_to_json_string(marks);
 | 
				
			||||||
 | 
							ipc_send_reply(client, json_string, (uint32_t)strlen(json_string));
 | 
				
			||||||
 | 
							json_object_put(marks);
 | 
				
			||||||
 | 
							goto exit_cleanup;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case IPC_GET_VERSION:
 | 
						case IPC_GET_VERSION:
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		json_object *version = ipc_json_get_version();
 | 
							json_object *version = ipc_json_get_version();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue