]> icculus.org git repositories - dana/openbox.git/blob - openbox/engine_interface.h
Implement plugin engine to draw frame (Follow Master patch)
[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 typedef enum
91 {
92     OB_FRAME_STATE_NORMAL,
93     OB_FRAME_STATE_INCONIFIED,
94     OB_FRAME_STATE_SHADED,
95     OB_FRAME_STATE_MAX,
96     OB_FRAME_STATE_MAX_VERT,
97     OB_FRAME_STATE_MAX_HORZ,
98     OB_FRAME_STATE_NO_BORDER
99 } ObFrameState;
100
101 struct _ObFramePlugin
102 {
103     gpointer handler; // Currently not used.
104
105     gchar * filename;
106     gchar * name;
107
108     /* Function to init module */
109     gint (*init)(Display * display, gint screen);
110     /* Not curently used */
111     gint (*release)(void);
112
113     /* create a new frame, return the ID of frame */
114     gpointer (*frame_new)(struct _ObClient *c);
115     /* Free the frame */
116     void (*frame_free)(gpointer self);
117
118     void (*frame_show)(gpointer self);
119     gint (*frame_hide)(gpointer self);
120
121     void (*frame_adjust_theme)(gpointer self);
122     void (*frame_adjust_shape)(gpointer self);
123
124     /* Grab or Ungrab event */
125     void (*frame_grab)(gpointer self, GHashTable *);
126     void (*frame_ungrab)(gpointer self, GHashTable *);
127
128     /* Provide the context of the mouse */
129     ObFrameContext (*frame_context)(gpointer self, Window win, gint x, gint y);
130
131     void (*frame_set_is_visible)(gpointer, gboolean);
132     void (*frame_set_is_focus)(gpointer, gboolean);
133     void (*frame_set_is_max_vert)(gpointer, gboolean);
134     void (*frame_set_is_max_horz)(gpointer, gboolean);
135     void (*frame_set_is_shaded)(gpointer, gboolean);
136
137     void (*frame_flash_start)(gpointer self);
138     void (*frame_flash_stop)(gpointer self);
139     void (*frame_begin_iconify_animation)(gpointer self, gboolean iconifying);
140     void (*frame_end_iconify_animation)(gpointer self);
141     gboolean (*frame_iconify_animating)(gpointer p);
142
143     /* Set the layout wanted by client */
144     void (*frame_set_decorations)(gpointer, ObFrameDecorations);
145
146     /* get the current window area */
147     Rect (*frame_get_window_area)(gpointer);
148     /* set the requested client area */
149     void (*frame_set_client_area)(gpointer, Rect);
150     /* Draw the frame */
151     void (*frame_update_layout)(gpointer self, gboolean is_resize,
152             gboolean is_fake);
153     void (*frame_update_skin)(gpointer);
154
155     void (*frame_set_hover_flag)(gpointer, ObFrameButton);
156     void (*frame_set_press_flag)(gpointer, ObFrameButton);
157
158     Window (*frame_get_window)(gpointer);
159
160     Strut (*frame_get_size)(gpointer);
161     gint (*frame_get_decorations)(gpointer);
162
163     gboolean (*frame_is_visible)(gpointer);
164     gboolean (*frame_is_max_horz)(gpointer);
165     gboolean (*frame_is_max_vert)(gpointer);
166
167     gint (*load_theme_config)(const RrInstance *inst, const gchar *name,
168             const gchar * path, XrmDatabase db, RrFont *active_window_font,
169             RrFont *inactive_window_font, RrFont *menu_title_font,
170             RrFont *menu_item_font, RrFont *osd_font);
171
172     /* Filled by openbox-core */
173     Display * ob_display;
174     gint ob_screen;
175     RrInstance *ob_rr_inst;
176     // Not more needed
177     //struct _RrTheme * ob_rr_theme;
178     gboolean config_theme_keepborder;
179     struct _ObClient *focus_cycle_target;
180     gchar *config_title_layout;
181     gboolean moveresize_in_progress;
182     struct _ObtMainLoop *ob_main_loop;
183 };
184 /* Define how to draw the current windows */
185 enum _ObStyle
186 {
187     OBSTYLE_DECOR,
188     OBSTYLE_NODECOR,
189     OBSTYLE_SHADE,
190     OBSTYLE_ICON,
191     OBSTYLE_MAXVERT,
192     OBSTYLE_MAXHORIZ,
193     OBSTYLE_MAX,
194 };
195
196 typedef enum _ObStyle ObStyle;
197 typedef struct _ObFramePlugin ObFramePlugin;
198 typedef ObFramePlugin * (*ObFramePluginFunc)(void);
199
200 #define OBFRAME(x) (ObFrame *) (x);
201
202 /* initialize theme plugin, it read themerc and load
203  * the plugin needed */
204 ObFramePlugin * init_frame_plugin(const gchar *name, gboolean allow_fallback,
205         RrFont *active_window_font, RrFont *inactive_window_font,
206         RrFont *menu_title_font, RrFont *menu_item_font, RrFont *osd_font);
207
208 /* Update plugin data */
209 void update_frame_plugin(ObFramePlugin *);
210
211 /* Load modules specified in filename */
212 ObFramePlugin * load_frame_plugin(const gchar * filename);
213
214 /* Give context from string, it's used to parse config file */
215 ObFrameContext frame_context_from_string(const gchar *name);
216 ObFrameContext plugin_frame_context(ObClient *, Window, gint, gint);
217
218 void frame_client_gravity(ObClient * self, gint *x, gint *y);
219 void frame_frame_gravity(ObClient * self, gint *x, gint *y);
220
221 void frame_rect_to_frame(ObClient * self, Rect *r);
222 void frame_rect_to_client(ObClient * self, Rect *r);
223
224 #endif /*FRAME_PLUGIN_H_*/