aboutsummaryrefslogtreecommitdiff
path: root/libi3
AgeCommit message (Collapse)Author
13 daysipc_connect: Delete outdated pathOrestis Floros
2024-01-27clang-format: enable InsertBraces (#5882)Orestis Floros
Enforces a rule that we have followed for years now. Yes, the diff is quite big but we get it over with once and we prevent having to nit-pick future PRs.
2023-07-22Share graphics context globally (#4376)Uli Schlachter
Instead of creating a graphics context for every surface_t, this commit adds a cache that allows to "remember" up to two GCs. Thus, the code uses less GCs. When a GC from the cache can be used, this also gets rid of a round-trip to the X11 server. Both of these are tiny, insignificant savings, but so what? Since GCs are per-depth, this code needs access to get_visual_depth(). To avoid a code duplication, this function is moved to libi3. Fixes: https://github.com/i3/i3/issues/3478 Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-11-06Allow text drawing to use the alpha channel. (#5246)Michael Stapelberg
This is the last remaining diff from the i3-gaps tree. related to https://github.com/i3/i3/issues/3724 Tested using the following config with picom: bar { i3bar_command i3bar -t status_command i3status colors { # fully transparent text on opaque background: statusline #ffffff00 background #000000ff } }
2022-11-05draw_util: refactor surface_initialized macro into functionMichael Stapelberg
This makes it possible to set a breakpoint in gdb on a line in the function and get a backtrace of un-initialized surface access.
2022-06-01Fix typos (#4989)George Rodrigues
2021-11-04Fix compilation error on debianOrestis Floros
2021-11-04Do not replace existing IPC socket (#4638)Uli Schlachter
Imagine you are a happy i3 user and want to also write patches for i3. You use "Xephyr :1" to get another X11 server and then start your newly build i3 in it with "DISPLAY=:1 ./i3". You test your changes and everything seems fine. You are happy. Later that day, you try to log out, but the $mod+Shift+e key binding from the default config no longer works. i3-msg cannot connect to the IPC socket because "No such file or directory". What is going on? The problem boils down to $I3SOCK having something like two meanings. When i3 starts, it sets the environment variable $I3SOCK to the path of its IPC socket. That way, any process started from i3 inherits this and i3-msg knows how to talk to i3. However, when this variable is already set when i3 starts, then i3 will replace the existing socket. Thus, in the earlier experiments, the "separate i3" that was used for experimenting stole the "main i3"'s socket and replaced it with its own. When it exited, it deleted that socket. This commit adds half a work around to this problem: When creating the IPC socket, i3 will now first try to connect() to the socket. If this succeeds, it will complain and refuse to use this socket. If the connect() call fails, it will proceed as usual and create the socket. Note that trying to connect() to a socket that no process listens on will fail. Thus, this new code only really "triggers" when some process is actively listening on this socket and accepting connections. Example output for when the socket is already in use: $ I3SOCK=/tmp/sdfdsf DISPLAY=:2 ./i3 31.10.2021 17:03:55 - [libi3] ERROR: Refusing to create UNIX socket at /tmp/sdfdsf: Socket is already in use 31.10.2021 17:03:55 - ERROR: Could not create the IPC socket, IPC disabled This commit sadly only provides part of the solution. i3 will still delete the socket when shutting down, even if it failed to create the IPC socket. Thus, the ipc socket will still break, but now only later. This will be fixed separately. First-step-towards-fixing: https://github.com/i3/i3/issues/4381 Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-09-15Fix a minor memory leakUli Schlachter
When xcb_request_check() returns an error, something has to clean up and free this error. Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-09-15Check cairo status in draw_util_surface_free()Uli Schlachter
When "something goes wrong" in cairo-land, the corresponding cairo object goes into an error state. These errors are sticky. Thus, it is enough to check for errors before destroying the context. This commit adds a check in draw_util_surface_free() to check the cairo context's status and print a log message if anything is wrong. The idea here is to help debugging drawing issues. Instead of "nothing visible", the corresponding log message hopefully helps debugging. This code would have saved me lots of time in figuring out why my pull request #4379 did not work. Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-07-05Use mkdirp() in get_process_filename() (#4397)tomty89
Avoids race condition in case multiple i3 instances are started in parallel with e.g. systemd user units for multiple X(vfb) servers.
2021-06-13Implement showing window icons in titlebar (#4439)Michael Stapelberg
This feature defaults to off, and can be turned on for individual windows, or (with for_window) for all new windows. See the userguide change. This commit is partially based on work by: • Marius Muja • mickael9 • Esteve Varela Colominas • Bernardo Menicagli
2021-05-20Do not "set" the wallpaper during startup (#4373)Uli Schlachter
"Set" the wallpaper during startup only sometimes Since commit 4f5e0e7, i3 would take a screenshot and set that as the background pixmap of the root window during startup. This is the easy part of setting a proper X11 wallpaper. The code in question was added because something either set the background pixmap of the root window to NONE or the X11 server was started with "-background none". This is apparently done by default by e.g. gdm to avoid some flickering while the X11 server starts up. This commit makes this code conditional: Only when no wallpaper is detected is a screenshot taken. Since I could not find any way to query the background of a window, a more direct approach is taken to detect this situation: First, we find some part of the root window that is not currently covered. Then we open a white window there, close it again and grab a screenshot. If a wallpaper is set, the X11 server will draw this wallpaper after the window is closed and something else will be visible in the screenshot. However, the wallpaper could have a white pixel at the tested position. Thus, this procedure is repeated with a black window. Only when this procedure produces two different pixel values is a screenshot taken and set as the wallpaper. Fixes: https://github.com/i3/i3/issues/4371 Fixes: https://github.com/i3/i3/issues/2869 Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-03-06Remove unused member from surface_tUli Schlachter
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-03-05font: Get rid of temporary cairo surfaceUli Schlachter
i3 actually manages to have two different cairo surfaces referring to the same drawable. One comes from the code in draw_util. The second is temporarily created while rendering text via draw_text(). No idea how well cairo handles this case. This commit instead changes the code to pass the already existing cairo surface from the caller through. This might or might not fix https://github.com/i3/i3/pull/4357. My thinking here is that cairo now knows the actual size of the drawable and thus does not clip the drawing to a smaller size. Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-03-05Remove draw_text_ascii()Uli Schlachter
This function is unused since commit fa488d721dfd1e1 from 2017. Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-01-20i3-dump-log -f: switch from pthreads to UNIX socketsMichael Stapelberg
fixes #4117
2021-01-20move set_nonblock, create_socket and path_exists to libi3Michael Stapelberg
2020-10-20clang-format: use TypenameMacrosAlbert Safin
This commit removes line breaks and extra empty lines introduced in commit fff3f79da9a87a1f790c6328f6615422f2b69b47.
2020-05-19add meson build files (#4094)Michael Stapelberg
Motivation: • faster builds (on an Intel Core i9-9900K): ( ../configure --disable-sanitizers && make -j8; ) 19,47s user 2,78s system 395% cpu 5,632 total ( meson .. -Dmans=true -Ddocs=true -Dprefix=/usr && ninja; ) 38,67s user 3,73s system 1095% cpu 3,871 total • more approachable build system configuration in the python-esque meson domain specific language instead of the autotools m4 macro language • built-in language server support thanks to ninja: the required compile_commands.json is built automatically and only needs to be linked from the source dir, e.g.: ln -s build/compile_commands.json . Changes: • the embedded vcs version info format changed from e.g. 4.18-282-gabe46f69 (2020-05-16, branch "next") to: 4.18-282-gabe46f69 I think it’s better to lose a little bit of detail for the gained cleanliness of using meson’s vcs_tag() • Drop unused xcb-event dependency. • We can no longer enable sanitizers and debug options based on whether we are in a release or non-release build, because our new version logic runs at ninja build time, not at meson configure time. The new behavior is probably for the better in terms of what people expect, and we can make the CI use address sanitizer explicitly to ensure it is still exercised. • We lose the AX_EXTEND_SRCDIR behavior, i.e. including the path component of the parent of the source dir in all paths. This was a trick we used for easier debugging, so that stack traces would contain e.g. ../i3-4.18.1/src/main.c, instead of just src/main.c. The other mechanism (_i3_version symbol) that we have for including the version number in the “backtrace full” (but not merely “backtrace”) output of gdb still works. • Release tarballs now use tar.xz. Why not. Migration plan This commit adds the meson build files to the tree, but does not remove autotools yet. For the development phase, we will keep both build systems functional (and built on travis). Then, just before the i3 v4.19 release, we will remove autotools from the tree and the release tarball will require meson to compile. This way, we incentivize maintainers to change, while also offering them an easy way out (if desired) by reverting the most recent commit. In practice, switching a distribution package from autotools to meson should only be a few line change, easier than applying the provided patch :). Take a look at the debian/ changes in this commit for an example. meson is broadly available everywhere that i3 is available: Both xorg-server and systemd gained meson build files in 2017, so we can follow suit: https://anholt.livejournal.com/52574.html https://in.waw.pl/~zbyszek/blog/systemd-meson.html How do I? For producing a coverage report, enable the b_coverage meson base option and run ninja coverage-html: % cd build % meson .. -Db_coverage=true % ninja % ninja test % ninja coverage-html See also https://mesonbuild.com/howtox.html#producing-a-coverage-report For using the address sanitizer, memory sanitizer or undefined behavior sanitizer, use the b_sanitize meson base option: % cd build % meson .. -Db_sanitize=address % ninja See also https://mesonbuild.com/Builtin-options.html#base-options related to #4086
2020-04-30Fix #ifndef statements: HAVE_ variables are all upper caseMichael Stapelberg
The autoconf manual states: define HAVE_function (in all capitals) if it is available https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Generic-Functions.html#Generic-Functions Thanks to @sur5r for the report
2020-04-20Remove unused headersOrestis Floros
With help from https://github.com/include-what-you-use/include-what-you-use/
2020-04-19Sort includes in *.c filesOrestis Floros
Not enabling in .clang-format because it breaks headers files. Used: IncludeCategories: - Regex: '^<config' Priority: 0 - Regex: '^".*"' Priority: 1 - Regex: '^<(xcb|xkb|yajl|X11)' Priority: 3 - Regex: '.*' Priority: 2
2020-04-14Sort dock clients by class and instanceOrestis Floros
This is similar to #3820 but does not use qsort but an insertion sort in con_attach. Since each bar block automatically gets its own incremental bar id, bards end up being sorted according to their definition order in the config file. For i3bar, the WM_CLASS is modified to include an instance name which depends on the bar_id. This could be useful for other reason, e.g. users targeting a specific bar instance. Fixes #3491
2020-02-21Code style: fix misaligned and trailing whitespacesAlbert Safin
2020-02-19clang-format: bring back ForeachMacros (#3948)xzfc
* clang-format: bring back ForeachMacros ForeachMacros was disabled in 4211274fcd028a8e33a084e5695290ae0e9f3020 due to the breakage of include/queue.h. The currently used version, clang-format-6.0 doesn't break it. * Add curly braces Co-authored-by: Orestis Floros <orestisflo@gmail.com>
2020-02-01libi3: Make visual_type externOrestis Floros
See #3914
2019-12-25Merge pull request #3824 from orestisfl/ac_replace_funcsMichael Stapelberg
Use AC_REPLACE_FUNCS
2019-10-20Remove various unused parametersOrestis Floros
2019-10-13Use AC_REPLACE_FUNCSOrestis Floros
strndup is removed from AC_CHECK_FUNCS since it will be provided if not found. Fixes #2610
2019-04-10Fix memory leakJeremy Klotz
2019-03-29Allow checking for duplicate bindings with -COrestis Floros
- Having both parse_configuration and parse_file is excessive now - We detect if we are parsing only by checking if conn is NULL, not with use_nagbar - font.pattern needs to be set to NULL because it is freed in free_font() Fixes #3660
2019-03-19convert_utf8_to_ucs2: Allow partial conversionOrestis Floros
Fixes #3638.
2018-10-24Merge pull request #3473 from soumya92/pango-font-alignmentOrestis
Always center text vertically
2018-10-22Always center text verticallySoumya
2018-10-13Use lround instead of (long)roundOrestis Floros
2018-10-13Make comment style more consistentOrestis Floros
2018-10-13Enforce strict prototypesOrestis Floros
i3 will now compile with no warnings when -Wstrict-prototypes is used.
2018-10-13Reduce some code around freesOrestis Floros
2018-10-13Merge pull request #3454 from alanbarr/cppcheck_fixes_2Orestis
Cppcheck Fixes
2018-10-13Fixes for undefined behaviour on signed shift (#3453)Alan Barr
Fixes for undefined behaviour on signed shift Change literal 1 to unsigned to allow safe bitshift of 31. Caught by cppcheck. Make 0xFF unsigned to prevent a left shift into signed bit. Spotted by @orestisf1993
2018-10-13Typecast void* before doing pointer arithmeticAlan Barr
Caught by cppcheck
2018-10-13Remove redundant NULL checkAlan Barr
copy has been used before this point - so it is too late to be concerned about a NULL pointer now. This is OK as sstrdup() calls err() on NULL return from the underlying strdup() call. Raised by cppcheck.
2018-10-07resolve_tilde: strncpy + strlen is pointless (#3436)Orestis
strlen already assumes that the string is NULL-terminated. Like in https://github.com/i3/i3status/pull/312 but for whatever reason gcc didn't warn about this here.
2018-09-25Provide g_utf8_make_valid if not availableOrestis Floros
See #3415 for licensing discussion. Fixes Airblader/i3#236
2018-09-24Fix typo: terminaison -> terminationOrestis Floros
2018-09-10libi3: validate UTF8 stringsOrestis Floros
Will validate container / window titles. Fixes #3156.
2018-08-22Apply compatible changes from clang-format 6.0.1Orestis Floros
These are the changes that clang-format 6.0.1 makes to the codebase that clang-format-3.8 doesn't change back. Useful for those that use a more recent version of clang-format in their local machines.
2018-08-08Merge pull request #3263 from orestisf1993/misbehaving-ipc-queue-2999Michael Stapelberg
Kill misbehaving subscribed clients instead of hanging
2018-08-08Kill misbehaving subscribed clients instead of hangingOrestis Floros
This change only affects clients that are subscribed to events, which should be the main cause of our problems. In the common case (no buffered data) the behaviour doesn't change at all: the message is sent directly, no ev_io / ev_timeout callback is enabled. Once a write to a client's socket is not completed fully (returns with EAGAIN error), we put the message in the tail of a queue and init an ev_io callback and a corresponding timer. If the timer is triggered first, the socket is closed and the client connection is removed. If the socket becomes writeable before the timeout we either reset the timer if we couldn't push all the buffered data or completely remove it if everything was pushed. We could also replace ipc_send_message() for all client connections in i3, not just those subscribed to events. Furthermore, we could limit the amount of messages stored and increase the timeout (or use multiple timeouts): eg it's ok if a client is not reading for 10 seconds and we are only holding 5KB of messages for them but it is not ok if they are inactive for 5 seconds and we have 30MB of messages held. Closes #2999 Closes #2539