Commit f5670b4a authored by Keith Packard's avatar Keith Packard

xfree86: Set xf86CrtcConfigRec cursor pointer to NULL in HideCursor

This makes the cursor pointer held by xf86Cursors.c get reset to NULL
whenever the cursor isn't displayed, and means that the reference
count held in xf86Cursor.c is sufficient to cover the reference in
xf86Cursors.c.

As HideCursor may be called in the cursor loading path after
UseHWCursor or UseHWCursorARGB when HARDWARE_CURSOR_UPDATE_UNHIDDEN
isn't set in the Flags field, the setting of the cursor pointer had to
be moved to the LoadCursor paths.

LoadCursorARGBCheck gets the cursor pointer, but LoadCursorImageCheck
does not. For LoadCursorImageCheck, I added a new function,
xf86CurrentCursor, which returns the current cursor. With this new
function, we can eliminate the cursor pointer from the
xf86CrtcConfigRec, once drivers are converted over to use it.
Signed-off-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
Acked-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent b64108fa
...@@ -287,7 +287,7 @@ xf86_set_cursor_colors(ScrnInfoPtr scrn, int bg, int fg) ...@@ -287,7 +287,7 @@ xf86_set_cursor_colors(ScrnInfoPtr scrn, int bg, int fg)
{ {
ScreenPtr screen = scrn->pScreen; ScreenPtr screen = scrn->pScreen;
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
CursorPtr cursor = xf86_config->cursor; CursorPtr cursor = xf86CurrentCursor(screen);
int c; int c;
CARD8 *bits = cursor ? CARD8 *bits = cursor ?
dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen) dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen)
...@@ -456,6 +456,7 @@ xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src) ...@@ -456,6 +456,7 @@ xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src)
CARD8 *cursor_image; CARD8 *cursor_image;
const Rotation rotation = xf86_crtc_cursor_rotation(crtc); const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
xf86_config->cursor = xf86CurrentCursor(xf86ScrnToScreen(scrn));
crtc->cursor_argb = FALSE; crtc->cursor_argb = FALSE;
if (rotation == RR_Rotate_0) if (rotation == RR_Rotate_0)
...@@ -517,11 +518,6 @@ xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor) ...@@ -517,11 +518,6 @@ xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
int c; int c;
cursor = RefCursor(cursor);
if (xf86_config->cursor)
FreeCursor(xf86_config->cursor, None);
xf86_config->cursor = cursor;
if (cursor->bits->width > cursor_info->MaxWidth || if (cursor->bits->width > cursor_info->MaxWidth ||
cursor->bits->height > cursor_info->MaxHeight) cursor->bits->height > cursor_info->MaxHeight)
return FALSE; return FALSE;
...@@ -593,6 +589,7 @@ xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor) ...@@ -593,6 +589,7 @@ xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor)
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
int c; int c;
xf86_config->cursor = cursor;
for (c = 0; c < xf86_config->num_crtc; c++) { for (c = 0; c < xf86_config->num_crtc; c++) {
xf86CrtcPtr crtc = xf86_config->crtc[c]; xf86CrtcPtr crtc = xf86_config->crtc[c];
...@@ -638,7 +635,6 @@ xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags) ...@@ -638,7 +635,6 @@ xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags)
cursor_info->LoadCursorARGBCheck = xf86_load_cursor_argb; cursor_info->LoadCursorARGBCheck = xf86_load_cursor_argb;
} }
xf86_config->cursor = NULL;
xf86_hide_cursors(scrn); xf86_hide_cursors(scrn);
return xf86InitCursor(screen, cursor_info); return xf86InitCursor(screen, cursor_info);
...@@ -681,7 +677,7 @@ xf86_reload_cursors(ScreenPtr screen) ...@@ -681,7 +677,7 @@ xf86_reload_cursors(ScreenPtr screen)
if (!cursor_info) if (!cursor_info)
return; return;
cursor = xf86_config->cursor; cursor = xf86CurrentCursor(screen);
GetSpritePosition(inputInfo.pointer, &x, &y); GetSpritePosition(inputInfo.pointer, &x, &y);
if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
(*cursor_info->HideCursor) (scrn); (*cursor_info->HideCursor) (scrn);
...@@ -716,8 +712,5 @@ xf86_cursors_fini(ScreenPtr screen) ...@@ -716,8 +712,5 @@ xf86_cursors_fini(ScreenPtr screen)
} }
free(xf86_config->cursor_image); free(xf86_config->cursor_image);
xf86_config->cursor_image = NULL; xf86_config->cursor_image = NULL;
if (xf86_config->cursor) { xf86_config->cursor = NULL;
FreeCursor(xf86_config->cursor, None);
xf86_config->cursor = NULL;
}
} }
...@@ -462,6 +462,15 @@ xf86ForceHWCursor(ScreenPtr pScreen, Bool on) ...@@ -462,6 +462,15 @@ xf86ForceHWCursor(ScreenPtr pScreen, Bool on)
} }
} }
CursorPtr
xf86CurrentCursor(ScreenPtr pScreen)
{
xf86CursorScreenPtr ScreenPriv =
(xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
xf86CursorScreenKey);
return ScreenPriv->CurrentCursor;
}
xf86CursorInfoPtr xf86CursorInfoPtr
xf86CreateCursorInfoRec(void) xf86CreateCursorInfoRec(void)
{ {
......
...@@ -61,6 +61,7 @@ extern _X_EXPORT xf86CursorInfoPtr xf86CreateCursorInfoRec(void); ...@@ -61,6 +61,7 @@ extern _X_EXPORT xf86CursorInfoPtr xf86CreateCursorInfoRec(void);
extern _X_EXPORT void xf86DestroyCursorInfoRec(xf86CursorInfoPtr); extern _X_EXPORT void xf86DestroyCursorInfoRec(xf86CursorInfoPtr);
extern _X_EXPORT void xf86CursorResetCursor(ScreenPtr pScreen); extern _X_EXPORT void xf86CursorResetCursor(ScreenPtr pScreen);
extern _X_EXPORT void xf86ForceHWCursor(ScreenPtr pScreen, Bool on); extern _X_EXPORT void xf86ForceHWCursor(ScreenPtr pScreen, Bool on);
extern _X_EXPORT CursorPtr xf86CurrentCursor(ScreenPtr pScreen);
#define HARDWARE_CURSOR_INVERT_MASK 0x00000001 #define HARDWARE_CURSOR_INVERT_MASK 0x00000001
#define HARDWARE_CURSOR_AND_SOURCE_WITH_MASK 0x00000002 #define HARDWARE_CURSOR_AND_SOURCE_WITH_MASK 0x00000002
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment