]> git.sur5r.net Git - i3/i3/blob - include/data.h
Add vim hints, copyright notice to each file, add LICENSE, retab! everything
[i3/i3] / include / data.h
1 /*
2  * vim:ts=8:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  *
6  * (c) 2009 Michael Stapelberg and contributors
7  *
8  * See file LICENSE for license information.
9  *
10  */
11 #include <xcb/xcb.h>
12
13 #ifndef _DATA_H
14 #define _DATA_H
15 /*
16  * This file defines all data structures used by i3
17  *
18  */
19 #include "queue.h"
20
21 /* Forward definitions */
22 typedef struct Cell Cell;
23 typedef struct Font i3Font;
24 typedef struct Container Container;
25 typedef struct Client Client;
26 typedef struct Binding Binding;
27 typedef struct Workspace Workspace;
28
29 /* Helper types */
30 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
31
32 enum {
33         BIND_NONE = 0,
34         BIND_MOD_1 = XCB_MOD_MASK_1,
35         BIND_MOD_2 = XCB_MOD_MASK_2,
36         BIND_MOD_3 = XCB_MOD_MASK_3,
37         BIND_MOD_4 = XCB_MOD_MASK_4,
38         BIND_MOD_5 = XCB_MOD_MASK_5,
39         BIND_SHIFT = XCB_MOD_MASK_SHIFT,
40         BIND_CONTROL = XCB_MOD_MASK_CONTROL,
41         BIND_MODE_SWITCH = (1 << 8)
42 };
43
44 struct Workspace {
45         int x;
46         int y;
47         int width;
48         int height;
49         int screen_num;
50         int num;
51
52         /* table dimensions */
53         int cols;
54         int rows;
55
56         /* These are stored here just while this workspace is _not_ shown (see show_workspace()) */
57         int current_row;
58         int current_col;
59
60         /* This is a two-dimensional dynamic array of Container-pointers. I’ve always wanted
61          * to be a three-star programmer :) */
62         Container ***table;
63 };
64
65 /*
66  * Defines a position in the table
67  *
68  */
69 struct Cell {
70         int row;
71         int column;
72 };
73
74 struct Binding {
75         /* Keycode to bind */
76         uint32_t keycode;
77         /* Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, … */
78         uint32_t mods;
79         /* Command, like in command mode */
80         char *command;
81
82         TAILQ_ENTRY(Binding) bindings;
83 };
84
85 /*
86  * We need to save the height of a font because it is required for each drawing of
87  * text but relatively hard to get. As soon as a new font needs to be loaded, a
88  * Font-entry will be filled for later use.
89  *
90  */
91 struct Font {
92         /* The name of the font, that is what the pattern resolves to */
93         char *name;
94         /* A copy of the pattern to build a cache */
95         char *pattern;
96         /* The height of the font, built from font_ascent + font_descent */
97         int height;
98         /* The xcb-id for the font */
99         xcb_font_t id;
100 };
101
102 /*
103  * A client is X11-speak for a window.
104  *
105  */
106 struct Client {
107         /* TODO: this is NOT final */
108         Cell old_position; /* if you set a client to floating and set it back to managed,
109                               it does remember its old position and *tries* to get back there */
110
111         /* Backpointer. A client is inside a container */
112         Container *container;
113
114         uint32_t x, y;
115         uint32_t width, height;
116
117         /* Name */
118         char *name;
119         int name_len;
120
121         /* XCB contexts */
122         xcb_window_t frame; /* Our window: The frame around the client */
123         xcb_gcontext_t titlegc; /* The titlebar’s graphic context inside the frame */
124         xcb_window_t child; /* The client’s window */
125
126         /* The following entry provides the necessary list pointers to use Client with LIST_* macros */
127         CIRCLEQ_ENTRY(Client) clients;
128 };
129
130 /*
131  * A container is either in default or stacking mode. It sits inside the table.
132  *
133  */
134 struct Container {
135         /* Those are speaking for themselves: */
136         Client *currently_focused;
137         int colspan;
138         int rowspan;
139
140         /* Position of the container inside our table */
141         int row;
142         int col;
143         /* Xinerama: X/Y of the container */
144         int x;
145         int y;
146         /* Width/Height of the container. Changeable by the user */
147         int width;
148         int height;
149
150         /* Ensure MODE_DEFAULT maps to 0 because we use calloc for initialization later */
151         enum { MODE_DEFAULT = 0, MODE_STACK = 1 } mode;
152         CIRCLEQ_HEAD(client_head, Client) clients;
153 };
154
155 #endif