Commit Graph

704 Commits

Author SHA1 Message Date
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
Yuxuan Shui 6c71146f1c
Don't call map_win() in add_win()
Only case where you want to map window in add_win() is during compton
startup, when compton is registering existing windows. Otherwise,
add_win() is always called for newly created windows, so there will
always be a MapNotify coming up for that window. If we map newly created
windows in add_win(), we will try to map it a second time when the MapNotify
arrives.

So, just don't call map_win() from add_win(). For compton startup, we
explicitly call map_win() after calling add_win() in session_init.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 02:29:06 +00:00
Yuxuan Shui ff37cf9756
Don't start fading when screen is unredirected
If a window is destroyed and starts to fade out when screen is
unredirected, when the screen become redirected again, we will generate
errors when trying to render that window.

Also make sure the assumption that all window are either MAPPED or
UNMAPPED when screen is unredirected holds.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 02:12:07 +00:00
Yuxuan Shui 9aaf0fc707
Fix a use-after-free
paint_preprocess takes head of the window list as an argument. The
actual head of the window list might be freed and deleted during processing
of fade, but paint_preprocess will keep using the old head of the list,
thus uses freed memory.

Solution is just don't pass the head as an argument. paint_preprocess
will use session_t::list directly.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-21 01:40:04 +00:00
Yuxuan Shui 64e08cc1e3
Fix memory leaks when using the new backends
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 18:21:40 +00:00
Yuxuan Shui c2f274ca8a
Fix some problems in new backend integration
Fix several use of uninitialized/unallocated variables when using
--experimental-backends

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 18:17:16 +00:00
Yuxuan Shui 417e12bc62
Don't call init_render when using new backends
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 18:04:04 +00:00
Yuxuan Shui b0c5db9f5a
Let old/new backends co-exist
Now both the old and the new backends are compiled in, the user can
choose which one to use with a command line switch.

Lower the barrier for testing.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 17:52:24 +00:00
Yuxuan Shui 62d4c0cbdb
Cut fading short if we decide to unredirect the screen
Previously if we unredirect the screen while a fading is in progress, we
will "resume" the fading when we redirect the screen again.

This is usually fine unless the window being faded out is destroyed. we
still tries to fade it out, but since we don't have the pixmap of the
window anymore (freed by unredirect), we will generate lots of errors
until the window is completely "faded out".

Also this change makes it easy to reason about things. Now we know when
the screen is unredirected, all the windows can either be in MAPPED or
UNMAPPED state, nothing else.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 17:41:28 +00:00
Yuxuan Shui 9ec298305a
Cache converted blur kernel
After converting from struct conv to xorg format, cache the result to
save CPU time.

And remove an unused function.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 16:45:53 +00:00
Yuxuan Shui ed9c7064de
Add helper function for kernel normalization
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 01:47:52 +00:00
Yuxuan Shui a5e3837f6d
Fix typo
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 01:45:34 +00:00
Yuxuan Shui 2e2e8e3ce0
Use struct conv for blur kernel as well
Instead of storing them as an array of xfixed.

Might cause some performance overhead for the new backend, because
it is allocating a buffer to do the conversion every frame. Will fix
later.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 01:39:43 +00:00
Yuxuan Shui ae9dee8a9a
Remove the remaining users of win::destroying
And remove win::destroying as well.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 01:21:58 +00:00
Yuxuan Shui 709065d531
Destroy Input Only window properly
Destruction of Input Only windows is erroneously ignored by commit
cea010a, causing future window with the same window id as the destroyed
Input Only window to be treated by an Input Only window even when they
are not. The end result is that some windows don't show up.

Also improved the comments in win.c.

Fixes #119

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 01:11:13 +00:00
Yuxuan Shui 02ddf96fd5
Remove leftover CONFIG_XINERAMAs
Fixes #118

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-19 20:48:31 +00:00
Yuxuan Shui bb8fd08b5b
Fix a compiler complaint
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-18 21:32:49 +00:00
Yuxuan Shui 2a41847aa6
Make xinerama mandatory
Fixes #116

Also tweaks the usage message a bit.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-18 21:05:12 +00:00
Yuxuan Shui b2750b26e0
Rectangle kernels
Replace conv::size with conv::{w,h}.

