aboutsummaryrefslogtreecommitdiff
path: root/src/window
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-11-27 19:33:20 +0100
committerdec05eba <dec05eba@protonmail.com>2024-11-27 19:33:20 +0100
commit7acea115d95f57427ff8e34411d25ef5d9f46f49 (patch)
tree502be6d1c3b59b74fd3f79c077d9fabfaf048e63 /src/window
parent3101f4bf13b0f2129c24c6b35f75b040502baaa2 (diff)
Only do XCheckTypedWindowEvent if not injected event
Diffstat (limited to 'src/window')
-rw-r--r--src/window/window.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/window/window.c b/src/window/window.c
index 5fcd466..2efb161 100644
--- a/src/window/window.c
+++ b/src/window/window.c
@@ -1373,7 +1373,7 @@ static bool mgl_on_rr_notify(mgl_context *context, x11_context *x11_context, XEv
return false;
}
-static void mgl_window_on_receive_event(mgl_window *self, XEvent *xev, mgl_event *event, mgl_context *context) {
+static void mgl_window_on_receive_event(mgl_window *self, XEvent *xev, mgl_event *event, mgl_context *context, bool injected) {
x11_context *x11_context = self->context;
switch(xev->type - context->randr_event_base) {
case RRScreenChangeNotify: {
@@ -1465,7 +1465,9 @@ static void mgl_window_on_receive_event(mgl_window *self, XEvent *xev, mgl_event
return;
}
case ConfigureNotify: {
- while(XCheckTypedWindowEvent(context->connection, self->window, ConfigureNotify, xev)) {}
+ if(!injected)
+ while(XCheckTypedWindowEvent(context->connection, self->window, ConfigureNotify, xev)) {}
+
if(xev->xconfigure.x != self->pos.x || xev->xconfigure.y != self->pos.y) {
mgl_window_on_move(self, xev->xconfigure.x, xev->xconfigure.y);
}
@@ -1483,7 +1485,9 @@ static void mgl_window_on_receive_event(mgl_window *self, XEvent *xev, mgl_event
return;
}
case MotionNotify: {
- while(XCheckTypedWindowEvent(context->connection, self->window, MotionNotify, xev)) {}
+ if(!injected)
+ while(XCheckTypedWindowEvent(context->connection, self->window, MotionNotify, xev)) {}
+
self->cursor_position.x = xev->xmotion.x;
self->cursor_position.y = xev->xmotion.y;
@@ -1593,7 +1597,7 @@ bool mgl_window_poll_event(mgl_window *self, mgl_event *event) {
XEvent xev; /* TODO: Move to window struct */
XNextEvent(display, &xev);
if(xev.xany.window == self->window || xev.type == ClientMessage || xev.type - context->randr_event_base >= 0)
- mgl_window_on_receive_event(self, &xev, event, context);
+ mgl_window_on_receive_event(self, &xev, event, context, false);
else
event->type = MGL_EVENT_UNKNOWN;
return true;
@@ -1605,7 +1609,7 @@ bool mgl_window_poll_event(mgl_window *self, mgl_event *event) {
bool mgl_window_inject_x11_event(mgl_window *self, XEvent *xev, mgl_event *event) {
mgl_context *context = mgl_get_context();
event->type = MGL_EVENT_UNKNOWN;
- mgl_window_on_receive_event(self, xev, event, context);
+ mgl_window_on_receive_event(self, xev, event, context, true);
return event->type != MGL_EVENT_UNKNOWN;
}