Commit Graph

1179 Commits

Author SHA1 Message Date
Yuxuan Shui f93f697759
Remove several unnecessary experimental_backends check
Window flags can be set whichever backend we use, we will ignore then in
paint_preprocess. free_paint can be called whichever backend we use,
they just do nothing if we use experimental backends.

Others should rather just check if backend_data is NULL.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:29 +01:00
Yuxuan Shui 27603343a1
list: add list_replace
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:29 +01:00
Yuxuan Shui adc52798db
README: mentions how to specify header/library path
Closes #155

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

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

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

Do window image update before the checks.

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

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

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

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

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

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

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00
Yuxuan Shui 532a90d573
Use __builtin_isnan
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00