Commit Graph

652 Commits

Author SHA1 Message Date
Yuxuan Shui 3686bf7a33
Use functions in backend/backend_common.c
Build backend_common.c even when new_backend=false.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-01 11:01:47 +00:00
Yuxuan Shui 4aeffa36b8
Refactor shadow generation
Trying to make the code easier to understand. The logic is unchanged.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-01 10:54:21 +00:00
Yuxuan Shui edb1139507
Add some comments to backend.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 23:30:45 +00:00
Yuxuan Shui 86713c8170
Add make_shadow and paint_all_new to backend_common.c
Also made make_shadow private in render.c

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 14:30:58 +00:00
Yuxuan Shui 3b2e149369
Add missing include in x.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 14:30:53 +00:00
Yuxuan Shui 0b94bde004
Remove unused variable in backend/xrender.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 14:08:35 +00:00
Yuxuan Shui 6226ab1228
Fix memory leak in backend/xrender.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 08:22:57 +00:00
Yuxuan Shui cb12430633
Use options_t::shadow_radius for shadow size calculation
No need to access gaussian_map

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 08:15:36 +00:00
Yuxuan Shui 4039a6db64
Remove all use of psglx from backend/glx.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 07:37:49 +00:00
Yuxuan Shui a2022661e6
Move glx_init_blur to gl_common.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 07:18:38 +00:00
Yuxuan Shui 8629fee78f
Fix some static analyzer complains in glx.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 06:54:59 +00:00
Yuxuan Shui f322bd4a53
Remove backend/gl/glx.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 01:53:25 +00:00
Yuxuan Shui 61f55f69a6
Add backend/gl/glx.c to build
Still a long way to go for the glx backend.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 01:32:31 +00:00
Yuxuan Shui 3e7b7bd608
Move glx_fbconfig_t to opengl.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-31 00:38:13 +00:00
Yuxuan Shui e7a8adf2cc
Clear ps->sync_fence after error, part 2
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-30 22:13:30 +00:00
Yuxuan Shui 14f357ea2b
Clean up ps->sync_fence after error
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-30 08:05:16 +00:00
Yuxuan Shui d12b3c1e1d
Add missing header files
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-30 08:00:22 +00:00
Yuxuan Shui 4bfed7f7e3
Use one global XSync fence
And only sync once per frame.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-30 07:43:24 +00:00
Yuxuan Shui 80847dd3fa
Refactor the XSync fence code
Use a temporary fence everytime. Convert the Xlib XSync functions to use
xcb_sync_*.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-30 07:06:47 +00:00
Yuxuan Shui bc0382d962
Remove usage of Xlib from x.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-30 06:05:39 +00:00
Yuxuan Shui 2e26c511c4
Fix allocation with 0 size
Thanks to the static analyzer

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-27 20:56:05 +00:00
Yuxuan Shui 669cbcdb14
Fix some static analyzer errors
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-27 20:47:58 +00:00
Yuxuan Shui 51d03132bf
A bit more xcb conversion
None -> XCB_NONE
Window -> xcb_window_t
Atom -> xcb_atom_t

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-27 20:45:38 +00:00
Yuxuan Shui 86e744345e
Fix build with gcc 6
gcc want _Noreturn to be the first thing in declaration.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-25 14:55:01 +00:00
Yuxuan Shui 311fa65840
Mark report_allocation_failure as noreturn
Silence an static analyzer warning

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-25 04:11:29 +00:00
Yuxuan Shui 4f1dddd072
-C and -G *disables* shadow, not enabling them
Well, I made a mistake.

Fixes #79

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-24 19:58:25 +00:00
Yuxuan Shui f41765fca5
Refactor setting the default winopts
Move filling winopts with default values to after command line options have
been parsed, not after parsing the config file. This is more intuitive.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-24 19:57:16 +00:00
Yuxuan Shui b434451abb
Lower x_print_error to log_debug
This information is only really useful for debugging anyway.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-22 14:29:26 +00:00
Yuxuan Shui 0c4b690b2b
First step of split backend into modules
This commit introduced a new, modular backend interface. The interface
is not very good, since I don't think I fully understand all the
requirements writing a backend have. But this is a good first step.

This commit also includes an initial xrender backend written using the
new interface, and some opengl backend related helper functions, which
are taken from the old opengl backend.

However, there is not integration with the core compton yet. compton
will still use the old backend code. This commit is here so we can get
the automated build test.

What is implemented in the new xrender backend:

* Windows with transparency
* Shadow
* Opacity
* Wallpaper (getting the root pixmap)
* Blur

Known problem with the xrender backend:

* It is slower

Things that still need to be figured out:

* What is the better way to add vsync to the new backends

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-22 00:50:25 +00:00
Yuxuan Shui 2cf04544d8
Add some window related helper
For the backend refactoring.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-22 00:34:08 +00:00
Yuxuan Shui db5a78790c
Make make_shadow() public
Some the refactored backends can use it.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-22 00:30:45 +00:00
yshui 7993758bf9
Merge pull request #74 from Avi-D-coder/next
Fix compile errors triggered by vsync-drm option
2018-12-22 00:13:52 +00:00
Yuxuan Shui 6c00d46d7a
Some new x helper functions
They should be useful for the refactored backends.

Renamed x_create_picture to x_create_picture_with_pictfmt.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-21 23:47:31 +00:00
Yuxuan Shui f8c86d51b3
Mark fallthrough switch case
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-21 23:04:51 +00:00
Yuxuan Shui e211c395fa
Append to log file, not overwrite
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-21 23:02:19 +00:00
Yuxuan Shui 8bb7027393
Fix memory leak in get_cfg
When setting --shadow-exclude-reg from both the config file and the
command line, one of the strings is not freed.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-21 22:59:28 +00:00
Yuxuan Shui 7915ade1be
Make --logpath work again
Also add a new option "log-file" to config file and command line, it
doesn the same thing as --logpath.

