mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-08 07:55:14 +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:
parent
cc6a5fb40a
commit
e264458841
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef QB64_ANDROID
|
#ifdef QB64_ANDROID
|
||||||
#include <cstdlib> //required for system()
|
#include <cstdlib> //required for system()
|
||||||
struct android_app* android_state;
|
struct android_app* android_state;
|
||||||
JavaVM* android_vm;
|
JavaVM* android_vm;
|
||||||
JNIEnv* android_env;
|
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;}
|
if (key==GLUT_KEY_INSERT){vk=0x5200;}
|
||||||
|
|
||||||
#ifdef CORE_FREEGLUT
|
#ifdef CORE_FREEGLUT
|
||||||
if (key==112){vk=VK+QBVK_LSHIFT;}
|
#ifdef QB64_WINDOWS
|
||||||
if (key==113){vk=VK+QBVK_RSHIFT;}
|
if (window_handle==GetActiveWindow()) {
|
||||||
if (key==114){vk=VK+QBVK_LCTRL;}
|
if (key==112){vk=VK+QBVK_LSHIFT;}
|
||||||
if (key==115){vk=VK+QBVK_RCTRL;}
|
if (key==113){vk=VK+QBVK_RSHIFT;}
|
||||||
if (key==116){vk=VK+QBVK_LALT;}
|
if (key==114){vk=VK+QBVK_LCTRL;}
|
||||||
if (key==117){vk=VK+QBVK_RALT;}
|
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
|
#endif
|
||||||
|
|
||||||
if (vk!=-1){
|
if (vk!=-1){
|
||||||
|
|
|
@ -31,4 +31,6 @@ double func_coth (double num);
|
||||||
double func_sec (double num);
|
double func_sec (double num);
|
||||||
double func_csc (double num);
|
double func_csc (double num);
|
||||||
double func_cot (double num);
|
double func_cot (double num);
|
||||||
int32 func_screenicon ();
|
int32 func_screenicon ();
|
||||||
|
|
||||||
|
extern HWND window_handle;
|
|
@ -1,20 +1,32 @@
|
||||||
int32 func_screenwidth () {
|
int32 func_screenwidth () {
|
||||||
while (!window_exists){Sleep(100);}
|
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 () {
|
int32 func_screenheight () {
|
||||||
while (!window_exists){Sleep(100);}
|
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 () {
|
void sub_screenicon () {
|
||||||
while (!window_exists){Sleep(100);}
|
while (!window_exists){Sleep(100);}
|
||||||
glutIconifyWindow();
|
#ifdef QB64_WINDOWS
|
||||||
|
while (!window_handle){Sleep(100);}
|
||||||
|
#endif
|
||||||
|
glutIconifyWindow();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 func_windowexists () {
|
int32 func_windowexists () {
|
||||||
|
#ifdef QB64_WINDOWS
|
||||||
|
if (!window_handle){return 0;}
|
||||||
|
#endif
|
||||||
return -window_exists;
|
return -window_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,27 +35,29 @@ int32 func__controlchr () {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 func_screenicon () {
|
int32 func_screenicon () {
|
||||||
while (!window_exists){Sleep(100);}
|
while (!window_exists){Sleep(100);}
|
||||||
extern int32 screen_hide;
|
#ifdef QB64_WINDOWS
|
||||||
if (screen_hide) {error(5); return 0;}
|
while (!window_handle){Sleep(100);}
|
||||||
#ifdef QB64_WINDOWS
|
#endif
|
||||||
#include <windows.h>
|
extern int32 screen_hide;
|
||||||
extern HWND window_handle;
|
if (screen_hide) {error(5); return 0;}
|
||||||
return -IsIconic(window_handle);
|
#ifdef QB64_WINDOWS
|
||||||
#else
|
#include <windows.h>
|
||||||
/*
|
return -IsIconic(window_handle);
|
||||||
Linux code not compiling for now
|
#else
|
||||||
#include <X11/X.h>
|
/*
|
||||||
#include <X11/Xlib.h>
|
Linux code not compiling for now
|
||||||
extern Display *X11_display;
|
#include <X11/X.h>
|
||||||
extern Window X11_window;
|
#include <X11/Xlib.h>
|
||||||
extern int32 screen_hide;
|
extern Display *X11_display;
|
||||||
XWindowAttributes attribs;
|
extern Window X11_window;
|
||||||
while (!(X11_display && X11_window));
|
extern int32 screen_hide;
|
||||||
XGetWindowAttributes(X11_display, X11_window, &attribs);
|
XWindowAttributes attribs;
|
||||||
if (attribs.map_state == IsUnmapped) return -1;
|
while (!(X11_display && X11_window));
|
||||||
return 0;
|
XGetWindowAttributes(X11_display, X11_window, &attribs);
|
||||||
#endif */
|
if (attribs.map_state == IsUnmapped) return -1;
|
||||||
return 0; //if we get here and haven't exited already, we failed somewhere along the way.
|
return 0;
|
||||||
#endif
|
#endif */
|
||||||
|
return 0; //if we get here and haven't exited already, we failed somewhere along the way.
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
|
|
||||||
#include "Steve Stuff/convert_angle.cpp"
|
#include "Steve Stuff/convert_angle.cpp"
|
||||||
#include "Steve Stuff/extramath.cpp"
|
#include "Steve Stuff/extramath.cpp"
|
||||||
#include "Steve Stuff/screeninfo.cpp"
|
|
||||||
#include "Steve Stuff/stringcomp.cpp"
|
#include "Steve Stuff/stringcomp.cpp"
|
||||||
|
#include "Steve Stuff/screeninfo.cpp"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue