mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-25 00:35:44 +00:00
emscripten, wayland, x11: Share the table of CSS cursor names
As suggested in #8939. This results in some minor changes for emscripten and x11. Both previously mapped SIZEALL to "move", but "move" is not guaranteed to be a four-pointed arrow: according to the CSS spec, it's actually intended to be a drag-and-drop cursor, analogous to "alias" and "copy". Map it to "all-scroll" instead, as in Wayland: while this is *also* not semantically guaranteed to be a four-pointed arrow, it is at least *suggested* to make it a four-pointed arrow. Also, emscripten was previously using two-pointed arrows for resizing (BOTTOMLEFT mapped to "nesw-resize", and so on). This commit changes it to use the more specific "sw-resize" and so on, which might be single-directional. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
committed by
Ryan C. Gordon
parent
7dbd6669c3
commit
b986bc8be9
@@ -29,6 +29,7 @@
|
||||
#include "SDL_emscriptenmouse.h"
|
||||
#include "SDL_emscriptenvideo.h"
|
||||
|
||||
#include "../SDL_video_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
/* older Emscriptens don't have this, but we need to for wasm64 compatibility. */
|
||||
@@ -117,73 +118,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int
|
||||
|
||||
static SDL_Cursor *Emscripten_CreateSystemCursor(SDL_SystemCursor id)
|
||||
{
|
||||
const char *cursor_name = NULL;
|
||||
|
||||
switch (id) {
|
||||
case SDL_SYSTEM_CURSOR_ARROW:
|
||||
cursor_name = "default";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_IBEAM:
|
||||
cursor_name = "text";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAIT:
|
||||
cursor_name = "wait";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_CROSSHAIR:
|
||||
cursor_name = "crosshair";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW:
|
||||
cursor_name = "progress";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENWSE:
|
||||
cursor_name = "nwse-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENESW:
|
||||
cursor_name = "nesw-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEWE:
|
||||
cursor_name = "ew-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENS:
|
||||
cursor_name = "ns-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEALL:
|
||||
cursor_name = "move";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_NO:
|
||||
cursor_name = "not-allowed";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_HAND:
|
||||
cursor_name = "pointer";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT:
|
||||
cursor_name = "nwse-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_TOP:
|
||||
cursor_name = "ns-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT:
|
||||
cursor_name = "nesw-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_RIGHT:
|
||||
cursor_name = "ew-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT:
|
||||
cursor_name = "nwse-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_BOTTOM:
|
||||
cursor_name = "ns-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT:
|
||||
cursor_name = "nesw-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_LEFT:
|
||||
cursor_name = "ew-resize";
|
||||
break;
|
||||
default:
|
||||
SDL_assert(0);
|
||||
return NULL;
|
||||
}
|
||||
const char *cursor_name = SDL_GetCSSCursorName(id, NULL);
|
||||
|
||||
return Emscripten_CreateCursorFromString(cursor_name, SDL_FALSE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user