Selection ownership for docks and panels
- From: Sam Spilsbury <smspillaz gmail com>
- To: wm-spec-list gnome org
- Subject: Selection ownership for docks and panels
- Date: Tue, 4 Jan 2011 23:17:40 +0800
Hi everyone,
I'd like to propose that there be selection owners for docks and
panels much like there is for window managers, compositors and
decorators right now. The reason for this is because it doesn't make
sense to be running multiple docks at the same which which all provide
methods of setting _NET_WM_ICON_GEOMETRY. It also means that when
switching between some of the new shells such as gnome-shell and
unity-shell that the old docks and panels are able to quit
appropriately and this is standardized amongst all docks and panels.
Something like this should probably suffice:
Display *xdisplay = XOpenDisplay (NULL);
const char *name = "mydock"
XEvent event;
XSetWindowAttributes attr;
Window current_dock_sn_owner, new_dock_sn_owner;
Atom dock_sn_atom;
Atom manager_atom;
Atom dock_name_atom;
Atom utf8_string_atom;
Time dock_sn_timestamp;
char buf[128];
manager_atom = XInternAtom (xdisplay, "MANAGER", FALSE);
dock_name_atom = XInternAtom (xdisplay, "_DOCK_NAME", 0);
utf8_string_atom = XInternAtom (xdisplay, "UTF8_STRING", 0);
sprintf (buf, "_DOCK_S%d", screen);
dock_sn_atom = XInternAtom (xdisplay, buf, 0);
current_dock_sn_owner = XGetSelectionOwner (xdisplay, dock_sn_atom);
if (current_dock_sn_owner != None)
{
if (!replace_current_dock)
printf ("Another dock already running, use --replace to get rid of it");
XSelectInput (xdisplay, current_dock_sn_owner, StructureNotifyMask);
}
attr.override_redirect = TRUE;
attr.event_mask = PropertyChangeMask;
new_dock_sn_owner =
XCreateWindow (xdisplay, XRootWindow (xdisplay, screen),
-100, -100, 1, 1, 0,
CopyFromParent, CopyFromParent,
CopyFromParent,
CWOverrideRedirect | CWEventMask,
&attr);
XChangeProperty (xdisplay,
new_dock_sn_owner,
dock_name_atom,
utf8_string_atom, 8,
PropModeReplace,
(unsigned char *) name,
strlen (name));
XWindowEvent (xdisplay,
new_dm_sn_owner,
PropertyChangeMask,
&event);
dock_sn_timestamp = event.xproperty.time;
XSetSelectionOwner (xdisplay, dock_sn_atom, new_dock_sn_owner,
dock_sn_timestamp);
if (XGetSelectionOwner (xdisplay, dock_sn_atom) != new_dock_sn_owner)
{
XDestroyWindow (xdisplay, new_dock_sn_owner);
/* Failed */
return 1;
}
/* Send client message indicating that we are now the dock */
event.xclient.type = ClientMessage;
event.xclient.window = XRootWindow (xdisplay, screen);
event.xclient.message_type = manager_atom;
event.xclient.format = 32;
event.xclient.data.l[0] = dock_sn_timestamp;
event.xclient.data.l[1] = dock_sn_atom;
event.xclient.data.l[2] = 0;
event.xclient.data.l[3] = 0;
event.xclient.data.l[4] = 0;
XSendEvent (xdisplay, XRootWindow (xdisplay, screen), 0,
StructureNotifyMask, &event);
/* Wait for old dock to go away */
if (current_dock_sn_owner != None)
{
do {
XWindowEvent (xdisplay, current_dock_sn_owner,
StructureNotifyMask, &event);
} while (event.type != DestroyNotify);
}
(inspired by the decoration manager selection code in compiz /
libdecoration/decoration.c)
So in effect you'd have the following atoms on the root window
_DOCK_NAME: utf8 string with the dock name (eg "mydock)
_DOCK_S(screen number): Selection for the dock on the screen number specified
I don't know exactly what would be the right name for this,
considering that we might not want to be replacing entire docks
(indeed, just the tasklist portion is the problematic part), so maybe
it might be appropriate to have a selection method for entire docks
(where 2 docks doesn't make sense, eg docks / panels / anything with
unity / gnome-shell) and one for tasklists (where two docks can
logically co-exist)
Cheers
--
Sam Spilsbury
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]