@@ -101,6 +101,7 @@ typedef HRESULT(WINAPI * GETDPIFORMONITOR_T)(HMONITOR, MONITOR_DPI_TYPE, UINT*,
101
101
extern HINSTANCE App_Instance ; // Set by winmain function
102
102
extern void Host_Crash (char * reason );
103
103
extern LRESULT CALLBACK REBOL_Window_Proc (HWND hwnd , UINT msg , WPARAM wParam , LPARAM lParam );
104
+ extern LRESULT CALLBACK REBOL_OpenGL_Proc (HWND hwnd , UINT msg , WPARAM wParam , LPARAM lParam );
104
105
105
106
//***** Locals *****//
106
107
@@ -112,6 +113,7 @@ static struct gob_window *Gob_Windows;
112
113
static REBOOL DPI_Aware = FALSE;
113
114
static REBOOL Custom_Cursor = FALSE;
114
115
static HFONT Default_Font = NULL ;
116
+ static REBOOL Windows8_And_Newer = FALSE;
115
117
116
118
static u32 * window_ext_words ;
117
119
@@ -311,7 +313,7 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
311
313
312
314
wc .hIcon = LoadIcon (App_Instance , MAKEINTRESOURCE (101 ));
313
315
wc .hCursor = LoadCursor (NULL , IDC_ARROW );
314
- wc .hbrBackground = NULL ;
316
+ wc .hbrBackground = ( HBRUSH ) COLOR_WINDOW ;
315
317
wc .style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ;
316
318
317
319
wc .cbClsExtra = 0 ;
@@ -328,6 +330,10 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
328
330
329
331
if (!RegisterClassEx (& wc )) Host_Crash ("Cannot register window" );
330
332
333
+ wc .lpfnWndProc = REBOL_OpenGL_Proc ;
334
+ wc .lpszClassName = TXT ("RebOpenGL" );
335
+ if (!RegisterClassEx (& wc )) puts ("Failed to register OpenGL class" );
336
+
331
337
Make_Subclass (Class_Name_Button , TEXT ("BUTTON" ), NULL , TRUE);
332
338
333
339
Registered = TRUE;
@@ -543,7 +549,10 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
543
549
REBOOL changed ;
544
550
compositor = GOB_COMPOSITOR (gob );
545
551
changed = OS_Resize_Window_Buffer (compositor , gob );
546
- if (redraw ) OS_Compose_Gob (compositor , gob , gob , FALSE); // what if not actually resized?
552
+ if (redraw ) {
553
+ OS_Compose_Gob (compositor , gob , gob , FALSE); // what if not actually resized?
554
+ OS_Blit_Window (compositor );
555
+ }
547
556
return changed ;
548
557
}
549
558
@@ -635,7 +644,7 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
635
644
//render and blit the GOB
636
645
compositor = GOB_COMPOSITOR (wingob );
637
646
OS_Compose_Gob (compositor , wingob , gob , FALSE);
638
- OS_Blit_Window (compositor );
647
+ // OS_Blit_Window(compositor); //@@ When used, the content overwrites native widgets which are than invisible:/
639
648
}
640
649
641
650
@@ -709,6 +718,10 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
709
718
}
710
719
return 0 ;
711
720
}
721
+ // Is it a native widget?
722
+ else if (GOBT_WIDGET == GOB_TYPE (gob )) {
723
+ RedrawWindow ((HWND )VAL_HANDLE (GOB_WIDGET_HANDLE (gob )), NULL , NULL , RDW_INVALIDATE | RDW_ERASE );
724
+ }
712
725
// Is it a window gob that needs to be closed?
713
726
else if (!GOB_PARENT (gob ) && GET_GOB_FLAG (gob , GOBF_WINDOW )) {
714
727
OS_Close_Window (gob );
@@ -819,6 +832,10 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
819
832
class = TXT ("BUTTON" );
820
833
style |= BS_GROUPBOX ;
821
834
break ;
835
+ case W_WINDOW_OPENGL :
836
+ class = TXT ("RebOpenGL" );
837
+ style |= CS_OWNDC ;
838
+ break ;
822
839
default :
823
840
//RL_Print("unknown widget name");
824
841
return NULL ;
@@ -1339,18 +1356,32 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
1339
1356
Cursor = LoadCursor (NULL , IDC_ARROW );
1340
1357
Init_DPI_Awareness ();
1341
1358
1359
+ // Get information about system version
1360
+ // https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_osversioninfoa
1361
+ OSVERSIONINFO vi ;
1362
+ GetVersionEx (& vi );
1342
1363
1343
- INITCOMMONCONTROLSEX InitCtrlEx ;
1344
- InitCtrlEx .dwSize = sizeof (INITCOMMONCONTROLSEX );
1345
- InitCtrlEx .dwICC = ICC_STANDARD_CLASSES
1346
- | ICC_LINK_CLASS
1347
- | ICC_UPDOWN_CLASS
1348
- | ICC_LISTVIEW_CLASSES
1349
- | ICC_PROGRESS_CLASS
1350
- | ICC_BAR_CLASSES
1351
- | ICC_DATE_CLASSES ;
1352
- if (!InitCommonControlsEx (& InitCtrlEx )) {
1353
- RL_Print ("Could not initialize common controls! (%u)\n" , GetLastError ());
1364
+ if (
1365
+ vi .dwMajorVersion >= 10 // Windows10 and newer
1366
+ | (vi .dwMajorVersion >= 6 && vi .dwMinorVersion >= 2 ) //Win8
1367
+ ) {
1368
+ Windows8_And_Newer = TRUE;
1369
+ }
1370
+
1371
+ if (!(vi .dwMajorVersion == 5 && vi .dwMinorVersion < 1 )) {
1372
+ // Enable visual styles (not for Win2000)
1373
+ INITCOMMONCONTROLSEX InitCtrlEx ;
1374
+ InitCtrlEx .dwSize = sizeof (INITCOMMONCONTROLSEX );
1375
+ InitCtrlEx .dwICC = ICC_STANDARD_CLASSES
1376
+ | ICC_LINK_CLASS
1377
+ | ICC_UPDOWN_CLASS
1378
+ | ICC_LISTVIEW_CLASSES
1379
+ | ICC_PROGRESS_CLASS
1380
+ | ICC_BAR_CLASSES
1381
+ | ICC_DATE_CLASSES ;
1382
+ if (!InitCommonControlsEx (& InitCtrlEx )) {
1383
+ RL_Print ("Could not initialize common controls!\n" );
1384
+ }
1354
1385
}
1355
1386
}
1356
1387
0 commit comments