]> Dogcows Code - chaz/openbox/blob - openbox/frame.h
Fix the EXTENTS reported on window frames.
[chaz/openbox] / openbox / frame.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 frame.h for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #ifndef __frame_h
21 #define __frame_h
22
23 #include "geom.h"
24 #include "obrender/render.h"
25
26 typedef struct _ObFrame ObFrame;
27
28 struct _ObClient;
29
30 typedef void (*ObFrameIconifyAnimateFunc)(gpointer data);
31
32 typedef enum {
33 OB_FRAME_CONTEXT_NONE,
34 OB_FRAME_CONTEXT_DESKTOP,
35 OB_FRAME_CONTEXT_ROOT,
36 OB_FRAME_CONTEXT_CLIENT,
37 OB_FRAME_CONTEXT_TITLEBAR,
38 OB_FRAME_CONTEXT_FRAME,
39 OB_FRAME_CONTEXT_BLCORNER,
40 OB_FRAME_CONTEXT_BRCORNER,
41 OB_FRAME_CONTEXT_TLCORNER,
42 OB_FRAME_CONTEXT_TRCORNER,
43 OB_FRAME_CONTEXT_TOP,
44 OB_FRAME_CONTEXT_BOTTOM,
45 OB_FRAME_CONTEXT_LEFT,
46 OB_FRAME_CONTEXT_RIGHT,
47 OB_FRAME_CONTEXT_MAXIMIZE,
48 OB_FRAME_CONTEXT_ALLDESKTOPS,
49 OB_FRAME_CONTEXT_SHADE,
50 OB_FRAME_CONTEXT_ICONIFY,
51 OB_FRAME_CONTEXT_ICON,
52 OB_FRAME_CONTEXT_CLOSE,
53 /*! This is a special context, which occurs while dragging a window in
54 a move/resize */
55 OB_FRAME_CONTEXT_MOVE_RESIZE,
56 OB_FRAME_NUM_CONTEXTS
57 } ObFrameContext;
58
59 #define FRAME_CONTEXT(co, cl) ((cl && cl->type != OB_CLIENT_TYPE_DESKTOP) ? \
60 co == OB_FRAME_CONTEXT_FRAME : FALSE)
61 #define CLIENT_CONTEXT(co, cl) ((cl && cl->type == OB_CLIENT_TYPE_DESKTOP) ? \
62 co == OB_FRAME_CONTEXT_DESKTOP : \
63 co == OB_FRAME_CONTEXT_CLIENT)
64
65 /*! The decorations the client window wants to be displayed on it */
66 typedef enum {
67 OB_FRAME_DECOR_TITLEBAR = 1 << 0, /*!< Display a titlebar */
68 OB_FRAME_DECOR_HANDLE = 1 << 1, /*!< Display a handle (bottom) */
69 OB_FRAME_DECOR_GRIPS = 1 << 2, /*!< Display grips in the handle */
70 OB_FRAME_DECOR_BORDER = 1 << 3, /*!< Display a border */
71 OB_FRAME_DECOR_ICON = 1 << 4, /*!< Display the window's icon */
72 OB_FRAME_DECOR_ICONIFY = 1 << 5, /*!< Display an iconify button */
73 OB_FRAME_DECOR_MAXIMIZE = 1 << 6, /*!< Display a maximize button */
74 /*! Display a button to toggle the window's placement on
75 all desktops */
76 OB_FRAME_DECOR_ALLDESKTOPS = 1 << 7,
77 OB_FRAME_DECOR_SHADE = 1 << 8, /*!< Display a shade button */
78 OB_FRAME_DECOR_CLOSE = 1 << 9 /*!< Display a close button */
79 } ObFrameDecorations;
80
81 struct _ObFrame
82 {
83 struct _ObClient *client;
84
85 Window window;
86
87 Strut size; /* the size of the frame */
88 Strut oldsize; /* the size of the frame last told to the client */
89 Rect area;
90 gboolean visible;
91
92 guint functions;
93 guint decorations;
94
95 Window title;
96 Window label;
97 Window max;
98 Window close;
99 Window desk;
100 Window shade;
101 Window icon;
102 Window iconify;
103 Window handle;
104 Window lgrip;
105 Window rgrip;
106
107 /* These are borders of the frame and its elements */
108 Window titleleft;
109 Window titletop;
110 Window titletopleft;
111 Window titletopright;
112 Window titleright;
113 Window titlebottom;
114 Window left;
115 Window right;
116 Window handleleft;
117 Window handletop;
118 Window handleright;
119 Window handlebottom;
120 Window lgriptop;
121 Window lgripleft;
122 Window lgripbottom;
123 Window rgriptop;
124 Window rgripright;
125 Window rgripbottom;
126 Window innerleft; /*!< For drawing the inner client border */
127 Window innertop; /*!< For drawing the inner client border */
128 Window innerright; /*!< For drawing the inner client border */
129 Window innerbottom; /*!< For drawing the inner client border */
130 Window innerblb;
131 Window innerbll;
132 Window innerbrb;
133 Window innerbrr;
134 Window backback; /*!< A colored window shown while resizing */
135 Window backfront; /*!< An undrawn-in window, to prevent flashing on
136 unmap */
137
138 /* These are resize handles inside the titlebar */
139 Window topresize;
140 Window tltresize;
141 Window tllresize;
142 Window trtresize;
143 Window trrresize;
144
145 Colormap colormap;
146
147 gint icon_on; /* if the window icon button is on */
148 gint label_on; /* if the window title is on */
149 gint iconify_on; /* if the window iconify button is on */
150 gint desk_on; /* if the window all-desktops button is on */
151 gint shade_on; /* if the window shade button is on */
152 gint max_on; /* if the window maximize button is on */
153 gint close_on; /* if the window close button is on */
154
155 gint width; /* width of the titlebar and handle */
156 gint label_width; /* width of the label in the titlebar */
157 gint icon_x; /* x-position of the window icon button */
158 gint label_x; /* x-position of the window title */
159 gint iconify_x; /* x-position of the window iconify button */
160 gint desk_x; /* x-position of the window all-desktops button */
161 gint shade_x; /* x-position of the window shade button */
162 gint max_x; /* x-position of the window maximize button */
163 gint close_x; /* x-position of the window close button */
164 gint bwidth; /* border width */
165 gint cbwidth_l; /* client border width */
166 gint cbwidth_t; /* client border width */
167 gint cbwidth_r; /* client border width */
168 gint cbwidth_b; /* client border width */
169 gboolean max_horz; /* when maxed some decorations are hidden */
170 gboolean max_vert; /* when maxed some decorations are hidden */
171 gboolean shaded; /* decorations adjust when shaded */
172
173 /* the leftmost and rightmost elements in the titlebar */
174 ObFrameContext leftmost;
175 ObFrameContext rightmost;
176
177 gboolean max_press;
178 gboolean close_press;
179 gboolean desk_press;
180 gboolean shade_press;
181 gboolean iconify_press;
182 gboolean max_hover;
183 gboolean close_hover;
184 gboolean desk_hover;
185 gboolean shade_hover;
186 gboolean iconify_hover;
187
188 gboolean focused;
189 gboolean need_render;
190
191 gboolean flashing;
192 gboolean flash_on;
193 GTimeVal flash_end;
194 guint flash_timer;
195
196 /*! Is the frame currently in an animation for iconify or restore.
197 0 means that it is not animating. > 0 means it is animating an iconify.
198 < 0 means it is animating a restore.
199 */
200 gint iconify_animation_going;
201 guint iconify_animation_timer;
202 GTimeVal iconify_animation_end;
203 };
204
205 ObFrame *frame_new(struct _ObClient *c);
206 void frame_free(ObFrame *self);
207
208 void frame_show(ObFrame *self);
209 void frame_hide(ObFrame *self);
210 void frame_adjust_theme(ObFrame *self);
211 #ifdef SHAPE
212 void frame_adjust_shape_kind(ObFrame *self, int kind);
213 #endif
214 void frame_adjust_shape(ObFrame *self);
215 void frame_adjust_area(ObFrame *self, gboolean moved,
216 gboolean resized, gboolean fake);
217 void frame_adjust_client_area(ObFrame *self);
218 void frame_adjust_state(ObFrame *self);
219 void frame_adjust_focus(ObFrame *self, gboolean hilite);
220 void frame_adjust_title(ObFrame *self);
221 void frame_adjust_icon(ObFrame *self);
222 void frame_grab_client(ObFrame *self);
223 void frame_release_client(ObFrame *self);
224
225 ObFrameContext frame_context_from_string(const gchar *name);
226
227 /*! Parses a ObFrameContext from a string of space-separated context names.
228 @names The list of context names, the first of which is removed from the
229 string.
230 @cx The ObFrameContext is returned here. If an invalid name is found, this
231 is set to OB_FRAME_CONTEXT_NONE.
232 @return TRUE if there was something to read in @names, FALSE if it was an
233 empty input.
234 */
235 gboolean frame_next_context_from_string(gchar *names, ObFrameContext *cx);
236
237 ObFrameContext frame_context(struct _ObClient *self, Window win,
238 gint x, gint y);
239
240 /*! Applies gravity to the client's position to find where the frame should
241 be positioned.
242 @return The proper coordinates for the frame, based on the client.
243 */
244 void frame_client_gravity(ObFrame *self, gint *x, gint *y);
245
246 /*! Reversly applies gravity to the frame's position to find where the client
247 should be positioned.
248 @return The proper coordinates for the client, based on the frame.
249 */
250 void frame_frame_gravity(ObFrame *self, gint *x, gint *y);
251
252 /*! Convert a rectangle in client coordinates/sizes to what it would be
253 for the frame, given its current decorations sizes */
254 void frame_rect_to_frame(ObFrame *self, Rect *r);
255
256 /*! Convert a rectangle in frame coordinates/sizes to what it would be for the
257 client, given its current decorations sizes */
258 void frame_rect_to_client(ObFrame *self, Rect *r);
259
260 void frame_flash_start(ObFrame *self);
261 void frame_flash_stop(ObFrame *self);
262
263 /*! Start an animation for iconifying or restoring a frame. The callback
264 will be called when the animation finishes. But if another animation is
265 started in the meantime, the callback will never get called. */
266 void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying);
267 void frame_end_iconify_animation(ObFrame *self);
268
269 #define frame_iconify_animating(f) (f->iconify_animation_going != 0)
270
271 #endif
This page took 0.048213 seconds and 5 git commands to generate.