more informative `workspace' events
Add a `current' and `old' properties to the `focus' change type, containing the current and old workspace respectively. These additions are not necessary anywhere else because `focus' is always triggered when changing ws.
This commit is contained in:
parent
b67eedf71a
commit
74d596e0fc
18
docs/ipc
18
docs/ipc
|
@ -644,11 +644,25 @@ if ($is_event) {
|
||||||
|
|
||||||
This event consists of a single serialized map containing a property
|
This event consists of a single serialized map containing a property
|
||||||
+change (string)+ which indicates the type of the change ("focus", "init",
|
+change (string)+ which indicates the type of the change ("focus", "init",
|
||||||
"empty", "urgent").
|
"empty", "urgent"). Additionally, when the change is "focus", an +old
|
||||||
|
(object)+ and a +current (object)+ properties will be present with the
|
||||||
|
previous and current workspace respectively.
|
||||||
|
|
||||||
*Example:*
|
*Example:*
|
||||||
---------------------
|
---------------------
|
||||||
{ "change": "focus" }
|
{
|
||||||
|
"change": "focus",
|
||||||
|
"current": {
|
||||||
|
"id": 28489712,
|
||||||
|
"type":4,
|
||||||
|
...
|
||||||
|
}
|
||||||
|
"old": {
|
||||||
|
"id": 28489715,
|
||||||
|
"type": 4,
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
=== output event
|
=== output event
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
|
#include "yajl_utils.h"
|
||||||
|
|
||||||
|
#include <yajl/yajl_gen.h>
|
||||||
|
|
||||||
/* Stores a copy of the name of the last used workspace for the workspace
|
/* Stores a copy of the name of the last used workspace for the workspace
|
||||||
* back-and-forth switching. */
|
* back-and-forth switching. */
|
||||||
|
@ -331,6 +334,34 @@ static void workspace_defer_update_urgent_hint_cb(EV_P_ ev_timer *w, int revents
|
||||||
FREE(con->urgency_timer);
|
FREE(con->urgency_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For the "focus" event we send, along the usual "change" field, also the
|
||||||
|
* current and previous workspace, in "current" and "old" respectively.
|
||||||
|
*/
|
||||||
|
static void _workspace_focus_event(Con *current, Con *old) {
|
||||||
|
yajl_gen gen = ygenalloc();
|
||||||
|
|
||||||
|
y(map_open);
|
||||||
|
|
||||||
|
ystr("change");
|
||||||
|
ystr("focus");
|
||||||
|
|
||||||
|
ystr("current");
|
||||||
|
dump_node(gen, current, false);
|
||||||
|
|
||||||
|
ystr("old");
|
||||||
|
dump_node(gen, old, false);
|
||||||
|
|
||||||
|
y(map_close);
|
||||||
|
|
||||||
|
const unsigned char *payload;
|
||||||
|
ylength length;
|
||||||
|
y(get_buf, &payload, &length);
|
||||||
|
|
||||||
|
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
|
||||||
|
y(free);
|
||||||
|
}
|
||||||
|
|
||||||
static void _workspace_show(Con *workspace) {
|
static void _workspace_show(Con *workspace) {
|
||||||
Con *current, *old = NULL;
|
Con *current, *old = NULL;
|
||||||
|
|
||||||
|
@ -433,7 +464,7 @@ static void _workspace_show(Con *workspace) {
|
||||||
/* Update the EWMH hints */
|
/* Update the EWMH hints */
|
||||||
ewmh_update_current_desktop();
|
ewmh_update_current_desktop();
|
||||||
|
|
||||||
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"focus\"}");
|
_workspace_focus_event(workspace, current);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue