|
From: Dima K. <gn...@di...> - 2022-08-10 21:31:19
|
Hi. I'm using the x11 terminal to plot into an existing window:
set terminal x11 window XID
Overall it works really well. I'm seeing an issue when the requested
window doesn't exist: gnuplot simply ignores the request, and pops up a
new X window, as usual. This is never what the user intends, I think.
A less made-up scenario is what I actually encountered when trying to
use this feature: I made a new window, and asked gnuplot to plot into
it. This didn't work because my new target window hasn't been created
YET.
Trying to debug this, I added some more diagnostics to gplt_x11.c
(attached; these should be good-enough to merge). I see that the
failing sequence is:
- in pr_window() gplt_x11.c calls XGetWindowAttributes() on the
requested window. This is the first time gnuplot does anything with
the requested window
- If the window already exists, this succeeds, and we continue, happily.
If not, the error handler is invoked instead. Here's the diagnostic
output produced with DEBUG:
gplt_x11.c:1655 psp->external_container = 0x2400005
gplt_x11.c:6679 (pr_window)
gplt_x11.c:6683 was asked to plot externally...
gplt_x11.c:4354 Received X error: error_code=BadWindow request_code=X_GetWindowAttributes minor_code=0
gplt_x11.c:7230 Add plot to remove FIFO queue called.
gplt_x11.c:7269 -> Added an element to FIFO queue.
gplt_x11.c:6692 making plot window
gplt_x11.c:4354 Received X error: error_code=BadWindow request_code=X_CreateWindow minor_code=0
gplt_x11.c:7230 Add plot to remove FIFO queue called.
gplt_x11.c:4354 Received X error: error_code=BadWindow request_code=X_ChangeWindowAttributes minor_code=0
gplt_x11.c:7230 Add plot to remove FIFO queue called.
gplt_x11.c:7269 -> Added an element to FIFO queue.
gplt_x11.c:4354 Received X error: error_code=BadWindow request_code=X_ChangeProperty minor_code=0
gplt_x11.c:7230 Add plot to remove FIFO queue called.
gplt_x11.c:4354 Received X error: error_code=BadWindow request_code=X_ChangeProperty minor_code=0
gplt_x11.c:7230 Add plot to remove FIFO queue called.
gplt_x11.c:4354 Received X error: error_code=BadWindow request_code=X_ChangeProperty minor_code=0
gplt_x11.c:7230 Add plot to remove FIFO queue called.
gplt_x11.c:4354 Received X error: error_code=BadWindow request_code=X_ChangeWindowAttributes minor_code=0
gplt_x11.c:7230 Add plot to remove FIFO queue called.
gplt_x11.c:4354 Received X error: error_code=BadWindow request_code=X_ChangeWindowAttributes minor_code=0
gplt_x11.c:7230 Add plot to remove FIFO queue called.
gplt_x11.c:6795 term_number is -1
gplt_x11.c:4778 Cursors reset
gplt_x11.c:7321 Processed element in remove FIFO queue.
gplt_x11.c:1209 Delete plot -1
gplt_x11.c:1233 Destroy window 0x36000fe
gplt_x11.c:7321 Processed element in remove FIFO queue.
gplt_x11.c:7063 psp->external_container = None
...
The line numbers are off, since I had some extra diagnostic code. We
do see that X errors are received for every request that touches the
not-yet-existing window, the error handler does some complex thing I
don't yet understand, and eventually we psp->external_container =
None, i.e. we give up on plotting to the requested window, and create
a new one, as usual.
Would it not make more sense for gplt_x11 to retry
XGetWindowAttributes() call until the requested window exists? I'm not
familiar with Xlib error handling, and this doesn't look completely
trivial, so I wanted to ask here first. Anybody here have experience
with Xlib, and suggestions on the "right" way to implement that?
Thanks
|