--logpath was never documented, and "log-file" is more consistent with
the naming of options.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-21 22:59:21 +00:00
Avi ד 09e372cc9d Fix vsync-drm 2018-12-21 17:25:24 -05:00
Yuxuan Shui c8a9f32b05
Add debug logging to get_atom
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-21 17:22:10 +00:00
Yuxuan Shui cb7d852b0f
Clean up options/config file parsing
* Pass a options_t, not session_t
* Slightly improve error handling when setting vsync method via dbus

The goal here is to limit the scope of what a given function can access.
And session_t contains basically everything, so don't pass it around.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-21 17:21:52 +00:00
Yuxuan Shui ee2be09958
Rename argparse.* to options.*
Seems to be a more appropriate name.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-21 13:10:49 +00:00
Yuxuan Shui 2a2958b68d
Split the first and second pass of get_cfg
They are not separate functions

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 23:58:47 +00:00
Yuxuan Shui 9b121447b9
Remove a couple of unwanted options
* -d: because the standard way is to use $DISPLAY
* no-name-pixmap: undocumented debugging option
* -S: debugging option, not very useful

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 23:44:38 +00:00
Yuxuan Shui 9880245200
Move get_cfg and usage out of compton.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 23:12:38 +00:00
Yuxuan Shui 4ff9e810ff
Sort out the dbus function prototypes
* Moved dbus prototypes from common.h to dbus.h
* Removed private function prototypes from dbus.h
* Removed private macros from dbus.h
* Hide dbus types from common.h

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 23:12:27 +00:00
Yuxuan Shui abeb294508
Remove printf_* macros
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 17:36:23 +00:00
Yuxuan Shui a6fef8e8fb
Convert printf_* from config.c and config_libconfig.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 17:35:45 +00:00
Yuxuan Shui d8198926dc
Convert printf_* in opengl.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 17:24:03 +00:00
Yuxuan Shui 24dd8ee120
Convert printf_* in vsync.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 17:19:41 +00:00
Yuxuan Shui 9b5db1f0aa
Convert printf_* in c2.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 17:16:20 +00:00
Yuxuan Shui 832601354a
Convert printf_* in render.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 17:03:27 +00:00
Yuxuan Shui b5b0f4af7f
Convert printf_errf/dbgf in several files
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 16:54:51 +00:00
Yuxuan Shui 3966491846
Convert printf_errf/dbgf in opengl.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 16:50:11 +00:00
Yuxuan Shui 22669889eb
Don't report allocation failure via logging
They will be reported by allocchk and will abort the program. There is
no point to log them.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 14:23:06 +00:00
Yuxuan Shui 1ea611c90e
Improved allocation failure reporting
Now it reports file and line number of the function too.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 14:19:10 +00:00
Yuxuan Shui 6f0daf8076
Add a writev interface for log targets
So some log targets can be more efficient and allocate less memory.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 04:45:07 +00:00
Yuxuan Shui 26807e74d9
Convert printf_errf in dbus.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 04:02:37 +00:00
Yuxuan Shui 2af0b48c7b
Convert printf_errf in common.h
And remove some unused functions.

And improve some error messages.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 03:56:37 +00:00
Yuxuan Shui 833eb966f1
Convert print_errf/dbgf in win.c and compton.c
And improve some of the log messages. Like, when compton exits because
of unsupported options, explain which options are causing compton to
quit.

Convert some debugging messages that are guarded behind ifdef's to log_trace,
so user don't need to re-compile to enabled them.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 03:56:31 +00:00
Yuxuan Shui 185c0ce97c
Guard log_printf in LOG macros with a log level check
So that the format arguments will only be evaluated if the log is
enabled by the log level. Allow us to add more expensive logs without
impact performance when they are not enabled.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 02:34:45 +00:00
Yuxuan Shui fc57c7b55b
Add a FATAL ERROR log level
For errors that cause compton to quit

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 02:02:08 +00:00
Yuxuan Shui d9409ae2c9
Add command line and config file option log-level
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 01:26:04 +00:00
Yuxuan Shui 1bcd7f2f7a
Add a simple logging framework
It's not very pretty now, but it will get better.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 01:02:56 +00:00
Yuxuan Shui 4040ad259d
Add compiler dependent macros for thread_local
Also add stdc-predef.h because __STDC_NO_THREADS__ is defined there.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-20 00:46:38 +00:00
Yuxuan Shui 8bc052929e
Enable -Werror in CI
And fixes some warnings.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-19 23:41:58 +00:00
Yuxuan Shui e58cbf8add
Convert non-mandatory attributes to macros
They're shorter and more portable.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-19 20:50:02 +00:00
Yuxuan Shui 5f57cb41f9
A bit more compiler dependent macros
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-19 20:36:05 +00:00
Yuxuan Shui 7901b86024
Make sure vsync arrays are big enough
Fix array boundary overrun

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-17 00:51:27 +00:00
Yuxuan Shui eabe2b5bb8
Explicitly cast X sequence number
Fix an undefined behavior.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-17 00:51:27 +00:00
Yuxuan Shui 50ea3617ef
Move some deinitialization to render.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-16 03:00:56 +00:00
Yuxuan Shui e7a15ba846
Format changes
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-16 02:50:39 +00:00
Yuxuan Shui 404a6b47ad
Move presum_gaussian to render.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-16 02:49:41 +00:00
Yuxuan Shui a48e1f65a9
Fix building with opengl, again
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-16 02:48:02 +00:00
Yuxuan Shui 9ce1387f52
Move a few more functions into render.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-16 00:53:54 +00:00
Yuxuan Shui e29d9510ed
Remove a debug message
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-16 00:52:45 +00:00
Yuxuan Shui baeb4572ff
Move rendering related functions out of compton.c
Moved:
* Blur kernel related functions to kernel.c
* Vsync related functions to vsync.c
* paint related functions to render.c

