src/events/SDL_mouse.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 21 Feb 2011 10:50:53 -0800
changeset 5371 fc3d3d580777
parent 5370 cb219a294ebf
child 5376 183ec2d4485c
permissions -rw-r--r--
Fixed the responder chain for event handling, the listener fully handles mouse events - even in fullscreen mode.
The only reason we need a custom view is to handle right mouse down.

Implemented mouse grabbing, although it's kind of clunky right now. I'll be adding a relative mode that will be smoother soon.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@5262
     3
    Copyright (C) 1997-2011 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@0
    23
slouken@0
    24
/* General mouse handling code for SDL */
slouken@0
    25
slouken@0
    26
#include "SDL_events.h"
slouken@0
    27
#include "SDL_events_c.h"
slouken@1895
    28
#include "default_cursor.h"
slouken@3685
    29
#include "../video/SDL_sysvideo.h"
slouken@0
    30
slouken@0
    31
slouken@5371
    32
/* The mouse state */
slouken@4465
    33
static SDL_Mouse SDL_mouse;
slouken@0
    34
slouken@0
    35
slouken@0
    36
/* Public functions */
slouken@1895
    37
int
slouken@1895
    38
SDL_MouseInit(void)
slouken@0
    39
{
slouken@1895
    40
    return (0);
slouken@1123
    41
}
slouken@0
    42
slouken@5371
    43
SDL_Mouse *
slouken@5371
    44
SDL_GetMouse(void)
slouken@5371
    45
{
slouken@5371
    46
    return &SDL_mouse;
slouken@5371
    47
}
slouken@5371
    48
slouken@4465
    49
void
slouken@4465
    50
SDL_ResetMouse(void)
slouken@460
    51
{
slouken@4465
    52
    /* FIXME */
slouken@460
    53
}
slouken@460
    54
slouken@4465
    55
SDL_Window *
slouken@4465
    56
SDL_GetMouseFocus(void)
slouken@2710
    57
{
slouken@5371
    58
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@2940
    59
slouken@4465
    60
    return mouse->focus;
slouken@0
    61
}
slouken@0
    62
slouken@1895
    63
void
slouken@4465
    64
SDL_SetMouseFocus(SDL_Window * window)
slouken@0
    65
{
slouken@5371
    66
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
    67
slouken@4465
    68
    if (mouse->focus == window) {
slouken@1895
    69
        return;
slouken@1895
    70
    }
slouken@1895
    71
slouken@1895
    72
    /* See if the current window has lost focus */
slouken@1895
    73
    if (mouse->focus) {
slouken@4465
    74
        SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
slouken@1895
    75
    }
slouken@1895
    76
slouken@3685
    77
    mouse->focus = window;
slouken@1895
    78
slouken@1895
    79
    if (mouse->focus) {
slouken@4465
    80
        SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
slouken@1895
    81
    }
slouken@1895
    82
}
slouken@1895
    83
slouken@1895
    84
int
slouken@4484
    85
SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
slouken@1895
    86
{
slouken@5371
    87
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
    88
    int posted;
slouken@1895
    89
    int xrel;
slouken@1895
    90
    int yrel;
slouken@2860
    91
    int x_max = 0, y_max = 0;
slouken@1895
    92
slouken@4484
    93
    if (window) {
slouken@4484
    94
        SDL_SetMouseFocus(window);
slouken@4484
    95
    }
slouken@4484
    96
slouken@2710
    97
    /* the relative motion is calculated regarding the system cursor last position */
slouken@2842
    98
    if (relative) {
slouken@2842
    99
        xrel = x;
slouken@2842
   100
        yrel = y;
slouken@2860
   101
        x = (mouse->last_x + x);
slouken@2860
   102
        y = (mouse->last_y + y);
slouken@2842
   103
    } else {
slouken@2860
   104
        xrel = x - mouse->last_x;
slouken@2860
   105
        yrel = y - mouse->last_y;
slouken@2842
   106
    }
slouken@2710
   107
slouken@1895
   108
    /* Drop events that don't change state */
slouken@1895
   109
    if (!xrel && !yrel) {
slouken@1895
   110
#if 0
slouken@1895
   111
        printf("Mouse event didn't change state - dropped!\n");
slouken@1895
   112
#endif
slouken@1895
   113
        return 0;
slouken@1895
   114
    }
slouken@1895
   115
slouken@2710
   116
    /* Update internal mouse coordinates */
slouken@2710
   117
    if (mouse->relative_mode == SDL_FALSE) {
slouken@1895
   118
        mouse->x = x;
slouken@1895
   119
        mouse->y = y;
slouken@2710
   120
    } else {
slouken@2860
   121
        mouse->x += xrel;
slouken@2860
   122
        mouse->y += yrel;
slouken@2860
   123
    }
slouken@2849
   124
slouken@2860
   125
    SDL_GetWindowSize(mouse->focus, &x_max, &y_max);
slouken@5370
   126
    --x_max;
slouken@5370
   127
    --y_max;
slouken@2849
   128
slouken@2860
   129
    /* make sure that the pointers find themselves inside the windows */
slouken@2860
   130
    /* only check if mouse->xmax is set ! */
slouken@5370
   131
    if (mouse->x > x_max) {
slouken@2860
   132
        mouse->x = x_max;
slouken@5370
   133
    }
slouken@5370
   134
    if (mouse->x < 0) {
slouken@2860
   135
        mouse->x = 0;
slouken@1895
   136
    }
slouken@2860
   137
slouken@5370
   138
    if (mouse->y > y_max) {
slouken@2860
   139
        mouse->y = y_max;
slouken@5370
   140
    }
slouken@5370
   141
    if (mouse->y < 0) {
slouken@2860
   142
        mouse->y = 0;
slouken@2860
   143
    }
slouken@2860
   144
slouken@1895
   145
    mouse->xdelta += xrel;
slouken@1895
   146
    mouse->ydelta += yrel;
slouken@1895
   147
slouken@4465
   148
#if 0 /* FIXME */
slouken@1895
   149
    /* Move the mouse cursor, if needed */
slouken@1895
   150
    if (mouse->cursor_shown && !mouse->relative_mode &&
slouken@1895
   151
        mouse->MoveCursor && mouse->cur_cursor) {
slouken@1895
   152
        mouse->MoveCursor(mouse->cur_cursor);
slouken@1895
   153
    }
slouken@4465
   154
#endif
slouken@1895
   155
slouken@1895
   156
    /* Post the event, if desired */
slouken@1895
   157
    posted = 0;
slouken@4465
   158
    if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE) {
slouken@1895
   159
        SDL_Event event;
slouken@1895
   160
        event.motion.type = SDL_MOUSEMOTION;
slouken@4465
   161
        event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
slouken@1895
   162
        event.motion.state = mouse->buttonstate;
slouken@1895
   163
        event.motion.x = mouse->x;
slouken@1895
   164
        event.motion.y = mouse->y;
slouken@1895
   165
        event.motion.xrel = xrel;
slouken@1895
   166
        event.motion.yrel = yrel;
slouken@1895
   167
        posted = (SDL_PushEvent(&event) > 0);
slouken@1895
   168
    }
lestat@3112
   169
    mouse->last_x = mouse->x;
lestat@3112
   170
    mouse->last_y = mouse->y;
slouken@1895
   171
    return posted;
slouken@1895
   172
}
slouken@1895
   173
slouken@1895
   174
int
slouken@4484
   175
SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
slouken@1895
   176
{
slouken@5371
   177
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
   178
    int posted;
slouken@4429
   179
    Uint32 type;
slouken@1895
   180
slouken@4484
   181
    if (window) {
slouken@4484
   182
        SDL_SetMouseFocus(window);
slouken@4484
   183
    }
slouken@4484
   184
slouken@1895
   185
    /* Figure out which event to perform */
slouken@1895
   186
    switch (state) {
slouken@1895
   187
    case SDL_PRESSED:
slouken@1895
   188
        if (mouse->buttonstate & SDL_BUTTON(button)) {
slouken@1895
   189
            /* Ignore this event, no state change */
slouken@1895
   190
            return 0;
slouken@1895
   191
        }
slouken@1895
   192
        type = SDL_MOUSEBUTTONDOWN;
slouken@1895
   193
        mouse->buttonstate |= SDL_BUTTON(button);
slouken@1895
   194
        break;
slouken@1895
   195
    case SDL_RELEASED:
slouken@2725
   196
        if (!(mouse->buttonstate & SDL_BUTTON(button))) {
kazeuser@2718
   197
            /* Ignore this event, no state change */
kazeuser@2718
   198
            return 0;
kazeuser@2718
   199
        }
slouken@1895
   200
        type = SDL_MOUSEBUTTONUP;
slouken@1895
   201
        mouse->buttonstate &= ~SDL_BUTTON(button);
slouken@1895
   202
        break;
slouken@1895
   203
    default:
slouken@1895
   204
        /* Invalid state -- bail */
slouken@1895
   205
        return 0;
slouken@1895
   206
    }
slouken@1895
   207
slouken@1895
   208
    /* Post the event, if desired */
slouken@1895
   209
    posted = 0;
slouken@4429
   210
    if (SDL_GetEventState(type) == SDL_ENABLE) {
slouken@1895
   211
        SDL_Event event;
slouken@1895
   212
        event.type = type;
slouken@1895
   213
        event.button.state = state;
slouken@1895
   214
        event.button.button = button;
slouken@1895
   215
        event.button.x = mouse->x;
slouken@1895
   216
        event.button.y = mouse->y;
slouken@3689
   217
        event.button.windowID = mouse->focus ? mouse->focus->id : 0;
slouken@1895
   218
        posted = (SDL_PushEvent(&event) > 0);
slouken@1895
   219
    }
slouken@1895
   220
    return posted;
slouken@1895
   221
}
slouken@1895
   222
