Commit Graph

1007 Commits

Author SHA1 Message Date
Yuxuan Shui d7415fcf2e
new backends: blur background before rendering shadow
Otherwise the blurred background will have a darker edge because the
shadow is blended in.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-29 21:19:06 +01:00
Yuxuan Shui 5da71e6bfd
core: add a TODO
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-27 17:08:47 +00:00
Yuxuan Shui 6ac50626ef
win: don't create shadow image when not requested
win_set_shadow tries to create shadow image even when shadow_new is false, this
is incorrect.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-27 00:02:44 +01:00
Yuxuan Shui a229f34eaa
new backend: fix background blur of window with opacity set
Only render blur with transparency when window is fading in/out.
Otherwise, a window with a set opacity will always have a completely
blurred background.

Fixes #198

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 23:43:28 +01:00
Yuxuan Shui 79fc36b3e3
win: don't change window OPACITY property
Don't override the OPACITY property set by the user on the window.

Fixes #134

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 22:29:42 +01:00
Yuxuan Shui 3434ea25f4
new xrender: fix nothing gets rendered without vsync
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 20:25:17 +01:00
Yuxuan Shui c7bb6b0fe3
Clarify some of the backend interface functions
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 18:32:39 +01:00
Yuxuan Shui e3b93a4f84
Additional blur artifact fix
There were still some artifacts left when multiple semi-transparent
windows are stacked on top of each other.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 18:28:22 +01:00
Yuxuan Shui 0109fe181e
gl_common: fix memory leak in _gl_fill
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 03:53:24 +01:00
Yuxuan Shui 4772103334
Remove some unused members of session_t
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 03:39:01 +01:00
Yuxuan Shui 357968c815
options: remove a spurious warning
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 02:44:42 +01:00
Yuxuan Shui d37a4136ee
new xrender: implement partial updates
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 02:31:45 +01:00
Yuxuan Shui 5a861d5d6a
gl_common, new glx: implement partial updates
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 02:22:05 +01:00
Yuxuan Shui 06dba4b196
backend: do partial updates
Although the functionality is not implemented by any backends yet.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 02:05:06 +01:00
Yuxuan Shui f86d6b7cbd
backend: update present interface for partial updates
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 02:05:00 +01:00
Yuxuan Shui bc3ca92e04
gl common: render into a texture
Instead of rendering into the back buffer, render into a intermediate
texture.

This is a preparation for partial screen updating, which is necessary to
eliminate artifacts visible when using blur and use-damage together.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 01:20:11 +01:00
Yuxuan Shui 3d84f3f92a
gl_common: fix type mismatch when calling glVertexAttribPointer
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-26 01:19:55 +01:00
Yuxuan Shui 8dae86a8cf
dbus: log resets
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 21:32:59 +01:00
Yuxuan Shui 159a45b9e9
core: root_image freeing shouldn't be in a loop 2019-07-25 21:25:43 +01:00
Yuxuan Shui 80d77b4ee8
core: don't reuse X connection across resets
In theory, it should be fine. But it causes mesa to stuck in
xcb_wait_for_special_event, indicating X connection setup issues.

Instead of investigating what went wrong in mesa, I choose to apply this
simple fix.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 21:15:47 +01:00
Yuxuan Shui f9703cdc04
dbus: fix resetting
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 21:01:40 +01:00
Yuxuan Shui 79b135dccc
Fix warnings when opengl is disabled
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 02:52:37 +01:00
Yuxuan Shui 72cedea5a3
config: fix warning when config_file is disabled
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 02:46:46 +01:00
Yuxuan Shui 9194506696
core: destroy debug window in session_destroy
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 02:38:03 +01:00
Yuxuan Shui 5094400ab7
core: don't deinit tls logger in session_destroy
tls logger is initialized by main(), so only main() could deinit it.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 02:37:43 +01:00
Yuxuan Shui bb756b2238
Fix compiler warning about unused parameters
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 02:27:02 +01:00
Yuxuan Shui 62878d7c57
gl_common: use a dummy pass to unify blur code paths
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 00:36:42 +01:00
Yuxuan Shui 4c9ded837f
new backend: add interface for query blur size
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-24 23:27:51 +01:00
Tasos Sahanidis 93642e537f
Add --no-ewmh-fullscreen
This arg reverts to the old behaviour of checking for fullscreen
windows.
2019-07-19 14:13:41 +03:00
Tasos Sahanidis 10d5c9b2f9
Use XCB to check if an application is fullscreen 2019-07-19 14:11:15 +03:00
Yuxuan Shui ad30b4f826
gl_common: use texelFetch
This relieves us from the need to normalize texture coordinates.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-14 16:21:22 +01:00
Yuxuan Shui 8a794e0ce1
Improve the compatibility of gl_has_extension
Fix infinite loop when running under RenderDoc

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-13 19:30:26 +01:00
Yuxuan Shui 372f4f816e
new backend: ignore window tranparency info from the backend
Doing this forces compton to blur every windows' background.

However, doing this can be beneficial, we will figure out a way
to do this properly in the future.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-13 12:44:41 +01:00
Yuxuan Shui 426043baa7
Improve transparency detection for blur
Previously, only the WM windows (window manager usually reparents the
application windows under its own window so it can manage them) are
checked for alpha channels. Some of the window managers (e.g. awesome)
acquire alpha channels for all of the WM windows, whether the underlying
application windows have alpha channel or not.