This will make the `split-backend` branch easier to rebase.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-16 00:50:46 +00:00
Yuxuan Shui 85c5d34ce1
Add missing CONFIG_OPENGL check
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-15 20:09:49 +00:00
Yuxuan Shui 94b1bc0387
Use libxdg-basedir for finding config files
Also add a new config file path:
{$XDG_CONFIG_DIRS,$XDG_CONFIG_HOME}/compton/compton.conf

(For those not familiar with xdg: now compton will look for
~/.config/compton/compton.conf too)

Closes #62

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-15 19:53:16 +00:00
Yuxuan Shui 68873efaa2
Move likely/unlikely to compiler.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-15 19:14:01 +00:00
Yuxuan Shui b73dce1d6d
Replace mstrcpy, mstrncpy with strdup, strndup
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-15 19:07:14 +00:00
Yuxuan Shui b8912fa749
Use checked allocation everywhere
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-15 18:57:46 +00:00
Yuxuan Shui acb81bc9a9
Add log.h to files that need it
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-15 17:53:17 +00:00
Yuxuan Shui 0cebbc370a
Function movements
* string functions mstr*() are moved to string_utils.c
* allocation wrappers are moved to utils.h
* printf_* functions are moved to log.h

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-15 17:43:36 +00:00
Dan Elkouby 6195422c66 Swap control only works with OpenGL 2018-12-15 11:22:38 +02:00
Dan Elkouby e2182bb00b Work around mesa's default-on swap control 2018-12-14 19:25:05 +02:00
Dan Elkouby de1cce21ba Merge opengl-{,m}swc vsync methods
Both methods are redundant. Prefer Mesa's own extension when available,
fall back to the old SGI extension otherwise (NVIDIA drivers for the
most part).
2018-12-14 19:24:03 +02:00
Yuxuan Shui 0899a9689e
Remove unused variable in paint_preprocess
And fix a memory leak caused by it.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-09 21:00:32 +00:00
Yuxuan Shui 345bacf3b3
Convert wid_get_prop to xcb
This should give us sane item size, i.e. the item has the same number of
bits their format says they have.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-09 20:54:16 +00:00
Yuxuan Shui 8805cfa986
Move winprop_t to win.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-09 20:25:09 +00:00
Yuxuan Shui 733d5dcf54
Fix pointer types of winprop_t
Foolish of me to assume the returned window property items have the same
number of bits their format says they have.

Apparently, format = 32 means the return items are 64 bits long (on
64-bit machines).

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-09 20:19:13 +00:00
Yuxuan Shui dffde065b1
Make the shadow actually gaussian
The old shadow kernel formula is not "wrong" per se, as the only judge
is if it looks good. However, the formula used is not really gaussian.
Also, the kernel size calculation doesn't really make sense to me.

This commit change the kernel formula to actually use a gaussian
distribution. As far as I can tell, there is no perceivable difference.
Except now the effective shadow radius is smaller for the same config.

Also, made that part of code a bit more mordern.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-09 02:07:08 +00:00
Yuxuan Shui da3df75a8c
Make sure the vsync methods are really available
libglvnd seems to return a pointer to a function that does NOTHING
for things the backing driver doesn't support.

So we check if the extension is actually advertised before using it.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-08 18:22:59 +00:00
Yuxuan Shui f83eb79c05
Add wintype option `redir-ignore`.
This cause certain window types to be ignored in deciding whether the
screen should be redirected after being unredirected.

Fixes #58

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-04 16:36:49 +00:00
Yuxuan Shui 8f05b03411
Move the initialization of wintype options into common function
Make sure the wintype options are properly initialized even when there
is no config file specified/supported.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-04 16:29:32 +00:00
Yuxuan Shui f97cf48865
Clean up the wintype option logic
I just realized wintype option shadow and fade never worked. If you set
the global shadow option to true, wintype shadow option will have no effect.

Now the wintype options will properly override the global ones.

Also remove deprecated options from compton.sample.conf.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-12-04 15:13:08 +00:00
Yuxuan Shui a3f753105f Don't allocate libev struct separately
Elimiate some annoying types.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-27 00:32:08 +00:00
Yuxuan Shui 531aafabb5 Fix SIGUSR1 handling
Calling ev_break() in a signal handler doesn't work. Instead, we setup a
libev ev_signal handler for this.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-26 23:57:55 +00:00
Yuxuan Shui b89dadec40 Fix a wrong type
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-26 23:57:55 +00:00
Yuxuan Shui 2827a020a4 Handle SIGINT
Exit gracefully so sanitizer can do their jobs.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-26 23:57:55 +00:00
Yuxuan Shui 90a4b201bd Re-word some of the comments
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-26 23:57:55 +00:00
Yuxuan Shui 010a0c34ca Don't delay update when refresh rate is not available
Fix a divide by zero in delay time calculation.

Fixes #56
2018-11-26 16:53:57 +00:00
Yuxuan Shui 0a6f48dba2 Support all alpha values
Remove alpha_step, and support all 256 alpha values.

1 pixel pictures don't really use that many resources.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-19 12:43:46 +00:00
yshui c389a1335d
Merge pull request #46 from yshui/full-shadow
Add per window type option full-shadow
2018-11-19 12:31:11 +00:00
Yuxuan Shui f834cf20ae Print deprecation message for --glx-fshader-win
No functionality is removed in this commit.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-11 19:38:58 +00:00
Yuxuan Shui bcab5d1518 Workaround the incompatibility between DRI2 and xcb
When using DRI2, Mesa uses XESetWireToEvent to hook into Xlib's event
handling loop, so it can get notified when certain DRI2 event happens,
which is crucial to the normal functioning of GLX.

