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>
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>
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>
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>
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>
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>
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>