foo-wm

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

commit 1c366bd790581e9d056fb387e416ac6a17e2f297
parent 9aa5ad971e76c77cefe0fde981829e80be5859c9
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Tue, 17 Jul 2012 14:45:19 -0400

Spit main() setup code into a setup() function

Diffstat:
Msrc/fifo-wm.c | 48+++++++++++++++++++++++++-----------------------
Msrc/fifo-wm.h | 1+
2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/src/fifo-wm.c b/src/fifo-wm.c @@ -50,44 +50,46 @@ void handleEvents(void) { close(fifoFd); } - -int main(void) { +void setup(void) { + // Setting from defines from config.h layout = CONTAINER_DEFAULT_LAYOUT; containerPadding = CONTAINER_PADDING; clientPadding = CLIENT_PADDING; - display = XOpenDisplay(NULL); - assert(display); - - root = RootWindow(display, activeScreen); + // Open Display and set acitveScreen + assert((display = XOpenDisplay(NULL))); activeScreen = DefaultScreen(display); - /* Setup Screen Padding */ - rootX = 0 + SCREEN_PADDING_LEFT; - rootWidth = DisplayWidth(display, activeScreen) - SCREEN_PADDING_LEFT - SCREEN_PADDING_RIGHT; - rootY = 0 + SCREEN_PADDING_TOP; + // Setup Root / Screen Padding + root = RootWindow(display, activeScreen); + rootX = SCREEN_PADDING_LEFT; + rootY = SCREEN_PADDING_TOP; + rootWidth = DisplayWidth(display, activeScreen) - SCREEN_PADDING_LEFT - SCREEN_PADDING_RIGHT; rootHeight = DisplayHeight(display, activeScreen) - SCREEN_PADDING_TOP - SCREEN_PADDING_BOTTOM; - + XSelectInput(display, root, SubstructureRedirectMask | SubstructureNotifyMask); setCursor(&root, 68); - - /* Setup Clients Defaults */ + // Setup Clients Defaults + border = CLIENT_BORDER_WIDTH; focusedColor = getColor(CLIENT_FOCUSED_COLOR); - unfocusedColor = getColor(CLIENT_UNFOCUSED_COLOR); selectedColor = getColor(CLIENT_SELECTED_COLOR); - border = CLIENT_BORDER_WIDTH; - - XSelectInput(display, root, SubstructureRedirectMask | SubstructureNotifyMask); - - viewNode = allocateNode(); - viewNode -> layout = layout; - viewNode -> x = rootX; viewNode -> y = rootY; - viewNode -> width = rootWidth; viewNode -> height = rootHeight; + unfocusedColor = getColor(CLIENT_UNFOCUSED_COLOR); - rootNode = viewNode; + // Setup the Root Node (top of tree) + rootNode = allocateNode(); + rootNode -> layout = layout; + rootNode -> x = rootX; rootNode -> y = rootY; + rootNode -> width = rootWidth; rootNode-> height = rootHeight; + viewNode = rootNode; + // Set Error Handlers and Flush to X XSetErrorHandler((XErrorHandler)(xError)); XFlush(display); +} + + +int main(void) { + setup(); handleEvents(); return 0; diff --git a/src/fifo-wm.h b/src/fifo-wm.h @@ -24,4 +24,5 @@ long unfocusedColor, focusedColor, selectedColor; void handleCommand(char* request); +void setup(void); void handleEvents(void);