Commit Graph

1060 Commits

Author SHA1 Message Date
Yuxuan Shui
a56d66b4f3 win: rework how events for unmapped windows are handled
Make unmapped window events work mostly like a mapped window, except
flags set on unmapped windows aren't processed until the window is
mapped.

Hopefully this unifies some of the code paths and reduce corner cases.

Should fix #525

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-11-28 20:29:25 +00:00
Yuxuan Shui
248bffede7 Fix non-opengl build
Oops

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-11-03 19:03:07 +00:00
Yuxuan Shui
c9f75a53d9 core: fix leak of argb_fbconfig
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-11-02 18:43:12 +00:00
Yuxuan Shui
e3582cd996 legacy backend: render: fix leak of fbconfig
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-11-02 18:23:38 +00:00
Yuxuan Shui
685e5a9aac config_libconfig: allow overrides if supported
Related: #530

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-29 09:38:05 +00:00
Omar Polo
7eddf79ed2 wrap subobject initialization with braces to silence a warning 2020-10-28 20:27:01 +01:00
Omar Polo
eeaba75a62 use the correct format control for uint64_t 2020-10-28 20:07:14 +01:00
Bernd Busse
3d358a06f2 event: Add missing check if window is managed before setting flags 2020-10-25 12:36:09 +01:00
Yuxuan Shui
27d59dbb30 picom: get max hostname length with sysconf()
For FreeBSD compatibility, which doesn't define HOST_NAME_MAX.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-25 03:13:03 +00:00
Yuxuan Shui
ae62269eb7 Merge remote-tracking branch 'fix/clear-shadow-stale-on-unmap' into next 2020-10-23 17:27:40 +01:00
Yuxuan Shui
dfe4a362e2 win: clear more stale flags when destroying a window
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 17:22:15 +01:00
yshui
1ce8012519 Merge pull request #522 from tryone144/clang-analyzer-errors
Fix/silence memory errors reported by `scan-build`.
2020-10-23 17:06:27 +01:00
Yuxuan Shui
22162cb7e2 win: don't add damage when changing shadow setting while unredirected
When the screen is unredirected, no window have a shadow image. So the
assertions in win_set_shadow don't hold. But in that case, we don't want
to add damages anyway. So we put them behind a check of whether the screen
is redirected.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 16:44:21 +01:00
Bernd Busse
337831e094 Fix memory errors reported by scan-build.
- Fix non-critical memory-leak in `picom.c` and `options.c` where we
don't free all allocated memory before dieing.

- Explicitly allocate new branch in `c2.c` to silence false-positive
memory-leak.
2020-10-23 17:20:59 +02:00
Yuxuan Shui
3576a92da3 x: wid_get_text_prop shouldn't return 0 strings
Downstream code expect wid_get_text_prop to return at least 1 string.
However wid_get_text_prop would return 0 strings when the property is
set to an empty string.

Fixes: dc37370a66

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 15:16:11 +01:00
Bernd Busse
1a720edbad win: clear SHADOW_STALE in destroy_win_start
Clear both STALE flags (`IMAGES_STALE = PIXMAP_STALE | SHADOW_STALE`)
when destroying windows (see f493447b33).

Clearing `SHADOW_STALE` as well should eliminate the recreation of a shadow
image for a window currently being destroyed which will cause the
rendering to fail because we can't properly update the flags anymore.

Should fix: #394
2020-10-23 15:46:37 +02: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
e53ac7a6f9 event, win: delayed handling of shape notify
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 04:37:38 +01:00
Yuxuan Shui
f476a78ad1 event: don't eagerly add damage for configure notify
If a window receives multiple configure notifies in between 2 frames, we
add all the in between positions into damage, when we really just need
the starting and the end position.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 04:27:35 +01:00
Yuxuan Shui
35b4e82085 win: cache the result of fade-exclude rules
So we don't need to call c2_match every frame something is fading. Also
saves us from some out-of-critical-section X server queries.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 02:08:34 +01:00
Yuxuan Shui
21e9aab6b6 event: set WIN_FLAGS_FACTOR_CHANGED on tracked property change
Previously, when some explicitly checked property (e.g.
_NET_WM_WINDOW_OPACITY) changed, it won't trigger a
win_on_factor_change, and the rules will not be re-evaluated. Because
that property stale flag will be cleared after we explicitly check the
property, so it won't be detected as a tracked property change.

Here, we instead set WIN_FLAGS_FACTOR_CHANGED directly when a tracked
property changed.

