aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-11 02:26:19 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-11 02:26:19 +0100
commit131a2f0b5c51fc821224bf7637ba58df0a5ae15a (patch)
tree9cd42c3c3aafb2b084322881d5eddb0156284859 /src
parent6042e1843023e1f4e0f4c60da8458703b3bc58cf (diff)
Set ic focus on focus, remove urgency hint on focus
Diffstat (limited to 'src')
-rw-r--r--src/window/window.c17
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;