1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 15:00:38 +00:00

Change to _screenwidth and _screenheight

Having windows call GetSystemMetrics without relying on glutGet, gets rid of the seg fault that can occur at program start up.  screenicon was restored to it's previous state so that larger issues with it can be addressed at a future date.
This commit is contained in:
SteveMcNeill 2022-05-16 11:37:58 -04:00
parent acbeca81b9
commit 8574c1f921

View file

@ -27355,25 +27355,11 @@ void sub__icon(int32 handle_icon, int32 handle_window_icon, int32 passed) {
#endif // DEPENDENCY_ICON
int32 func_screenwidth() {
#ifdef QB64_GLUT
//while (!window_exists) {
// Sleep(100); //endless loop which is completely unneeded here.
//} //we can get the desktop's width and height without there needing to be an active screen (such as $SCREENHIDE)
# ifdef QB64_WINDOWS
int32 waited_enough = 20;
while (!window_handle&&waited_enough>0) {
Sleep(100);
waited_enough = waited_enough - 1;
}
if (waited_enough == 0) return 0; //if the screen isn't created and doesn't have a handle after two seconds, then return a value of 0. Don't run an endless loop!
# endif
return glutGet(GLUT_SCREEN_WIDTH);
#else
# ifdef QB64_WINDOWS
#ifdef QB64_WINDOWS
return GetSystemMetrics(0);
#else
# ifdef QB64_GLUT
return glutGet(GLUT_SCREEN_WIDTH);
# else
return 0;
# endif
@ -27381,25 +27367,11 @@ int32 func_screenwidth() {
}
int32 func_screenheight() {
#ifdef QB64_GLUT
//while (!window_exists) {
// Sleep(100); //same comments as above -- endless loopfor unneeded window handle check here.
//}
# ifdef QB64_WINDOWS
int32 waited_enough = 20;
while (!window_handle && waited_enough > 0) {
Sleep(100);
waited_enough = waited_enough - 1;
}
if (waited_enough == 0)
return 0; // if the screen isn't created and doesn't have a handle after two seconds, then return a value of 0. Don't run an endless loop!
# endif
return glutGet(GLUT_SCREEN_HEIGHT);
#else
# ifdef QB64_WINDOWS
#ifdef QB64_WINDOWS
return GetSystemMetrics(1);
#else
# ifdef QB64_GLUT
return glutGet(GLUT_SCREEN_HEIGHT);
# else
return 0;
# endif
@ -27408,21 +27380,15 @@ int32 func_screenheight() {
void sub_screenicon() {
#ifdef QB64_GLUT
int32 waited_enough = 20;
while (!window_exists&&waited_enough>0) {
while (!window_exists) {
Sleep(100);
waited_enough = waited_enough - 1; //don't make this an endless loop. Give it an exit condition for some sort after a few seconds!
}
# ifdef QB64_WINDOWS
while (!window_handle && waited_enough > 0) {
while (!window_handle) {
Sleep(100);
waited_enough = waited_enough - 1; //same here. Endless loops are a bad no-no!
}
# endif
if (waited_enough == 0)
return; // if the screen isn't created and doesn't have a handle after two seconds, then just return and don't try to minimize the window.
glutIconifyWindow();
return;
#endif