~muktupavels/metacity/adwaita-icon-theme-lp-1414613

« back to all changes in this revision

Viewing changes to src/core/window-props.c

  • Committer: Package Import Robot
  • Author(s): Dmitry Shachnev
  • Date: 2014-11-18 18:13:01 UTC
  • mto: (2.3.7 vivid-proposed)
  • mto: This revision was merged to the branch mainline in revision 135.
  • Revision ID: package-import@ubuntu.com-20141118181301-csmd2xaakfjv48r8
Tags: upstream-3.14.2
ImportĀ upstreamĀ versionĀ 3.14.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * together.
15
15
 */
16
16
 
17
 
/* 
 
17
/*
18
18
 * Copyright (C) 2001, 2002, 2003 Red Hat, Inc.
19
19
 * Copyright (C) 2004, 2005 Elijah Newren
20
20
 * Copyright (C) 2009 Thomas Thurman
21
 
 * 
 
21
 *
22
22
 * This program is free software; you can redistribute it and/or
23
23
 * modify it under the terms of the GNU General Public License as
24
24
 * published by the Free Software Foundation; either version 2 of the
28
28
 * WITHOUT ANY WARRANTY; without even the implied warranty of
29
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
30
30
 * General Public License for more details.
31
 
 * 
 
31
 *
32
32
 * You should have received a copy of the GNU General Public License
33
33
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
34
34
 */
64
64
                                  MetaPropValue *value,
65
65
                                  gboolean       initial);
66
66
 
67
 
typedef struct MetaWindowPropHooks
68
 
{
 
67
typedef enum {
 
68
  NONE       = 0,
 
69
  LOAD_INIT  = (1 << 0),
 
70
  INIT_ONLY  = (1 << 1),
 
71
  FORCE_INIT = (1 << 2),
 
72
} MetaPropHookFlags;
 
73
 
 
74
struct _MetaWindowPropHooks {
69
75
  Atom              property;
70
76
  MetaPropValueType type;
71
77
  ReloadValueFunc   reload_func;
72
 
} MetaWindowPropHooks;
 
78
  MetaPropHookFlags flags;
 
79
};
73
80
 
 
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,
 
86
                                        MetaPropValue       *value,
 
87
                                        gboolean             initial);
74
88
static MetaWindowPropHooks* find_hooks (MetaDisplay *display,
75
89
                                        Atom         property);
76
90
 
77
 
 
78
 
void
79
 
meta_window_reload_property (MetaWindow *window,
80
 
                             Atom        property,
81
 
                             gboolean    initial)
82
 
{
83
 
  meta_window_reload_properties (window, &property, 1, initial);
84
 
}
85
 
 
86
 
void
87
 
meta_window_reload_properties (MetaWindow *window,
88
 
                               const Atom *properties,
89
 
                               int         n_properties,
90
 
                               gboolean    initial)
91
 
{
92
 
  meta_window_reload_properties_from_xwindow (window,
93
 
                                              window->xwindow,
94
 
                                              properties,
95
 
                                              n_properties,
96
 
                                              initial);
97
 
}
98
 
 
99
91
void
100
92
meta_window_reload_property_from_xwindow (MetaWindow *window,
101
93
                                          Window      xwindow,
102
94
                                          Atom        property,
103
95
                                          gboolean    initial)
104
96
{
105
 
  meta_window_reload_properties_from_xwindow (window, xwindow, &property, 1,
106
 
                                              initial);
107
 
}
108
 
 
109
 
void
110
 
meta_window_reload_properties_from_xwindow (MetaWindow *window,
111
 
                                            Window      xwindow,
112
 
                                            const Atom *properties,
113
 
                                            int         n_properties,
114
 
                                            gboolean    initial)
115
 
{
116
 
  int i;
 
97
  MetaPropValue value = { 0, };
 
98
  MetaWindowPropHooks *hooks;
 
99
 
 
100
  hooks = find_hooks (window->display, property);
 
101
  if (!hooks)
 
102
    return;
 
103
 
 
104
  init_prop_value (window, hooks, &value);
 
105
 
 
106
  meta_prop_get_values (window->display, xwindow,
 
107
                        &value, 1);
 
108
 
 
109
  reload_prop_value (window, hooks, &value,
 
110
                     initial);
 
111
 
 
112
  meta_prop_free_values (&value, 1);
 
113
}
 
