lots of fixes for the iconify animation. i think it should all work perfectly now ?
[mikachu/openbox.git] / 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 "render/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_CLIENT,
36     OB_FRAME_CONTEXT_TITLEBAR,
37     OB_FRAME_CONTEXT_HANDLE,
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_MAXIMIZE,
44     OB_FRAME_CONTEXT_ALLDESKTOPS,
45     OB_FRAME_CONTEXT_SHADE,
46     OB_FRAME_CONTEXT_ICONIFY,
47     OB_FRAME_CONTEXT_ICON,
48     OB_FRAME_CONTEXT_CLOSE,
49     /*! This is a special context, which occurs while dragging a window in
50       a move/resize */
51     OB_FRAME_CONTEXT_MOVE_RESIZE,
52     OB_FRAME_NUM_CONTEXTS
53 } ObFrameContext;
54
55 /*! The decorations the client window wants to be displayed on it */
56 typedef enum {
57     OB_FRAME_DECOR_TITLEBAR    = 1 << 0, /*!< Display a titlebar */
58     OB_FRAME_DECOR_HANDLE      = 1 << 1, /*!< Display a handle (bottom) */
59     OB_FRAME_DECOR_GRIPS       = 1 << 2, /*!< Display grips in the handle */
60     OB_FRAME_DECOR_BORDER      = 1 << 3, /*!< Display a border */
61     OB_FRAME_DECOR_ICON        = 1 << 4, /*!< Display the window's icon */
62     OB_FRAME_DECOR_ICONIFY     = 1 << 5, /*!< Display an iconify button */
63     OB_FRAME_DECOR_MAXIMIZE    = 1 << 6, /*!< Display a maximize button */
64     /*! Display a button to toggle the window's placement on
65       all desktops */
66     OB_FRAME_DECOR_ALLDESKTOPS = 1 << 7,
67     OB_FRAME_DECOR_SHADE       = 1 << 8, /*!< Displays a shade button */
68     OB_FRAME_DECOR_CLOSE       = 1 << 9  /*!< Display a close button */
69 } ObFrameDecorations;
70
71 struct _ObFrame
72 {
73     struct _ObClient *client;
74
75     Window    window;
76     Window    plate;
77
78     Strut     size;
79     Rect      area;
80     /*! Is the frame visible? Don't read this directly ! Use frame_visible()
81       instead, because that takes into account if the frame is visible but
82       animating to the iconic (invisible) state. */
83     gboolean  visible;
84
85     guint     decorations;
86     gboolean  max_horz;
87
88     Window    inner;  /*!< The window for drawing the inner client border */
89     Window    title;
90     Window    label;
91     Window    max;
92     Window    close;
93     Window    desk;
94     Window    shade;
95     Window    icon;
96     Window    iconify;
97     Window    handle;
98     Window    lgrip;
99     Window    rgrip;
100
101     Window    tltresize;
102     Window    tllresize;
103     Window    trtresize;
104     Window    trrresize;
105
106     Colormap  colormap;
107
108     RrAppearance *a_unfocused_title;
109     RrAppearance *a_focused_title;
110     RrAppearance *a_unfocused_label;
111     RrAppearance *a_focused_label;
112     RrAppearance *a_icon;
113     RrAppearance *a_unfocused_handle;
114     RrAppearance *a_focused_handle;
115
116     Strut     innersize;
117
118     GSList   *clients;
119
120     gint      width;         /* title and handle */
121     gint      label_width;
122     gint      icon_x;        /* x-position of the window icon button */
123     gint      label_x;       /* x-position of the window title */
124     gint      iconify_x;     /* x-position of the window iconify button */
125     gint      desk_x;        /* x-position of the window all-desktops button */
126     gint      shade_x;       /* x-position of the window shade button */
127     gint      max_x;         /* x-position of the window maximize button */
128     gint      close_x;       /* x-position of the window close button */
129     gint      bwidth;        /* border width */
130     gint      rbwidth;       /* title border width */
131     gint      cbwidth_x;     /* client border width */
132     gint      cbwidth_y;     /* client border width */
133
134     gboolean  max_press;
135     gboolean  close_press;
136     gboolean  desk_press;
137     gboolean  shade_press;
138     gboolean  iconify_press;
139     gboolean  max_hover;
140     gboolean  close_hover;
141     gboolean  desk_hover;
142     gboolean  shade_hover;
143     gboolean  iconify_hover;
144
145     gboolean  focused;
146
147     gboolean  flashing;
148     gboolean  flash_on;
149     GTimeVal  flash_end;
150
151     /*! Is the frame currently in an animation for iconify or restore.
152       0 means that it is not animating. > 0 means it is animating an iconify.
153       < 0 means it is animating a restore.
154     */
155     gint iconify_animation_going;
156     GTimeVal  iconify_animation_end;
157     ObFrameIconifyAnimateFunc iconify_animation_cb;
158     gpointer iconify_animation_data;
159 };
160
161 ObFrame *frame_new(struct _ObClient *c);
162 void frame_show(ObFrame *self);
163 void frame_hide(ObFrame *self);
164 void frame_adjust_theme(ObFrame *self);
165 void frame_adjust_shape(ObFrame *self);
166 void frame_adjust_area(ObFrame *self, gboolean moved,
167                        gboolean resized, gboolean fake);
168 void frame_adjust_client_area(ObFrame *self);
169 void frame_adjust_state(ObFrame *self);
170 void frame_adjust_focus(ObFrame *self, gboolean hilite);
171 void frame_adjust_title(ObFrame *self);
172 void frame_adjust_icon(ObFrame *self);
173 void frame_grab_client(ObFrame *self, struct _ObClient *client);
174 void frame_release_client(ObFrame *self, struct _ObClient *client);
175
176 ObFrameContext frame_context_from_string(const gchar *name);
177
178 ObFrameContext frame_context(struct _ObClient *self, Window win);
179
180 /*! Applies gravity to the client's position to find where the frame should
181   be positioned.
182   @return The proper coordinates for the frame, based on the client.
183 */
184 void frame_client_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h);
185
186 /*! Reversly applies gravity to the frame's position to find where the client
187   should be positioned.
188     @return The proper coordinates for the client, based on the frame.
189 */
190 void frame_frame_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h);
191
192 void frame_flash_start(ObFrame *self);
193 void frame_flash_stop(ObFrame *self);
194
195 /*! Start an animation for iconifying or restoring a frame. The callback
196   will be called when the animation finishes. But if another animation is
197   started in the meantime, the callback will never get called. */
198 void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying,
199                                    ObFrameIconifyAnimateFunc callback,
200                                    gpointer data);
201 void frame_end_iconify_animation(ObFrame *self);
202
203 /* Returns true if the frame is visible (but false if it is only visible
204    because it is animating */
205 gboolean frame_visible(ObFrame *self);
206
207 #define frame_iconify_animating(f) (f->iconify_animation_going != 0)
208
209 #endif