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

From: Peter John Hartman <peterjohnhartman_AT_gmail.com>
Date: Sat, 29 Jan 2011 13:59:42 -0500

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.

This is a pretty minor aesthetic problem. Otherwise, enjoy.

2. I noticed today that dmenu doesn't play nice with osks. If
dmenu is opened first, and then I open an osk, everything is fine.
If the osk is opened first, and then I open dmenu, dmenu hogs the
focus and so I can't interact with it.

Anyone have a fix for this?

Here's the patch (sorry if its in a bit of a rough state):

diff -r 23b71491e149 dwm.c
--- a/dwm.c Thu Dec 02 10:16:47 2010 +0000
+++ b/dwm.c Mon Dec 20 15:42:40 2010 -0500
@@ -53,6 +53,7 @@
 #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
 #define TAGMASK ((1 << LENGTH(tags)) - 1)
 #define TEXTW(X) (textnw(X, strlen(X)) + dc.font.height)
+#define ISPANEL(x) (ISVISIBLE(x)&&(strcmp("xvkbd - Virtual Keyboard",x->name) == 0))
 
 /* enums */
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
@@ -88,7 +89,7 @@
         int basew, baseh, incw, inch, maxw, maxh, minw, minh;
         int bw, oldbw;
         unsigned int tags;
- Bool isfixed, isfloating, isurgent, oldstate;
+ Bool isfixed, isfloating, isurgent, oldstate, isfocusable;
         Client *next;
         Client *snext;
         Monitor *mon;
@@ -821,7 +822,8 @@
                 attachstack(c);
                 grabbuttons(c, True);
                 XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
- XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+ if(c->isfocusable)
+ XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
         }
         else
                 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@@ -857,17 +859,17 @@
         if(!selmon->sel)
                 return;
         if(arg->i > 0) {
- for(c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
+ for(c = selmon->sel->next; c && (!ISVISIBLE(c) || ISPANEL(c)); c = c->next);
                 if(!c)
- for(c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
+ for(c = selmon->clients; c && (!ISVISIBLE(c) || ISPANEL(c)); c = c->next);
         }
         else {
                 for(i = selmon->clients; i != selmon->sel; i = i->next)
- if(ISVISIBLE(i))
+ if(ISVISIBLE(i) && !ISPANEL(i))
                                 c = i;
                 if(!c)
                         for(; i; i = i->next)
- if(ISVISIBLE(i))
+ if(ISVISIBLE(i) && !ISPANEL(i))
                                         c = i;
         }
         if(c) {
@@ -1105,6 +1107,7 @@
         c->w = c->oldw = wa->width;
         c->h = c->oldh = wa->height;
         c->oldbw = wa->border_width;
+ c->isfocusable = True;
         if(c->w == c->mon->mw && c->h == c->mon->mh) {
                 c->isfloating = True;
                 c->x = c->mon->mx;
@@ -1936,6 +1939,7 @@
                 }
                 else
                         c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
+ c->isfocusable = !(wmh->flags & InputHint) || wmh->input;
                 XFree(wmh);
         }
 }

I also like to do the following and tuck the osk in underneath the drawbar:

In dwm.c:setup() change:

bh = dc.h = dc.font.height + 2;

to:

dc.h = dc.font.height + 2;
bh = MAX(dc.font.height +2, barheight);

Best,

Peter

-- 
sic dicit magister P
PhD Candidate
Collaborative Programme in Ancient and Medieval Philosophy
University of Toronto
http://individual.utoronto.ca/peterjh
Received on Sat Jan 29 2011 - 19:59:42 CET

This archive was generated by hypermail 2.2.0 : Sat Jan 29 2011 - 20:00:06 CET