With this change, the application windows are also checked for alpha
channels. If a WM window has alpha but its child doesn't, only the WM
frame will be considered to be semi-transparent. Thus preventing some
unnecessary blurring.

Closes #191

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-13 12:37:28 +01:00
Yuxuan Shui 7d28309a47
Stop debug mode from being used without the new backends
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-07 19:55:34 +01:00
Yuxuan Shui 722b01ca6a
Fix creation of X convolution kernel
During normalization of the kernel, the center element is added to the
sum twice, causing the resulting elements to be smaller than they should
be.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-07 19:51:42 +01:00
Yuxuan Shui 4c460a7bd5
new xrender: fix black border around blurred area
Similar fix to 6d646b54.

Also ping #50

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-07 19:49:23 +01:00
Yuxuan Shui e62971a0c3
gl common: fix memory leak
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-07 19:09:15 +01:00
Yuxuan Shui 182a207afd
new xrender: fix offset when using multi-pass blur
Also makes the code a bit more readable by replacing stateful variables.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-07 18:55:20 +01:00
Yuxuan Shui 6d646b543f
new glx: fix black border around blurred areas
This is done by extending the blur area internally when process
blurring.

Ping: #50, cause this fixes that problem but only when using the
experiemental backends.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-07 18:39:46 +01:00
Yuxuan Shui 4a0092c808
Don't register as compositor manager in debug mode
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-07 17:25:26 +01:00
Yuxuan Shui d31e9dae20
Don't render the debug window
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-07 16:20:08 +01:00
Yuxuan Shui 0b0d896ffe
Add debug mode
When enabled, the result will be redirected to a window, and compton
won't take over the screen.

Makes debugging easier.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-07 16:20:00 +01:00
Yuxuan Shui 640b4b1c99
Move resize_region to region.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-06 13:26:25 +01:00
Yuxuan Shui a52f95acd7
gl_common: fix misunderstanding of VAO
GL_ARRAY_BUFFER is not part of VAO state.

This shouldn't affect compton's behaviour at all, though.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-24 01:51:50 +01:00
Yuxuan Shui 85abdef765
gl_common: use explicit vertex attrib loction
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-24 01:34:12 +01:00
Yuxuan Shui 5a034ea169
Fix root change handling when screen is unredirected
If screen is not redirected, we don't need to reinitialize the backend
when we got a root change event.

Fixes #189

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-15 23:04:49 +01:00
Yuxuan Shui 863e2c82ec
new backends: don't destroy blur context when there's none
Fixes #190

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-13 08:14:14 +01:00
Yuxuan Shui 67f0ec773a
new backends: blur interface update
To prepare for different blur methods, the blur interface of backends
has been splitted into two parts.

Now to use blur, a blur context must be created first; then, the blur
method should be called with the blur context created.

Updated the existing backends to the new interface. Also implemented
handling of the new blur options.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-09 19:26:41 +01:00
Yuxuan Shui 1eba43f888
Rename blur kernel parameter types
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-09 12:57:23 +01:00
Yuxuan Shui c1b2ce1fce
Update generate_blur_kernel to use abstract parameter type
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-09 12:44:32 +01:00
Yuxuan Shui e16e592302
Move enum blur_method to backend.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-09 12:43:51 +01:00
Yuxuan Shui 8e0b467138
Warn when using new blur methods on old backends
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-09 01:09:54 +01:00
Yuxuan Shui 1da726047a
new backend: don't assume center of blur kernel is 1
Also fill the center of parsed kernel with 1. This shouldn't change the
behavior of the old backends since they will modify the center of the
kernels.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-09 01:03:37 +01:00
Yuxuan Shui f64ac97a91
Return kernel count from kernel generation functions
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-09 00:45:06 +01:00
Yuxuan Shui 2239181551
Properly implement gaussian blur kernel
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-08 23:56:47 +01:00
Yuxuan Shui fa8faaf91d
Remember the number of blur kernels
Don't count the number of blur kernels everytime.

Fixes #188

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-07 22:21:06 +01:00
Yuxuan Shui abb089e605
Lift the MAX_BLUR_PASS limit
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-07 07:04:50 +01:00
Yuxuan Shui cbb859ba3c
Fix non-OpenGL build
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-06 07:40:32 +01:00
Yuxuan Shui a18e8fcdf0
Destroy glx context created for vsync
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-06 07:33:07 +01:00
Yuxuan Shui 5e8d6bdc2d
Don't destroy glx if it's not initialized
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-06 07:27:30 +01:00
Yuxuan Shui b947a45d71
backend_common: add blur kernel generation functions
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-06 06:56:21 +01:00
Yuxuan Shui 82b9822fd0
config: introduce new syntax for blur options.
Parsing only, not used yet.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-01 00:39:00 +01:00
Yuxuan Shui 4a74b4f199
Move default values of options to config.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-27 23:00:12 +01:00
Yuxuan Shui c0053d1c8a
core: delay focus updates
Delay focus updates until critical section. Rational is that focus
events might arrive when the focused window hasn't been managed by
compton, result in that that window not being focused.

This commit makes compton mark focus update events, and only update
focus in critical section, after we managed all the new windows.

Fixes #177

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-25 00:06:41 +01:00
Yuxuan Shui 7d8a3e09be
core: just enable track_focuse
It's not an intensive task.