slouken@1895
   223
int
slouken@4484
   224
SDL_SendMouseWheel(SDL_Window * window, int x, int y)
slouken@1895
   225
{
slouken@5371
   226
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
   227
    int posted;
slouken@1895
   228
slouken@4484
   229
    if (window) {
slouken@4484
   230
        SDL_SetMouseFocus(window);
slouken@4484
   231
    }
slouken@4484
   232
slouken@4465
   233
    if (!x && !y) {
slouken@1895
   234
        return 0;
slouken@1895
   235
    }
slouken@1895
   236
slouken@1895
   237
    /* Post the event, if desired */
slouken@1895
   238
    posted = 0;
slouken@4429
   239
    if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
slouken@1895
   240
        SDL_Event event;
slouken@1895
   241
        event.type = SDL_MOUSEWHEEL;
slouken@4465
   242
        event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
slouken@2152
   243
        event.wheel.x = x;
slouken@2152
   244
        event.wheel.y = y;
slouken@1895
   245
        posted = (SDL_PushEvent(&event) > 0);
slouken@1895
   246
    }
slouken@1895
   247
    return posted;
slouken@1895
   248
}
slouken@1895
   249
slouken@1895
   250
void
slouken@4465
   251
SDL_MouseQuit(void)
slouken@4465
   252
{
slouken@4465
   253
}
slouken@4465
   254
slouken@4465
   255
Uint8
slouken@4465
   256
SDL_GetMouseState(int *x, int *y)
slouken@4465
   257
{
slouken@5371
   258
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@4465
   259
slouken@4465
   260
    if (x) {
slouken@4465
   261
        *x = mouse->x;
slouken@4465
   262
    }
slouken@4465
   263
    if (y) {
slouken@4465
   264
        *y = mouse->y;
slouken@4465
   265
    }
slouken@4465
   266
    return mouse->buttonstate;
slouken@4465
   267
}
slouken@4465
   268
slouken@4465
   269
Uint8
slouken@4465
   270
SDL_GetRelativeMouseState(int *x, int *y)
slouken@4465
   271
{
slouken@5371
   272
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@4465
   273
slouken@4465
   274
    if (x) {
slouken@4465
   275
        *x = mouse->xdelta;
slouken@4465
   276
    }
slouken@4465
   277
    if (y) {
slouken@4465
   278
        *y = mouse->ydelta;
slouken@4465
   279
    }
slouken@4465
   280
    mouse->xdelta = 0;
slouken@4465
   281
    mouse->ydelta = 0;
slouken@4465
   282
    return mouse->buttonstate;
slouken@4465
   283
}
slouken@4465
   284
slouken@4465
   285
void
slouken@3685
   286
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
slouken@1895
   287
{
slouken@5371
   288
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
   289
slouken@1895
   290
    if (mouse->WarpMouse) {
slouken@5371
   291
        mouse->WarpMouse(window, x, y);
slouken@1895
   292
    } else {
slouken@4484
   293
        SDL_SendMouseMotion(window, 0, x, y);
slouken@1895
   294
    }
slouken@1895
   295
}
slouken@1895
   296
slouken@4465
   297
int
slouken@4465
   298
SDL_SetRelativeMouseMode(SDL_bool enabled)
slouken@4465
   299
{
slouken@5371
   300
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@4465
   301
slouken@4465
   302
    /* Flush pending mouse motion */
slouken@4465
   303
    SDL_FlushEvent(SDL_MOUSEMOTION);
slouken@4465
   304
slouken@4465
   305
    /* Set the relative mode */
slouken@4465
   306
    mouse->relative_mode = enabled;
slouken@4465
   307
slouken@4465
   308
    if (!enabled) {
slouken@4465
   309
        /* Restore the expected mouse position */
slouken@4465
   310
        SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
slouken@4465
   311
    }
slouken@4465
   312
slouken@4465
   313
    /* Update cursor visibility */
slouken@4465
   314
    SDL_SetCursor(NULL);
slouken@4465
   315
slouken@4465
   316
    return 0;
slouken@4465
   317
}
slouken@4465
   318
