Commit Graph

1867 Commits

Author SHA1 Message Date
Yuxuan Shui
fcb9dc8cfd core: make sure unredirection happens when screen is off
So when the screen is off, we calls queue_redraw, hoping draw_callback
will be called and unredirects the screen. However, queue_redraw doesn't
queue another redraw when one is already queued. Redraws can be queued
in two ways: one is timer based, which is fine, because it will be
triggered no matter what; the other is frame based, which is triggered
by Present events.

When the screen is off, X server, depends on the driver, could send
abnormal Present events, which we ignore. But that also means queued
frame based redraw will stop being triggered.

Those two factors combined means sometimes unredirection does not happen
when the screen is off. Which means we aren't going to free the GL
context, which are still receiving Present events, but can't handle
them, because we are not rendering anything with GL. In the end all
these causes memory usage to balloon, until the screen is turned on and
we start rendering again.

And all these is not caught by leak checkers because this technically is
not a leak, as everything is eventually freed.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:31 +01:00
Yuxuan Shui
edeb17ad46 core: don't fully trust msc from present complete notify
Sometimes X sends bogus complete notifies with invalid msc number.
Instead use a saved msc number to get the next complete notify.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:30 +01:00
Yuxuan Shui
1899ef0d49 core: only check present timer alignment in the first frame
Timer can sometimes drift randomly, like when the system is suspended.
we don't want to disable frame pacing for that

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:29 +01:00
Yuxuan Shui
480fd24da6 core: stop sending NotifyMsc if frame pacing is disabled
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:28 +01:00
Yuxuan Shui
a4fae2b60a core: better frame pacing function
Details explained in the comments on schedule_render().

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:26 +01:00
Yuxuan Shui
47ffaf0a38 core: workaround X present event quirk
When the screen turns off, X sometimes sends present complete notify for
the same frame multiple times, or even events with invalid msc/ust
number.

This will cause us to ignore it and not send a subsequent NotifyMsc
request, causing the complete notify to stop.

Now we send NotifyMsc regardless to keep the events going.

Also detect when the complete notifies skip frames, divide the interval
by frame count to estimate frame time in that case.

Upstream bug report:
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1418

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:25 +01:00
Yuxuan Shui
86d3739374 core: frame pacing
Use frame timing and render time statistic to pace frames.

Right now the criteria are simple:

* Don't render multiple frames in one vblank cycle. Otherwise the
  rendered frame will be delay multiple cycles, which isn't ideal.
* Start rendering as late as possible while still hitting vblank.

Refresh rate is estimated from a rolling average of frame timing. Render
time is predicted from the rolling maximum of past 128 frames. The
window size still needs to be investigated.

Remove glFinish calls and GL_MaxFramesAllowed=1, frame pacing superseeds
them.

Professionals might laugh at how rudimentary this is, but hopefully this
is better than what we had before. Which is absolutely nothing at all.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:24 +01:00
Yuxuan Shui
2a4e32babf backend: add last_render_time interface.
Used for querying how long render takes to complete, used for frame
pacing.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:23 +01:00
Yuxuan Shui
64a97b57b5 core: collect frame timing information.
Needed to estimate refresh rate, and for us to stay in phase with
vblank.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:21 +01:00
Yuxuan Shui
62fcfe5d1a backend: remove unused parameter 'ignore_damage'
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:16 +01:00
Yuxuan Shui
3aed5599c3 glx: calculate residual in both directions
We only considered residual in the positive direction, i.e. we would set
dithering to zero if the color is (whole number + 0.0001). But we should
also set dithering to zero if color is (whole number - 0.0001).

Fixes #1064
2023-05-08 15:01:50 +01:00
Yuxuan Shui
05ef18d78f Merge pull request #1044 from yshui/alanpq 2023-04-01 11:32:30 +01:00
Yuxuan Shui
379f67f5c2 tests: add corner-radius-rules to the parsing test
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-04-01 11:27:05 +01:00
oofsauce
6d459badbc Add corner-radius-rules configuration option
This option accepts a list of patterns and overrides the corner radii of
matching windows

