Hi,
On Wed, 2010-05-12 at 07:39 +0200, ext Pallavi Kandhare wrote:
..
2. On mobile certain aplications are running at a time. (ed. clock,
calender etc). How
can i find out and list all these applications.
There is nothing very convenient for this but you can do it using the
same API as the window manager (hildon-desktop) uses: XQueryTree and
reading some window properties with XGetWindowProperty. You could get a
some kind of list by taking top-level (== parent is the root window)
windows that have _NET_WM_WINDOW_TYPE property set to
_NET_WM_WINDOW_TYPE_NORMAL.
I'm attaching the source code of a small utility that uses XQueryTree,
you could use it as a starting point.
-Kimmo
#include X11/Xlib.h
#include X11/Xatom.h
#include stdio.h
#include stdlib.h
#include string.h
static Atom class_atom, name_atom, name_atom2, xembed_atom, pid_atom,
trans_atom, hildon_stack_atom,
utf8_string_atom,
current_app_atom, win_type_atom, wm_state_atom, theme_atom,
portrait_support, portrait_request, non_comp_atom;
static char *get_atom_prop(Display *dpy, Window w, Atom atom)
{
Atom type;
int format, rc;
unsigned long items;
unsigned long left;
Atom *value;
char *copy;
rc = XGetWindowProperty (dpy, w, atom, 0, 1, False,
XA_ATOM, type, format,
items, left, (unsigned char**)value);
if (type != XA_ATOM || format == 0 || rc != Success) {
copy = strdup();
} else {
char *s = XGetAtomName(dpy, *value);
copy = strdup(s);
XFree(s);
}
return copy;
}
static Window get_win_prop(Display *dpy, Window w, Atom atom)
{
Atom type;
int format, rc;
unsigned long items;
unsigned long left;
Window *value;
rc = XGetWindowProperty (dpy, w, atom, 0, 1, False,
XA_WINDOW, type, format,
items, left, (unsigned char**)value);
if (type == None || rc != Success)
return 0;
else
{
return *value;
}
}
static unsigned long get_card_prop(Display *dpy, Window w, Atom atom)
{
Atom type;
int format, rc;
unsigned long items;
unsigned long left;
unsigned long *value;
rc = XGetWindowProperty (dpy, w, atom, 0, 1, False,
XA_CARDINAL, type, format,
items, left, (unsigned char**)value);
if (type == None || rc != Success)
return 0;
else
{
return *value;
}
}
static long get_int_prop(Display *dpy, Window w, Atom atom)
{
Atom type;
int format, rc;
unsigned long items;
unsigned long left;
unsigned long *value;
rc = XGetWindowProperty (dpy, w, atom, 0, 1, False,
XA_INTEGER, type, format,
items, left, (unsigned char**)value);
if (type == None || rc != Success)
return -1;
else
{
return *value;
}
}
static long get_xembed_prop(Display *dpy, Window w)
{
Atom type;
int format, rc;
unsigned long items;
unsigned long left;
unsigned long *value;
rc = XGetWindowProperty (dpy, w, xembed_atom, 0, 2, False,
XA_CARDINAL, type, format,
items, left, (unsigned char**)value);
if (type == None || rc != Success)
return -1;
else
{
long ret;
ret = value[1] (1 0);
XFree(value);
return ret;
}
}
static char *get_str_prop(Display *dpy, Window w, Atom atom)
{
Atom type;
int format, rc;
unsigned long items;
unsigned long left;
char *value;
rc = XGetWindowProperty (dpy, w, atom, 0, 200, False,
XA_STRING, type, format,
items, left, (unsigned char**)value);
if (type == None || rc != Success)
return NULL;
else
{
char *s = strdup((const char*)value);
XFree(value);
return s;
}
}
static char *get_utf8_prop(Display *dpy, Window w, Atom atom)
{
Atom type;
int format, rc;
unsigned long items;
unsigned long left;
char *value;
rc = XGetWindowProperty (dpy, w, atom, 0, 200, False,
utf8_string_atom, type, format,
items, left, (unsigned char**)value);
if (type == None || rc != Success)
return NULL;
else
{
char *s = strdup((const char*)value);
XFree(value);
return s;
}
}
static const char