Simplifies logic.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-25 00:02:25 +01:00
Yuxuan Shui 57f4a99940
win: fix focuse tracking
Call win_on_focus_change on previous focused window too.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-24 23:34:33 +01:00
Yuxuan Shui a2dab52334
win: remove win_unset_focus
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-24 23:32:12 +01:00
Yuxuan Shui 98d351ecf6
win: break win_set_focused into 2 functions
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-24 23:15:19 +01:00
Yuxuan Shui 51476cafa4
dbus: simplify getting focused window
Remove find_focused

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-24 22:53:16 +01:00
Yuxuan Shui 20e60a87fa
recheck_focus doesn't need to return anything
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-24 22:40:36 +01:00
Yuxuan Shui 9c50bc58cb
core: don't refresh image when not using experimental backends
Fixes #176

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-24 00:12:42 +01:00
Yuxuan Shui 44bea480b2
Fix build on gcc < 8
Fixes #175

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-24 00:07:01 +01:00
Yuxuan Shui 094f00a048
Refresh stale image in critical section
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-22 22:38:22 +01:00
Yuxuan Shui b5da914920
Mark xcb_generate_id deprecated in compton
x_new_id is preferred since it checks for error.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 23:23:42 +01:00
Yuxuan Shui b9a3b67f9c
new backend: xrender: fix INVER_COLOR_ALL
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 22:15:38 +01:00
Yuxuan Shui 294aae11ff
Fix xrender APPLY_ALPHA
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:22:20 +01:00
Yuxuan Shui 488db11f14
make sure backend_data is not null
... before assigning to backend_data->ops in initialize_backend()

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:35 +01:00
Yuxuan Shui 3cabba6161
gl_common: don't use GL4 feature
glGetIntegerv(GL_NUM_EXTENSIONS) is only available since GL4.

(However glGetStringi(GL_EXTENSIONS) is available since GL3)

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:35 +01:00
Yuxuan Shui 2d50d32bf7
new backend: glx: multiply color in APPLY_ALPHA
Because we use pre-multiplied alpha.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:35 +01:00
Yuxuan Shui 80c7b2f7ec
new backend: glx: implement IMAGE_OP_APPLY_ALPHA
Slight change to the backend_operations::fill interface.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:35 +01:00
Yuxuan Shui 18b1fc95ff
new backend: glx: reduce code duplication
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:35 +01:00
Yuxuan Shui 45ead409b5
new backend: glx: fix off-by-1 in blur shader generation
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:35 +01:00
Yuxuan Shui 86f4d73c22
new backend: gl_common: add support for decoupling lazy copied images
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:35 +01:00
Yuxuan Shui b91888b0a3
new backend: glx: trivial refactoring
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:34 +01:00
Yuxuan Shui e894105e7b
atom: fix memory leak
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:34 +01:00
Yuxuan Shui 7ed9f2884f
Fix build 2019-05-21 20:15:34 +01:00
Yuxuan Shui 18a62537ec
Add missing header file 2019-05-21 20:15:34 +01:00
Yuxuan Shui cdb24ec99c
common.h: cleanup, cont.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:34 +01:00
Yuxuan Shui 16ea51bbc1
common.h: more clean up
Remove more unused stuff.

Also removed session::xinerama_scrs, since all the information we need
is covered by xinerama_scr_regs. Convert uses of xinerama_scrs to use
xinerama_scr_regs.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:34 +01:00
Yuxuan Shui a409913c5f
common.h: remove cxfree
Apparently XFree does take NULL.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:34 +01:00
Yuxuan Shui 939f2fb602
common.h: general clean up
Remove unused functions and definitions. Move some macros into the files
they belong.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:34 +01:00
Yuxuan Shui e330464126
core: acquire X compositor selection first
Don't do anything with the overlay window with out the compositor
selection.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:33 +01:00
Yuxuan Shui c6a4928a45
atom: cache result of get_atom
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:33 +01:00
Yuxuan Shui 76c484885d
cache: cache_get can now return error
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:33 +01:00
Yuxuan Shui 93e4a53d48
cache: fix memory leak, add missing function
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:33 +01:00
Yuxuan Shui c08fd08ea4
Add a general key-value caching framework
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:33 +01:00
Yuxuan Shui be673f93c6
backend: add interfaces for readiness reporting
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:33 +01:00
Yuxuan Shui f50428a18b
core: reuse handle_new_window for pre-existing windows
Reduce code duplication, also handle_new_window handles damage of mapped
windows properly.

Fixes #160

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:33 +01:00
Yuxuan Shui 1b00eeaf60
core: mark pre-existing window as damaged
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:33 +01:00
Yuxuan Shui a40fdb86e1
core: unmap overlay window when we first acquire it
It used to be unmap when we receive its MapNotify, but now since we discard
events received before we grab X server, that event it lost. But it
turns out we can just unmap it when it's first created, no need to wait
for the MapNotify.

Partially fix #160

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:32 +01:00
Yuxuan Shui ad8211e341
event: handle reparent to the same parent
When a window is reparented to the same parent again, we should just
move it to the top of the stack, instead of add it again.

Also a slight refactor restack_win.