114
 
 
115
void
 
116
meta_window_reload_property (MetaWindow *window,
 
117
                             Atom        property,
 
118
                             gboolean    initial)
 
119
{
 
120
  meta_window_reload_property_from_xwindow (window,
 
121
                                            window->xwindow,
 
122
                                            property,
 
123
                                            initial);
 
124
}
 
125
 
 
126
void
 
127
meta_window_load_initial_properties (MetaWindow *window)
 
128
{
 
129
  int i, j;
117
130
  MetaPropValue *values;
118
 
 
119
 
  g_return_if_fail (properties != NULL);
120
 
  g_return_if_fail (n_properties > 0);
121
 
  
122
 
  values = g_new0 (MetaPropValue, n_properties);
123
 
 
124
 
  for (i=0; i<n_properties; i++)
 
131
  int n_properties = 0;
 
132
 
 
133
  values = g_new0 (MetaPropValue, window->display->n_prop_hooks);
 
134
 
 
135
  j = 0;
 
136
  for (i = 0; i < window->display->n_prop_hooks; i++)
125
137
    {
126
 
      MetaWindowPropHooks *hooks = find_hooks (window->display,
127
 
                                               properties[i]);
128
 
    
129
 
      if (!hooks || hooks->type == META_PROP_VALUE_INVALID)
130
 
        {
131
 
          values[i].type = META_PROP_VALUE_INVALID;
132
 
          values[i].atom = None;
133
 
        }
134
 
      else
135
 
        {
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)
 
140
        {
 
141
          init_prop_value (window, hooks, &values[j]);
 
142
          ++j;
138
143
        }
139
144
    }
140
 
  
141
 
  meta_prop_get_values (window->display, xwindow,
 
145
  n_properties = j;
 
146
 
 
147
  meta_prop_get_values (window->display, window->xwindow,
142
148
                        values, n_properties);
143
149
 
144
 
  for (i=0; i<n_properties; i++)
 
150
  j = 0;
 
151
  for (i = 0; i < window->display->n_prop_hooks; i++)
145
152
    {
146
 
      MetaWindowPropHooks *hooks = find_hooks (window->display,
147
 
                                               properties[i]);
148
 
 
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)
 
155
        {
 
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.
 
159
           */
 
160
          if (values[j].type != META_PROP_VALUE_INVALID || hooks->flags & FORCE_INIT)
 
161
            reload_prop_value (window, hooks, &values[j], TRUE);
 
162
          ++j;
 
163
        }
151
164
    }
152
165
 
153
166
  meta_prop_free_values (values, n_properties);
154
 
  
 
167
 
155
168
  g_free (values);
156
169
}
157
170
 
 
171
/* Fill in the MetaPropValue used to get the value of "property" */
 
172
static void
 
173
init_prop_value (MetaWindow          *window,
 
174
                 MetaWindowPropHooks *hooks,
 
175
                 MetaPropValue       *value)
 
176
{
 
177
  if (!hooks || hooks->type == META_PROP_VALUE_INVALID)
 
178
    {
 
179
      value->type = META_PROP_VALUE_INVALID;
 
180
      value->atom = None;
 
181
    }
 
182
  else
 
183
    {
 
184
      value->type = hooks->type;
 
185
      value->atom = hooks->property;
 
186
    }
 
187
}
 
188
 
 
189
static void
 
190
reload_prop_value (MetaWindow          *window,
 
191
                   MetaWindowPropHooks *hooks,
 
192
                   MetaPropValue       *value,
 
193
                   gboolean             initial)
 
194
{
 
195
  if (hooks && hooks->reload_func != NULL)
 
196
    (* hooks->reload_func) (window, value, initial);
 
197
}
 
198
 
