Troels Henriksen athas@sigkill.dk writes:
Troels Henriksen athas@sigkill.dk writes:
I'm not really sure why it's necessary, but I'm pretty sure it's very ugly.
The attached simple patch seems to make everything work properly, and removes the need for explicit management of keyboard focus in Drei and Goatee, but because of its simplicity, and my lack of knowledge about CLX, I'd like a review before I commit it and make a fool out of myself:
I don't think that this makes a fool out of you, but I also don't think it's the Right Thing.
(defmethod %set-port-keyboard-focus ((port clx-port) focus &key timestamp) (let ((mirror (sheet-mirror focus))) (when mirror
(xlib:set-input-focus (clx-port-display port) mirror :parent timestamp))))
(xlib:set-input-focus (clx-port-display port) :pointer-root :parent timestamp))))
This is in the nature of a workaround: setting the focus to whatever toplevel window is under the pointer. That might work by coincidence for many applications, in the case that I described in my original mail, but I don't think it's defined to work: if the window over which I have moved my mouse has multiple input widgets, it's not clear which will win the focus battle, if that application is not programmed such that the toplevel window will distribute events to its children.
I think the Right Thing is tricky to implement. What needs to happen is that the X event which caused Drei to become disarmed needs to be propagated through to the disarmed callback and back out again, so that the timestamp field of the set-input-focus request is set to the timestamp of that event. The key point is that this allows the X server to discard a set-input-focus request with a timestamp that is earlier than a request that has already been dealt with, which is exactly the behaviour we want. (There's much detail about this in the ICCCM document available in the xspecs package on Ubuntu and elsewhere).
Well, I say the "Right Thing": _clearly_ the right thing is to abandon this horrific focus-follows-mouse-around-widgets disaster and implement a sane keyboard focus policy. Then much of the complexity can go away. Hooray. (What did Classic CLIM do?)
Cheers,
Christophe