~ubuntu-branches/debian/sid/gnome-shell/sid

« back to all changes in this revision

Viewing changes to src/shell-window-tracker.c

  • Committer: Package Import Robot
  • Author(s): Emilio Pozuelo Monfort, Petr Salinger, Emilio Pozuelo Monfort
  • Date: 2013-10-13 17:47:35 UTC
  • mfrom: (1.2.17) (18.1.41 experimental)
  • Revision ID: package-import@ubuntu.com-20131013174735-2npsu0w5wk0e6vgb
Tags: 3.8.4-4
[ Petr Salinger ]
* Restrict dependency on gir1.2-nmgtk-1.0 to linux-any (Closes: #726099)

[ Emilio Pozuelo Monfort ]
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
}
128
128
 
129
129
/**
130
 
 * get_appid_from_window:
131
 
 *
132
 
 * Turn the WM_CLASS property into our best guess at a .desktop file id.
133
 
 */
134
 
static char *
135
 
get_appid_from_window (MetaWindow  *window)
136
 
{
137
 
  const char *wmclass;
138
 
  char *appid_guess;
139
 
 
140
 
  wmclass = meta_window_get_wm_class (window);
141
 
  if (!wmclass)
142
 
    return NULL;
143
 
 
144
 
  appid_guess = g_ascii_strdown (wmclass, -1);
145
 
 
146
 
  /* This handles "Fedora Eclipse", probably others.
147
 
   * Note g_strdelimit is modify-in-place. */
148
 
  g_strdelimit (appid_guess, " ", '-');
149
 
 
150
 
  return appid_guess;
151
 
}
152
 
 
153
 
/**
154
130
 * shell_window_tracker_is_window_interesting:
155
131
 *
156
132
 * The ShellWindowTracker associates certain kinds of windows with
202
178
}
203
179
 
204
180
/**
205
 
 * get_app_from_window_wmclass:
206
 
 *
207
 
 * Looks only at the given window, and attempts to determine
208
 
 * an application based on WM_CLASS.  If one can't be determined,
209
 
 * return %NULL.
210
 
 *
211
 
 * Return value: (transfer full): A newly-referenced #ShellApp, or %NULL
212
 
 */
213
 
static ShellApp *
214
 
get_app_from_window_wmclass (MetaWindow  *window)
215
 
{
216
 
  ShellApp *app;
217
 
  ShellAppSystem *appsys;
218
 
  char *wmclass;
219
 
  char *with_desktop;
220
 
 
221
 
  appsys = shell_app_system_get_default ();
222
 
  wmclass = get_appid_from_window (window);
223
 
 
224
 
  if (!wmclass)
225
 
    return NULL;
226
 
 
227
 
  with_desktop = g_strjoin (NULL, wmclass, ".desktop", NULL);
228
 
  g_free (wmclass);
229
 
 
230
 
  app = shell_app_system_lookup_heuristic_basename (appsys, with_desktop);
231
 
  if (app != NULL)
232
 
    g_object_ref (app);
233
 
  g_free (with_desktop);
234
 
 
235
 
  return app;
236
 
}
237
 
 
238
 
/**
239
181
 * get_app_from_window_group:
240
182
 * @monitor: a #ShellWindowTracker
241
183
 * @window: a #MetaWindow
328
270
get_app_for_window (ShellWindowTracker    *tracker,
329
271
                    MetaWindow            *window)
330
272
{
 
273
  ShellAppSystem *app_system;
331
274
  ShellApp *result = NULL;
332
275
  const char *startup_id;
333
276
 
 
277
  app_system = shell_app_system_get_default ();
 
278
 
334
279
  /* First, we check whether we already know about this window,
335
280
   * if so, just return that.
336
281
   */
351
296
  /* Check if the app's WM_CLASS specifies an app; this is
352
297
   * canonical if it does.
353
298
   */
354
 
  result = get_app_from_window_wmclass (window);
 
299
  result = shell_app_system_lookup_wmclass (app_system,
 
300
                                            meta_window_get_wm_class (window));
355
301
  if (result != NULL)
356
 
    return result;
 
302
    return g_object_ref (result);
357
303
 
358
304
  result = get_app_from_window_pid (tracker, window);
359
305
  if (result != NULL)
411
357
  new_focus_app = new_focus_win ? shell_window_tracker_get_window_app (self, new_focus_win) : NULL;
412
358
 
413
359
  if (new_focus_app)
414
 
    shell_app_update_window_actions (new_focus_app, new_focus_win);
 
360
    {
 
361
      shell_app_update_window_actions (new_focus_app, new_focus_win);
 
362
      shell_app_update_app_menu (new_focus_app, new_focus_win);
 
363
    }
415
364
 
416
365
  set_focus_app (self, new_focus_app);
417
366
}