1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2025-04-14 17:53:25 -04:00
A lightweight compositor for X11
Find a file
Yuxuan Shui 6cdb36d404
core: fix poll for event loop (i hope)
This partially reverts c57b705ec4, the
previous fix for #1345

The previous fix falsely assumed if `x_poll_for_event` returned nothing,
it must have not read from the X connection. This is just not true. It
worked, probably because it's impossible to have vblank events close
together (they are only once per frame). But that's an assumption we
probably shouldn't make.

_Separately_, we have another problem. We assumed if `x_poll_for_event`
returned nothing, we don't need to flush again. This is not true either.
There could be pending requests being completed, whose callback function
might have sent new requests. This, for example, causes `picom-inspect`
to hang, because some requests are stuck in the outgoing buffer.

The explanation for the fix is going to be long, because this kind of
problems are never simple.

First of all, we need a version of `x_poll_for_event` that actually
guarantees to not read from X. The current version of `x_poll_for_event`
is already extremely complex, I don't want to pile more complexity on
top of it. So instead we are now using a different approach, one some
might consider a ugly hack.

The complexity of `x_poll_for_event` all stems from the lack of
`xcb_poll_for_queued_{reply,special_event}` API, so we had to use
complex to merge message from different streams (events, special events,
replies, and errors) all the while trying our best (and fail) to handle
all messages in the xcb buffer before going to sleep. There is a
`xcb_poll_for_queued_event` which in theory can be used for this and
will make things a lot simpler, the problem is we don't control events,
so if there is a large gap between event arrivals, picom would just be
sitting there doing nothing.

And that's exactly what we do in this commit, that is, controlling
events. Every time we wait for replies/errors for some requests, we send
a request that are guaranteed to _fail_. This is because unchecked
errors will be returned by `xcb_poll_for_queued_event` as an event. This
way, we can be sure an event will be received in a bounded amount of time,
so we won't hang.

This vastly simplifies the logic in `x_poll_for_event`, and made adding
a no-read version of it trivial. Now we have that, some care need to be
taken to make sure that we _do_ read from X sometimes, otherwise we
will go to sleep without reading anything, and be woken up again
immediately by the file descriptor. This will result in an infinite
loop. This has some ripple effects, for example, now we queue redraw
whenever the wm tree changes; before, redraws were only queued when the
wm tree becomes consistent.

Even with this, we still need the `while(true)` loop in
`handle_x_events`, this is because of the other problem we mentioned at
the beginning - flushing. The way we fix the flushing problem is by
tracking the completion of pending requests - if any requests were
completed, we flush conservatively (meaning even when not strictly
necessary) - simple enough. But flushing could read (yes, read) from X
too! So whenever we flush, we need to call `x_poll_for_event` again,
hence the while loop.

Fixes: #1345

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-10-12 18:50:26 +01:00
.circleci ci: test animgen 2024-08-06 01:21:47 +01:00
.github docs: document animation 2024-08-09 23:25:02 +01:00
assets animation/presets: add geometry-change preset 2024-08-12 06:25:25 +01:00
bin picom-trans: Added SPDX-License-Identifier 2021-07-23 21:15:53 +01:00
data transition: avoid opacity change for fly-out/slide-out presets 2024-10-10 12:20:57 +01:00
dbus-examples Update inverter.sh 2020-04-01 04:50:03 +00:00
include animation: add saved-image-blend 2024-08-12 05:39:54 +01:00
LICENSES More license stuff... 2018-10-04 11:18:09 +01:00
man docs: clarify interaction between rules and picom-trans 2024-08-30 16:45:05 +01:00
media Added 48x48px raster of initial Compton logo 2015-09-17 21:57:11 -04:00
meson Made meson/install.sh executable 2022-04-12 05:41:41 +00:00
src core: fix poll for event loop (i hope) 2024-10-12 18:50:26 +01:00
subprojects test.h: silence gcc warnings about unused results 2024-08-02 17:16:32 +01:00
tests tests: test animation presets 2024-08-06 01:15:51 +01:00
tools tools/animgen: support more sophisticated preset parameters 2024-08-06 01:18:33 +01:00
.clang-format file_watch: use kqueue on *BSD platforms 2019-11-11 21:22:57 +00:00
.clang-tidy clang-tidy: be more strict about strcmp 2024-08-29 23:19:42 +01:00
.editorconfig build: add libepoxy 2024-02-10 20:35:24 +00:00
.gitignore transition: add support for animation presets 2024-08-06 01:15:48 +01:00
CHANGELOG.md backend/xrender: actually, nobody has accelerated convolution :'( 2024-10-11 18:42:52 +01:00
compton-default-fshader-win.glsl Feature: #183 custom window shader & #193 --no-fading-destroyed-argb 2014-05-16 15:18:17 +08:00
compton-fake-transparency-fshader-win.glsl Feature: #183 custom window shader & #193 --no-fading-destroyed-argb 2014-05-16 15:18:17 +08:00
compton.desktop set .desktop files to NoDisplay=true 2020-12-14 14:54:33 +01:00
CONTRIBUTORS update contributors list 2024-10-08 17:21:31 +03:00
COPYING rename: documentation changes 2019-10-23 20:24:25 +01:00
desc.txt Misc: #49: Add CMake support 2012-10-03 13:34:54 +08:00
Doxyfile Fix small misspellings 2019-01-28 10:58:14 +01:00
flake.lock flake: update and upgrade to llvm 18 2024-07-26 16:33:34 +01:00
flake.nix doc: switch to asciidoctor 2024-07-30 19:01:07 +01:00
History.md README: Move old historical info out of main README 2022-04-12 09:43:57 -04:00
LICENSE.spdx rename: documentation changes 2019-10-23 20:24:25 +01:00
meson.build meson: bump version 2024-09-27 07:29:52 +01:00
meson_options.txt meson: add support for llvm-style code coverage 2024-06-06 17:12:18 +01:00
picom-dbus.desktop set .desktop files to NoDisplay=true 2020-12-14 14:54:33 +01:00
picom.desktop meson.build: autostart picom 2022-08-21 06:25:55 +01:00
picom.sample.conf docs: update picom.sample.conf 2024-08-03 04:35:42 +01:00
README.md misc: update README.md 2024-09-08 09:31:48 +01:00

