src/video/x11/SDL_x11mouse.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 11 Mar 2011 13:56:53 -0800
changeset 5471 179adad3ae6f
parent 5470 8f5e10ec4faf
child 5481 22dfc3958dc3
permissions -rw-r--r--
Added support for the Xcursor library for color cursors
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
5262
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
     3
    Copyright (C) 1997-2011 Sam Lantinga
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
5471
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    23
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    24
#include "SDL_assert.h"
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#include "SDL_x11video.h"
2940
b93965a16fe0 Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    26
#include "SDL_x11mouse.h"
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "../../events/SDL_mouse_c.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
5470
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    29
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    30
/* FIXME: Find a better place to put this... */
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    31
static Cursor x11_empty_cursor = None;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    32
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    33
static Display *
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    34
GetDisplay(void)
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    35
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    36
    return ((SDL_VideoData *)SDL_GetVideoDevice()->driverdata)->display;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    37
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    38
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    39
static Cursor
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    40
X11_CreateEmptyCursor()
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    41
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    42
    if (x11_empty_cursor == None) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    43
        Display *display = GetDisplay();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    44
        char data[1];
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    45
        XColor color;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    46
        Pixmap pixmap;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    47
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    48
        SDL_zero(data);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    49
        color.red = color.green = color.blue = 0;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    50
        pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    51
                                       data, 1, 1);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    52
        if (pixmap) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    53
            x11_empty_cursor = XCreatePixmapCursor(display, pixmap, pixmap,
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    54
                                                   &color, &color, 0, 0);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    55
            XFreePixmap(display, pixmap);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    56
        }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    57
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    58
    return x11_empty_cursor;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    59
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    60
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    61
static void
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    62
X11_DestroyEmptyCursor(void)
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    63
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    64
    if (x11_empty_cursor != None) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    65
        XFreeCursor(GetDisplay(), x11_empty_cursor);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    66
        x11_empty_cursor = None;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    67
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    68
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    69
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    70
static SDL_Cursor *
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    71
X11_CreateDefaultCursor()
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    72
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    73
    SDL_Cursor *cursor;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    74
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    75
    cursor = SDL_calloc(1, sizeof(*cursor));
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    76
    if (cursor) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    77
        /* None is used to indicate the default cursor */
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    78
        cursor->driverdata = (void*)None;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    79
    } else {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    80
        SDL_OutOfMemory();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    81
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    82
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    83
    return cursor;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    84
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    85
5471
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    86
#if SDL_VIDEO_DRIVER_X11_XCURSOR
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    87
static Cursor
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    88
X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y)
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    89
{
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    90
    Display *display = GetDisplay();
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    91
    Cursor cursor = None;
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    92
    XcursorImage *image;
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    93
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    94
    image = XcursorImageCreate(surface->w, surface->h);
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    95
    if (!image) {
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    96
        SDL_OutOfMemory();
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    97
        return None;
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    98
    }
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
    99
    image->xhot = hot_x;
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   100
    image->yhot = hot_y;
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   101
    image->delay = 0;
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   102
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   103
    SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   104
    SDL_assert(surface->pitch == surface->w * 4);
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   105
    SDL_memcpy(image->pixels, surface->pixels, surface->h * surface->pitch);
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   106
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   107
    cursor = XcursorImageLoadCursor(display, image);
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   108
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   109
    XcursorImageDestroy(image);
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   110
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   111
    return cursor;
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   112
}
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   113
#endif /* SDL_VIDEO_DRIVER_X11_XCURSOR */
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   114
5470
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   115
static Cursor
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   116
X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y)
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   117
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   118
    Display *display = GetDisplay();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   119
    XColor fg, bg;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   120
    Cursor cursor = None;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   121
    Uint32 *ptr;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   122
    Uint8 *data_bits, *mask_bits;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   123
    Pixmap data_pixmap, mask_pixmap;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   124
    int x, y;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   125
    unsigned int rfg, gfg, bfg, rbg, gbg, bbg, fgBits, bgBits;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   126
    unsigned int width_bytes = ((surface->w + 7) & ~7) / 8;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   127
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   128
    data_bits = SDL_calloc(1, surface->h * width_bytes);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   129
    mask_bits = SDL_calloc(1, surface->h * width_bytes);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   130
    if (!data_bits || !mask_bits) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   131
        SDL_OutOfMemory();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   132
        return None;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   133
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   134
5471
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   135
    /* Code below assumes ARGB pixel format */
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   136
    SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   137
