mirror of
https://github.com/swaywm/sway.git
synced 2024-11-16 21:23:17 +00:00
Trigger ipc_event_workspace in all cases
This makes sure that the workspace IPC event is triggered when needed. Fixes #382 while making sure that the IPC event is only triggered once.
This commit is contained in:
parent
442a54c38b
commit
50b04884b6
|
@ -9,7 +9,7 @@ void ipc_init(void);
|
||||||
void ipc_terminate(void);
|
void ipc_terminate(void);
|
||||||
struct sockaddr_un *ipc_user_sockaddr(void);
|
struct sockaddr_un *ipc_user_sockaddr(void);
|
||||||
|
|
||||||
void ipc_event_workspace(swayc_t *old, swayc_t *new);
|
void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change);
|
||||||
void ipc_event_barconfig_update(struct bar_config *bar);
|
void ipc_event_barconfig_update(struct bar_config *bar);
|
||||||
const char *swayc_type_string(enum swayc_types type);
|
const char *swayc_type_string(enum swayc_types type);
|
||||||
|
|
||||||
|
|
15
sway/focus.c
15
sway/focus.c
|
@ -34,7 +34,7 @@ static void update_focus(swayc_t *c) {
|
||||||
// Case where workspace changes
|
// Case where workspace changes
|
||||||
case C_WORKSPACE:
|
case C_WORKSPACE:
|
||||||
if (prev) {
|
if (prev) {
|
||||||
ipc_event_workspace(prev, c);
|
ipc_event_workspace(prev, c, "focus");
|
||||||
// update visibility of old workspace
|
// update visibility of old workspace
|
||||||
update_visibility(prev);
|
update_visibility(prev);
|
||||||
|
|
||||||
|
@ -122,11 +122,6 @@ bool set_focused_container(swayc_t *c) {
|
||||||
p = p->parent;
|
p = p->parent;
|
||||||
p->is_focused = false;
|
p->is_focused = false;
|
||||||
}
|
}
|
||||||
// active_ws might have been destroyed by now
|
|
||||||
// (focus swap away from empty ws = destroy ws)
|
|
||||||
if (active_ws_child_count == 0) {
|
|
||||||
active_ws = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get new focused view and set focus to it.
|
// get new focused view and set focus to it.
|
||||||
p = get_focused_view(c);
|
p = get_focused_view(c);
|
||||||
|
@ -146,7 +141,13 @@ bool set_focused_container(swayc_t *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (active_ws != workspace) {
|
if (active_ws != workspace) {
|
||||||
ipc_event_workspace(active_ws, workspace);
|
// active_ws might have been destroyed by now
|
||||||
|
// (focus swap away from empty ws = destroy ws)
|
||||||
|
if (active_ws_child_count == 0) {
|
||||||
|
active_ws = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ipc_event_workspace(active_ws, workspace, "focus");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,15 +562,23 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ipc_event_workspace(swayc_t *old, swayc_t *new) {
|
void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) {
|
||||||
json_object *obj = json_object_new_object();
|
json_object *obj = json_object_new_object();
|
||||||
json_object_object_add(obj, "change", json_object_new_string("focus"));
|
json_object_object_add(obj, "change", json_object_new_string(change));
|
||||||
|
if (strcmp("focus", change) == 0) {
|
||||||
if (old) {
|
if (old) {
|
||||||
json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
|
json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
|
||||||
} else {
|
} else {
|
||||||
json_object_object_add(obj, "old", NULL);
|
json_object_object_add(obj, "old", NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new) {
|
||||||
json_object_object_add(obj, "current", ipc_json_describe_workspace(new));
|
json_object_object_add(obj, "current", ipc_json_describe_workspace(new));
|
||||||
|
} else {
|
||||||
|
json_object_object_add(obj, "current", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
const char *json_string = json_object_to_json_string(obj);
|
const char *json_string = json_object_to_json_string(obj);
|
||||||
|
|
||||||
for (int i = 0; i < ipc_client_list->length; i++) {
|
for (int i = 0; i < ipc_client_list->length; i++) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
|
#include "ipc-server.h"
|
||||||
|
|
||||||
swayc_t root_container;
|
swayc_t root_container;
|
||||||
list_t *scratchpad;
|
list_t *scratchpad;
|
||||||
|
@ -312,6 +313,12 @@ void move_container_to(swayc_t* container, swayc_t* destination) {
|
||||||
// reset container geometry
|
// reset container geometry
|
||||||
container->width = container->height = 0;
|
container->width = container->height = 0;
|
||||||
add_child(destination, container);
|
add_child(destination, container);
|
||||||
|
|
||||||
|
// If the workspace only has one child after adding one, it
|
||||||
|
// means that the workspace was just initialized.
|
||||||
|
if (destination->children->length + destination->floating->length == 1) {
|
||||||
|
ipc_event_workspace(NULL, destination, "init");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// reset container geometry
|
// reset container geometry
|
||||||
container->width = container->height = 0;
|
container->width = container->height = 0;
|
||||||
|
|
Loading…
Reference in a new issue