aboutsummaryrefslogtreecommitdiffstats
path: root/src/x11.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/x11.c')
-rw-r--r--src/x11.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/x11.c b/src/x11.c
index 455ee20..1c022e6 100644
--- a/src/x11.c
+++ b/src/x11.c
@@ -795,7 +795,16 @@ translateEvent(PuglView* const view, XEvent xevent)
PuglStatus
puglGrabFocus(PuglView* const view)
{
- PuglInternals* const impl = view->impl;
+ PuglInternals* const impl = view->impl;
+ XWindowAttributes attrs = {0};
+
+ if (!impl->win || !XGetWindowAttributes(impl->display, impl->win, &attrs)) {
+ return PUGL_UNKNOWN_ERROR;
+ }
+
+ if (attrs.map_state != IsViewable) {
+ return PUGL_FAILURE;
+ }
XSetInputFocus(impl->display, impl->win, RevertToNone, CurrentTime);
return PUGL_SUCCESS;