Commit Graph

355 Commits

Author SHA1 Message Date
Yuxuan Shui 1e0deea57f
Improve the include situation
Slightly clean up header inclusion with the help of clang's module system.
It's better for files to include the things you need directly.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-18 23:30:44 +00:00
Yuxuan Shui c93789f5e9
Enable the glStringMarker logger when available
glStringMarker is usually only available when running under some
kind of GL debugger, and can be used to insert strings into the
GL command string. Writing logs using it can be useful, since it
lets us correspond GL calls with what happens in compton.

More info about the extension can be found here:

https://www.khronos.org/registry/OpenGL/extensions/GREMEDY/GREMEDY_string_marker.txt

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-09 21:58:16 +00:00
Yuxuan Shui 34eb14fb0f Tweak the default shadow-radius
We need to make the radius 1.5x bigger to achieve the same effect.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-02 11:14:27 +00:00
Yuxuan Shui 6d3ea3564b
Implement vsync for the new xrender backend
We use the Present extension for that, since it is the best option we
have.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-01 14:59:56 +00:00
Yuxuan Shui 6413ccbd71
Improve XSync extension detection
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-01 14:09:55 +00:00
Yuxuan Shui 428c24a6fa
Speed up shadow generation for small windows
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-01 11:35:59 +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 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 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 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 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 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
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 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 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 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 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 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 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 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 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 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 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 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