Move `ipc_send_workspace_focus_event` to icp.h
Patch status: needinfo
Patch by Tony Crisci
Long description:
Make `ipc_send_workspace_focus_event publicly available from ipc.h for more flexible event sending.
To apply this patch, use:
curl http://cr.i3wm.org/patch/369/raw.patch | git am
b/include/ipc.h
| 17 |
@@ -80,3 +80,10 @@ void ipc_send_event(const char *event, uint32_t message_type, const char *payloa |
| 18 |
void ipc_shutdown(void); |
| 19 |
|
| 20 |
void dump_node(yajl_gen gen, Con *con, bool inplace_restart); |
| 21 |
+ |
| 22 |
+/** |
| 23 |
+ * For the workspace "focus" event we send, along the usual "change" field, |
| 24 |
+ * also the current and previous workspace, in "current" and "old" |
| 25 |
+ * respectively. |
| 26 |
+ */ |
| 27 |
+void ipc_send_workspace_focus_event(Con *current, Con *old); |
b/src/ipc.c
| 32 |
@@ -1022,3 +1022,37 @@ int ipc_create_socket(const char *filename) {
|
| 33 |
current_socketpath = resolved; |
| 34 |
return sockfd; |
| 35 |
} |
| 36 |
+ |
| 37 |
+/* |
| 38 |
+ * For the workspace "focus" event we send, along the usual "change" field, |
| 39 |
+ * also the current and previous workspace, in "current" and "old" |
| 40 |
+ * respectively. |
| 41 |
+ */ |
| 42 |
+void ipc_send_workspace_focus_event(Con *current, Con *old) {
|
| 43 |
+ setlocale(LC_NUMERIC, "C"); |
| 44 |
+ yajl_gen gen = ygenalloc(); |
| 45 |
+ |
| 46 |
+ y(map_open); |
| 47 |
+ |
| 48 |
+ ystr("change");
|
| 49 |
+ ystr("focus");
|
| 50 |
+ |
| 51 |
+ ystr("current");
|
| 52 |
+ dump_node(gen, current, false); |
| 53 |
+ |
| 54 |
+ ystr("old");
|
| 55 |
+ if (old == NULL) |
| 56 |
+ y(null); |
| 57 |
+ else |
| 58 |
+ dump_node(gen, old, false); |
| 59 |
+ |
| 60 |
+ y(map_close); |
| 61 |
+ |
| 62 |
+ const unsigned char *payload; |
| 63 |
+ ylength length; |
| 64 |
+ y(get_buf, &payload, &length); |
| 65 |
+ |
| 66 |
+ ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
|
| 67 |
+ y(free); |
| 68 |
+ setlocale(LC_NUMERIC, ""); |
| 69 |
+} |
b/src/workspace.c
| 74 |
@@ -11,9 +11,6 @@ |
| 75 |
* |
| 76 |
*/ |
| 77 |
#include "all.h" |
| 78 |
-#include "yajl_utils.h" |
| 79 |
- |
| 80 |
-#include <yajl/yajl_gen.h> |
| 81 |
|
| 82 |
/* Stores a copy of the name of the last used workspace for the workspace |
| 83 |
* back-and-forth switching. */ |
| 84 |
@@ -335,39 +332,6 @@ static void workspace_defer_update_urgent_hint_cb(EV_P_ ev_timer *w, int revents |
| 85 |
FREE(con->urgency_timer); |
| 86 |
} |
| 87 |
|
| 88 |
-/* |
| 89 |
- * For the "focus" event we send, along the usual "change" field, also the |
| 90 |
- * current and previous workspace, in "current" and "old" respectively. |
| 91 |
- */ |
| 92 |
-static void ipc_send_workspace_focus_event(Con *current, Con *old) {
|
| 93 |
- setlocale(LC_NUMERIC, "C"); |
| 94 |
- yajl_gen gen = ygenalloc(); |
| 95 |
- |
| 96 |
- y(map_open); |
| 97 |
- |
| 98 |
- ystr("change");
|
| 99 |
- ystr("focus");
|
| 100 |
- |
| 101 |
- ystr("current");
|
| 102 |
- dump_node(gen, current, false); |
| 103 |
- |
| 104 |
- ystr("old");
|
| 105 |
- if (old == NULL) |
| 106 |
- y(null); |
| 107 |
- else |
| 108 |
- dump_node(gen, old, false); |
| 109 |
- |
| 110 |
- y(map_close); |
| 111 |
- |
| 112 |
- const unsigned char *payload; |
| 113 |
- ylength length; |
| 114 |
- y(get_buf, &payload, &length); |
| 115 |
- |
| 116 |
- ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
|
| 117 |
- y(free); |
| 118 |
- setlocale(LC_NUMERIC, ""); |
| 119 |
-} |
| 120 |
- |
| 121 |
static void _workspace_show(Con *workspace) {
|
| 122 |
Con *current, *old = NULL; |
| 123 |
|