julien.barnier at ens-lsh.fr
2008-Apr-28 14:40 UTC
[Rd] X11 window title setting in X11() Device (PR#11325)
--=-=-Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, I think I have found a very little bug in the new version of the X11() device in R 2.7.0, more precisely in the devX11.c file. The problem is that when you open a new window with X11(), the title of the window (the WM_NAME property) is not immediately set. It seems that the window is created, then it is displayed (mapped) with no title, and then the title is set. It is something absolutely invisible for the user, but it leads to problem for me because I use a window manager that relies on window titles to give them different attributes (I use it to make all my R Graphics windows floating). And due to the fact that the title is set after opening, my window manager rules don't apply anymore. I found a quick and dirty workaround which set the title immediately after the window opening if the =C2=ABtitle=C2=BB option in X11.options() is set. You will find the patch for devX11.c attached to this mail, it is just two lines moved before the call to X11_Open. Surely there could be something much better, but I am quite new to C and X11 programming... Here is my sessionInfo() : ,---- | R version 2.7.0 (2008-04-22)=20 | i486-pc-linux-gnu=20 |=20 | locale: | LC_CTYPE=3Dfr_FR.UTF-8;LC_NUMERIC=3DC;LC_TIME=3Dfr_FR.UTF-8;LC_COLLATE=3Dfr_FR.UTF-8;LC_MONETARY=3DC;LC_MESSAGES=3Dfr_FR.UTF-8;LC_PAPER=3Dfr_FR.UTF-8;LC_NAME=3DC;LC_ADDRESS=3DC;LC_TELEPHONE=3DC;LC_MEASUREMENT=3Dfr_FR.UTF-8;LC_IDENTIFICATION=3DC |=20 | attached base packages: | [1] grDevices utils datasets graphics stats methods base=20=20=20=20=20 |=20 | other attached packages: | [1] car_1.2-7 `---- Thanks for all your work ! Regards, Julien=20 --=-=-Content-Type: text/x-diff Content-Disposition: attachment; filename=devX11_patch.diff --- devX11.c.orig 2008-04-28 16:22:46.000000000 +0200 +++ devX11.c 2008-04-28 16:22:57.000000000 +0200 @@ -2225,6 +2225,9 @@ else strcpy(xd->symbolfamily,fn); } + strncpy(xd->title, title, 100); + xd->title[100] = '\0'; + /* Start the Device Driver and Hardcopy. */ if (!X11_Open(dd, xd, disp_name, width, height, @@ -2238,8 +2241,6 @@ xd->fill = 0xffffffff; /* this is needed to ensure that the first newpage does set whitecolor if par("bg") is not transparent */ - strncpy(xd->title, title, 100); - xd->title[100] = '\0'; #if BUG R_ProcessX11Events((void*) NULL); --=-=-=--
ripley at stats.ox.ac.uk
2008-Apr-29 08:00 UTC
[Rd] X11 window title setting in X11() Device (PR#11325)
Can you please give precise reproduction instructions -- you don't even tell us what the window manager is. I'd be willing to consider a workaround, but only if I can reproduce the problem (which appears to be a false assumption elsewhere in your setup). On Mon, 28 Apr 2008, julien.barnier at ens-lsh.fr wrote:> --=-=-> Content-Type: text/plain; charset=utf-8 > Content-Transfer-Encoding: quoted-printable > > Hi, > > I think I have found a very little bug in the new version of the X11() > device in R 2.7.0, more precisely in the devX11.c file. > > The problem is that when you open a new window with X11(), the title > of the window (the WM_NAME property) is not immediately set. It seems > that the window is created, then it is displayed (mapped) with no > title, and then the title is set.Which is perfectly valid in X11, so I don't see where the 'bug' is. R changes the title to reflect the window state, do the supplied 'title' is never actually used without decoration. R 2.6.x put up one title and then immediately changed it, but that was undocumented and not safe to rely on (as you found).> It is something absolutely invisible for the user, but it leads to > problem for me because I use a window manager that relies on window > titles to give them different attributes (I use it to make all my R > Graphics windows floating). And due to the fact that the title is set > after opening, my window manager rules don't apply anymore. > > I found a quick and dirty workaround which set the title immediately > after the window opening if the =C2=ABtitle=C2=BB option in X11.options() is > set. You will find the patch for devX11.c attached to this mail, it is > just two lines moved before the call to X11_Open. > > Surely there could be something much better, but I am quite new to C > and X11 programming... > > Here is my sessionInfo() : > > ,---- > | R version 2.7.0 (2008-04-22)=20 > | i486-pc-linux-gnu=20 > |=20 > | locale: > | LC_CTYPE=3Dfr_FR.UTF-8;LC_NUMERIC=3DC;LC_TIME=3Dfr_FR.UTF-8;LC_COLLATE=3D> fr_FR.UTF-8;LC_MONETARY=3DC;LC_MESSAGES=3Dfr_FR.UTF-8;LC_PAPER=3Dfr_FR.UTF-> 8;LC_NAME=3DC;LC_ADDRESS=3DC;LC_TELEPHONE=3DC;LC_MEASUREMENT=3Dfr_FR.UTF-8;> LC_IDENTIFICATION=3DC > |=20 > | attached base packages: > | [1] grDevices utils datasets graphics stats methods base=20> =20=20=20=20 > |=20 > | other attached packages: > | [1] car_1.2-7 > `---- > > Thanks for all your work ! > > Regards, > > Julien=20 > > > --=-=-> Content-Type: text/x-diff > Content-Disposition: attachment; filename=devX11_patch.diff > > --- devX11.c.orig 2008-04-28 16:22:46.000000000 +0200 > +++ devX11.c 2008-04-28 16:22:57.000000000 +0200 > @@ -2225,6 +2225,9 @@ > else strcpy(xd->symbolfamily,fn); > } > > + strncpy(xd->title, title, 100); > + xd->title[100] = '\0'; > + > /* Start the Device Driver and Hardcopy. */ > > if (!X11_Open(dd, xd, disp_name, width, height, > @@ -2238,8 +2241,6 @@ > xd->fill = 0xffffffff; /* this is needed to ensure that the > first newpage does set whitecolor > if par("bg") is not transparent */ > - strncpy(xd->title, title, 100); > - xd->title[100] = '\0'; > > #if BUG > R_ProcessX11Events((void*) NULL); > > --=-=-=-- > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
julien.barnier at ens-lsh.fr
2008-Apr-29 09:40 UTC
[Rd] X11 window title setting in X11() Device (PR#11325)
Hi,> Can you please give precise reproduction instructions -- you don't > even tell us what the window manager is. > I'd be willing to consider a workaround, but only if I can reproduce > the problem (which appears to be a false assumption elsewhere in your > setup).Yes, sorry, it is one of my first bug report so please forgive me for being incomplete. The window manager I use is dwm, which can be found at : http://www.suckless.org/wiki/dwm It is a lightweight tiled window manager with configuration by compilation. You can change settings by modifying the config.h file and recompiling dwm.c. The setting which cause problem in my config.h is the following : Rule rules[] =3D { /* class instance title tags ref isfloating */ { NULL, NULL, "R Graphics", NULL, True}, which makes every window whose title match the =C2=ABR Graphics=C2=BB substring to be considered as a floating window. If you use dwm with this configuration rule, launch R and open a graphics window, it will not be set as floating but will remain tiled (which is the default). The problem is that dwm applies the rule given above as soon as the window is mapped. But in R 2.7.0, when the window is mapped she doesn't have any title (it is assigned later), so the rule doesn't apply because the window is considered having no instance name, no class name (the WM_CLASS attribute) and no title.> Which is perfectly valid in X11, so I don't see where the 'bug' is. > > R changes the title to reflect the window state, do the supplied > title' is never actually used without decoration. R 2.6.x put up one > title and then immediately changed it, but that was undocumented and > not safe to rely on (as you found).You're perfectly right by saying that it is not a bug per se, it is just a small change which shouldn't affect the vast majority of users but those who rely on windows attributes to manage them. But maybe I am the only one in that case... Another workaround could be to give a class or instance name specific to the graphics windows. Thanks for your answer and sorry for the incomplete bug report. Regards, --=20 Julien Barnier Groupe de Recherche sur la Socialisation ENS Lettres et Sciences humaines, Lyon T=C3=A9l : 04 37 37 62 92