From: Ben A. <bpa...@ma...> - 2009-01-30 12:48:09
|
On Jan 29, 2009, at 4:13 PM, Ethan Merritt wrote: > On Thursday 29 January 2009 12:32:29 Ben Abbott wrote: >> >> On Dec 29, 2008, at 12:15 AM, Ethan A Merritt wrote: >> >>> On Sunday 28 December 2008, Ben Abbott wrote: >>>> >>>> On Dec 28, 2008, at 9:10 PM, Ethan A Merritt wrote: >>>> >>>>> On Sunday 28 December 2008, Ben Abbott wrote: >>>>> >>>> >>>>>> *SNIP* >>>>>> By the way, it would really be cool if there was a method by >>>>>> which >>>>>> the >>>>>> size and position of a plot window could be determined. That way >>>>>> if a >>>>>> user moves or resizes a window Octave could do some checking and >>>>>> have >>>>>> some awareness of such (I'd be stunned if such were possible, but >>>>>> thought I'd ask). >>>>> >>>>> You can do that with a call into xlib; you don't need any special >>>>> code in gnuplot for that. You should be able to get all the info >>>>> you'd get from the command line using "xwininfo" >>>> >>>> hmmm ... that may be quite useful. >>>> >>>> xwininfo: Window id: 0xc00008 "Figure 1" >>>> >>>> Absolute upper-left X: 440 >>>> Absolute upper-left Y: 128 >>>> Relative upper-left X: 0 >>>> Relative upper-left Y: 22 >>>> Width: 560 >>>> Height: 493 >>>> Depth: 24 >>>> Visual Class: TrueColor >>>> Border width: 0 >>>> Class: InputOutput >>>> Colormap: 0x21 (installed) >>>> Bit Gravity State: ForgetGravity >>>> Window Gravity State: NorthWestGravity >>>> Backing Store State: NotUseful >>>> Save Under State: no >>>> Map State: IsViewable >>>> Override Redirect State: no >>>> Corners: +440+128 -440+128 -440-279 +440-279 >>>> -geometry 560x493+440+106 >>>> >>>> Unfortunately, the height includes the portion needed to display >>>> the >>>> cursor's coordinates ... sigh :-( >>> >>> That extra height is equal to term->v_char. This quantity is not >>> currently exported as a user variable, but it would be trivial to do >>> so. >>> Do you want it? Its name would be GPVAL_TERM_VCHAR. >> >> I'm back hoping to better understand what is needed to determine the >> position of a specific gnuplot x11 window. I can see how xwininfo can >> be used, but how do I determine the window id (0xc00008 in the >> instance above)? Would it be necessary to patch gnuplot? > > The usual way is to make successive requests to the window mananger > asking it to step through all the current windows on the display, > and check each one to see if it is the one you want. That does not > require any cooperation or modification of the program that created > the window in the first place. > > It would also be possible to modify gnuplot_x11 so that it reports > back the id of each new plot window that it opens. The would involve > modifying gplt_x11.c, mouse.c, and perhaps x11.trm, but I think it > would not be difficult. > >> Regarding the proposed GPVAL_TERM_VCHAR, how would be be accessed? > > It would be just like any of the other internally-maintained > variables. > The two obvious ones are > > show GPVAL_TERM_VCHAR > or > set print "my/named/pipe/or/other/file" > print "term->char =", GPVAL_TERM_VCHAR > unset print Presently, Octave uses gnuplot's ability to detect a mouse click in the window. The mouse coordinates are returned to octave, via the gnuplot commands below. pause mouse any; if (exists("MOUSE_KEY") && exists("MOUSE_X")) print "OCTAVE: ", MOUSE_X, MOUSE_Y, MOUSE_KEY; else print "0 0 -1" Then octave uses regexp to pick the result out. For more info see the link below to the Octave script that does the job. http://hg.savannah.gnu.org/hgweb/octave/file/4385bb503467/scripts/plot/__gnuplot_ginput__.m I assume GPVAL_TERM_VCHAR would/could be handled in the same way. Could the size and position of the x11 plot window be determined in a similar manner (on the gnuplot end)? Of course, no pause would be required, but I assume some gnuplot command would be needed. Either that or could another internally-maintained variable be created to hold a window's x11 id? ... if so would this work for wxt as well? Ben |