Documentation

This commit is contained in:
Bastien Dejean 2012-09-22 23:11:57 +02:00
parent 0d04cd6c0c
commit a43b45f7f4
8 changed files with 249 additions and 98 deletions

View file

@ -1,4 +1,4 @@
VERSION = 0.01
VERSION = 0.1
CC = gcc
LIBS = `pkg-config --libs xcb xcb-ewmh xcb-icccm lua`
@ -17,35 +17,35 @@ CL_OBJ = $(CL_SRC:.c=.o)
all: options clean bspwm bspc
options:
# @echo "bspwm build options:"
# @echo "CC = $(CC)"
# @echo "CFLAGS = $(CFLAGS)"
# @echo "LDFLAGS = $(LDFLAGS)"
# @echo "PREFIX = $(PREFIX)"
@echo "bspwm build options:"
@echo "CC = $(CC)"
@echo "CFLAGS = $(CFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
@echo "PREFIX = $(PREFIX)"
.c.o:
# @echo "CC $<"
@echo "CC $<"
@$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
bspwm: $(WM_OBJ)
# @echo CC -o $@
@echo CC -o $@
@$(CC) -o $@ $(WM_OBJ) $(LDFLAGS)
bspc: $(CL_OBJ)
# @echo CC -o $@
@echo CC -o $@
@$(CC) -o $@ $(CL_OBJ) $(LDFLAGS)
clean:
# @echo "cleaning"
@echo "cleaning"
@rm -f $(WM_OBJ) $(CL_OBJ) bsp{wm,c}
install: all
# @echo "installing executable files to $(DESTDIR)$(BINPREFIX)"
install:
@echo "installing executable files to $(DESTDIR)$(BINPREFIX)"
@install -D -m 755 bspwm $(DESTDIR)$(BINPREFIX)/bspwm
@install -D -m 755 bspc $(DESTDIR)$(BINPREFIX)/bspc
uninstall:
# @echo "removing executable files from $(DESTDIR)$(BINPREFIX)"
@echo "removing executable files from $(DESTDIR)$(BINPREFIX)"
@rm -f $(DESTDIR)$(BINPREFIX)/bsp{wm,c}
.PHONY: all options clean install uninstall

221
README.md Normal file
View file