Fixes #164

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:32 +01:00
Yuxuan Shui cfbd1819ed
core: only grab X server when there indeed is new windows
Shouldn't grab X server for nothing.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:32 +01:00
Yuxuan Shui 46b8eb8d4d
core: handle configure notify of unmanaged window
Important for window stacking.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:32 +01:00
Yuxuan Shui 9ed1b985c5
core: don't try rebinding the window image when unredirected
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:32 +01:00
Yuxuan Shui efe63f5380
fix nogl build
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:32 +01:00
Yuxuan Shui 468fb637b6
new backends: xrender: fix memory leak
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:32 +01:00
Yuxuan Shui f93f697759
Remove several unnecessary experimental_backends check
Window flags can be set whichever backend we use, we will ignore then in
paint_preprocess. free_paint can be called whichever backend we use,
they just do nothing if we use experimental backends.

Others should rather just check if backend_data is NULL.

Making the code slightly more understandable, also making the eventual
removal of these checks easier.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:31 +01:00
Yuxuan Shui 8e5210cb9c
new backend: glx: use glFinish instead of glXWaitGL
The API document claims they achieve the same thing, apparently not.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:31 +01:00
Yuxuan Shui c55088944a
new backend: glx: use glFinish/glXWaitGL if not on NVIDIA
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:31 +01:00
Yuxuan Shui b35bfd07d1
backend: driver: fix string out-of-bound read
libxcb doesn't null terminate strings.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:31 +01:00
Yuxuan Shui 197e9dc866
auto enable sync fence for NVIDIA driver users
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:31 +01:00
Yuxuan Shui 685a583f84
backend: add preliminary support for driver detection
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:31 +01:00
Yuxuan Shui a2d0d5c826
xrender: move into its own folder
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:31 +01:00
Yuxuan Shui 5069193893
core: mark newly created window as damaged
Damage could have already happened at the time we call fill_win on a new
window. It's too difficult, or impossible, for us the find out if that
happened. So just blindly mark window as damaged.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:31 +01:00
Yuxuan Shui d4fde6a392
core: wait for the result xcb_grab_server before doing anything
Make sure X grab server is finished before calling x_discard_events in
session_init. Otherwise x_discard_events won't be able to discard all of
the events that were sent before we grab the server.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:30 +01:00
Yuxuan Shui 3d2217a112
event: promote several logs to log level debug 2019-05-21 20:15:30 +01:00
Yuxuan Shui 0753eaacf8
Map newly created window in handle_new_window
A window might be mapped before we had the chance to start managing it.
So check to see if we should map a window after we call fill_win on it.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:30 +01:00
Yuxuan Shui 58944f36ce
Delay window managing
Create a "critical section" in draw_callback by grabbing the X server.
Delay the managing of newly created windows until we enter the cricial section.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:30 +01:00
Yuxuan Shui 927cdd8652
win: handle destruction of unmanaged window
Previous destructions of unmanaged window are silently ignored, causing
windows with duplicated IDs.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:30 +01:00
Yuxuan Shui 883d8c9142
x: add x_discard_events
Also, during session_init, discard old events after we grab the server.
If we don't do that, old, out dated CreateNotify will cause us to add
the window with the same id multiple times. Here is an explanation of
how that could happen:

1. compton connects to X
2. a new window created by someone else, X send us a CreateNotify
3. compton is initializing, so it didn't handle the event.
4. compton pulls a list of all windows from X. This will include that
   window created in (2)
5. compton starts to handle event. it will handle the CreateNotify sent
   in (2), thus adds the same window twice.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:30 +01:00
Yuxuan Shui 0c992b11d3
win: add assert to catch duplicated windows
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:30 +01:00
Yuxuan Shui 452e313c64
kernel: tweak gaussian deviation
So that the shadow doesn't look cut off or fuzzy.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:30 +01:00
Yuxuan Shui eb2b0a6fa1
win: fix add_win_top
Instead of reusing add_win_above with the id of the window on the top
of the stack, we create a new function that takes a list_node.

Fix a problem when the window on the top of the stack is destroyed. Because
add_win_above search for windows from the hash table, it won't find that window
and returns NULL.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:29 +01:00
Yuxuan Shui dfd9ecf5c9
core: fix use-after-free in session_init
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:29 +01:00
Yuxuan Shui a96cdc7e15
win: fix an invalid cast from struct win to managed_win
Should always check if win::managed is true first.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:29 +01:00
Yuxuan Shui bd4c242015
win: split struct win
Currently compton handles window creation event by immediately query all
the information it needs and create a window struct with that
information. However, this is prone to race conditions.

In the future, we want to react to window creation event by creating a
placeholder in the window stack, and only query window information in a
critical section where the X server is grabbed by us.

This commit split struct win into two struct, one as placeholder, the
other for holding actual window information.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:29 +01:00
Yuxuan Shui 27603343a1
list: add list_replace
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:29 +01:00
Yuxuan Shui aee496aeff
build: look for libev via pkgconfig
FreeBSD has pkg-config files for libev

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:29 +01:00
Yuxuan Shui 41fd229230
build: check if std-predef.h exists
Fix build on FreeBSD / non-glibc systems

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:28 +01:00
Yuxuan Shui 85dba1f3c9
core: don't paint window with image errors
Previously we do window image update _after_ the to_paint checks.
Therefore the window image might failed to update after we decided to
paint it.

