Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rust/Cargo.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ edition = "2021"

[dependencies]
libwmctl = { version = "0.0.51", optional = true }
serde = { version = "1.0", optional = true, features = ["derive"] }
serde_json = { version = "1.0", optional = true }
x11rb = { version = "0.13", optional = true }
xcb = { version = "1", optional = true }

[features]
default = ["i3", "xcb"]
i3 = ["dep:serde_json"]
i3 = ["dep:serde_json", "dep:serde"]
xcb = ["dep:xcb"]
wmctl = ["dep:libwmctl", "dep:x11rb"]
6 changes: 5 additions & 1 deletion rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ dist/i3switch: target/x86_64-unknown-linux-gnu/release/i3switch
cp target/x86_64-unknown-linux-gnu/release/i3switch dist/

.PHONY: test
test: Cargo.toml $(SOURCE_FILES)
test: schema Cargo.toml $(SOURCE_FILES)
cargo test --all-features

.PHONY: schema
schema:
check-jsonschema --schemafile jsons/node.jsonschema jsons/*.json

.PHONY: all
all: dist/i3switch

Expand Down
31 changes: 31 additions & 0 deletions rust/jsons/2node_splith.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"id": 1,
"type": "con",
"layout": "splith",
"nodes": [
{
"id": 2,
"type": "con",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": true
},
{
"id": 3,
"type": "con",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 300, "y": 450, "width": 15, "height": 200},
"focus": [],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [2],
"focused": false
}
52 changes: 52 additions & 0 deletions rust/jsons/ambigous_tabs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"id": 0,
"type": "con",
"layout": "splith",
"nodes": [
{
"id": 1,
"type": "con",
"layout": "tabbed",
"nodes": [
{
"id": 3,
"type": "con",
"layout": "tabbed",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": true
},
{
"id": 4,
"type": "con",
"layout": "tabbed",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [3],
"focused": false
},
{
"id": 2,
"type": "con",
"layout": "tabbed",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [1, 3],
"focused": false
}
10 changes: 10 additions & 0 deletions rust/jsons/empty_node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": 0,
"type": "con",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": false
}
21 changes: 21 additions & 0 deletions rust/jsons/empty_tabs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"id": 2,
"type": "con",
"layout": "tabbed",
"nodes": [
{
"id": 1,
"type": "con",
"layout": "tabbed",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": true
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [1],
"focused": false
}
10 changes: 10 additions & 0 deletions rust/jsons/empty_workspace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": 1,
"type": "workspace",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": false
}
36 changes: 36 additions & 0 deletions rust/jsons/node.jsonschema
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": { "type": "number" },
"name": { "type": "string" },
"type": { "type": "string" },
"layout": { "type": "string" },
"nodes": {
"type": "array",
"items": { "$ref": "#" }
},
"floating_nodes": {
"type": "array",
"items": { "$ref": "#" }
},
"rect": {
"type": "object",
"properties": {
"x": { "type": "number" },
"y": { "type": "number" },
"width": { "type": "number" },
"height": { "type": "number" }
},
"required": ["x", "y", "width", "height"]
},
"focus": {
"type": "array",
"items": { "type": "number" }
},
"focused": {
"type": "boolean"
}
},
"required": ["id", "type", "layout", "nodes", "floating_nodes", "rect", "focus", "focused"]
}
173 changes: 173 additions & 0 deletions rust/jsons/root_with_several_nodes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
"id": 0,
"type": "root",
"layout": "splith",
"nodes": [
{
"id": 1,
"type": "output",
"layout": "output",
"nodes": [
{
"id": 2,
"name": "content",
"type": "con",
"layout": "splith",
"nodes": [
{
"id": 3,
"type": "workspace",
"layout": "splith",
"nodes": [
{
"id": 4,
"type": "con",
"layout": "splith",
"nodes": [
{
"id": 5,
"type": "con",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": false
},
{
"id": 6,
"type": "con",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": true
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [6, 5],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [4],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [3],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [2],
"focused": false
},
{
"id": 7,
"type": "output",
"layout": "output",
"nodes": [
{
"id": 8,
"type": "con",
"layout": "splith",
"name": "content",
"nodes": [
{
"id": 12,
"type": "workspace",
"layout": "splith",
"nodes": [
{
"id": 13,
"type": "con",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [13],
"focused": false
},
{
"id": 9,
"type": "workspace",
"layout": "splith",
"nodes": [
{
"id": 10,
"type": "con",
"layout": "tabbed",
"nodes": [
{
"id": 14,
"type": "con",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": false
},
{
"id": 11,
"type": "con",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 0, "height": 0},
"focus": [11, 14],
"focused": false
}
],
"floating_nodes": [
{
"id": 20,
"type": "con",
"layout": "splith",
"nodes": [],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [],
"focused": false
}
],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [10, 20],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [9, 12],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [8],
"focused": false
}
],
"floating_nodes": [],
"rect": {"x": 0, "y": 0, "width": 100, "height": 100},
"focus": [1, 7],
"focused": false
}
Loading
Loading