GNOME Window Manager Compliance - How to write a GNOME compliant Window Manager | ||
---|---|---|
Prev | Chapter 1. Providing Client Information For The Window Manager | Next |
If your Window Manager supports the concept of Multiple/Virtual Desktops or Workspaces then you will definitely want to include it. This involves your Window Manager setting several properties on the root window.
First you should advertise how many Desktops your Window Manager supports. This is done by setting a property on the root window with the atom name _WIN_WORKSPACE_COUNT of type CARDINAL. The properties data is a 32-bit integer that is the number of Desktops your Window Manager currently supports. If you can add and delete desktops while running, you may change this property and its value whenever required. You should also set a property of the atom _WIN_WORKSPACE of type CARDINAL that contains the number of the currently active desktop (which is a number between 0 and the number advertised by _WIN_WORKSPACE_COUNT - 1). Whenever the active desktop changes, change this property.
Lastly you should set a property that is a list of strings called _WIN_WORKSPACE_NAMES that contains names for the desktops (the first string is the name of the first desktop, the second string is the second desktop, etc.). This will allow applications to know what the name of the desktop is too, possibly to display it.
Example:
Display *disp; Window root_window; Atom atom_set; XTextProperty text; int i, current_desk, number_of_desks; char **names, s[1024]; CARD32 val; atom_set = XInternAtom(disp, "_WIN_WORKSPACE", False); val = (CARD32) current_desk; XChangeProperty(disp, root_window, atom_set, XA_CARDINAL, 32, PropModeReplace, (unsigned char *), 1); atom_set = XInternAtom(disp, "_WIN_WORKSPACE_COUNT", False); val = (CARD32) number_of_desks; XChangeProperty(disp, root_window, atom_set, XA_CARDINAL, 32, PropModeReplace, (unsigned char *), 1); atom_set = XInternAtom(disp, "_WIN_WORKSPACE_NAMES", False); names = malloc(sizeof(char *) * number_of_desks); for (i = 0; i < number_of_desks; i++) { snprintf(s, sizeof(s), "Desktop %i", i); names[i] = malloc(strlen(s) + 1); strcpy(names[i], s); } if (XStringListToTextProperty(names, mode.numdesktops, )) { XSetTextProperty(disp, root_window, , atom_set); XFree(text.value); } for (i = 0; i < number_of_desks; i++) free(names[i]); free(names); |