Make potentially window destroying functions take simple pointers

Instead of pointer to pointer. The two level of pointers were used to
inform the caller the window has been destroyed (pointer set to NULL).

Now, destruction of windows are now signaled by the return value, which
is marked `must_use`.

Problem with taking pointer to pointer is that they tends to pollute the
function signatures a little bit. And we are not using it well anyways.
A lot of the callers passes pointers to local variables to those
functions, so the information about window destruction doesn't actually
bubble up. So, we switch to use just one level of pointers instead.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2019-09-16 22:14:34 +01:00
parent 127b1ac3a4
commit 48687b985d
4 changed files with 57 additions and 53 deletions

View File

@@ -11,8 +11,8 @@
#include <X11/Xlib-xcb.h>
#include <X11/Xlib.h>
#include <X11/extensions/sync.h>
#include <X11/Xutil.h>
#include <X11/extensions/sync.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
@@ -458,10 +458,8 @@ static struct managed_win *paint_preprocess(session_t *ps, bool *fade_running) {
add_damage_from_win(ps, w);
}
win_check_fade_finished(ps, &w);
if (!w) {
// the window might have been destroyed because fading finished
if (win_check_fade_finished(ps, w)) {
// the window has been destroyed because fading finished
continue;
}
@@ -657,10 +655,8 @@ static void rebuild_shadow_exclude_reg(session_t *ps) {
static void destroy_backend(session_t *ps) {
win_stack_foreach_managed_safe(w, &ps->window_stack) {
// Wrapping up fading in progress
win_skip_fading(ps, &w);
// `w` might be freed by win_check_fade_finished
if (!w) {
if (win_skip_fading(ps, w)) {
// `w` is freed by win_skip_fading
continue;
}
@@ -1276,7 +1272,7 @@ static void handle_new_windows(session_t *ps) {
map_win(ps, mw);
// This window might be damaged before we called fill_win
// and created the damage handle. And there is not way for
// and created the damage handle. And there is no way for
// us to find out. So just blindly mark it damaged
mw->ever_damaged = true;
add_damage_from_win(ps, mw);