Authored-by: oofsauce <alanpanayotov@gmail.com>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-04-01 11:26:10 +01:00
Yuxuan Shui
838f1f097c Merge pull request #1023 from absolutelynothelix/xrescheck-xcb-render-pictures-test 2023-03-30 09:06:37 +01:00
Maxim Solovyov
ce7758a07b backend: fix leak in default_backend_render_shadow 2023-02-13 03:36:00 +03:00
Yuxuan Shui
cee1287562 github: update git-clang-format-lint action
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-29 16:23:26 +00:00
Yuxuan Shui
317275abf6 Merge pull request #995 from absolutelynothelix/begone-xinerama 2023-01-29 15:36:04 +00:00
Maxim Solovyov
986b3c1cb3 core: drop xinerama
there are two x extensions for working with monitors (especially
multiple): xinerama and randr. xinerama is old, feature-poor and in
general isn't used anymore compared to the randr: new, feature-rich and
widely-used. for some reason we were using both of them, so let's drop
xinerama to keep things simple, clean and small. and to be modern.

the drop was done in three steps:
* first step was to replace all the xinerama-based code with the
  randr-based one and to replace or remove all the xinerama mentions;
* second step was to replace the xinerama's terminology with the
  randr's one. xinerama was referring only to the word "screen", while
  randr refers to multiple words and i think the word "monitor" is the
  most suitable for us and, hopefully, clear both to a contributor and
  to an end user;
* third step was to refactor the new randr-based code if needed and to
  address related todo's (mostly about moving related functions
  elsewhere).

all the steps were done well except addressing a leftover todo about
moving the win_update_monitor function to the x.c which wasn't done.

the xinerama-shadow-crop option was renamed to crop-shadow-to-monitor,
but it's previous name is still accepted, has effect and the
deprecation message is printed to preserve backwards-compatibility.
2023-01-29 10:51:12 +03:00
Yuxuan Shui
102a0bc5e0 backend: mask can be null in blur()
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-29 06:35:28 +00:00
Yuxuan Shui
364463feaf doc: list cases that trigger unredirect
unredir-if-possible doesn't just happen for fullscreen windows, be more
accurate.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-17 02:56:28 +00:00
Yuxuan Shui
1926b6d231 Merge pull request #994 from absolutelynothelix/ensure_glx_context_segfault 2023-01-13 16:55:41 +00:00
Yuxuan Shui
766f9f996f Merge pull request #986 from absolutelynothelix/fix-creating-eglpixmap
fixes https://github.com/yshui/picom/issues/981
2023-01-13 16:55:06 +00:00
Yuxuan Shui
7ac80f980d Merge pull request #992 from absolutelynothelix/xcb_request_check_memory_leaks 2023-01-13 16:52:22 +00:00
Yuxuan Shui
e18a42ebd0 Merge pull request #985 from absolutelynothelix/free-root-image-properly
fixes https://github.com/yshui/picom/issues/982
2023-01-13 16:51:41 +00:00
Yuxuan Shui
2f1e244cd5 Merge pull request #990 from absolutelynothelix/simplify-getting-egl-fbconfig 2023-01-13 16:51:09 +00:00
Yuxuan Shui
e20a02e67a Merge pull request #991 from absolutelynothelix/xcb_request_check_checked_functions 2023-01-12 11:01:34 +00:00
Maxim Solovyov
74ab307626 opengl: fix segfault in ensure_glx_context 2023-01-12 06:40:56 +03:00
Maxim Solovyov
0ecfd9fd32 backend: egl: fix creating eglpixmap
according to the specification of the EGL_KHR_image_pixmap extension,
if target is EGL_NATIVE_PIXMAP_KHR then ctx must be EGL_NO_CONTEXT,
otherwise, the EGL_BAD_PARAMETER error is generated. source:
https://registry.khronos.org/EGL/extensions/KHR/EGL_KHR_image_pixmap.txt

