mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-28 22:23:42 +01: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
4 changed files with 31 additions and 15 deletions
|
@ -9,7 +9,7 @@ void ipc_init(void);
|
|||
void ipc_terminate(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);
|
||||
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 C_WORKSPACE:
|
||||
if (prev) {
|
||||
ipc_event_workspace(prev, c);
|
||||
ipc_event_workspace(prev, c, "focus");
|
||||
// update visibility of old workspace
|
||||
update_visibility(prev);
|
||||
|
||||
|
@ -122,11 +122,6 @@ bool set_focused_container(swayc_t *c) {
|
|||
p = p->parent;
|
||||
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.
|
||||
p = get_focused_view(c);
|
||||
|
@ -146,7 +141,13 @@ bool set_focused_container(swayc_t *c) {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -562,15 +562,23 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
|
|||
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_object_add(obj, "change", json_object_new_string("focus"));
|
||||
if (old) {
|
||||
json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
|
||||
} else {
|
||||
json_object_object_add(obj, "old", NULL);
|
||||
json_object_object_add(obj, "change", json_object_new_string(change));
|
||||
if (strcmp("focus", change) == 0) {
|
||||
if (old) {
|
||||
json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
|
||||
} else {
|
||||
json_object_object_add(obj, "old", NULL);
|
||||
}
|
||||
}
|
||||
json_object_object_add(obj, "current", ipc_json_describe_workspace(new));
|
||||
|
||||
if (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);
|
||||
|
||||
for (int i = 0; i < ipc_client_list->length; i++) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "workspace.h"
|
||||
#include "focus.h"
|
||||
#include "output.h"
|
||||
#include "ipc-server.h"
|
||||
|
||||
swayc_t root_container;
|
||||
list_t *scratchpad;
|
||||
|
@ -312,6 +313,12 @@ void move_container_to(swayc_t* container, swayc_t* destination) {
|
|||
// reset container geometry
|
||||
container->width = container->height = 0;
|
||||
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 {
|
||||
// reset container geometry
|
||||
container->width = container->height = 0;
|
||||
|
|
Loading…
Reference in a new issue