Duncan Murdoch
2021-Mar-22 19:42 UTC
[Rd] Possible x11 window manager window aggregation under one icon?
On 22/03/2021 3:32 p.m., Ivan Krylov wrote:> On Sat, 20 Mar 2021 11:51:41 -0500 > Dirk Eddelbuettel <edd at debian.org> wrote: > >> R plots however all have one each. Needless to say I may also have >> more than one plot device open... Would anyone know how we can force >> these to aggregate under just one? > > Grouping seems to be achieved by setting the window_group component of > the WM_HINTS property of the window: > > https://www.x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#wm_hints_property > > ICCCM goes on to say that "The window group leader may be a window that > exists only for that purpose <...> [not] mapped either by the client or > by the window manager". > > Is that enough of a direction? I have only ever written X11 code using > xcb, not Xlib, but I could try to help further if needed. >I just did a quick grep of the R-devel sources, and don't see WM_HINTS used there at all. (This is after searching rgl sources, with the same result.) I'd be happy to add something to rgl if you could point me to an example: it also uses Xlib like R, so once that works I could propose a patch to R. Duncan Murdoch
Dirk Eddelbuettel
2021-Mar-22 19:54 UTC
[Rd] Possible x11 window manager window aggregation under one icon?
(Group reply to three emails at once) On 22 March 2021 at 10:27, Balasubramanian Narasimhan wrote: | Confession: haven't done this in decades. Equally green here. | Isn't the usual way to use 'xwininfo' to figure out the information | about any X window and set a specific resource in the .X11defaults or | equivalent?? Also doing the same with windows that aggregate could yield | a common resource, perhaps? Could be. On 22 March 2021 at 22:32, Ivan Krylov wrote: | Grouping seems to be achieved by setting the window_group component of | the WM_HINTS property of the window: | | https://www.x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#wm_hints_property | | ICCCM goes on to say that "The window group leader may be a window that | exists only for that purpose <...> [not] mapped either by the client or | by the window manager". | | Is that enough of a direction? I have only ever written X11 code using | xcb, not Xlib, but I could try to help further if needed. That is quite promising. Just like Duncan I see now WM_HINTS yet, so maybe by just giving them we can improve? On 22 March 2021 at 15:42, Duncan Murdoch wrote: | I just did a quick grep of the R-devel sources, and don't see WM_HINTS | used there at all. (This is after searching rgl sources, with the same | result.) I'd be happy to add something to rgl if you could point me to | an example: it also uses Xlib like R, so once that works I could | propose a patch to R. I'd love for us to put the focus back to src/modules/X11/devX11.{c,h} :) The original email I got for the Debian patch that then made it into R's sources is still here: https://sources.debian.org/src/r-base/4.0.4-1/debian/icon-class-patch/ And I think we somehow need to aggregate all three strands: the Xtoolkit -based info Naras alluded to, and possibly adding hints as identified by Ivan. It might help to spy on "any" other better-behaving X11 client. Dirk -- https://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
Ivan Krylov
2021-Mar-22 21:01 UTC
[Rd] Possible x11 window manager window aggregation under one icon?
On Mon, 22 Mar 2021 15:42:04 -0400 Duncan Murdoch <murdoch.duncan at gmail.com> wrote:> I'd be happy to add something to rgl if you could point me to > an exampleOn Mon, 22 Mar 2021 14:54:43 -0500 Dirk Eddelbuettel <edd at debian.org> wrote:> Just like Duncan I see now WM_HINTS yet, so maybe by > just giving them we can improve?The surrounding code and <https://tronche.com/gui/x/xlib/ICC/client-to-window-manager/wm-hints.html> proved to be enough of an example. The following patch makes it possible to group x11() windows on my PC with Xfce running: -----------------------------------8<----------------------------------- Index: src/modules/X11/devX11.c ==================================================================--- src/modules/X11/devX11.c (revision 80104) +++ src/modules/X11/devX11.c (working copy) @@ -105,7 +105,7 @@ static Display *display; /* Display */ static char dspname[101]=""; static int screen; /* Screen */ -static Window rootwin; /* Root Window */ +static Window rootwin, group_leader; /* Root Window, Group leader */ static Visual *visual; /* Visual */ static int depth; /* Pixmap depth */ static int Vclass; /* Visual class */ @@ -1617,6 +1617,16 @@ PropModeReplace, (const unsigned char*) rlogo_icon, 2 + 99*77); + /* set the window group leader */ + XWMHints * hints; + hints = XAllocWMHints(); + if (hints) { + hints->window_group = group_leader; + hints->flags |= WindowGroupHint; + XSetWMHints(display, xd->window, hints); + XFree(hints); + } + /* set up protocols so that window manager sends */ /* me an event when user "destroys" window */ _XA_WM_PROTOCOLS = XInternAtom(display, "WM_PROTOCOLS", 0); @@ -2109,6 +2119,7 @@ if (numX11Devices == 0) { int fd = ConnectionNumber(display); /* Free Resources Here */ + XDestroyWindow(display, group_leader); while (nfonts--) R_XFreeFont(display, fontcache[nfonts].font); nfonts = 0; @@ -3133,6 +3144,9 @@ #endif screen = DefaultScreen(display); rootwin = DefaultRootWindow(display); + group_leader = XCreateSimpleWindow( /* never mapped or visible */ + display, rootwin, 0, 0, 1, 1, 0, 0, 0 + ); depth = DefaultDepth(display, screen); visual = DefaultVisual(display, screen); colormap = DefaultColormap(display, screen); -----------------------------------8<----------------------------------- Some very limited testing didn't seem to uncover any problems. -- Best regards, Ivan -------------- next part -------------- A non-text attachment was scrubbed... Name: groups.png Type: image/png Size: 4393 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20210323/b2552350/attachment.png>