5470
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   138
    rfg = gfg = bfg = rbg = gbg = bbg = fgBits = 0;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   139
    for (y = 0; y < surface->h; ++y) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   140
        ptr = (Uint32 *)((Uint8 *)surface->pixels + y * surface->pitch);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   141
        for (x = 0; x < surface->w; ++x) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   142
            int alpha = (*ptr >> 24) & 0xff;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   143
            int red   = (*ptr >> 16) & 0xff;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   144
            int green = (*ptr >> 8) & 0xff;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   145
            int blue  = (*ptr >> 0) & 0xff;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   146
            if (alpha > 25) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   147
                mask_bits[y * width_bytes + x / 8] |= (0x01 << (x % 8));
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   148
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   149
                if ((red + green + blue) > 0x40) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   150
                    fgBits++;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   151
                    rfg += red;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   152
                    gfg += green;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   153
                    bfg += blue;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   154
                    data_bits[y * width_bytes + x / 8] |= (0x01 << (x % 8));
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   155
                } else {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   156
                    bgBits++;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   157
                    rbg += red;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   158
                    gbg += green;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   159
                    bbg += blue;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   160
                }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   161
            }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   162
            ++ptr;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   163
        }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   164
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   165
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   166
    if (fgBits) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   167
        fg.red   = rfg * 257 / fgBits;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   168
        fg.green = gfg * 257 / fgBits;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   169
        fg.blue  = bfg * 257 / fgBits;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   170
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   171
    else fg.red = fg.green = fg.blue = 0;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   172
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   173
    if (bgBits) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   174
        bg.red   = rbg * 257 / bgBits;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   175
        bg.green = gbg * 257 / bgBits;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   176
        bg.blue  = bbg * 257 / bgBits;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   177
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   178
    else bg.red = bg.green = bg.blue = 0;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   179
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   180
    data_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   181
                                        data_bits, surface->w, surface->h);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   182
    mask_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   183
                                        mask_bits, surface->w, surface->h);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   184
    cursor = XCreatePixmapCursor(display, data_pixmap, mask_pixmap,
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   185
                                 &fg, &bg, hot_x, hot_y);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   186
	XFreePixmap(display, data_pixmap);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   187
	XFreePixmap(display, mask_pixmap);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   188
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   189
    return cursor;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   190
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   191
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   192
static SDL_Cursor *
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   193
X11_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   194
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   195
    SDL_Cursor *cursor;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   196
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   197
    cursor = SDL_calloc(1, sizeof(*cursor));
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   198
    if (cursor) {
5471
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   199
        Cursor x11_cursor = None;
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   200
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   201
#if SDL_VIDEO_DRIVER_X11_XCURSOR
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   202
        if (SDL_X11_HAVE_XCURSOR) {
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   203
            x11_cursor = X11_CreateXCursorCursor(surface, hot_x, hot_y);
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   204
        }
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   205
#endif
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   206
        if (x11_cursor == None) {
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   207
            x11_cursor = X11_CreatePixmapCursor(surface, hot_x, hot_y);
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   208
        }
179adad3ae6f Added support for the Xcursor library for color cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5470
diff changeset
   209
        cursor->driverdata = (void*)x11_cursor;
5470
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   210
    } else {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   211
        SDL_OutOfMemory();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   212
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   213
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   214
    return cursor;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   215
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   216
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   217
static void
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   218
X11_FreeCursor(SDL_Cursor * cursor)
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   219
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   220
    Cursor x11_cursor = (Cursor)cursor->driverdata;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   221
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   222
    if (x11_cursor != None) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   223
        XFreeCursor(GetDisplay(), x11_cursor);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   224
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   225
    SDL_free(cursor);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   226
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   227
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   228
static int
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   229
X11_ShowCursor(SDL_Cursor * cursor)
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   230
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   231
    Cursor x11_cursor = 0;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   232
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   233
    if (cursor) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   234
        x11_cursor = (Cursor)cursor->driverdata;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   235
    } else {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   236
        x11_cursor = X11_CreateEmptyCursor();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   237
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   238
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   239
    /* FIXME: Is there a better way than this? */
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   240
    {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   241
        SDL_VideoDevice *video = SDL_GetVideoDevice();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   242
        Display *display = GetDisplay();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   243
        SDL_Window *window;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   244
        SDL_WindowData *data;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   245
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   246
        for (window = video->windows; window; window = window->next) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   247
            data = (SDL_WindowData *)window->driverdata;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   248
            if (x11_cursor != None) {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   249
                XDefineCursor(display, data->xwindow, x11_cursor);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   250
            } else {
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   251
                XUndefineCursor(display, data->xwindow);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   252
            }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   253
        }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   254
        XFlush(display);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   255
    }
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   256
    return 0;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   257
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   258
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   259
static void
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   260
X11_WarpMouse(SDL_Window * window, int x, int y)
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   261
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   262
    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   263
    Display *display = data->videodata->display;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   264
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   265
    XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   266
    XSync(display, False);
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   267
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   268
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   269
static int
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   270
X11_SetRelativeMouseMode(SDL_bool enabled)
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   271
{
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   272
    SDL_Unsupported();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   273
    return -1;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   274
}
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   275
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
void
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
X11_InitMouse(_THIS)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
{
5470
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   279
    SDL_Mouse *mouse = SDL_GetMouse();
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   280
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   281
    mouse->CreateCursor = X11_CreateCursor;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   282
    mouse->ShowCursor = X11_ShowCursor;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   283
    mouse->FreeCursor = X11_FreeCursor;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   284
    mouse->WarpMouse = X11_WarpMouse;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   285
    mouse->SetRelativeMouseMode = X11_SetRelativeMouseMode;
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   286
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   287
    SDL_SetDefaultCursor(X11_CreateDefaultCursor());
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
}
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
void
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
X11_QuitMouse(_THIS)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
{
5470
8f5e10ec4faf Implemented X11 cursor support.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   293
    X11_DestroyEmptyCursor();
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
}
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
/* vi: set ts=4 sw=4 expandtab: */