exec* calls return when an error occurs, this is unexpected but would
still leave the forked process in a broken state. This commit fixes that
by ensuring they are followed by an immediate exit.
In theory, if `/proc/sys/kernel/core_pattern` is 1024 or more bytes, the
null character terminating the buffer can be overwritten.
Note: Found with [bugfinder](https://github.com/stanek-michal/bugfinder)
Before the xcb_randr_get_crtc_info() call fails, `new` has been already
added to `outputs with `TAILQ_INSERT_TAIL(&outputs, new, outputs);`.
Note: Found with [bugfinder](https://github.com/stanek-michal/bugfinder)
tree_move calls tree_flatten which can destroy redundant containers.
An example reproduction would be V[H[a V[b]]] where V[b] is focused
(parent of b) and a is moved away using the DT_PARENT target.
Note: Found with [bugfinder](https://github.com/stanek-michal/bugfinder)
Example in
https://github.com/i3/i3/actions/runs/18260895234/job/51988635887?pr=6502
`i3-log-for-124-move.t`:
```
../libi3/font.c:332:9: runtime error: signed integer overflow: 2147483641 + 11 cannot be represented in type 'int'
#0 0x5611ce962d65 in draw_text_xcb ../libi3/font.c:332
#1 0x5611ce962d65 in draw_text ../libi3/font.c:376
#2 0x5611ce95de20 in draw_util_text ../libi3/draw_util.c:219
#3 0x5611ce947e7a in x_draw_decoration ../src/x.c:751
#4 0x5611ce94f93a in x_push_node ../src/x.c:1097
#5 0x5611ce94e9d8 in x_push_node ../src/x.c:1204
#6 0x5611ce94e9d8 in x_push_node ../src/x.c:1204
#7 0x5611ce94e9d8 in x_push_node ../src/x.c:1204
#8 0x5611ce952e9b in x_push_changes ../src/x.c:1373
#9 0x5611ce922d1f in tree_render ../src/tree.c:468
#10 0x5611ce8d1bbb in handle_run_command ../src/ipc.c:220
#11 0x5611ce8c87fe in ipc_receive_message ../src/ipc.c:1481
#12 0x7effc262b64a in ev_invoke_pending (/lib/x86_64-linux-gnu/libev.so.4+0x564a) (BuildId: cfcffb10ff16734dcc7d31d002a90940abff0323)
#13 0x7effc262f22e in ev_run (/lib/x86_64-linux-gnu/libev.so.4+0x922e) (BuildId: cfcffb10ff16734dcc7d31d002a90940abff0323)
#14 0x5611ce809d48 in ev_loop /usr/include/ev.h:841
#15 0x5611ce809d48 in main ../src/main.c:1229
#16 0x7effc1e41ca7 (/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: def5460e3cee00bfee25b429c97bcc4853e5b3a8)
#17 0x7effc1e41d64 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: def5460e3cee00bfee25b429c97bcc4853e5b3a8)
#18 0x5611ce80e770 in _start (/usr/src/i3/build/i3+0x230770) (BuildId: 181abde9a3dd28a8a4be68b90b9b710c8e280633)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../libi3/font.c:332:9
```
Unrelated but I fixed the build fails in `next` because of a
false-positive:
```
In file included from ../include/all.h:40,
from ../src/commands.c:10:
../src/commands.c: In function ‘cmd_floating’:
../include/log.h:30:33: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
30 | #define DLOG(fmt, ...) debuglog("%s:%s:%d - " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
| ^~~~~~~~~~~~~
../src/commands.c:1193:13: note: in expansion of macro ‘DLOG’
1193 | DLOG("should switch mode to %s\n", floating_mode);
| ^~~~
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.
```
Inspired by #5384, but instead of just using the border width, this PR
reports the actual frame extents for the window, which may also include
the title bar (for floating windows and tiled windows in plain split
containers, but not for tiled windows in stacked/tabbed containers).
The existing `con_border_style_rect()` function should already handle
all configuration options which can affect the decoration sizes (if it
does not, that would also show up in other places); its result just
needs to be converted into the format used by the `_NET_FRAME_EXTENTS`
property.
This PR fixes#4292 probably in the best way possible (the reported
`_NET_FRAME_EXTENTS` values should always match the actual sizes of
window frame elements which are actually drawn into the X11 frame window
into which the client window is reparented). The only really problematic
case is with the stacked/tabbed containers, for which the title bar is
actually drawn into a completely separate window, therefore the title
bar size cannot be reported in `_NET_FRAME_EXTENTS` (actually I tried to
calculate the size of those decorations and add it to the top decoration
size, but that did not change the behavior of `picom`).
<details><summary>Large screenshots here (3840×2160)</summary>
Example of configuration with `hide_edge_borders smart` — a single
window does not have borders, so only the top frame size is non-zero:

but multiple windows have borders:

Changing border width works too (although with `border normal 8` you can
see that the top border overlaps the title text, because on the i3 side
that border does not really exists, and `picom` just draws it over; also
the pixel sizes reported by `xprop` and `xwininfo` are not identical to
what is specified in i3, because I use 168 dpi on this system, therefore
4 px in the i3 config = 7 dpx):

Handling of tabbed containers is less perfect though. Here is a single
tabbed container with `hide_edge_borders smart`, so it does not really
have a border — note that all frame extents are zero, and the titlebar
is rounded separately (although it could easily be excluded from
rounding, that does not really help much):

Once the border actually appears, you may notice that the top part of
the `picom` border actually gets drawn over the top part of the window,
partially obscuring the top line in this terminal (`picom` does not mind
that the top frame size is reported as 0):

Some examples of floating windows (no major problems there):

Options like `hide_edge_borders both` work too when gaps are removed
(although the resulting behavior with `picom` is probably not very
useful — the rounded border gets drawn only if all of the left, bottom
and right borders are present):

The same with `border pixel 8` (note that windows with only the top
border hidden still get the rounded border treatment by `picom`, but the
border overlaps the top part of the window):

</details>
---------
Signed-off-by: Sergey Vlasov <sigprof@gmail.com>
Co-authored-by: Orestis Floros <orestisflo@gmail.com>
This is a very easy fix, to remove the following warning:
```
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
```
The fix is to just run `meson setup` instead and it works like a charm.
Related PRs: i3/i3lock#365 and i3/i3status#538.
This causes test breakage when the developer/tester is running the tests
in i3, as the actual active instance socket is used instead of the test
instance.
Besides breaking tests, this is quite dangerous as tests like 319-gaps.t
will replace the **actual** config of the user (i.e.
~/.config/i3/config) instead of the current test config.
Broken after #5987
This was originally mentioned in #3085 but left for a future PR.
One of the noticeable limitations is that pressing the modifier while
the drag is already initiated, will not swap the containers but instead
cancel the drag. This is because of how `drag_pointer()` is written and
would be quite an involved case to handle it.
The crash was brought up in a comment in
https://github.com/i3/i3/discussions/6076#discussioncomment-9536969
The cause is that the command criteria are matching a window in the
scratchpad. In that case, the assertion in get_output_for_con() fails.
That happens because there is no `Output` for the `Con` output of a
scratchpad window.
I've decided to *not* remove the offending assertion but rather rely on
the caller not using the function with internal containers. My reasoning
is:
1. If get_output_for_con can return NULL then the caller will either
segfault (which is worse) or needs to check the return for NULL.
2. The case where the return can be NULL is already known, it happens
for internal containers.
3. Therefore, the caller should already prevent the situation with a
call to con_is_internal(). Thus, the `assert`ion can remain.
There is also the potential fix of con_get_workspace returning some
arbitrary output (e.g. first in the list or currently focused one)
instead of NULL. This can lead to more tricky to catch bugs.
This adds some detail to the workspace events documentation and is
written along the same lines as the window events documentation. This
was brought up in [#4392 (issue)](https://github.com/i3/i3/issues/4392).
This fixes the following warnings on 32 bit systems
```
[60/108] Compiling C object i3.p/src_regex.c.o
In file included from ../include/all.h:40,
from ../src/regex.c:10:
../src/regex.c: In function ‘regex_new’:
../include/log.h:29:33: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
29 | #define ELOG(fmt, ...) errorlog("ERROR: " fmt, ##__VA_ARGS__)
| ^~~~~~~~~
../src/regex.c:35:9: note: in expansion of macro ‘ELOG’
35 | ELOG("PCRE regular expression compilation failed at %lu: %s\n",
| ^~~~
[93/108] Compiling C object i3-input.p/i3-input_main.c.o
../i3-input/main.c: In function ‘finish_input’:
../i3-input/main.c:173:29: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
173 | printf("occurrences = %ld\n", cnt);
| ~~^ ~~~
| | |
| | size_t {aka unsigned int}
| long int
| %d
```
One case when this might be useful is when i3 is restarted and there are
children that terminate after the previous i3 instance shut down but
before the new one set things up.
Fixes#5756
While this initially worked fine, at some point these patches broke
because libcairo started calling shmget(2) - a syscall not covered by
any pledge promise - and a common pitfall when using pledge with
graphics-oriented applications.
Various attempts were made to fix them, but at some time they were
simply disabled in the OpenBSD port:
a4a9f41dd75a03c386ba
This seems pointless and creates needless friction both for the i3 team
who was willing to carry ugly code and for the OpenBSD ports maintainers
who had to disable that code again.
Let's abandon this experiment.
Commit 3ae5f31d0 introduced the I3SOCK environment variable. This
prevents us from having to call `i3 --get-socketpath'. In case the
variable doesn't exist, fall back to the old ways.
Signed-off-by: Wesley Schwengle <wesleys@opperschaap.net>
If there is no newline character at the end of the version option's
output, the next command line prompt is written left to the version,
rather than under it.
Add simple `if exists' construct in the subscribe function. This
prevents a somewhat cryptic warnings such as these:
Use of uninitialized value $type in hash element at
/usr/share/perl5/AnyEvent/I3.pm line 309.
We still warn the user, but it is much clearer as to what the cause is.
It now shows something like this:
Could not subscribe to event type 'foo'. Supported events are _error
barconfig_update binding mode output shutdown tick window workspace
Signed-off-by: Wesley Schwengle <wesleys@opperschaap.net>