Drew Frank
2011-Jun-16 23:53 UTC
[Rd] X11 device windows are spawned with empty WM_NAME property
Hello, I've noticed that X11 device windows (the ones that pop up when I plot something on Linux) aren't assigned any WM_NAME property until after they've been spawned. This causes problems for users of tiling window managers, who may wish to use the WM_NAME property to decide whether to float or tile the window. If I create a plot and then examine the window properties with xprop, I see something like the following: WM_NAME(STRING) = "R Graphics: Device 2 (ACTIVE)". However, by instructing my window manager (xmonad) to float all windows with a matching name, I can tell that when the window was created its WM_NAME property was empty. Is this behavior intended? Would be it be reasonable to instead create windows with a generic name like "R Graphics" prior to updating them with the device number and active/inactive status? I'm not familiar with the R code base, but I found that creating a plot results in a call to the function in_do_X11 in the file src/modules/X11/devX11.c. In that function (around like 2869) there is code to parse out the window title from the SEXP args parameter, and it always seems to parse out an empty string. If I manually assign title="R Graphics" at that point, I am able to successfully float R plot windows based on their WM_NAME. (line numbers based on SVN revision 56131) Is this actually an issue that needs fixing? Should I create a bug report for this? Thanks, Drew [[alternative HTML version deleted]]
peter dalgaard
2011-Jun-17 12:27 UTC
[Rd] X11 device windows are spawned with empty WM_NAME property
On Jun 17, 2011, at 01:53 , Drew Frank wrote:> Hello, > > I've noticed that X11 device windows (the ones that pop up when I plot > something on Linux) aren't assigned any WM_NAME property until after they've > been spawned. This causes problems for users of tiling window managers, who > may wish to use the WM_NAME property to decide whether to float or tile the > window. > > If I create a plot and then examine the window properties with xprop, I see > something like the following: WM_NAME(STRING) = "R Graphics: Device 2 > (ACTIVE)". However, by instructing my window manager (xmonad) to float all > windows with a matching name, I can tell that when the window was created > its WM_NAME property was empty. > > Is this behavior intended? Would be it be reasonable to instead create > windows with a generic name like "R Graphics" prior to updating them with > the device number and active/inactive status? > > I'm not familiar with the R code base, but I found that creating a plot > results in a call to the function in_do_X11 in the file > src/modules/X11/devX11.c. In that function (around like 2869) there is code > to parse out the window title from the SEXP args parameter, and it always > seems to parse out an empty string. If I manually assign title="R Graphics" > at that point, I am able to successfully float R plot windows based on their > WM_NAME. (line numbers based on SVN revision 56131) > > Is this actually an issue that needs fixing? Should I create a bug report > for this? >A well-tested patch might be considered, but beware of the demons... Notice that you can actually set the title via X11(title="Foo's bar"). If you do that, it won't display the device number. So (a) you wouldn't want to destroy that feature, and (b) how does the code that inserts the "Device 2" bit know that it can do so? By checking for an empty title? (Yup). I notice that the initial title string could contain formatting characters, so possibly, what you really want to do is to default it to "R Graphics: Device %d"). Something of the sort is already happening with the quartz() device.> Thanks, > Drew > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel-- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Drew Frank
2011-Jun-17 21:05 UTC
[Rd] X11 device windows are spawned with empty WM_NAME property
On Fri, Jun 17, 2011 at 1:57 PM, Drew Frank <ajfrank at ics.uci.edu> wrote:> On Fri, Jun 17, 2011 at 7:26 AM, peter dalgaard <pdalgd at gmail.com> wrote: >> >> On Jun 17, 2011, at 15:32 , Prof Brian Ripley wrote: >> >>> >> >>> Is this behavior intended? ?Would be it be reasonable to instead create >> >>> windows with a generic name like "R Graphics" prior to updating them with >> >>> the device number and active/inactive status? >> > >> > Yes, no. >> > >> >> Well, "yes, maybe", I'd say. If the WM insists on looking at the title, it makes some pragmatic sense for the user to set it to a generic name that the WM can recognize. >> >> However, on revisiting this, the obvious fix/workaround is just to set >> >> X11.options(title="R Graphics: Device %d") >> >> and the user can do this in his/her startup files. No need to inflict it on every user with any WM. >> >> -- >> Peter Dalgaard >> Center for Statistics, Copenhagen Business School >> Solbjerg Plads 3, 2000 Frederiksberg, Denmark >> Phone: (+45)38153501 >> Email: pd.mes at cbs.dk ?Priv: PDalgd at gmail.com >>Thank you Peter and Brian for your replies.? The X11.options workaround is effective, and I'd be happy to make use of it. That said, after reading your replies I agree that the "correct" thing to do would be for the WM to match on WM_CLASS, which is currently not set.? I checked out the R-devel trunk and was preparing a patch to set WM_CLASS when I noticed that Brian already committed code to do this in r56008. ?However, the code is wrapped in an "#ifndef USE_Xt", with the comment "/* For those too idle to make use of Xt (PR#14588) */". When I compile, USE_Xt is set so this code isn't executed and WM_CLASS is never set. ?Is it supposed to be set somewhere else? Thank you, Drew