]> icculus.org git repositories - dana/openbox.git/blob - openbox/engine_interface.h
Ramove unneeded frame_get_window
[dana/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 _ObFrameEngine
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_adjust_theme)(gpointer self);
139     void (*frame_adjust_shape)(gpointer self);
140
141     /* Grab or Ungrab event */
142     void (*frame_grab)(gpointer self, GHashTable *);
143     void (*frame_ungrab)(gpointer self, GHashTable *);
144
145     /* Provide the context of the mouse */
146     ObFrameContext (*frame_context)(gpointer self, Window win, gint x, gint y);
147
148     void (*frame_set_is_visible)(gpointer, gboolean);
149     void (*frame_set_is_focus)(gpointer, gboolean);
150     void (*frame_set_is_max_vert)(gpointer, gboolean);
151     void (*frame_set_is_max_horz)(gpointer, gboolean);
152     void (*frame_set_is_shaded)(gpointer, gboolean);
153
154     void (*frame_flash_start)(gpointer self);
155     void (*frame_flash_stop)(gpointer self);
156
157     /* Set the layout wanted by client */
158     void (*frame_set_decorations)(gpointer, ObFrameDecorations);
159     
160     void (*frame_update_title)(gpointer, const gchar *);
161
162     /* get the current window area */
163     void (*frame_get_window_area)(gpointer, Rect *);
164     /* set the requested client area */
165     void (*frame_set_client_area)(gpointer, Rect);
166     /* Update size, move/resize windows */
167     void (*frame_update_layout)(gpointer self, Rect, gboolean is_resize,
168             gboolean is_fake);
169     /* Update skin, color/texture windows */ 
170     void (*frame_update_skin)(gpointer);
171
172     void (*frame_set_hover_flag)(gpointer, ObFrameButton);
173     void (*frame_set_press_flag)(gpointer, ObFrameButton);
174
175     void (*frame_get_size)(gpointer, Strut *);
176     gint (*frame_get_decorations)(gpointer);
177
178     gboolean (*frame_is_visible)(gpointer);
179     gboolean (*frame_is_max_horz)(gpointer);
180     gboolean (*frame_is_max_vert)(gpointer);
181     
182     /* This must implement triggers (currently not used) */
183     void (*frame_trigger)(gpointer, ObFrameTrigger);
184
185     gint (*load_theme_config)(const RrInstance *inst, const gchar *name,
186             const gchar * path, XrmDatabase db, RrFont *active_window_font,
187             RrFont *inactive_window_font, RrFont *menu_title_font,
188             RrFont *menu_item_font, RrFont *osd_font);
189
190     /* Filled by openbox-core */
191     //Display * ob_display;
192     //gint ob_screen;
193     //RrInstance *ob_rr_inst;
194     // Not more needed
195     //struct _RrTheme * ob_rr_theme;
196     gboolean config_theme_keepborder;
197     struct _ObClient *focus_cycle_target;
198     gchar *config_title_layout;
199     gboolean moveresize_in_progress;
200     struct _ObtMainLoop *ob_main_loop;
201 };
202 /* Define how to draw the current windows */
203 enum _ObStyle
204 {
205     OBSTYLE_DECOR,
206     OBSTYLE_NODECOR,
207     OBSTYLE_SHADE,
208     OBSTYLE_ICON,
209     OBSTYLE_MAXVERT,
210     OBSTYLE_MAXHORIZ,
211     OBSTYLE_MAX,
212 };
213
214 typedef enum _ObStyle ObStyle;
215 typedef struct _ObFrameEngine ObFrameEngine;
216 typedef ObFrameEngine * (*ObFrameEngineFunc)(void);
217
218 #define OBFRAME(x) (ObFrame *) (x);
219
220 /* initialize theme plugin, it read themerc and load
221  * the plugin needed */
222 ObFrameEngine * init_frame_plugin(const gchar *name, gboolean allow_fallback,
223         RrFont *active_window_font, RrFont *inactive_window_font,
224         RrFont *menu_title_font, RrFont *menu_item_font, RrFont *osd_font);
225
226 /* Update plugin data */
227 void update_frame_plugin(ObFrameEngine *);
228
229 /* Load modules specified in filename */
230 ObFrameEngine * load_frame_plugin(const gchar * filename);
231
232 /* Give context from string, it's used to parse config file */
233 ObFrameContext frame_context_from_string(const gchar *name);
234 ObFrameContext plugin_frame_context(ObClient *, Window, gint, gint);
235
236 void frame_client_gravity(ObClient * self, gint *x, gint *y);
237 void frame_frame_gravity(ObClient * self, gint *x, gint *y);
238
239 void frame_rect_to_frame(ObClient * self, Rect *r);
240 void frame_rect_to_client(ObClient * self, Rect *r);
241
242 #endif /*FRAME_PLUGIN_H_*/