When xcb is owning the event queue (meaning libxcb is doing all the
event handling), those functions registered by Mesa will never be
called, thus GLX will malfunction, leading to screen flickers or visual
artifacts.

This commit uses a hack from Qt to manually call those functions in
compton.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-10 22:25:41 +00:00
Yuxuan Shui 03ff094f75 Remove GLX sync fence code
It was never enabled in the old version of compton anyway.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-10 22:16:30 +00:00
Yuxuan Shui 45a260b433 Print warning messages for multipass blur
Multipass blur is not properly implemented for xrender backend. There is
visible artifacts when it is used. And it is quite difficult to
implement correctly and efficiently for the xrender backend.

Print a warning message for multipass blur so we can survey whether it
is actually been used.

No functionality is removed in this commit.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-10 14:57:41 +00:00
Yuxuan Shui 683cda0b91 Set clip region on the target picture
Setting it on the target buffer picture has no effect. Fix performance
problem when using xrender with virtual box.

Fixes #40

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-10 12:55:08 +00:00
Yuxuan Shui 46d162cec9 Print useful message when clear-shadow is used
Points the user to the full-shadow per window type option.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-09 21:04:22 +00:00
Yuxuan Shui 0dcb0e0dc6 Add per window type option full-shadow
When this option is enabled for a window type, shadow will be drawn in
areas that are obscure by the shape of the window.

Useful when the given window type has parts of the window transparent,
and you want to have shadows in those areas.

Fixes #45

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-09 19:56:05 +00:00
Yuxuan Shui b18d46bcbd Revert "Remove xrender-sync and xrender-sync-fence"
This reverts commit 50e2259404.

Temporarily revert the removal until we have more information about this whole
thing.

Turns out a couple of drivers don't work properly without the sync fence,
including intel, llvmpipe and NVIDIA.

