Commit Graph

424 Commits

Author SHA1 Message Date
Yuxuan Shui edbf7f430c
Initialize tls log structure in main
Fix error reporting when failed to open X display.

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

So, make sure they are freed.

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

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

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

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

Simplify the logic a little bit.

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

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

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

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

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

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

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

Extras:

Keep GL_BLEND enabled; Fixed some texture/fbo leaks

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 01:53:46 +00:00
Yuxuan Shui 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 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 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 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 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 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 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 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 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 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 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 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 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 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