1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 frame.h for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
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.
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.
17 See the COPYING file for a copy of the GNU General Public License.
24 #include "render/render.h"
26 typedef struct _ObFrame ObFrame;
30 typedef void (*ObFrameIconifyAnimateFunc)(gpointer data);
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,
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
55 OB_FRAME_CONTEXT_MOVE_RESIZE,
59 /*! The decorations the client window wants to be displayed on it */
61 OB_FRAME_DECOR_TITLEBAR = 1 << 0, /*!< Display a titlebar */
62 OB_FRAME_DECOR_HANDLE = 1 << 1, /*!< Display a handle (bottom) */
63 OB_FRAME_DECOR_GRIPS = 1 << 2, /*!< Display grips in the handle */
64 OB_FRAME_DECOR_BORDER = 1 << 3, /*!< Display a border */
65 OB_FRAME_DECOR_ICON = 1 << 4, /*!< Display the window's icon */
66 OB_FRAME_DECOR_ICONIFY = 1 << 5, /*!< Display an iconify button */
67 OB_FRAME_DECOR_MAXIMIZE = 1 << 6, /*!< Display a maximize button */
68 /*! Display a button to toggle the window's placement on
70 OB_FRAME_DECOR_ALLDESKTOPS = 1 << 7,
71 OB_FRAME_DECOR_SHADE = 1 << 8, /*!< Displays a shade button */
72 OB_FRAME_DECOR_CLOSE = 1 << 9 /*!< Display a close button */
77 struct _ObClient *client;
100 /* These are borders of the frame and its elements */
104 Window titletopright;
119 Window innerleft; /*!< For drawing the inner client border */
120 Window innertop; /*!< For drawing the inner client border */
121 Window innerright; /*!< For drawing the inner client border */
122 Window innerbottom; /*!< For drawing the inner client border */
127 Window backback; /*!< A colored window shown while resizing */
128 Window backfront; /*!< An undrawn-in window, to prevent flashing on
131 /* These are resize handles inside the titlebar */
140 gint icon_on; /* if the window icon button is on */
141 gint label_on; /* if the window title is on */
142 gint iconify_on; /* if the window iconify button is on */
143 gint desk_on; /* if the window all-desktops button is on */
144 gint shade_on; /* if the window shade button is on */
145 gint max_on; /* if the window maximize button is on */
146 gint close_on; /* if the window close button is on */
148 gint width; /* width of the titlebar and handle */
149 gint label_width; /* width of the label in the titlebar */
150 gint icon_x; /* x-position of the window icon button */
151 gint label_x; /* x-position of the window title */
152 gint iconify_x; /* x-position of the window iconify button */
153 gint desk_x; /* x-position of the window all-desktops button */
154 gint shade_x; /* x-position of the window shade button */
155 gint max_x; /* x-position of the window maximize button */
156 gint close_x; /* x-position of the window close button */
157 gint bwidth; /* border width */
158 gint cbwidth_l; /* client border width */
159 gint cbwidth_t; /* client border width */
160 gint cbwidth_r; /* client border width */
161 gint cbwidth_b; /* client border width */
162 gboolean max_horz; /* when maxed some decorations are hidden */
163 gboolean max_vert; /* when maxed some decorations are hidden */
164 gboolean shaded; /* decorations adjust when shaded */
166 /* the leftmost and rightmost elements in the titlebar */
167 ObFrameContext leftmost;
168 ObFrameContext rightmost;
171 gboolean close_press;
173 gboolean shade_press;
174 gboolean iconify_press;
176 gboolean close_hover;
178 gboolean shade_hover;
179 gboolean iconify_hover;
182 gboolean need_render;
188 /*! Is the frame currently in an animation for iconify or restore.
189 0 means that it is not animating. > 0 means it is animating an iconify.
190 < 0 means it is animating a restore.
192 gint iconify_animation_going;
193 GTimeVal iconify_animation_end;
196 ObFrame *frame_new(struct _ObClient *c);
197 void frame_free(ObFrame *self);
199 void frame_show(ObFrame *self);
200 void frame_hide(ObFrame *self);
201 void frame_adjust_theme(ObFrame *self);
202 void frame_adjust_shape(ObFrame *self);
203 void frame_adjust_area(ObFrame *self, gboolean moved,
204 gboolean resized, gboolean fake);
205 void frame_adjust_client_area(ObFrame *self);
206 void frame_adjust_state(ObFrame *self);
207 void frame_adjust_focus(ObFrame *self, gboolean hilite);
208 void frame_adjust_title(ObFrame *self);
209 void frame_adjust_icon(ObFrame *self);
210 void frame_grab_client(ObFrame *self);
211 void frame_release_client(ObFrame *self);
213 ObFrameContext frame_context_from_string(const gchar *name);
215 ObFrameContext frame_context(struct _ObClient *self, Window win,
218 /*! Applies gravity to the client's position to find where the frame should
220 @return The proper coordinates for the frame, based on the client.
222 void frame_client_gravity(ObFrame *self, gint *x, gint *y);
224 /*! Reversly applies gravity to the frame's position to find where the client
225 should be positioned.
226 @return The proper coordinates for the client, based on the frame.
228 void frame_frame_gravity(ObFrame *self, gint *x, gint *y);
230 /*! Convert a rectangle in client coordinates/sizes to what it would be
231 for the frame, given its current decorations sizes */
232 void frame_rect_to_frame(ObFrame *self, Rect *r);
234 /*! Convert a rectangle in frame coordinates/sizes to what it would be for the
235 client, given its current decorations sizes */
236 void frame_rect_to_client(ObFrame *self, Rect *r);
238 void frame_flash_start(ObFrame *self);
239 void frame_flash_stop(ObFrame *self);
241 /*! Start an animation for iconifying or restoring a frame. The callback
242 will be called when the animation finishes. But if another animation is
243 started in the meantime, the callback will never get called. */
244 void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying);
245 void frame_end_iconify_animation(ObFrame *self);
247 #define frame_iconify_animating(f) (f->iconify_animation_going != 0)