@@ -64,41 +64,12 @@ const S32 MAX_NUM_RESOLUTIONS = 200;
64
64
// LLWindowSDL
65
65
//
66
66
67
- #include < X11/Xutil.h>
68
-
69
67
// TOFU HACK -- (*exactly* the same hack as LLWindowMacOSX for a similar
70
68
// set of reasons): Stash a pointer to the LLWindowSDL object here and
71
69
// maintain in the constructor and destructor. This assumes that there will
72
70
// be only one object of this class at any time. Currently this is true.
73
71
static LLWindowSDL *gWindowImplementation = nullptr ;
74
72
75
- void maybe_lock_display (void )
76
- {
77
- if (gWindowImplementation && gWindowImplementation ->Lock_Display )
78
- gWindowImplementation ->Lock_Display ();
79
- }
80
-
81
- void maybe_unlock_display (void )
82
- {
83
- if (gWindowImplementation && gWindowImplementation ->Unlock_Display )
84
- gWindowImplementation ->Unlock_Display ();
85
- }
86
-
87
-
88
- Window LLWindowSDL::get_SDL_XWindowID (void )
89
- {
90
- if (gWindowImplementation )
91
- return gWindowImplementation ->mX11Data .mXWindowID ;
92
- return None;
93
- }
94
-
95
- Display* LLWindowSDL::get_SDL_Display (void )
96
- {
97
- if (gWindowImplementation )
98
- return gWindowImplementation ->mX11Data .mDisplay ;
99
- return nullptr ;
100
- }
101
-
102
73
/*
103
74
* In wayland a window does not have a state of "minimized" or gets messages that it got minimized [1]
104
75
* There's two ways to approach this challenge:
@@ -238,8 +209,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks,
238
209
bool enable_vsync, bool use_gl,
239
210
bool ignore_pixel_depth, U32 fsaa_samples)
240
211
: LLWindow(callbacks, fullscreen, flags),
241
- Lock_Display(nullptr ),
242
- Unlock_Display(nullptr ), mGamma(1 .0f )
212
+ mGamma(1 .0f )
243
213
{
244
214
// Initialize the keyboard
245
215
gKeyboard = new LLKeyboardSDL ();
@@ -377,6 +347,14 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b
377
347
378
348
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1 );
379
349
350
+ if (LLRender::sGLCoreProfile )
351
+ {
352
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
353
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 2 );
354
+
355
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
356
+ }
357
+
380
358
U32 context_flags = 0 ;
381
359
if (gDebugGL )
382
360
{
@@ -416,36 +394,18 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b
416
394
setupFailure (" GL Context failed to set current failure" , " Error" , OSMB_OK);
417
395
}
418
396
419
- mSurface = SDL_GetWindowSurface (mWindow );
420
397
if (mFullscreen )
421
398
{
422
- if (mSurface )
423
- {
424
- mFullscreen = true ;
425
- mFullscreenWidth = mSurface ->w ;
426
- mFullscreenHeight = mSurface ->h ;
427
- mFullscreenBits = mSurface ->format ->BitsPerPixel ;
428
- mFullscreenRefresh = -1 ;
429
-
430
- LL_INFOS () << " Running at " << mFullscreenWidth
431
- << " x" << mFullscreenHeight
432
- << " x" << mFullscreenBits
433
- << " @ " << mFullscreenRefresh
434
- << LL_ENDL;
435
- }
436
- else
437
- {
438
- LL_WARNS () << " createContext: fullscreen creation failure. SDL: " << SDL_GetError () << LL_ENDL;
439
-
440
- mFullscreen = false ;
441
- mFullscreenWidth = -1 ;
442
- mFullscreenHeight = -1 ;
443
- mFullscreenBits = -1 ;
444
- mFullscreenRefresh = -1 ;
399
+ mFullscreen = true ;
400
+ SDL_GetWindowSize (mWindow , &mFullscreenWidth , &mFullscreenHeight );
401
+ mFullscreenBits = 32 ;
402
+ mFullscreenRefresh = -1 ;
445
403
446
- std::string error = llformat (" Unable to run fullscreen at %d x %d.\n Running in window." , width, height);
447
- setupFailure ( error, " Error" , OSMB_OK );
448
- }
404
+ LL_INFOS () << " Running at " << mFullscreenWidth
405
+ << " x" << mFullscreenHeight
406
+ << " x" << mFullscreenBits
407
+ << " @ " << mFullscreenRefresh
408
+ << LL_ENDL;
449
409
}
450
410
451
411
SDL_GL_GetAttribute (SDL_GL_RED_SIZE, &redBits);
@@ -499,25 +459,23 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b
499
459
/* Save the information for later use */
500
460
if (info.subsystem == SDL_SYSWM_X11)
501
461
{
502
- mX11Data .mDisplay = info.info .x11 .display ;
503
- mX11Data .mXWindowID = info.info .x11 .window ;
504
462
mServerProtocol = X11;
505
463
LL_INFOS () << " Running under X11" << LL_ENDL;
506
464
}
507
465
else if (info.subsystem == SDL_SYSWM_WAYLAND)
508
466
{
467
+ mServerProtocol = Wayland;
468
+
509
469
#ifdef LL_WAYLAND
470
+ mWaylandData .mSurface = info.info .wl .surface ;
510
471
mWaylandLoaded = loadWaylandClient ();
511
472
if (!mWaylandLoaded )
512
473
{
513
474
LL_WARNS () << " Failed to load wayland-client.so or grab required functions" << LL_ENDL;
514
475
}
515
- #endif
516
-
517
- mWaylandData .mSurface = info.info .wl .surface ;
518
- mServerProtocol = Wayland;
519
476
520
477
setupWaylandFrameCallback ();
478
+ #endif
521
479
522
480
// If set (XWayland) remove DISPLAY, this will prompt dullahan to also use Wayland
523
481
if ( getenv (" DISPLAY" ) )
@@ -537,8 +495,6 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b
537
495
}
538
496
539
497
SDL_StartTextInput ();
540
- // make sure multisampling is disabled by default
541
- glDisable (GL_MULTISAMPLE_ARB);
542
498
543
499
// Don't need to get the current gamma, since there's a call that restores it to the system defaults.
544
500
return true ;
@@ -620,10 +576,9 @@ void LLWindowSDL::destroyContext()
620
576
LL_INFOS () << " shutdownGL begins" << LL_ENDL;
621
577
gGLManager .shutdownGL ();
622
578
623
- mX11Data .mDisplay = nullptr ;
624
- mX11Data .mXWindowID = None;
625
- Lock_Display = nullptr ;
626
- Unlock_Display = nullptr ;
579
+ #ifdef LL_WAYLAND
580
+ mWaylandData .mSurface = nullptr ;
581
+ #endif
627
582
mServerProtocol = Unknown;
628
583
629
584
LL_INFOS () << " Destroying SDL cursors" << LL_ENDL;
@@ -651,9 +606,6 @@ void LLWindowSDL::destroyContext()
651
606
LL_INFOS () << " SDL Window already destroyed" << LL_ENDL;
652
607
}
653
608
LL_INFOS () << " destroyContext end" << LL_ENDL;
654
-
655
- LL_INFOS () << " SDL_QuitSS/VID begins" << LL_ENDL;
656
- SDL_QuitSubSystem (SDL_INIT_VIDEO); // *FIX: this might be risky...
657
609
}
658
610
659
611
LLWindowSDL::~LLWindowSDL ()
@@ -730,8 +682,10 @@ bool LLWindowSDL::getVisible() const
730
682
731
683
bool LLWindowSDL::getMinimized () const
732
684
{
685
+ #if LL_WAYLAND
733
686
if ( isWaylandWindowNotDrawing () )
734
687
return true ;
688
+ #endif
735
689
736
690
bool result = false ;
737
691
if (mWindow )
@@ -782,10 +736,9 @@ bool LLWindowSDL::getPosition(LLCoordScreen *position) const
782
736
783
737
bool LLWindowSDL::getSize (LLCoordScreen *size) const
784
738
{
785
- if (mSurface )
739
+ if (mWindow )
786
740
{
787
- size->mX = mSurface ->w ;
788
- size->mY = mSurface ->h ;
741
+ SDL_GetWindowSize (mWindow , &size->mX , &size->mY );
789
742
return true ;
790
743
}
791
744
@@ -794,10 +747,9 @@ bool LLWindowSDL::getSize(LLCoordScreen *size) const
794
747
795
748
bool LLWindowSDL::getSize (LLCoordWindow *size) const
796
749
{
797
- if (mSurface )
750
+ if (mWindow )
798
751
{
799
- size->mX = mSurface ->w ;
800
- size->mY = mSurface ->h ;
752
+ SDL_GetWindowSize (mWindow , &size->mX , &size->mY );
801
753
return true ;
802
754
}
803
755
@@ -1001,25 +953,12 @@ void LLWindowSDL::beforeDialog()
1001
953
if (mFullscreen && mWindow )
1002
954
SDL_SetWindowFullscreen ( mWindow , 0 );
1003
955
}
1004
-
1005
- if (mServerProtocol == X11 && mX11Data .mDisplay )
1006
- {
1007
- // Everything that we/SDL asked for should happen before we
1008
- // potentially hand control over to GTK.
1009
- maybe_lock_display ();
1010
- XSync (mX11Data .mDisplay , False);
1011
- maybe_unlock_display ();
1012
- }
1013
-
1014
- maybe_lock_display ();
1015
956
}
1016
957
1017
958
void LLWindowSDL::afterDialog ()
1018
959
{
1019
960
LL_INFOS () << " LLWindowSDL::afterDialog()" << LL_ENDL;
1020
961
1021
- maybe_unlock_display ();
1022
-
1023
962
if (mFullscreen && mWindow )
1024
963
SDL_SetWindowFullscreen ( mWindow , 0 );
1025
964
}
@@ -1106,7 +1045,6 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso
1106
1045
mSupportedResolutions = new LLWindowResolution[MAX_NUM_RESOLUTIONS];
1107
1046
mNumSupportedResolutions = 0 ;
1108
1047
1109
- // <FS:ND> Use display no from mWindow/mSurface here?
1110
1048
int max = SDL_GetNumDisplayModes (0 );
1111
1049
max = llclamp ( max, 0 , MAX_NUM_RESOLUTIONS );
1112
1050
@@ -1142,8 +1080,13 @@ bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to) const
1142
1080
if (!to)
1143
1081
return false ;
1144
1082
1083
+ if (!mWindow )
1084
+ return false ;
1085
+ S32 height;
1086
+ SDL_GetWindowSize (mWindow , nullptr , &height);
1087
+
1145
1088
to->mX = from.mX ;
1146
- to->mY = mSurface -> h - from.mY - 1 ;
1089
+ to->mY = height - from.mY - 1 ;
1147
1090
1148
1091
return true ;
1149
1092
}
@@ -1153,8 +1096,13 @@ bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to) const
1153
1096
if (!to)
1154
1097
return false ;
1155
1098
1099
+ if (!mWindow )
1100
+ return false ;
1101
+ S32 height;
1102
+ SDL_GetWindowSize (mWindow , nullptr , &height);
1103
+
1156
1104
to->mX = from.mX ;
1157
- to->mY = mSurface -> h - from.mY - 1 ;
1105
+ to->mY = height - from.mY - 1 ;
1158
1106
1159
1107
return true ;
1160
1108
}
@@ -1520,7 +1468,6 @@ void LLWindowSDL::gatherInput(bool app_has_focus)
1520
1468
S32 width = llmax (event.window .data1 , (S32)mMinWindowWidth );
1521
1469
S32 height = llmax (event.window .data2 , (S32)mMinWindowHeight );
1522
1470
1523
- mSurface = SDL_GetWindowSurface (mWindow );
1524
1471
mCallbacks ->handleResize (this , width, height);
1525
1472
break ;
1526
1473
}
0 commit comments