Skip to content

Commit 3ba8afe

Browse files
merge
2 parents 595468b + ede6863 commit 3ba8afe

File tree

2 files changed

+189
-37
lines changed

2 files changed

+189
-37
lines changed

CHANGELOG

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,36 @@ changelog
33

44
Current:
55

6-
Release: RGFW 1.8.5-dev
7-
-----------------------------------------------
8-
This release is being worked on in a fork, but will not be pushed to main until 1.8.0's offical release.
6+
Release: RGFW 1.9-dev
97
-----------------------------------------------
8+
So far, this release is focused on fixing bugs and cleaning up aspects of RGFW's API.
9+
10+
In this PR I am redefining how RGFW handles versioning. Breaking changes are going to be left for major releases. If something is going to be renamed, the new function will be added in the minor release, and the old one will be removed in the major release. There will be a warning if a feature will be removed in the next major version. This should allow for a smooth transition between versions. Patch versions will be used for minor fixes after minor releases.
1011

11-
Release: RGFW 1.8.0 (pre-release)
12+
-----------------------------------------------
13+
- add RGFW_glForwardCompatibility
14+
- fix documentation typos
15+
- add RGFW_windowRawMouse and rawMouseMode (rawMouseMode will replace holdMouse/unholdMouse in 2.0)
16+
- fix mouse hold/unhold on focus/unfocus
17+
- cleanup hacky X11 raw mouse input
18+
- support window resizing in the Vulkan Example
19+
- fix extra chars from RGFW_window_setName (X11)
20+
- fix window not hiding after it's first shown (X11)
21+
- fix fullscreen bugs when a hidden window is created (X11)
22+
- add RGFW_equal and RGFW_kpEquals alts for consistency
23+
- add `RGFW_mouseText` as an altname for `RGFW_mouseIbeam`
24+
- add `RGFW_mouseResizeNW`
25+
- add `RGFW_mouseResizeN`
26+
- add `RGFW_mouseResizeNE`
27+
- add `RGFW_mouseResizeE`
28+
- add `RGFW_mouseResizeSE`
29+
- add `RGFW_mouseResizeS`
30+
- add `RGFW_mouseResizeSW`
31+
- add `RGFW_mouseResizeW`
32+
- add `RGFW_mouseWait`
33+
- add `RGFW_mouseProgress`
34+
35+
Release: RGFW 1.8.0
1236
-----------------------------------------------
1337
This release focuses on improving RGFW’s API while making its internals more stable and less prone to bugs.
1438
It also cleans up inconsistencies, reworks poor design choices, and removes non-essential features.

RGFW.h