Do window image update before the checks.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:28 +01:00
Yuxuan Shui a6decc3a0f
list.h: remove restrict qualifier 2019-05-21 20:15:28 +01:00
Yuxuan Shui 4afc853d4f
Advertise ourselves as compton to X
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:28 +01:00
Yuxuan Shui abeeb36bb2
x: wrap xcb_generate_id to check for errors
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:28 +01:00
Yuxuan Shui 8cfa750a6d
config: fix grammar 2019-05-21 20:15:28 +01:00
Yuxuan Shui c54b2c0277
win: add new type window_stack_entry 2019-05-21 20:15:28 +01:00
Yuxuan Shui 5077d56676
Refactor linked-list operations into a header
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:28 +01:00
Yuxuan Shui b9f894c4fc
win: handle restack to bottom correctly
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:27 +01:00
Yuxuan Shui 166ec55778
win: keep a `prev` pointer
Save us some iteration when updating the window stack

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:27 +01:00
Yuxuan Shui a68903b9ef
win: track windows with a hash table
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:27 +01:00
Yuxuan Shui 3935e97e69
gl_common: bump GL to 3.30
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:27 +01:00
Yuxuan Shui 6e8a86d415
gl_common: use vao
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:27 +01:00
Yuxuan Shui ffc9c32b5e
gl_common: update gl_compose to core profile
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:27 +01:00
Yuxuan Shui f08004a448
gl_common: update gl_blur to core profile
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:27 +01:00
Yuxuan Shui 599e8b6600
gl_common: update gl_fill to core profile
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:27 +01:00
Yuxuan Shui 233edbd1c3
gl_common: fix implicit conversion warnings
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:26 +01:00
Yuxuan Shui 7c2edd9d63
gl_common: remove some fixed function glEnable/Disable
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:26 +01:00
Yuxuan Shui d64aab7d40
gl_common: add vertex shader
Also use an attribute for the texture coordinates.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:26 +01:00
Yuxuan Shui 18f6a20bf4
new backend: fix crash when window's shadow state change
Create a shadow image for a mapped window when it's shadow become enabled.
For unmapped window, the shadow image is created during mapping. Also,
if the window has IMAGE_ERROR flag, it won't be render anyway. So shadow
image won't be created in that case either.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:26 +01:00
Yuxuan Shui eeb8712982
Add debug prints to win_determine_shadow
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:26 +01:00
Yuxuan Shui 2040190fb6
utils: improve CHECK() macro
Include the original expression in the assertion failure message.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:26 +01:00
Yuxuan Shui 0733f7540f
Silence unused variable warning in release build
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:26 +01:00
Yuxuan Shui 63dd16ebac
Use int in margin_t
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00
Yuxuan Shui 9677750e3d
Improve checked cast macros
to_{int,char,i16}_checked now works with unsigned types (except
uint64_t).

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00
Yuxuan Shui 0037b7e5fb
Eliminate implicit conversions
Use explicit conversions everywhere. Adding bounds check assertions when
necessary.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00
Yuxuan Shui 532a90d573
Use __builtin_isnan
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00
Yuxuan Shui df2a33e8a8
core: fix a case where closed window is left on screen
If a window is unmapped, then mapped to a different position on screen
before fade out is completed (when fading is not enabled, it has to be
mapped again in the same frame), the old window content is left on screen.

This is because when this happens, we didn't add the unmapping window to
damage.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00
Yuxuan Shui 49e85f6161
core: opacity_old should be double
Using opacity_t for opacity_old resulting in opacity being rounded to 0.
This is fine until the opacity reaches 0, where the opacity != opacity_old
check fails and the damage is not added.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:24 +01:00
Yuxuan Shui a93754009c
Dump damage region info in trace log
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:24 +01:00
Yuxuan Shui 1f80e547bc
core: remove unnecessary win_check_fade_finished
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:24 +01:00
Yuxuan Shui 6344ae2a46
Format region.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:24 +01:00
Yuxuan Shui 8155e5e453
core: fix missing damage when window closed
If window is closed when fading is not enabled, the window might be destroyed
before we can add the window extent to damage.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:24 +01:00
Yuxuan Shui ad3ec8cada
gl_common: initialize string marker logger
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:24 +01:00
Yuxuan Shui 51ad94f745
win: remove unnecessary assertion
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:24 +01:00
Yuxuan Shui d3a2c94461
win: invalidate reg_ignore properly when destroying window
reg_ignore_valid marks the validity of the reg_ignore of the windows
BENEATH the current window. That is, set `w->reg_ignore_valid = false`
doesn't invalidate `w->reg_ignore`.

When destroying window `w`, we need to invalidate all reg_ignore beneath
`w`. So it is not enough to just set `w->next->reg_ignore_valid =
false`, we also need to invalidate `w->next->reg_ignore`.

Yes, this variable name is confusing. Will be changed in the future.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:23 +01:00
Yuxuan Shui df15526722
options: print warning for --vsync-aggressive
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:23 +01:00
Yuxuan Shui b5b9419ecc
core: don't rebind root image when unredirected
When the screen is not redirected, don't update the root image because
the backend is not initialized in this case.

Fixes a crash.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:23 +01:00
Yuxuan Shui f501d35ba9
core: re-run paint_preprocess after redirecting
paint_preprocess calls redir_start if it decides to redirect the screen.
redir_start might change the state of the windows. For example, when the
image of the window fails to bind, redir_start sets the error flag. And
those state changes might exclude the window from being rendered. Thus,
paint_preprocess should be re-run to make sure the new states are
honoured.

