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