@@ -1734,6 +1734,8 @@ RGFWDEF void RGFW_window_basic_init(RGFW_window* win, RGFW_rect rect, RGFW_windo
1734
1734
RGFW_mouse * RGFW_hiddenMouse = NULL ;
1735
1735
#endif
1736
1736
1737
+ RGFW_window * RGFW_root = NULL ;
1738
+
1737
1739
/* do a basic initialization for RGFW_window, this is to standard it for each OS */
1738
1740
void RGFW_window_basic_init (RGFW_window * win , RGFW_rect rect , RGFW_windowFlags flags ) {
1739
1741
/* clear out dnd info */
@@ -1761,6 +1763,10 @@ void RGFW_window_basic_init(RGFW_window* win, RGFW_rect rect, RGFW_windowFlags f
1761
1763
if (flags & RGFW_windowFullscreen )
1762
1764
rect = RGFW_RECT (0 , 0 , screenR .w , screenR .h );
1763
1765
1766
+ if (RGFW_root == NULL ) {
1767
+ RGFW_root = win ;
1768
+ }
1769
+
1764
1770
#if defined(RGFW_X11 ) || defined(RGFW_WINDOWS )
1765
1771
if (RGFW_hiddenMouse == NULL ) {
1766
1772
u8 RGFW_blk [] = { 0 , 0 , 0 , 0 };
@@ -1793,8 +1799,6 @@ void RGFW_window_setBufferPtr(RGFW_window* win, u8* ptr, RGFW_area size) {
1793
1799
#endif
1794
1800
}
1795
1801
1796
- RGFW_window * RGFW_root = NULL ;
1797
-
1798
1802
#ifdef RGFW_MACOS
1799
1803
RGFWDEF void RGFW_window_cocoaSetLayer (RGFW_window * win , void * layer );
1800
1804
RGFWDEF void * RGFW_cocoaGetLayer (void );
@@ -2905,8 +2909,6 @@ RGFW_window* RGFW_createWindowPtr(const char* name, RGFW_rect rect, RGFW_windowF
2905
2909
2906
2910
win -> src .ctx = glXCreateContextAttribsARB ((Display * ) win -> src .display , bestFbc , ctx , True , context_attribs );
2907
2911
#endif
2908
- if (RGFW_root == NULL )
2909
- RGFW_root = win ;
2910
2912
2911
2913
RGFW_init_buffer (win , vi );
2912
2914
}
@@ -3684,7 +3686,7 @@ b32 RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) {
3684
3686
RGFW_mouse * RGFW_loadMouse (u8 * icon , RGFW_area a , i32 channels ) {
3685
3687
assert (icon );
3686
3688
assert (channels == 3 || channels == 4 );
3687
-
3689
+
3688
3690
#ifndef RGFW_NO_X11_CURSOR
3689
3691
XcursorImage * native = XcursorImageCreate (a .w , a .h );
3690
3692
native -> xhot = 0 ;
@@ -4236,6 +4238,11 @@ void RGFW_window_close(RGFW_window* win) {
4236
4238
RGFW_closeEGL (win );
4237
4239
#endif
4238
4240
4241
+ if (RGFW_hiddenMouse != NULL && (RGFW_windowsOpen - 1 ) <= 0 ) {
4242
+ RGFW_freeMouse (RGFW_hiddenMouse );
4243
+ RGFW_hiddenMouse = 0 ;
4244
+ }
4245
+
4239
4246
#if defined(RGFW_OSMESA ) || defined(RGFW_BUFFER )
4240
4247
if (win -> buffer != NULL ) {
4241
4248
if ((win -> _flags & RGFW_BUFFER_ALLOC ))
@@ -4305,11 +4312,6 @@ void RGFW_window_close(RGFW_window* win) {
4305
4312
close (RGFW_gamepads [i ]);
4306
4313
}
4307
4314
#endif
4308
-
4309
- if (RGFW_hiddenMouse != NULL ) {
4310
- RGFW_freeMouse (RGFW_hiddenMouse );
4311
- RGFW_hiddenMouse = 0 ;
4312
- }
4313
4315
}
4314
4316
4315
4317
RGFW_clipboard_switch (NULL );
@@ -5060,10 +5062,6 @@ RGFW_window* RGFW_createWindowPtr(const char* name, RGFW_rect rect, RGFW_windowF
5060
5062
RGFW_window_showMouse (win , 0 );
5061
5063
}
5062
5064
5063
- if (RGFW_root == NULL ) {
5064
- RGFW_root = win ;
5065
- }
5066
-
5067
5065
win -> src .eventIndex = 0 ;
5068
5066
win -> src .eventLen = 0 ;
5069
5067
@@ -5913,9 +5911,6 @@ RGFW_window* RGFW_createWindowPtr(const char* name, RGFW_rect rect, RGFW_windowF
5913
5911
5914
5912
ShowWindow (win -> src .window , SW_SHOWNORMAL );
5915
5913
5916
- if (RGFW_root == NULL )
5917
- RGFW_root = win ;
5918
-
5919
5914
#ifdef RGFW_OPENGL
5920
5915
else
5921
5916
wglShareLists (RGFW_root -> src .ctx , win -> src .ctx );
@@ -8052,9 +8047,6 @@ RGFW_window* RGFW_createWindowPtr(const char* name, RGFW_rect rect, RGFW_windowF
8052
8047
8053
8048
objc_msgSend_void (NSApp , sel_registerName ("finishLaunching" ));
8054
8049
8055
- if (RGFW_root == NULL )
8056
- RGFW_root = win ;
8057
-
8058
8050
NSRetain (win -> src .window );
8059
8051
NSRetain (NSApp );
8060
8052
@@ -9544,8 +9536,6 @@ RGFW_window* RGFW_createWindowPtr(const char* name, RGFW_rect rect, RGFW_windowF
9544
9536
RGFW_init_buffer (win );
9545
9537
glViewport (0 , 0 , rect .w , rect .h );
9546
9538
9547
- RGFW_root = win ;
9548
-
9549
9539
if (flags & RGFW_windowHideMouse ) {
9550
9540
RGFW_window_showMouse (win , 0 );
9551
9541
}
0 commit comments