If screen is not redirected, we don't need to reinitialize the backend
when we got a root change event.
Fixes#189
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
To prepare for different blur methods, the blur interface of backends
has been splitted into two parts.
Now to use blur, a blur context must be created first; then, the blur
method should be called with the blur context created.
Updated the existing backends to the new interface. Also implemented
handling of the new blur options.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Also fill the center of parsed kernel with 1. This shouldn't change the
behavior of the old backends since they will modify the center of the
kernels.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Delay focus updates until critical section. Rational is that focus
events might arrive when the focused window hasn't been managed by
compton, result in that that window not being focused.
This commit makes compton mark focus update events, and only update
focus in critical section, after we managed all the new windows.
Fixes#177
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
glGetIntegerv(GL_NUM_EXTENSIONS) is only available since GL4.
(However glGetStringi(GL_EXTENSIONS) is available since GL3)
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Remove more unused stuff.
Also removed session::xinerama_scrs, since all the information we need
is covered by xinerama_scr_regs. Convert uses of xinerama_scrs to use
xinerama_scr_regs.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
It used to be unmap when we receive its MapNotify, but now since we discard
events received before we grab X server, that event it lost. But it
turns out we can just unmap it when it's first created, no need to wait
for the MapNotify.
Partially fix#160
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
When a window is reparented to the same parent again, we should just
move it to the top of the stack, instead of add it again.
Also a slight refactor restack_win.
Fixes#164
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
If a window is unmapped, then mapped to a different position on screen
before fade out is completed (when fading is not enabled, it has to be
mapped again in the same frame), the old window content is left on screen.
This is because when this happens, we didn't add the unmapping window to
damage.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Using opacity_t for opacity_old resulting in opacity being rounded to 0.
This is fine until the opacity reaches 0, where the opacity != opacity_old
check fails and the damage is not added.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
If window is closed when fading is not enabled, the window might be destroyed
before we can add the window extent to damage.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
reg_ignore_valid marks the validity of the reg_ignore of the windows
BENEATH the current window. That is, set `w->reg_ignore_valid = false`
doesn't invalidate `w->reg_ignore`.
When destroying window `w`, we need to invalidate all reg_ignore beneath
`w`. So it is not enough to just set `w->next->reg_ignore_valid =
false`, we also need to invalidate `w->next->reg_ignore`.
Yes, this variable name is confusing. Will be changed in the future.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
When the screen is not redirected, don't update the root image because
the backend is not initialized in this case.
Fixes a crash.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
paint_preprocess calls redir_start if it decides to redirect the screen.
redir_start might change the state of the windows. For example, when the
image of the window fails to bind, redir_start sets the error flag. And
those state changes might exclude the window from being rendered. Thus,
paint_preprocess should be re-run to make sure the new states are
honoured.
Fixes a crash when window images fail to bind after redirecting.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
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>
Make sure before the mapping operation begins, the window is always in
UNUNMAPPED state. This makes it easier to reason about things, such as
resource availability, etc.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Previously we try to keep the image data until the rebind succeeds. This
way even if the rebind fails, we still have something to display.
But that triggers a NVIDIA driver bug. Basically you cannot have more
than one names (XIDs) of a window pixmap. NVIDIA driver doesn't like
that, and binding the pixmap with its aliases will fail. This can
sometimes happen if we name the new pixmap before freeing the old one during
rebind, and the pixmap doesn't actually change (i.e. the rebind is
unnecessary, could happen because of X event handling complications).
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Clear the STALE_IMAGE flag set by win_update_bounding_shape to avoid an
unnecessary image data invalidation.
Mainly to workaround a NVIDIA bug. For more detailed explanation, see
commit 8f67c6190c281955846589d8769385f30e7c5d23
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
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>
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>
Setting glx-swap-method to value other than "undefined" and "buffer-age"
could potentially cause rendering problems. So remove them, the meaning
of the remaining options can be more precisely captured by "use-damage",
so create a new option under that name.
--glx-swap-method is deprecated in favor of the new option --use-damage.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
struct _glx_image_data needs to be freed even when refcount is not 0.
Also fixed a typo in glx_bind_pixmap.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Rectangle textures was used as a fallback when the driver doesn't
support non-power-of-two (NPOT) textures. Since we are using OpenGL 3.0 now,
which includes support for NPOT textures, we don't need this fallback
anymore.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
blur_textures are not initialized when blur is disabled, but we still
try to resize them in gl_resize.
Don't do that.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>