Re: [dwm] Virtual keyboards

2009-02-09 Thread Peter Hartlich
Hi Anselm,

>>> It appears to me that both the onscreen keyboard and the client with
>>> the input focus should have a selfg border -- at least that makes most
>>> sense in my opinion.

>> But you need to be able to distinguish between dwm's _selected_ (for
>> tagging, closing etc.) client and X's _focused_ client.

What I meant was imagine you have an unselected but focused window (e.g.
a vkbd) and an unfocused but selected other window (e.g. a terminal). If
both get the same border, how would you know which one will close if you
press Shift+Mod+c? (Except looking at the window title and guessing.)

> What's wrong with focussing the next in the stack?

Instead of focusing the last focused window saved in foc, if I understand
you right? Wouldn't that make using a virtual keyboard pretty hard?

Regards,
Peter



Re: [dwm] Virtual keyboards

2009-02-09 Thread Anselm R Garbe
Hi Peter,

2009/2/9 Peter Hartlich :
>> It appears to me that both the onscreen keyboard and the client with
>> the input focus should have a selfg border -- at least that makes most
>> sense in my opinion.
>
> But you need to be able to distinguish between dwm's _selected_ (for
> tagging, closing etc.) client and X's _focused_ client. Killing your
> terminal window on accident could be awful.

What's wrong with focussing the next in the stack?

>> Introducing another couple just for that sounds quite over-engineered
>> to me.
>
> Agreed.
>
> What I would propose is the attached series of patches for hg import:
> The first renames focus() to selclient() and focusstack() to selstack().
> The second adds a new focus() function calling XSetInputFocus() and
> saving the client in a global foc (analogue to sel) variable; it then
> implements isfocusable based on the Gottox port + selfgcolor border
> for focused, but unselected windows.

Agreed, I'll apply your patches.

> By the way, your last commits have "a...@null" as the author?

I will address this. I'm using a fresh host.

Kind regards,
--Anselm



Re: [dwm] Virtual keyboards

2009-02-08 Thread Peter Hartlich
Hi Anselm,

> It appears to me that both the onscreen keyboard and the client with
> the input focus should have a selfg border -- at least that makes most
> sense in my opinion.

But you need to be able to distinguish between dwm's _selected_ (for
tagging, closing etc.) client and X's _focused_ client. Killing your
terminal window on accident could be awful.

> Introducing another couple just for that sounds quite over-engineered
> to me.

Agreed.

What I would propose is the attached series of patches for hg import:
The first renames focus() to selclient() and focusstack() to selstack().
The second adds a new focus() function calling XSetInputFocus() and
saving the client in a global foc (analogue to sel) variable; it then
implements isfocusable based on the Gottox port + selfgcolor border
for focused, but unselected windows.

By the way, your last commits have "a...@null" as the author?

Regards,
Peter
>From 21a07081c462ba83851d4bc120fd02be3692fe7a Mon Sep 17 00:00:00 2001
From: Peter Hartlich 
Date: Mon, 9 Feb 2009 01:13:29 +0059
Subject: [PATCH 1/2] rename focus to selclient, focusstack to selstack

---
 config.def.h |4 +-
 dwm.c|  114 +-
 2 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/config.def.h b/config.def.h