slouken@4465
   319
SDL_bool
slouken@4465
   320
SDL_GetRelativeMouseMode()
slouken@4465
   321
{
slouken@5371
   322
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@4465
   323
slouken@4465
   324
    return mouse->relative_mode;
slouken@4465
   325
}
slouken@4465
   326
slouken@1895
   327
SDL_Cursor *
slouken@1895
   328
SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
slouken@1895
   329
                 int w, int h, int hot_x, int hot_y)
slouken@1895
   330
{
slouken@5371
   331
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
   332
    SDL_Surface *surface;
slouken@1895
   333
    SDL_Cursor *cursor;
slouken@1895
   334
    int x, y;
slouken@1895
   335
    Uint32 *pixel;
slouken@4465
   336
    Uint8 datab = 0, maskb = 0;
slouken@1895
   337
    const Uint32 black = 0xFF000000;
slouken@1895
   338
    const Uint32 white = 0xFFFFFFFF;
slouken@1895
   339
    const Uint32 transparent = 0x00000000;
slouken@1895
   340
slouken@1895
   341
    if (!mouse->CreateCursor) {
slouken@4465
   342
        SDL_SetError("Cursors are not currently supported");
slouken@1895
   343
        return NULL;
slouken@1895
   344
    }
slouken@1895
   345
slouken@1895
   346
    /* Sanity check the hot spot */
slouken@1895
   347
    if ((hot_x < 0) || (hot_y < 0) || (hot_x >= w) || (hot_y >= h)) {
slouken@1895
   348
        SDL_SetError("Cursor hot spot doesn't lie within cursor");
slouken@1895
   349
        return NULL;
slouken@1895
   350
    }
slouken@1895
   351
slouken@1895
   352
    /* Make sure the width is a multiple of 8 */
slouken@1895
   353
    w = ((w + 7) & ~7);
slouken@1895
   354
slouken@1895
   355
    /* Create the surface from a bitmap */
slouken@1895
   356
    surface =
slouken@1895
   357
        SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
slouken@1895
   358
                             0xFF000000);
slouken@1895
   359
    if (!surface) {
slouken@1895
   360
        return NULL;
slouken@1895
   361
    }
slouken@1895
   362
    for (y = 0; y < h; ++y) {
slouken@1895
   363
        pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch);
slouken@1895
   364
        for (x = 0; x < w; ++x) {
slouken@1895
   365
            if ((x % 8) == 0) {
slouken@1895
   366
                datab = *data++;
slouken@1895
   367
                maskb = *mask++;
slouken@1895
   368
            }
slouken@1895
   369
            if (maskb & 0x80) {
slouken@1895
   370
                *pixel++ = (datab & 0x80) ? black : white;
slouken@1895
   371
            } else {
slouken@1895
   372
                *pixel++ = (datab & 0x80) ? black : transparent;
slouken@1895
   373
            }
slouken@1895
   374
            datab <<= 1;
slouken@1895
   375
            maskb <<= 1;
slouken@1895
   376
        }
slouken@1895
   377
    }
slouken@1895
   378
slouken@1895
   379
    cursor = mouse->CreateCursor(surface, hot_x, hot_y);
slouken@1895
   380
    if (cursor) {
slouken@1895
   381
        cursor->next = mouse->cursors;
slouken@1895
   382
        mouse->cursors = cursor;
slouken@1895
   383
    }
slouken@1895
   384
slouken@1895
   385
    SDL_FreeSurface(surface);
slouken@1895
   386
slouken@1895
   387
    return cursor;
slouken@1895
   388
}
slouken@1895
   389
slouken@1895
   390
/* SDL_SetCursor(NULL) can be used to force the cursor redraw,
slouken@1895
   391
   if this is desired for any reason.  This is used when setting
slouken@1895
   392
   the video mode and when the SDL window gains the mouse focus.
slouken@1895
   393
 */
slouken@1895
   394
void
slouken@1895
   395
