xprops.h

Go to the documentation of this file.
00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
00002 
00003 /* Metacity X property convenience routines */
00004 
00005 /* 
00006  * Copyright (C) 2001 Havoc Pennington
00007  * 
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License as
00010  * published by the Free Software Foundation; either version 2 of the
00011  * License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00021  * 02111-1307, USA.
00022  */
00023 
00024 #ifndef META_XPROPS_H
00025 #define META_XPROPS_H
00026 
00027 #include <config.h>
00028 
00029 #include "display.h"
00030 #include <X11/Xutil.h>
00031 
00032 #ifdef HAVE_XSYNC
00033 #include <X11/extensions/sync.h>
00034 #endif
00035 
00036 /* Copied from Lesstif by way of GTK. Rudimentary docs can be
00037  * found in some Motif reference guides online.
00038  */
00039 typedef struct {
00040     unsigned long flags;
00041     unsigned long functions;
00042     unsigned long decorations;
00043     long input_mode;
00044     unsigned long status;
00045 } MotifWmHints, MwmHints;
00046 
00047 #define MWM_HINTS_FUNCTIONS     (1L << 0)
00048 #define MWM_HINTS_DECORATIONS   (1L << 1)
00049 #define MWM_HINTS_INPUT_MODE    (1L << 2)
00050 #define MWM_HINTS_STATUS        (1L << 3)
00051 
00052 #define MWM_FUNC_ALL            (1L << 0)
00053 #define MWM_FUNC_RESIZE         (1L << 1)
00054 #define MWM_FUNC_MOVE           (1L << 2)
00055 #define MWM_FUNC_MINIMIZE       (1L << 3)
00056 #define MWM_FUNC_MAXIMIZE       (1L << 4)
00057 #define MWM_FUNC_CLOSE          (1L << 5)
00058 
00059 #define MWM_DECOR_ALL           (1L << 0)
00060 #define MWM_DECOR_BORDER        (1L << 1)
00061 #define MWM_DECOR_RESIZEH       (1L << 2)
00062 #define MWM_DECOR_TITLE         (1L << 3)
00063 #define MWM_DECOR_MENU          (1L << 4)
00064 #define MWM_DECOR_MINIMIZE      (1L << 5)
00065 #define MWM_DECOR_MAXIMIZE      (1L << 6)
00066 
00067 #define MWM_INPUT_MODELESS 0
00068 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
00069 #define MWM_INPUT_SYSTEM_MODAL 2
00070 #define MWM_INPUT_FULL_APPLICATION_MODAL 3
00071 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
00072 
00073 #define MWM_TEAROFF_WINDOW      (1L<<0)
00074 
00075 /* These all return the memory from Xlib, so require an XFree()
00076  * when they return TRUE. They return TRUE on success.
00077  */
00078 gboolean meta_prop_get_atom_list     (MetaDisplay   *display,
00079                                       Window         xwindow,
00080                                       Atom           xatom,
00081                                       Atom         **atoms_p,
00082                                       int           *n_atoms_p);
00083 gboolean meta_prop_get_motif_hints   (MetaDisplay   *display,
00084                                       Window         xwindow,
00085                                       Atom           xatom,
00086                                       MotifWmHints **hints_p);
00087 gboolean meta_prop_get_cardinal_list (MetaDisplay   *display,
00088                                       Window         xwindow,
00089                                       Atom           xatom,
00090                                       gulong       **cardinals_p,
00091                                       int           *n_cardinals_p);
00092 gboolean meta_prop_get_latin1_string (MetaDisplay   *display,
00093                                       Window         xwindow,
00094                                       Atom           xatom,
00095                                       char         **str_p);
00096 gboolean meta_prop_get_utf8_string   (MetaDisplay   *display,
00097                                       Window         xwindow,
00098                                       Atom           xatom,
00099                                       char         **str_p);
00100 gboolean meta_prop_get_utf8_list     (MetaDisplay   *display,
00101                                       Window         xwindow,
00102                                       Atom           xatom,
00103                                       char        ***str_p,
00104                                       int           *n_str_p);
00105 void     meta_prop_set_utf8_string_hint
00106                                      (MetaDisplay *display,
00107                                       Window xwindow,
00108                                       Atom atom,
00109                                       const char *val);
00110 gboolean meta_prop_get_window        (MetaDisplay   *display,
00111                                       Window         xwindow,
00112                                       Atom           xatom,
00113                                       Window        *window_p);
00114 gboolean meta_prop_get_cardinal      (MetaDisplay   *display,
00115                                       Window         xwindow,
00116                                       Atom           xatom,
00117                                       gulong        *cardinal_p);
00118 gboolean meta_prop_get_cardinal_with_atom_type (MetaDisplay   *display,
00119                                                 Window         xwindow,
00120                                                 Atom           xatom,
00121                                                 Atom           prop_type,
00122                                                 gulong        *cardinal_p);
00123 gboolean meta_prop_get_text_property (MetaDisplay   *display,
00124                                       Window         xwindow,
00125                                       Atom           xatom,
00126                                       char         **utf8_str_p);
00127 
00128 gboolean meta_prop_get_wm_hints      (MetaDisplay   *display,
00129                                       Window         xwindow,
00130                                       Atom           xatom,
00131                                       XWMHints     **hints_p);
00132 
00133 gboolean meta_prop_get_class_hint    (MetaDisplay   *display,
00134                                       Window         xwindow,
00135                                       Atom           xatom,
00136                                       XClassHint    *class_hint);
00137 
00138 gboolean meta_prop_get_size_hints    (MetaDisplay   *display,
00139                                       Window         xwindow,
00140                                       Atom           xatom,
00141                                       XSizeHints   **hints_p,
00142                                       gulong        *flags_p);
00143 
00144 typedef enum
00145 {
00146   META_PROP_VALUE_INVALID,
00147   META_PROP_VALUE_UTF8,
00148   META_PROP_VALUE_STRING,
00149   META_PROP_VALUE_STRING_AS_UTF8,
00150   META_PROP_VALUE_MOTIF_HINTS,
00151   META_PROP_VALUE_CARDINAL,
00152   META_PROP_VALUE_WINDOW,
00153   META_PROP_VALUE_CARDINAL_LIST,
00154   META_PROP_VALUE_UTF8_LIST,
00155   META_PROP_VALUE_ATOM_LIST,
00156   META_PROP_VALUE_TEXT_PROPERTY, /* comes back as UTF-8 string */
00157   META_PROP_VALUE_WM_HINTS,
00158   META_PROP_VALUE_CLASS_HINT,
00159   META_PROP_VALUE_SIZE_HINTS,
00160   META_PROP_VALUE_SYNC_COUNTER /* comes back as CARDINAL */
00161 } MetaPropValueType;
00162 
00163 /* used to request/return/store property values */
00164 typedef struct
00165 {
00166   MetaPropValueType type;
00167   Atom atom;
00168   Atom required_type; /* autofilled if None */
00169   
00170   union
00171   {
00172     char *str;
00173     MotifWmHints *motif_hints;
00174     Window xwindow;
00175     gulong cardinal;
00176     XWMHints *wm_hints;
00177     XClassHint class_hint;
00178 #ifdef HAVE_XSYNC
00179     XSyncCounter xcounter;
00180 #endif
00181     
00182     struct
00183     {
00184       XSizeHints   *hints;
00185       unsigned long flags;
00186     } size_hints;
00187     
00188     struct
00189     {
00190       gulong *cardinals;
00191       int     n_cardinals;
00192     } cardinal_list;
00193 
00194     struct
00195     {
00196       char **strings;
00197       int    n_strings;
00198     } string_list;
00199 
00200     struct
00201     {
00202       Atom *atoms;
00203       int   n_atoms;
00204     } atom_list;
00205     
00206   } v;
00207 
00208 } MetaPropValue;
00209 
00210 /* Each value has type and atom initialized. If there's an error,
00211  * or property is unset, type comes back as INVALID;
00212  * else type comes back as it originated, and the data
00213  * is filled in.
00214  */
00215 void meta_prop_get_values (MetaDisplay   *display,
00216                            Window         xwindow,
00217                            MetaPropValue *values,
00218                            int            n_values);
00219 
00220 void meta_prop_free_values (MetaPropValue *values,
00221                             int            n_values);
00222 
00223 #endif
00224 
00225 
00226 
00227 

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