@ -0,0 +1,221 @@
![logo](https://github.com/baskerville/bspwm/raw/master/resources/bspwm_logo.png)
## Description
`bspwm` is a tiling window manager based on binary space partitioning.
The windows are represented as the leaves of a binary tree.
## Configuration
`bspwm` have only two sources of informations: the X events it receives and the messages it reads on a dedicated socket.
Those messages are sent through the `bspc` program.
Therefore, the `BSPWM_SOCKET` environment variable must be defined and indicate the path to where the socket will be created.
The recommended way of defining keyboard shortcuts, is to use `xbindkeys`.
Configuration files must be placed in `$XDG_CONFIG_HOME/bspwm/`.
In that directory, `bspwmrc` (written in Lua) will be sourced and `autostart` executed.
Example configurations: [bspwmrc](https://github.com/baskerville/dotfiles/blob/master/bspwmrc), [autostart](https://github.com/baskerville/bin/blob/master/bspwm_autostart) and [xbindkeysrc](https://github.com/baskerville/dotfiles/blob/master/xbindkeysrc)
## Splitting Modes
There is only two splitting modes: *automatic* and *manual*.
The default mode is *automatic*. The *manual* mode is entered by sending a *presel* message.
Example: insertion of a new node (number 4) into the given tree in
*automatic* mode:
b c
/ \ / \
3 a --> 4 b
^ / \ ^ / \
2 1 3 a
/ \
2 1
+-------------------------+ +-------------------------+
| | | | | |
| | 2 | | | 3 |
| | | | | |
| 3 |------------| --> | 4 |------------|
| ^ | | | ^ | | |
| | 1 | | | 1 | 2 |
| | | | | | |
+-------------------------+ +-------------------------+
Same departure, but the mode is *manual*, a `presel up` message
was sent beforehand:
b b
/ \ / \
3 a --> c a
^ / \ / \ / \
2 1 4 3 2 1
^
+-------------------------+ +-------------------------+
| | | | | |
| | 2 | | 4 | 2 |
| | | | ^ | |
| 3 |------------| --> |------------|------------|
| ^ | | | | |
| | 1 | | 3 | 1 |
| | | | | |
+-------------------------+ +-------------------------+
## Messages
The syntax for the client is `bspc COMMAND ARGUMENTS...`.
The following messages are handled:
quit
Quit.
get SETTING
Return the value of the given setting.
set SETTING VALUE
Set the value of the given setting.
dump
Output the internal representation of the window tree.
list
Perform a dump of each desktop.
windows
Return the list of managed windows (i.e. their identifiers).
close
Close the focused window.
presel DIR
Switch to manual mode and select the splitting direction.
ratio VALUE
Set the splitting ratio of the focused window.
cancel
Switch to automatic mode.
focus DIR
Focus the neighbor node situated in the given direction.
shift DIR
Focus the neighbor node situated in the given direction.
push DIR
Push the fence located in the given direction.
pull DIR
Pull the fence located in the given direction.
cycle CYC [--skip-floating|--skip-tiled]
Focus the next or previous window in the list of leaves.
rotate ROT
Rotate the tree of the current desktop.
send_to DESKTOP_NAME
Send the focused window to the given desktop.
use DESKTOP_NAME
Select the given desktop.
alternate
Alternate between the current and the last focused desktop.
add DESKTOP_NAME
Make a new desktop with the given name.
rename CURRENT_NAME NEW_NAME
Rename the desktop named CURRENT_NAME to NEW_NAME.
cycle_desktop CYC
Select the next or previous desktop.
layout LYT
Set the layout of the current desktop to LYT.
toggle_fullscreen
Toggle the fullscreen state of the current window.
toggle_floating
Toggle the floating state of the current window.
toggle_locked
Toggle the locked state of the current window (locked windows will not respond to the 'close' command).
rule PATTERN floating
Make a new rule that will floats the windows whose class name or instance name matches PATTERN.
reload_autostart
Reload the autostart file.
reload_settings
Reload the settings file.
reload
Reload the autostart and the settings file.
Where
DIR = left|right|up|down
CYC = next|prev
ROT = clockwise|counter_clockwise|full_cycle
LYT = monocle|tiled
## Settings
Colors are either X color names or '#RRGGBB'.
active_border_color
Color of the main border of a focused window.
normal_border_color
Color of the main border of an unfocused window.
inner_border_color
Color of the inner border of a window.
outer_border_color
Color of the outer border of a window.
presel_border_color
Color of the *presel* message feedback.
active_locked_border_color
Color of the main border of a focused locked window.
normal_locked_border_color
Color of the main border of an unfocused locked window.
urgent_border_color
Color of the border of an urgent window.
inner_border_width
main_border_width
outer_border_width
Width of the inner, main and outer borders.
window_gap
Value of the gap that separates windows.
top_padding
bottom_padding
left_padding
right_padding
Padding space added at the sides of the screen.
wm_name
The value that shall be used for the _NET_WM_NAME property of the root window.
## Requirements
- XCB.
- Lua.

View file

@ -1,58 +0,0 @@
![logo](https://github.com/baskerville/bspwm/raw/master/resources/bspwm_logo.png)
## Description
- Windows are represented as the leaves of a binary tree.
- To each leaf corresponds exactly one window.
- The only nodes which can be focused are the leaves.
- The leaves are called *window nodes*.
- The other nodes are called *container nodes*.
- Each container node is a split rectangle.
- Only two methods of node insertion will be provided: *replace* and *pair*.
Example: insertion of a new node (number 4) into the given tree with the
*replace* method:
b c
/ \ / \
3 a --> 4 b
^ / \ ^ / \
2 1 3 a
/ \
2 1
+-------------------------+ +-------------------------+
| | | | | |
| | 2 | | | 3 |
| | | | | |
| 3 |------------| --> | 4 |------------|
| ^ | | | ^ | | |
| | 1 | | | 2 | 1 |
| | | | | | |
+-------------------------+ +-------------------------+
And with the *pair* method:
b b
/ \ / \
3 a --> c a
^ / \ / \ / \
2 1 4 3 2 1
^
+-------------------------+ +-------------------------+
| | | | | |
| | 2 | | 4 | 2 |
| | | | ^ | |
| 3 |------------| --> |------------|------------|
| ^ | | | | |
| | 1 | | 3 | 1 |
| | | | | |
+-------------------------+ +-------------------------+
## Features
- Triple window borders. (Rationale: with single borders, it might happen that the color of the window border is too close to the color of its inner or outer environment to be visible.)
- Directional *pair* splitting preselection (the feedback is drawn in the window border pixman).
- Don't automatically give the focus to toolbar windows.
- Set or get settings and call methods at runtime.
- Configuration file in Lua.

View file

@ -45,7 +45,6 @@ void handle_event(xcb_generic_event_t *evt)
button_release(evt);
break;
default:
/* PRINTF("received event %i\n", XCB_EVENT_RESPONSE_TYPE(evt)); */
break;
}
}

View file

@ -94,15 +94,6 @@ void process_message(char *msg, char *rsp)
}
}
return;
} else if (strcmp(cmd, "locate") == 0) {
char *wid = strtok(NULL, TOKEN_SEP);
if (wid != NULL) {
window_location_t loc;
xcb_window_t win = atoi(wid);
if (locate_window(win, &loc))
sprintf(rsp, "%s", loc.desktop->name);
}
} else if (strcmp(cmd, "push") == 0 || strcmp(cmd, "pull") == 0) {
char *dir = strtok(NULL, TOKEN_SEP);
if (dir != NULL) {
@ -118,6 +109,18 @@ void process_message(char *msg, char *rsp)
desktop_t *d = find_desktop(name);
transfer_node(desk, d, desk->focus);
}
} else if (strcmp(cmd, "rename") == 0) {
char *cur_name = strtok(NULL, TOKEN_SEP);
if (cur_name != NULL) {
desktop_t *d = find_desktop(cur_name);
if (d != NULL) {
char *new_name = strtok(NULL, TOKEN_SEP);
if (new_name != NULL) {
strcpy(d->name, new_name);
ewmh_update_desktop_names();
}
}
}
} else if (strcmp(cmd, "use") == 0) {
char *name = strtok(NULL, TOKEN_SEP);
if (name != NULL) {

4
tree.c
View file

@ -178,11 +178,8 @@ void dump_tree(desktop_t *d, node_t *n, char *rsp, int depth)
strcat(rsp, " ");
if (is_leaf(n))
/* sprintf(line, "0x%X [%i %i %u %u]", n->client->window, n->rectangle.x, n->rectangle.y, n->rectangle.width, n->rectangle.height); */
/* sprintf(line, "C %X [%i %i %u %u] (%s%s) [%i %i %u %u]", n->client->window, n->rectangle.x, n->rectangle.y, n->rectangle.width, n->rectangle.height, (n->client->floating ? "f" : "-"), (n->client->transient ? "t" : "-"), n->client->floating_rectangle.x, n->client->floating_rectangle.y, n->client->floating_rectangle.width, n->client->floating_rectangle.height); */
sprintf(line, "C %X %s%s%s%s%s", n->client->window, (n->client->floating ? "f" : "-"), (n->client->transient ? "t" : "-"), (n->client->fullscreen ? "F" : "-"), (n->client->urgent ? "u" : "-"), (n->client->locked ? "l" : "-"));
else
/* sprintf(line, "%s %.2f [%i %i %u %u]", (n->split_type == TYPE_HORIZONTAL ? "H" : "V"), n->split_ratio, n->rectangle.x, n->rectangle.y, n->rectangle.width, n->rectangle.height); */
sprintf(line, "%s %.2f", (n->split_type == TYPE_HORIZONTAL ? "H" : "V"), n->split_ratio);
strcat(rsp, line);
@ -545,7 +542,6 @@ void select_desktop(desktop_t *d)
node_t *n = first_extrema(d->root);
while (n != NULL) {
/* xcb_map_window(dpy, n->client->window); */
window_show(n->client->window);
n = next_leaf(n);
}

View file

@ -80,12 +80,12 @@ struct node_t {
split_type_t split_type;
double split_ratio;
xcb_rectangle_t rectangle;
bool vacant; /* vacant nodes only hold floating clients */
split_mode_t born_as; /* container node property used to when removing leaves */
bool vacant; /* vacant nodes only hold floating clients */
split_mode_t born_as;
node_t *first_child;
node_t *second_child;
node_t *parent;
client_t *client; /* NULL except for leaves */
client_t *client; /* NULL except for leaves */
};
typedef struct desktop_t desktop_t;

View file

@ -47,16 +47,6 @@ void window_draw_border(node_t *n, bool focused)
return;
xcb_window_t win = n->client->window;
/* xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, win), NULL); */
/* if (geom == NULL) */
/* return; */
/* uint16_t width = geom->width; */
/* uint16_t height = geom->height; */
/* uint8_t depth = geom->depth; */
/* free(geom); */
xcb_rectangle_t actual_rectangle = (is_tiled(n->client) ? n->client->tiled_rectangle : n->client->floating_rectangle);