Lines changed: 161 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ typedef RGFW_ENUM(u8, RGFW_key) {
487487
RGFW_8 = '8',
488488
RGFW_9 = '9',
489489
RGFW_minus = '-',
490-
RGFW_equals = '=',
490+
RGFW_equal = '=',
491+
RGFW_equals = RGFW_equal,
491492
RGFW_backSpace = '\b',
492493
RGFW_tab = '\t',
493494
RGFW_space = ' ',
@@ -578,6 +579,7 @@ typedef RGFW_ENUM(u8, RGFW_key) {
578579
RGFW_kpPlus,
579580
RGFW_kpMinus,
580581
RGFW_kpEqual,
582+
RGFW_kpEquals = RGFW_kpEqual,
581583
RGFW_kp1,
582584
RGFW_kp2,
583585
RGFW_kp3,
@@ -621,7 +623,7 @@ typedef RGFW_ENUM(u8, RGFW_keymod) {
621623
/*! @brief codes for the event types that can be sent */
622624
typedef RGFW_ENUM(u8, RGFW_eventType) {
623625
RGFW_eventNone = 0, /*!< no event has been sent */
624-
RGFW_keyPressed, /* a key has been pressed */
626+
RGFW_keyPressed, /*!< a key has been pressed */
625627
RGFW_keyReleased, /*!< a key has been released */
626628
/*! key event note
627629
the code of the key pressed is stored in
@@ -828,14 +830,25 @@ typedef RGFW_ENUM(u8, RGFW_mouseIcons) {
828830
RGFW_mouseNormal = 0,
829831
RGFW_mouseArrow,
830832
RGFW_mouseIbeam,
833+
RGFW_mouseText = RGFW_mouseIbeam,
831834
RGFW_mouseCrosshair,
832835
RGFW_mousePointingHand,
833836
RGFW_mouseResizeEW,
834837
RGFW_mouseResizeNS,
835838
RGFW_mouseResizeNWSE,
836839
RGFW_mouseResizeNESW,
840+
RGFW_mouseResizeNW,
841+
RGFW_mouseResizeN,
842+
RGFW_mouseResizeNE,
843+
RGFW_mouseResizeE,
844+
RGFW_mouseResizeSE,
845+
RGFW_mouseResizeS,
846+
RGFW_mouseResizeSW,
847+
RGFW_mouseResizeW,
837848
RGFW_mouseResizeAll,
838849
RGFW_mouseNotAllowed,
850+
RGFW_mouseWait,
851+
RGFW_mouseProgress,
839852
RGFW_mouseIconCount,
840853
RGFW_mouseIconFinal = 16 /* padding for alignment */
841854
};
@@ -946,6 +959,7 @@ typedef RGFW_ENUM(i32, RGFW_glReleaseBehavior) {
946959
/*! values for the profile hint */
947960
typedef RGFW_ENUM(i32, RGFW_glProfile) {
948961
RGFW_glCore = 0, /*!< the core OpenGL version, e.g. just support for that version */
962+
RGFW_glForwardCompatibility, /*!< only compatibility for newer versions of OpenGL as well as the requested version */
949963
RGFW_glCompatibility, /*!< allow compatibility for older versions of OpenGL as well as the requested version */
950964
RGFW_glES /*!< use OpenGL ES */
951965
};
@@ -4531,8 +4545,11 @@ RGFW_bool RGFW_window_createContextPtr_EGL(RGFW_window* win, RGFW_eglContext* ct
45314545
RGFW_attribStack_pushAttribs(&stack, EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT);
45324546
} else if (hints->profile == RGFW_glCompatibility) {
45334547
RGFW_attribStack_pushAttribs(&stack, EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT);
4548+
} else if (hints->profile == RGFW_glForwardCompatibility) {
4549+
RGFW_attribStack_pushAttribs(&stack, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE, EGL_TRUE);
45344550
}
45354551

4552+
45364553
RGFW_attribStack_pushAttribs(&stack, EGL_CONTEXT_OPENGL_ROBUST_ACCESS, hints->robustness);
45374554
RGFW_attribStack_pushAttribs(&stack, EGL_CONTEXT_OPENGL_DEBUG, hints->debug);
45384555

@@ -5758,7 +5775,7 @@ void RGFW_XHandleEvent(void) {
57585775
event.type = RGFW_mouseButtonPressed;
57595776
}
57605777

5761-
switch(E.xbutton.button) {
5778+
switch (E.xbutton.button) {
57625779
case Button1: event.button.value = RGFW_mouseLeft; break;
57635780
case Button2: event.button.value = RGFW_mouseMiddle; break;
57645781
case Button3: event.button.value = RGFW_mouseRight; break;
@@ -6570,14 +6587,33 @@ RGFW_bool RGFW_FUNC(RGFW_window_setMouseDefault) (RGFW_window* win) {
65706587
RGFW_bool RGFW_FUNC(RGFW_window_setMouseStandard) (RGFW_window* win, u8 mouse) {
65716588
RGFW_ASSERT(win != NULL);
65726589

6573-
static const u8 mouseIconSrc[16] = { XC_arrow, XC_left_ptr, XC_xterm, XC_crosshair, XC_hand2, XC_sb_h_double_arrow, XC_sb_v_double_arrow, XC_bottom_left_corner, XC_bottom_right_corner, XC_fleur, XC_X_cursor};
6574-
6575-
if (mouse > (sizeof(mouseIconSrc) / sizeof(u8)))
6576-
return RGFW_FALSE;
6577-
6578-
mouse = mouseIconSrc[mouse];
6579-
6580-
Cursor cursor = XCreateFontCursor(_RGFW->display, mouse);
6590+
u32 mouseIcon = 0;
6591+
6592+
switch (mouse) {
6593+
case RGFW_mouseNormal: mouseIcon = XC_left_ptr; break;
6594+
case RGFW_mouseIbeam: mouseIcon = XC_xterm; break;
6595+
case RGFW_mouseWait: mouseIcon = XC_watch; break;
6596+
case RGFW_mouseCrosshair: mouseIcon = XC_tcross; break;
6597+
case RGFW_mouseProgress: mouseIcon = XC_watch; break;
6598+
case RGFW_mouseResizeNWSE: mouseIcon = XC_top_left_corner; break;
6599+
case RGFW_mouseResizeNESW: mouseIcon = XC_top_right_corner; break;
6600+
case RGFW_mouseResizeEW: mouseIcon = XC_sb_h_double_arrow; break;
6601+
case RGFW_mouseResizeNS: mouseIcon = XC_sb_v_double_arrow; break;
6602+
case RGFW_mouseResizeNW: mouseIcon = XC_top_left_corner; break;
6603+
case RGFW_mouseResizeN: mouseIcon = XC_top_side; break;
6604+
case RGFW_mouseResizeNE: mouseIcon = XC_top_right_corner; break;
6605+
case RGFW_mouseResizeE: mouseIcon = XC_right_side; break;
6606+
case RGFW_mouseResizeSE: mouseIcon = XC_bottom_right_corner; break;
6607+
case RGFW_mouseResizeS: mouseIcon = XC_bottom_side; break;
6608+
case RGFW_mouseResizeSW: mouseIcon = XC_bottom_left_corner; break;
6609+
case RGFW_mouseResizeW: mouseIcon = XC_left_side; break;
6610+
case RGFW_mouseResizeAll: mouseIcon = XC_fleur; break;
6611+
case RGFW_mouseNotAllowed: mouseIcon = XC_pirate; break;
6612+
case RGFW_mousePointingHand: mouseIcon = XC_hand2; break;
6613+
default: return RGFW_FALSE;
6614+
}
6615+
6616+
Cursor cursor = XCreateFontCursor(_RGFW->display, mouseIcon);
65816617
XDefineCursor(_RGFW->display, win->src.window, (Cursor) cursor);
65826618
XFreeCursor(_RGFW->display, (Cursor) cursor);
65836619
return RGFW_TRUE;
@@ -7105,6 +7141,7 @@ RGFW_bool RGFW_FUNC(RGFW_window_createContextPtr_OpenGL) (RGFW_window* win, RGFW
71057141
i32 mask = 0;
71067142
switch (hints->profile) {
71077143
case RGFW_glES: mask |= GLX_CONTEXT_ES_PROFILE_BIT_EXT; break;
7144+
case RGFW_glForwardCompatibility: mask |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; break;
71087145
case RGFW_glCompatibility: mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; break;
71097146
case RGFW_glCore: mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB; break;
71107147
default: mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB; break;
@@ -8751,13 +8788,36 @@ RGFW_bool RGFW_FUNC(RGFW_window_setMouseDefault)(RGFW_window* win) {
87518788

87528789
RGFW_bool RGFW_FUNC(RGFW_window_setMouseStandard)(RGFW_window* win, u8 mouse) {
87538790
RGFW_ASSERT(win != NULL);
8754-
static const char* iconStrings[16] = { "arrow", "left_ptr", "xterm", "crosshair", "hand2", "sb_h_double_arrow", "sb_v_double_arrow", "bottom_left_corner", "bottom_right_corner", "fleur", "forbidden" };
87558791

8756-
win->src.using_custom_cursor = RGFW_FALSE;
8792+
char* cursorName = NULL;
8793+
switch (mouse) {
8794+
case RGFW_mouseNormal: cursorName = (char*)"left_ptr"; break;
8795+
case RGFW_mouseArrow: cursorName = (char*)"left_ptr"; break;
8796+
case RGFW_mouseIbeam: cursorName = (char*)"xterm"; break;
8797+
case RGFW_mouseCrosshair: cursorName = (char*)"crosshair"; break;
8798+
case RGFW_mousePointingHand: cursorName = (char*)"hand2"; break;
8799+
case RGFW_mouseResizeEW: cursorName = (char*)"sb_h_double_arrow"; break;
8800+
case RGFW_mouseResizeNS: cursorName = (char*)"sb_v_double_arrow"; break;
8801+
case RGFW_mouseResizeNWSE: cursorName = (char*)"top_left_corner"; break; /* or fd_double_arrow */
8802+
case RGFW_mouseResizeNESW: cursorName = (char*)"top_right_corner"; break; /* or bd_double_arrow */
8803+
case RGFW_mouseResizeNW: cursorName = (char*)"top_left_corner"; break;
8804+
case RGFW_mouseResizeN: cursorName = (char*)"top_side"; break;
8805+
case RGFW_mouseResizeNE: cursorName = (char*)"top_right_corner"; break;
8806+
case RGFW_mouseResizeE: cursorName = (char*)"right_side"; break;
8807+
case RGFW_mouseResizeSE: cursorName = (char*)"bottom_right_corner"; break;
8808+
case RGFW_mouseResizeS: cursorName = (char*)"bottom_side"; break;
8809+
case RGFW_mouseResizeSW: cursorName = (char*)"bottom_left_corner"; break;
8810+
case RGFW_mouseResizeW: cursorName = (char*)"left_side"; break;
8811+
case RGFW_mouseResizeAll: cursorName = (char*)"fleur"; break;
8812+
case RGFW_mouseNotAllowed: cursorName = (char*)"not-allowed"; break;
8813+
case RGFW_mouseWait: cursorName = (char*)"watch"; break;
8814+
case RGFW_mouseProgress: cursorName = (char*)"watch"; break;
8815+
default: return RGFW_FALSE;
8816+
}
87578817

8758-
if (mouse > RGFW_mouseIconCount - 1) return RGFW_FALSE;
8818+
win->src.using_custom_cursor = RGFW_FALSE;
87598819

8760-
struct wl_cursor* wlcursor = wl_cursor_theme_get_cursor(_RGFW->wl_cursor_theme, iconStrings[mouse]);
8820+
struct wl_cursor* wlcursor = wl_cursor_theme_get_cursor(_RGFW->wl_cursor_theme, cursorName);
87618821
struct wl_cursor_image* cursor_image = wlcursor->images[0];
87628822
struct wl_buffer* cursor_buffer = wl_cursor_image_get_buffer(cursor_image);
87638823
wl_pointer_set_cursor(_RGFW->wl_pointer, _RGFW->mouse_enter_serial, _RGFW->cursor_surface, (i32)cursor_image->hotspot_x, (i32)cursor_image->hotspot_y);
@@ -10258,11 +10318,34 @@ RGFW_bool RGFW_window_setMouseDefault(RGFW_window* win) {
1025810318
RGFW_bool RGFW_window_setMouseStandard(RGFW_window* win, u8 mouse) {
1025910319
RGFW_ASSERT(win != NULL);
1026010320

10261-
static const u32 mouseIconSrc[16] = {OCR_NORMAL, OCR_NORMAL, OCR_IBEAM, OCR_CROSS, OCR_HAND, OCR_SIZEWE, OCR_SIZENS, OCR_SIZENWSE, OCR_SIZENESW, OCR_SIZEALL, OCR_NO};
10262-
if (mouse > (sizeof(mouseIconSrc) / sizeof(u32)))
10263-
return RGFW_FALSE;
10321+
u32 mouseIcon = 0;
10322+
10323+
switch (mouse) {
10324+
case RGFW_mouseNormal: mouseIcon = OCR_NORMAL; break;
10325+
case RGFW_mouseArrow: mouseIcon = OCR_NORMAL; break;
10326+
case RGFW_mouseIbeam: mouseIcon = OCR_IBEAM; break;
10327+
case RGFW_mouseWait: mouseIcon = OCR_WAIT; break;
10328+
case RGFW_mouseCrosshair: mouseIcon = OCR_CROSS; break;
10329+
case RGFW_mouseProgress: mouseIcon = OCR_APPSTARTING; break;
10330+
case RGFW_mouseResizeNWSE: mouseIcon = OCR_SIZENWSE; break;
10331+
case RGFW_mouseResizeNESW: mouseIcon = OCR_SIZENESW; break;
10332+
case RGFW_mouseResizeEW: mouseIcon = OCR_SIZEWE; break;
10333+
case RGFW_mouseResizeNS: mouseIcon = OCR_SIZENS; break;
10334+
case RGFW_mouseResizeAll: mouseIcon = OCR_SIZEALL; break;
10335+
case RGFW_mouseNotAllowed: mouseIcon = OCR_NO; break;
10336+
case RGFW_mousePointingHand: mouseIcon = OCR_HAND; break;
10337+
case RGFW_mouseResizeNW: mouseIcon = OCR_SIZENWSE; break;
10338+
case RGFW_mouseResizeN: mouseIcon = OCR_SIZENS; break;
10339+
case RGFW_mouseResizeNE: mouseIcon = OCR_SIZENESW; break;
10340+
case RGFW_mouseResizeE: mouseIcon = OCR_SIZEWE; break;
10341+
case RGFW_mouseResizeSE: mouseIcon = OCR_SIZENWSE; break;
10342+
case RGFW_mouseResizeS: mouseIcon = OCR_SIZENS; break;
10343+
case RGFW_mouseResizeSW: mouseIcon = OCR_SIZENESW; break;
10344+
case RGFW_mouseResizeW: mouseIcon = OCR_SIZEWE; break;
10345+
default: return RGFW_FALSE;
10346+
}
1026410347

10265-
char* icon = MAKEINTRESOURCEA(mouseIconSrc[mouse]);
10348+
char* icon = MAKEINTRESOURCEA(mouseIcon);
1026610349

1026710350
SetClassLongPtrA(win->src.window, GCLP_HCURSOR, (LPARAM) LoadCursorA(NULL, icon));
1026810351
SetCursor(LoadCursorA(NULL, icon));
@@ -10545,6 +10628,7 @@ void RGFW_win32_loadOpenGLFuncs(HWND dummyWin) {
1054510628
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
1054610629
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
1054710630
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
10631+
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
1054810632
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
1054910633
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
1055010634
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
@@ -10638,6 +10722,7 @@ RGFW_bool RGFW_window_createContextPtr_OpenGL(RGFW_window* win, RGFW_glContext*
1063810722
switch (hints->profile) {
1063910723
case RGFW_glES: mask |= WGL_CONTEXT_ES_PROFILE_BIT_EXT; break;
1064010724
case RGFW_glCompatibility: mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; break;
10725+
case RGFW_glForwardCompatibility: mask |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; break;
1064110726
case RGFW_glCore: mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB; break;
1064210727
default: mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB; break;
1064310728
}
@@ -12325,13 +12410,35 @@ void RGFW_window_showMouse(RGFW_window* win, RGFW_bool show) {
1232512410
else CGDisplayHideCursor(kCGDirectMainDisplay);
1232612411
}
1232712412

12328-
RGFW_bool RGFW_window_setMouseStandard(RGFW_window* win, u8 stdMouses) {
12329-
static const char* mouseIconSrc[16] = {"arrowCursor", "arrowCursor", "IBeamCursor", "crosshairCursor", "pointingHandCursor", "resizeLeftRightCursor", "resizeUpDownCursor", "_windowResizeNorthWestSouthEastCursor", "_windowResizeNorthEastSouthWestCursor", "closedHandCursor", "operationNotAllowedCursor"};
12330-
if (stdMouses > ((sizeof(mouseIconSrc)) / (sizeof(char*))))
12331-
return RGFW_FALSE;
12413+
RGFW_bool RGFW_window_setMouseStandard(RGFW_window* win, u8 stdMouse) {
12414+
const char* cursorSelectorStr;
12415+
switch (stdMouse) {
12416+
case RGFW_mouseNormal: cursorSelectorStr = "arrowCursor"; break;
12417+
case RGFW_mouseArrow: cursorSelectorStr = "arrowCursor"; break;
12418+
case RGFW_mouseIbeam: cursorSelectorStr = "IBeamCursor"; break;
12419+
case RGFW_mouseCrosshair: cursorSelectorStr = "crosshairCursor"; break;
12420+
case RGFW_mousePointingHand: cursorSelectorStr = "pointingHandCursor"; break;
12421+
case RGFW_mouseResizeEW: cursorSelectorStr = "resizeLeftRightCursor"; break;
12422+
case RGFW_mouseResizeE: cursorSelectorStr = "resizeLeftRightCursor"; break;
12423+
case RGFW_mouseResizeW: cursorSelectorStr = "resizeLeftRightCursor"; break;
12424+
case RGFW_mouseResizeNS: cursorSelectorStr = "resizeUpDownCursor"; break;
12425+
case RGFW_mouseResizeN: cursorSelectorStr = "resizeUpDownCursor"; break;
12426+
case RGFW_mouseResizeS: cursorSelectorStr = "resizeUpDownCursor"; break;
12427+
case RGFW_mouseResizeNWSE: cursorSelectorStr = "_windowResizeNorthWestSouthEastCursor"; break;
12428+
case RGFW_mouseResizeNW: cursorSelectorStr = "_windowResizeNorthWestSouthEastCursor"; break;
12429+
case RGFW_mouseResizeSE: cursorSelectorStr = "_windowResizeNorthWestSouthEastCursor"; break;
12430+
case RGFW_mouseResizeNESW: cursorSelectorStr = "_windowResizeNorthEastSouthWestCursor"; break;
12431+
case RGFW_mouseResizeNE: cursorSelectorStr = "_windowResizeNorthEastSouthWestCursor"; break;
12432+
case RGFW_mouseResizeSW: cursorSelectorStr = "_windowResizeNorthEastSouthWestCursor"; break;
12433+
case RGFW_mouseResizeAll: cursorSelectorStr = "openHandCursor"; break;
12434+
case RGFW_mouseNotAllowed: cursorSelectorStr = "operationNotAllowedCursor"; break;
12435+
case RGFW_mouseWait: cursorSelectorStr = "arrowCursor"; break;
12436+
case RGFW_mouseProgress: cursorSelectorStr = "arrowCursor"; break;
12437+
default:
12438+
return RGFW_FALSE;
12439+
}
1233212440

12333-
const char* mouseStr = mouseIconSrc[stdMouses];
12334-
id mouse = NSCursor_arrowStr(mouseStr);
12441+
id mouse = NSCursor_arrowStr(cursorSelectorStr);
1233512442

1233612443
if (mouse == NULL)
1233712444
return RGFW_FALSE;
@@ -13325,8 +13432,8 @@ u8 RGFW_rgfwToKeyChar(u32 rgfw_keycode) {
1332513432
}
1332613433

1332713434
void RGFW_pollEvents(void) {
13328-
emscripten_sleep(0);
1332913435
RGFW_resetPrevState();
13436+
emscripten_sleep(0);
1333013437
}
1333113438

1333213439
void RGFW_window_resize(RGFW_window* win, i32 w, i32 h) {
@@ -13343,14 +13450,35 @@ void RGFW_window_setMouse(RGFW_window* win, RGFW_mouse* mouse) { RGFW_UNUSED(win
1334313450
void RGFW_freeMouse(RGFW_mouse* mouse) { RGFW_UNUSED(mouse); }
1334413451

1334513452
RGFW_bool RGFW_window_setMouseStandard(RGFW_window* win, u8 mouse) {
13346-
static const char cursors[16][16] = {
13347-
"default", "default", "text", "crosshair",
13348-
"pointer", "ew-resize", "ns-resize", "nwse-resize", "nesw-resize",
13349-
"move", "not-allowed"
13350-
};
13351-
1335213453
RGFW_UNUSED(win);
13353-
EM_ASM( { document.getElementById("canvas").style.cursor = UTF8ToString($0); }, cursors[mouse]);
13454+
char* cursorName = NULL;
13455+
13456+
switch (mouse) {
13457+
case RGFW_mouseNormal: cursorName = (char*)"default"; break;
13458+
case RGFW_mouseArrow: cursorName = (char*)"default"; break;
13459+
case RGFW_mouseIbeam: cursorName = (char*)"text"; break;
13460+
case RGFW_mouseCrosshair: cursorName = (char*)"crosshair"; break;
13461+
case RGFW_mousePointingHand: cursorName = (char*)"pointer"; break;
13462+
case RGFW_mouseResizeEW: cursorName = (char*)"ew-resize"; break;
13463+
case RGFW_mouseResizeNS: cursorName = (char*)"ns-resize"; break;
13464+
case RGFW_mouseResizeNWSE: cursorName = (char*)"nwse-resize"; break;
13465+
case RGFW_mouseResizeNESW: cursorName = (char*)"nesw-resize"; break;
13466+
case RGFW_mouseResizeNW: cursorName = (char*)"nw-resize"; break;
13467+
case RGFW_mouseResizeN: cursorName = (char*)"n-resize"; break;
13468+
case RGFW_mouseResizeNE: cursorName = (char*)"ne-resize"; break;
13469+
case RGFW_mouseResizeE: cursorName = (char*)"e-resize"; break;
13470+
case RGFW_mouseResizeSE: cursorName = (char*)"se-resize"; break;
13471+
case RGFW_mouseResizeS: cursorName = (char*)"s-resize"; break;
13472+
case RGFW_mouseResizeSW: cursorName = (char*)"sw-resize"; break;
13473+
case RGFW_mouseResizeW: cursorName = (char*)"w-resize"; break;
13474+
case RGFW_mouseResizeAll: cursorName = (char*)"move"; break;
13475+
case RGFW_mouseNotAllowed: cursorName = (char*)"not-allowed"; break;
13476+
case RGFW_mouseWait: cursorName = (char*)"wait"; break;
13477+
case RGFW_mouseProgress: cursorName = (char*)"progress"; break;
13478+
default: return RGFW_FALSE;
13479+
}
13480+
13481+
EM_ASM( { document.getElementById("canvas").style.cursor = UTF8ToString($0); }, cursorName);
1335413482
return RGFW_TRUE;
1335513483
}
1335613484

0 commit comments

Comments
 (0)