Commit Graph

16 Commits

Author SHA1 Message Date
Yuxuan Shui e92745671b
compiler: use C23 auto when available
One annoying thing is C23 still defines auto as a storage class despite
it now being used for type inference. As a consequence we must write
"auto const" instead of the more natural "const auto".

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-17 08:55:23 +00:00
Yuxuan Shui 1b97f18e5f
compiler: bring the unreachable macro in line with C23
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-17 08:51:22 +00:00
Yuxuan Shui 96fcc6089e
c2: silence a compiler warning
GCC warns about a use after free, because a pointer is used in pointer
comparison after it was freed. This particular case is completely safe,
but GCC warns anyway.

Move the free after the comparison requires me duplicating the free a
couple of times, so instead I made use of the cleanup attribute to auto
free the pointer when it goes out of scope.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2022-07-16 15:05:03 +01:00
Yuxuan Shui dc37370a66
x: remove the last bit of Xlib dependency
Of course, we still use GLX, so we can't completely remove Xlib yet. But
this removes all Xlib uses outside of the backends.

This drops support for COMPOUND_TEXT Xorg strings, so people how wants
multilingual support has to use UTF8, which should be fine since most of
the applications support that.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 07:58:01 +01:00
Yuxuan Shui d00c1c7a1d
compile.h, utils.h: rename popcount
Rename `popcountl` to `popcntul` to avoid name conflicts with NetBSD
system headers.

Remove the unused `popcount` function.

Closes #502

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-07 19:35:55 +01:00
Jan Beich e54058fcc7 compiler.h: also check threads.h exists
In file included from ../src/log.h:8,
                 from ../src/backend/gl/glx.h:18,
                 from ../src/common.h:45,
                 from ../src/picom.c:32:
../src/compiler.h:98:11: fatal error: threads.h: No such file or directory
   98 | # include <threads.h>
      |           ^~~~~~~~~~~
2019-12-24 12:04:04 +00:00
Yuxuan Shui b2ff4eb2c9
compiler.h: add popcount 2019-09-07 19:11:04 +01:00
Yuxuan Shui b5da914920
Mark xcb_generate_id deprecated in compton
x_new_id is preferred since it checks for error.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 23:23:42 +01:00
Yuxuan Shui 41fd229230
build: check if std-predef.h exists
Fix build on FreeBSD / non-glibc systems

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:28 +01:00
Yuxuan Shui 0037b7e5fb
Eliminate implicit conversions
Use explicit conversions everywhere. Adding bounds check assertions when
necessary.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00
Yuxuan Shui a826e0ce79
Window state tracking refactor
Window state tracking is basically the back bond of window fading. We
add a new enum field to the win struct to track the state of the window,
instead of using a set of boolean variables. We also remove the fading
callbacks, since it is only used for fading, so the potential of code
reuse is lost. And it makes the code slightly harder to understand.

Also fixed a problem that --no-fading-openclose is not behaving as
advertised (from my observation, enabling this flag disables fading
entirely, instead of just diabling it for open/close).

Also uses double for opacity everywhere internally. Use opacity_t only
when setting X opacity prop.

TODO: Remove win::*_last

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-17 16:37:28 +00:00
Yuxuan Shui 60aa36b7af
Failure of config file parsing is a hard failure
compton will now quit if it fails to parse the config file.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-13 02:05:01 +00:00
Yuxuan Shui 4040ad259d
Add compiler dependent macros for thread_local
Also add stdc-predef.h because __STDC_NO_THREADS__ is defined there.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 00:46:38 +00:00
Yuxuan Shui 5f57cb41f9
A bit more compiler dependent macros
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-19 20:36:05 +00:00
Yuxuan Shui 68873efaa2
Move likely/unlikely to compiler.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-15 19:14:01 +00:00
Yuxuan Shui b8912fa749
Use checked allocation everywhere
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-15 18:57:46 +00:00