]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/engine_interface.h
Rename ObCLient.window to ObClient.w_client
[mikachu/openbox.git] / openbox / engine_interface.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3  plugin.h for the Openbox window manager
4  Copyright (c) 2003-2007   Dana Jansens
5
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  See the COPYING file for a copy of the GNU General Public License.
17  */
18 #ifndef ENGINE_INTERFACE_H_
19 #define ENGINE_INTERFACE_H_
20 /* Thanks to BMP, XMMS, Audacious and glib project to enable plugin */
21 #include "geom.h"
22 #include "render/render.h"
23 #include "render/theme.h"
24 #include "obt/parse.h"
25 #include "client.h"
26
27 #include "obt/mainloop.h"
28
29 #include <X11/Xresource.h>
30 #include <gmodule.h>
31
32 struct _RrTheme;
33 struct _ObClient;
34
35 typedef enum
36 {
37     OB_FRAME_CONTEXT_NONE,
38     OB_FRAME_CONTEXT_DESKTOP,
39     OB_FRAME_CONTEXT_ROOT,
40     OB_FRAME_CONTEXT_CLIENT,
41     OB_FRAME_CONTEXT_TITLEBAR,
42     OB_FRAME_CONTEXT_FRAME,
43     OB_FRAME_CONTEXT_BLCORNER,
44     OB_FRAME_CONTEXT_BRCORNER,
45     OB_FRAME_CONTEXT_TLCORNER,
46     OB_FRAME_CONTEXT_TRCORNER,
47     OB_FRAME_CONTEXT_TOP,
48     OB_FRAME_CONTEXT_BOTTOM,
49     OB_FRAME_CONTEXT_LEFT,
50     OB_FRAME_CONTEXT_RIGHT,
51     OB_FRAME_CONTEXT_MAXIMIZE,
52     OB_FRAME_CONTEXT_ALLDESKTOPS,
53     OB_FRAME_CONTEXT_SHADE,
54     OB_FRAME_CONTEXT_ICONIFY,
55     OB_FRAME_CONTEXT_ICON,
56     OB_FRAME_CONTEXT_CLOSE,
57     /*! This is a special context, which occurs while dragging a window in
58      a move/resize */
59     OB_FRAME_CONTEXT_MOVE_RESIZE,
60     OB_FRAME_NUM_CONTEXTS
61 } ObFrameContext;
62
63 /*! The decorations the client window wants to be displayed on it */
64 typedef enum
65 {
66     OB_FRAME_DECOR_TITLEBAR = 1 << 0, /*!< Display a titlebar */
67     OB_FRAME_DECOR_HANDLE = 1 << 1, /*!< Display a handle (bottom) */
68     OB_FRAME_DECOR_GRIPS = 1 << 2, /*!< Display grips in the handle */
69     OB_FRAME_DECOR_BORDER = 1 << 3, /*!< Display a border */
70     OB_FRAME_DECOR_ICON = 1 << 4, /*!< Display the window's icon */
71     OB_FRAME_DECOR_ICONIFY = 1 << 5, /*!< Display an iconify button */
72     OB_FRAME_DECOR_MAXIMIZE = 1 << 6, /*!< Display a maximize button */
73     /*! Display a button to toggle the window's placement on
74      all desktops */
75     OB_FRAME_DECOR_ALLDESKTOPS = 1 << 7,
76     OB_FRAME_DECOR_SHADE = 1 << 8, /*!< Displays a shade button */
77     OB_FRAME_DECOR_CLOSE = 1 << 9 /*!< Display a close button */
78 } ObFrameDecorations;
79
80 typedef enum
81 {
82     OB_BUTTON_NONE = 0,
83     OB_BUTTON_MAX = 1,
84     OB_BUTTON_CLOSE = 2,
85     OB_BUTTON_DESK = 3,
86     OB_BUTTON_SHADE = 4,
87     OB_BUTTON_ICONIFY = 5
88 } ObFrameButton;
89
90 /* The plugin must implement standars triggers and is free to use other
91  * It's mimic signal (USR1 and USR2) */
92 typedef enum
93 {
94     OB_TRIGGER_NONE,
95     OB_TRIGGER_INCONIFY,
96     OB_TRIGGER_UNICONIFY,
97     OB_TRIGGER_INCONIFY_TOGGLE,
98     OB_TRIGGER_SHADE,
99     OB_TRIGGER_UNSHADE,
100     OB_TRIGGER_SHADE_TOGGLE,
101     OB_TRIGGER_MAX,
102     OB_TRIGGER_UNMAX,
103     OB_TRIGGER_MAX_TOGGLE,
104     OB_TRIGGER_MAX_VERT,
105     OB_TRIGGER_UNMAX_VERT,
106     OB_TRIGGER_MAX_VERT_TOGGLE,
107     OB_TRIGGER_MAX_HORZ,
108     OB_TRIGGER_UNMAX_HORZ,
109     OB_TRIGGER_MAX_HORZ_TOGGLE,
110     OB_TRIGGER_PLUGIN1,
111     OB_TRIGGER_PLUGIN2,
112     OB_TRIGGER_PLUGIN3,
113     OB_TRIGGER_PLUGIN4, /* ... */
114     OB_TRIGGER_PLUGIN5, /* ... */
115     OB_TRIGGER_PLUGIN6, /* ... */
116     OB_TRIGGER_PLUGIN7, /* ... */
117     OB_TRIGGER_PLUGIN8, /* ... */
118     OB_TRIGGER_PLUGIN9, /* ... */
119 } ObFrameTrigger;
120
121 struct _ObFramePlugin
122 {
123     gpointer handler; // Currently not used.
124
125     gchar * filename;
126     gchar * name;
127
128     /* Function to init module */
129     gint (*init)(Display * display, gint screen);
130     /* Not curently used */
131     gint (*release)(void);
132
133     /* create a new frame, return the ID of frame */
134     gpointer (*frame_new)(struct _ObClient *c, Window w_client, Window w_frame);
135     /* Free the frame */
136     void (*frame_free)(gpointer self);
137
138     void (*frame_show)(gpointer self);
139     gint (*frame_hide)(gpointer self);
140
141     void (*frame_adjust_theme)(gpointer self);
142     void (*frame_adjust_shape)(gpointer self);
143
144     /* Grab or Ungrab event */
145     void (*frame_grab)(gpointer self, GHashTable *);
146     void (*frame_ungrab)(gpointer self, GHashTable *);
147
148     /* Provide the context of the mouse */
149     ObFrameContext (*frame_context)(gpointer self, Window win, gint x, gint y);
150
151     void (*frame_set_is_visible)(gpointer, gboolean);
152     void (*frame_set_is_focus)(gpointer, gboolean);
153     void (*frame_set_is_max_vert)(gpointer, gboolean);
154     void (*frame_set_is_max_horz)(gpointer, gboolean);
155     void (*frame_set_is_shaded)(gpointer, gboolean);
156
157     void (*frame_flash_start)(gpointer self);
158     void (*frame_flash_stop)(gpointer self);
159     void (*frame_begin_iconify_animation)(gpointer self, gboolean iconifying);
160     void (*frame_end_iconify_animation)(gpointer self);
161     gboolean (*frame_iconify_animating)(gpointer p);
162
163     /* Set the layout wanted by client */
164     void (*frame_set_decorations)(gpointer, ObFrameDecorations);
165     
166     void (*frame_update_title)(gpointer, const gchar *);
167
168     /* get the current window area */
169     Rect (*frame_get_window_area)(gpointer);
170     /* set the requested client area */
171     void (*frame_set_client_area)(gpointer, Rect);
172     /* Update size, move/resize windows */
173     void (*frame_update_layout)(gpointer self, gboolean is_resize,
174             gboolean is_fake);
175     /* Update skin, color/texture windows */ 
176     void (*frame_update_skin)(gpointer);
177
178     void (*frame_set_hover_flag)(gpointer, ObFrameButton);
179     void (*frame_set_press_flag)(gpointer, ObFrameButton);
180
181     Window (*frame_get_window)(gpointer);
182
183     Strut (*frame_get_size)(gpointer);
184     gint (*frame_get_decorations)(gpointer);
185
186     gboolean (*frame_is_visible)(gpointer);
187     gboolean (*frame_is_max_horz)(gpointer);
188     gboolean (*frame_is_max_vert)(gpointer);
189     
190     /* This must implement triggers (currently not used) */
191     void (*frame_trigger)(gpointer, ObFrameTrigger);
192
193     gint (*load_theme_config)(const RrInstance *inst, const gchar *name,
194             const gchar * path, XrmDatabase db, RrFont *active_window_font,
195             RrFont *inactive_window_font, RrFont *menu_title_font,
196             RrFont *menu_item_font, RrFont *osd_font);
197
198     /* Filled by openbox-core */
199     //Display * ob_display;
200     //gint ob_screen;
201     //RrInstance *ob_rr_inst;
202     // Not more needed
203     //struct _RrTheme * ob_rr_theme;
204     gboolean config_theme_keepborder;
205     struct _ObClient *focus_cycle_target;
206     gchar *config_title_layout;
207     gboolean moveresize_in_progress;
208     struct _ObtMainLoop *ob_main_loop;
209 };
210 /* Define how to draw the current windows */
211 enum _ObStyle
212 {
213     OBSTYLE_DECOR,
214     OBSTYLE_NODECOR,
215     OBSTYLE_SHADE,
216     OBSTYLE_ICON,
217     OBSTYLE_MAXVERT,
218     OBSTYLE_MAXHORIZ,
219     OBSTYLE_MAX,
220 };
221
222 typedef enum _ObStyle ObStyle;
223 typedef struct _ObFramePlugin ObFramePlugin;
224 typedef ObFramePlugin * (*ObFramePluginFunc)(void);
225
226 #define OBFRAME(x) (ObFrame *) (x);
227
228 /* initialize theme plugin, it read themerc and load
229  * the plugin needed */
230 ObFramePlugin * init_frame_plugin(const gchar *name, gboolean allow_fallback,
231         RrFont *active_window_font, RrFont *inactive_window_font,
232         RrFont *menu_title_font, RrFont *menu_item_font, RrFont *osd_font);
233
234 /* Update plugin data */
235 void update_frame_plugin(ObFramePlugin *);
236
237 /* Load modules specified in filename */
238 ObFramePlugin * load_frame_plugin(const gchar * filename);
239
240 /* Give context from string, it's used to parse config file */
241 ObFrameContext frame_context_from_string(const gchar *name);
242 ObFrameContext plugin_frame_context(ObClient *, Window, gint, gint);
243
244 void frame_client_gravity(ObClient * self, gint *x, gint *y);
245 void frame_frame_gravity(ObClient * self, gint *x, gint *y);
246
247 void frame_rect_to_frame(ObClient * self, Rect *r);
248 void frame_rect_to_client(ObClient * self, Rect *r);
249
250 #endif /*FRAME_PLUGIN_H_*/