Shadow kernels are still squares, though.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-17 21:58:43 +00:00
Yuxuan Shui cea010afec
Ignore the map/unmap of input only windows
Fixes some misleading warning messages.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-17 18:27:19 +00:00
Yuxuan Shui 635351c820
Remove win::*_last
A side effect of this is that some window properties are allowed to
change during fade-in/out. (e.g. window background can become blurred
during window fade out if window properties changed so blur is requirired).
But it is unclear what is the expected behaviour in this case anyway, so we
choose the one that is simpler to implement.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-17 18:12:41 +00:00
Yuxuan Shui ed4202b52f
Fix memory leaks
Restrict the use of ps_g to xerror() and main().

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-17 16:59:22 +00:00
Yuxuan Shui e0d394595b
Remove session_t::fade_running
It is used more as a out variable for paint_preprocess, so make it that.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-17 16:48:41 +00:00
Yuxuan Shui a826e0ce79
Window state tracking refactor
Window state tracking is basically the back bond of window fading. We
add a new enum field to the win struct to track the state of the window,
instead of using a set of boolean variables. We also remove the fading
callbacks, since it is only used for fading, so the potential of code
reuse is lost. And it makes the code slightly harder to understand.

Also fixed a problem that --no-fading-openclose is not behaving as
advertised (from my observation, enabling this flag disables fading
entirely, instead of just diabling it for open/close).

Also uses double for opacity everywhere internally. Use opacity_t only
when setting X opacity prop.

TODO: Remove win::*_last

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-17 16:37:28 +00:00
Yuxuan Shui e109bee380
Fix some clang-analyzer complains
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-13 04:23:54 +00:00
Yuxuan Shui 7cdc0aedee
log.h needs to export compiler.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-13 04:18:32 +00:00
Yuxuan Shui bb7466fc68
trace/debug logs are unlikely
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-13 04:11:41 +00:00
Yuxuan Shui 60aa36b7af
Failure of config file parsing is a hard failure
compton will now quit if it fails to parse the config file.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-13 02:05:01 +00:00
Yuxuan Shui 7a21cef9a4
Handle SIGINT through libev
Handle SIGINT using libev's ev_signal handler, instead of using
sigaction().

Fixes #64. But compton might miss signals when it's not in the main loop
(e.g. when compton is reset), and thus not exit "clearly". It should
cause any real problem though, so we don't care.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-11 23:13:39 +00:00
Yuxuan Shui df69749804
Don't remove stderr logger if it fail to create
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-11 22:58:16 +00:00
Yuxuan Shui fc2353d186
Tolerant logger creation failure
Fix resetting a background compton

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-09 02:49:16 +00:00
Yuxuan Shui 39faac0f83
Blacklist more glx.h prototypes just in case
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-09 00:52:45 +00:00
Yuxuan Shui 136ce7c9e8
Prevent GL/glx.h from defining prototypes
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-09 00:43:31 +00:00
Yuxuan Shui 4c99ecfde4
Fix compile without opengl
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-09 00:16:47 +00:00
Yuxuan Shui 7e9d1c6442
Condense GLX extension lookup
Put them all into one function, and move the function pointers out of
glx_session_t, making them global variables (because them don't change
after initialized). Remove the function pointer typedefs and replace
them with the ones in glxext.h

We also only lookup the functions once per a lifetime of compton.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-09 00:14:32 +00:00
Yuxuan Shui 1a327b06ab
Fix abort because we used log too early
Can't use log in get_early_config.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-08 22:46:28 +00:00
Yuxuan Shui 343140f845
Reuse glx_has_extension for old backend
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-08 22:34:53 +00:00
Yuxuan Shui edb8b38eef
Tile root pixmap in the glx backend
In X, background pixmap is tiled (meaning they are repeated to filled
the window) by default. So, in the glx backend, we mimic this behavior
by binding the background pixmap of the root window (aka, the wallpaper)
to texture that repeats.

Fixes #107

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-08 21:48:39 +00:00
Yuxuan Shui 5fffb6f3f6
Fork as early as possible
If fork is requested, we fork as early as possible, way before anything
is initialized. This way, we don't need to do the gymnastics to make
OpenGL work properly across fork.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-08 01:33:42 +00:00
Yuxuan Shui fec43acfaa
Add missing headers
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-07 22:47:42 +00:00
Yuxuan Shui 33c1cd439b
Fix memory leak of dbus service names
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-07 22:47:32 +00:00
Yuxuan Shui a019ff453b
Make get_early_config even earlier
Also improve the management of X Display and session_t.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-07 22:45:44 +00:00
Yuxuan Shui 2867ac7a1c
Remove unused screenshot code
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-07 22:16:32 +00:00
Yuxuan Shui 68c77cd7d8
Add log_remove_target
Don't need to deinit+init struct log any more just to switch log target
:)

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-07 21:50:20 +00:00
Yuxuan Shui 22bc79369e
Review the use of XFlush and xcb_flush
Replace most of XFlush with xcb_flush.

Also, in a lot of places, XFlush is used as if it is XSync. Replace
those cases by using xcb's _checked version of functions and
xcb_request_check.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-07 01:11:13 +00:00
Yuxuan Shui 856ad4b230
Wrap root window background prop check
It might be reused by the backends.

