mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Merge pull request #776 from Hummer12007/window-events
[RFC] Implement window events
This commit is contained in:
		
						commit
						464239f7ac
					
				
					 9 changed files with 113 additions and 23 deletions
				
			
		| 
						 | 
					@ -9,5 +9,6 @@ json_object *ipc_json_get_version();
 | 
				
			||||||
json_object *ipc_json_describe_bar_config(struct bar_config *bar);
 | 
					json_object *ipc_json_describe_bar_config(struct bar_config *bar);
 | 
				
			||||||
json_object *ipc_json_describe_container(swayc_t *c);
 | 
					json_object *ipc_json_describe_container(swayc_t *c);
 | 
				
			||||||
json_object *ipc_json_describe_container_recursive(swayc_t *c);
 | 
					json_object *ipc_json_describe_container_recursive(swayc_t *c);
 | 
				
			||||||
 | 
					json_object *ipc_json_describe_window(swayc_t *c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,10 @@ void ipc_event_barconfig_update(struct bar_config *bar);
 | 
				
			||||||
 * Send IPC mode event to all listening clients
 | 
					 * Send IPC mode event to all listening clients
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void ipc_event_mode(const char *mode);
 | 
					void ipc_event_mode(const char *mode);
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Send IPC window change event
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void ipc_event_window(swayc_t *window, const char *change);
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Sends an IPC modifier event to all listening clients.  The modifier event
 | 
					 * Sends an IPC modifier event to all listening clients.  The modifier event
 | 
				
			||||||
 * includes a key 'change' with the value of state and a key 'modifier' with
 | 
					 * includes a key 'change' with the value of state and a key 'modifier' with
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -679,6 +679,7 @@ static struct cmd_results *cmd_floating(int argc, char **argv) {
 | 
				
			||||||
		view->width = view->height = 0;
 | 
							view->width = view->height = 0;
 | 
				
			||||||
		arrange_windows(swayc_active_workspace(), -1, -1);
 | 
							arrange_windows(swayc_active_workspace(), -1, -1);
 | 
				
			||||||
		remove_view_from_scratchpad(view);
 | 
							remove_view_from_scratchpad(view);
 | 
				
			||||||
 | 
							ipc_event_window(view, "floating");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	set_focused_container(view);
 | 
						set_focused_container(view);
 | 
				
			||||||
	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
						return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
				
			||||||
| 
						 | 
					@ -2495,6 +2496,7 @@ static struct cmd_results *cmd_fullscreen(int argc, char **argv) {
 | 
				
			||||||
		arrange_windows(container, -1, -1);
 | 
							arrange_windows(container, -1, -1);
 | 
				
			||||||
		workspace->fullscreen = NULL;
 | 
							workspace->fullscreen = NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						ipc_event_window(container, "fullscreen_mode");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
						return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@
 | 
				
			||||||
#include "log.h"
 | 
					#include "log.h"
 | 
				
			||||||
#include "input_state.h"
 | 
					#include "input_state.h"
 | 
				
			||||||
#include "extensions.h"
 | 
					#include "extensions.h"
 | 
				
			||||||
 | 
					#include "ipc-server.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct desktop_shell_state desktop_shell;
 | 
					struct desktop_shell_state desktop_shell;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -128,6 +129,7 @@ static void set_lock_surface(struct wl_client *client, struct wl_resource *resou
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true);
 | 
							wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true);
 | 
				
			||||||
		workspace->fullscreen = view;
 | 
							workspace->fullscreen = view;
 | 
				
			||||||
 | 
							ipc_event_window(view, "fullscreen_mode");
 | 
				
			||||||
		desktop_shell.is_locked = true;
 | 
							desktop_shell.is_locked = true;
 | 
				
			||||||
		// reset input state
 | 
							// reset input state
 | 
				
			||||||
		input_init();
 | 
							input_init();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -118,6 +118,10 @@ bool set_focused_container(swayc_t *c) {
 | 
				
			||||||
		c = focused;
 | 
							c = focused;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (c->type == C_VIEW) {
 | 
				
			||||||
 | 
							// dispatch a window event
 | 
				
			||||||
 | 
							ipc_event_window(c, "focus");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	// update container focus from here to root, making necessary changes along
 | 
						// update container focus from here to root, making necessary changes along
 | 
				
			||||||
	// the way
 | 
						// the way
 | 
				
			||||||
	swayc_t *p = c;
 | 
						swayc_t *p = c;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -369,6 +369,7 @@ static bool handle_view_created(wlc_handle handle) {
 | 
				
			||||||
	suspend_workspace_cleanup = true;
 | 
						suspend_workspace_cleanup = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (newview) {
 | 
						if (newview) {
 | 
				
			||||||
 | 
							ipc_event_window(newview, "new");
 | 
				
			||||||
		set_focused_container(newview);
 | 
							set_focused_container(newview);
 | 
				
			||||||
		swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT);
 | 
							swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT);
 | 
				
			||||||
		arrange_windows(output, -1, -1);
 | 
							arrange_windows(output, -1, -1);
 | 
				
			||||||
| 
						 | 
					@ -461,6 +462,7 @@ static void handle_view_destroyed(wlc_handle handle) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		arrange_windows(parent, -1, -1);
 | 
							arrange_windows(parent, -1, -1);
 | 
				
			||||||
 | 
							ipc_event_window(parent, "close");
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		// Is it unmanaged?
 | 
							// Is it unmanaged?
 | 
				
			||||||
		int i;
 | 
							int i;
 | 
				
			||||||
| 
						 | 
					@ -555,6 +557,7 @@ static void handle_view_properties_updated(wlc_handle view, uint32_t mask) {
 | 
				
			||||||
				} else if (c->border_type == B_NORMAL) {
 | 
									} else if (c->border_type == B_NORMAL) {
 | 
				
			||||||
					update_view_border(c);
 | 
										update_view_border(c);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									ipc_event_window(c, "title");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,17 @@ static json_object *ipc_json_create_rect(swayc_t *c) {
 | 
				
			||||||
	return rect;
 | 
						return rect;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static json_object *ipc_json_create_rect_from_geometry(struct wlc_geometry g) {
 | 
				
			||||||
 | 
						json_object *rect = json_object_new_object();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						json_object_object_add(rect, "x", json_object_new_int(g.origin.x));
 | 
				
			||||||
 | 
						json_object_object_add(rect, "y", json_object_new_int(g.origin.y));
 | 
				
			||||||
 | 
						json_object_object_add(rect, "width", json_object_new_int(g.size.w));
 | 
				
			||||||
 | 
						json_object_object_add(rect, "height", json_object_new_int(g.size.h));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return rect;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char *ipc_json_border_description(swayc_t *c) {
 | 
					static const char *ipc_json_border_description(swayc_t *c) {
 | 
				
			||||||
	const char *border;
 | 
						const char *border;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,10 +49,10 @@ static const char *ipc_json_border_description(swayc_t *c) {
 | 
				
			||||||
	return border;
 | 
						return border;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char *ipc_json_layout_description(swayc_t *c) {
 | 
					static const char *ipc_json_layout_description(enum swayc_layouts l) {
 | 
				
			||||||
	const char *layout;
 | 
						const char *layout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (c->layout) {
 | 
						switch (l) {
 | 
				
			||||||
	case L_VERT:
 | 
						case L_VERT:
 | 
				
			||||||
		layout = "splitv";
 | 
							layout = "splitv";
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					@ -111,7 +122,7 @@ static void ipc_json_describe_output(swayc_t *output, json_object *object) {
 | 
				
			||||||
static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) {
 | 
					static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) {
 | 
				
			||||||
	int num = (isdigit(workspace->name[0])) ? atoi(workspace->name) : -1;
 | 
						int num = (isdigit(workspace->name[0])) ? atoi(workspace->name) : -1;
 | 
				
			||||||
	bool focused = root_container.focused == workspace->parent && workspace->parent->focused == workspace;
 | 
						bool focused = root_container.focused == workspace->parent && workspace->parent->focused == workspace;
 | 
				
			||||||
	const char *layout = ipc_json_layout_description(workspace);
 | 
						const char *layout = ipc_json_layout_description(workspace->layout);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	json_object_object_add(object, "num", json_object_new_int(num));
 | 
						json_object_object_add(object, "num", json_object_new_int(num));
 | 
				
			||||||
	json_object_object_add(object, "focused", json_object_new_boolean(focused));
 | 
						json_object_object_add(object, "focused", json_object_new_boolean(focused));
 | 
				
			||||||
| 
						 | 
					@ -121,26 +132,68 @@ static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object)
 | 
				
			||||||
	json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
 | 
						json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void ipc_json_describe_view(swayc_t *view, json_object *object) {
 | 
					// window is in the scratchpad ? changed : none
 | 
				
			||||||
	float percent = ipc_json_child_percentage(view);
 | 
					static const char *ipc_json_get_scratchpad_state(swayc_t *c) {
 | 
				
			||||||
	const char *layout = ipc_json_layout_description(view);
 | 
						int i;
 | 
				
			||||||
 | 
						for (i = 0; i < scratchpad->length; i++) {
 | 
				
			||||||
 | 
							if (scratchpad->items[i] == c) {
 | 
				
			||||||
 | 
								return "changed";
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return "none"; // we ignore the fresh value
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	json_object_object_add(object, "border", json_object_new_string(ipc_json_border_description(view)));
 | 
					static void ipc_json_describe_view(swayc_t *c, json_object *object) {
 | 
				
			||||||
	json_object_object_add(object, "current_border_width", json_object_new_int(view->border_thickness));
 | 
						json_object *props = json_object_new_object();
 | 
				
			||||||
 | 
						float percent = ipc_json_child_percentage(c);
 | 
				
			||||||
 | 
						const char *layout = (c->parent->type == C_CONTAINER) ?
 | 
				
			||||||
 | 
							ipc_json_layout_description(c->parent->layout) : "none";
 | 
				
			||||||
 | 
						const char *last_layout = (c->parent->type == C_CONTAINER) ?
 | 
				
			||||||
 | 
							ipc_json_layout_description(c->parent->prev_layout) : "none";
 | 
				
			||||||
 | 
						wlc_handle parent = wlc_view_get_parent(c->handle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						json_object_object_add(object, "id", json_object_new_int(c->handle));
 | 
				
			||||||
 | 
						json_object_object_add(object, "type", json_object_new_string((c->is_floating) ? "floating_con" : "con"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						json_object_object_add(object, "scratchpad_state",
 | 
				
			||||||
 | 
							json_object_new_string(ipc_json_get_scratchpad_state(c)));
 | 
				
			||||||
	json_object_object_add(object, "percent", (percent > 0) ? json_object_new_double(percent) : NULL);
 | 
						json_object_object_add(object, "percent", (percent > 0) ? json_object_new_double(percent) : NULL);
 | 
				
			||||||
	// TODO: make urgency actually work once Sway supports it
 | 
						// TODO: make urgency actually work once Sway supports it
 | 
				
			||||||
	json_object_object_add(object, "urgent", json_object_new_boolean(false));
 | 
						json_object_object_add(object, "urgent", json_object_new_boolean(false));
 | 
				
			||||||
	json_object_object_add(object, "focused", json_object_new_boolean(view->is_focused));
 | 
						json_object_object_add(object, "focused", json_object_new_boolean(c->is_focused));
 | 
				
			||||||
	json_object_object_add(object, "type", json_object_new_string((view->is_floating) ? "floating_con" : "con"));
 | 
					 | 
				
			||||||
	json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (view->class) {
 | 
						json_object_object_add(object, "layout",
 | 
				
			||||||
		json_object_object_add(object, "class", json_object_new_string(view->class));
 | 
							(strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
 | 
				
			||||||
	}
 | 
						json_object_object_add(object, "last_split_layout",
 | 
				
			||||||
 | 
							(strcmp(last_layout, "null") == 0) ? NULL : json_object_new_string(last_layout));
 | 
				
			||||||
 | 
						json_object_object_add(object, "workspace_layout",
 | 
				
			||||||
 | 
							json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->layout)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (view->app_id) {
 | 
						json_object_object_add(object, "border", json_object_new_string(ipc_json_border_description(c)));
 | 
				
			||||||
		json_object_object_add(object, "app_id", json_object_new_string(view->app_id));
 | 
						json_object_object_add(object, "current_border_width", json_object_new_int(c->border_thickness));
 | 
				
			||||||
	}
 | 
					
 | 
				
			||||||
 | 
						json_object_object_add(object, "rect", ipc_json_create_rect(c));
 | 
				
			||||||
 | 
						json_object_object_add(object, "deco_rect", ipc_json_create_rect_from_geometry(c->title_bar_geometry));
 | 
				
			||||||
 | 
						json_object_object_add(object, "geometry", ipc_json_create_rect_from_geometry(c->cached_geometry));
 | 
				
			||||||
 | 
						json_object_object_add(object, "window_rect", ipc_json_create_rect_from_geometry(c->actual_geometry));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						json_object_object_add(object, "window", json_object_new_int(c->handle)); // for the sake of i3 compat
 | 
				
			||||||
 | 
						json_object_object_add(props, "class", c->class ? json_object_new_string(c->class) :
 | 
				
			||||||
 | 
							c->app_id ? json_object_new_string(c->app_id) : NULL);
 | 
				
			||||||
 | 
						json_object_object_add(props, "title", (c->name) ? json_object_new_string(c->name) : NULL);
 | 
				
			||||||
 | 
						json_object_object_add(props, "transient_for", parent ? json_object_new_int(parent) : NULL);
 | 
				
			||||||
 | 
						json_object_object_add(object, "window_properties", props);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						json_object_object_add(object, "fullscreen_mode",
 | 
				
			||||||
 | 
							json_object_new_int(swayc_is_fullscreen(c) ? 1 : 0));
 | 
				
			||||||
 | 
						json_object_object_add(object, "sticky", json_object_new_boolean(c->sticky));
 | 
				
			||||||
 | 
						json_object_object_add(object, "floating", json_object_new_string(
 | 
				
			||||||
 | 
							c->is_floating ? "auto_on" : "auto_off")); // we can't state the cause
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						json_object_object_add(object, "app_id", c->app_id ? json_object_new_string(c->app_id) : NULL);
 | 
				
			||||||
 | 
						// we do not include children, floating, unmanaged etc. as views have none
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
json_object *ipc_json_describe_container(swayc_t *c) {
 | 
					json_object *ipc_json_describe_container(swayc_t *c) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,6 +54,8 @@ bool ipc_send_reply(struct ipc_client *client, const char *payload, uint32_t pay
 | 
				
			||||||
void ipc_get_workspaces_callback(swayc_t *workspace, void *data);
 | 
					void ipc_get_workspaces_callback(swayc_t *workspace, void *data);
 | 
				
			||||||
void ipc_get_outputs_callback(swayc_t *container, void *data);
 | 
					void ipc_get_outputs_callback(swayc_t *container, void *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define event_mask(ev) (1 << (ev & 0x7F))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ipc_init(void) {
 | 
					void ipc_init(void) {
 | 
				
			||||||
	ipc_socket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
 | 
						ipc_socket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
 | 
				
			||||||
	if (ipc_socket == -1) {
 | 
						if (ipc_socket == -1) {
 | 
				
			||||||
| 
						 | 
					@ -334,16 +336,18 @@ void ipc_client_handle_command(struct ipc_client *client) {
 | 
				
			||||||
		for (int i = 0; i < json_object_array_length(request); i++) {
 | 
							for (int i = 0; i < json_object_array_length(request); i++) {
 | 
				
			||||||
			const char *event_type = json_object_get_string(json_object_array_get_idx(request, i));
 | 
								const char *event_type = json_object_get_string(json_object_array_get_idx(request, i));
 | 
				
			||||||
			if (strcmp(event_type, "workspace") == 0) {
 | 
								if (strcmp(event_type, "workspace") == 0) {
 | 
				
			||||||
				client->subscribed_events |= IPC_EVENT_WORKSPACE;
 | 
									client->subscribed_events |= event_mask(IPC_EVENT_WORKSPACE);
 | 
				
			||||||
			} else if (strcmp(event_type, "barconfig_update") == 0) {
 | 
								} else if (strcmp(event_type, "barconfig_update") == 0) {
 | 
				
			||||||
				client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE;
 | 
									client->subscribed_events |= event_mask(IPC_EVENT_BARCONFIG_UPDATE);
 | 
				
			||||||
			} else if (strcmp(event_type, "mode") == 0) {
 | 
								} else if (strcmp(event_type, "mode") == 0) {
 | 
				
			||||||
				client->subscribed_events |= IPC_EVENT_MODE;
 | 
									client->subscribed_events |= event_mask(IPC_EVENT_MODE);
 | 
				
			||||||
 | 
								} else if (strcmp(event_type, "window") == 0) {
 | 
				
			||||||
 | 
									client->subscribed_events |= event_mask(IPC_EVENT_WINDOW);
 | 
				
			||||||
			} else if (strcmp(event_type, "modifier") == 0) {
 | 
								} else if (strcmp(event_type, "modifier") == 0) {
 | 
				
			||||||
				client->subscribed_events |= IPC_EVENT_MODIFIER;
 | 
									client->subscribed_events |= event_mask(IPC_EVENT_MODIFIER);
 | 
				
			||||||
#if SWAY_BINDING_EVENT
 | 
					#if SWAY_BINDING_EVENT
 | 
				
			||||||
			} else if (strcmp(event_type, "binding") == 0) {
 | 
								} else if (strcmp(event_type, "binding") == 0) {
 | 
				
			||||||
				client->subscribed_events |= IPC_EVENT_BINDING;
 | 
									client->subscribed_events |= event_mask(IPC_EVENT_BINDING);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				ipc_send_reply(client, "{\"success\": false}", 18);
 | 
									ipc_send_reply(client, "{\"success\": false}", 18);
 | 
				
			||||||
| 
						 | 
					@ -522,7 +526,7 @@ void ipc_send_event(const char *json_string, enum ipc_command_type event) {
 | 
				
			||||||
	struct ipc_client *client;
 | 
						struct ipc_client *client;
 | 
				
			||||||
	for (i = 0; i < ipc_client_list->length; i++) {
 | 
						for (i = 0; i < ipc_client_list->length; i++) {
 | 
				
			||||||
		client = ipc_client_list->items[i];
 | 
							client = ipc_client_list->items[i];
 | 
				
			||||||
		if ((client->subscribed_events & event) == 0) {
 | 
							if ((client->subscribed_events & event_mask(event)) == 0) {
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		client->current_command = event;
 | 
							client->current_command = event;
 | 
				
			||||||
| 
						 | 
					@ -556,6 +560,21 @@ void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) {
 | 
				
			||||||
	json_object_put(obj); // free
 | 
						json_object_put(obj); // free
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void ipc_event_window(swayc_t *window, const char *change) {
 | 
				
			||||||
 | 
						json_object *obj = json_object_new_object();
 | 
				
			||||||
 | 
						json_object_object_add(obj, "change", json_object_new_string(change));
 | 
				
			||||||
 | 
						if (strcmp(change, "close") == 0 || !window) {
 | 
				
			||||||
 | 
							json_object_object_add(obj, "container", NULL);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							json_object_object_add(obj, "container", ipc_json_describe_container(window));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const char *json_string = json_object_to_json_string(obj);
 | 
				
			||||||
 | 
						ipc_send_event(json_string, IPC_EVENT_WINDOW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						json_object_put(obj); // free
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ipc_event_barconfig_update(struct bar_config *bar) {
 | 
					void ipc_event_barconfig_update(struct bar_config *bar) {
 | 
				
			||||||
	json_object *json = ipc_json_describe_bar_config(bar);
 | 
						json_object *json = ipc_json_describe_bar_config(bar);
 | 
				
			||||||
	const char *json_string = json_object_to_json_string(json);
 | 
						const char *json_string = json_object_to_json_string(json);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,6 +91,7 @@ void add_floating(swayc_t *ws, swayc_t *child) {
 | 
				
			||||||
	if (!ws->focused) {
 | 
						if (!ws->focused) {
 | 
				
			||||||
		ws->focused = child;
 | 
							ws->focused = child;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						ipc_event_window(child, "floating");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) {
 | 
					swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) {
 | 
				
			||||||
| 
						 | 
					@ -305,6 +306,7 @@ void move_container(swayc_t *container, enum movement_direction dir) {
 | 
				
			||||||
		parent = child->parent;
 | 
							parent = child->parent;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	arrange_windows(parent->parent, -1, -1);
 | 
						arrange_windows(parent->parent, -1, -1);
 | 
				
			||||||
 | 
						ipc_event_window(container, "move");
 | 
				
			||||||
	set_focused_container_for(parent->parent, container);
 | 
						set_focused_container_for(parent->parent, container);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue