From 108dd1bec22ffe9841eb383f7b4598d493860af6 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Thu, 21 Apr 2011 08:31:52 +0000 Subject: [PATCH] Explicitly request keyboard focus. This fixes problems with Maemo5 on a Nokia N900. Debugged and initial patch by Aapo Rantalainen (Thanks!) --- src/conio/x_cio.c | 8 ++++++++ src/conio/x_events.c | 9 +++++++++ src/conio/x_events.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/src/conio/x_cio.c b/src/conio/x_cio.c index c465872087..30d6acbc63 100644 --- a/src/conio/x_cio.c +++ b/src/conio/x_cio.c @@ -324,6 +324,14 @@ int x_init(void) xp_dlclose(dl); return(-1); } + if((x11.XAllocWMHints=xp_dlsym(dl,XAllocWMHints))==NULL) { + xp_dlclose(dl); + return(-1); + } + if((x11.XSetWMProperties=xp_dlsym(dl,XSetWMProperties))==NULL) { + xp_dlclose(dl); + return(-1); + } if(sem_init(&pastebuf_set, 0, 0)) return(-1); diff --git a/src/conio/x_events.c b/src/conio/x_events.c index e7a1b9b33b..81d0e954fc 100644 --- a/src/conio/x_events.c +++ b/src/conio/x_events.c @@ -195,6 +195,7 @@ static int init_window() XColor color; int i; XWindowAttributes attr; + XWMHints *wmhints; dpy = x11.XOpenDisplay(NULL); if (dpy == NULL) { @@ -210,6 +211,14 @@ static int init_window() win = x11.XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1, 1, 2, black, black); + wmhints=x11.XAllocWMHints(); + if(wmhints) { + wmhints->initial_state=NormalState; + wmhints->flags = (StateHint | IconPixmapHint | IconMaskHint | InputHint); + wmhints->input = True; + x11.XSetWMProperties(dpy, win, NULL, NULL, 0, 0, NULL, wmhints, NULL); + } + gcv.function = GXcopy; gcv.foreground = white; gcv.background = black; diff --git a/src/conio/x_events.h b/src/conio/x_events.h index 49cfd4cc04..c19e1310e0 100644 --- a/src/conio/x_events.h +++ b/src/conio/x_events.h @@ -78,6 +78,8 @@ struct x11 { int (*XSetIconName) (Display*, Window, _Xconst char *); int (*XSynchronize) (Display*, Bool); Status (*XGetWindowAttributes) (Display*,Window,XWindowAttributes*); + XWMHints* (*XAllocWMHints) (void); + void (*XSetWMProperties) (Display*, Window, XTextProperty*, XTextProperty*, char**, int, XSizeHints*, XWMHints*, XClassHint*); }; -- GitLab