158
199
static void
159
200
reload_wm_client_machine (MetaWindow    *window,
160
201
                          MetaPropValue *value,
162
203
{
163
204
  g_free (window->wm_client_machine);
164
205
  window->wm_client_machine = NULL;
165
 
  
 
206
 
166
207
  if (value->type != META_PROP_VALUE_INVALID)
167
208
    window->wm_client_machine = g_strdup (value->v.str);
168
209
 
184
225
                           MetaPropValue *value,
185
226
                           gboolean       initial)
186
227
{
187
 
  meta_window_update_net_wm_type (window);
 
228
  int n_atoms;
 
229
  Atom *atoms;
 
230
  int i;
 
231
 
 
232
  window->type_atom = None;
 
233
  n_atoms = 0;
 
234
  atoms = NULL;
 
235
 
 
236
  meta_prop_get_atom_list (window->display, window->xwindow,
 
237
                           window->display->atom__NET_WM_WINDOW_TYPE,
 
238
                           &atoms, &n_atoms);
 
239
 
 
240
  i = 0;
 
241
  while (i < n_atoms)
 
242
    {
 
243
      /* We break as soon as we find one we recognize,
 
244
       * supposed to prefer those near the front of the list
 
245
       */
 
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)
 
254
        {
 
255
          window->type_atom = atoms[i];
 
256
          break;
 
257
        }
 
258
 
 
259
      ++i;
 
260
    }
 
261
 
 
262
  meta_XFree (atoms);
 
263
 
 
264
  if (meta_is_verbose ())
 
265
    {
 
266
      char *str;
 
267
 
 
268
      str = NULL;
 
269
      if (window->type_atom != None)
 
270
        {
 
271
          meta_error_trap_push (window->display);
 
272
          str = XGetAtomName (window->display->xdisplay, window->type_atom);
 
273
          meta_error_trap_pop (window->display, TRUE);
 
274
        }
 
275
 
 
276
      meta_verbose ("Window %s type atom %s\n", window->desc,
 
277
                    str ? str : "(none)");
 
278
 
 
279
      if (str)
 
280
        meta_XFree (str);
 
281
    }
 
282
 
 
283
  meta_window_recalc_window_type (window);
188
284
}
189
285
 
190
286
static void
213
309
  reload_icon (window, window->display->atom__KWM_WIN_ICON);
214
310
}
215
311
 
 
312
static gboolean
 
313
gtk_border_equal (GtkBorder *a,
 
314
                  GtkBorder *b)
 
315
{
 
316
  return (a->left == b->left &&
 
317
          a->right == b->right &&
 
318
          a->top == b->top &&
 
319
          a->bottom == b->bottom);
 
320
}
 
321
 
 
322
static void
 
323
meta_window_set_custom_frame_extents (MetaWindow *window,
 
324
                                      GtkBorder  *extents)
 
325
{
 
326
  if (extents)
 
327
    {
 
328
      if (window->has_custom_frame_extents && gtk_border_equal (&window->custom_frame_extents, extents))
 
329
        return;
 
330
 
 
331
      window->has_custom_frame_extents = TRUE;
 
332
      window->custom_frame_extents = *extents;
 
333
    }
 
334
  else
 
335
    {
 
336
      if (!window->has_custom_frame_extents)
 
337
        return;
 
338
 
 
339
      window->has_custom_frame_extents = FALSE;
 
340
      memset (&window->custom_frame_extents, 0, sizeof (window->custom_frame_extents));
 
341
    }
 
342
 
 
343
  meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
 
344
}
 
345
 
 
346
static void
 
347
reload_gtk_frame_extents (MetaWindow    *window,
 
348
                          MetaPropValue *value,
 
349
                          gboolean       initial)
 
350
{
 
351
  if (value->type != META_PROP_VALUE_INVALID)
 
352
    {
 
353
      if (value->v.cardinal_list.n_cardinals != 4)
 
354
        {
 
355
          meta_verbose ("_GTK_FRAME_EXTENTS on %s has %d values instead of 4\n",
 
356
                        window->desc, value->v.cardinal_list.n_cardinals);
 
357
        }
 
358
      else
 
359
        {
 
360
          GtkBorder extents;
 
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);
 
366
        }
 
367
    }
 
368
  else
 
369
    {
 
370
      meta_window_set_custom_frame_extents (window, NULL);
 
371
    }
 
372
}
 
373
 
216
374
static void
217
375
reload_struts (MetaWindow    *window,
218
376
               MetaPropValue *value,
226
384
                       MetaPropValue *value,
227
385
                       gboolean       initial)