Although sync fence is needed, from the information I have gathered (looking
at old bug reports, protocol specifications, look at other compositors' code),
compton's usage of it is not proper. So we need to rewrite it in the future,
after we get more information from driver developers.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-08 18:07:18 +00:00
Yuxuan Shui 2b0b7435df Convert some Xlib constants to xcb
And remove some Xlib headers

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-04 18:58:05 +00:00
Yuxuan Shui 471f6f90ff Remove some unnecessary macros
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-04 18:54:37 +00:00
Yuxuan Shui 06abd7b041 Fix xr_glx_hybrid backend
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-04 13:49:55 +00:00
Yuxuan Shui 796b0e0448 Move private functions from compton.h to compton.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-03 22:38:33 +00:00
Yuxuan Shui 332a873729 Add --diagnostics option
It will cause compton to print out some rudimentary diagnostics.

Also small improvements of the meson.build.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-03 22:37:18 +00:00
Yuxuan Shui e142993bb5 Enable paint-on-overlay whenever possible
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-03 22:36:52 +00:00
Yuxuan Shui f65d7b2e64 Fix unsupported optimize attribute on clang
Use optnone instead, this does require a more recent clang though. In
general, just don't use -ffast-math.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-03 14:05:13 +00:00
Yuxuan Shui be09a9a835 Workaround compiling with -ffast-math
And add a compiler warning.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-02 13:57:42 +00:00
Yuxuan Shui 45e9530bcb Update bounding shape when a window is mapped
Fixes #35

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-01 21:06:40 +00:00
Yuxuan Shui 4f4201976d Fix signedness of x properties
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-11-01 11:12:46 +00:00
Yuxuan Shui 32e0b45255 Sanitize opacity data get from window props
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-31 23:18:10 +00:00
Yuxuan Shui d7b5104fd4 Remove poll.h include 2018-10-30 22:18:10 +00:00
Yuxuan Shui c0d7f9d915 Add damage when restacking windows
Interesting this problem only surface when using GTK applications on
KDE. Maybe on other WMs there are some other events after window
restacking that triggers repaint of the window.

Fixes #28

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-29 17:16:56 +00:00
Yuxuan Shui a312dcb3da Remove a debug message
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-29 13:36:48 +00:00
Yuxuan Shui 50e2259404 Remove xrender-sync and xrender-sync-fence
This was a dubious "fix" for a Nvidia driver problem. The problem was
never fully understood, and the then developers took a shotgun approach
and implemented xsync fences as a fix. Which somehow fixed the problem.
Again, I don't see any indication that the developers understood why
this "fix" worked.

(for details, see chjj/compton#152 and chjj/compton#181)

The driver problem should have been fixed almost 5 years ago. So this
shouldn't be needed anymore. In addition the way compton uses xsync fences
is apparently wrong according to the xsync spec (fences are attached to
screen, but compton uses them as if they were attached to drawables).

So, I will try removing it and see if anyone will complain. If there are
real concrete reasons why fences are needed, it will be brought back.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-28 23:36:55 +00:00
Yuxuan Shui 5694e75932 Fix build when opengl is disabled, again
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-28 23:09:42 +00:00
Yuxuan Shui 309a4cec79 Make monitor_repaint an option
This is a potentially useful feature for debugging the xrender backend,
so make it a commandline option rather than an obscure compiler flag.

Also this is only usable with xrender, for glx there are better tools
for debugging.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-25 23:32:10 +01:00
Yuxuan Shui 551d487836 Remove some unused parameters
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-25 23:32:10 +01:00
Yuxuan Shui f519ee53c1 Remove support of Xdbe
--dbe does not seem to have an effect on tearing, as noted in the old
manpage, and confirmed by my own testing.

So remove it, since it complicates the logic of painting.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-25 23:32:10 +01:00
Yuxuan Shui 1f95c74a68 Move struct win to win.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-25 23:32:10 +01:00
Yuxuan Shui 0686300013 Move some common functions to utils.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-25 23:32:10 +01:00
Yuxuan Shui e13bc7fc51 Move common types to types.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-25 23:32:10 +01:00
Yuxuan Shui 3ffc0c77ed Replace get_alpha_pict with get_alpha_step
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-25 23:32:10 +01:00
Yuxuan Shui 16f202f4a0 Fix build when opengl is disabled 2018-10-25 23:31:57 +01:00
Yuxuan Shui df63cab39a Print messages about removed options
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-24 11:10:35 +01:00
Yuxuan Shui db700f9be1 Fix OOB when the number of screens change 2018-10-22 15:38:45 +01:00
Yuxuan Shui 0b866fb17f Hot fix: trail when moving windows around
Call win_on_factor_change when window is moved. This does some
duplicate work, but fix the problem for now.
2018-10-16 17:16:18 +01:00
Yuxuan Shui 4094d8b9c4 Add initial meson build scripts 2018-10-15 00:38:21 +01:00
Yuxuan Shui aa2098eefd Move w->bounding_shape to local coordinates
This way we don't need to update the bounding region after window moves.

Also add some comments about the coordinate systems in compton.
Also change a few function that takes a `bool global` parameter to
always return region in local coordinates.
2018-10-13 01:24:52 +01:00
Yuxuan Shui 4f071ffc30 Fix infinite recursive calls
win_rounded_corners is called by win_updated_bounding_shape, so there is
no need for the former to call the later.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-12 23:37:02 +01:00
Yuxuan Shui bbb73fe64e Fix integer overflow
`x + wid` will convert x to unsigned first, if x < 0, integer overflow
could occur.
2018-10-12 23:17:12 +01:00
Uli Schlachter 9bb3327549 Die when the X11 connection breaks
With libX11, the library calls an I/O error handler if the connection to
the server breaks. The default I/O error handler prints an error message
and calls exit(). This can be seen when running a "pre-xcb" compton
against Xephyr and then closing the Xephyr window:

XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":1"
      after 241 requests (241 known processed) with 0 events remaining.

The current compton would just continue running. After this commit, it
instead exits with this message:

handle_queued_x_events(): X11 server connection broke (error 1)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:54:05 +01:00
Uli Schlachter 1c1adc96c8 Change event masks to XCB defines
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:54:05 +01:00
Uli Schlachter 37ef9c5b8a Add the xcb_connection_t to session_t
Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-10 10:54:00 +01:00
Uli Schlachter 54807342f4 Convert XQueryTree to XCB
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:50:00 +01:00
Uli Schlachter 6c6156932f Convert find_client_win() to XCB
This function was the only caller of wid_get_children() which called
XQueryTree().

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:50:00 +01:00
Uli Schlachter b2bfbcdfb0 Convert XGetAtomName to XCB
Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-10 10:49:52 +01:00
Uli Schlachter ca148c8f15 Fix printf format with DEBUG_EVENTS
Xlib uses unsigned long for XIDs, but xcb always uses uint32_t. Thus,
this needs the format string for uint32_t now.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:46:39 +01:00
Uli Schlachter 7e71f46401 Convert XInternAtom to XCB
Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-10 10:46:34 +01:00
Uli Schlachter 2da0ecdf66 Convert XSelectInput() to XCB
Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-10 10:42:12 +01:00
Uli Schlachter 1b1b3456bc Convert XGetSelectionOwner to XCB
This also fixes a memory leak: buf was not freed if another composite
manager was already running.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:41:40 +01:00
Uli Schlachter 2dc90e7d4d Convert XGetInputFocus to XCB
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:41:40 +01:00
Uli Schlachter 8db6473d32 Convert property management to XCB
I removed the error checking in compton.c because it was dead code.
XChangeProperty() always returns 1.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:41:40 +01:00
Uli Schlachter a192bfb130 Replace XSetSelectionOwner with XCB
Note that the argument order is different between Xlib and XCB.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:41:40 +01:00
Uli Schlachter 0cae42faaa Replace XDestroyWindow with xcb_destroy_window
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:41:40 +01:00
Uli Schlachter e30ff25dd3 Replace XClearArea with xcb_clear_area
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:41:40 +01:00
Uli Schlachter 28e9488e25 XCBify XCreateGC and XFreeGC
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:41:40 +01:00
Uli Schlachter b86190452c XCBify X{Ung,G}abServer
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:41:40 +01:00
Uli Schlachter 3c5d7555a4 XCBify X{Unm,M}apWindow
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-10 10:41:40 +01:00
Yuxuan Shui 6a8df0ada7 Fix a leak of XFIXES regions 2018-10-09 22:24:00 +01:00
Yuxuan Shui 7b755a3cf0 Fix typo in CONTRIBUTORS, move licenses around
Having a LICENSE file makes github happy
2018-10-03 22:24:12 +01:00
Yuxuan Shui ee318582f5 Sort out license problems
IANAL, but I think I am allowed to add missing copyright notices for
someone else. And I did my best job using git history to figure out who
wrote which functions. So I hope everything is fine.
2018-10-03 22:14:51 +01:00
Yuxuan Shui 9e1422dc90 Fix parsing of shadow-exclude-reg
Closes #13

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-03 18:20:40 +01:00
Yuxuan Shui f1872c4033 Allocation for xinerama_scr_regs used wrong size
Should be sizeof(region_t). Rebasing is hard :(
2018-10-03 16:19:48 +01:00
Yuxuan Shui 2a4fed50f4 Use libev for inputs and timeouts
Bugs:

* There seems to be a noticeable frame loss when window
  is being opened/closed. But the same problem also exists
  in master/next, so this is not a regression.
* Using --sw-opti and --benchmark at the same time causing
  compton to draw more frequently than permitted by the
  arguments. That is because the sleep interval calculation
  is flawed. Not really a regression either.

Verified still working:

* Usual painting
* Fade
* Benchmark mode
* --sw-opti (with or without benchmark mode)
* DBus
* Unredir delay

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-10-03 01:05:32 +01:00
yshui e58de49d7a
Merge pull request #10 from psychon/remove-xfixes
Some more trivial Xlib -> XCB conversions
2018-10-02 21:38:28 +01:00
Yuxuan Shui d917ec22a8 Fix a typo in conversion to xcb damage 2018-10-02 21:25:09 +01:00
Uli Schlachter 385ba2cdf6 Remove unused definition
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-02 19:56:47 +02:00
Uli Schlachter cad786c025 Remove include of X11/Xutil.h
It doesn't seem to cause any problems. Perhaps its uses were already
converted to XCB?

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-02 19:54:20 +02:00
Uli Schlachter bc7767e086 Replace Xlib atom constants with XCB ones
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-02 19:53:28 +02:00
Uli Schlachter b2d947a19a Remove include of Xfixes.h
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-02 19:51:37 +02:00
Uli Schlachter 91468c3622 Replace BadRegion with XCB_XFIXES_BAD_REGION
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-02 19:51:30 +02:00
Uli Schlachter 7c174cc3b1 Replace XserverRegion with xcb_xfixes_region_t
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-02 19:50:27 +02:00
Yuxuan Shui cb4bab1cf6 Print deprecation warning for removed OpenGL options
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 21:07:29 +01:00
Yuxuan Shui 03f33ed45c Move a couple X related functions to x.c
Also replace remaining Pixmap with xcb_pixmap_t

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 20:57:42 +01:00
Yuxuan Shui ddab20176b Fix building with ENABLE_XRESCHECK=1 2018-09-30 20:43:34 +01:00
Yuxuan Shui 18022181ee Make sure to clear the rectangles 2018-09-30 20:41:30 +01:00
Yuxuan Shui 6a41bebfa5 Just clear shadow anyways
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 20:12:06 +01:00
Yuxuan Shui 97cd3421b0 Remove last bits of Xfixes
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 15:54:12 +01:00
Yuxuan Shui e0bc6f5f7c Add helper macros for calling xcb function and wait for reply
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 15:54:12 +01:00
Yuxuan Shui ff27ca4072 Move xerror_common to x.c
Also rename it to x_print_error

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 15:54:12 +01:00
Yuxuan Shui 915839c3d3 Convert XFixesCreateRegionFromWindow to use Shape directly
Fetch the rectangles directly use the Shape extension.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 15:54:12 +01:00
Yuxuan Shui 82e63593ae region.h: helper functions for converting rect types
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 15:54:12 +01:00
Yuxuan Shui a7d50ffdb2 Remove unused function rect_crop
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 15:54:12 +01:00
Yuxuan Shui 28a2cc62fa Convert XfixesRegion to pixman region
Re-did the painting logic, and document it.

It is unclear to me what is the previous painting logic. But the current
one is basically this:

1. Go through all windows top to bottom, and put visible windows (not
   unmapped, opacity > 0, etc) into a linked list, from bottom to top
2. Accumulate a region of ignore on each window, which is basically the
   region of screen that is obscured by all the windows above current
   one.
3. Paint all the visible windows from bottom to top. Subtract the region
   of ignore from the painting region. If we need to paint shadow, we
   subtract the body of the window from the shadow painting region too,
   because we don't want shadow behind the window.
4. region of ignore is invalidated when window stack change, an
   window on top moved or changed shape, when window changed between
   opaque and transparent, etc.

Notes:

It is unclear whether all the different shapes of a window (extents,
noframe, border, bounding shape, etc) are calculated correctly or not.

It is unclear if window shape related events are handled correctly or
not. Need more testing.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 14:18:33 +01:00
Yuxuan Shui 56f7dd36f6 x: Add region related helper functions
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 14:18:33 +01:00
Yuxuan Shui 3f4c05720d utils.h: Some utility functions and macros
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 14:18:33 +01:00
Yuxuan Shui ab12467c3f Change fade callback function parameter
Change `win *` to `win **`, because a window could be freed by the
callback, so we can set `*w` to NULL to communicate that.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 14:18:33 +01:00
Yuxuan Shui 417744df14 Move opengl related function prototype to opengl.h
And aggregate some of the OPENGL ifdefs

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 14:18:01 +01:00
Yuxuan Shui c01ad5bf04 Move OpenGL functions around
Also remove some debug function calls (there are better tools for opengl
debugging now). Also remove copysubbuffermesa

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 13:49:45 +01:00
Yuxuan Shui 90b6aa16ad Remove ARGB as a window mode
Instead use win_has_alpha to check for alpha channel, window mode is
reserved for determine if the window is possibly transparent.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-30 13:49:45 +01:00
Uli Schlachter 8848676540 Add a function that allocates a pixmap and checks success
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-30 09:31:22 +02:00
yshui 6ec951763e
Merge branch 'next' into more-xcb-conv 2018-09-30 04:53:34 +01:00
Uli Schlachter aedea014a9 Replace XFixes initialisation with xcb
XFixesQueryExtension() does an XFixes QueryVersion request internally,
so one was added here.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 17:02:44 +01:00
Uli Schlachter 529306e65f Convert usage of XCreatePixmap to xcb
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 12:00:18 +02:00
Uli Schlachter ea9942b87e Replace use of XFreePixmap with XCB
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:53:30 +02:00
Uli Schlachter 9dff55540f Convert Xinerama usage to xcb
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:48:58 +02:00
Uli Schlachter 83a4853419 Convert use of SHAPE extension to XCB
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:48:58 +02:00
Uli Schlachter aa8cb217c8 Fix xcb error ignoring
The existing mechanism with set_ignore_next() is (IMHO) ugly and also
does not work with XCB requests. This commit adds a new function
set_ignore_cookie() and fixes callers that were converted to XCB to use
this new function instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:48:58 +02:00
Uli Schlachter 00ae9718ee Handle asyncronous X11 errors
Errors for requests sent via Xlib that expect a reply are handled via
XSetErrorHandler(), which sets up a callback function that Xlib calls.
Errors for requests that do not expect a reply or for errors caused via
unchecked XCB requests show up as events of type 0 in the event handling
function.

Before this commit, errors were ignored here. This commit changes the
code so that the errors are printed instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:48:58 +02:00
Uli Schlachter 3ed73b1f8e Replace last definitions from Xcomposite.h with xcb
Note that this adds an include for Xfixes.h, because that header is
still needed and was previously included through Xcomposite.h.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:48:57 +02:00
Uli Schlachter 2f49f6f03d Switch XComposite initialisation to XCB
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:48:57 +02:00
Uli Schlachter 8064eaaa37 Replace more usage of XComposite with xcb
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 10:38:25 +02:00
Uli Schlachter 79089b0652 Port XCompositeUnredirect{Subw,W}indows to xcb
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 10:37:53 +02:00
Uli Schlachter 11204e7a44 Port usage of XCompositeNameWindowPixmap to xcb
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 10:37:29 +02:00
Uli Schlachter 7719dc7325 RENDER: Fix check for convolution filter
The X11 server's answer is not \0-terminated, so xcb_str_name() also
does not provide a \0-terminated pointer.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-28 10:45:16 +02:00
Uli Schlachter 539d62ca93 Port from xrender to xcb-render
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-27 18:14:44 +02:00
Uli Schlachter 6d54d6b055 Port from xrandr to xcb-randr
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-27 17:38:24 +02:00
Uli Schlachter 62b847323c Port from xdamage to xcb-damage
No functional changes intended. The new xcb_damage_query_version() was
previously done by XDamageQueryExtension() internally.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-27 17:29:51 +02:00
Uli Schlachter 0a98ef79ef Fix build with NO_LIBCONFIG=1
This got broken in commit fcef5e706d.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-27 17:10:43 +02:00
Yuxuan Shui 4da626639f Update comments about clear-shadow 2018-09-24 00:20:28 +01:00
Yuxuan Shui 6f59367c00 Remove the clear-shadow option
Shadows attached to ARGB/transparent windows are always cleared now.
2018-09-23 23:58:17 +01:00
Yuxuan Shui 209b751b25 Port more stuff to xcb
To avoid interoperability issues between xcb and xlib.
2018-09-23 22:58:49 +01:00
Yuxuan Shui 7af815a0aa Proper fix for screen freeze
If an X event is received at a very specific point in time, it can trigger
a race condition in Xlib. Said event will be read, but Xlib will
nonetheless be completely unaware of the event.

This cause compton to sometimes block on select() while there are events
ready to be processed. If the event is a damage report, screen freeze
will happen until some other event is received.

The proper fix is to switch to xcb for event handling, thus avoid this
problem entirely.
2018-09-22 23:57:51 +01:00
Yuxuan Shui 43f3744fea Revert "Workaround for what seems to be a race in Xserver"
This reverts commit 967d9f32ea.
2018-09-22 19:46:50 +01:00
Yuxuan Shui 967d9f32ea Workaround for what seems to be a race in Xserver
There seems to be a race between DamageAdd (what the client uses
to report damage to Xserver) and DamageSubtract (what compton uses
to clear the reported damage, so it can receive new ones). I am not
sure how to confirm this. But this (terrible) workaround seems to
solve this problem.
2018-09-10 13:46:24 +01:00
Yuxuan Shui 72231098d1 Refactoring
* Move code around
* Remove unneeded forward declaration
* Rename win->damaged to win->ever_damaged, to be less confusing
* Expose debug functions even when DEBUG is not enabled. Compiler
  would remove the dead code for us anyway.
* Some code cleanup
2018-09-10 13:46:24 +01:00
Yuxuan Shui 2adfdfa897 Clear prototypes 2018-09-10 13:46:24 +01:00
Yuxuan Shui d2b85dd6af Fix some null pointer problems 2018-09-10 13:46:24 +01:00
Yuxuan Shui 2e39fc5618 Split out win related functions to win.c
Also move static function prototypes out of compton.h. Seems like the
previous developers didn't know what header files are for.

Seems to have bugs after the split.
2018-09-10 13:46:24 +01:00
Yuxuan Shui 0d6b1627f2 Make gcc happy 2018-09-10 13:46:24 +01:00
Yuxuan Shui 571a6cf15f Enable everything OpenGL when using OpenGL
Remove finer grained macro definitions, just enable everything OpenGL
when we are using OpenGL.
2018-09-10 13:46:24 +01:00
Yuxuan Shui 3ce59930a4 More compiler warning flags 2018-09-10 13:46:22 +01:00
Yuxuan Shui 4940a93f03 c2.h cleanup
Move most of the static functions into c2.c itself, and
only keep the public functions in c2.h
2018-09-10 13:46:05 +01:00
Yuxuan Shui fcef5e706d Some cleanup work
* Remove NO_C2 option
* Split configuration related functions into their own file
* Drop support for libconfig < 1.4
* Fix dependencies in Makefile
2018-09-10 13:46:05 +01:00
Yuxuan Shui ba780659be Add repo info to usage string 2018-09-10 12:08:45 +01:00
Yuxuan Shui c8bfbd6b11 Allow setting active/inactive opacity to 0 2018-08-14 11:05:28 +01:00
Yuxuan Shui 15e3c525e3 Expose opacity_is_set, has_opacity_prop over dbus 2018-08-14 11:05:28 +01:00
Yuxuan Shui bfead72d37 Honor opacity explicitly set by rules 2018-08-14 11:05:28 +01:00
Yuxuan Shui 58a0b9ec39 Honor wintype opacity if set explicitly
Also normalize wintype opacity value to [0, 1]
2018-08-14 11:05:28 +01:00
Yuxuan Shui 66785aae99 Honor opacity prop if set
If opacity prop is explicitly set on the window, active/inactive opacity
shouldn't kick in.
2018-08-14 11:05:28 +01:00
Yuxuan Shui 91ca387723 Unify opacity_prop and opacity_prop_client
Also keep track of whether opacity prop is present on the window
2018-08-14 11:05:28 +01:00
Yuxuan Shui a1afb76c44 Warn about fallthrough
And fix some fallthroughs
2018-08-14 10:59:09 +01:00
Yuxuan Shui 27fc4a2af4 Clear compiler warnings
Thanks to chjj/compton#445
2018-05-17 12:50:22 +01:00
Yuxuan Shui af8a08e655 Remove blur limit
Thanks chjj/compton#414
2018-05-17 12:37:13 +01:00
Yuxuan Shui bf29b2dd37 Avoid using 10bit FBConfigs
Fix weird color issue with Mesa 18.0
2018-04-16 10:13:55 -04:00
Uli Schlachter 1125389910 Exit when compton loses the _NET_WM_CM_Sn selection
Again, this behaviour is required by ICCCM.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-04-16 10:13:55 -04:00
Uli Schlachter f8ea3e8668 Don't steal the _NET_WM_CM_Sn selection (#301)
Before becoming the selection owner for _NET_WM_CM_Sn, compton will now check if
that selection is already owned (which means that another composite manager is
already running). If this check fails, startup will be refused. This behaviour
is required by EWMH / ICCCM.

Because this should catch all composite managers, the error message that was
used before when another manager is already running is reworded to mention that
the other manager does not follow EWMH.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-04-16 10:13:55 -04:00
Yuxuan Shui cfdb946992 Avoid using window id as identifier in finish_destroy_win
Under extreme race conditions (window A close at the same time as window
B create), there can be multiple windows with same id in compton's window
list. If at this point window B closes itself as well, finish_destroy_win
might destroy a different window as what's passed to destroy_callback.

This can be a problem because someone can still hold a reference to that
window (e.g. 't' in paint_preprocess), and there's no way to clear that
reference. If finish_destroy_win always destroy the same window passed
to destroy_callback, this will not be a problem.
2018-04-16 10:13:55 -04:00
Yuxuan Shui f4f39d1989 Avoid changing fade_callback when window is destroyed
Fix assertion at src/compton.c:1261
2018-04-16 10:13:55 -04:00
Richard Grenville 2343e4bbd2 Misc #308: Close config file after using it
Misc #308: Close the config file after using it, instead of leaving it
open forever. Thanks to SyedAmerGilani for the report.
2015-09-22 08:34:28 +08:00
Richard Grenville 20e996494b Misc: Modify function attributes
- Remove the const function attribute from get_time_*(), since the
   functions they call that actually get the time probably access global
   variables or have other behaviors unacceptable for const functions.

 - Change the const function attribute on win_has_frame() to pure, as it
   accesses memory its parameter points to, which is invalid for a const
   function.
2015-09-06 22:34:02 +08:00
Richard Grenville c156abb0e8 Bug fix #302: Use more EWMH-compliant way to determine frame extents
Bug fix: Select the larger of the X window border width and
_NET_FRAME_EXTENTS, instead of adding them together, when determining
the frame extents. (Supposedly) more EWMH compliant, as EWMH
_NET_FRAME_EXTENTS should include the X window border width already. We
did not choose to completely rely on _NET_FRAME_EXTENTS to remove the
need to keep track of whether there is a _NET_FRAME_EXTENTS, and
(hopefully) take care of some cases when it is wrong. The commit should
fix awesomeWM/awesome#425. Thanks to psychon for the information. (#302)

The commit fixes the bug in win_get_region_noframe() that the X window
border width is not considered when determining the width/height of the
window without frame, as well.
2015-09-06 22:19:19 +08:00
Richard Grenville 7d4d87d683 Misc: Add margin_t & Store frame extents with it & Misc
- Add margin_t, a structure that represents margins around a rectangle.

 - Store frame extents of a window with margin_t, replacing the 4
   fields ({left,right,top,bottom}_width) in struct _win.

 - Add two helper macros, cmemzero() and cmemzero_one(), that zero out a
   block of memory.
2015-09-06 20:53:07 +08:00
Kevin Kelley 0e0b35a361 Plug XserverRegion leak. 2015-05-12 13:17:35 -07:00
Richard Grenville 663e1a1a04 Bug fix: --active-opacity state does not change correctly on `--focus-exclude`-ed windows
Fix the bug that --active-opacity state does not change
on `--focus-exclude`-ed windows correctly, since win_update_focused()
enables the WFLAG_OPCT_CHANGE flag on a window only if w->focused
changes, while --active-opacity depends on the output of
win_is_focused_real() instead of w->focused, which could be changed even
if w->focused does not change (e.g. when the window is
`--focus-exclude`-ed).
2015-02-24 21:08:29 +08:00
Richard Grenville 3b17fe15f0 Bug fix #263: Always redirect std{out,err} if --logpath is specified
Always redirect std{out,err} if --logpath is specified, instead of only
redirect after fork, to correct the inconsistent behavior of --logpath
when getppid() returns 1. (#263)
2015-01-26 21:28:48 +08:00
Richard Grenville e4ff1a5130 Misc: Update disabled-at-compile-time notes in the usage text
- Add disabled-at-compile-time note in usage text with NO_LIBCONFIG.

 - Fix the incorrect disabled-at-compile-time note for --backend.

 - Move position of the disabled-at-compile-time note of --dbus
   slightly.
2015-01-11 16:24:54 +08:00
Richard Grenville 03ebae4c33 Bug fix: Compilation failure with NO_VSYNC_OPENGL=1
Fix compilation failure with NO_VSYNC_OPENGL=1, caused by one
incorrectly placed "#endif" in "src/common.h".
2015-01-11 10:47:19 +08:00