64
64
MetaPropValue *value,
67
typedef struct MetaWindowPropHooks
71
FORCE_INIT = (1 << 2),
74
struct _MetaWindowPropHooks {
70
76
MetaPropValueType type;
71
77
ReloadValueFunc reload_func;
72
} MetaWindowPropHooks;
78
MetaPropHookFlags flags;
81
static void init_prop_value (MetaWindow *window,
82
MetaWindowPropHooks *hooks,
83
MetaPropValue *value);
84
static void reload_prop_value (MetaWindow *window,
85
MetaWindowPropHooks *hooks,
74
88
static MetaWindowPropHooks* find_hooks (MetaDisplay *display,
79
meta_window_reload_property (MetaWindow *window,
83
meta_window_reload_properties (window, &property, 1, initial);
87
meta_window_reload_properties (MetaWindow *window,
88
const Atom *properties,
92
meta_window_reload_properties_from_xwindow (window,
100
92
meta_window_reload_property_from_xwindow (MetaWindow *window,
105
meta_window_reload_properties_from_xwindow (window, xwindow, &property, 1,
110
meta_window_reload_properties_from_xwindow (MetaWindow *window,
112
const Atom *properties,
97
MetaPropValue value = { 0, };
98
MetaWindowPropHooks *hooks;
100
hooks = find_hooks (window->display, property);
104
init_prop_value (window, hooks, &value);
106
meta_prop_get_values (window->display, xwindow,
109
reload_prop_value (window, hooks, &value,
112
meta_prop_free_values (&value, 1);
116
meta_window_reload_property (MetaWindow *window,
120
meta_window_reload_property_from_xwindow (window,
127
meta_window_load_initial_properties (MetaWindow *window)
117
130
MetaPropValue *values;
119
g_return_if_fail (properties != NULL);
120
g_return_if_fail (n_properties > 0);
122
values = g_new0 (MetaPropValue, n_properties);
124
for (i=0; i<n_properties; i++)
131
int n_properties = 0;
133
values = g_new0 (MetaPropValue, window->display->n_prop_hooks);
136
for (i = 0; i < window->display->n_prop_hooks; i++)
126
MetaWindowPropHooks *hooks = find_hooks (window->display,
129
if (!hooks || hooks->type == META_PROP_VALUE_INVALID)
131
values[i].type = META_PROP_VALUE_INVALID;
132
values[i].atom = None;
136
values[i].type = hooks->type;
137
values[i].atom = properties[i];
138
MetaWindowPropHooks *hooks = &window->display->prop_hooks_table[i];
139
if (hooks->flags & LOAD_INIT)
141
init_prop_value (window, hooks, &values[j]);
141
meta_prop_get_values (window->display, xwindow,
147
meta_prop_get_values (window->display, window->xwindow,
142
148
values, n_properties);
144
for (i=0; i<n_properties; i++)
151
for (i = 0; i < window->display->n_prop_hooks; i++)
146
MetaWindowPropHooks *hooks = find_hooks (window->display,
149
if (hooks && hooks->reload_func != NULL)
150
(* hooks->reload_func) (window, &values[i], initial);
153
MetaWindowPropHooks *hooks = &window->display->prop_hooks_table[i];
154
if (hooks->flags & LOAD_INIT)
156
/* If we didn't actually manage to load anything then we don't need
157
* to call the reload function; this is different from a notification
158
* where disappearance of a previously present value is significant.
160
if (values[j].type != META_PROP_VALUE_INVALID || hooks->flags & FORCE_INIT)
161
reload_prop_value (window, hooks, &values[j], TRUE);
153
166
meta_prop_free_values (values, n_properties);
171
/* Fill in the MetaPropValue used to get the value of "property" */
173
init_prop_value (MetaWindow *window,
174
MetaWindowPropHooks *hooks,
175
MetaPropValue *value)
177
if (!hooks || hooks->type == META_PROP_VALUE_INVALID)
179
value->type = META_PROP_VALUE_INVALID;
184
value->type = hooks->type;
185
value->atom = hooks->property;
190
reload_prop_value (MetaWindow *window,
191
MetaWindowPropHooks *hooks,
192
MetaPropValue *value,
195
if (hooks && hooks->reload_func != NULL)
196
(* hooks->reload_func) (window, value, initial);
159
200
reload_wm_client_machine (MetaWindow *window,
160
201
MetaPropValue *value,
184
225
MetaPropValue *value,
185
226
gboolean initial)
187
meta_window_update_net_wm_type (window);
232
window->type_atom = None;
236
meta_prop_get_atom_list (window->display, window->xwindow,
237
window->display->atom__NET_WM_WINDOW_TYPE,
243
/* We break as soon as we find one we recognize,
244
* supposed to prefer those near the front of the list
246
if (atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_DESKTOP ||
247
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_DOCK ||
248
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_TOOLBAR ||
249
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_MENU ||
250
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_DIALOG ||
251
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_NORMAL ||
252
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_UTILITY ||
253
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_SPLASH)
255
window->type_atom = atoms[i];
264
if (meta_is_verbose ())
269
if (window->type_atom != None)
271
meta_error_trap_push (window->display);
272
str = XGetAtomName (window->display->xdisplay, window->type_atom);
273
meta_error_trap_pop (window->display, TRUE);
276
meta_verbose ("Window %s type atom %s\n", window->desc,
277
str ? str : "(none)");
283
meta_window_recalc_window_type (window);
213
309
reload_icon (window, window->display->atom__KWM_WIN_ICON);
313
gtk_border_equal (GtkBorder *a,
316
return (a->left == b->left &&
317
a->right == b->right &&
319
a->bottom == b->bottom);
323
meta_window_set_custom_frame_extents (MetaWindow *window,
328
if (window->has_custom_frame_extents && gtk_border_equal (&window->custom_frame_extents, extents))
331
window->has_custom_frame_extents = TRUE;
332
window->custom_frame_extents = *extents;
336
if (!window->has_custom_frame_extents)
339
window->has_custom_frame_extents = FALSE;
340
memset (&window->custom_frame_extents, 0, sizeof (window->custom_frame_extents));
343
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
347
reload_gtk_frame_extents (MetaWindow *window,
348
MetaPropValue *value,
351
if (value->type != META_PROP_VALUE_INVALID)
353
if (value->v.cardinal_list.n_cardinals != 4)
355
meta_verbose ("_GTK_FRAME_EXTENTS on %s has %d values instead of 4\n",
356
window->desc, value->v.cardinal_list.n_cardinals);
361
extents.left = (int)value->v.cardinal_list.cardinals[0];
362
extents.right = (int)value->v.cardinal_list.cardinals[1];
363
extents.top = (int)value->v.cardinal_list.cardinals[2];
364
extents.bottom = (int)value->v.cardinal_list.cardinals[3];
365
meta_window_set_custom_frame_extents (window, &extents);
370
meta_window_set_custom_frame_extents (window, NULL);
217
375
reload_struts (MetaWindow *window,
218
376
MetaPropValue *value,
1484
1671
meta_display_init_window_prop_hooks (MetaDisplay *display)
1486
1673
MetaWindowPropHooks hooks[] = {
1487
{ display->atom_WM_STATE, META_PROP_VALUE_INVALID, NULL },
1488
{ display->atom_WM_CLIENT_MACHINE, META_PROP_VALUE_STRING, reload_wm_client_machine },
1489
{ display->atom__NET_WM_PID, META_PROP_VALUE_CARDINAL, reload_net_wm_pid },
1490
{ display->atom__NET_WM_USER_TIME, META_PROP_VALUE_CARDINAL, reload_net_wm_user_time },
1491
{ display->atom__NET_WM_NAME, META_PROP_VALUE_UTF8, reload_net_wm_name },
1492
{ XA_WM_NAME, META_PROP_VALUE_TEXT_PROPERTY, reload_wm_name },
1493
{ display->atom__NET_WM_ICON, META_PROP_VALUE_INVALID, reload_net_wm_icon },
1494
{ display->atom__KWM_WIN_ICON, META_PROP_VALUE_INVALID, reload_kwm_win_icon },
1495
{ display->atom__NET_WM_ICON_NAME, META_PROP_VALUE_UTF8, reload_net_wm_icon_name },
1496
{ XA_WM_ICON_NAME, META_PROP_VALUE_TEXT_PROPERTY, reload_wm_icon_name },
1497
{ display->atom__NET_WM_STATE, META_PROP_VALUE_ATOM_LIST, reload_net_wm_state },
1498
{ display->atom__MOTIF_WM_HINTS, META_PROP_VALUE_MOTIF_HINTS, reload_mwm_hints },
1499
{ display->atom__NET_WM_ICON_GEOMETRY, META_PROP_VALUE_INVALID, NULL },
1500
{ XA_WM_CLASS, META_PROP_VALUE_CLASS_HINT, reload_wm_class },
1501
{ display->atom_WM_CLIENT_LEADER, META_PROP_VALUE_INVALID, complain_about_broken_client },
1502
{ display->atom_SM_CLIENT_ID, META_PROP_VALUE_INVALID, complain_about_broken_client },
1503
{ display->atom_WM_WINDOW_ROLE, META_PROP_VALUE_INVALID, reload_wm_window_role },
1504
{ display->atom__NET_WM_WINDOW_TYPE, META_PROP_VALUE_INVALID, reload_net_wm_window_type },
1505
{ display->atom__NET_WM_DESKTOP, META_PROP_VALUE_CARDINAL, reload_net_wm_desktop },
1506
{ display->atom__NET_WM_STRUT, META_PROP_VALUE_INVALID, reload_struts },
1507
{ display->atom__NET_WM_STRUT_PARTIAL, META_PROP_VALUE_INVALID, reload_struts },
1508
{ display->atom__NET_STARTUP_ID, META_PROP_VALUE_UTF8, reload_net_startup_id },
1509
{ display->atom__NET_WM_SYNC_REQUEST_COUNTER, META_PROP_VALUE_SYNC_COUNTER, reload_update_counter },
1510
{ XA_WM_NORMAL_HINTS, META_PROP_VALUE_SIZE_HINTS, reload_normal_hints },
1511
{ display->atom_WM_PROTOCOLS, META_PROP_VALUE_ATOM_LIST, reload_wm_protocols },
1512
{ XA_WM_HINTS, META_PROP_VALUE_WM_HINTS, reload_wm_hints },
1513
{ XA_WM_TRANSIENT_FOR, META_PROP_VALUE_WINDOW, reload_transient_for },
1514
{ display->atom__NET_WM_USER_TIME_WINDOW, META_PROP_VALUE_WINDOW, reload_net_wm_user_time_window },
1675
display->atom_WM_CLIENT_MACHINE,
1676
META_PROP_VALUE_STRING,
1677
reload_wm_client_machine,
1681
display->atom__NET_WM_NAME,
1682
META_PROP_VALUE_UTF8,
1688
META_PROP_VALUE_CLASS_HINT,
1693
display->atom__NET_WM_PID,
1694
META_PROP_VALUE_CARDINAL,
1700
META_PROP_VALUE_TEXT_PROPERTY,
1705
display->atom__NET_WM_ICON_NAME,
1706
META_PROP_VALUE_UTF8,
1707
reload_net_wm_icon_name,
1712
META_PROP_VALUE_TEXT_PROPERTY,
1713
reload_wm_icon_name,
1717
display->atom__NET_WM_DESKTOP,
1718
META_PROP_VALUE_CARDINAL,
1719
reload_net_wm_desktop,
1720
LOAD_INIT | INIT_ONLY
1723
display->atom__NET_STARTUP_ID,
1724
META_PROP_VALUE_UTF8,
1725
reload_net_startup_id,
1729
display->atom__NET_WM_SYNC_REQUEST_COUNTER,
1730
META_PROP_VALUE_SYNC_COUNTER,
1731
reload_update_counter,
1736
META_PROP_VALUE_SIZE_HINTS,
1737
reload_normal_hints,
1741
display->atom_WM_PROTOCOLS,
1742
META_PROP_VALUE_ATOM_LIST,
1743
reload_wm_protocols,
1748
META_PROP_VALUE_WM_HINTS,
1753
display->atom__NET_WM_USER_TIME,
1754
META_PROP_VALUE_CARDINAL,
1755
reload_net_wm_user_time,
1759
display->atom__NET_WM_STATE,
1760
META_PROP_VALUE_ATOM_LIST,
1761
reload_net_wm_state,
1762
LOAD_INIT | INIT_ONLY
1765
display->atom__MOTIF_WM_HINTS,
1766
META_PROP_VALUE_MOTIF_HINTS,
1771
XA_WM_TRANSIENT_FOR,
1772
META_PROP_VALUE_WINDOW,
1773
reload_transient_for,
1777
display->atom__GTK_THEME_VARIANT,
1778
META_PROP_VALUE_UTF8,
1779
reload_gtk_theme_variant,
1783
display->atom__GTK_FRAME_EXTENTS,
1784
META_PROP_VALUE_CARDINAL_LIST,
1785
reload_gtk_frame_extents,
1789
display->atom__NET_WM_USER_TIME_WINDOW,
1790
META_PROP_VALUE_WINDOW,
1791
reload_net_wm_user_time_window,
1795
display->atom_WM_STATE,
1796
META_PROP_VALUE_INVALID,
1801
display->atom__NET_WM_ICON,
1802
META_PROP_VALUE_INVALID,
1807
display->atom__KWM_WIN_ICON,
1808
META_PROP_VALUE_INVALID,
1809
reload_kwm_win_icon,
1813
display->atom_WM_CLIENT_LEADER,
1814
META_PROP_VALUE_INVALID,
1815
complain_about_broken_client,
1819
display->atom_SM_CLIENT_ID,
1820
META_PROP_VALUE_INVALID,
1821
complain_about_broken_client,
1825
display->atom_WM_WINDOW_ROLE,
1826
META_PROP_VALUE_STRING,
1827
reload_wm_window_role,
1828
LOAD_INIT | FORCE_INIT
1831
display->atom__NET_WM_WINDOW_TYPE,
1832
META_PROP_VALUE_ATOM_LIST,
1833
reload_net_wm_window_type,
1834
LOAD_INIT | FORCE_INIT
1837
display->atom__NET_WM_STRUT,
1838
META_PROP_VALUE_INVALID,
1843
display->atom__NET_WM_STRUT_PARTIAL,
1844
META_PROP_VALUE_INVALID,
1518
1853
MetaWindowPropHooks *table = g_memdup (hooks, sizeof (hooks)),