228
386
{
229
 
  meta_window_update_role (window);
 
387
  g_clear_pointer (&window->role, g_free);
 
388
  if (value->type != META_PROP_VALUE_INVALID)
 
389
    window->role = g_strdup (value->v.str);
230
390
}
231
391
 
232
392
static void
237
397
  if (value->type != META_PROP_VALUE_INVALID)
238
398
    {
239
399
      gulong cardinal = (int) value->v.cardinal;
240
 
      
 
400
 
241
401
      if (cardinal <= 0)
242
402
        meta_warning (_("Application set a bogus _NET_WM_PID %lu\n"),
243
403
                      cardinal);
332
492
{
333
493
#ifdef HAVE_GTOP
334
494
  glibtop_proc_uid process_details;
335
 
      
 
495
 
336
496
  glibtop_get_proc_uid (&process_details, process);
337
497
 
338
498
  if (process_details.flags & (1L << GLIBTOP_PROC_UID_UID))
370
530
{
371
531
  char hostname[HOST_NAME_MAX + 1];
372
532
  gboolean modified = FALSE;
373
 
  
 
533
 
374
534
  if (!target)
375
535
    return FALSE;
376
 
  
 
536
 
377
537
  g_free (*target);
378
 
  
 
538
 
379
539
  if (!title)
380
540
    *target = g_strdup ("");
381
541
  else if (g_utf8_strlen (title, MAX_TITLE_LENGTH + 1) > MAX_TITLE_LENGTH)
409
569
      /* Assume a window with unknown ownership is ours (call it usufruct!) */
410
570
      gboolean window_owner_is_us =
411
571
              !window_owner_known || window_owner==getuid ();
412
 
      
 
572
 
413
573
      if (window_owner_is_us)
414
574
        {
415
575
          /* we own it, so fall back to the simple case */
436
596
                {
437
597
                  found_name = pwd->pw_name;
438
598
                }
439
 
            
 
599
 
440
600
              if (found_name)
441
601
                /* Translators: the title of a window owned by another user
442
602
                 * on this machine */
451
611
            }
452
612
          /* either way we changed it */
453
613
          modified = TRUE;
454
 
              
 
614
 
455
615
        }
456
616
    }
457
617
  else
480
640
                  const char *title)
481
641
{
482
642
  char *str;
483
 
 
 
643
 
484
644
  gboolean modified =
485
645
    set_title_text (window,
486
646
                    window->using_net_wm_visible_name,
488
648
                    window->display->atom__NET_WM_VISIBLE_NAME,
489
649
                    &window->title);
490
650
  window->using_net_wm_visible_name = modified;
491
 
  
 
651
 
492
652
  /* strndup is a hack since GNU libc has broken %.10s */
493
653
  str = g_strndup (window->title, 10);
494
654
  g_free (window->desc);
534
694
                    value->v.str);
535
695
      return;
536
696
    }
537
 
  
 
697
 
538
698
  if (value->type != META_PROP_VALUE_INVALID)
539
699
    {
540
700
      set_window_title (window, value->v.str);
594
754
                    value->v.str);
595
755
      return;
596
756
    }
597
 
  
 
757
 
598
758
  if (value->type != META_PROP_VALUE_INVALID)
599
759
    {
600
760
      set_icon_title (window, value->v.str);
601
 
      
 
761
 
602
762
      meta_verbose ("Using WM_ICON_NAME for new title of %s: \"%s\"\n",
603
763
                    window->desc, window->title);
604
764
    }
675
835
                window->desc);
676
836
 
677
837
  meta_window_recalc_window_type (window);
 
838
  meta_window_recalc_features (window);
678
839
}
679
840
 
680
841
static void
786
947
    meta_verbose ("Functions flag unset\n");
787
948
 
788
949
  meta_window_recalc_features (window);
789
 
  
 
950
 
790
951
  /* We do all this anyhow at the end of meta_window_new() */
791
952
  if (!window->constructing)