fixes #981
2023-01-11 13:36:18 +03:00
Maxim Solovyov
81f2bf4c07 picom: fix xcb_request_check memory leaks 2023-01-11 12:35:03 +03:00
Maxim Solovyov
ca64654256 use _checked functions with xcb_request_check 2023-01-10 00:15:49 +03:00
Maxim Solovyov
29342e7cea backend: egl: simplify getting a framebuffer configuration
we're using the first available framebuffer configuration that
meets our needs so there is no need to ask for more than one
2023-01-09 04:25:59 +03:00
Maxim Solovyov
91828be79d picom: free root image properly
fixes #982
2022-12-30 06:16:46 +03:00
Yuxuan Shui
60ac2b64db Merge pull request #983 from absolutelynothelix/next
fixes #867
2022-12-23 15:44:18 +00:00
Maxim Solovyov
cffc443bfd xrender: make corner-radius respect inactive-dim
for the new xrender backend it's enough to clip with a rounded rectangle after dimming, not before

partially fixes #867
2022-12-23 15:21:52 +03:00
Yuxuan Shui
99e1a74afa Merge pull request #980 from absolutelynothelix/next 2022-12-22 21:19:38 +00:00
Maxim Solovyov
32020ff659 xrender: fix leak in release_rounded_corner_cache
calling wrong free function did nothing and produced ton of x errors

fixes at least #892
2022-12-22 20:42:20 +03:00
Yuxuan Shui
5457d76de6 Merge pull request #979 from absolutelynothelix/next 2022-12-22 10:59:50 +00:00
Maxim Solovyov
dd9ffecd85 xrender: fix leak in deinit
and check should we actually free something

fixes at least #960
2022-12-22 02:08:04 +03:00
Yuxuan Shui
48d3a0b9d8 Merge pull request #978 from absolutelynothelix/next 2022-12-21 22:21:29 +00:00
Maxim Solovyov
70032b9282 xrender: fix leak in bind_pixmap 2022-12-22 00:20:43 +03:00
Yuxuan Shui
156b7c48de Merge pull request #977 from absolutelynothelix/next 2022-12-21 21:02:02 +00:00
Maxim Solovyov
df7b994d00 x: fix leak in x_create_picture_with_pictfmt_and_pixmap 2022-12-21 23:29:52 +03:00
Yuxuan Shui
fdecbb98f8 Merge pull request #969 from yshui/detect-dpms-off 2022-12-21 18:12:51 +00:00
Yuxuan Shui
37ecb4b496 core: detect screen off
Use the DPMS extension to detect if screen is turned off, and unredirect
if it is. This also helps working around the problem where OpenGL
buffers lose data when screen is turned off, causing screen to flicker
later when it turns back on if use-damage is enabled.

Unfortunately the DPMS extension doesn't define an event, so we have to
periodically poll the screen state.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2022-12-19 08:52:18 +00:00
Yuxuan Shui
c28462673e backend: xrender: fix using of invalid picture when vsync is disabled
Fixes #974

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2022-12-18 19:24:16 +00:00
Yuxuan Shui
1ea3276bd1 x: fix missing _checked
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2022-12-18 19:23:06 +00:00
Yuxuan Shui
17b34ce390 core: add set_cant_fail_cookie
Enables picom to abort when certain requests fail.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2022-12-14 14:30:58 +00:00
Yuxuan Shui
aca3fdcef7 core: expand X error handling
We used to have a list of X errors we should ignore in case they do
occur. This commit expands that functionality to also allow us aborting
on certain errors.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2022-12-14 14:23:55 +00:00
Yuxuan Shui
4ecb8093cf x: fix CI build failure
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2022-12-14 14:02:57 +00:00