]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/frame.h
construct the titlebar without borders
[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_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 /*! The decorations the client window wants to be displayed on it */
60 typedef enum {
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
69       all desktops */
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 */
73 } ObFrameDecorations;
74
75 struct _ObFrame
76 {
77     struct _ObClient *client;
78
79     Window    window;
80     Window    plate;
81
82     Strut     size;
83     Rect      area;
84     gboolean  visible;
85
86     guint     functions;
87     guint     decorations;
88     gboolean  max_horz;
89
90     Window    inner;  /*!< The window for drawing the inner client border */
91     Window    title;
92     Window    label;
93     Window    max;
94     Window    close;
95     Window    desk;
96     Window    shade;
97     Window    icon;
98     Window    iconify;
99     Window    handle;
100     Window    lgrip;
101     Window    rgrip;
102
103     /* These are borders of the frame and its elements */
104     Window    titleleft;
105     Window    titletop;
106     Window    titletopleft;
107     Window    titletopright;
108     Window    titleright;
109     Window    titlebottom;
110     Window    leftresize;
111     Window    rightresize;
112
113     /* These are resize handles inside the titlebar */
114     Window    topresize;
115     Window    tltresize;
116     Window    tllresize;
117     Window    trtresize;
118     Window    trrresize;
119
120     Colormap  colormap;
121
122     RrAppearance *a_unfocused_title;
123     RrAppearance *a_focused_title;
124     RrAppearance *a_unfocused_label;
125     RrAppearance *a_focused_label;
126     RrAppearance *a_icon;
127     RrAppearance *a_unfocused_handle;
128     RrAppearance *a_focused_handle;
129
130     GSList   *clients;
131
132     gint      icon_on;    /* if the window icon button is on */
133     gint      label_on;   /* if the window title is on */
134     gint      iconify_on; /* if the window iconify button is on */
135     gint      desk_on;    /* if the window all-desktops button is on */
136     gint      shade_on;   /* if the window shade button is on */
137     gint      max_on;     /* if the window maximize button is on */
138     gint      close_on;   /* if the window close button is on */
139
140     gint      width;         /* width of the titlebar and handle */
141     gint      label_width;   /* width of the label in the titlebar */
142     gint      icon_x;        /* x-position of the window icon button */
143     gint      label_x;       /* x-position of the window title */
144     gint      iconify_x;     /* x-position of the window iconify button */
145     gint      desk_x;        /* x-position of the window all-desktops button */
146     gint      shade_x;       /* x-position of the window shade button */
147     gint      max_x;         /* x-position of the window maximize button */
148     gint      close_x;       /* x-position of the window close button */
149     gint      bwidth;        /* border width */
150     gint      rbwidth;       /* border width between the title and client */
151     gint      cbwidth_x;     /* client border width */
152     gint      cbwidth_y;     /* client border width */
153
154     /* the leftmost and rightmost elements in the titlebar */
155     ObFrameContext leftmost;
156     ObFrameContext rightmost;
157
158     gboolean  max_press;
159     gboolean  close_press;
160     gboolean  desk_press;
161     gboolean  shade_press;
162     gboolean  iconify_press;
163     gboolean  max_hover;
164     gboolean  close_hover;
165     gboolean  desk_hover;
166     gboolean  shade_hover;
167     gboolean  iconify_hover;
168
169     gboolean  focused;
170
171     gboolean  flashing;
172     gboolean  flash_on;
173     GTimeVal  flash_end;
174
175     /*! Is the frame currently in an animation for iconify or restore.
176       0 means that it is not animating. > 0 means it is animating an iconify.
177       < 0 means it is animating a restore.
178     */
179     gint iconify_animation_going;
180     GTimeVal  iconify_animation_end;
181 };
182
183 ObFrame *frame_new(struct _ObClient *c);
184 void frame_free(ObFrame *self);
185
186 void frame_show(ObFrame *self);
187 void frame_hide(ObFrame *self);
188 void frame_adjust_theme(ObFrame *self);
189 void frame_adjust_shape(ObFrame *self);
190 void frame_adjust_area(ObFrame *self, gboolean moved,
191                        gboolean resized, gboolean fake);
192 void frame_adjust_client_area(ObFrame *self);
193 void frame_adjust_state(ObFrame *self);
194 void frame_adjust_focus(ObFrame *self, gboolean hilite);
195 void frame_adjust_title(ObFrame *self);
196 void frame_adjust_icon(ObFrame *self);
197 void frame_grab_client(ObFrame *self);
198 void frame_release_client(ObFrame *self);
199
200 ObFrameContext frame_context_from_string(const gchar *name);
201
202 ObFrameContext frame_context(struct _ObClient *self, Window win,
203                              gint x, gint y);
204
205 /*! Applies gravity to the client's position to find where the frame should
206   be positioned.
207   @return The proper coordinates for the frame, based on the client.
208 */
209 void frame_client_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h);
210
211 /*! Reversly applies gravity to the frame's position to find where the client
212   should be positioned.
213     @return The proper coordinates for the client, based on the frame.
214 */
215 void frame_frame_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h);
216
217 void frame_flash_start(ObFrame *self);
218 void frame_flash_stop(ObFrame *self);
219
220 /*! Start an animation for iconifying or restoring a frame. The callback
221   will be called when the animation finishes. But if another animation is
222   started in the meantime, the callback will never get called. */
223 void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying);
224 void frame_end_iconify_animation(ObFrame *self);
225
226 #define frame_iconify_animating(f) (f->iconify_animation_going != 0)
227
228 #endif