Fixes a crash when window images fail to bind after redirecting.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:23 +01:00
Yuxuan Shui edbf7f430c
Initialize tls log structure in main
Fix error reporting when failed to open X display.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:22 +01:00
Yuxuan Shui aa37c4f4ca
Add some unittests
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:22 +01:00
Yuxuan Shui 061f9aea9d
win: clear window flag _after_ release_image
release_image has assertions on the flags, clear the flags before
calling it causes assertion failure.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:23 +00:00
Yuxuan Shui 7c1876c787
core: don't use stale window images
Previously, when the backend doesn't implement root_change(), we will
deinit, and then init the backend again. However, we didn't free all the
images previously returned by the backend. There is no guarantee that
these images will be valid across deinit/init.

So, make sure they are freed.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:23 +00:00
Yuxuan Shui e8f2298159
event: lazify screen update
Set root screen change flag in event handler, and update in
draw_callback.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:23 +00:00
Yuxuan Shui e414fee91f
event: use log levels, not ifdefs
And some general clean up.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:23 +00:00
Yuxuan Shui 17c96eb9ba
core: general clean up
Also move some remaing event functions to event.c

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:22 +00:00
Yuxuan Shui 472185e885
core: split out event code
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:22 +00:00
Yuxuan Shui 1b955cabc5
win: add comment mentioning the NVIDIA bug
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:22 +00:00
Yuxuan Shui aa742146f1
win: put window into UNMAPPED state before mapping
Make sure before the mapping operation begins, the window is always in
UNUNMAPPED state. This makes it easier to reason about things, such as
resource availability, etc.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:22 +00:00
Yuxuan Shui fed6ac5b09
win: release window image before rebind
Previously we try to keep the image data until the rebind succeeds. This
way even if the rebind fails, we still have something to display.

But that triggers a NVIDIA driver bug. Basically you cannot have more
than one names (XIDs) of a window pixmap. NVIDIA driver doesn't like
that, and binding the pixmap with its aliases will fail. This can
sometimes happen if we name the new pixmap before freeing the old one during
rebind, and the pixmap doesn't actually change (i.e. the rebind is
unnecessary, could happen because of X event handling complications).

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:22 +00:00
Yuxuan Shui 9bb2fa44d4
core: ignore window with IMAGE_ERRORs
window with IMAGE_ERROR might not have an image data attached, so ignore
them during paint.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:22 +00:00
Yuxuan Shui b32ae5a32c
win: free window resource
It's fine to call free_win_res in the new backends too.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:22 +00:00
Yuxuan Shui 838a214749
Add several debug prints
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:22 +00:00
Yuxuan Shui 312643c454
win: clear STALE_IMAGE flag in map_win
Clear the STALE_IMAGE flag set by win_update_bounding_shape to avoid an
unnecessary image data invalidation.

Mainly to workaround a NVIDIA bug. For more detailed explanation, see
commit 8f67c6190c281955846589d8769385f30e7c5d23

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:21 +00:00
Yuxuan Shui b10f0bbc67
win: always refresh window size in map_win
Instead queue up configure notification while the window is unmapped,
just update the window geometry when the window is mapped.

Simplify the logic a little bit.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:21 +00:00
Yuxuan Shui 8dc250a415
win: update window's image lazily
Use a flag to mark whether the image needs update, and only update once
per frame.

Also refactor some common code into functions, and handle image errors
properly.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-23 14:35:21 +00:00
Yuxuan Shui 0a32c81d9c
backend interface: improve documentation 2019-03-16 20:57:43 +00:00
Yuxuan Shui 5940a959dc
new backend: handle --use-damage
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-16 12:12:54 +00:00
Yuxuan Shui dd240d0576
Deprecate --glx-swap-method
Setting glx-swap-method to value other than "undefined" and "buffer-age"
could potentially cause rendering problems. So remove them, the meaning
of the remaining options can be more precisely captured by "use-damage",
so create a new option under that name.

--glx-swap-method is deprecated in favor of the new option --use-damage.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-12 00:35:47 +00:00
Yuxuan Shui 17d1281594
Remove options deprecated in v3
Specifically, use --glx-copy-from-front and --glx-use-copysubbuffermesa
are now hard errors.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-11 23:56:58 +00:00
Yuxuan Shui d39d937566
new glx: fix memory leak, and bind pixmap
struct _glx_image_data needs to be freed even when refcount is not 0.

Also fixed a typo in glx_bind_pixmap.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 22:48:42 +00:00
Yuxuan Shui cabd0b0801
new glx: always use GL_TEXTURE_2D
Rectangle textures was used as a fallback when the driver doesn't
support non-power-of-two (NPOT) textures. Since we are using OpenGL 3.0 now,
which includes support for NPOT textures, we don't need this fallback
anymore.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 20:42:52 +00:00
Yuxuan Shui e1c5e7ab8d
gl_common: fix gl error when blur is not enabled
blur_textures are not initialized when blur is disabled, but we still
try to resize them in gl_resize.

Don't do that.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 20:04:11 +00:00
Yuxuan Shui e40f16c60e
new glx: fix leak of X pixmaps
release_image should release the X pixmap when it's owned by the
backend.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 20:00:56 +00:00
Yuxuan Shui 9296706f7b
backend: fix rendering shadow with opacity
Shadow opacity should be multiplied with the window's opacity.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 19:56:55 +00:00
Yuxuan Shui 0bd08f4ab4
Don't call glx_on_root_change when using new backends
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 16:34:07 +00:00
Yuxuan Shui cebe1b18d6
vsync: choose vsync method automatically
Choose the best vsync method for the user, instead of asking them to
frustratingly try every one of the options to see what works.

