]> git.sur5r.net Git - i3/i3/blob - data.h
Implement focus on click
[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
18 /* Helper types */
19 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
20
21 enum {
22         BIND_NONE = 0,
23         BIND_MOD_1 = XCB_MOD_MASK_1,
24         BIND_MOD_2 = XCB_MOD_MASK_2,
25         BIND_MOD_3 = XCB_MOD_MASK_3,
26         BIND_MOD_4 = XCB_MOD_MASK_4,
27         BIND_MOD_5 = XCB_MOD_MASK_5,
28         BIND_SHIFT = XCB_MOD_MASK_SHIFT,
29         BIND_CONTROL = XCB_MOD_MASK_CONTROL,
30         BIND_MODE_SWITCH = (1 << 8)
31 };
32
33 struct table_dimensions_t {
34         int x;
35         int y;
36 };
37
38 /*
39  * Defines a position in the table
40  *
41  */
42 struct Cell {
43         int row;
44         int column;
45 };
46
47 struct Binding {
48         /* Keycode to bind */
49         uint32_t keycode;
50         /* Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, … */
51         uint32_t mods;
52         /* Command, like in command mode */
53         char *command;
54
55         TAILQ_ENTRY(Binding) bindings;
56 };
57
58 /*
59  * We need to save the height of a font because it is required for each drawing of
60  * text but relatively hard to get. As soon as a new font needs to be loaded, a
61  * Font-entry will be filled for later use.
62  *
63  */
64 struct Font {
65         /* The name of the font, that is what the pattern resolves to */
66         char *name;
67         /* A copy of the pattern to build a cache */
68         char *pattern;
69         /* The height of the font, built from font_ascent + font_descent */
70         int height;
71         /* The xcb-id for the font */
72         xcb_font_t id;
73 };
74
75 /*
76  * A client is X11-speak for a window.
77  *
78  */
79 struct Client {
80         /* TODO: this is NOT final */
81         Cell old_position; /* if you set a client to floating and set it back to managed,
82                               it does remember its old position and *tries* to get back there */
83
84         /* Backpointer. A client is inside a container */
85         Container *container;
86
87         int x, y;
88         int width, height;
89
90         /* XCB contexts */
91         xcb_window_t frame; /* Our window: The frame around the client */
92         xcb_gcontext_t titlegc; /* The titlebar’s graphic context inside the frame */
93         xcb_window_t child; /* The client’s window */
94
95         /* The following entry provides the necessary list pointers to use Client with LIST_* macros */
96         CIRCLEQ_ENTRY(Client) clients;
97 };
98
99 /*
100  * A container is either in default or stacking mode. It sits inside the table.
101  *
102  */
103 struct Container {
104         /* Those are speaking for themselves: */
105         Client *currently_focused;
106         int colspan;
107         int rowspan;
108
109         /* Position of the container inside our table */
110         int row;
111         int col;
112         /* Width/Height of the container. Changeable by the user */
113         int width;
114         int height;
115
116         /* Ensure MODE_DEFAULT maps to 0 because we use calloc for initialization later */
117         enum { MODE_DEFAULT = 0, MODE_STACK = 1 } mode;
118         CIRCLEQ_HEAD(client_head, Client) clients;
119 };
120
121 #endif