792
953
    {
794
955
        meta_window_ensure_frame (window);
795
956
      else
796
957
        meta_window_destroy_frame (window);
797
 
      
 
958
 
798
959
      meta_window_queue (window,
799
960
                         META_QUEUE_MOVE_RESIZE |
800
961
                         /* because ensure/destroy frame may unmap: */
816
977
  window->res_name = NULL;
817
978
 
818
979
  if (value->type != META_PROP_VALUE_INVALID)
819
 
    { 
 
980
    {
820
981
      if (value->v.class_hint.res_name)
821
982
        window->res_name = g_strdup (value->v.class_hint.res_name);
822
983
 
852
1013
{
853
1014
  guint32 timestamp = window->net_wm_user_time;
854
1015
  MetaWorkspace *workspace = NULL;
855
 
  
 
1016
 
856
1017
  g_free (window->startup_id);
857
 
  
 
1018
 
858
1019
  if (value->type != META_PROP_VALUE_INVALID)
859
1020
    window->startup_id = g_strdup (value->v.str);
860
1021
  else
861
1022
    window->startup_id = NULL;
862
 
    
 
1023
 
863
1024
  /* Update timestamp and workspace on a running window */
864
1025
  if (!window->constructing)
865
1026
  {
866
 
    window->initial_timestamp_set = 0;  
 
1027
    window->initial_timestamp_set = 0;
867
1028
    window->initial_workspace_set = 0;
868
 
    
 
1029
 
869
1030
    if (meta_screen_apply_startup_properties (window->screen, window))
870
1031
      {
871
 
  
 
1032
 
872
1033
        if (window->initial_timestamp_set)
873
1034
          timestamp = window->initial_timestamp;
874
1035
        if (window->initial_workspace_set)
875
1036
          workspace = meta_screen_get_workspace_by_index (window->screen, window->initial_workspace);
876
 
    
 
1037
 
877
1038
        meta_window_activate_with_workspace (window, timestamp, workspace);
878
1039
      }
879
1040
  }
880
 
  
 
1041
 
881
1042
  meta_verbose ("New _NET_STARTUP_ID \"%s\" for %s\n",
882
1043
                window->startup_id ? window->startup_id : "unset",
883
1044
                window->desc);
957
1118
  if (FLAG_CHANGED (old, new, PWinGravity))
958
1119
    meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: PWinGravity now %s  (%d -> %d)\n",
959
1120
                FLAG_TOGGLED_ON (old, new, PWinGravity) ? "set" : "unset",
960
 
                old->win_gravity, new->win_gravity);  
 
1121
                old->win_gravity, new->win_gravity);
961
1122
}
962
1123
 
963
1124
void
1310
1471
  if (value->type != META_PROP_VALUE_INVALID)
1311
1472
    {
1312
1473
      XSizeHints old_hints;
1313
 
  
 
1474
 
1314
1475
      meta_topic (META_DEBUG_GEOMETRY, "Updating WM_NORMAL_HINTS for %s\n", window->desc);
1315
1476
 
1316
1477
      old_hints = window->size_hints;
1317
 
  
 
1478
 
1318
1479
      meta_set_normal_hints (window, value->v.size_hints.hints);
1319
 
      
 
1480
 
1320
1481
      spew_size_hints_differences (&old_hints, &window->size_hints);
1321
 
      
 
1482
 
1322
1483
      meta_window_recalc_features (window);
1323
1484
 
1324
1485
      if (!initial)
1332
1493
                     gboolean       initial)
1333
1494
{
1334
1495
  int i;
1335
 
  
 
1496
 
1336
1497
  window->take_focus = FALSE;
1337
1498
  window->delete_window = FALSE;
1338
1499
  window->net_wm_ping = FALSE;
1339
 
  
1340
 
  if (value->type == META_PROP_VALUE_INVALID)    
 
1500
 
 
1501
  if (value->type == META_PROP_VALUE_INVALID)
1341
1502
    return;
1342
1503
 
1343
1504
  i = 0;
1354
1515
        window->net_wm_ping = TRUE;
1355
1516
      ++i;
1356
1517
    }
1357
 
  
 
1518
 
1358
1519
  meta_verbose ("New _NET_STARTUP_ID \"%s\" for %s\n",
1359
1520
                window->startup_id ? window->startup_id : "unset",
1360
1521
                window->desc);
1366
1527
                 gboolean       initial)
1367
1528
{
1368
1529
  Window old_group_leader;
1369
 
  
 
1530
 
1370
1531
  old_group_leader = window->xgroup_leader;
1371
 
  
 
1532
 
1372
1533
  /* Fill in defaults */
1373
1534
  window->input = TRUE;
1374
1535
  window->initially_iconic = FALSE;
1375
1536
  window->xgroup_leader = None;
1376
1537
  window->wm_hints_pixmap = None;
1377
1538
  window->wm_hints_mask = None;
1378
 
  
 
1539
 
1379
1540
  if (value->type != META_PROP_VALUE_INVALID)
1380
1541
    {
1381
1542
      const XWMHints *hints = value->v.wm_hints;
1382
 
      
 
1543
 
1383
1544
      if (hints->flags & InputHint)
1384
1545
        window->input = hints->input;
1385
1546
 
1394
1555
 
1395
1556
      if (hints->flags & IconMaskHint)
1396
1557
        window->wm_hints_mask = hints->icon_mask;
1397
 
      
 
1558
 
1398
1559
      meta_verbose ("Read WM_HINTS input: %d iconic: %d group leader: 0x%lx pixmap: 0x%lx mask: 0x%lx\n",
1399
1560
                    window->input, window->initially_iconic,
1400
1561
                    window->xgroup_leader,
1406
1567
    {
1407
1568
      meta_verbose ("Window %s changed its group leader to 0x%lx\n",
1408
1569
                    window->desc, window->xgroup_leader);
1409
 
      
 
1570
 
1410
1571
      meta_window_group_leader_changed (window);
1411
1572
    }
1412
1573
 
1423
1584
                      gboolean       initial)
1424
1585
{
1425
1586
  window->xtransient_for = None;
1426
 
  
 
1587
 
1427
1588
  if (value->type != META_PROP_VALUE_INVALID)
1428
1589
    window->xtransient_for = value->v.xwindow;
1429
1590
 
1430
1591
  /* Make sure transient_for is valid */
1431
1592
  if (window->xtransient_for != None &&
1432
 
      meta_display_lookup_x_window (window->display, 
 
1593
      meta_display_lookup_x_window (window->display,
1433
1594
                                    window->xtransient_for) == NULL)
1434
1595
    {
1435
1596
      meta_warning (_("Invalid WM_TRANSIENT_FOR window 0x%lx specified "
1466
1627
    meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
1467
1628
}
1468
1629
 
 
1630
static void
 
1631
reload_gtk_theme_variant (MetaWindow    *window,
 
1632
                          MetaPropValue *value,
 
1633
                          gboolean       initial)
 
1634
{
 
1635
  char *requested_variant = NULL;
 
1636
  char *current_variant = window->gtk_theme_variant;
 
1637
 
 
1638
  if (value->type != META_PROP_VALUE_INVALID)
 
1639
    {
 
1640
      requested_variant = value->v.str;
 
1641
      meta_verbose ("Requested \"%s\" theme variant for window %s.\n",
 
1642
                    requested_variant, window->desc);
 
1643
    }
 
1644
 
 
1645
  if (g_strcmp0 (requested_variant, current_variant) != 0)
 
1646
    {
 
1647
      g_free (current_variant);
 
1648
 
 
1649
      window->gtk_theme_variant = g_strdup (requested_variant);
 
1650
 
 
1651
      if (window->frame)
 
1652
        meta_ui_update_frame_style (window->screen->ui, window->frame->xwindow);
 
1653
    }
 
1654
}
 
1655
 
1469
1656
/**
1470
1657
 * Initialises the property hooks system.  Each row in the table named "hooks"
1471
1658
 * represents an action to take when a property is found on a newly-created
1484
1671
meta_display_init_window_prop_hooks (MetaDisplay *display)
1485
1672
{
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 },
1515
 
    { 0 },
 
1674
    {
 
1675
      display->atom_WM_CLIENT_MACHINE,
 
1676
      META_PROP_VALUE_STRING,
 
1677
      reload_wm_client_machine,
 
1678
      LOAD_INIT
 
1679
    },
 
1680
    {
 
1681
      display->atom__NET_WM_NAME,
 
1682
      META_PROP_VALUE_UTF8,
 
1683
      reload_net_wm_name,
 
1684
      LOAD_INIT
 
1685
    },
 
1686
    {
 
1687
      XA_WM_CLASS,
 
1688
      META_PROP_VALUE_CLASS_HINT,
 
1689
      reload_wm_class,
 
1690
      LOAD_INIT
 
1691
    },
 
1692
    {
 
1693
      display->atom__NET_WM_PID,
 
1694
      META_PROP_VALUE_CARDINAL,
 
1695
      reload_net_wm_pid,
 
1696
      LOAD_INIT
 
1697
    },
 
1698
    {
 
1699
      XA_WM_NAME,
 
1700
      META_PROP_VALUE_TEXT_PROPERTY,
 
1701
      reload_wm_name,
 
1702
      LOAD_INIT
 
1703
    },
 
1704
    {
 
1705
      display->atom__NET_WM_ICON_NAME,
 
1706
      META_PROP_VALUE_UTF8,
 
1707
      reload_net_wm_icon_name,
 
1708
      LOAD_INIT
 
1709
    },
 
1710
    {
 
1711
      XA_WM_ICON_NAME,
 
1712
      META_PROP_VALUE_TEXT_PROPERTY,
 
1713
      reload_wm_icon_name,
 
1714
      LOAD_INIT
 
1715
    },
 
1716
    {
 
1717
      display->atom__NET_WM_DESKTOP,
 
1718
      META_PROP_VALUE_CARDINAL,
 
1719
      reload_net_wm_desktop,
 
1720
      LOAD_INIT | INIT_ONLY
 
1721
    },
 
1722
    {
 
1723
      display->atom__NET_STARTUP_ID,
 
1724
      META_PROP_VALUE_UTF8,
 
1725
      reload_net_startup_id,
 
1726
      LOAD_INIT
 
1727
    },
 
1728
    {
 
1729
      display->atom__NET_WM_SYNC_REQUEST_COUNTER,
 
1730
      META_PROP_VALUE_SYNC_COUNTER,
 
1731
      reload_update_counter,
 
1732
      LOAD_INIT
 
1733
    },
 
1734
    {
 
1735
      XA_WM_NORMAL_HINTS,
 
1736
      META_PROP_VALUE_SIZE_HINTS,
 
1737
      reload_normal_hints,
 
1738
      LOAD_INIT
 
1739
    },
 
1740
    {
 
1741
      display->atom_WM_PROTOCOLS,
 
1742
      META_PROP_VALUE_ATOM_LIST,
 
1743
      reload_wm_protocols,
 
1744
      LOAD_INIT
 
1745
    },
 
1746
    {
 
1747
      XA_WM_HINTS,
 
1748
      META_PROP_VALUE_WM_HINTS,
 
1749
      reload_wm_hints,
 
1750
      LOAD_INIT
 
1751
    },
 
1752
    {
 
1753
      display->atom__NET_WM_USER_TIME,
 
1754
      META_PROP_VALUE_CARDINAL,
 
1755
      reload_net_wm_user_time,
 
1756
      LOAD_INIT
 
1757
    },
 
1758
    {
 
1759
      display->atom__NET_WM_STATE,
 
1760
      META_PROP_VALUE_ATOM_LIST,
 
1761
      reload_net_wm_state,
 
1762
      LOAD_INIT | INIT_ONLY
 
1763
    },
 
1764
    {
 
1765
      display->atom__MOTIF_WM_HINTS,
 
1766
      META_PROP_VALUE_MOTIF_HINTS,
 
1767
      reload_mwm_hints,
 
1768
      LOAD_INIT
 
1769
    },
 
1770
    {
 
1771
      XA_WM_TRANSIENT_FOR,
 
1772
      META_PROP_VALUE_WINDOW,
 
1773
      reload_transient_for,
 
1774
      LOAD_INIT
 
1775
    },
 
1776
    {
 
1777
      display->atom__GTK_THEME_VARIANT,
 
1778
      META_PROP_VALUE_UTF8,
 
1779
      reload_gtk_theme_variant,
 
1780
      LOAD_INIT
 
1781
    },
 
1782
    {
 
1783
      display->atom__GTK_FRAME_EXTENTS,
 
1784
      META_PROP_VALUE_CARDINAL_LIST,
 
1785
      reload_gtk_frame_extents,
 
1786
      LOAD_INIT
 
1787
    },
 
1788
    {
 
1789
      display->atom__NET_WM_USER_TIME_WINDOW,
 
1790
      META_PROP_VALUE_WINDOW,
 
1791
      reload_net_wm_user_time_window,
 
1792
      LOAD_INIT
 
1793
    },
 
1794
    {
 
1795
      display->atom_WM_STATE,
 
1796
      META_PROP_VALUE_INVALID,
 
1797
      NULL,
 
1798
      NONE
 
1799
    },
 
1800
    {
 
1801
      display->atom__NET_WM_ICON,
 
1802
      META_PROP_VALUE_INVALID,
 
1803
      reload_net_wm_icon,
 
1804
      NONE
 
1805
    },
 
1806
    {
 
1807
      display->atom__KWM_WIN_ICON,
 
1808
      META_PROP_VALUE_INVALID,
 
1809
      reload_kwm_win_icon,
 
1810
      NONE
 
1811
    },
 
1812
    {
 
1813
      display->atom_WM_CLIENT_LEADER,
 
1814
      META_PROP_VALUE_INVALID,
 
1815
      complain_about_broken_client,
 
1816
      NONE
 
1817
    },
 
1818
    {
 
1819
      display->atom_SM_CLIENT_ID,
 
1820
      META_PROP_VALUE_INVALID,
 
1821
      complain_about_broken_client,
 
1822
      NONE
 
1823
    },
 
1824
    {
 
1825
      display->atom_WM_WINDOW_ROLE,
 
1826
      META_PROP_VALUE_STRING,
 
1827
      reload_wm_window_role,
 
1828
      LOAD_INIT | FORCE_INIT
 
1829
    },
 
1830
    {
 
1831
      display->atom__NET_WM_WINDOW_TYPE,
 
1832
      META_PROP_VALUE_ATOM_LIST,
 
1833
      reload_net_wm_window_type,
 
1834
      LOAD_INIT | FORCE_INIT
 
1835
    },
 
1836
    {
 
1837
      display->atom__NET_WM_STRUT,
 
1838
      META_PROP_VALUE_INVALID,
 
1839
      reload_struts,
 
1840
      NONE
 
1841
    },
 
1842
    {
 
1843
      display->atom__NET_WM_STRUT_PARTIAL,
 
1844
      META_PROP_VALUE_INVALID,
 
1845
      reload_struts,
 
1846
      NONE
 
1847
    },
 
1848
    {
 
1849
      0
 
1850
    },
1516
1851
  };
1517
1852
 
1518
1853
  MetaWindowPropHooks *table = g_memdup (hooks, sizeof (hooks)),
1525
1860
 
1526
1861
  while (cursor->property)
1527
1862
    {
 
1863
      /* Doing initial loading doesn't make sense if we just want notification */
 
1864
      g_assert (!((cursor->flags & LOAD_INIT) && cursor->type == META_PROP_VALUE_INVALID));
 
1865
 
 
1866
      /* Forcing initialization doesn't make sense if not loading initially */
 
1867
      g_assert ((cursor->flags & LOAD_INIT) || !(cursor->flags & FORCE_INIT));
 
1868
 
1528
1869
      /* Atoms are safe to use with GINT_TO_POINTER because it's safe with
1529
1870
       * anything 32 bits or less, and atoms are 32 bits with the top three
1530
1871
       * bits clear.  (Scheifler & Gettys, 2e, p372)
1534
1875
                           cursor);
1535
1876
      cursor++;
1536
1877
    }
 
1878
  display->n_prop_hooks = cursor - table;
1537
1879
}
1538
1880
 
1539
1881
void
1546
1888
  display->prop_hooks_table = NULL;
1547
1889
}
1548
1890
 
1549
 
/**
1550
 
 * Finds the hooks for a particular property.
1551
 
 */
1552
1891
static MetaWindowPropHooks*
1553
1892
find_hooks (MetaDisplay *display,
1554
1893
            Atom         property)