Depends on what the backend API ends up look like.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-07 00:34:48 +00:00
Yuxuan Shui 7d00b89364
x_get_pictform_for_visual should return const *
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-07 00:22:16 +00:00
Yuxuan Shui aa9c439cc6
Improve the interface of glx_find_fbconfig
Remove the dependence of xcb_render types in glx.h

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-07 00:04:43 +00:00
Yuxuan Shui f19766f15a
Fix FBConfig cost calculation
Double buffering only doubles the color buffer, not the depth and
stencil.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 19:33:31 +00:00
Yuxuan Shui 2263bab2ff
Consider buffer size and double buffering as well
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 19:15:30 +00:00
Yuxuan Shui 519bf8500b
Prefer FBConfig with smaller depth + stencil buffer
Reduce GPU memory usage to what it was before fix-fbconfig.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 19:06:33 +00:00
Yuxuan Shui 39b612a8a4
Delete irrelevant comments
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 18:53:28 +00:00
Yuxuan Shui b1d8687b31
Add copyright notice to backend/**
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 18:47:36 +00:00
Yuxuan Shui 388a7f3ad4
Fix leaking of root_tile FBConfig
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 18:41:47 +00:00
Yuxuan Shui 24370f44e6
Cache FBConfig used for shadows
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 18:41:47 +00:00
Yuxuan Shui 8922312e42
Refactor FBConfig lookup
Background: To bind a Xorg window content to a OpenGL FBConfig, which
has to match the color format the Xorg window is using.

Previously, compton just find a FBConfig that has the same depth. This
led to chjj/compton#477, which has been fixed by a ugly hack.

The commit refactor the lookup mechanism to take as much into
consideration as we reasonably can. Hopefully preventing similar
breakages in the future.

Also, some code sharing between the old and new glx backend.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 18:41:47 +00:00
Yuxuan Shui 7ac351e5b5
Move some default_* functions to backend_common.c
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 18:41:02 +00:00
Yuxuan Shui b061789a84
Add helper function x_get_visual_depth
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 16:49:04 +00:00
Yuxuan Shui 17c8517abc
Most of the x_* functions don't need session_t
Replace session_t parameter with xcb_connection_t if that's the only
thing needed.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 15:59:31 +00:00
Yuxuan Shui ad3dc5d233
Move session_t::pictfmts into x.c
As a global variable, since they shouldn't change during the period
compton is running. Also limit the scope of the variable to x.c.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-03 15:14:18 +00:00
Yuxuan Shui 0be3fb5ea2
Remove some unused macros/ifdefs
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-02 22:19:15 +00:00
Yuxuan Shui eadb09ee0d
Remove glx_mark
glx_mark is part of the logging system now, so no need for the old
functions.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-02 22:05:53 +00:00
Yuxuan Shui 7d10db6531
Move deallocation of damage_ring to deinit_render
Fix a memory leak when compton is reset.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-02 22:05:43 +00:00
Yuxuan Shui 6eff9ebf8b
Variable name change
win::destroyed to win::destroying, because it make slightly more sense.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-02 19:43:42 +00:00
Yuxuan Shui 8371d6a0b7
Replace glDrawBuffers with glDrawBuffers
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-02 19:30:07 +00:00
Yuxuan Shui 94505bbcf4
Fix compiling on older gcc
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-02 02:12:08 +00:00
Yuxuan Shui 0947148fcc
Fix compiler warnings
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-02 02:00:15 +00:00
Yuxuan Shui 465a968ddd
Parse number locale-independently
Previously we were using glibc's strtod function to parse floating point
numbers. The problem is, strtod is locale dependent. Meaning 7,7 might
be parsed as two numbers (7 and 7) in one locale, and parsed as one
number (7 point 7) in another locale. This is undesirable.

We need to set the locale to a value we know to make number parsing
consistently. We could use setlocale(), but that is not thread-safe. We
can also use uselocale(), which is thread-safe, but doesn't cover strtod
(Yeah, some of the locale-aware functions only acknowledge the global
locale, not the thread local one).

So in frustration, I just wrote a simple floating point number parser
myself. This parser obviously doesn't cover all cases strtod covers, but
is good enough for our needs.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-02 01:28:15 +00:00
Yuxuan Shui 3f5a4d570c
Fix memory leak in glx_init_blur
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-31 22:47:04 +00:00
Yuxuan Shui b76a4234e5
Fix NULL dereference in glx_update_fbconfig
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-31 22:46:12 +00:00
Yuxuan Shui 543bbe6a39
Fix NULL pointer dereference in glx_init_blur
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-31 22:40:17 +00:00
Yuxuan Shui 205427d7da
Exit with exit code 1 when argument parsing failed
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-30 22:19:05 +00:00
Yuxuan Shui c11c24b3f2
Improve config file search order
Previously the search order is:

~/.config/compton/compton.conf
/etc/xdg/compton/compton.conf
~/.config/compton.conf
/etc/xdg/compton.conf
...

Now the search order is:

~/.config/compton/compton.conf
~/.config/compton.conf
~/.compton.conf
/etc/xdg/compton/compton.conf
...

In other word, compton will now search all possible user config file
path first before searching for a system config file.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-30 00:27:14 +00:00
Yuxuan Shui f7d4dff099
Use strncpy for string_utils functions
Also removed mstrjoin3 since it's not used.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-30 00:12:12 +00:00
Yuxuan Shui 9d64decf2a
`compton -h` should quit after printing help
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-29 23:36:34 +00:00
Yuxuan Shui 1627a91c76
Use glDrawBuffer instead of glDrawBuffers in glx_blur_dst
glDrawBuffers doesn't take GL_BACK, which is what we are passing. And we
are using only one buffer argument anyway, no need to use glDrawBuffers.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-29 23:18:44 +00:00
Yuxuan Shui 4e14eec2ba
Remove a redundant glEnd in glx_dim_dst
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-29 22:27:05 +00:00
Antonin Décimo 8366310daf Fix small misspellings 2019-01-28 10:58:14 +01:00
Yuxuan Shui 198dcdb987
gl_common: fix coordinate mismatch
Xorg uses top left as origin, OpenGL uses lower left. So we need to flip
the y axis, and make sure we are using the right points as origin of
windows.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-28 01:14:41 +00:00
Yuxuan Shui 3b21365e94
gl_common: fix rendering
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-28 00:48:26 +00:00
Yuxuan Shui 6e454adff1
glx (new backend): Add some missing functions
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-28 00:04:01 +00:00
Yuxuan Shui 8c71f3fcbe
Move some macros around
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-27 23:57:43 +00:00
Yuxuan Shui 5364c8ac9b
Add backend_info_t::max_buffer_age
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-27 19:45:40 +00:00
Yuxuan Shui d92a546beb
Fix includes and typos in new backends 2019-01-27 19:34:26 +00:00
Yuxuan Shui 22f0d10c65
Make backend_info_t::buffer_age optional
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-27 19:32:07 +00:00
Yuxuan Shui b50f15c835
Adapt paint_all_new to new interface
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-27 19:29:02 +00:00
Yuxuan Shui e898526afb
Add glx_backend to backend_list
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-27 19:28:15 +00:00
Yuxuan Shui 99b3c4575f
Fix handling of region == NULL in paint_all_new
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-27 18:21:42 +00:00
Yuxuan Shui 061dd8e52e
Reuse some code from the new gl backend
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-27 18:16:28 +00:00
Yuxuan Shui 290ec7fb04
Don't pretend that we have glStringMarker
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-27 17:45:38 +00:00
Yuxuan Shui 6c6dd6ad7d
Remove unused session_t argument from gl_has_extension
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-26 23:08:32 +00:00
Yuxuan Shui 031356069a
new glx: Add glx_present
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-26 18:01:24 +00:00
yshui 4bc2870ddf
Merge pull request #86 from yshui/damage-ring
Make buffer age not glx specific
2019-01-26 15:11:13 +00:00
Yuxuan Shui e80ff8530e
Make buffer age not glx specific
Buffer age is not a glx specific concept. xrender backend can have
buffer age too, if double buffering is used (required if we want to use
Present). So, make buffer age a generic concept in compton is required
for further backend improvements.

Moved buffer age based damage aggragation out of glx as well.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-26 15:07:09 +00:00
Yuxuan Shui 5e49ab0861
Make sure draw_idle is stopped in all cases
Previously, compton fails to stop draw_idle in some cases when sw_opti
is enabled.

sw_opti is a feature that limits the draw frequence to vblank frequence.
It adds a delay to drawing when the screen is updated more frequently
than the vblank frequence. However when the delay is not used (i.e. the
screen is updated infrequent enough), compton will start drawing the
frame directly without using the delay. And specically in this case,
compton will fail to stop the draw_idle, causing a callback to be called
once per loop of the mainloop, resulting in high CPU usage.

Fixes #92

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-25 00:35:24 +00:00
Yuxuan Shui f649a949e2
Even more includes
Expand the modulemap to cover some of the system headers too.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-20 22:09:22 +00:00
Yuxuan Shui 916e23861a
Improve the header includes, cont'd
Also check in the modulemap file, and add a option to build with clang's
-fmodules.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-20 17:10:06 +00:00
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 dd02ea31ae
Fix copying damage region with wrong size
Fortunately this hasn't caused problems...

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-08 21:34:56 +00:00
Yuxuan Shui 72e3468694
Add backend_info_t::buffer_age
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-08 21:32:54 +00:00
Yuxuan Shui 82e8b09d56
Move paint_all_new to backend.c
Fix build with -Dnew_backends=false. And more build test for this case.

Fixes #83

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-01-02 20:36:33 +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