foo-wm

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

commit 3717a23b82f1a1d335542d8cda4ed274a68bb919
parent 8aaab07eb438052f20f5a191ca10e8cd8ce87f17
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Thu, 28 Jun 2012 23:42:49 -0400

Working toward better client focusing.
Expanding focusClient to update currently focused client/set new

Diffstat:
Mconfig/.xbindkeysrc | 4++++
Msrc/client.c | 29++++++++++++++++++++++++-----
Msrc/config.h | 2+-
Msrc/events.c | 19+++----------------
Msrc/structs.h | 1+
Msrc/tree.c | 14+++++++++++---
6 files changed, 44 insertions(+), 25 deletions(-)

diff --git a/config/.xbindkeysrc b/config/.xbindkeysrc @@ -7,6 +7,10 @@ m:0x40 + c:51 Mod4 + backslash +"xdotool getactivewindow windowkill" + m:0x41 + c:24 + Shift+Mod4 + q + ### WM "echo 'layout vertical set' > /home/mil/code/repos/github/fifo-wm/wm-fifo" m:0x40 + c:55 diff --git a/src/client.c b/src/client.c @@ -1,15 +1,30 @@ #include <X11/Xlib.h> +#include <stdio.h> #include "fifo-wm.h" #include "client.h" void focusClient(Client *client) { - XSetWindowBorder(display, currentClient -> window, unfocusedColor); - XSetWindowBorderWidth(display, currentClient -> window, 0); - XSetWindowBorderWidth(display, client -> window, 2); - XSetWindowBorder(display, client -> window, focusedColor); + fprintf(stderr, "Focusing client window %p\n", &client -> window); + + Client *c; + for (c = (client -> parent) -> client; c != NULL; c = c -> next) { + + if (client == c) { + XSetWindowBorder(display, client -> window, focusedColor); + XSetWindowBorderWidth(display, client -> window, 2); + + } else { + XSetWindowBorder(display, c -> window, unfocusedColor); + XSetWindowBorderWidth(display, c -> window, 0); + + } + } + + + (client -> parent) -> focus = client; //Focuses window XSelectInput( @@ -20,5 +35,9 @@ void focusClient(Client *client) { XGrabButton( display, AnyButton, AnyModifier, client -> window, False, OwnerGrabButtonMask | ButtonPressMask, - GrabModeSync, GrabModeSync, None, None); + GrabModeSync, GrabModeSync, None, None + ); + + XRaiseWindow(display, client -> window); + XSetInputFocus(display, client -> window, RevertToPointerRoot, CurrentTime); } diff --git a/src/config.h b/src/config.h @@ -7,4 +7,4 @@ // Containers #define CONTAINER_DEFAULT_LAYOUT (0) -#define CONTAINER_PADDING 0 +#define CONTAINER_PADDING (0) diff --git a/src/events.c b/src/events.c @@ -23,20 +23,9 @@ void eMapRequest(XEvent *event) { newClient -> window = event -> xmaprequest.window; fprintf(stderr, "Got a map request\n"); - parentClient(newClient, currentContainer); - currentClient = newClient; + parentClient(newClient, currentContainer); + currentClient = newClient; - /* - Container * newContainer = malloc(sizeof(Container)); - newContainer -> layout = layout; - parentClient(newClient, newContainer); - parentContainer(newContainer, currentContainer); - currentContainer = newContainer; - - XSetWindowBorderWidth(display, newClient -> window, 5); - XSetWindowBorder(display, newClient -> window, unfocusedColor); - - */ //Update view placeContainer( rootContainer, 0, 0, @@ -44,8 +33,7 @@ void eMapRequest(XEvent *event) { DisplayHeight (display, activeScreen) ); - //focusClient(newClient); - + focusClient(newClient); //Add Client and window to lookup list Lookup *entry = malloc(sizeof(Lookup)); @@ -57,7 +45,6 @@ void eMapRequest(XEvent *event) { } void eButtonPress(XEvent *event) { - fprintf(stderr, "Button Event Window is %p\n", &(event -> xbutton.subwindow)); //Root Window diff --git a/src/structs.h b/src/structs.h @@ -15,6 +15,7 @@ struct Container { char *label; int layout; int x, y, width, height; + Client *focus; Container *parent; Container *next; diff --git a/src/tree.c b/src/tree.c @@ -93,6 +93,8 @@ int placeContainer(Container * container, int x, int y, int width, int height) { container -> width = width; container -> height = height; + fprintf(stderr, "Place Container called"); + //Count up children int children = 0; Client *a = malloc(sizeof(Client)); @@ -124,9 +126,14 @@ int placeContainer(Container * container, int x, int y, int width, int height) { for (a = container -> client; a != NULL; a = a -> next, i++) { + XMapWindow(display, a -> window); XSetWindowBorderWidth(display, a -> window, 1); - XSetWindowBorder(display, a -> window, unfocusedColor); + if (container -> focus == a) + XSetWindowBorder(display, a -> window, focusedColor); + else + XSetWindowBorder(display, a -> window, unfocusedColor); + switch (container -> layout) { case 0: @@ -146,7 +153,6 @@ int placeContainer(Container * container, int x, int y, int width, int height) { default: break; } - } free(a), free(b); @@ -158,9 +164,11 @@ int placeContainer(Container * container, int x, int y, int width, int height) { Client * getClientByWindow(Window * window) { Lookup *node; int win = *window; - for (node = lookup; node != NULL; node = node -> previous) + for (node = lookup; node != NULL; node = node -> previous) { + fprintf(stderr, "Comparing [%p] to [%p]\n", window, node -> window); if (win == node -> window) return node -> client; + } return NULL; }