Fixes: f3ff7eff8c

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 01:58:12 +01:00
Yuxuan Shui
a099678664 win: delayed handling of configure notify
Part of the configure notify handling which requires querying the X
server, has been moved into the X critical section.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 01:36:04 +01:00
Yuxuan Shui
f3ff7eff8c event: delayed handling of window property changes
Move handling window property changes into the X critical section.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 00:15:54 +01:00
nia
8f78b9b631 Fix the build when memcpy is defined as a macro. (#501)
Parentheses are required around macro argument containing braced
initializer list.

memcpy(3) is a macro when using e.g. -D_FORTIFY_SOURCE=2.
2020-10-22 02:25:19 +01:00
Yuxuan Shui
ff70f6056e core: remove a bit more of Xlib dependencies
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-21 02:06:15 +00:00
Yuxuan Shui
00ee5cb4b1 diagnostics: fix missing newline
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-20 03:10:26 +00: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
Bernd Busse
fb3760bbe3 config: add wintypes option blur-background 2020-10-01 23:28:05 +02:00
Bernd Busse
fbbc97eedb log: Use thread-safe version of localtime()
Fixes CodeQL warning: https://github.com/yshui/picom/security/code-scanning/1
2020-10-01 23:00:09 +02:00
Yuxuan Shui
9bb21fc726 core: remove pid file on shutdown
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-09-16 12:14:46 +01:00
jialeens
7d7eef7ff4 Accept write-pid-path option from the config file
Signed-off-by: jialeens <jialeadmin@163.com>
2020-09-16 12:14:46 +01:00
Bernd Busse
aef1b856a6 backend: gl_common: render correct number of elements in blur
Keep track of the number of elements/indices for the normal blur rects
as well as the resized ones and use the correct number when drawing.
The number of rects can change if resized rects overlap and are reduced
into a single rect.

Fixes #440
2020-09-11 20:11:11 +02:00
Yuxuan Shui
699ff9bc82 options: fix typo
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-09-08 07:17:56 +01:00
Yuxuan Shui
7d32783d9e options: warn when dual-kawase blur is chosen on unsupported backends
Closes #464

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-09-08 07:08:23 +01:00
Yuxuan Shui
670b4abae7 backend/backend: add a TODO about image ops ordering 2020-09-05 18:55:23 +01:00
Yuxuan Shui
c5145479b0 Fix several memory leaks
* src/event.c: expose_root: region is not freed
* backend/xrender/xrender.c:
    * bind_pixmap: the reply `r` is not freed
    * blur: reg_op_resized is not freed

Spotted-by: Samuel Hand <samuel.d.hand@gmail.com>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-09-05 16:45:21 +01:00
Bernd Busse
c9ca9de55e core: update stale images AFTER checking focus
Partially revert 32754b0262.

We start with mapping the window (`win_process_update_flags()`). Then check
if focus has changed and process focus updates. Finally refresh stale images
(`win_process_image_flags`) because rules based on focus may have invalidated
them or require them to be created.

Fixes #465 with the following rule:
```
shadow-exclude = [
  "focused" != 1"
]
```
2020-08-31 20:22:28 +02:00
Yuxuan Shui
283504d527 Remove no-dock-shadow and no-dnd-shadow
Deprecated since v4

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-08-31 18:32:14 +01:00
Bernd Busse
5e0215abab backend: gl_common: implement dual-filter kawase blur method
Implement the dual-filter kawase blur algorithm for the new OpenGL backend
as seen in kwin [1]. Use with `--blur-method dual_kawase` and set the
desired strength with `--blur-strength level` (1-20).

The dual-filter kawase algorithm produces results close to a traditional
gaussian blur with higher performace, especially at high blur radii. The
supported strength levels provide an effect similar to gauss-radii between
4 and 500 pixels.

As this algorithm relies heavily on the texture-filtering units of a
GPU, there is no support for the xrender backend — at least for now.

[1](https://kwin.kde.narkive.com/aSqRYYw7/d9848-updated-the-blur-method-to-use-the-more-efficient-dual-kawase-blur-algorithm)
2020-08-31 14:06:45 +02:00
Bernd Busse
89c18afac6 backend: gl_common: split kernel-blur code from general init/blur code [WIP]
**Work-in-Progress**

Split-off kernel-blur specific initialization and rendering from common
OpenGL setup. Add stub functions for dual_kawase-blur initialization and
rendering.
2020-08-31 14:06:18 +02:00
Bernd Busse
d45d0ca209 backend: create dual_kawase blur parameters from selected strength [WIP]
**Work-in-Progress**

Generate suitable parameters for dual-filter kawase blur based on the
selected `blur-strength` or approximate a gauss blur with the selected
`blur-size` and std-deviation.
2020-08-31 14:06:18 +02:00
Bernd Busse
33c5a5a36b Add support for new blur method dual_kawase [WIP]
**Work-in-Progress**

Add `dual_kawase` to configuration and argument parsing. Allow `kawase`
for backward compatibility. Add `--blur-strength` parameter for
blur-method `dual_kawase`.

Update documentation to reflect the new blur-method and parameters.
2020-08-31 14:06:17 +02:00
Bernd Busse
0000cc1d98 backend: gl_common: support arbitrary number of aux. blur textures/fbos
Support an arbitrary number of auxiliary textures and framebuffers for
blur. Preparation for the dual-filter kawase algorithm.
2020-08-31 14:06:17 +02:00
Yuxuan Shui
5ebac238e2 Remove documentation, usage messages and examples about sw-opti
It have been deprecated.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-08-30 21:26:19 +01:00
Yuxuan Shui
9c7b8597e0 core: rename _draw_callback to draw_callback_impl
All names start with underscore are reserved in C.

Also just testing out the language server's renaming feature.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-08-30 17:44:21 +01:00
Yuxuan Shui
8c1b0657ff Refresh the TODO comments
Removed the outdated ones, clarified some of them, and assigned them to
me.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-08-30 15:25:58 +01:00
Yuxuan Shui
0574e63658 Be explicit when checking XCB_NONE
Obvisouly this commit only cover a tiny portion of these checks.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-08-30 14:10:26 +01:00
Yuxuan Shui
617503a5de core: use a long-lived XFixes region
This is a workaround for #301. This doesn't fix the bug, but by
allocating X resources much less frequently, this should make the
bug almost never happen.

Also, it might generally be a good idea to not create/destroy X
resources so often. (XFixes Region accounts for >99% of the resource
creations/destructions)

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-08-30 09:17:20 +01:00
Bernd Busse
7077609c01 c2: correctly initialize new branch for combined rule 2020-08-29 16:27:56 +02:00
Yuxuan Shui
933f2cfe80 diagnostics: improve driver printing
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-08-25 06:54:10 +01:00