Commit Graph

179 Commits

Author SHA1 Message Date
nixo 3fe8e00356 [meson]: add more programs, [i3]: add bindsym 2020-05-10 00:40:57 +02:00
Michael Stapelberg 5ee7690af3 Fix #ifndef statements: HAVE_ variables are all upper case
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-30 18:20:51 +02:00
Orestis Floros 0b62129224
Remove unused headers
With help from
https://github.com/include-what-you-use/include-what-you-use/
2020-04-20 04:25:06 +02:00
Orestis Floros 3c522d9f2f
Sort includes in *.c files
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-19 09:58:25 +02:00
Orestis Floros 7df88f18eb
Sort dock clients by class and instance
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-04-14 20:47:51 +02:00
Albert Safin d3976fee8c Code style: fix misaligned and trailing whitespaces 2020-02-21 02:06:48 +00:00
xzfc 1f0c628cde
clang-format: bring back ForeachMacros (#3948)
* clang-format: bring back ForeachMacros

ForeachMacros was disabled in 4211274fcd
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-19 11:31:09 +01:00
Orestis Floros e9f011397a
libi3: Make visual_type extern
See #3914
2020-02-01 17:32:54 +01:00
Michael Stapelberg d341b91b0a
Merge pull request #3824 from orestisfl/ac_replace_funcs
Use AC_REPLACE_FUNCS
2019-12-25 12:27:21 +01:00
Orestis Floros 17d0cd7034
Remove various unused parameters 2019-10-20 16:14:20 +03:00
Orestis Floros b0d6f44779
Use AC_REPLACE_FUNCS
strndup is removed from AC_CHECK_FUNCS since it will be provided if not
found.

Fixes #2610
2019-10-13 13:17:40 +03:00
Jeremy Klotz 58c808a961 Fix memory leak 2019-04-10 19:56:30 -04:00
Orestis Floros 08cdc3a6ae
Allow checking for duplicate bindings with -C
- 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-29 12:30:04 +02:00
Orestis Floros bd58d67ea8
convert_utf8_to_ucs2: Allow partial conversion
Fixes #3638.
2019-03-19 10:31:34 +02:00
Orestis 2ddf4f2c6d
Merge pull request #3473 from soumya92/pango-font-alignment
Always center text vertically
2018-10-24 22:57:31 +03:00
Soumya 81eea19e1e Always center text vertically 2018-10-22 12:59:08 -07:00
Orestis Floros 052e96d323
Use lround instead of (long)round 2018-10-13 21:10:10 +03:00
Orestis Floros e4d2b38552
Make comment style more consistent 2018-10-13 21:10:10 +03:00
Orestis Floros 2a9522dda4
Enforce strict prototypes
i3 will now compile with no warnings when -Wstrict-prototypes is used.
2018-10-13 21:10:09 +03:00
Orestis Floros 50880db2c5
Reduce some code around frees 2018-10-13 21:10:09 +03:00
Orestis 565d38c5af
Merge pull request #3454 from alanbarr/cppcheck_fixes_2
Cppcheck Fixes
2018-10-13 21:07:17 +03:00
Alan Barr 7c0994dafc Fixes for undefined behaviour on signed shift (#3453)
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-13 21:04:40 +03:00
Alan Barr 687238b79b Typecast void* before doing pointer arithmetic
Caught by cppcheck
2018-10-13 17:41:50 +01:00
Alan Barr 88c378154a Remove redundant NULL check
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-13 17:41:50 +01:00
Orestis 2be4975f18 resolve_tilde: strncpy + strlen is pointless (#3436)
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-10-07 20:26:37 +02:00
Orestis Floros daf5ca111f
Provide g_utf8_make_valid if not available
See #3415 for licensing discussion.

Fixes Airblader/i3#236
2018-09-25 10:28:20 +03:00
Orestis Floros aa8215194c
Fix typo: terminaison -> termination 2018-09-24 20:53:36 +03:00
Orestis Floros 6a1f653508
libi3: validate UTF8 strings
Will validate container / window titles.

Fixes #3156.
2018-09-10 02:00:32 +03:00
Orestis Floros e6202d43f5
Apply compatible changes from clang-format 6.0.1
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-22 14:51:17 +03:00
Michael Stapelberg 5a54a1ab04
Merge pull request #3263 from orestisf1993/misbehaving-ipc-queue-2999
Kill misbehaving subscribed clients instead of hanging
2018-08-08 19:14:15 +02:00
Orestis Floros 37d0105c83
Kill misbehaving subscribed clients instead of hanging
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
2018-08-08 19:14:56 +03:00
Ingo Bürk 65eb54c0ba
Merge pull request #3319 from Stunkymonkey/format_placholders-case_sensitive
make format_placeholders case-sensitive
2018-08-04 09:23:11 +02:00
Cassandra Fox ad236dbaec fix height offset calculation in pango text drawing 2018-07-28 19:31:32 -07:00
Felix Buehler 37ea56c221 make format_placeholders case-sensitive 2018-07-10 23:24:50 +02:00
Orestis Floros fd70ea6b31
Correct XDG paths precedence for config files
Fixes #3323
2018-07-10 05:04:34 +03:00
Orestis Floros 0b5a2092a0
Fix redundant casts to the same type
Found using clang-tidy's google-readability-casting.
2018-04-27 00:09:42 +03:00
Orestis Floros 0aa636b207
Prefer compiler warnings to assertions for unhandled switch cases
Using 'default:' cases can hide logical errors which would lead to i3
crashes for users. With this change the compiler will print a warning
when a case is not handled. For example, if I add a new value in the
Font.type enum:
../../i3/libi3/font.c: In function ‘draw_text’:
../../i3/libi3/font.c:378:5: warning: enumeration value ‘NEWFONT’ not handled in switch [-Wswitch]
     switch (savedFont->type) {
     ^~~~~~
2018-04-04 19:20:55 +03:00
Pawel S. Veselov d2b35388b4 Fixes #3072, Xft.dpi can be floating point 2017-12-09 15:12:25 +01:00
Michael Stapelberg c07936d91b no-op refactoring: make ipc_connect find socket path 2017-11-26 16:41:59 +01:00
xzfc 103e78e04a Bugfix: avert endless loop on unexpected EOF at ipc messages (#3021)
Fix freeze on invalid ipc commands like

    echo -n $'i3-ipc\0\0\0\xa\0\0\0\0focus left' | socat - `i3 --get-socketpath`

Also, treat incomplete headers as IPC violation. Example of incomplete header:

    echo -n i3-ip | socat - `i3 --get-socketpath`
2017-11-09 11:18:23 -08:00
Michael Stapelberg d968d39b27 Replace http:// with https:// where applicable
The testcases will be updated automatically in a separate commit.
2017-09-24 10:19:07 +02:00
Ingo Bürk eba177342f Revert "Use OVER operator for drawing text (#2908)" (#2925)
This reverts commit 16160462a3.
2017-09-10 17:03:09 +02:00
Jan Alexander Steffens 16160462a3 Use OVER operator for drawing text (#2908)
For opaque text, SOURCE is not any different from OVER. However, when
drawing color glyphs (which consist of RGBA pixels instead of strokes)
SOURCE's handling of alpha is not what we want.

I stumbled across this because cairo 1.15.8 seems to clear the surface
before drawing color emoji if the operator is SOURCE, deleting every-
thing drawn before. Arguably, the area outside the glyph bounds should
not be touched, but even if this is a cairo bug the problem of alpha
within the glyph remains.
2017-09-09 17:32:34 +02:00
Theo Buehler d29d908003 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.
2017-08-23 15:48:58 +02:00
Tony Crisci 3a914396df libi3: Add basic validation to hex color conversion
Make sure a given hex color is the expected length and begins with a hash in
draw_util_hex_to_color() to avoid memory errors.

fixes #2829
2017-07-12 17:53:15 -04:00
Ingo Bürk e0582aa5eb Remove unused function arguments. (#2635)
The connection is no longer necessary since the non-cairo paths have
been removed.
2017-01-13 09:34:09 -08:00
Ingo Bürk 25d27c5b2e Free allocated X resource value. (#2620)
This fixes a little memory leak.
2017-01-02 15:56:28 +01:00
Michael Stapelberg 2ff3d9d651 Merge pull request #2551 from bapt/freebsd_fixes
Freebsd fixes
2016-11-16 13:48:05 -08:00
mihaicmn ad7dec31d5 Use the DPI setting within the i3bar (#2556) 2016-11-12 06:34:54 -08:00
Baptiste Daroussin c602ec7cc2 Respect SYSCONFDIR when looking for defaut 'xdg' directory 2016-11-09 22:34:39 +01:00