common.h

Go to the documentation of this file.
00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
00002 
00003 /* Metacity common types shared by core.h and ui.h */
00004 
00005 /* 
00006  * Copyright (C) 2001 Havoc Pennington
00007  * Copyright (C) 2005 Elijah Newren
00008  * 
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License as
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00022  * 02111-1307, USA.
00023  */
00024 
00025 #ifndef META_COMMON_H
00026 #define META_COMMON_H
00027 
00028 /* Don't include GTK or core headers here */
00029 #include <X11/Xlib.h>
00030 #include <glib.h>
00031 
00032 typedef struct _MetaResizePopup MetaResizePopup;
00033 
00034 typedef enum
00035 {
00036   META_FRAME_ALLOWS_DELETE            = 1 << 0,
00037   META_FRAME_ALLOWS_MENU              = 1 << 1,
00038   META_FRAME_ALLOWS_MINIMIZE          = 1 << 2,
00039   META_FRAME_ALLOWS_MAXIMIZE          = 1 << 3,
00040   META_FRAME_ALLOWS_VERTICAL_RESIZE   = 1 << 4,
00041   META_FRAME_ALLOWS_HORIZONTAL_RESIZE = 1 << 5,
00042   META_FRAME_HAS_FOCUS                = 1 << 6,
00043   META_FRAME_SHADED                   = 1 << 7,
00044   META_FRAME_STUCK                    = 1 << 8,
00045   META_FRAME_MAXIMIZED                = 1 << 9,
00046   META_FRAME_ALLOWS_SHADE             = 1 << 10,
00047   META_FRAME_ALLOWS_MOVE              = 1 << 11,
00048   META_FRAME_FULLSCREEN               = 1 << 12,
00049   META_FRAME_IS_FLASHING              = 1 << 13,
00050   META_FRAME_ABOVE                    = 1 << 14
00051 } MetaFrameFlags;
00052 
00053 typedef enum
00054 {
00055   META_MENU_OP_DELETE      = 1 << 0,
00056   META_MENU_OP_MINIMIZE    = 1 << 1,
00057   META_MENU_OP_UNMAXIMIZE  = 1 << 2,
00058   META_MENU_OP_MAXIMIZE    = 1 << 3,
00059   META_MENU_OP_UNSHADE     = 1 << 4,
00060   META_MENU_OP_SHADE       = 1 << 5,
00061   META_MENU_OP_UNSTICK     = 1 << 6,
00062   META_MENU_OP_STICK       = 1 << 7,
00063   META_MENU_OP_WORKSPACES  = 1 << 8,
00064   META_MENU_OP_MOVE        = 1 << 9,
00065   META_MENU_OP_RESIZE      = 1 << 10,
00066   META_MENU_OP_ABOVE       = 1 << 11,
00067   META_MENU_OP_UNABOVE     = 1 << 12,
00068   META_MENU_OP_MOVE_LEFT   = 1 << 13,
00069   META_MENU_OP_MOVE_RIGHT  = 1 << 14,
00070   META_MENU_OP_MOVE_UP     = 1 << 15,
00071   META_MENU_OP_MOVE_DOWN   = 1 << 16,
00072   META_MENU_OP_RECOVER     = 1 << 17
00073 } MetaMenuOp;
00074 
00075 typedef struct _MetaWindowMenu MetaWindowMenu;
00076 
00077 typedef void (* MetaWindowMenuFunc) (MetaWindowMenu *menu,
00078                                      Display        *xdisplay,
00079                                      Window          client_xwindow,
00080                                      guint32         timestamp,
00081                                      MetaMenuOp      op,
00082                                      int             workspace,
00083                                      gpointer        data);
00084 
00085 /* when changing this enum, there are various switch statements
00086  * you have to update
00087  */
00088 typedef enum
00089 {
00090   META_GRAB_OP_NONE,
00091 
00092   /* Mouse ops */
00093   META_GRAB_OP_MOVING,
00094   META_GRAB_OP_RESIZING_SE,
00095   META_GRAB_OP_RESIZING_S,
00096   META_GRAB_OP_RESIZING_SW,
00097   META_GRAB_OP_RESIZING_N,
00098   META_GRAB_OP_RESIZING_NE,
00099   META_GRAB_OP_RESIZING_NW,
00100   META_GRAB_OP_RESIZING_W,
00101   META_GRAB_OP_RESIZING_E,
00102 
00103   /* Keyboard ops */
00104   META_GRAB_OP_KEYBOARD_MOVING,
00105   META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN,
00106   META_GRAB_OP_KEYBOARD_RESIZING_S,
00107   META_GRAB_OP_KEYBOARD_RESIZING_N,
00108   META_GRAB_OP_KEYBOARD_RESIZING_W,
00109   META_GRAB_OP_KEYBOARD_RESIZING_E,
00110   META_GRAB_OP_KEYBOARD_RESIZING_SE,
00111   META_GRAB_OP_KEYBOARD_RESIZING_NE,
00112   META_GRAB_OP_KEYBOARD_RESIZING_SW,
00113   META_GRAB_OP_KEYBOARD_RESIZING_NW,
00114 
00115   /* Alt+Tab */
00116   META_GRAB_OP_KEYBOARD_TABBING_NORMAL,
00117   META_GRAB_OP_KEYBOARD_TABBING_DOCK,
00118 
00119   /* Alt+Esc */
00120   META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL,
00121   META_GRAB_OP_KEYBOARD_ESCAPING_DOCK,
00122 
00123   META_GRAB_OP_KEYBOARD_ESCAPING_GROUP,
00124   
00125   /* Alt+F6 */
00126   META_GRAB_OP_KEYBOARD_TABBING_GROUP,
00127   
00128   META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING,
00129   
00130   /* Frame button ops */
00131   META_GRAB_OP_CLICKING_MINIMIZE,
00132   META_GRAB_OP_CLICKING_MAXIMIZE,
00133   META_GRAB_OP_CLICKING_UNMAXIMIZE,
00134   META_GRAB_OP_CLICKING_DELETE,
00135   META_GRAB_OP_CLICKING_MENU,
00136   META_GRAB_OP_CLICKING_SHADE,
00137   META_GRAB_OP_CLICKING_UNSHADE,
00138   META_GRAB_OP_CLICKING_ABOVE,
00139   META_GRAB_OP_CLICKING_UNABOVE,
00140   META_GRAB_OP_CLICKING_STICK,
00141   META_GRAB_OP_CLICKING_UNSTICK
00142 } MetaGrabOp;
00143 
00144 typedef enum
00145 {
00146   META_CURSOR_DEFAULT,
00147   META_CURSOR_NORTH_RESIZE,
00148   META_CURSOR_SOUTH_RESIZE,
00149   META_CURSOR_WEST_RESIZE,
00150   META_CURSOR_EAST_RESIZE,
00151   META_CURSOR_SE_RESIZE,
00152   META_CURSOR_SW_RESIZE,
00153   META_CURSOR_NE_RESIZE,
00154   META_CURSOR_NW_RESIZE,
00155   META_CURSOR_MOVE_OR_RESIZE_WINDOW,
00156   META_CURSOR_BUSY
00157 
00158 } MetaCursor;
00159 
00160 typedef enum
00161 {
00162   META_FOCUS_MODE_CLICK,
00163   META_FOCUS_MODE_SLOPPY,
00164   META_FOCUS_MODE_MOUSE
00165 } MetaFocusMode;
00166 
00167 typedef enum
00168 {
00169   META_FOCUS_NEW_WINDOWS_SMART,
00170   META_FOCUS_NEW_WINDOWS_STRICT
00171 } MetaFocusNewWindows;
00172 
00173 typedef enum
00174 {
00175   META_ACTION_TITLEBAR_TOGGLE_SHADE,
00176   META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE,
00177   META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY,
00178   META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY,
00179   META_ACTION_TITLEBAR_MINIMIZE,
00180   META_ACTION_TITLEBAR_NONE,
00181   META_ACTION_TITLEBAR_LOWER,
00182   META_ACTION_TITLEBAR_MENU,
00183   META_ACTION_TITLEBAR_LAST
00184 } MetaActionTitlebar;
00185 
00186 typedef enum
00187 {
00188   META_FRAME_TYPE_NORMAL,
00189   META_FRAME_TYPE_DIALOG,
00190   META_FRAME_TYPE_MODAL_DIALOG,
00191   META_FRAME_TYPE_UTILITY,
00192   META_FRAME_TYPE_MENU,
00193   META_FRAME_TYPE_BORDER,
00194   META_FRAME_TYPE_LAST
00195 } MetaFrameType;
00196 
00197 typedef enum
00198 {
00199   /* Create gratuitous divergence from regular
00200    * X mod bits, to be sure we find bugs
00201    */
00202   META_VIRTUAL_SHIFT_MASK    = 1 << 5,
00203   META_VIRTUAL_CONTROL_MASK  = 1 << 6,
00204   META_VIRTUAL_ALT_MASK      = 1 << 7,  
00205   META_VIRTUAL_META_MASK     = 1 << 8,
00206   META_VIRTUAL_SUPER_MASK    = 1 << 9,
00207   META_VIRTUAL_HYPER_MASK    = 1 << 10,
00208   META_VIRTUAL_MOD2_MASK     = 1 << 11,
00209   META_VIRTUAL_MOD3_MASK     = 1 << 12,
00210   META_VIRTUAL_MOD4_MASK     = 1 << 13,
00211   META_VIRTUAL_MOD5_MASK     = 1 << 14
00212 } MetaVirtualModifier;
00213 
00214 /* Relative directions or sides seem to come up all over the place... */
00215 /* FIXME: Replace
00216  *   screen.[ch]:MetaScreenDirection,
00217  *   workspace.[ch]:MetaMotionDirection,
00218  * with the use of MetaDirection.
00219  */
00220 typedef enum
00221 {
00222   META_DIRECTION_LEFT       = 1 << 0,
00223   META_DIRECTION_RIGHT      = 1 << 1,
00224   META_DIRECTION_TOP        = 1 << 2,
00225   META_DIRECTION_BOTTOM     = 1 << 3,
00226 
00227   /* Some aliases for making code more readable for various circumstances. */
00228   META_DIRECTION_UP         = META_DIRECTION_TOP,
00229   META_DIRECTION_DOWN       = META_DIRECTION_BOTTOM,
00230 
00231   /* A few more definitions using aliases */
00232   META_DIRECTION_HORIZONTAL = META_DIRECTION_LEFT | META_DIRECTION_RIGHT,
00233   META_DIRECTION_VERTICAL   = META_DIRECTION_UP   | META_DIRECTION_DOWN,
00234 
00235   /* And a few more aliases */
00236   META_SIDE_LEFT            = META_DIRECTION_LEFT,
00237   META_SIDE_RIGHT           = META_DIRECTION_RIGHT,
00238   META_SIDE_TOP             = META_DIRECTION_TOP,
00239   META_SIDE_BOTTOM          = META_DIRECTION_BOTTOM
00240 } MetaDirection;
00241 
00242 /* Function a window button can have.  Note, you can't add stuff here
00243  * without extending the theme format to draw a new function and
00244  * breaking all existing themes.
00245  */
00246 typedef enum
00247 {
00248   META_BUTTON_FUNCTION_MENU,
00249   META_BUTTON_FUNCTION_MINIMIZE,
00250   META_BUTTON_FUNCTION_MAXIMIZE,
00251   META_BUTTON_FUNCTION_CLOSE,
00252   META_BUTTON_FUNCTION_SHADE,
00253   META_BUTTON_FUNCTION_ABOVE,
00254   META_BUTTON_FUNCTION_STICK,
00255   META_BUTTON_FUNCTION_UNSHADE,
00256   META_BUTTON_FUNCTION_UNABOVE,
00257   META_BUTTON_FUNCTION_UNSTICK,
00258   META_BUTTON_FUNCTION_LAST
00259 } MetaButtonFunction;
00260 
00261 #define MAX_BUTTONS_PER_CORNER META_BUTTON_FUNCTION_LAST
00262 
00263 typedef struct _MetaButtonLayout MetaButtonLayout;
00264 struct _MetaButtonLayout
00265 {
00266   /* buttons in the group on the left side */
00267   MetaButtonFunction left_buttons[MAX_BUTTONS_PER_CORNER];
00268   gboolean left_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
00269 
00270   /* buttons in the group on the right side */
00271   MetaButtonFunction right_buttons[MAX_BUTTONS_PER_CORNER];
00272   gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
00273 };
00274 
00275 /* should investigate changing these to whatever most apps use */
00276 #define META_ICON_WIDTH 32
00277 #define META_ICON_HEIGHT 32
00278 #define META_MINI_ICON_WIDTH 16
00279 #define META_MINI_ICON_HEIGHT 16
00280 
00281 #define META_DEFAULT_ICON_NAME "window"
00282 
00283 #define META_PRIORITY_PREFS_NOTIFY   (G_PRIORITY_DEFAULT_IDLE + 10)
00284 #define META_PRIORITY_WORK_AREA_HINT (G_PRIORITY_DEFAULT_IDLE + 15)
00285 
00286 #define POINT_IN_RECT(xcoord, ycoord, rect) \
00287  ((xcoord) >= (rect).x &&                   \
00288   (xcoord) <  ((rect).x + (rect).width) &&  \
00289   (ycoord) >= (rect).y &&                   \
00290   (ycoord) <  ((rect).y + (rect).height))
00291 
00292 #endif

Generated on Sat Aug 23 22:04:18 2008 for metacity by  doxygen 1.5.5