This fixes a crash that occurs when disabling floating for a container
while it is being moved or resized.
@Deiz describes the problem:
> It occurs because the command that disables floating runs before the
event loop. So, the window is tiled, its floating parent is destroyed,
but then a key event is handled which causes the position/size of the
now-destroyed parent to be modified.
canonicalize_output_name allowed the "primary" special output name to
be canonicalized, thus converting it to the name of whatever output
was the primary output at the time. This caused settings
(specifically, i3bar output and tray_output settings) to be stored as
specific output names, instead of the intended special names whose
referred output may change as the system's configuration (i.e. current
primary output) changes.
Add a check to canonicalize_output_name to return the name as-is if it
is the special name "primary".
fake_outputs: Allow designating a fake output as primary
Allow appending 'P' to the fake output specification to set the
created output's "primary" flag, to allow writing test cases that
depend on the presence of a primary output.
fake_outputs_init would unconditionally increase the string read
pointer variable (walk) by one character more than the number of
characters that have been read, to skip past the character delimiting
records (a comma). However, when the input string was not terminated
by a comma, it would cause the function to read past the null
terminator instead.
Avoid this by explicitly checking for the expected delimiter.
fake_outputs: Use %n format specifier instead of sprintf
fake_outputs_init used a sprintf invocation with a throw-away buffer
to estimate how many characters the sscanf invocation consumed. This
was unnecessary, and also potentially incorrect, as differences
between the read and formatted strings (such as leading zeros) could
lead to fake_outputs_init to lose its track.
Instead, use the %n format specifier which allows saving the number of
characters consumed by sscanf so far. %n is part of C99.
I previously tried to fix the check, but could only come up with a fix which
required removing our module pre-loading, which makes the tests considerably
more expensive. Instead, let’s just remove the check.
t/265-swap: don’t start new i3 instances with the same config
$config is never touched after being initially set up.
Not restarting i3 between each test case reduces the runtime of this test by an
order of magnitude.
Fix erratic behavior with single container child jumping outputs
This fixes a regression introduced in commit 4e88c10564ca5366c2578908f62ec56625a26718: when attempting to move the
single child of a container in the direction of another output, i3
would move the window to the output, despite the window not being at
the edge of its output, instead of moving it to its parent container.
The bug occurred because the check for moving containers across
outputs with non-default workspace layouts (issue #1603) did not
actually verify that the moved window lies at the edge of the
workspace, despite what its comment said.
This commit also introduces slurp() which reads a file in its entirety. Using
this function instead of doing IO in the functions in load_layout.c again and
again makes the code cleaner (fixing at least two memory leaks) and avoids
re-reading the same file 3 times.
ipc: Canonicalize output names in bar configuration
Convert the output names specified in the "output" and "tray_output"
fields in bar blocks in i3's configuration to the referred output's
primary name. This allows specifying names other than the primary
output's name in the given fields without changing the IPC protocol.
randr: Register monitors' output names as additional i3 output names
In addition to the name of the monitor itself (which is still used as
the i3 output's primary name), register RandR output names associated
with the RandR monitor as alternative i3 output names.
Currently, only one name is ever added, and only the first name is
ever accessed; actually using the capability to store and access
multiple names comes in the following commits.
Currently simply returns output->name, but this will make it easier to
change how output names are stored in the following commits.
Also replace reading output->name with invocations of
output_primary_name. Code which writes output->name is unchanged. Done
using a mostly mechanical replacement of output->name to
output_primary_name(output).
The test runs `xrandr setmonitor`, which will otherwise affect any test
scheduled after 533-randr15.t, causing flakyness in t/217-NET_CURRENT_DESKTOP.t
for example.
hwangcc23 [Thu, 31 Aug 2017 14:48:33 +0000 (22:48 +0800)]
Properly initialize sigaction struct
The code in handle_signal() wasn't clearing the struct sigaction before passing it to sigaction().
This meant that we would block a random set of signals while executing the default handler, or jump to the uninitialized __sa_sigaction__ (instead of sa_handler).
Initialize properly as we do in setup_signal_handler().
Theo Buehler [Wed, 23 Aug 2017 13:48:58 +0000 (15:48 +0200)]
Avoid use of uninitialized in init_dpi_end
If conn == NULL or display == NULL, init_dpi() jumps to init_dpi_end
before (declaring and) initializing resource. In init_dpi_end, there
is a free(resource) call conditionally on resource != NULL, so this
may lead to a bogus free. Found by clang -Wsometimes-uninitialized.
This fixes the following issue when having an error early in the config file:
==1562==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6220000180ff at pc 0x55c837edb1d3 bp 0x7ffee7534650 sp 0x7ffee7534648
READ of size 1 at 0x6220000180ff thread T0
#0 0x55c837edb1d2 in start_of_line ../../i3/src/config_parser.c:238
#1 0x55c837edc96f in parse_config ../../i3/src/config_parser.c:493
#2 0x55c837edf527 in parse_file ../../i3/src/config_parser.c:1091
#3 0x55c837ecf14b in parse_configuration ../../i3/src/config.c:65
#4 0x55c837ed1ef4 in load_configuration ../../i3/src/config.c:230
#5 0x55c837f0a8d0 in main ../../i3/src/main.c:539
#6 0x7fb63ae042b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
#7 0x55c837e95eb9 in _start (/home/michael/i3/build/i3+0x4beb9)
0x6220000180ff is located 1 bytes to the left of 5165-byte region [0x622000018100,0x62200001952d)
allocated by thread T0 here:
#0 0x7fb63e590cf8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1cf8)
#1 0x55c837f59aa6 in smalloc ../../i3/libi3/safewrappers.c:24
#2 0x55c837edef45 in parse_file ../../i3/src/config_parser.c:1029
#3 0x55c837ecf14b in parse_configuration ../../i3/src/config.c:65
#4 0x55c837ed1ef4 in load_configuration ../../i3/src/config.c:230
#5 0x55c837f0a8d0 in main ../../i3/src/main.c:539
#6 0x7fb63ae042b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)