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