SDL_SetCursor(SDL_Cursor * cursor)
slouken@1895
   396
{
slouken@5371
   397
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
   398
slouken@1895
   399
    /* Set the new cursor */
slouken@1895
   400
    if (cursor) {
slouken@1895
   401
        /* Make sure the cursor is still valid for this mouse */
slouken@1895
   402
        SDL_Cursor *found;
slouken@1895
   403
        for (found = mouse->cursors; found; found = found->next) {
slouken@1895
   404
            if (found == cursor) {
slouken@1895
   405
                break;
slouken@1895
   406
            }
slouken@1895
   407
        }
slouken@1895
   408
        if (!found) {
slouken@1895
   409
            SDL_SetError("Cursor not associated with the current mouse");
slouken@1895
   410
            return;
slouken@1895
   411
        }
slouken@1895
   412
        mouse->cur_cursor = cursor;
slouken@1895
   413
    } else {
slouken@1895
   414
        cursor = mouse->cur_cursor;
slouken@1895
   415
    }
slouken@1895
   416
slouken@1895
   417
    if (cursor && mouse->cursor_shown && !mouse->relative_mode) {
slouken@1895
   418
        if (mouse->ShowCursor) {
slouken@1895
   419
            mouse->ShowCursor(cursor);
slouken@1895
   420
        }
slouken@1895
   421
    } else {
slouken@1895
   422
        if (mouse->ShowCursor) {
slouken@1895
   423
            mouse->ShowCursor(NULL);
slouken@1895
   424
        }
slouken@1895
   425
    }
slouken@1895
   426
}
slouken@1895
   427
slouken@1895
   428
SDL_Cursor *
slouken@1895
   429
SDL_GetCursor(void)
slouken@1895
   430
{
slouken@5371
   431
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
   432
slouken@1895
   433
    if (!mouse) {
slouken@1895
   434
        return NULL;
slouken@1895
   435
    }
slouken@1895
   436
    return mouse->cur_cursor;
slouken@1895
   437
}
slouken@1895
   438
slouken@1895
   439
void
slouken@1895
   440
SDL_FreeCursor(SDL_Cursor * cursor)
slouken@1895
   441
{
slouken@5371
   442
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
   443
    SDL_Cursor *curr, *prev;
slouken@1895
   444
slouken@1895
   445
    if (!cursor) {
slouken@1895
   446
        return;
slouken@1895
   447
    }
slouken@1895
   448
slouken@1895
   449
    if (cursor == mouse->def_cursor) {
slouken@1895
   450
        return;
slouken@1895
   451
    }
slouken@1895
   452
    if (cursor == mouse->cur_cursor) {
slouken@1895
   453
        SDL_SetCursor(mouse->def_cursor);
slouken@1895
   454
    }
slouken@1895
   455
slouken@1895
   456
    for (prev = NULL, curr = mouse->cursors; curr;
slouken@1895
   457
         prev = curr, curr = curr->next) {
slouken@1895
   458
        if (curr == cursor) {
slouken@1895
   459
            if (prev) {
slouken@1895
   460
                prev->next = curr->next;
slouken@1895
   461
            } else {
slouken@1895
   462
                mouse->cursors = curr->next;
slouken@1895
   463
            }
slouken@1895
   464
slouken@1895
   465
            if (mouse->FreeCursor) {
slouken@1895
   466
                mouse->FreeCursor(curr);
slouken@1895
   467
            }
slouken@1895
   468
            return;
slouken@1895
   469
        }
slouken@1895
   470
    }
slouken@1895
   471
}
slouken@1895
   472
slouken@1895
   473
int
slouken@1895
   474
SDL_ShowCursor(int toggle)
slouken@1895
   475
{
slouken@5371
   476
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@1895
   477
    SDL_bool shown;
slouken@1895
   478
slouken@1895
   479
    if (!mouse) {
slouken@1895
   480
        return 0;
slouken@1895
   481
    }
slouken@1895
   482
slouken@1895
   483
    shown = mouse->cursor_shown;
slouken@1895
   484
    if (toggle >= 0) {
slouken@1895
   485
        if (toggle) {
slouken@1895
   486
            mouse->cursor_shown = SDL_TRUE;
slouken@1895
   487
        } else {
slouken@1895
   488
            mouse->cursor_shown = SDL_FALSE;
slouken@1895
   489
        }
slouken@1895
   490
        if (mouse->cursor_shown != shown) {
slouken@1895
   491
            SDL_SetCursor(NULL);
slouken@1895
   492
        }
slouken@1895
   493
    }
slouken@1895
   494
    return shown;
slouken@1895
   495
}
slouken@1895
   496
slouken@1895
   497
/* vi: set ts=4 sw=4 expandtab: */