[PATCH xserver 1/2] present: implement `present_event_abandon()`
Olivier Fourdan
ofourdan at redhat.com
Mon Oct 8 14:46:32 UTC 2018
The function `present_event_abandon()` is marked as exported in the
present.h header but it's nowhere to be found.
Such a function might prove handy for the DDX such as Xwayland who
creates and destroys CRTCs as new outputs are added or removed.
`present_event_abandon()` checks all vblank for all windows for the
given CRTC and abort those who match, so that we don't leave events
behind referring to a `RRCtrcPtr` pointing to freed memory.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
Bugzilla: https://bugs.freedesktop.org/108249
---
present/present_screen.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/present/present_screen.c b/present/present_screen.c
index c7e37c5fd..35a106ada 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -167,6 +167,38 @@ present_destroy_window(WindowPtr window)
return ret;
}
+static int
+check_vblank_crtc(WindowPtr window, void *value)
+{
+ ScreenPtr screen = window->drawable.pScreen;
+ present_window_priv_ptr window_priv = present_window_priv(window);
+ present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+ present_vblank_ptr vblank, tmp;
+ RRCrtcPtr target_crtc = value;
+
+ if (!window_priv)
+ return WT_WALKCHILDREN;
+
+ xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->vblank, window_list) {
+ if (target_crtc == vblank->crtc) {
+ screen_priv->abort_vblank(window->drawable.pScreen,
+ window, vblank->crtc,
+ vblank->event_id, vblank->target_msc);
+ present_vblank_destroy(vblank);
+ }
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+void
+present_event_abandon(RRCrtcPtr crtc)
+{
+ ScreenPtr pScreen = crtc->pScreen;
+
+ WalkTree(pScreen, check_vblank_crtc, (void *) crtc);
+}
+
/*
* Hook the config notify screen function to deliver present config notify events
*/
--
2.19.0
More information about the xorg-devel
mailing list