2007-03-15 07:59:29 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2007 Keith Packard
|
2011-08-25 19:19:48 +02:00
|
|
|
* Copyright © 2010-2011 Aaron Plattner
|
2007-03-15 07:59:29 +01:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
|
|
* that the name of the copyright holders not be used in advertising or
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. The copyright holders make no representations
|
|
|
|
* about the suitability of this software for any purpose. It is provided "as
|
|
|
|
* is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
* OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#else
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2010-06-01 12:05:47 +02:00
|
|
|
#include <X11/Xarch.h>
|
2007-03-15 07:59:29 +01:00
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86DDC.h"
|
|
|
|
#include "xf86Crtc.h"
|
|
|
|
#include "xf86Modes.h"
|
|
|
|
#include "xf86RandR12.h"
|
2008-03-18 00:14:43 +01:00
|
|
|
#include "xf86CursorPriv.h"
|
2007-03-15 07:59:29 +01:00
|
|
|
#include "X11/extensions/render.h"
|
2009-07-15 08:51:05 +02:00
|
|
|
#include "X11/extensions/dpmsconst.h"
|
2007-03-15 07:59:29 +01:00
|
|
|
#include "X11/Xatom.h"
|
|
|
|
#include "picturestr.h"
|
|
|
|
#include "cursorstr.h"
|
2007-03-19 00:12:56 +01:00
|
|
|
#include "inputstr.h"
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2011-08-25 19:19:48 +02:00
|
|
|
/*
|
|
|
|
* Returns the rotation being performed by the server. If the driver indicates
|
|
|
|
* that it's handling the screen transform, then this returns RR_Rotate_0.
|
|
|
|
*/
|
|
|
|
static Rotation
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_cursor_rotation(xf86CrtcPtr crtc)
|
2011-08-25 19:19:48 +02:00
|
|
|
{
|
|
|
|
if (crtc->driverIsPerformingTransform)
|
2012-03-21 20:55:09 +01:00
|
|
|
return RR_Rotate_0;
|
2011-08-25 19:19:48 +02:00
|
|
|
return crtc->rotation;
|
|
|
|
}
|
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
/*
|
|
|
|
* Given a screen coordinate, rotate back to a cursor source coordinate
|
|
|
|
*/
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_rotate_coord(Rotation rotation,
|
|
|
|
int width,
|
|
|
|
int height, int x_dst, int y_dst, int *x_src, int *y_src)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2007-07-14 18:03:40 +02:00
|
|
|
int t;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-07-14 18:03:40 +02:00
|
|
|
switch (rotation & 0xf) {
|
|
|
|
case RR_Rotate_0:
|
2012-03-21 20:55:09 +01:00
|
|
|
break;
|
2007-07-14 18:03:40 +02:00
|
|
|
case RR_Rotate_90:
|
2012-03-21 20:55:09 +01:00
|
|
|
t = x_dst;
|
|
|
|
x_dst = height - y_dst - 1;
|
|
|
|
y_dst = t;
|
|
|
|
break;
|
2007-07-14 18:03:40 +02:00
|
|
|
case RR_Rotate_180:
|
2012-03-21 20:55:09 +01:00
|
|
|
x_dst = width - x_dst - 1;
|
|
|
|
y_dst = height - y_dst - 1;
|
|
|
|
break;
|
2007-07-14 18:03:40 +02:00
|
|
|
case RR_Rotate_270:
|
2012-03-21 20:55:09 +01:00
|
|
|
t = x_dst;
|
|
|
|
x_dst = y_dst;
|
|
|
|
y_dst = width - t - 1;
|
|
|
|
break;
|
2007-07-14 18:03:40 +02:00
|
|
|
}
|
2007-03-15 07:59:29 +01:00
|
|
|
if (rotation & RR_Reflect_X)
|
2012-03-21 20:55:09 +01:00
|
|
|
x_dst = width - x_dst - 1;
|
2007-03-15 07:59:29 +01:00
|
|
|
if (rotation & RR_Reflect_Y)
|
2012-03-21 20:55:09 +01:00
|
|
|
y_dst = height - y_dst - 1;
|
2007-07-14 18:03:40 +02:00
|
|
|
*x_src = x_dst;
|
|
|
|
*y_src = y_dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a cursor source coordinate, rotate to a screen coordinate
|
|
|
|
*/
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_rotate_coord_back(Rotation rotation,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int x_dst, int y_dst, int *x_src, int *y_src)
|
2007-07-14 18:03:40 +02:00
|
|
|
{
|
|
|
|
int t;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-07-14 18:03:40 +02:00
|
|
|
if (rotation & RR_Reflect_X)
|
2012-03-21 20:55:09 +01:00
|
|
|
x_dst = width - x_dst - 1;
|
2007-07-14 18:03:40 +02:00
|
|
|
if (rotation & RR_Reflect_Y)
|
2012-03-21 20:55:09 +01:00
|
|
|
y_dst = height - y_dst - 1;
|
2007-07-14 18:03:40 +02:00
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
switch (rotation & 0xf) {
|
|
|
|
case RR_Rotate_0:
|
2012-03-21 20:55:09 +01:00
|
|
|
break;
|
2007-03-15 07:59:29 +01:00
|
|
|
case RR_Rotate_90:
|
2012-03-21 20:55:09 +01:00
|
|
|
t = x_dst;
|
|
|
|
x_dst = y_dst;
|
|
|
|
y_dst = width - t - 1;
|
|
|
|
break;
|
2007-03-15 07:59:29 +01:00
|
|
|
case RR_Rotate_180:
|
2012-03-21 20:55:09 +01:00
|
|
|
x_dst = width - x_dst - 1;
|
|
|
|
y_dst = height - y_dst - 1;
|
|
|
|
break;
|
2007-03-15 07:59:29 +01:00
|
|
|
case RR_Rotate_270:
|
2012-03-21 20:55:09 +01:00
|
|
|
t = x_dst;
|
|
|
|
x_dst = height - y_dst - 1;
|
|
|
|
y_dst = t;
|
|
|
|
break;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
2007-07-14 18:03:40 +02:00
|
|
|
*x_src = x_dst;
|
|
|
|
*y_src = y_dst;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
2010-11-16 05:43:18 +01:00
|
|
|
struct cursor_bit {
|
|
|
|
CARD8 *byte;
|
|
|
|
char bitpos;
|
|
|
|
};
|
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
/*
|
|
|
|
* Convert an x coordinate to a position within the cursor bitmap
|
|
|
|
*/
|
2010-11-16 05:43:18 +01:00
|
|
|
static struct cursor_bit
|
2012-03-21 20:55:09 +01:00
|
|
|
cursor_bitpos(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y,
|
|
|
|
Bool mask)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2010-11-16 05:43:18 +01:00
|
|
|
const int flags = cursor_info->Flags;
|
|
|
|
const Bool interleaved =
|
2012-03-21 20:55:09 +01:00
|
|
|
! !(flags & (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
|
|
|
|
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 |
|
|
|
|
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 |
|
|
|
|
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 |
|
|
|
|
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64));
|
2010-11-16 05:43:18 +01:00
|
|
|
const int width = cursor_info->MaxWidth;
|
|
|
|
const int height = cursor_info->MaxHeight;
|
|
|
|
const int stride = interleaved ? width / 4 : width / 8;
|
|
|
|
|
|
|
|
struct cursor_bit ret;
|
|
|
|
|
|
|
|
image += y * stride;
|
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
if (flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK)
|
2012-03-21 20:55:09 +01:00
|
|
|
mask = !mask;
|
2007-03-15 07:59:29 +01:00
|
|
|
if (flags & HARDWARE_CURSOR_NIBBLE_SWAPPED)
|
2012-03-21 20:55:09 +01:00
|
|
|
x = (x & ~3) | (3 - (x & 3));
|
2008-03-20 14:18:29 +01:00
|
|
|
if (((flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) == 0) ==
|
2012-03-21 20:55:09 +01:00
|
|
|
(X_BYTE_ORDER == X_BIG_ENDIAN))
|
|
|
|
x = (x & ~7) | (7 - (x & 7));
|
2007-03-15 07:59:29 +01:00
|
|
|
if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1)
|
2012-03-21 20:55:09 +01:00
|
|
|
x = (x << 1) + mask;
|
2007-03-15 07:59:29 +01:00
|
|
|
else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8)
|
2012-03-21 20:55:09 +01:00
|
|
|
x = ((x & ~7) << 1) | (mask << 3) | (x & 7);
|
2007-03-15 07:59:29 +01:00
|
|
|
else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16)
|
2012-03-21 20:55:09 +01:00
|
|
|
x = ((x & ~15) << 1) | (mask << 4) | (x & 15);
|
2007-03-15 07:59:29 +01:00
|
|
|
else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32)
|
2012-03-21 20:55:09 +01:00
|
|
|
x = ((x & ~31) << 1) | (mask << 5) | (x & 31);
|
2007-03-15 07:59:29 +01:00
|
|
|
else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64)
|
2012-03-21 20:55:09 +01:00
|
|
|
x = ((x & ~63) << 1) | (mask << 6) | (x & 63);
|
2010-11-16 05:43:18 +01:00
|
|
|
else if (mask)
|
2012-03-21 20:55:09 +01:00
|
|
|
image += stride * height;
|
2010-11-16 05:43:18 +01:00
|
|
|
|
|
|
|
ret.byte = image + (x / 8);
|
|
|
|
ret.bitpos = x & 7;
|
|
|
|
|
|
|
|
return ret;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fetch one bit from a cursor bitmap
|
|
|
|
*/
|
|
|
|
static CARD8
|
2012-03-21 20:55:09 +01:00
|
|
|
get_bit(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2010-11-16 05:43:18 +01:00
|
|
|
struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-11-16 05:43:18 +01:00
|
|
|
return (*bit.byte >> bit.bitpos) & 1;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set one bit in a cursor bitmap
|
|
|
|
*/
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
set_bit(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2010-11-16 05:43:18 +01:00
|
|
|
struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-11-16 05:43:18 +01:00
|
|
|
*bit.byte |= 1 << bit.bitpos;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2014-04-25 17:22:15 +02:00
|
|
|
/*
|
|
|
|
* Wrappers to deal with API compatibility with drivers that don't expose
|
|
|
|
* load_cursor_*_check
|
|
|
|
*/
|
|
|
|
static inline Bool
|
|
|
|
xf86_driver_has_load_cursor_image(xf86CrtcPtr crtc)
|
|
|
|
{
|
|
|
|
return crtc->funcs->load_cursor_image_check || crtc->funcs->load_cursor_image;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Bool
|
|
|
|
xf86_driver_has_load_cursor_argb(xf86CrtcPtr crtc)
|
|
|
|
{
|
|
|
|
return crtc->funcs->load_cursor_argb_check || crtc->funcs->load_cursor_argb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Bool
|
|
|
|
xf86_driver_load_cursor_image(xf86CrtcPtr crtc, CARD8 *cursor_image)
|
|
|
|
{
|
|
|
|
if (crtc->funcs->load_cursor_image_check)
|
|
|
|
return crtc->funcs->load_cursor_image_check(crtc, cursor_image);
|
|
|
|
crtc->funcs->load_cursor_image(crtc, cursor_image);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Bool
|
|
|
|
xf86_driver_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *cursor_argb)
|
|
|
|
{
|
|
|
|
if (crtc->funcs->load_cursor_argb_check)
|
|
|
|
return crtc->funcs->load_cursor_argb_check(crtc, cursor_argb);
|
|
|
|
crtc->funcs->load_cursor_argb(crtc, cursor_argb);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
/*
|
|
|
|
* Load a two color cursor into a driver that supports only ARGB cursors
|
|
|
|
*/
|
2014-03-31 11:21:42 +02:00
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_convert_cursor_to_argb(xf86CrtcPtr crtc, unsigned char *src)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScrnInfoPtr scrn = crtc->scrn;
|
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
|
|
|
|
CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
|
|
|
|
int x, y;
|
|
|
|
int xin, yin;
|
|
|
|
int flags = cursor_info->Flags;
|
|
|
|
CARD32 bits;
|
|
|
|
const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
crtc->cursor_argb = FALSE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (y = 0; y < cursor_info->MaxHeight; y++)
|
2012-03-21 20:55:09 +01:00
|
|
|
for (x = 0; x < cursor_info->MaxWidth; x++) {
|
|
|
|
xf86_crtc_rotate_coord(rotation,
|
|
|
|
cursor_info->MaxWidth,
|
|
|
|
cursor_info->MaxHeight, x, y, &xin, &yin);
|
|
|
|
if (get_bit(src, cursor_info, xin, yin, TRUE) ==
|
|
|
|
((flags & HARDWARE_CURSOR_INVERT_MASK) == 0)) {
|
|
|
|
if (get_bit(src, cursor_info, xin, yin, FALSE))
|
|
|
|
bits = xf86_config->cursor_fg;
|
|
|
|
else
|
|
|
|
bits = xf86_config->cursor_bg;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bits = 0;
|
|
|
|
cursor_image[y * cursor_info->MaxWidth + x] = bits;
|
|
|
|
}
|
2014-04-25 17:22:15 +02:00
|
|
|
return xf86_driver_load_cursor_argb(crtc, cursor_image);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the colors for a two-color cursor (ignore for ARGB cursors)
|
|
|
|
*/
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_set_cursor_colors(ScrnInfoPtr scrn, int bg, int fg)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScreenPtr screen = scrn->pScreen;
|
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
CursorPtr cursor = xf86_config->cursor;
|
|
|
|
int c;
|
|
|
|
CARD8 *bits = cursor ?
|
2010-09-17 02:27:59 +02:00
|
|
|
dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen)
|
2012-03-21 20:55:09 +01:00
|
|
|
: NULL;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
/* Save ARGB versions of these colors */
|
|
|
|
xf86_config->cursor_fg = (CARD32) fg | 0xff000000;
|
|
|
|
xf86_config->cursor_bg = (CARD32) bg | 0xff000000;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
for (c = 0; c < xf86_config->num_crtc; c++) {
|
|
|
|
xf86CrtcPtr crtc = xf86_config->crtc[c];
|
|
|
|
|
|
|
|
if (crtc->enabled && !crtc->cursor_argb) {
|
2014-04-25 17:22:15 +02:00
|
|
|
if (xf86_driver_has_load_cursor_image(crtc))
|
2012-03-21 20:55:09 +01:00
|
|
|
crtc->funcs->set_cursor_colors(crtc, bg, fg);
|
|
|
|
else if (bits)
|
|
|
|
xf86_crtc_convert_cursor_to_argb(crtc, bits);
|
|
|
|
}
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_hide_cursor(xf86CrtcPtr crtc)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (crtc->cursor_shown) {
|
|
|
|
crtc->funcs->hide_cursor(crtc);
|
|
|
|
crtc->cursor_shown = FALSE;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_hide_cursors(ScrnInfoPtr scrn)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
int c;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
xf86_config->cursor_on = FALSE;
|
2012-03-21 20:55:09 +01:00
|
|
|
for (c = 0; c < xf86_config->num_crtc; c++) {
|
|
|
|
xf86CrtcPtr crtc = xf86_config->crtc[c];
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (crtc->enabled)
|
|
|
|
xf86_crtc_hide_cursor(crtc);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_show_cursor(xf86CrtcPtr crtc)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!crtc->cursor_shown && crtc->cursor_in_range) {
|
|
|
|
crtc->funcs->show_cursor(crtc);
|
|
|
|
crtc->cursor_shown = TRUE;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_show_cursors(ScrnInfoPtr scrn)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
int c;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
xf86_config->cursor_on = TRUE;
|
2012-03-21 20:55:09 +01:00
|
|
|
for (c = 0; c < xf86_config->num_crtc; c++) {
|
|
|
|
xf86CrtcPtr crtc = xf86_config->crtc[c];
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (crtc->enabled)
|
|
|
|
xf86_crtc_show_cursor(crtc);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
}
|
2011-08-26 00:41:55 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
void
|
|
|
|
xf86CrtcTransformCursorPos(xf86CrtcPtr crtc, int *x, int *y)
|
2011-08-26 00:41:55 +02:00
|
|
|
{
|
|
|
|
ScrnInfoPtr scrn = crtc->scrn;
|
|
|
|
ScreenPtr screen = scrn->pScreen;
|
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
|
|
|
|
xf86CursorScreenPtr ScreenPriv =
|
2012-03-21 20:55:09 +01:00
|
|
|
(xf86CursorScreenPtr) dixLookupPrivate(&screen->devPrivates,
|
|
|
|
xf86CursorScreenKey);
|
2011-08-26 00:41:55 +02:00
|
|
|
struct pict_f_vector v;
|
|
|
|
int dx, dy;
|
|
|
|
|
|
|
|
v.v[0] = (*x + ScreenPriv->HotX) + 0.5;
|
|
|
|
v.v[1] = (*y + ScreenPriv->HotY) + 0.5;
|
|
|
|
v.v[2] = 1;
|
2012-03-21 20:55:09 +01:00
|
|
|
pixman_f_transform_point(&crtc->f_framebuffer_to_crtc, &v);
|
2011-08-26 00:41:55 +02:00
|
|
|
/* cursor will have 0.5 added to it already so floor is sufficent */
|
2012-03-21 20:55:09 +01:00
|
|
|
*x = floor(v.v[0]);
|
|
|
|
*y = floor(v.v[1]);
|
2011-08-26 00:41:55 +02:00
|
|
|
/*
|
|
|
|
* Transform position of cursor upper left corner
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_rotate_coord_back(crtc->rotation, cursor_info->MaxWidth,
|
|
|
|
cursor_info->MaxHeight, ScreenPriv->HotX,
|
|
|
|
ScreenPriv->HotY, &dx, &dy);
|
2011-08-26 00:41:55 +02:00
|
|
|
*x -= dx;
|
|
|
|
*y -= dy;
|
|
|
|
}
|
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScrnInfoPtr scrn = crtc->scrn;
|
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
|
|
|
|
DisplayModePtr mode = &crtc->mode;
|
|
|
|
Bool in_range;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
/*
|
2007-07-14 18:03:40 +02:00
|
|
|
* Transform position of cursor on screen
|
2007-03-15 07:59:29 +01:00
|
|
|
*/
|
2011-08-25 19:19:48 +02:00
|
|
|
if (crtc->transform_in_use && !crtc->driverIsPerformingTransform)
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcTransformCursorPos(crtc, &x, &y);
|
|
|
|
else {
|
|
|
|
x -= crtc->x;
|
|
|
|
y -= crtc->y;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable the cursor when it is outside the viewport
|
|
|
|
*/
|
|
|
|
in_range = TRUE;
|
|
|
|
if (x >= mode->HDisplay || y >= mode->VDisplay ||
|
2012-03-21 20:55:09 +01:00
|
|
|
x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight) {
|
|
|
|
in_range = FALSE;
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
crtc->cursor_in_range = in_range;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (in_range) {
|
|
|
|
crtc->funcs->set_cursor_position(crtc, x, y);
|
|
|
|
xf86_crtc_show_cursor(crtc);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
else
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_hide_cursor(crtc);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_set_cursor_position(ScrnInfoPtr scrn, int x, int y)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
int c;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
/* undo what xf86HWCurs did to the coordinates */
|
|
|
|
x += scrn->frameX0;
|
|
|
|
y += scrn->frameY0;
|
2012-03-21 20:55:09 +01:00
|
|
|
for (c = 0; c < xf86_config->num_crtc; c++) {
|
|
|
|
xf86CrtcPtr crtc = xf86_config->crtc[c];
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (crtc->enabled)
|
|
|
|
xf86_crtc_set_cursor_position(crtc, x, y);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
/*
|
|
|
|
* Load a two-color cursor into a crtc, performing rotation as needed
|
|
|
|
*/
|
2014-03-31 11:21:42 +02:00
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScrnInfoPtr scrn = crtc->scrn;
|
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
|
|
|
|
CARD8 *cursor_image;
|
|
|
|
const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
crtc->cursor_argb = FALSE;
|
|
|
|
#endif
|
|
|
|
|
2011-08-25 19:19:48 +02:00
|
|
|
if (rotation == RR_Rotate_0)
|
2012-03-21 20:55:09 +01:00
|
|
|
cursor_image = src;
|
|
|
|
else {
|
2007-03-15 07:59:29 +01:00
|
|
|
int x, y;
|
2012-03-21 20:55:09 +01:00
|
|
|
int xin, yin;
|
|
|
|
int stride = cursor_info->MaxWidth >> 2;
|
|
|
|
|
|
|
|
cursor_image = xf86_config->cursor_image;
|
|
|
|
memset(cursor_image, 0, cursor_info->MaxHeight * stride);
|
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
for (y = 0; y < cursor_info->MaxHeight; y++)
|
2012-03-21 20:55:09 +01:00
|
|
|
for (x = 0; x < cursor_info->MaxWidth; x++) {
|
|
|
|
xf86_crtc_rotate_coord(rotation,
|
|
|
|
cursor_info->MaxWidth,
|
|
|
|
cursor_info->MaxHeight,
|
|
|
|
x, y, &xin, &yin);
|
|
|
|
if (get_bit(src, cursor_info, xin, yin, FALSE))
|
|
|
|
set_bit(cursor_image, cursor_info, x, y, FALSE);
|
|
|
|
if (get_bit(src, cursor_info, xin, yin, TRUE))
|
|
|
|
set_bit(cursor_image, cursor_info, x, y, TRUE);
|
|
|
|
}
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
2014-04-25 17:22:15 +02:00
|
|
|
return xf86_driver_load_cursor_image(crtc, cursor_image);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
/*
|
|
|
|
* Load a cursor image into all active CRTCs
|
|
|
|
*/
|
2014-03-31 11:21:42 +02:00
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
int c;
|
|
|
|
|
|
|
|
for (c = 0; c < xf86_config->num_crtc; c++) {
|
|
|
|
xf86CrtcPtr crtc = xf86_config->crtc[c];
|
|
|
|
|
|
|
|
if (crtc->enabled) {
|
2014-04-25 17:22:15 +02:00
|
|
|
if (xf86_driver_has_load_cursor_image(crtc)) {
|
2014-03-31 11:21:42 +02:00
|
|
|
if (!xf86_crtc_load_cursor_image(crtc, src))
|
|
|
|
return FALSE;
|
2014-04-25 17:22:15 +02:00
|
|
|
} else if (xf86_driver_has_load_cursor_argb(crtc)) {
|
2014-03-31 11:21:42 +02:00
|
|
|
if (!xf86_crtc_convert_cursor_to_argb(crtc, src))
|
|
|
|
return FALSE;
|
|
|
|
} else
|
|
|
|
return FALSE;
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
2014-03-31 11:21:42 +02:00
|
|
|
return TRUE;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-04-10 16:47:33 +02:00
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2013-05-15 11:01:11 +02:00
|
|
|
cursor = RefCursor(cursor);
|
2007-08-20 05:28:05 +02:00
|
|
|
if (xf86_config->cursor)
|
2012-03-21 20:55:09 +01:00
|
|
|
FreeCursor(xf86_config->cursor, None);
|
2007-03-15 07:59:29 +01:00
|
|
|
xf86_config->cursor = cursor;
|
2010-03-12 16:52:56 +01:00
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
if (cursor->bits->width > cursor_info->MaxWidth ||
|
2012-03-21 20:55:09 +01:00
|
|
|
cursor->bits->height > cursor_info->MaxHeight)
|
|
|
|
return FALSE;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-04-10 16:47:33 +02:00
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
|
|
|
|
|
2013-05-15 11:01:11 +02:00
|
|
|
cursor = RefCursor(cursor);
|
2009-09-21 19:13:31 +02:00
|
|
|
if (xf86_config->cursor)
|
2012-03-21 20:55:09 +01:00
|
|
|
FreeCursor(xf86_config->cursor, None);
|
2007-03-15 07:59:29 +01:00
|
|
|
xf86_config->cursor = cursor;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
/* Make sure ARGB support is available */
|
|
|
|
if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
if (cursor->bits->width > cursor_info->MaxWidth ||
|
2012-03-21 20:55:09 +01:00
|
|
|
cursor->bits->height > cursor_info->MaxHeight)
|
|
|
|
return FALSE;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-03-31 11:21:42 +02:00
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_crtc_load_cursor_argb(xf86CrtcPtr crtc, CursorPtr cursor)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScrnInfoPtr scrn = crtc->scrn;
|
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
|
|
|
|
CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
|
|
|
|
CARD32 *cursor_source = (CARD32 *) cursor->bits->argb;
|
|
|
|
int x, y;
|
|
|
|
int xin, yin;
|
|
|
|
CARD32 bits;
|
|
|
|
int source_width = cursor->bits->width;
|
|
|
|
int source_height = cursor->bits->height;
|
|
|
|
int image_width = cursor_info->MaxWidth;
|
|
|
|
int image_height = cursor_info->MaxHeight;
|
|
|
|
const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
|
2011-08-25 19:19:48 +02:00
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
for (y = 0; y < image_height; y++)
|
2012-03-21 20:55:09 +01:00
|
|
|
for (x = 0; x < image_width; x++) {
|
|
|
|
xf86_crtc_rotate_coord(rotation, image_width, image_height, x, y,
|
|
|
|
&xin, &yin);
|
|
|
|
if (xin < source_width && yin < source_height)
|
|
|
|
bits = cursor_source[yin * source_width + xin];
|
|
|
|
else
|
|
|
|
bits = 0;
|
|
|
|
cursor_image[y * image_width + x] = bits;
|
|
|
|
}
|
|
|
|
|
2014-04-25 17:22:15 +02:00
|
|
|
return xf86_driver_load_cursor_argb(crtc, cursor_image);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
2014-03-31 11:21:42 +02:00
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
int c;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (c = 0; c < xf86_config->num_crtc; c++) {
|
|
|
|
xf86CrtcPtr crtc = xf86_config->crtc[c];
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (crtc->enabled)
|
2014-03-31 11:21:42 +02:00
|
|
|
if (!xf86_crtc_load_cursor_argb(crtc, cursor))
|
|
|
|
return FALSE;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
2014-03-31 11:21:42 +02:00
|
|
|
return TRUE;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-04-10 16:47:33 +02:00
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
xf86CursorInfoPtr cursor_info;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
|
|
|
cursor_info = xf86CreateCursorInfoRec();
|
|
|
|
if (!cursor_info)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
xf86_config->cursor_image = malloc(max_width * max_height * 4);
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!xf86_config->cursor_image) {
|
|
|
|
xf86DestroyCursorInfoRec(cursor_info);
|
|
|
|
return FALSE;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
xf86_config->cursor_info = cursor_info;
|
|
|
|
|
|
|
|
cursor_info->MaxWidth = max_width;
|
|
|
|
cursor_info->MaxHeight = max_height;
|
|
|
|
cursor_info->Flags = flags;
|
|
|
|
|
|
|
|
cursor_info->SetCursorColors = xf86_set_cursor_colors;
|
|
|
|
cursor_info->SetCursorPosition = xf86_set_cursor_position;
|
2014-04-25 17:22:15 +02:00
|
|
|
cursor_info->LoadCursorImageCheck = xf86_load_cursor_image;
|
2007-03-15 07:59:29 +01:00
|
|
|
cursor_info->HideCursor = xf86_hide_cursors;
|
|
|
|
cursor_info->ShowCursor = xf86_show_cursors;
|
|
|
|
cursor_info->UseHWCursor = xf86_use_hw_cursor;
|
|
|
|
#ifdef ARGB_CURSOR
|
2012-03-21 20:55:09 +01:00
|
|
|
if (flags & HARDWARE_CURSOR_ARGB) {
|
|
|
|
cursor_info->UseHWCursorARGB = xf86_use_hw_cursor_argb;
|
2014-04-25 17:22:15 +02:00
|
|
|
cursor_info->LoadCursorARGBCheck = xf86_load_cursor_argb;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-03-15 07:59:29 +01:00
|
|
|
xf86_config->cursor = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_hide_cursors(scrn);
|
|
|
|
|
|
|
|
return xf86InitCursor(screen, cursor_info);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when anything on the screen is reconfigured.
|
|
|
|
*
|
|
|
|
* Reloads cursor images as needed, then adjusts cursor positions
|
2014-03-31 11:21:42 +02:00
|
|
|
* @note We assume that all hardware cursors to be loaded have already been
|
|
|
|
* found to be usable by the hardware.
|
2007-03-15 07:59:29 +01:00
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_reload_cursors(ScreenPtr screen)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScrnInfoPtr scrn;
|
|
|
|
xf86CrtcConfigPtr xf86_config;
|
|
|
|
xf86CursorInfoPtr cursor_info;
|
|
|
|
CursorPtr cursor;
|
|
|
|
int x, y;
|
2008-12-03 07:52:53 +01:00
|
|
|
xf86CursorScreenPtr cursor_screen_priv;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2008-05-02 07:26:58 +02:00
|
|
|
/* initial mode setting will not have set a screen yet.
|
|
|
|
May be called before the devices are initialised.
|
|
|
|
*/
|
|
|
|
if (!screen || !inputInfo.pointer)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2008-12-03 07:52:53 +01:00
|
|
|
cursor_screen_priv = dixLookupPrivate(&screen->devPrivates,
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CursorScreenKey);
|
2008-12-03 07:52:53 +01:00
|
|
|
/* return if HW cursor is inactive, to avoid displaying two cursors */
|
2010-03-01 02:11:36 +01:00
|
|
|
if (!cursor_screen_priv || !cursor_screen_priv->isUp)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2008-12-03 07:52:53 +01:00
|
|
|
|
2012-04-10 16:47:33 +02:00
|
|
|
scrn = xf86ScreenToScrn(screen);
|
2007-03-15 18:50:45 +01:00
|
|
|
xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
|
|
|
|
/* make sure the cursor code has been initialized */
|
|
|
|
cursor_info = xf86_config->cursor_info;
|
|
|
|
if (!cursor_info)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2008-12-03 07:52:53 +01:00
|
|
|
|
2007-03-15 18:50:45 +01:00
|
|
|
cursor = xf86_config->cursor;
|
2012-03-21 20:55:09 +01:00
|
|
|
GetSpritePosition(inputInfo.pointer, &x, &y);
|
2007-03-15 07:59:29 +01:00
|
|
|
if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
|
2012-03-21 20:55:09 +01:00
|
|
|
(*cursor_info->HideCursor) (scrn);
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (cursor) {
|
|
|
|
void *src =
|
|
|
|
dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey,
|
|
|
|
screen);
|
2007-03-15 07:59:29 +01:00
|
|
|
#ifdef ARGB_CURSOR
|
2014-04-25 17:22:15 +02:00
|
|
|
if (cursor->bits->argb && xf86DriverHasLoadCursorARGB(cursor_info))
|
|
|
|
xf86DriverLoadCursorARGB(cursor_info, cursor);
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (src)
|
2008-03-03 05:13:11 +01:00
|
|
|
#endif
|
2014-04-25 17:22:15 +02:00
|
|
|
xf86DriverLoadCursorImage(cursor_info, src);
|
2007-03-15 07:59:29 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
x += scrn->frameX0 + cursor_screen_priv->HotX;
|
|
|
|
y += scrn->frameY0 + cursor_screen_priv->HotY;
|
|
|
|
(*cursor_info->SetCursorPosition) (scrn, x, y);
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clean up CRTC-based cursor code
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86_cursors_fini(ScreenPtr screen)
|
2007-03-15 07:59:29 +01:00
|
|
|
{
|
2012-04-10 16:47:33 +02:00
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
|
|
|
|
if (xf86_config->cursor_info) {
|
|
|
|
xf86DestroyCursorInfoRec(xf86_config->cursor_info);
|
|
|
|
xf86_config->cursor_info = NULL;
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|
2010-06-09 23:08:54 +02:00
|
|
|
free(xf86_config->cursor_image);
|
|
|
|
xf86_config->cursor_image = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
if (xf86_config->cursor) {
|
|
|
|
FreeCursor(xf86_config->cursor, None);
|
|
|
|
xf86_config->cursor = NULL;
|
2007-08-20 05:28:05 +02:00
|
|
|
}
|
2007-03-15 07:59:29 +01:00
|
|
|
}
|