With this commit, the `vsync` option will take only a boolean value.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 15:00:56 +00:00
Yuxuan Shui e7de44260b
Deprecate --vsync-aggressive
Original developer's word in man page: "Reported to work pretty terribly".

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 13:59:22 +00:00
Yuxuan Shui 22da17630f
Run clang-format
Now we have a consistent style across the codebase.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 12:35:38 +00:00
Yuxuan Shui 472fe6c6bd
options: remove mentions of some deprecated options
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 03:04:43 +00:00
Yuxuan Shui 5f22b4b31c
new glx: implement dim
Also removed a bunch of unused functions and macros. Fixed a memory leak
of gl_texture::refcount.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 02:25:41 +00:00
Yuxuan Shui a72fb0c755
new glx: handle blur with opacity
Now blur can fade out smoothly

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 02:04:14 +00:00
Yuxuan Shui 34254ff86e
new glx: implement fill for monitor-repaint
Refine the API of fill_rectangle and rename it to fill.

Extras:

Keep GL_BLEND enabled; Fixed some texture/fbo leaks

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 01:53:46 +00:00
Yuxuan Shui 48338a9903
new glx: implement blur
This is barely tested, so bugs and/or performance problems to be
expected.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 01:22:38 +00:00
Yuxuan Shui 710ff2fd42
Deprecate --glx-use-gpushader4
Original develop commented in the man page: My tests ... show no noticeable
effect.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-09 18:29:01 +00:00
Yuxuan Shui c5d9f459dd
backend interface: add IMAGE_OP_RESIZE_TILE
We need this to paint the wallpaper with repeat to mimic the behavior of Xorg's
background pixmap.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-09 18:01:18 +00:00
Yuxuan Shui fb155c9769
new glx: create a OpenGL 3.0 context
Older version of OpenGL won't be supported by the new glx backend.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-09 16:13:27 +00:00
Yuxuan Shui c67eb62ce8
gl_common: texture should repeat
To match xrender's behavior.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-09 15:08:21 +00:00
Yuxuan Shui 0a2dd8aa72
gl_common: implement image_op
Implement image processing in gl_compose using a frag shader.
gl_image_op is used to set flags corresponds to what processing is
needed for a texture.

Also implement proper reference counting for textures.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-09 14:12:53 +00:00
Yuxuan Shui 6ff0facae6
backend: invert color and dim doesn't need reg_op
We only ever invert color of or dim the entire image, so just remove the
ability to do region based inversion and dimming. Making implementing
image_op easier.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-09 13:38:50 +00:00
Yuxuan Shui 60c10790d7
new glx: initial implementation
This is basically just adapting old code to the new interface. A lot
of the functions are still stubs, but the basic stuffs is working.

What remains to be done:

* Implement gl_image_op. (It should do the operation lazily, only update
the flags on the texture. Actual processing will be delayed until composition.)

* Implement gl_copy. Now it just return the same image after incrementing the
refcount. It should actually copy the image data structure so it can have a
separate set of flags.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-09 01:39:18 +00:00
Yuxuan Shui 5d321c85f5
Don't release window resource when unredirected
Because when the screen is unredirected, the window resource would have
already been freed. Fix a NULL pointer deref.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-09 01:35:52 +00:00
Yuxuan Shui 684d95988d
Fix one un-guarded use of backend_data
Fixes #127

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-07 23:54:13 +00:00
Yuxuan Shui f2aeb848ec
Put the whole vtable in backend_list
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-07 21:08:51 +00:00
Yuxuan Shui 7e3976947b
Fix crash when using monitor-repaint
If monitor-repaint is not implemented by the backend, compton will
crash. This commit fix the crash by not doing monitor-repaint in that
case.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-05 22:37:53 +00:00
Yuxuan Shui d0fd21e167
Drop support for Composite < 0.2
Rational: current workaround for Composite < 0.2 doesn't work with the
GLX backend, it also doesn't handle window border properly. Plus,
Composite 0.2 came out more than a decade ago, it's safe to assume
everyone has it.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-05 22:14:23 +00:00
Yuxuan Shui eed5ea719e
Implement monitor repaint in new xrender
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-05 20:27:10 +00:00
Yuxuan Shui c387a266dc
backend interface: prepare is optional
Also remove xrender's prepare since it overwrite part of the screen
outside the damage region, causing rendering problems.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-05 20:27:10 +00:00
Yuxuan Shui de30ef14ae
backend: move the head of the damage ring after paint
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-05 20:27:10 +00:00
Yuxuan Shui c57f267535
backend interface: Add visible hint
Pass the visible region of the image to the backend, so the backend
could optimize based on that information.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-04 23:02:58 +00:00
Yuxuan Shui a2ae36c1d6
backend_common: fix shadow generation with opacity
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-04 23:02:35 +00:00
Yuxuan Shui 3ab4107fda
Fix NULL pointer deref in configure_root
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-04 22:53:49 +00:00
Yuxuan Shui 7b664de74e
win: Remove win::pixmap
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-04 00:09:05 +00:00
Yuxuan Shui 3707f792fb
new_backend: New interface
Move more logic out of the backend. The backends are now more agnostic
to what happens in compton.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-03 22:18:34 +00:00
Yuxuan Shui 11c8655206
Fix build
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-27 06:33:30 +00:00
Yuxuan Shui 26214f312f
x: create_picture_with_{visual, pictfmt} don't need session_t
Take xcb_connection_t and xcb_drawable_t instead.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-27 00:30:27 +00:00
Yuxuan Shui 0ceee9aad1
solid_picture and build_shadow shouldn't take session_t
Pass xcb_connection_t and xcb_drawable_t instead, which is what these
functions need.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-26 23:21:11 +00:00
Yuxuan Shui 7e7c54761e
Remove an undocumented option
Removed --glx-reinit-on-root-change.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-25 21:18:48 +00:00
Yuxuan Shui 2699367b46
Handle xcb_wait_for_special_events failure
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-25 01:43:01 +00:00
Yuxuan Shui 29ceea8412
Implement buffer_age() for the new xrender backend
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-25 01:16:57 +00:00
Yuxuan Shui 244c23140d
Remove the ability to change vsync method via dbus
Supporting this will complicate the new backends.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-25 00:48:51 +00:00
Yuxuan Shui b76ff9fe5b
Add a TODO comment
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-25 00:29:05 +00:00
Yuxuan Shui 59ca5c9628
Remove one undocumented option
Removed --reredir-on-root-change

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-25 00:26:54 +00:00
Yuxuan Shui f16d00a6a2
Split configure_win into two
One for configuring root, one for regular windows.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-25 00:25:45 +00:00
Yuxuan Shui 7a446ca1f4
Slightly better error handling
Handle backend initialization failure.

Also actually disable vsync when it's not supported in the new xrender
backend.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-25 00:22:10 +00:00
Yuxuan Shui 72a977eed5
Allow double buffering in the new xrender backend
If PresentPixmap choose to use the Flip mode, we cannot reuse the same
buffer for rendering for the next frame. Add double buffering for that
case.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-24 23:53:46 +00:00
Yuxuan Shui 28cf35e43b
Wait for PresentCompleteNotify
Don't use idle fence. There is no reliable & portable way to obtain a
fence Present will like. Intel driver wants a DRI3 fence, NVIDIA driver
doesn't support DRI3, and wants a XSync fence (I am not even sure, since
Present doesn't really work with the NVIDIA driver. And using the fence
on NVIDIA driver causes compton to use 100% CPU).

Just don't bother.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-24 23:29:48 +00:00
Yuxuan Shui e986ebceda
Allow win_on_win_size_change to be called on UNMAPPED windows
This can happen when the window has just been created

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-23 00:25:10 +00:00
Yuxuan Shui b92182416c
Don't stop fading for window size change
Window size change cause window resource to be released and re-acquired,
so it cannot work on unmapped windows.

Previously we make sure of that by skipping fading and change if the
window is mapped. Now we just make sure that functino is never called
with an unmapped window.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-23 00:18:12 +00:00
Yuxuan Shui 1005e61553
Delay reconfiguration of unmapped windows
If a window is being faded out because of unmapping, don't handle its
configuration notify. Avoid freeing pixmap of a window that is being
faded out, because that will cause paint to fail.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-23 00:14:26 +00:00
Yuxuan Shui 8d639f41e9
Make sure only MAPPED state can transition to FADING
win_update_focused transition window into FADING without checking their
current state, resulting into unmapping windows being brought into
FADING state and stops unmapping.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-23 00:11:29 +00:00
Yuxuan Shui 9cce1efe3f
Call glxext_init from glx_init
Make sure we query the extensions.

Also don't start glx string marker logger for new backends yet.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 23:25:31 +00:00
Yuxuan Shui 23ee4c6cbe
Add missing check for experimental_backends
Fixes #121

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 22:32:49 +00:00
Yuxuan Shui f120f9b754
Make sure map_win initialize win::win_data
Previously it is initialized by win_update_bounding_shape, so
configure_win is called when win_data == NULL and state ==
WSTATE_MAPPING, which is an invalid state for a `win` to be in.

Now map_win explicitly calls backend->prepare_win. This is not very
efficient since win_update_bounding_shape will reinit it.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 14:53:41 +00:00
Yuxuan Shui e82bc0ca23
Silence a warning in release build
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 14:15:25 +00:00
Yuxuan Shui 350933a054
Cleanups
* Make some functions in win.c pure
* Remove unused code
* Fix misuse of attr_const, const functions shouldn't exam data pointed
  to by its pointer arguments.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 14:08:08 +00:00
Yuxuan Shui 69826a0844
Add some TODOs
reg_ignore is a bit complicated.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 04:11:58 +00:00
Yuxuan Shui d145808e69
Fix new backend related crash
Use of invalid backend_info_t.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 03:51:26 +00:00
Yuxuan Shui a7f373dec3
Starting the deprecation process for --sw-opti
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 03:42:03 +00:00
Yuxuan Shui 6909597ee3
Use monotonic clock for time
Remove handling of the so-called "time disorders".

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 03:36:51 +00:00
Yuxuan Shui 934c269f9b
Update win::reg_ignore_valid when destroying window
When destroying a window, set window->next->reg_ignore_valid to false,
since its reg_ignore is not valid anymore.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 03:00:27 +00:00