From 483717484afb4ccf5b48483b3a21a9fe91213dd4 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Tue, 20 Sep 2011 17:15:12 +0800 Subject: [PATCH] glamor-ddx: Destroy all the pixmap cursors when close current screen. As now we use pixmap to handle cursor, and pixmaps are related to current screen. If we close the screen, then we have to destroy all the related cursors. Signed-off-by: Zhigang Gong --- hw/xfree86/glamor/glamor_crtc.c | 37 +++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/glamor/glamor_crtc.c b/hw/xfree86/glamor/glamor_crtc.c index 854e81645..e86466abd 100644 --- a/hw/xfree86/glamor/glamor_crtc.c +++ b/hw/xfree86/glamor/glamor_crtc.c @@ -512,6 +512,34 @@ drmmode_hide_cursor (xf86CrtcPtr crtc) 0, 64, 64); } + +static void +_drmmode_destroy_cursor(xf86CrtcPtr crtc) +{ + drmmode_crtc_private_ptr + drmmode_crtc = crtc->driver_private; + + if (drmmode_crtc->cursor == NULL) + return; + drmmode_hide_cursor(crtc); + glamor_destroy_cursor(crtc->scrn, drmmode_crtc->cursor); + free(drmmode_crtc->cursor); + drmmode_crtc->cursor = NULL; +} + +static void +drmmode_destroy_cursor(ScrnInfoPtr scrn) +{ + int i; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + for (i = 0; i < xf86_config->num_crtc; i++) + _drmmode_destroy_cursor(xf86_config->crtc[i]); +} + + + + static void drmmode_show_cursor (xf86CrtcPtr crtc) { @@ -629,12 +657,7 @@ drmmode_crtc_destroy(xf86CrtcPtr crtc) drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; ScrnInfoPtr scrn = crtc->scrn; - if (drmmode_crtc->cursor) { - drmmode_hide_cursor(crtc); - glamor_destroy_cursor(scrn, drmmode_crtc->cursor); - free(drmmode_crtc->cursor); - drmmode_crtc->cursor = NULL; - } + _drmmode_destroy_cursor(crtc); free(drmmode_crtc->cursor); crtc->driver_private = NULL; } @@ -1539,6 +1562,8 @@ void drmmode_closefb(ScrnInfoPtr scrn) drmmode_crtc = xf86_config->crtc[0]->driver_private; drmmode = drmmode_crtc->drmmode; + drmmode_destroy_cursor(scrn); + drmModeRmFB(drmmode->fd, drmmode->fb_id); drmmode->fb_id = 0; }