1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-05 10:00:23 +00:00

Patch to SLEEP, _KEYHIT, INP(&H60), _SCREENEXISTS for WINDOWS

Change so that modifer keypresses will only register when the window has
focus in Windows.  This corrects the issue with SLEEP, KEYHIT, and
INP(&H60) registering SHIFT, CTRL, and ALT keypresses even when the
program is not in focus or is running as a background app.

Also changed _SCREENEXISTS (and a few other window user commands) so
that they require windows to have actually registered a windows handle
for the function to return -1, and not just for glut to have finished
initializing the screen itself.
This commit is contained in:
SteveMcNeill 2017-09-23 20:24:19 -04:00
parent cc6a5fb40a
commit e264458841
4 changed files with 63 additions and 35 deletions

View file

@ -44,7 +44,7 @@
#ifdef QB64_ANDROID
#include <cstdlib> //required for system()
#include <cstdlib> //required for system()
struct android_app* android_state;
JavaVM* android_vm;
JNIEnv* android_env;
@ -29469,12 +29469,23 @@ void sub__maptriangle(int32 cull_options,float sx1,float sy1,float sx2,float sy2
if (key==GLUT_KEY_INSERT){vk=0x5200;}
#ifdef CORE_FREEGLUT
if (key==112){vk=VK+QBVK_LSHIFT;}
if (key==113){vk=VK+QBVK_RSHIFT;}
if (key==114){vk=VK+QBVK_LCTRL;}
if (key==115){vk=VK+QBVK_RCTRL;}
if (key==116){vk=VK+QBVK_LALT;}
if (key==117){vk=VK+QBVK_RALT;}
#ifdef QB64_WINDOWS
if (window_handle==GetActiveWindow()) {
if (key==112){vk=VK+QBVK_LSHIFT;}
if (key==113){vk=VK+QBVK_RSHIFT;}
if (key==114){vk=VK+QBVK_LCTRL;}
if (key==115){vk=VK+QBVK_RCTRL;}
if (key==116){vk=VK+QBVK_LALT;}
if (key==117){vk=VK+QBVK_RALT;}
}
#else
if (key==112){vk=VK+QBVK_LSHIFT;}
if (key==113){vk=VK+QBVK_RSHIFT;}
if (key==114){vk=VK+QBVK_LCTRL;}
if (key==115){vk=VK+QBVK_RCTRL;}
if (key==116){vk=VK+QBVK_LALT;}
if (key==117){vk=VK+QBVK_RALT;}
#endif
#endif
if (vk!=-1){

View file

@ -31,4 +31,6 @@ double func_coth (double num);
double func_sec (double num);
double func_csc (double num);
double func_cot (double num);
int32 func_screenicon ();
int32 func_screenicon ();
extern HWND window_handle;

View file

@ -1,20 +1,32 @@
int32 func_screenwidth () {
while (!window_exists){Sleep(100);}
return glutGet(GLUT_SCREEN_WIDTH);
#ifdef QB64_WINDOWS
while (!window_handle){Sleep(100);}
#endif
return glutGet(GLUT_SCREEN_WIDTH);
}
int32 func_screenheight () {
while (!window_exists){Sleep(100);}
return glutGet(GLUT_SCREEN_HEIGHT);
#ifdef QB64_WINDOWS
while (!window_handle){Sleep(100);}
#endif
return glutGet(GLUT_SCREEN_HEIGHT);
}
void sub_screenicon () {
while (!window_exists){Sleep(100);}
glutIconifyWindow();
#ifdef QB64_WINDOWS
while (!window_handle){Sleep(100);}
#endif
glutIconifyWindow();
return;
}
int32 func_windowexists () {
#ifdef QB64_WINDOWS
if (!window_handle){return 0;}
#endif
return -window_exists;
}
@ -23,27 +35,29 @@ int32 func__controlchr () {
}
int32 func_screenicon () {
while (!window_exists){Sleep(100);}
extern int32 screen_hide;
if (screen_hide) {error(5); return 0;}
#ifdef QB64_WINDOWS
#include <windows.h>
extern HWND window_handle;
return -IsIconic(window_handle);
#else
/*
Linux code not compiling for now
#include <X11/X.h>
#include <X11/Xlib.h>
extern Display *X11_display;
extern Window X11_window;
extern int32 screen_hide;
XWindowAttributes attribs;
while (!(X11_display && X11_window));
XGetWindowAttributes(X11_display, X11_window, &attribs);
if (attribs.map_state == IsUnmapped) return -1;
return 0;
#endif */
return 0; //if we get here and haven't exited already, we failed somewhere along the way.
#endif
while (!window_exists){Sleep(100);}
#ifdef QB64_WINDOWS
while (!window_handle){Sleep(100);}
#endif
extern int32 screen_hide;
if (screen_hide) {error(5); return 0;}
#ifdef QB64_WINDOWS
#include <windows.h>
return -IsIconic(window_handle);
#else
/*
Linux code not compiling for now
#include <X11/X.h>
#include <X11/Xlib.h>
extern Display *X11_display;
extern Window X11_window;
extern int32 screen_hide;
XWindowAttributes attribs;
while (!(X11_display && X11_window));
XGetWindowAttributes(X11_display, X11_window, &attribs);
if (attribs.map_state == IsUnmapped) return -1;
return 0;
#endif */
return 0; //if we get here and haven't exited already, we failed somewhere along the way.
#endif
}

View file

@ -3,5 +3,6 @@
#include "Steve Stuff/convert_angle.cpp"
#include "Steve Stuff/extramath.cpp"
#include "Steve Stuff/screeninfo.cpp"
#include "Steve Stuff/stringcomp.cpp"
#include "Steve Stuff/screeninfo.cpp"