commit ac52b9f9cefade62d14a6c24c9ff0d9e6cd4c188
Author: Jan Palus <[email protected]>
Date:   Tue Feb 9 19:52:15 2021 +0100

    patch for improving IPC compatibility with i3

 sway-i3_ipc_compat.patch | 175 +++++++++++++++++++++++++++++++++++++++++++++++
 sway.spec                |   2 +
 2 files changed, 177 insertions(+)
---
diff --git a/sway.spec b/sway.spec
index 1b7c61f..9fcf1a9 100644
--- a/sway.spec
+++ b/sway.spec
@@ -7,6 +7,7 @@ Group:          Applications
 Source0:       
https://github.com/swaywm/sway/releases/download/%{version}/%{name}-%{version}.tar.gz
 # Source0-md5: 9a7edc89abfc3f36d47546457e0bc901
 Patch0:                x32.patch
+Patch1:                %{name}-i3_ipc_compat.patch
 URL:           https://swaywm.org/
 BuildRequires: OpenGLESv2-devel
 BuildRequires: bash-completion
@@ -86,6 +87,7 @@ ZSH completion for sway.
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 
 %build
 %meson build
diff --git a/sway-i3_ipc_compat.patch b/sway-i3_ipc_compat.patch
new file mode 100644
index 0000000..cff03a4
--- /dev/null
+++ b/sway-i3_ipc_compat.patch
@@ -0,0 +1,175 @@
+From 37da1dcbcaf38bd0ae5dbfa330414d6468b82d4c Mon Sep 17 00:00:00 2001
+From: Jan Palus <[email protected]>
+Date: Thu, 4 Feb 2021 00:50:27 +0100
+Subject: [PATCH] Align ordering of core node properties with i3
+
+Try to better mimic JSON node structure produced by i3 which might be
+relied on by already existing tools. In particular having "type" right
+after "id" is quite handy for streaming high-performance JSON parsers
+such as simdjson (which are handy for maintaining responsiveness on
+resource constrained systems).
+
+refer 
https://github.com/i3/i3/blob/ab2a22a78b25ad12fed2c177a34c44950795cf33/src/ipc.c#L338
+---
+ sway/ipc-json.c | 72 ++++++++++++++++++++++++++-----------------------
+ 1 file changed, 39 insertions(+), 33 deletions(-)
+
+diff --git a/sway/ipc-json.c b/sway/ipc-json.c
+index fceee84d..11802ba6 100644
+--- a/sway/ipc-json.c
++++ b/sway/ipc-json.c
+@@ -23,6 +23,20 @@
+ static const int i3_output_id = INT32_MAX;
+ static const int i3_scratch_id = INT32_MAX - 1;
+ 
++static const char *ipc_json_node_type_description(enum sway_node_type l) {
++      switch (l) {
++      case N_ROOT:
++              return "root";
++      case N_OUTPUT:
++              return "output";
++      case N_WORKSPACE:
++              return "workspace";
++      case N_CONTAINER:
++              return "con";
++      }
++      return "none";
++}
++
+ static const char *ipc_json_layout_description(enum sway_container_layout l) {
+       switch (l) {
+       case L_VERT:
+@@ -189,16 +203,22 @@ static json_object *ipc_json_create_empty_rect(void) {
+       return ipc_json_create_rect(&empty);
+ }
+ 
+-static json_object *ipc_json_create_node(int id, char *name,
++static json_object *ipc_json_create_node(int id, const char* type, char *name,
+               bool focused, json_object *focus, struct wlr_box *box) {
+       json_object *object = json_object_new_object();
+ 
+       json_object_object_add(object, "id", json_object_new_int(id));
+-      json_object_object_add(object, "name",
+-                      name ? json_object_new_string(name) : NULL);
+-      json_object_object_add(object, "rect", ipc_json_create_rect(box));
++      json_object_object_add(object, "type", json_object_new_string(type));
++      json_object_object_add(object, "orientation",
++                      json_object_new_string(
++                              ipc_json_orientation_description(L_HORIZ)));
++      json_object_object_add(object, "percent", NULL);
++      json_object_object_add(object, "urgent", 
json_object_new_boolean(false));
++      json_object_object_add(object, "marks", json_object_new_array());
+       json_object_object_add(object, "focused", 
json_object_new_boolean(focused));
+-      json_object_object_add(object, "focus", focus);
++      json_object_object_add(object, "layout",
++                      json_object_new_string(
++                              ipc_json_layout_description(L_HORIZ)));
+ 
+       // set default values to be compatible with i3
+       json_object_object_add(object, "border",
+@@ -206,35 +226,25 @@ static json_object *ipc_json_create_node(int id, char 
*name,
+                               ipc_json_border_description(B_NONE)));
+       json_object_object_add(object, "current_border_width",
+                       json_object_new_int(0));
+-      json_object_object_add(object, "layout",
+-                      json_object_new_string(
+-                              ipc_json_layout_description(L_HORIZ)));
+-      json_object_object_add(object, "orientation",
+-                      json_object_new_string(
+-                              ipc_json_orientation_description(L_HORIZ)));
+-      json_object_object_add(object, "percent", NULL);
+-      json_object_object_add(object, "window_rect", 
ipc_json_create_empty_rect());
++      json_object_object_add(object, "rect", ipc_json_create_rect(box));
+       json_object_object_add(object, "deco_rect", 
ipc_json_create_empty_rect());
++      json_object_object_add(object, "window_rect", 
ipc_json_create_empty_rect());
+       json_object_object_add(object, "geometry", 
ipc_json_create_empty_rect());
++      json_object_object_add(object, "name",
++                      name ? json_object_new_string(name) : NULL);
+       json_object_object_add(object, "window", NULL);
+-      json_object_object_add(object, "urgent", 
json_object_new_boolean(false));
+-      json_object_object_add(object, "marks", json_object_new_array());
+-      json_object_object_add(object, "fullscreen_mode", 
json_object_new_int(0));
+       json_object_object_add(object, "nodes", json_object_new_array());
+       json_object_object_add(object, "floating_nodes", 
json_object_new_array());
++      json_object_object_add(object, "focus", focus);
++      json_object_object_add(object, "fullscreen_mode", 
json_object_new_int(0));
+       json_object_object_add(object, "sticky", 
json_object_new_boolean(false));
+ 
+       return object;
+ }
+ 
+-static void ipc_json_describe_root(struct sway_root *root, json_object 
*object) {
+-      json_object_object_add(object, "type", json_object_new_string("root"));
+-}
+-
+ static void ipc_json_describe_output(struct sway_output *output,
+               json_object *object) {
+       struct wlr_output *wlr_output = output->wlr_output;
+-      json_object_object_add(object, "type", 
json_object_new_string("output"));
+       json_object_object_add(object, "active", json_object_new_boolean(true));
+       json_object_object_add(object, "dpms",
+                       json_object_new_boolean(wlr_output->enabled));
+@@ -369,11 +379,9 @@ static json_object 
*ipc_json_describe_scratchpad_output(void) {
+                               json_object_new_int(container->node.id));
+       }
+ 
+-      json_object *workspace = ipc_json_create_node(i3_scratch_id,
++      json_object *workspace = ipc_json_create_node(i3_scratch_id, 
"workspace",
+                               "__i3_scratch", false, workspace_focus, &box);
+       json_object_object_add(workspace, "fullscreen_mode", 
json_object_new_int(1));
+-      json_object_object_add(workspace, "type",
+-                      json_object_new_string("workspace"));
+ 
+       // List all hidden scratchpad containers as floating nodes
+       json_object *floating_array = json_object_new_array();
+@@ -390,10 +398,8 @@ static json_object 
*ipc_json_describe_scratchpad_output(void) {
+       json_object *output_focus = json_object_new_array();
+       json_object_array_add(output_focus, json_object_new_int(i3_scratch_id));
+ 
+-      json_object *output = ipc_json_create_node(i3_output_id,
++      json_object *output = ipc_json_create_node(i3_output_id, "output",
+                                       "__i3", false, output_focus, &box);
+-      json_object_object_add(output, "type",
+-                      json_object_new_string("output"));
+       json_object_object_add(output, "layout",
+                       json_object_new_string("output"));
+ 
+@@ -423,7 +429,6 @@ static void ipc_json_describe_workspace(struct 
sway_workspace *workspace,
+       json_object_object_add(object, "fullscreen_mode", 
json_object_new_int(1));
+       json_object_object_add(object, "output", workspace->output ?
+                       
json_object_new_string(workspace->output->wlr_output->name) : NULL);
+-      json_object_object_add(object, "type", 
json_object_new_string("workspace"));
+       json_object_object_add(object, "urgent",
+                       json_object_new_boolean(workspace->urgent));
+       json_object_object_add(object, "representation", 
workspace->representation ?
+@@ -583,8 +588,10 @@ static void ipc_json_describe_view(struct sway_container 
*c, json_object *object
+ static void ipc_json_describe_container(struct sway_container *c, json_object 
*object) {
+       json_object_object_add(object, "name",
+                       c->title ? json_object_new_string(c->title) : NULL);
+-      json_object_object_add(object, "type",
+-                      json_object_new_string(container_is_floating(c) ? 
"floating_con" : "con"));
++      if (container_is_floating(c)) {
++              json_object_object_add(object, "type",
++                              json_object_new_string("floating_con"));
++      }
+ 
+       json_object_object_add(object, "layout",
+                       json_object_new_string(
+@@ -692,12 +699,11 @@ json_object *ipc_json_describe_node(struct sway_node 
*node) {
+       };
+       seat_for_each_node(seat, focus_inactive_children_iterator, &data);
+ 
+-      json_object *object = ipc_json_create_node(
+-                              (int)node->id, name, focused, focus, &box);
++      json_object *object = ipc_json_create_node((int)node->id,
++                              ipc_json_node_type_description(node->type), 
name, focused, focus, &box);
+ 
+       switch (node->type) {
+       case N_ROOT:
+-              ipc_json_describe_root(root, object);
+               break;
+       case N_OUTPUT:
+               ipc_json_describe_output(node->sway_output, object);
+-- 
+2.30.1
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/sway.git/commitdiff/ac52b9f9cefade62d14a6c24c9ff0d9e6cd4c188

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to