Linux: don't rely on focus messages, just ask for the current focus at the end of the event loop act accordingly

This commit is contained in:
Elias Naur 2004-11-06 09:41:02 +00:00
parent e2dfdb2b9a
commit d3cc993523
1 changed files with 9 additions and 5 deletions

View File

@ -245,13 +245,16 @@ static void checkInput(void) {
if (win == current_win) { if (win == current_win) {
acquireInput(); acquireInput();
focused = true; focused = true;
} else {
releaseInput();
focused = false;
} }
} }
void handleMessages(void) { void handleMessages(void) {
XEvent event; XEvent event;
Window win; /* Window win;
int revert_mode; int revert_mode;*/
while (XPending(getDisplay()) > 0) { while (XPending(getDisplay()) > 0) {
XNextEvent(getDisplay(), &event); XNextEvent(getDisplay(), &event);
if (XFilterEvent(&event, None) == True) if (XFilterEvent(&event, None) == True)
@ -263,7 +266,7 @@ void handleMessages(void) {
} else if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == delete_atom)) } else if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == delete_atom))
closerequested = true; closerequested = true;
break; break;
case FocusOut: /* case FocusOut:
XGetInputFocus(getDisplay(), &win, &revert_mode); XGetInputFocus(getDisplay(), &win, &revert_mode);
if (win != current_win) { if (win != current_win) {
releaseInput(); releaseInput();
@ -272,7 +275,7 @@ void handleMessages(void) {
break; break;
case FocusIn: case FocusIn:
checkInput(); checkInput();
break; break;*/
case MapNotify: case MapNotify:
dirty = true; dirty = true;
minimized = false; minimized = false;
@ -299,6 +302,7 @@ void handleMessages(void) {
break; break;
} }
} }
checkInput();
} }
static void setWindowTitle(const char *title) { static void setWindowTitle(const char *title) {
@ -367,7 +371,7 @@ static bool createWindow(JNIEnv* env, int x, int y, int width, int height) {
root_win = RootWindow(getDisplay(), getCurrentScreen()); root_win = RootWindow(getDisplay(), getCurrentScreen());
cmap = XCreateColormap(getDisplay(), root_win, vis_info->visual, AllocNone); cmap = XCreateColormap(getDisplay(), root_win, vis_info->visual, AllocNone);
attribs.colormap = cmap; attribs.colormap = cmap;
attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; attribs.event_mask = ExposureMask | /*FocusChangeMask | */VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
attribs.background_pixel = 0xFF000000; attribs.background_pixel = 0xFF000000;
attribs.win_gravity = NorthWestGravity; attribs.win_gravity = NorthWestGravity;
attribmask = CWColormap | CWBackPixel | CWEventMask | CWWinGravity; attribmask = CWColormap | CWBackPixel | CWEventMask | CWWinGravity;