1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 
3 /* Marco common types shared by core.h and ui.h */
4 
5 /*
6  * Copyright (C) 2001 Havoc Pennington
7  * Copyright (C) 2005 Elijah Newren
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301, USA.
23  */
24 
25 #ifndef META_COMMON_H
26 #define META_COMMON_H
27 
28 /* Don't include core headers here */
29 #include <X11/Xlib.h>
30 #include <glib.h>
31 #include <gtk/gtk.h>
32 
33 typedef struct _MetaResizePopup MetaResizePopup;
34 
35 typedef enum
36 {
37   META_FRAME_ALLOWS_DELETE            = 1 << 0,
38   META_FRAME_ALLOWS_MENU              = 1 << 1,
39   META_FRAME_ALLOWS_APPMENU           = 1 << 2,
40   META_FRAME_ALLOWS_MINIMIZE          = 1 << 3,
41   META_FRAME_ALLOWS_MAXIMIZE          = 1 << 4,
42   META_FRAME_ALLOWS_VERTICAL_RESIZE   = 1 << 5,
43   META_FRAME_ALLOWS_HORIZONTAL_RESIZE = 1 << 6,
44   META_FRAME_HAS_FOCUS                = 1 << 7,
45   META_FRAME_SHADED                   = 1 << 8,
46   META_FRAME_STUCK                    = 1 << 9,
47   META_FRAME_MAXIMIZED                = 1 << 10,
48   META_FRAME_ALLOWS_SHADE             = 1 << 11,
49   META_FRAME_ALLOWS_MOVE              = 1 << 12,
50   META_FRAME_FULLSCREEN               = 1 << 13,
51   META_FRAME_IS_FLASHING              = 1 << 14,
52   META_FRAME_ABOVE                    = 1 << 15,
53   META_FRAME_TILED_LEFT               = 1 << 16,
54   META_FRAME_TILED_RIGHT              = 1 << 17
55 } MetaFrameFlags;
56 
57 typedef enum
58 {
59   META_MENU_OP_NONE        = 0,
60   META_MENU_OP_DELETE      = 1 << 0,
61   META_MENU_OP_MINIMIZE    = 1 << 1,
62   META_MENU_OP_UNMAXIMIZE  = 1 << 2,
63   META_MENU_OP_MAXIMIZE    = 1 << 3,
64   META_MENU_OP_UNSHADE     = 1 << 4,
65   META_MENU_OP_SHADE       = 1 << 5,
66   META_MENU_OP_UNSTICK     = 1 << 6,
67   META_MENU_OP_STICK       = 1 << 7,
68   META_MENU_OP_WORKSPACES  = 1 << 8,
69   META_MENU_OP_MOVE        = 1 << 9,
70   META_MENU_OP_RESIZE      = 1 << 10,
71   META_MENU_OP_ABOVE       = 1 << 11,
72   META_MENU_OP_UNABOVE     = 1 << 12,
73   META_MENU_OP_MOVE_LEFT   = 1 << 13,
74   META_MENU_OP_MOVE_RIGHT  = 1 << 14,
75   META_MENU_OP_MOVE_UP     = 1 << 15,
76   META_MENU_OP_MOVE_DOWN   = 1 << 16,
77   META_MENU_OP_RECOVER     = 1 << 17
78 } MetaMenuOp;
79 
80 typedef struct _MetaWindowMenu MetaWindowMenu;
81 
82 typedef void (* MetaWindowMenuFunc) (MetaWindowMenu *menu,
83                                      Display        *xdisplay,
84                                      Window          client_xwindow,
85                                      guint32         timestamp,
86                                      MetaMenuOp      op,
87                                      int             workspace,
88                                      gpointer        data);
89 
90 /* when changing this enum, there are various switch statements
91  * you have to update
92  */
93 typedef enum
94 {
95   META_GRAB_OP_NONE,
96 
97   /* Mouse ops */
98   META_GRAB_OP_MOVING,
99   META_GRAB_OP_RESIZING_SE,
100   META_GRAB_OP_RESIZING_S,
101   META_GRAB_OP_RESIZING_SW,
102   META_GRAB_OP_RESIZING_N,
103   META_GRAB_OP_RESIZING_NE,
104   META_GRAB_OP_RESIZING_NW,
105   META_GRAB_OP_RESIZING_W,
106   META_GRAB_OP_RESIZING_E,
107 
108   /* Keyboard ops */
109   META_GRAB_OP_KEYBOARD_MOVING,
110   META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN,
111   META_GRAB_OP_KEYBOARD_RESIZING_S,
112   META_GRAB_OP_KEYBOARD_RESIZING_N,
113   META_GRAB_OP_KEYBOARD_RESIZING_W,
114   META_GRAB_OP_KEYBOARD_RESIZING_E,
115   META_GRAB_OP_KEYBOARD_RESIZING_SE,
116   META_GRAB_OP_KEYBOARD_RESIZING_NE,
117   META_GRAB_OP_KEYBOARD_RESIZING_SW,
118   META_GRAB_OP_KEYBOARD_RESIZING_NW,
119 
120   /* Alt+Tab */
121   META_GRAB_OP_KEYBOARD_TABBING_NORMAL,
122   META_GRAB_OP_KEYBOARD_TABBING_DOCK,
123   META_GRAB_OP_KEYBOARD_TABBING_NORMAL_ALL_WORKSPACES,
124 
125   /* Alt+Esc */
126   META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL,
127   META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL_ALL_WORKSPACES,
128   META_GRAB_OP_KEYBOARD_ESCAPING_DOCK,
129 
130   META_GRAB_OP_KEYBOARD_ESCAPING_GROUP,
131 
132   /* Alt+F6 */
133   META_GRAB_OP_KEYBOARD_TABBING_GROUP,
134 
135   META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING,
136   META_GRAB_OP_KEYBOARD_WORKSPACE_MOVING,
137 
138   /* Frame button ops */
139   META_GRAB_OP_CLICKING_MINIMIZE,
140   META_GRAB_OP_CLICKING_MAXIMIZE,
141   META_GRAB_OP_CLICKING_MAXIMIZE_VERTICAL,
142   META_GRAB_OP_CLICKING_MAXIMIZE_HORIZONTAL,
143   META_GRAB_OP_CLICKING_UNMAXIMIZE,
144   META_GRAB_OP_CLICKING_UNMAXIMIZE_VERTICAL,
145   META_GRAB_OP_CLICKING_UNMAXIMIZE_HORIZONTAL,
146   META_GRAB_OP_CLICKING_DELETE,
147   META_GRAB_OP_CLICKING_MENU,
148   META_GRAB_OP_CLICKING_APPMENU,
149   META_GRAB_OP_CLICKING_SHADE,
150   META_GRAB_OP_CLICKING_UNSHADE,
151   META_GRAB_OP_CLICKING_ABOVE,
152   META_GRAB_OP_CLICKING_UNABOVE,
153   META_GRAB_OP_CLICKING_STICK,
154   META_GRAB_OP_CLICKING_UNSTICK
155 } MetaGrabOp;
156 
157 typedef enum
158 {
159   META_CURSOR_DEFAULT,
160   META_CURSOR_NORTH_RESIZE,
161   META_CURSOR_SOUTH_RESIZE,
162   META_CURSOR_WEST_RESIZE,
163   META_CURSOR_EAST_RESIZE,
164   META_CURSOR_SE_RESIZE,
165   META_CURSOR_SW_RESIZE,
166   META_CURSOR_NE_RESIZE,
167   META_CURSOR_NW_RESIZE,
168   META_CURSOR_MOVE_OR_RESIZE_WINDOW,
169   META_CURSOR_BUSY
170 
171 } MetaCursor;
172 
173 typedef enum
174 {
175   META_FOCUS_MODE_CLICK,
176   META_FOCUS_MODE_SLOPPY,
177   META_FOCUS_MODE_MOUSE
178 } MetaFocusMode;
179 
180 typedef enum
181 {
182   META_FOCUS_NEW_WINDOWS_SMART,
183   META_FOCUS_NEW_WINDOWS_STRICT
184 } MetaFocusNewWindows;
185 
186 typedef enum
187 {
188   META_WRAP_NONE,
189   META_WRAP_CLASSIC,
190   META_WRAP_TOROIDAL
191 } MetaWrapStyle;
192 
193 typedef enum
194 {
195   META_ACTION_TITLEBAR_TOGGLE_SHADE,
196   META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE,
197   META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY,
198   META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY,
199   META_ACTION_TITLEBAR_MINIMIZE,
200   META_ACTION_TITLEBAR_NONE,
201   META_ACTION_TITLEBAR_LOWER,
202   META_ACTION_TITLEBAR_MENU,
203   META_ACTION_TITLEBAR_LAST
204 } MetaActionTitlebar;
205 
206 typedef enum
207 {
208   META_FRAME_TYPE_NORMAL,
209   META_FRAME_TYPE_DIALOG,
210   META_FRAME_TYPE_MODAL_DIALOG,
211   META_FRAME_TYPE_UTILITY,
212   META_FRAME_TYPE_MENU,
213   META_FRAME_TYPE_BORDER,
214   META_FRAME_TYPE_ATTACHED,
215   META_FRAME_TYPE_LAST
216 } MetaFrameType;
217 
218 typedef enum
219 {
220   /* Create gratuitous divergence from regular
221    * X mod bits, to be sure we find bugs
222    */
223   META_VIRTUAL_SHIFT_MASK    = 1 << 5,
224   META_VIRTUAL_CONTROL_MASK  = 1 << 6,
225   META_VIRTUAL_ALT_MASK      = 1 << 7,
226   META_VIRTUAL_META_MASK     = 1 << 8,
227   META_VIRTUAL_SUPER_MASK    = 1 << 9,
228   META_VIRTUAL_HYPER_MASK    = 1 << 10,
229   META_VIRTUAL_MOD2_MASK     = 1 << 11,
230   META_VIRTUAL_MOD3_MASK     = 1 << 12,
231   META_VIRTUAL_MOD4_MASK     = 1 << 13,
232   META_VIRTUAL_MOD5_MASK     = 1 << 14
233 } MetaVirtualModifier;
234 
235 /* Relative directions or sides seem to come up all over the place... */
236 /* FIXME: Replace
237  *   screen.[ch]:MetaScreenDirection,
238  *   workspace.[ch]:MetaMotionDirection,
239  * with the use of MetaDirection.
240  */
241 typedef enum
242 {
243   META_DIRECTION_LEFT       = 1 << 0,
244   META_DIRECTION_RIGHT      = 1 << 1,
245   META_DIRECTION_TOP        = 1 << 2,
246   META_DIRECTION_BOTTOM     = 1 << 3,
247 
248   /* Some aliases for making code more readable for various circumstances. */
249   META_DIRECTION_UP         = META_DIRECTION_TOP,
250   META_DIRECTION_DOWN       = META_DIRECTION_BOTTOM,
251 
252   /* A few more definitions using aliases */
253   META_DIRECTION_HORIZONTAL = META_DIRECTION_LEFT | META_DIRECTION_RIGHT,
254   META_DIRECTION_VERTICAL   = META_DIRECTION_UP   | META_DIRECTION_DOWN,
255 } MetaDirection;
256 
257 /* Sometimes we want to talk about sides instead of directions; note
258  * that the values must be as follows or meta_window_update_struts()
259  * won't work. Using these values also is a safety blanket since
260  * MetaDirection used to be used as a side.
261  */
262 typedef enum
263 {
264   META_SIDE_LEFT            = META_DIRECTION_LEFT,
265   META_SIDE_RIGHT           = META_DIRECTION_RIGHT,
266   META_SIDE_TOP             = META_DIRECTION_TOP,
267   META_SIDE_BOTTOM          = META_DIRECTION_BOTTOM
268 } MetaSide;
269 
270 /* Function a window button can have.  Note, you can't add stuff here
271  * without extending the theme format to draw a new function and
272  * breaking all existing themes.
273  */
274 typedef enum
275 {
276   META_BUTTON_FUNCTION_MENU,
277   META_BUTTON_FUNCTION_APPMENU,
278   META_BUTTON_FUNCTION_MINIMIZE,
279   META_BUTTON_FUNCTION_MAXIMIZE,
280   META_BUTTON_FUNCTION_CLOSE,
281   META_BUTTON_FUNCTION_SHADE,
282   META_BUTTON_FUNCTION_ABOVE,
283   META_BUTTON_FUNCTION_STICK,
284   META_BUTTON_FUNCTION_UNSHADE,
285   META_BUTTON_FUNCTION_UNABOVE,
286   META_BUTTON_FUNCTION_UNSTICK,
287   META_BUTTON_FUNCTION_LAST
288 } MetaButtonFunction;
289 
290 #define MAX_BUTTONS_PER_CORNER META_BUTTON_FUNCTION_LAST
291 
292 typedef struct _MetaButtonLayout MetaButtonLayout;
293 struct _MetaButtonLayout
294 {
295   /* buttons in the group on the left side */
296   MetaButtonFunction left_buttons[MAX_BUTTONS_PER_CORNER];
297   gboolean left_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
298 
299   /* buttons in the group on the right side */
300   MetaButtonFunction right_buttons[MAX_BUTTONS_PER_CORNER];
301   gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
302 };
303 
304 typedef struct _MetaFrameBorders MetaFrameBorders;
305 struct _MetaFrameBorders
306 {
307   /* The frame border is made up of two pieces - an inner visible portion
308    * and an outer portion that is invisible but responds to events.
309    */
310   GtkBorder visible;
311   GtkBorder invisible;
312 
313   /* For convenience, we have a "total" border which is equal to the sum
314    * of the two borders above. */
315   GtkBorder total;
316 };
317 
318 /* sets all dimensions to zero */
319 void meta_frame_borders_clear (MetaFrameBorders *self);
320 
321 /* should investigate changing these to whatever most apps use */
322 #define META_DEFAULT_ICON_SIZE 48
323 #define META_MIN_ICON_SIZE 8
324 #define META_MAX_ICON_SIZE 256
325 
326 #define META_MINI_ICON_WIDTH 16
327 #define META_MINI_ICON_HEIGHT 16
328 
329 #define META_DEFAULT_ICON_NAME "preferences-desktop-theme"
330 
331 #define META_PRIORITY_PREFS_NOTIFY   (G_PRIORITY_DEFAULT_IDLE + 10)
332 #define META_PRIORITY_WORK_AREA_HINT (G_PRIORITY_DEFAULT_IDLE + 15)
333 
334 #define POINT_IN_RECT(xcoord, ycoord, rect) \
335  ((xcoord) >= (rect).x &&                   \
336   (xcoord) <  ((rect).x + (rect).width) &&  \
337   (ycoord) >= (rect).y &&                   \
338   (ycoord) <  ((rect).y + (rect).height))
339 
340 /*
341  * Placement mode
342  */
343 typedef enum
344 {
345   META_PLACEMENT_MODE_AUTOMATIC,
346   META_PLACEMENT_MODE_POINTER,
347   META_PLACEMENT_MODE_MANUAL
348 } MetaPlacementMode;
349 
350 #define META_DEFAULT_ALT_TAB_MAX_COLUMNS 5
351 #define META_MIN_ALT_TAB_MAX_COLUMNS 1
352 #define META_MAX_ALT_TAB_MAX_COLUMNS 64
353 
354 #define META_DEFAULT_ALT_TAB_EXPAND_TO_FIT_TITLE FALSE
355 
356 #endif
357