Initial work on window events

master
Mykyta Holubakha 8 years ago
parent 095353d91d
commit 976e48d79f

@ -17,6 +17,10 @@ void ipc_event_barconfig_update(struct bar_config *bar);
* Send IPC mode event to all listening clients
*/
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
* 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;
arrange_windows(swayc_active_workspace(), -1, -1);
remove_view_from_scratchpad(view);
ipc_event_window(view, "floating");
}
set_focused_container(view);
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);
workspace->fullscreen = NULL;
}
ipc_event_window(container, "fullscreen_mode");
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}

@ -8,6 +8,7 @@
#include "log.h"
#include "input_state.h"
#include "extensions.h"
#include "ipc-server.h"
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);
workspace->fullscreen = view;
ipc_event_window(view, "fullscreen_mode");
desktop_shell.is_locked = true;
// reset input state
input_init();

@ -118,6 +118,10 @@ bool set_focused_container(swayc_t *c) {
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
// the way
swayc_t *p = c;

@ -369,6 +369,7 @@ static bool handle_view_created(wlc_handle handle) {
suspend_workspace_cleanup = true;
if (newview) {
ipc_event_window(newview, "new");
set_focused_container(newview);
swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT);
arrange_windows(output, -1, -1);
@ -461,6 +462,7 @@ static void handle_view_destroyed(wlc_handle handle) {
}
arrange_windows(parent, -1, -1);
ipc_event_window(parent, "close");
} else {
// Is it unmanaged?
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) {
update_view_border(c);
}
ipc_event_window(c, "title");
}
}
}

@ -339,6 +339,8 @@ void ipc_client_handle_command(struct ipc_client *client) {
client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE;
} else if (strcmp(event_type, "mode") == 0) {
client->subscribed_events |= IPC_EVENT_MODE;
} else if (strcmp(event_type, "window") == 0) {
client->subscribed_events |= IPC_EVENT_WINDOW;
} else if (strcmp(event_type, "modifier") == 0) {
client->subscribed_events |= IPC_EVENT_MODIFIER;
#if SWAY_BINDING_EVENT
@ -556,6 +558,21 @@ void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) {
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) {
json_object *json = ipc_json_describe_bar_config(bar);
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) {
ws->focused = child;
}
ipc_event_window(child, "floating");
}
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;
}
arrange_windows(parent->parent, -1, -1);
ipc_event_window(container, "move");
set_focused_container_for(parent->parent, container);
}

Loading…
Cancel
Save