Commit Graph

1083 Commits

Author SHA1 Message Date
Yuxuan Shui
af99101757 win: update screen after win_on_win_size_change
win_update_screen needs w->widthb/heightb, which is only updated in
win_on_win_size_change

Related: #554

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-05 23:01:16 +00:00
Yuxuan Shui
3c38b36f04 win: move win_update_screen from fill_win into win_process_update_flags
fill_win only sets the pending geometry (aka the shadow geometry) of the
window, we have to wait for it to propagate to the real geometry before
we can update the screen.

Related: #554

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-05 11:11:16 +00:00
Yuxuan Shui
ef9f09b68a core: don't add damage in handle_new_windows
Since commit 95a64acf5a, fill_win doesn't
set the window geometry anymore, so we can't use it in
handle_new_windows.

However, we don't need to add damage in handle_new_windows anyway,
damage will be added later when the MAPPED flag is handled.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-05 11:04:55 +00:00
Yuxuan Shui
80b35806f1 win: add debug logging to win_update_screen
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-05 11:03:55 +00:00
Yuxuan Shui
8be379db4d win: fix fading always skipped by unmap_win_start
Fading skip needs to be based on the original value of w->ever_damaged.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-04 04:22:48 +00:00
Yuxuan Shui
f5ee0e12e1 win: fix window not being rendered when it's mapped and damged while fading out
Consider these 2 cases:

* A window is mapped while fading out
* A window is mapped and damaged while fading out

From the perspective of map_win_start, these 2 cases look the same. The
window will has ever_damage = true in both cases. However, map_win_start
has to distinguish between these 2 cases, because at the end of
map_win_start, window in the first case cannot have ever_damage = true,
while window in the second case should have ever_damage = true.

Currently, map_win_start always clears ever_damage in both cases
(indirectly through win_skip_fading), which causes windows in the second
case to not be rendered when they should be.

This commit move clearing of ever_damage from unmap_win_finish to
unmap_win_start, so when map_win_start sees ever_damage = true, it's
always to second case. And to make sure windows which are fading out are
still rendered, we relax the ever_damage check in paint_preprocess to
also accept windows that are fading out. (see code comment for
explanation why this is fine)

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-04 03:46:49 +00:00
Yuxuan Shui
e66a452a27 win: skip fading out for window which aren't ever damaged
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-04 02:58:02 +00:00
Yuxuan Shui
1985360632 core: add trace log about why a window is/isn't painted
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-04 02:53:43 +00:00
Yuxuan Shui
c50e44a8f4 win: downgrade a debug log to trace log
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-04 01:52:19 +00:00
Yuxuan Shui
84ab55d730 win: fix win_is_real_visible
Forgot to negate the expression.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-04 01:07:44 +00:00
Yuxuan Shui
a7be1dc1ad [general]: add more debug logs
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-04 01:07:14 +00:00
Yuxuan Shui
2f2b0319d5 log: strip newlines for gl string marker
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-04 01:06:20 +00:00
Yuxuan Shui
95a64acf5a event, win: fix damage when window is moved while fading out
When a window is moved during fade-out, configure_win won't add the old
window extent to damage (because it's unmapping), but the new window
extent will be added to damage when the window is rendered. And the
window will be rendered in its new location. Thus the damage for the old
window extent is missing.

We could fix this by adding damage in configure_win for unmapping window
too. But in general we don't want to move a window while it's fading
out. So we shadow the window geometry. The shadow geometry is updated in
configure_win, and the update will only propagate to real geometry in
win_process_update_flags.

This also fix the case where a window is unmapped, moved, then mapped
all in the same render cycle. map_win_start is supposed to add the old
window extent to damage in that case, but the old window extent is
already overwritten when we reach map_win_start. The shadow geometry
fixes that.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-03 23:53:10 +00:00
Yuxuan Shui
e1bed6a84b config_libconfig: drop unnecessary warning
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-03 06:09:02 +00:00
yshui
bb54da0039 Merge pull request #544 from niacat/ctype
Cast argument to ctype functions to unsigned char

Fix `-Wchar-subscripts` warnings on NetBSD
2020-11-30 22:42:46 +00:00
Yuxuan Shui
69d4199daa Add rounded-corners-exclude configuration option
Allows the user to selectively disable rounded corners.

Authored-by: Samuel Hand <samuel.d.hand@gmail.com>
2020-11-30 00:35:40 +00:00
Yuxuan Shui
430be62b63 Rounded corners for legacy xrender backend
Authored-by: Samuel Hand <samuel.d.hand@gmail.com>
2020-11-30 00:35:34 +00:00
Samuel Hand
e20b187912 options: add corner-radius
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-11-30 00:31:52 +00:00
Yuxuan Shui
0f975616d6 core: ensure stale flags aren't set in destroy_backend
After 60f733d17c, we can be sure stale
flags won't be seen in destroy_backend.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-11-29 00:14:02 +00:00
Yuxuan Shui
60f733d17c core: don't call map_win_start in handle_new_windows
Set WIN_FLAGS_MAPPED instead, it will be handled later. Previously, we
call map_win_start because we need the geometry of the window, which is
updated in map_win_start. Now, we get the geometry in fill_win, so
map_win_start is not needed anymore.

Eliminate a case where destroy_backend could see IMAGES_STALE flags set
on windows.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-11-28 22:49:18 +00:00
Yuxuan Shui
e49ef2ccd8 core: always clear stale flags in destroy_backend
Reference: https://github.com/yshui/picom/pull/546#discussion_r532054960

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-11-28 20:29:36 +00:00
Yuxuan Shui
1b4dacf2c2 win: add assertion ensuring flags of unmapped windows aren't processed
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-11-28 20:29:34 +00:00
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
nia
b14e85a6bc Cast argument to ctype functions to unsigned char
Per POSIX, "The c argument is an int, the value of which the application
shall ensure is a character representable as an unsigned char or equal
to the value of the macro EOF. If the argument has any other value, the
behavior is undefined."

https://pubs.opengroup.org/onlinepubs/009604499/functions/isspace.html

Signed-off-by: Nia Alarie <nia@NetBSD.org>
2020-11-19 12:19:35 +01: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