summaryrefslogtreecommitdiff
path: root/src/core/xprops.h
blob: 241557ff7a84cd3bcb089c1112dd70f00f8d4058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */

/* Mutter X property convenience routines */

/* 
 * Copyright (C) 2001 Havoc Pennington
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef META_XPROPS_H
#define META_XPROPS_H

#include <config.h>

#include <meta/display.h>
#include <X11/Xutil.h>

#ifdef HAVE_XSYNC
#include <X11/extensions/sync.h>
#endif

/* Copied from Lesstif by way of GTK. Rudimentary docs can be
 * found in some Motif reference guides online.
 */
typedef struct {
    unsigned long flags;
    unsigned long functions;
    unsigned long decorations;
    long input_mode;
    unsigned long status;
} MotifWmHints, MwmHints;

#define MWM_HINTS_FUNCTIONS     (1L << 0)
#define MWM_HINTS_DECORATIONS   (1L << 1)
#define MWM_HINTS_INPUT_MODE    (1L << 2)
#define MWM_HINTS_STATUS        (1L << 3)

#define MWM_FUNC_ALL            (1L << 0)
#define MWM_FUNC_RESIZE         (1L << 1)
#define MWM_FUNC_MOVE           (1L << 2)
#define MWM_FUNC_MINIMIZE       (1L << 3)
#define MWM_FUNC_MAXIMIZE       (1L << 4)
#define MWM_FUNC_CLOSE          (1L << 5)

#define MWM_DECOR_ALL           (1L << 0)
#define MWM_DECOR_BORDER        (1L << 1)
#define MWM_DECOR_RESIZEH       (1L << 2)
#define MWM_DECOR_TITLE         (1L << 3)
#define MWM_DECOR_MENU          (1L << 4)
#define MWM_DECOR_MINIMIZE      (1L << 5)
#define MWM_DECOR_MAXIMIZE      (1L << 6)

#define MWM_INPUT_MODELESS 0
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
#define MWM_INPUT_SYSTEM_MODAL 2
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL

#define MWM_TEAROFF_WINDOW	(1L<<0)

/* These all return the memory from Xlib, so require an XFree()
 * when they return TRUE. They return TRUE on success.
 */
gboolean meta_prop_get_atom_list     (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      Atom         **atoms_p,
                                      int           *n_atoms_p);
gboolean meta_prop_get_motif_hints   (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      MotifWmHints **hints_p);
gboolean meta_prop_get_cardinal_list (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      gulong       **cardinals_p,
                                      int           *n_cardinals_p);
gboolean meta_prop_get_latin1_string (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      char         **str_p);
gboolean meta_prop_get_utf8_string   (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      char         **str_p);
gboolean meta_prop_get_utf8_list     (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      char        ***str_p,
                                      int           *n_str_p);
gboolean meta_prop_get_latin1_list   (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      char        ***str_p,
                                      int           *n_str_p);
void     meta_prop_set_utf8_string_hint
                                     (MetaDisplay *display,
                                      Window xwindow,
                                      Atom atom,
                                      const char *val);
gboolean meta_prop_get_window        (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      Window        *window_p);
gboolean meta_prop_get_cardinal      (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      gulong        *cardinal_p);
gboolean meta_prop_get_cardinal_with_atom_type (MetaDisplay   *display,
                                                Window         xwindow,
                                                Atom           xatom,
                                                Atom           prop_type,
                                                gulong        *cardinal_p);
gboolean meta_prop_get_text_property (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      char         **utf8_str_p);

gboolean meta_prop_get_wm_hints      (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      XWMHints     **hints_p);

gboolean meta_prop_get_class_hint    (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      XClassHint    *class_hint);

gboolean meta_prop_get_size_hints    (MetaDisplay   *display,
                                      Window         xwindow,
                                      Atom           xatom,
                                      XSizeHints   **hints_p,
                                      gulong        *flags_p);

typedef enum
{
  META_PROP_VALUE_INVALID,
  META_PROP_VALUE_UTF8,
  META_PROP_VALUE_STRING,
  META_PROP_VALUE_STRING_AS_UTF8,
  META_PROP_VALUE_MOTIF_HINTS,
  META_PROP_VALUE_CARDINAL,
  META_PROP_VALUE_WINDOW,
  META_PROP_VALUE_CARDINAL_LIST,
  META_PROP_VALUE_UTF8_LIST,
  META_PROP_VALUE_ATOM_LIST,
  META_PROP_VALUE_TEXT_PROPERTY, /* comes back as UTF-8 string */
  META_PROP_VALUE_WM_HINTS,
  META_PROP_VALUE_CLASS_HINT,
  META_PROP_VALUE_SIZE_HINTS,
  META_PROP_VALUE_SYNC_COUNTER,     /* comes back as CARDINAL */
  META_PROP_VALUE_SYNC_COUNTER_LIST /* comes back as CARDINAL */
} MetaPropValueType;

/* used to request/return/store property values */
typedef struct
{
  MetaPropValueType type;
  Atom atom;
  Atom required_type; /* autofilled if None */
  
  union
  {
    char *str;
    MotifWmHints *motif_hints;
    Window xwindow;
    gulong cardinal;
    XWMHints *wm_hints;
    XClassHint class_hint;
#ifdef HAVE_XSYNC
    XSyncCounter xcounter;
    struct
    {
      gulong *counters;
      int     n_counters;
    } xcounter_list;
#endif
    
    struct
    {
      XSizeHints   *hints;
      unsigned long flags;
    } size_hints;
    
    struct
    {
      gulong *cardinals;
      int     n_cardinals;
    } cardinal_list;

    struct
    {
      char **strings;
      int    n_strings;
    } string_list;

    struct
    {
      Atom *atoms;
      int   n_atoms;
    } atom_list;
    
  } v;

} MetaPropValue;

/* Each value has type and atom initialized. If there's an error,
 * or property is unset, type comes back as INVALID;
 * else type comes back as it originated, and the data
 * is filled in.
 */
void meta_prop_get_values (MetaDisplay   *display,
                           Window         xwindow,
                           MetaPropValue *values,
                           int            n_values);

void meta_prop_free_values (MetaPropValue *values,
                            int            n_values);

#endif