/* xwindow is a group leader */ WnckApplication* _wnck_application_create (Window xwindow, WnckScreen *screen) { WnckApplication *application; Screen *xscreen; if (app_hash == NULL) app_hash = g_hash_table_new_full (_wnck_xid_hash, _wnck_xid_equal, NULL, g_object_unref); g_return_val_if_fail (g_hash_table_lookup (app_hash, &xwindow) == NULL, NULL); xscreen = WNCK_SCREEN_XSCREEN (screen); application = g_object_new (WNCK_TYPE_APPLICATION, NULL); application->priv->xwindow = xwindow; application->priv->screen = screen; application->priv->name = _wnck_get_name (xscreen, xwindow); if (application->priv->name == NULL) application->priv->name = _wnck_get_res_class_utf8 (xscreen, xwindow); if (application->priv->name) application->priv->name_from_leader = TRUE; application->priv->pid = _wnck_get_pid (xscreen, application->priv->xwindow); application->priv->startup_id = _wnck_get_utf8_property (xscreen, application->priv->xwindow, _wnck_atom_get ("_NET_STARTUP_ID")); g_hash_table_insert (app_hash, &application->priv->xwindow, application); /* Hash now owns one ref, caller gets none */ /* Note that xwindow may correspond to a WnckWindow's xwindow, * so we select events needed by either */ application->priv->orig_event_mask = _wnck_select_input (xscreen, application->priv->xwindow, WNCK_APP_WINDOW_EVENT_MASK, TRUE); return application; }
void _wnck_application_process_property_notify (WnckApplication *app, XEvent *xevent) { /* This prop notify is on the leader window */ if (xevent->xproperty.atom == XA_WM_NAME || xevent->xproperty.atom == _wnck_atom_get ("_NET_WM_NAME") || xevent->xproperty.atom == _wnck_atom_get ("_NET_WM_VISIBLE_NAME")) { /* FIXME should change the name */ } else if (xevent->xproperty.atom == XA_WM_ICON_NAME || xevent->xproperty.atom == _wnck_atom_get ("_NET_WM_ICON_NAME") || xevent->xproperty.atom == _wnck_atom_get ("_NET_WM_VISIBLE_ICON_NAME")) { /* FIXME */ } else if (xevent->xproperty.atom == _wnck_atom_get ("_NET_WM_ICON") || xevent->xproperty.atom == _wnck_atom_get ("KWM_WIN_ICON") || xevent->xproperty.atom == _wnck_atom_get ("WM_NORMAL_HINTS")) { _wnck_icon_cache_property_changed (app->priv->icon_cache, xevent->xproperty.atom); emit_icon_changed (app); } else if (xevent->xproperty.atom == _wnck_atom_get ("_NET_STARTUP_ID")) { /* FIXME update startup id */ } }
/** * wnck_xid_read_resource_usage: * @gdk_display: a <classname>GdkDisplay</classname>. * @xid: an X window ID. * @usage: return location for the X resource usage of the application owning * the X window ID @xid. * * Looks for the X resource usage of the application owning the X window ID * @xid on display @gdisplay. If no resource usage can be found, then all * fields of @usage are set to 0. * * To properly work, this function requires the XRes extension on the X server. * * Since: 2.6 */ void wnck_xid_read_resource_usage (GdkDisplay *gdisplay, gulong xid, WnckResourceUsage *usage) { g_return_if_fail (usage != NULL); memset (usage, '\0', sizeof (*usage)); if (wnck_init_resource_usage (gdisplay) == WNCK_EXT_MISSING) return; #ifdef HAVE_XRES { Display *xdisplay; XResType *types; int n_types; unsigned long pixmap_bytes; int i; Atom pixmap_atom; Atom window_atom; Atom gc_atom; Atom picture_atom; Atom glyphset_atom; Atom font_atom; Atom colormap_entry_atom; Atom passive_grab_atom; Atom cursor_atom; types = NULL; n_types = 0; pixmap_bytes = 0; xdisplay = GDK_DISPLAY_XDISPLAY (gdisplay); _wnck_error_trap_push (xdisplay); XResQueryClientResources (xdisplay, xid, &n_types, &types); XResQueryClientPixmapBytes (xdisplay, xid, &pixmap_bytes); _wnck_error_trap_pop (xdisplay); usage->pixmap_bytes = pixmap_bytes; pixmap_atom = _wnck_atom_get ("PIXMAP"); window_atom = _wnck_atom_get ("WINDOW"); gc_atom = _wnck_atom_get ("GC"); font_atom = _wnck_atom_get ("FONT"); glyphset_atom = _wnck_atom_get ("GLYPHSET"); picture_atom = _wnck_atom_get ("PICTURE"); colormap_entry_atom = _wnck_atom_get ("COLORMAP ENTRY"); passive_grab_atom = _wnck_atom_get ("PASSIVE GRAB"); cursor_atom = _wnck_atom_get ("CURSOR"); i = 0; while (i < n_types) { int t = types[i].resource_type; if (t == pixmap_atom) usage->n_pixmaps += types[i].count; else if (t == window_atom) usage->n_windows += types[i].count; else if (t == gc_atom) usage->n_gcs += types[i].count; else if (t == picture_atom) usage->n_pictures += types[i].count; else if (t == glyphset_atom) usage->n_glyphsets += types[i].count; else if (t == font_atom) usage->n_fonts += types[i].count; else if (t == colormap_entry_atom) usage->n_colormap_entries += types[i].count; else if (t == passive_grab_atom) usage->n_passive_grabs += types[i].count; else if (t == cursor_atom) usage->n_cursors += types[i].count; else usage->n_other += types[i].count; ++i; } XFree(types); usage->total_bytes_estimate = usage->pixmap_bytes; /* FIXME look in the X server source and come up with better * answers here. Ideally we change XRes to return a number * like this since it can do things like divide the cost of * a shared resource among those sharing it. */ usage->total_bytes_estimate += usage->n_windows * 24; usage->total_bytes_estimate += usage->n_gcs * 24; usage->total_bytes_estimate += usage->n_pictures * 24; usage->total_bytes_estimate += usage->n_glyphsets * 24; usage->total_bytes_estimate += usage->n_fonts * 1024; usage->total_bytes_estimate += usage->n_colormap_entries * 24; usage->total_bytes_estimate += usage->n_passive_grabs * 24; usage->total_bytes_estimate += usage->n_cursors * 24; usage->total_bytes_estimate += usage->n_other * 24; } #else /* HAVE_XRES */ g_assert_not_reached (); #endif /* HAVE_XRES */ }