foo-wm

(Archived) Experimental Zooming IPC-based WM
git clone http://milesalan.com/git/foo-wm
Log | Files | Refs | Mirror | README | LICENSE

commit 75e943090624882b356469ea1b6df71da452ab24
parent 4ad7abfc5ff93846b93fa1b3913a9ad4e117bae5
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Fri, 13 Jul 2012 13:44:59 -0400

Functioning Mouse Support and Point to Click
Ungrab called when the window is focused
Grab called when a window loses focused (so it listens for when itll
next be clicked/focused)

Diffstat:
Msrc/events.c | 29++++++++++++++++++-----------
Msrc/fifo-wm.c | 15++-------------
Msrc/tree.c | 21+++++++++++++--------
3 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/src/events.c b/src/events.c @@ -18,6 +18,11 @@ void eMapRequest(XEvent *event) { Node *newNode = allocateNode(); newNode -> window = event -> xmaprequest.window; + /* For Click to Focus */ + XGrabButton(display, AnyButton, AnyModifier, newNode -> window, + True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeSync, + None, None); + if (selectedNode != NULL) { fprintf(stderr,"Mapping based on selectedNode\n"); parentNode(newNode, selectedNode); @@ -30,13 +35,13 @@ void eMapRequest(XEvent *event) { } else if (focusedNode != NULL) { fprintf(stderr,"Mapping based on focusedNode\n"); if (focusedNode == viewNode && isClient(viewNode)) { - fprintf(stderr, "Just viewing a single client"); - containerize(); - viewNode = focusedNode -> parent; - parentNode(newNode, viewNode); - placeNode(viewNode, - rootX, rootY, - rootWidth, rootHeight); + fprintf(stderr, "Just viewing a single client"); + containerize(); + viewNode = focusedNode -> parent; + parentNode(newNode, viewNode); + placeNode(viewNode, + rootX, rootY, + rootWidth, rootHeight); } else { //Brother new node to current focus then focus new node brotherNode(newNode, focusedNode, 1); @@ -83,6 +88,7 @@ void eConfigureRequest(XEvent *e) { /* Structed From DWM */ XConfigureRequestEvent *ev = &e->xconfigurerequest; Node *configuredNode = getNodeByWindow(&ev->window); + if (configuredNode == NULL) return; XWindowChanges wc; @@ -98,6 +104,7 @@ void eConfigureRequest(XEvent *e) { placeNode(configuredNode, configuredNode -> x, configuredNode -> y, configuredNode -> width, configuredNode -> height); + } void eResizeRequest(XEvent *event) { @@ -107,11 +114,11 @@ void eResizeRequest(XEvent *event) { void eButtonPress(XEvent *event) { fprintf(stderr, "Button Event Window is %p\n", &(event -> xbutton.window)); - //Root Window - if (event -> xbutton.subwindow == None) { return; } + // Root Window + if (event -> xbutton.window == None) return; - Node *n = getNodeByWindow(&(event -> xbutton.subwindow)); - focusNode(n); + // Click to Focus + focusNode(getNodeByWindow(&(event -> xbutton.window))); } void handleXEvent(XEvent *event) { diff --git a/src/fifo-wm.c b/src/fifo-wm.c @@ -74,24 +74,13 @@ int main() { unfocusedColor = getColor(CLIENT_UNFOCUSED_COLOR); border = CLIENT_BORDER_WIDTH; - - - XGrabButton( - display, AnyButton, AnyModifier, - root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | OwnerGrabButtonMask, - GrabModeAsync, GrabModeAsync, None, None - ); - XSelectInput(display, root, - FocusChangeMask | PropertyChangeMask | - SubstructureNotifyMask | SubstructureRedirectMask | - KeyPressMask - ); + XSelectInput(display, root, SubstructureRedirectMask | SubstructureNotifyMask); viewNode = allocateNode(); viewNode -> layout = layout; viewNode -> x = rootX; viewNode -> y = rootY; viewNode -> width = rootWidth; viewNode -> height = rootHeight; - + rootNode = viewNode; XSetErrorHandler((XErrorHandler)(xError)); diff --git a/src/tree.c b/src/tree.c @@ -55,22 +55,27 @@ void focusNode(Node * n) { return; } + /* Regrab the focused window (for pointer to click) + * as it will no longer be focused */ + if (focusedNode != NULL) { + XGrabButton(display, AnyButton, AnyModifier, + focusedNode -> window, True, + ButtonPressMask | ButtonReleaseMask, + GrabModeAsync, GrabModeAsync, None, None); + } + if (isClient(focusedNode)) XSetWindowBorder(display, focusedNode -> window, unfocusedColor); selectedNode = NULL; focusedNode = n; centerPointer(&n -> window); - XSetInputFocus(display, n -> window, RevertToParent, CurrentTime); - //XSelectInput(display, n -> window, ButtonPressMask | ButtonReleaseMask); - XSetWindowBorder(display, n -> window, focusedColor); + + /* Set the Input focus, and ungrab the window (no longer point to click */ + XSetInputFocus(display, n -> window, RevertToParent, CurrentTime); + XUngrabButton(display, AnyButton, AnyModifier, focusedNode->window); XRaiseWindow(display, n -> window); - /* - XGrabPointer(display, n -> window, False, - ButtonPressMask, GrabModeAsync, GrabModeAsync, - None, None, CurrentTime); - */ }