index bb60471..03dc235 100644
--- a/config.def.h
+++ b/config.def.h
@@ -56,8 +56,8 @@ static Key keys[] = {
{ MODKEY,   XK_p,  spawn,  {.v = 
dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn,  {.v = 
termcmd } },
{ MODKEY,   XK_b,  togglebar,  {0} },
-   { MODKEY,   XK_j,  focusstack, {.i = +1 } },
-   { MODKEY,   XK_k,  focusstack, {.i = -1 } },
+   { MODKEY,   XK_j,  selstack,   {.i = +1 } },
+   { MODKEY,   XK_k,  selstack,   {.i = -1 } },
{ MODKEY,   XK_h,  setmfact,   {.f = -0.05} 
},
{ MODKEY,   XK_l,  setmfact,   {.f = +0.05} 
},
{ MODKEY,   XK_Return, zoom,   {0} },
diff --git a/dwm.c b/dwm.c
index db9e9c0..489fe0e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -149,9 +149,7 @@ static void drawsquare(Bool filled, Bool empty, Bool 
invert, unsigned long col[C
 static void drawtext(const char *text, unsigned long col[ColLast], Bool 
invert);
 static void enternotify(XEvent *e);
 static void expose(XEvent *e);
-static void focus(Client *c);
 static void focusin(XEvent *e);
-static void focusstack(const Arg *arg);
 static Client *getclient(Window w);
 static unsigned long getcolor(const char *colstr);
 static long getstate(Window w);
@@ -175,6 +173,8 @@ static void resizemouse(const Arg *arg);
 static void restack(void);
 static void run(void);
 static void scan(void);
+static void selclient(Client *c);
+static void selstack(const Arg *arg);
 static void setclientstate(Client *c, long state);
 static void setlayout(const Arg *arg);
 static void setmfact(const Arg *arg);
@@ -288,7 +288,7 @@ arrange(void) {
 
for(nt = 0, c = nexttiled(clients); c; c = nexttiled(c->next), nt++);
showhide(stack, nt);
-   focus(NULL);
+   selclient(NULL);
if(lt[sellt]->arrange)
lt[sellt]->arrange();
restack();
@@ -329,7 +329,7 @@ buttonpress(XEvent *e) {
click = ClkWinTitle;
}
else if((c = getclient(ev->window))) {
-   focus(c);
+   selclient(c);
click = ClkClientWin;
}
 
@@ -603,9 +603,9 @@ enternotify(XEvent *e) {
if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && 
ev->window != root)
return;
if((c = getclient(ev->window)))
-   focus(c);
+   selclient(c);
else
-   focus(NULL);
+   selclient(NULL);
 }
 
 void
@@ -617,29 +617,6 @@ expose(XEvent *e) {
 }
 
 void
-focus(Client *c) {
-   if(!c || !ISVISIBLE(c))
-   for(c = stack; c && !ISVISIBLE(c); c = c->snext);
-   if(sel && sel != c) {
-   grabbuttons(sel, False);
-   XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
-   }
-   if(c) {
-   if(c->isurgent)
-   clearurgent(c);
-   detachstack(c);
-   attachstack(c);
-   grabbuttons(c, True);
-   XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
-   XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
-   }
-   else
-   XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
-   sel = c;
-   drawbar();
-}
-
-void
 focusin(XEvent *e) { /* there are some broken focus acquiring clients */
XFocusChangeEvent *ev = &e->xfocus;
 
@@ -647,32 +624,6 @@ focusin(XEvent *e) { /* the

Re: [dwm] Virtual keyboards

2009-02-08 Thread Anselm R Garbe
Hi Peter,

2009/1/31 Peter Hartlich :
>> I like this patch and will apply it to 5.4 which is going to be
>> released until the weekend.
>
> One problem with it is that you don't really know where keyboard input
> will be going (dwm being focus-follows-mouse by default). I use another
> patch on top of that (attached) to draw a selfgcolor border around the
> last focusable window when an unfocusable window is selected, but I'm
> not sure recycling selfgcolor is kosher...
>
> Plus you may want to rename focus() to selectwin() or something.

I see. I think the whole unfocussable stuff needs further thinking
before going mainstream. I'm going to release 5.4 now.

It appears to me that both the onscreen keyboard and the client with
the input focus should have a selfg border -- at least that makes most
sense in my opinion. Introducing another couple just for that sounds
quite over-engineered to me.

>> I should get broadband today that I'll be ack online and can support
>> questions regarding my upcoming st and libtg release.
>
> So, when's the st release and does libtg (if that's the name of the
> not-completely-secret project) use XCB? :)

Well, I changed my mind several times during the last weeks. When I
get time I end up thinking that several decisions I made are wrong by
nature... but I will come up with one way or another soon. I'm not too
convinced libtg as it is (X abstraction primitives + text format
processing + parts of text window abstractions and input handling) is
the right way to go. I feel remembered at the wmii times, when wmii
was screwed up due to depending on its 9P scripting interface. I
believe I did the same journey with st making it dependent on libtg,
and I tend to revert this mistake at the moment.

Kind regards,
--Anselm



Re: [dwm] Virtual keyboards

2009-01-31 Thread Peter Hartlich
> Plus you may want to rename focus() to selectwin() or something.

Uh, selectclient().

Regards,
Peter



Re: [dwm] Virtual keyboards

2009-01-31 Thread Peter Hartlich
Hi Anselm,

> I like this patch and will apply it to 5.4 which is going to be
> released until the weekend.

One problem with it is that you don't really know where keyboard input
will be going (dwm being focus-follows-mouse by default). I use another
patch on top of that (attached) to draw a selfgcolor border around the
last focusable window when an unfocusable window is selected, but I'm
not sure recycling selfgcolor is kosher...

Plus you may want to rename focus() to selectwin() or something.

> I should get broadband today that I'll be ack online and can support
> questions regarding my upcoming st and libtg release.

So, when's the st release and does libtg (if that's the name of the
not-completely-secret project) use XCB? :)

Regards,
Peter
diff --git a/dwm.c b/dwm.c
index 133f420..56f9485 100644
--- a/dwm.c
+++ b/dwm.c
@@ -232,6 +232,7 @@ static Bool otherwm;
 static Bool running = True;
 static Client *clients = NULL;
 static Client *sel = NULL;
+static Client *foc = NULL;
 static Client *stack = NULL;
 static Cursor cursor[CurLast];
 static Display *dpy;
@@ -627,8 +628,14 @@ focus(Client *c) {
attachstack(c);
grabbuttons(c, True);
XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
-   if(c->isfocusable)
-   XSetInputFocus(dpy, c->win, RevertToPointerRoot, 
CurrentTime);
+   if(c->isfocusable) {
+   if(foc && foc != c)
+   XSetWindowBorder(dpy, foc->win, 
dc.norm[ColBorder]);
+   foc = c;
+   XSetInputFocus(dpy, foc->win, RevertToPointerRoot, 
CurrentTime);
+   }
+   else if(foc)
+   XSetWindowBorder(dpy, foc->win, dc.sel[ColFG]);
}
else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);


Re: [dwm] Virtual keyboards

2009-01-26 Thread Anselm R Garbe
Hi,

I like this patch and will apply it to 5.4 which is going to be
released until the weekend. I should get broadband today that I'll be
back online and can support questions regarding my upcoming st and
libtg release.

Kind regards,
Anselm

2009/1/22 Peter Hartlich :
> Hi,
>
>> http://s01.de/~gottox/hg/dwm/rev/d3c3a8018349
>
> A port of that + http://s01.de/~gottox/hg/dwm/rev/0c589f7247e6
> is attached. Thanks Gottox!
>
> Regards,
> Peter



Re: [dwm] Virtual keyboards

2009-01-22 Thread Sergey Dolgov
On Thu, Jan 22, 2009 at 11:04:00AM +0100, Peter Hartlich wrote:
> Hi,
> 
> > http://s01.de/~gottox/hg/dwm/rev/d3c3a8018349
> 
> A port of that + http://s01.de/~gottox/hg/dwm/rev/0c589f7247e6
> is attached. Thanks Gottox!
> 

Thank you guys!

--
Sergey



Re: [dwm] Virtual keyboards

2009-01-22 Thread Peter Hartlich
Hi,

> http://s01.de/~gottox/hg/dwm/rev/d3c3a8018349

A port of that + http://s01.de/~gottox/hg/dwm/rev/0c589f7247e6
is attached. Thanks Gottox!

Regards,
Peter
diff --git a/dwm.c b/dwm.c
index 77a91ac..133f420 100644
--- a/dwm.c
+++ b/dwm.c
@@ -86,7 +86,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
-   Bool isfixed, isfloating, isurgent;
+   Bool isfixed, isfloating, isurgent, isfocusable;
Client *next;
Client *snext;
Window win;
@@ -627,7 +627,8 @@ focus(Client *c) {
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);
@@ -869,6 +870,7 @@ manage(Window w, XWindowAttributes *wa) {
c->w = wa->width;
c->h = wa->height;
c->oldbw = wa->border_width;
+   c->isfocusable = True;
if(c->w == sw && c->h == sh) {
c->x = sx;
c->y = sy;
@@ -890,6 +892,7 @@ manage(Window w, XWindowAttributes *wa) {
XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
configure(c); /* propagates border_width, if size doesn't change */
updatesizehints(c);
+   updatewmhints(c);
XSelectInput(dpy, w, 
EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, False);
updatetitle(c);
@@ -1637,6 +1640,7 @@ updatewmhints(Client *c) {
}
else
c->isurgent = (wmh->flags & XUrgencyHint) ? True : 
False;
+   c->isfocusable = !(wmh->flags & InputHint) || wmh->input;
 
XFree(wmh);
}


Re: [dwm] Virtual keyboards

2009-01-21 Thread Enno "Gottox" Boland
This is the patchset in dwm-gtx:

http://s01.de/~gottox/hg/dwm/rev/d3c3a8018349

It should be easy to port it to dwm.

regards
Gottox

2009/1/22, Sergey Dolgov :
> On Wed, Jan 21, 2009 at 11:54:47PM +0100, Peter Hartlich wrote:
>  > > I'm using dwm-gtx now for this very purpose (I have a tablet PC).
>  >
>  > Ah, thanks for the hint! Got it working roughly with dwm now.
>  >
>
>
> I'd like to know how to get virtual keyboards working with dwm,
>  too. Could you please post the patch here?
>
>  --
>
> Sergey
>
>


-- 
http://www.gnuffy.org - Real Community Distro
http://www.gnuffy.org/index.php/GnuEm - Gnuffy on Ipaq (Codename Peggy)



Re: [dwm] Virtual keyboards

2009-01-21 Thread Sergey Dolgov
On Wed, Jan 21, 2009 at 11:54:47PM +0100, Peter Hartlich wrote:
> > I'm using dwm-gtx now for this very purpose (I have a tablet PC).
> 
> Ah, thanks for the hint! Got it working roughly with dwm now.
> 

I'd like to know how to get virtual keyboards working with dwm,
too. Could you please post the patch here?

--
Sergey



Re: [dwm] Virtual keyboards

2009-01-21 Thread Peter Hartlich
> I'm using dwm-gtx now for this very purpose (I have a tablet PC).

Ah, thanks for the hint! Got it working roughly with dwm now.

Regards,
Peter



Re: [dwm] Virtual keyboards

2009-01-21 Thread Antony Jepson
Dear Peter,

On 2009-01-21, Peter Hartlich wrote:
> Hi,
> 
> It's dishwasher time for my keyboard. For the days it'll be drying, any
> ideas how to get a virtual keyboard like xkbd, xvkbd, or matchbox-keyboard
> (last one seems nice enough) to run with dwm?

I'm using dwm-gtx now for this very purpose (I have a tablet PC).

If you do manage to get it working with dwm, then I recommend you
include the following in your config.h:

static const char *kbdcmd[]  = { "matchbox-keyboard", NULL };
[...]
{ ClkStatusText, 0, Button1, spawn, {.v = kbdcmd} },
{ ClkStatusText, 0, Button3, spawn, {.v = dmenucmd} },

-- 
Antony Jepson /   / GPG Key: 0xFA10ED80


pgpZtvKhJFegi.pgp
Description: PGP signature


[dwm] Virtual keyboards

2009-01-21 Thread Peter Hartlich
Hi,

It's dishwasher time for my keyboard. For the days it'll be drying, any
ideas how to get a virtual keyboard like xkbd, xvkbd, or matchbox-keyboard
(last one seems nice enough) to run with dwm?

They all seem to work by drawing a window that is supposed to never receive
keyboard focus from the wm (see attachment), but *will* receive mouse button
clicks (?!).

Regards,
Peter
diff --git a/config.def.h b/config.def.h
index bb60471..38f765a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,9 +20,9 @@ static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", 
"5", "6", "7", "8",
 static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */
 
 static Rule rules[] = {
-   /* class  instancetitle   tags mask isfloating */
-   { "Gimp", NULL,   NULL,   0,True },
-   { "Firefox",  NULL,   NULL,   1 << 8,   True },
+   /* class  instancetitle   tags mask flags */
+   { "Gimp", NULL,   NULL,   0,Floating },
+   { "Firefox",  NULL,   NULL,   1 << 8,   Floating },
 };
 
 /* layout(s) */
diff --git a/dwm.c b/dwm.c
index 77a91ac..fbdae45 100644
--- a/dwm.c
+++ b/dwm.c
@@ -45,6 +45,7 @@
 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask))
 #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= 
(RY) && (Y) < (RY) + (RH))
 #define ISVISIBLE(x)(x->tags & tagset[seltags])
+#define ISFOCUSABLE(x)  (ISVISIBLE(x) && !(x)->nofocus)
 #define LENGTH(x)   (sizeof x / sizeof x[0])
 #define MAX(a, b)   ((a) > (b) ? (a) : (b))
 #define MIN(a, b)   ((a) < (b) ? (a) : (b))
@@ -62,6 +63,7 @@ enum { NetSupported, NetWMName, NetLast };  /* 
EWMH atoms */
 enum { WMProtocols, WMDelete, WMState, WMLast };/* default atoms */
 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
+enum { Normal, Floating, NoFocus }; /* flags */
 
 typedef union {
int i;
@@ -86,7 +88,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
-   Bool isfixed, isfloating, isurgent;
+   Bool isfixed, isfloating, isurgent, nofocus;
Client *next;
Client *snext;
Window win;
@@ -124,7 +126,7 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
-   Bool isfloating;
+   unsigned int flags;
 } Rule;
 
 /* function declarations */
@@ -268,7 +270,8 @@ applyrules(Client *c) {
if((!r->title || strstr(c->name, r->title))
&& (!r->class || (ch.res_class && strstr(ch.res_class, 
r->class)))
&& (!r->instance || (ch.res_name && strstr(ch.res_name, 
r->instance {
-   c->isfloating = r->isfloating;
+   c->isfloating = r->flags & Floating;
+   c->nofocus = r->flags & NoFocus;
c->tags |= r->tags & TAGMASK ? r->tags & 
TAGMASK : tagset[seltags]; 
}
}
@@ -614,8 +617,8 @@ expose(XEvent *e) {
 
 void
 focus(Client *c) {
-   if(!c || !ISVISIBLE(c))
-   for(c = stack; c && !ISVISIBLE(c); c = c->snext);
+   if(!c || !ISFOCUSABLE(c))
+   for(c = stack; c && !ISFOCUSABLE(c); c = c->snext);
if(sel && sel != c) {
grabbuttons(sel, False);
XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
@@ -650,17 +653,17 @@ focusstack(const Arg *arg) {
if(!sel)
return;
if (arg->i > 0) {
-   for(c = sel->next; c && !ISVISIBLE(c); c = c->next);
+   for(c = sel->next; c && !ISFOCUSABLE(c); c = c->next);
if(!c)
-   for(c = clients; c && !ISVISIBLE(c); c = c->next);
+   for(c = clients; c && !ISFOCUSABLE(c); c = c->next);
}
else {
for(i = clients; i != sel; i = i->next)
-   if(ISVISIBLE(i))
+   if(ISFOCUSABLE(i))
c = i;
if(!c)
for(; i; i = i->next)
-   if(ISVISIBLE(i))
+   if(ISFOCUSABLE(i))
c = i;
}
if(c) {