Linux: only grab the keyboard when in fullscreen mode. Remove the alt-tab hack
This commit is contained in:
parent
4b98c873da
commit
a558ad68b2
|
@ -80,18 +80,13 @@ static void ungrabKeyboard(void) {
|
|||
void updateKeyboardGrab(void) {
|
||||
if (!created)
|
||||
return;
|
||||
if (isFullscreen() || shouldGrab()) {
|
||||
if (isFullscreen()/* || shouldGrab()*/) {
|
||||
grabKeyboard();
|
||||
} else {
|
||||
ungrabKeyboard();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_input_Keyboard
|
||||
* Method: nCreate
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
|
@ -128,11 +123,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate
|
|||
updateKeyboardGrab();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_input_Keyboard
|
||||
* Method: nDestroy
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nDestroy
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
|
@ -199,17 +189,6 @@ void handleKeyEvent(XKeyEvent *event) {
|
|||
unsigned char keycode = getKeycode(event);
|
||||
unsigned char state = eventState(event);
|
||||
key_buf[keycode] = state;
|
||||
if (key_buf[org_lwjgl_input_Keyboard_KEY_LMENU] == 1 ||
|
||||
key_buf[org_lwjgl_input_Keyboard_KEY_RMENU] == 1) {
|
||||
if (key_buf[org_lwjgl_input_Keyboard_KEY_TAB] == 1) {
|
||||
if (releaseInput()) {
|
||||
key_buf[org_lwjgl_input_Keyboard_KEY_RMENU] = 0;
|
||||
key_buf[org_lwjgl_input_Keyboard_KEY_LMENU] = 0;
|
||||
key_buf[org_lwjgl_input_Keyboard_KEY_TAB] = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buffer_enabled)
|
||||
bufferEvent(event);
|
||||
}
|
||||
|
|
|
@ -187,6 +187,9 @@ bool releaseInput(void) {
|
|||
input_released = true;
|
||||
setRepeatMode(AutoRepeatModeDefault);
|
||||
updateInputGrab();
|
||||
/* if (current_fullscreen) {
|
||||
XIconifyWindow(getDisplay(), getCurrentWindow(), getCurrentScreen());
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -323,7 +326,8 @@ static bool createWindow(JNIEnv* env, int width, int height) {
|
|||
attribs.colormap = cmap;
|
||||
attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask| StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
||||
attribs.background_pixel = 0xFF000000;
|
||||
attribmask = CWColormap | CWBackPixel | CWEventMask;
|
||||
attribs.win_gravity = NorthWestGravity;
|
||||
attribmask = CWColormap | CWBackPixel | CWEventMask | CWWinGravity;
|
||||
if (current_fullscreen || undecorated) {
|
||||
attribmask |= CWOverrideRedirect;
|
||||
attribs.override_redirect = True;
|
||||
|
@ -345,6 +349,11 @@ static bool createWindow(JNIEnv* env, int width, int height) {
|
|||
XFree(size_hints);
|
||||
delete_atom = XInternAtom(getDisplay(), "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(getDisplay(), win, &delete_atom, 1);
|
||||
/* if (current_fullscreen) {
|
||||
Atom fullscreen_atom = XInternAtom(getDisplay(), "_NET_WM_STATE_FULLSCREEN", False);
|
||||
XChangeProperty(getDisplay(), getCurrentWindow(), XInternAtom(getDisplay(), "_NET_WM_STATE", False),
|
||||
XInternAtom(getDisplay(), "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1);
|
||||
}*/
|
||||
XMapRaised(getDisplay(), win);
|
||||
waitMapped(win);
|
||||
XClearWindow(getDisplay(), win);
|
||||
|
@ -368,11 +377,6 @@ int getWindowHeight(void) {
|
|||
return current_height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: nUpdate
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nUpdate
|
||||
(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue