IPC: set ws reply "num" member to -1 when named
When a named workspace (i.e., a workspace that has a name that does not begin with text that can be parsed as an integer greater than or equal to zero) is represented by the ipc as a workspace json object such as can be queried with `i3-msg -t get_workspaces`, set the num property to -1 instead of json null. This is for convenience of ipc consumers using type-constrained languages such as C which have difficulty cleanly expressing nullable integers. fixes #1368
This commit is contained in:
parent
8870edc2ca
commit
fd8a2b0e51
2
docs/ipc
2
docs/ipc
@ -156,7 +156,7 @@ following properties:
|
|||||||
|
|
||||||
num (integer)::
|
num (integer)::
|
||||||
The logical number of the workspace. Corresponds to the command
|
The logical number of the workspace. Corresponds to the command
|
||||||
to switch to this workspace.
|
to switch to this workspace. For named workspaces, this will be -1.
|
||||||
name (string)::
|
name (string)::
|
||||||
The name of this workspace (by default num+1), as changed by the
|
The name of this workspace (by default num+1), as changed by the
|
||||||
user. Encoded in UTF-8.
|
user. Encoded in UTF-8.
|
||||||
|
@ -617,10 +617,7 @@ IPC_HANDLER(get_workspaces) {
|
|||||||
y(map_open);
|
y(map_open);
|
||||||
|
|
||||||
ystr("num");
|
ystr("num");
|
||||||
if (ws->num == -1)
|
y(integer, ws->num);
|
||||||
y(null);
|
|
||||||
else
|
|
||||||
y(integer, ws->num);
|
|
||||||
|
|
||||||
ystr("name");
|
ystr("name");
|
||||||
ystr(ws->name);
|
ystr(ws->name);
|
||||||
|
@ -24,7 +24,7 @@ sub check_order {
|
|||||||
my ($msg) = @_;
|
my ($msg) = @_;
|
||||||
|
|
||||||
my @ws = @{$i3->get_workspaces->recv};
|
my @ws = @{$i3->get_workspaces->recv};
|
||||||
my @nums = map { $_->{num} } grep { defined($_->{num}) } @ws;
|
my @nums = map { $_->{num} } grep { $_->{num} != -1 } @ws;
|
||||||
my @sorted = sort @nums;
|
my @sorted = sort @nums;
|
||||||
|
|
||||||
is_deeply(\@nums, \@sorted, $msg);
|
is_deeply(\@nums, \@sorted, $msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user