picom

circleci codecov chat on discord

picom is a compositor for X, and a fork of Compton.

This is a development branch, bugs to be expected

You can leave your feedback or thoughts in the discussion tab, or chat with other users on discord!

Change Log

See Releases

Build

Dependencies

Assuming you already have all the usual building tools installed (e.g. gcc, python, meson, ninja, etc.), you still need:

  • libx11
  • libx11-xcb
  • xproto
  • xcb
  • xcb-util
  • xcb-damage
  • xcb-xfixes
  • xcb-shape
  • xcb-renderutil
  • xcb-render
  • xcb-randr
  • xcb-composite
  • xcb-image
  • xcb-present
  • xcb-glx
  • pixman
  • libconfig
  • libdbus (optional, disable with the -Ddbus=false meson configure flag)
  • libGL, libEGL, libepoxy (optional, disable with the -Dopengl=false meson configure flag)
  • libpcre2 (optional, disable with the -Dregex=false meson configure flag)
  • libev
  • uthash

On Debian based distributions (e.g. Ubuntu), the needed packages are

libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libepoxy-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev meson ninja-build uthash-dev

On Fedora, the needed packages are

dbus-devel gcc git libconfig-devel libdrm-devel libev-devel libX11-devel libX11-xcb libxcb-devel libGL-devel libEGL-devel libepoxy-devel meson pcre2-devel pixman-devel uthash-devel xcb-util-image-devel xcb-util-renderutil-devel xorg-x11-proto-devel xcb-util-devel

To build the documents, you need asciidoctor

To build

$ meson setup --buildtype=release build
$ ninja -C build

Built binary can be found in build/src

If you have libraries and/or headers installed at non-default location (e.g. under /usr/local/), you might need to tell meson about them, since meson doesn't look for dependencies there by default.

You can do that by setting the CPPFLAGS and LDFLAGS environment variables when running meson. Like this:

$ LDFLAGS="-L/path/to/libraries" CPPFLAGS="-I/path/to/headers" meson setup --buildtype=release build

As an example, on FreeBSD, you might have to run meson with:

$ LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" meson setup --buildtype=release build
$ ninja -C build

To install

$ ninja -C build install

Default install prefix is /usr/local, you can change it with meson configure -Dprefix=<path> build

How to Contribute

All contributions are welcome!

New features you think should be included in picom, a fix for a bug you found - please open a PR!

You can take a look at the Issues.

Contributions to the documents and wiki are also appreciated.

Even if you don't want to add anything to picom, you are still helping by compiling and running this branch, and report any issue you can find.

Become a Collaborator

Becoming a collaborator of picom requires significant time commitment. You are expected to reply to issue reports, reviewing PRs, and sometimes fix bugs or implement new feature. You won't be able to push to the main branch directly, and all you code still has to go through code review.

If this sounds good to you, feel free to contact me.

Contributors

See CONTRIBUTORS

The README for the original Compton project can be found here.

Licensing

picom is free software, made available under the MIT and MPL-2.0 software licenses. See the individual source files for details.