Re: [dev] onscreen keyboards (xvkbd), dwm, and dmenu (part II with a patch to dwm)

From: Łukasz Pankowski <>
Date: Sat, 29 Jan 2011 21:22:46 +0100

Peter John Hartman <> writes:

> Hi folks,
> A few things:
> 1. Below is a very simple patch to dwm to make it play nice with onscreen
> keyboards. It could be improved, and especially I want to implement
> this:
> * If the osk (on screen keyboard, e.g., xvkbd) has the focus but it is
> focused on, say, app Q, then app Q and not osk should show up in the
> drawbar title.

Hi to everyone,

It is my first post to this list.

I yesterday tried to do the same thing with svkbd (,
prepared similar patch, and only than I found the right solution is in...
the starting comment of dwm.c -- use override_redirect:

 * Each child of the root window is called a client, except windows which have
 * set the override_redirect flag. Clients are organized in a linked client
 * list on each monitor, the focus history is remembered through a stack list
 * on each monitor. Each client contains a bit array to indicate the tags of a
 * client.

Below is my patch that fixes svkbd to use override_redirect so that dwm
does not manage it (the CopyFromParent just works, but I do not know if
this is the best thing to do):

Another issue is to shrink the client area available to the managed
clients so that the keyboard does not cover the clients. Probably
a meter of taste, but it is not nice to write to the client where the
cursor is covered by the keyboard and you do not see what you are
writing (that is on the Neo FreeRunner screen). There is a heuristic in
dwm that if a client asks for a geometry equal to the dimensions of the
screen it is considered to be asking for the fullscreen mode and it also
covers dwm bar. One could use similar heuristic to detect an on screen
keyboard -- if a not managed window has the geometry that covers the
full width of the screen and extends exactly to the bottom of the screen
than it is an on screen keyboard (or a bottom bar, but I care for the
keyboard only) and then the client area would be shrank not to cover the
keyboard. But I have not prepared this patch yet.


Fix svkbd to use override_redirect so dwm will not manage svkbd window:

diff -r 5a356042d49c svkbd.c
--- a/svkbd.c Tue Aug 10 23:15:12 2010 +0200
+++ b/svkbd.c Sat Jan 29 21:21:30 2011 +0100
@@ -309,6 +309,7 @@
 setup(void) {
         int i;
         XWMHints *wmh;
+ XSetWindowAttributes wa;
         /* init screen */
         screen = DefaultScreen(dpy);
@@ -331,7 +332,12 @@
         for(i = 0; i < LENGTH(keys); i++)
                 keys[i].pressed = 0;
- win = XCreateSimpleWindow(dpy, root, wx, wy, ww, wh, 0, dc.norm[ColFG], dc.norm[ColBG]);
+ wa.override_redirect = True;
+ wa.border_pixel = dc.norm[ColFG];
+ wa.background_pixel = dc.norm[ColBG];
+ win = XCreateWindow(dpy, root, wx, wy, ww, wh, 0,
+ CopyFromParent, CopyFromParent, CopyFromParent,
+ CWOverrideRedirect | CWBorderPixel | CWBackingPixel, &wa);
         XSelectInput(dpy, win, StructureNotifyMask|ButtonReleaseMask|
         wmh = XAllocWMHints();
Received on Sat Jan 29 2011 - 21:22:46 CET

This archive was generated by hypermail 2.2.0 : Sat Jan 29 2011 - 22:00:05 CET