Linux: When parented, take focus on click

This commit is contained in:
Elias Naur 2008-04-09 18:09:15 +00:00
parent c5aa4d7b09
commit b5c893d207
3 changed files with 7 additions and 4 deletions

View file

@ -50,6 +50,7 @@ import org.lwjgl.LWJGLUtil;
final class LinuxDisplay implements DisplayImplementation {
/* X11 constants */
public final static int CurrentTime = 0;
public final static int GrabSuccess = 0;
public final static int AutoRepeatModeOff = 0;
public final static int AutoRepeatModeOn = 1;
@ -620,7 +621,7 @@ final class LinuxDisplay implements DisplayImplementation {
return peer_info;
}
private native static void setInputFocus(long display, long window);
static native void setInputFocus(long display, long window, long time);
private void processEvents() {
while (LinuxEvent.getPending(getDisplay()) > 0) {
@ -754,7 +755,7 @@ final class LinuxDisplay implements DisplayImplementation {
grabServer(getDisplay());
try {
if (nGetInputFocus(getDisplay()) == current_focus)
setInputFocus(getDisplay(), getWindow());
setInputFocus(getDisplay(), getWindow(), CurrentTime);
} finally {
ungrabServer(getDisplay());
}

View file

@ -280,6 +280,8 @@ final class LinuxMouse {
case LinuxEvent.ButtonPress: /* Fall through */
case LinuxEvent.ButtonRelease:
handleButtonEvent(grab, event.getButtonTime(), event.getButtonType(), (byte)event.getButtonButton());
if (Display.getParent() != null)
LinuxDisplay.setInputFocus(display, window, event.getButtonTime());
return true;
case LinuxEvent.MotionNotify:
handlePointerMotion(grab, warp_pointer, event.getButtonTime(), event.getButtonRoot(), event.getButtonXRoot(), event.getButtonYRoot(), event.getButtonX(), event.getButtonY());