]> icculus.org git repositories - dana/openbox.git/blob - openbox/frame.h
add the MoveResize context, which is used while doing a move/resize on a window....
[dana/openbox.git] / openbox / frame.h
1 #ifndef __frame_h
2 #define __frame_h
3
4 #include "geom.h"
5 #include "render/render.h"
6
7 typedef struct _ObFrame ObFrame;
8
9 struct _ObClient;
10
11 typedef enum {
12     OB_FRAME_CONTEXT_NONE,
13     OB_FRAME_CONTEXT_DESKTOP,
14     OB_FRAME_CONTEXT_CLIENT,
15     OB_FRAME_CONTEXT_TITLEBAR,
16     OB_FRAME_CONTEXT_HANDLE,
17     OB_FRAME_CONTEXT_FRAME,
18     OB_FRAME_CONTEXT_BLCORNER,
19     OB_FRAME_CONTEXT_BRCORNER,
20     OB_FRAME_CONTEXT_TLCORNER,
21     OB_FRAME_CONTEXT_TRCORNER,
22     OB_FRAME_CONTEXT_MAXIMIZE,
23     OB_FRAME_CONTEXT_ALLDESKTOPS,
24     OB_FRAME_CONTEXT_SHADE,
25     OB_FRAME_CONTEXT_ICONIFY,
26     OB_FRAME_CONTEXT_ICON,
27     OB_FRAME_CONTEXT_CLOSE,
28     /*! This is a special context, which occurs while dragging a window in
29       a move/resize */
30     OB_FRAME_CONTEXT_MOVE_RESIZE,
31     OB_FRAME_NUM_CONTEXTS
32 } ObFrameContext;
33
34 /*! The decorations the client window wants to be displayed on it */
35 typedef enum {
36     OB_FRAME_DECOR_TITLEBAR    = 1 << 0, /*!< Display a titlebar */
37     OB_FRAME_DECOR_HANDLE      = 1 << 1, /*!< Display a handle (bottom) */
38     OB_FRAME_DECOR_GRIPS       = 1 << 2, /*!< Display grips in the handle */
39     OB_FRAME_DECOR_BORDER      = 1 << 3, /*!< Display a border */
40     OB_FRAME_DECOR_ICON        = 1 << 4, /*!< Display the window's icon */
41     OB_FRAME_DECOR_ICONIFY     = 1 << 5, /*!< Display an iconify button */
42     OB_FRAME_DECOR_MAXIMIZE    = 1 << 6, /*!< Display a maximize button */
43     /*! Display a button to toggle the window's placement on
44       all desktops */
45     OB_FRAME_DECOR_ALLDESKTOPS = 1 << 7,
46     OB_FRAME_DECOR_SHADE       = 1 << 8, /*!< Displays a shade button */
47     OB_FRAME_DECOR_CLOSE       = 1 << 9  /*!< Display a close button */
48 } ObFrameDecorations;
49
50 struct _ObFrame
51 {
52     struct _ObClient *client;
53
54     Window    window;
55     Window    plate;
56
57     Strut     size;
58     Rect      area;
59     gboolean  visible;
60
61     /*! Whether the window is obscured at all or fully visible. */
62     gboolean obscured;
63
64     guint     decorations;
65     gboolean  max_horz;
66
67     Window    title;
68     Window    label;
69     Window    max;
70     Window    close;
71     Window    desk;
72     Window    shade;
73     Window    icon;
74     Window    iconify;
75     Window    handle;
76     Window    lgrip;
77     Window    rgrip;
78
79     Window    tlresize;
80     Window    trresize;
81
82     RrAppearance *a_unfocused_title;
83     RrAppearance *a_focused_title;
84     RrAppearance *a_unfocused_label;
85     RrAppearance *a_focused_label;
86     RrAppearance *a_icon;
87     RrAppearance *a_unfocused_handle;
88     RrAppearance *a_focused_handle;
89
90     Strut     innersize;
91
92     GSList   *clients;
93
94     gint      width;         /* title and handle */
95     gint      label_width;
96     gint      icon_x;        /* x-position of the window icon button */
97     gint      label_x;       /* x-position of the window title */
98     gint      iconify_x;     /* x-position of the window iconify button */
99     gint      desk_x;        /* x-position of the window all-desktops button */
100     gint      shade_x;       /* x-position of the window shade button */
101     gint      max_x;         /* x-position of the window maximize button */
102     gint      close_x;       /* x-position of the window close button */
103     gint      bwidth;        /* border width */
104     gint      rbwidth;       /* title border width */
105     gint      cbwidth_x;     /* client border width */
106     gint      cbwidth_y;     /* client border width */
107
108     gboolean  max_press;
109     gboolean  close_press;
110     gboolean  desk_press;
111     gboolean  shade_press;
112     gboolean  iconify_press;
113     gboolean  max_hover;
114     gboolean  close_hover;
115     gboolean  desk_hover;
116     gboolean  shade_hover;
117     gboolean  iconify_hover;
118
119     gboolean  focused;
120
121     gboolean  flashing;
122     gboolean  flash_on;
123     GTimeVal  flash_end;
124 };
125
126 ObFrame *frame_new();
127 void frame_show(ObFrame *self);
128 void frame_hide(ObFrame *self);
129 void frame_adjust_theme(ObFrame *self);
130 void frame_adjust_shape(ObFrame *self);
131 void frame_adjust_area(ObFrame *self, gboolean moved,
132                        gboolean resized, gboolean fake);
133 void frame_adjust_state(ObFrame *self);
134 void frame_adjust_focus(ObFrame *self, gboolean hilite);
135 void frame_adjust_title(ObFrame *self);
136 void frame_adjust_icon(ObFrame *self);
137 void frame_grab_client(ObFrame *self, struct _ObClient *client);
138 void frame_release_client(ObFrame *self, struct _ObClient *client);
139
140 ObFrameContext frame_context_from_string(char *name);
141
142 ObFrameContext frame_context(struct _ObClient *self, Window win);
143
144 /*! Applies gravity to the client's position to find where the frame should
145   be positioned.
146   @return The proper coordinates for the frame, based on the client.
147 */
148 void frame_client_gravity(ObFrame *self, int *x, int *y);
149
150 /*! Reversly applies gravity to the frame's position to find where the client
151   should be positioned.
152     @return The proper coordinates for the client, based on the frame.
153 */
154 void frame_frame_gravity(ObFrame *self, int *x, int *y);
155
156 void frame_flash_start(ObFrame *self);
157 void frame_flash_stop(ObFrame *self);
158
159 #endif