diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/window/window.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/window/window.c b/src/window/window.c index 1df12e0..3f902e3 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -360,8 +360,6 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window return -1; } - XSetICFocus(x11_context->xic); - self->open = true; self->focused = false; /* TODO: Check if we need to call XGetInputFocus for this, or just wait for focus event */ return 0; @@ -572,11 +570,23 @@ static void mgl_window_on_receive_event(mgl_window *self, XEvent *xev, mgl_event return; } case FocusIn: { + x11_context *x11_context = self->context; + XSetICFocus(x11_context->xic); + + XWMHints* hints = XGetWMHints(context->connection, self->window); + if(hints) { + hints->flags &= ~XUrgencyHint; + XSetWMHints(context->connection, self->window, hints); + XFree(hints); + } + event->type = MGL_EVENT_GAINED_FOCUS; self->focused = true; return; } case FocusOut: { + x11_context *x11_context = self->context; + XUnsetICFocus(x11_context->xic); event->type = MGL_EVENT_LOST_FOCUS; self->focused = false; return; @@ -690,7 +700,8 @@ bool mgl_window_poll_event(mgl_window *self, mgl_event *event) { if(XPending(display)) { XEvent xev; /* TODO: Move to window struct */ XNextEvent(display, &xev); - mgl_window_on_receive_event(self, &xev, event, context); + if(xev.xany.window == self->window || event->type == ClientMessage) + mgl_window_on_receive_event(self, &xev, event, context); return true; } else { return false; |