You are not logged in.
Pages: 1
I'm playing around with TinyWM in python, and I was wondering how you would go about implementing "Click to focus"? It seems X's default with this is to do hover to focus, and I want to stop X from doing that. How do I do it?
Here's the code for TinyWM:
from Xlib.display import Display
from Xlib import X, XK
dpy = Display()
root = dpy.screen().root
root.grab_key(XK.string_to_keysym("F1"), X.Mod1Mask, 1,
X.GrabModeAsync, X.GrabModeAsync)
root.grab_button(1, X.Mod1Mask, 1, X.ButtonPressMask,
X.GrabModeAsync, X.GrabModeAsync, X.NONE, X.NONE)
root.grab_button(3, X.Mod1Mask, 1, X.ButtonPressMask,
X.GrabModeAsync, X.GrabModeAsync, X.NONE, X.NONE)
while 1:
ev = root.display.next_event()
if ev.type == X.KeyPress and ev.child != X.NONE:
ev.window.circulate(X.RaiseLowest)
elif ev.type == X.ButtonPress and ev.child != X.NONE:
ev.child.grab_pointer(1, X.PointerMotionMask|X.ButtonReleaseMask,
X.GrabModeAsync, X.GrabModeAsync, X.NONE, X.NONE, X.CurrentTime)
attr = ev.child.get_geometry()
start = ev
elif ev.type == X.MotionNotify:
#while(XCheckTypedEvent(dpy, MotionNotify, &ev));
xdiff = ev.root_x - start.root_x
ydiff = ev.root_y - start.root_y
ev.window.configure(
x = attr.x + (start.detail == 1 and xdiff or 0),
y = attr.y + (start.detail == 1 and ydiff or 0),
width = max(1, attr.width + (start.detail == 3 and xdiff or 0)),
height = max(1, attr.height + (start.detail == 3 and ydiff or 0)))
elif ev.type == X.ButtonRelease:
dpy.ungrab_pointer(X.CurrentTime)
Offline
Well, if I do this at the very beginning:
root.change_attributes(event_mask = X.KeyPressMask | X.ButtonPressMask | X.ButtonReleaseMask | X.KeyReleaseMask | X.SubstructureNotifyMask | X.FocusChangeMask | X.EnterWindowMask | X.PointerMotionMask | X.LeaveWindow.Mask)
I can then at least see when any window is being clicked on or whatever. But it doesn't block X from changing the focus of windows
I've looked through the Xlib docs over and over again, I can't find how to do this.
Offline
Windowlab is a pretty simple click to focus WM. It might not be too hard to find the trick in there. Or Ratpoison or StumpWM, maybe. Don't know why you'd want such a thing though.
Edit: This feature seems to only be found in reparenting WMs. Could that be necessary?
Last edited by pauldonnelly (2010-03-15 04:53:35)
Offline
Pages: 1