GLX context is released when it's no longer current in any threads, so
we have to release the context before destroy it.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Prevent a useless error message from glGetUniformLocationChecked, as
"opacity" is not used by the dummy shader, we will fail to get its
location.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
If the user is using custom shaders, picom will naturally fail to get
some uniform locations if the given uniform is not used in the shader.
So we really shouldn't report error for it.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
"notify" is the only wintype that has a name inconsistent with its Xorg
name. So fix that.
Compatibility code is added as well, so the old "notify" wintype name
still works.
Fixes#323
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
xdgh in xdg_config_home is not always allocated. This commit makes sure
it's always a valid pointer to free by strdup it.
With helps from @dtzWill
Fixes#326Closes#327
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
According to the XDG Base Directory Specification, relative paths in
XDG_CONFIG_DIRS are invalid, so eliminate them if found.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Fixed 2 problems:
1. Made sure the returned list is NULL terminated.
2. Allocate the duplicated string and the return list together, so the
duplicated string will be freed as we free the list. Fixed a memory
leak.
Fixes#324
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
While /dev/null is always empty, it still generates inotify events. So
using /dev/null as config file will cause the compositor to reset itself
frequently.
Not entire sure if only allowing regular files is sufficient, but we
will be doing this until an issue comes up.
Fixes#320
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Currently if the shadow image fails to bind, the entire window is marked
as having image errors. So nothing of that window will render, even if
the window image itself is fine.
The commit cause shadow to be disabled when shadow image fails, instead
of marking the window.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
For big windows, their shadow images might exceed the maximum request
length limit of Xorg. libxcb will shutdown the connection to X server if
we try to send that image. So we have to break the image apart and send
it piecemeal.
In the future we probably should migrate to MIT-SHM.
Fixes#255#274
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Unredirect the screen when some window sets _NET_WM_BYPASS_COMPOSITOR
to 1, but ignore the case where some window requests the screen to be
redirected by setting _NET_WM_BYPASS_COMPOSITOR to 2.
Closes#267
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
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>
| ^~~~~~~~~~~
Transparent windows usually blends on top of other windows, this commit
adds an option to make transparent windows clip other windows like
non-transparent windows do.
Closes#265
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Previously win_set_shadow tries to release the shadow image when turning
off shadow for a window. When shadow is turned off _immediately_ after
it's turned on, picom won't have a chance to handle the delayed creation
of the shadow before win_set_shadow tries to release the shadow image,
causing a assertion failure because win_set_shadow tried to release a
non-existing image.
This commit makes releasing the shadow image delayed as well.
In theory, we could check the STALE flag in win_set_shadow before
release the image, but that duplicates the logic that is already in
win_process_flags.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
The assertion check for condition that are too board.
If we get multiple root config event in a row, then we might find
ourselves trying to release a image that was released in a previous
backend destruction and is yet to be bound (IOW, the window will have
IMAGES_NONE _and_ IMAGES_STALE set), causing the assertion to fail.
This commit relax the check, so we don't check if STALE is set when NONE
is set.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
deinit then init the logging system after resets, because otherwise
duplicated log handlers will be added by session_init, and we will
see duplicated logs.
Doing this also enables us to add log handlers for early logging.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Automatically reset picom and reload the configuration when a change in
the configuration file is detected.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Unsupported backends were rejected when we try to initialize them, now
we reject them in the option parsing phase.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Instead of allocating new textures everytime gl_average_texture_color is
called, we keep two textures per gl_image and reuse those.
Doing this significantly improves CPU usage on AMDGPU driver for some
reason. But in general, less texture allocation is always better.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
leftovers:
1) config file path. Has to implement compatibility functionalities before
we can change it.
2) links in man pages. Has to migrate the repo first.
3) _COMPTON_SHADOW, it has become a defacto standard, so we have to keep
supporting it.
4) dbus names, undecided whether we should/could change it.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
A quick search on GitHub showing the _COMPTON_SHADOW is actively being
used (most noteably, by polybar). It is not a difficult thing to support,
and it doesn't have that much runtime overhead. So remove the option
that guards this feature, make it enabled by default.
(Side note, I saw lots of people putting this option in their config
files, but this is actually a command line only option.)
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Firstly, this breaks the assumption that when we redirect the screen,
all window is either mapped or unmapped, causing a assertion failure.
Secondly, if transition window into fading when the screen is not
redirected, the fading will not progress until the screen is redirected,
probably not the desired result.
Fixes#246
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Since user reports indicate it has real performance benefits.
Also add a command line flag for turning use-damage off.
Fixes#242
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Because first frame no window has their pixmap bound, which doesn't
happen in frames after the first. If a window is unmapped in that frame,
the compositor will try to render a window with no pixmap bound if
fading is enabled.
Now we keep track if we are in the first frame, and if that's the case
we skip fading in unmap/destroy.
Fixes#239, bug number 2
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This simplifies the logic a bit since we know a shadow is always bound
(if needed) when the screen is redirected.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Previously all image stale flags are ignored when processing an unmapped
window. If a window gains a shadow during its fading out transition, the
shadow flag will be set, but shadow won't actually be generated, causing
a NULL pointer dereference during render.
Fixes#239
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Otherwise shadow won't get generated in next critical section, causing
NULL pointer dereference or assertion failure in next render.
Partially fixes#239
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
win_get_name _updates_ the name of the window by querying the X server,
thus potentially changes the behaviour of the compositor when logging is
turned on (e.g. we could fail to detect window name changes, because the
name was blindly updated in a logging call without handling the name change).
We shouldn't do that.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
recheck_focus rejects focus of unmapped windows, so we have to make sure
pending maps of windows are processed before we call recheck_focus.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Fixes the following memory leak reported by valgrind:
1,056 bytes in 24 blocks are definitely lost in loss record 83 of 111
at 0x483577F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x49DB0DD: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49D8FB4: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA63E: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA751: xcb_wait_for_reply (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x11FD5B: fill_win (win.c:1165)
by 0x117CE6: handle_new_windows (compton.c:1266)
by 0x118065: _draw_callback (compton.c:1333)
by 0x1184D0: draw_callback (compton.c:1426)
by 0x49BF292: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)
by 0x49C3344: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)
by 0x11AD65: session_run (compton.c:2226)
This one out of multiple code paths forgot to free the structure. Yeah,
manual memory management is hard. :-)
Fixes the following memory leak reported by valgrind:
992 bytes in 31 blocks are definitely lost in loss record 81 of 111
at 0x483577F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x49DB0DD: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49D8FB4: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA63E: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA751: xcb_wait_for_reply (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x118094: _draw_callback (compton.c:1335)
by 0x1184D0: draw_callback (compton.c:1426)
by 0x49BF292: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)
by 0x49C3344: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)
by 0x11AD65: session_run (compton.c:2226)
by 0x11B005: main (compton.c:2308)
To prevent accidentaly reusing the freed structure, wrap it in a lexical
scope.
Fixes the following memory leaks reported by valgrind:
96 bytes in 1 blocks are definitely lost in loss record 54 of 111
at 0x483577F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x49DB0DD: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49D8FB4: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA63E: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA751: xcb_wait_for_reply (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x14B266: detect_driver (driver.c:34)
by 0x119949: session_init (compton.c:1879)
by 0x11AEF0: main (compton.c:2285)
96 bytes in 1 blocks are definitely lost in loss record 55 of 111
at 0x483577F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x49DB0DD: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49D8FB4: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA63E: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA751: xcb_wait_for_reply (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x14B266: detect_driver (driver.c:34)
by 0x11795E: redir_start (compton.c:1202)
by 0x115C76: paint_preprocess (compton.c:629)
by 0x1182BD: _draw_callback (compton.c:1380)
by 0x1184D0: draw_callback (compton.c:1426)
by 0x49BF292: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)
by 0x49C3344: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)
Fixes the following memory leaks reported by valgrind:
32 bytes in 1 blocks are definitely lost in loss record 15 of 111
at 0x483577F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x49DB0DD: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49D8FB4: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA63E: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA751: xcb_wait_for_reply (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x14B16F: detect_driver (driver.c:20)
by 0x119949: session_init (compton.c:1879)
by 0x11AEF0: main (compton.c:2285)
32 bytes in 1 blocks are definitely lost in loss record 16 of 111
at 0x483577F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x49DB0DD: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49D8FB4: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA63E: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x49DA751: xcb_wait_for_reply (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
by 0x14B16F: detect_driver (driver.c:20)
by 0x11795E: redir_start (compton.c:1202)
by 0x115C76: paint_preprocess (compton.c:629)
by 0x1182BD: _draw_callback (compton.c:1380)
by 0x1184D0: draw_callback (compton.c:1426)
by 0x49BF292: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)
by 0x49C3344: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)
Also, free(randr_version) in the error path as well.
Convert several places where the window image is bound/unbound directly
to use image flags. Make sure window image updates only happen in one
place.
Remove win_bind_image function since its no longer used after this.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
And a window update flag for mapping the window.
Also make sure related functions consider the case where the given window
has pending updates.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Which includes the pending update flags for the window.
Using an internal struct makes sure the window update flags are opaque outside
of win.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
rename map_win, unmap_win, destroy_win to map_win_start,
unmap_win_start, destroy_win_start respectively. To clarify their
intended functions. Also rename the corresponding finish_* functions to
*_finish so they are consistent.
Also some very minor code clean ups.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Instead of doing both unmapping and destroying in the same function,
since that complicates the logic.
Also since now destroy_win handles both the managed and unmanaged cases,
remove destroy_unmanage_win function.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Split it into PIXMAP_STALE and SHADOW_STALE, this allows us to update
pixmaps and shadow images separately.
Also added PIXMAP_NONE and SHADOW_NONE, as redundancy to detect logic
errors.
Convenient constants and functions are provided for updating pixmap and
shadow together.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Instead of pointer to pointer. The two level of pointers were used to
inform the caller the window has been destroyed (pointer set to NULL).
Now, destruction of windows are now signaled by the return value, which
is marked `must_use`.
Problem with taking pointer to pointer is that they tends to pollute the
function signatures a little bit. And we are not using it well anyways.
A lot of the callers passes pointers to local variables to those
functions, so the information about window destruction doesn't actually
bubble up. So, we switch to use just one level of pointers instead.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>