@@ -82,7 +82,7 @@ macos : gcc main.c -framework Cocoa -framework OpenGL -framework IOKit
8282u8 icon[4 * 3 * 3] = {0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF};
8383
8484int main() {
85- RGFW_window* win = RGFW_createWindowPtr ("name", RGFW_RECT(500, 500 , 500, 500), (u64)0);
85+ RGFW_window* win = RGFW_createWindow ("name", RGFW_RECT(100, 100 , 500, 500), (u64)0);
8686
8787 RGFW_window_setIcon(win, icon, RGFW_AREA(3, 3), 4);
8888
@@ -867,8 +867,8 @@ RGFWDEF b32 RGFW_window_setIcon(RGFW_window* win, /*!< source window */
867867 i32 channels /*!< how many channels the bitmap has (rgb : 3, rgba : 4) */
868868); /*!< image resized by default */
869869
870- /*!< sets mouse to bitmap (very simular to RGFW_window_setIcon), icon NOT resized by default*/
871- RGFWDEF b32 RGFW_window_setMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels );
870+ /*!< sets mouse to bitmap (very similar to RGFW_window_setIcon), icon NOT resized by default*/
871+ RGFWDEF b32 RGFW_window_loadMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels );
872872
873873/*!< sets the mouse to a standard API cursor (based on RGFW_MOUSE, as seen at the end of the RGFW_HEADER part of this file) */
874874RGFWDEF b32 RGFW_window_setMouseStandard (RGFW_window * win , u8 mouse );
@@ -1913,7 +1913,7 @@ RGFW_gamepadType RGFW_getGamepadType(RGFW_window* win, u16 controller) {
19131913void RGFW_window_showMouse (RGFW_window * win , i8 show ) {
19141914 static u8 RGFW_blk [] = { 0 , 0 , 0 , 0 };
19151915 if (show == 0 )
1916- RGFW_window_setMouse (win , RGFW_blk , RGFW_AREA (1 , 1 ), 4 );
1916+ RGFW_window_loadMouse (win , RGFW_blk , RGFW_AREA (1 , 1 ), 4 );
19171917 else
19181918 RGFW_window_setMouseDefault (win );
19191919}
@@ -3629,7 +3629,7 @@ b32 RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) {
36293629 return res ;
36303630}
36313631
3632- b32 RGFW_window_setMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) {
3632+ b32 RGFW_window_loadMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) {
36333633 RGFW_ASSERT (win != NULL ); assert (icon );
36343634 assert (channels == 3 || channels == 4 );
36353635
@@ -3652,11 +3652,11 @@ b32 RGFW_window_setMouse(RGFW_window* win, u8* icon, RGFW_area a, i32 channels)
36523652 }
36533653
36543654 Cursor cursor = XcursorImageLoadCursor (win -> src .display , native );
3655+ XcursorImageDestroy (native );
36553656
36563657 b32 res = (b32 )XDefineCursor (win -> src .display , win -> src .window , cursor );
3657- if (res ) XFreeCursor (win -> src .display , cursor );
36583658
3659- XcursorImageDestroy ( native );
3659+ if ( res ) XFreeCursor ( win -> src . display , cursor );
36603660
36613661 return (b32 )res ;
36623662#else
@@ -5204,7 +5204,7 @@ b32 RGFW_window_setMouseStandard(RGFW_window* win, u8 mouse) {
52045204 return 1 ;
52055205}
52065206
5207- b32 RGFW_window_setMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) {
5207+ b32 RGFW_window_loadMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) {
52085208 RGFW_UNUSED (win ); RGFW_UNUSED (image ); RGFW_UNUSED (a ); RGFW_UNUSED (channels )
52095209 //struct wl_cursor* cursor = wl_cursor_theme_get_cursor(RGFW_wl_cursor_theme, iconStrings[mouse]);
52105210 //RGFW_cursor_image = icon;
@@ -6689,15 +6689,23 @@ HICON RGFW_loadHandleImage(RGFW_window* win, u8* src, RGFW_area a, BOOL icon) {
66896689 return handle ;
66906690}
66916691
6692- b32 RGFW_window_setMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) {
6692+ void * RGFW_window_loadMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) {
66936693 RGFW_ASSERT (win != NULL );
66946694 RGFW_UNUSED (channels );
66956695
66966696 HCURSOR cursor = (HCURSOR ) RGFW_loadHandleImage (win , icon , a , FALSE);
6697- SetClassLongPtrA (win -> src .window , GCLP_HCURSOR , (LPARAM ) cursor );
6698- SetCursor (cursor );
6699- DestroyCursor (cursor );
6700- return 1 ;
6697+ return cursor ;
6698+ }
6699+
6700+ void RGFW_window_setMouse (RGFW_window * win , void * mouse ) {
6701+ assert (win && mouse );
6702+ SetClassLongPtrA (win -> src .window , GCLP_HCURSOR , (LPARAM ) mouse );
6703+ SetCursor ((HCURSOR )mouse );
6704+ }
6705+
6706+ void RGFW_window_freeMouse (RGFW_window * win , void * mouse ) {
6707+ assert (win && mouse );
6708+ DestroyCursor ((HCURSOR )mouse );
67016709}
67026710
67036711b32 RGFW_window_setMouseDefault (RGFW_window * win ) {
@@ -8560,7 +8568,7 @@ id NSCursor_arrowStr(const char* str) {
85608568 return (id ) objc_msgSend_id (nclass , func );
85618569}
85628570
8563- b32 RGFW_window_setMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) {
8571+ b32 RGFW_window_loadMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) {
85648572 RGFW_ASSERT (win != NULL );
85658573
85668574 if (icon == NULL ) {
@@ -9610,7 +9618,7 @@ void RGFW_window_resize(RGFW_window* win, RGFW_area a) {
96109618/* NOTE: I don't know if this is possible */
96119619void RGFW_window_moveMouse (RGFW_window * win , RGFW_point v ) { RGFW_UNUSED (win ); RGFW_UNUSED (v ); }
96129620/* this one might be possible but it looks iffy */
9613- b32 RGFW_window_setMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) { RGFW_UNUSED (win ); RGFW_UNUSED (channels ); RGFW_UNUSED (a ); RGFW_UNUSED (icon ); return 1 ; }
9621+ b32 RGFW_window_loadMouse (RGFW_window * win , u8 * icon , RGFW_area a , i32 channels ) { RGFW_UNUSED (win ); RGFW_UNUSED (channels ); RGFW_UNUSED (a ); RGFW_UNUSED (icon ); return 1 ; }
96149622
96159623const char RGFW_CURSORS [11 ][12 ] = {
96169624 "default" ,
0 commit comments