chiark / gitweb /
f9ca6e05409874b37a3b0b27e38f852d396a9e99
[ypp-sc-tools.web-live.git] / pctb / pages.c
1 /*
2  * Interaction with the YPP client via X11
3  */
4 /*
5  *  This is part of ypp-sc-tools, a set of third-party tools for assisting
6  *  players of Yohoho Puzzle Pirates.
7  * 
8  *  Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
9  * 
10  *  This program is free software: you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation, either version 3 of the License, or
13  *  (at your option) any later version.
14  * 
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  * 
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  * 
23  *  Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
24  *  are used without permission.  This program is not endorsed or
25  *  sponsored by Three Rings.
26  */
27
28 /*
29  * Only this file #includes the X11 headers, as they're quite
30  * pollutant of the namespace.
31  */
32
33 #include "structure.h"
34
35 #include <X11/Xlib.h>
36 #include <X11/extensions/XTest.h>
37 #include <X11/keysym.h>
38 #include <X11/Xutil.h>
39
40 #include <X11/extensions/XShm.h>
41 #include <sys/ipc.h>
42 #include <sys/shm.h>
43
44 CanonImage *page_images[MAX_PAGES];
45 int npages;
46
47 const char *ocean, *pirate;
48
49 static XWindowAttributes attr;
50 static Window id;
51 static Display *disp;
52 static struct timeval tv_startup;
53 static unsigned wwidth, wheight;
54 static int max_relevant_y= -1;
55
56 static XImage *shmim;
57 static XShmSegmentInfo shminfo;
58
59 DEBUG_DEFINE_DEBUGF(pages)
60
61 #define xassert(what)                                   \
62   ((what) ? (void)0 :                                   \
63    fatal("X11 operation unexpectedly failed."           \
64          " %s:%d: %s\n", __FILE__,__LINE__,#what))
65
66 static KeyCode keycode(KeySym sym) {
67   return XKeysymToKeycode(disp,sym);
68 }
69
70 void screenshot_startup(void) {
71   progress("starting...");
72   disp= XOpenDisplay(0);
73   if (!disp) fatal("Unable to open X11 display.");
74   sysassert(! gettimeofday(&tv_startup,0) );
75 }
76
77 /*---------- pager ----------*/
78
79 typedef RgbImage Snapshot;
80
81 static double last_input;
82 static const double min_update_allowance= 0.25;
83
84 static double timestamp(void) {
85   struct timeval tv;
86   
87   sysassert(! gettimeofday(&tv,0) );
88   double t= (tv.tv_sec - tv_startup.tv_sec) +
89             (tv.tv_usec - tv_startup.tv_usec) * 1e-6;
90   debugf("PAGING %f\n",t);
91   return t;
92 }
93 static void delay(double need_sleep) {
94   debugf("PAGING     delay %f\n",need_sleep);
95   sysassert(! usleep(need_sleep * 1e6) );
96 }
97
98 static void sync_after_input(void) {
99   xassert( XSync(disp, False) );
100   last_input= timestamp();
101 }
102
103 static void translate_coords_toroot(int wx, int wy, int *rx, int *ry) {
104   Window dummy;
105   xassert( XTranslateCoordinates(disp, id,attr.root, wx,wy, rx,ry, &dummy) );
106 }
107
108 static void check_client_window_all_on_screen(void) {
109   Rect onroot;
110   unsigned rwidth, rheight;
111   Window dummy;
112   unsigned bd, depth;
113   int rxpos, rypos;
114
115   xassert( XGetGeometry(disp,attr.root, &dummy, &rxpos,&rypos,
116                         &rwidth, &rheight,
117                         &bd,&depth) );
118   
119   translate_coords_toroot(0,0, &onroot.tl.x,&onroot.tl.y);
120   translate_coords_toroot(wwidth-1,wheight-1, &onroot.br.x,&onroot.br.y);
121   if (!(onroot.tl.x >= 0 &&
122         onroot.tl.y >= 0 &&
123         onroot.br.x < rwidth &&
124         onroot.br.y < rheight))
125     fatal("YPP client window is not entirely on the screen.");
126 }
127
128 static void check_not_disturbed(void) {
129   XEvent ev;
130   int r;
131   
132   for (;;) {
133     r= XCheckMaskEvent(disp, ~0, &ev);
134     if (r==False) return;
135
136     switch (ev.type) {
137     case VisibilityNotify:
138       if (ev.xvisibility.state != VisibilityUnobscured)
139         fatal("YPP client window has become obscured.");
140       break;
141     case ConfigureNotify:
142       check_client_window_all_on_screen();
143       break;
144     case FocusOut:
145       fatal("Focus left YPP client window.");
146       break;
147     case FocusIn:
148       warning("focus entered YPP client window ?!");
149       break;
150     default:
151       fatal("Received unexpected X11 event (type code %d)!", ev.type);
152     }
153   }
154 }      
155
156 static void send_key(KeySym sym) {
157   check_not_disturbed();
158   XTestFakeKeyEvent(disp, keycode(sym),1, 10);
159   XTestFakeKeyEvent(disp, keycode(sym),0, 10);
160 }
161 static void mouse_1_updown_here(void) {
162   check_not_disturbed();
163   XTestFakeButtonEvent(disp,1,1, 50);
164   XTestFakeButtonEvent(disp,1,0, 50);
165 }
166 static void mouse_1_updown(int x, int y) {
167   check_not_disturbed();
168   int screen= XScreenNumberOfScreen(attr.screen);
169   int xpos, ypos;
170   translate_coords_toroot(x,y, &xpos,&ypos);
171   XTestFakeMotionEvent(disp, screen, xpos,ypos, 0);
172   mouse_1_updown_here();
173 }
174
175 static int pgupdown;
176
177 static void send_pgup_many(void) {
178   int i;
179   for (i=0; i<25; i++) {
180     send_key(XK_Prior);
181     pgupdown--;
182   }
183   debugf("PAGING   PageUp x %d\n",i);
184   sync_after_input();
185 }
186 static void send_pgdown(void) {
187   send_key(XK_Next);
188   pgupdown++;
189   debugf("PAGING   PageDown\n");
190   sync_after_input();
191 }
192 static void send_pgdown_torestore(void) {
193   debugf("PAGING   PageDown x %d\n", -pgupdown);
194   while (pgupdown < 0) {
195     send_key(XK_Next);
196     pgupdown++;
197   }
198   sync_after_input();
199 }
200
201 static void free_snapshot(Snapshot **io) {
202   free(*io);
203   *io= 0;
204 }
205
206 #define SAMPLEMASK 0xfful
207
208 typedef struct {
209   int lshift, rshift;
210 } ShMask;
211
212 static void compute_shift_mask(ShMask *sm, unsigned long ximage_mask) {
213   sm->lshift= 0;
214   sm->rshift= 0;
215   
216   for (;;) {
217     if (ximage_mask <= (SAMPLEMASK>>1)) {
218       sm->lshift++;  ximage_mask <<= 1;
219     } else if (ximage_mask > SAMPLEMASK) {
220       sm->rshift++;  ximage_mask >>= 1;
221     } else {
222       break;
223     }
224     assert(!(sm->lshift && sm->rshift));
225   }
226   assert(sm->lshift < LONG_BIT);
227   assert(sm->rshift < LONG_BIT);
228 }
229
230 static void rtimestamp(double *t, const char *wh) {
231   double n= timestamp();
232   debugf("PAGING                INTERVAL %f  %s\n", n-*t, wh);
233   *t= n;
234 }
235
236 static void snapshot(Snapshot **output) {
237   XImage *im_use, *im_free=0;
238
239   ShMask shiftmasks[3];
240
241   debugf("PAGING   snapshot\n");
242
243   double begin= timestamp();
244   if (shmim) {
245     rtimestamp(&begin, "XShmGetImage before");
246     xassert( XShmGetImage(disp,id,shmim, 0,0, AllPlanes) );
247     rtimestamp(&begin, "XShmGetImage");
248
249     size_t dsz= shmim->bytes_per_line * shmim->height;
250     im_use= im_free= mmalloc(sizeof(*im_use) + dsz);
251     *im_free= *shmim;
252     im_free->data= (void*)(im_free+1);
253     memcpy(im_free->data, shmim->data, dsz);
254     rtimestamp(&begin, "mmalloc/memcpy");
255   } else {
256     rtimestamp(&begin, "XGetImage before");
257     xassert( im_use= im_free=
258              XGetImage(disp,id, 0,0, wwidth,wheight, AllPlanes, ZPixmap) );
259     rtimestamp(&begin, "XGetImage");
260   }
261
262 #define COMPUTE_SHIFT_MASK(ix, rgb) \
263   compute_shift_mask(&shiftmasks[ix], im_use->rgb##_mask)
264   COMPUTE_SHIFT_MASK(0, red);
265   COMPUTE_SHIFT_MASK(1, green);
266   COMPUTE_SHIFT_MASK(2, blue);
267   
268   if (!*output)
269     *output= alloc_rgb_image(wwidth, wheight);
270
271   rtimestamp(&begin, "compute_shift_masks+alloc_rgb_image");
272
273   int x,y,i;
274   unsigned char *op= (*output)->data;
275   for (y=0; y<wheight; y++) {
276     for (x=0; x<wwidth; x++) {
277       long xrgb= XGetPixel(im_use,x,y);
278       for (i=0; i<3; i++) {
279         unsigned long sample=
280           ((xrgb << shiftmasks[i].lshift) >> shiftmasks[i].rshift)
281           & SAMPLEMASK;
282         *op++= sample;
283       }
284     }
285   }
286
287   rtimestamp(&begin,"w*h*XGetPixel");
288   if (im_free)
289     XDestroyImage(im_free);
290   
291   rtimestamp(&begin,"XDestroyImage");
292   check_not_disturbed();
293
294   debugf("PAGING   snapshot done.\n");
295 }
296
297 static int identical(const Snapshot *a, const Snapshot *b) {
298   if (!(a->w == b->w &&
299         a->h == b->h))
300     return 0;
301
302   int compare_to= a->h;
303   if (max_relevant_y>=0 && compare_to > max_relevant_y)
304     compare_to= max_relevant_y;
305   
306   return !memcmp(a->data, b->data, a->w * 3 * compare_to);
307 }
308
309 static void wait_for_stability(Snapshot **output,
310                                const Snapshot *previously,
311                                void (*with_keypress)(void),
312                                const char *fmt, ...)
313      FMT(4,5);
314
315 static void wait_for_stability(Snapshot **output,
316                                const Snapshot *previously,
317                                void (*with_keypress)(void),
318                                const char *fmt, ...) {
319   va_list al;
320   va_start(al,fmt);
321
322   Snapshot *last=0;
323   int nidentical=0;
324   /* waits longer if we're going to return an image identical to previously
325    * if previously==0, all images are considered identical to it */
326
327   char *doing;
328   sysassert( vasprintf(&doing,fmt,al) >=0 );
329
330   debugf("PAGING  wait_for_stability"
331           "  last_input=%f previously=%p `%s'\n",
332           last_input, previously, doing);
333
334   double min_interval= 25000; /*us*/
335   for (;;) {
336     progress_spinner("%s",doing);
337     
338     double since_last_input= timestamp() - last_input;
339     double this_interval= min_interval - since_last_input;
340
341     if (this_interval >= 0)
342       usleep(this_interval);
343
344     snapshot(output);
345
346     if (!last) {
347       debugf("PAGING  wait_for_stability first...\n");
348       last=*output; *output=0;
349     } else if (!identical(*output,last)) {
350       debugf("PAGING  wait_for_stability changed...\n");
351       free_snapshot(&last); last=*output; *output=0;
352       nidentical=0;
353       if (!with_keypress) {
354         min_interval *= 3.0;
355         min_interval += 0.5;
356       }
357     } else {
358       nidentical++;
359       int threshold=
360         !previously ? 3 :
361         identical(*output,previously) ? 5
362         : 1;
363       debugf("PAGING  wait_for_stability nidentical=%d threshold=%d\n",
364               nidentical, threshold);
365       if (nidentical >= threshold)
366         break;
367
368       min_interval += 0.5;
369       min_interval *= 2.0;
370     }
371
372     if (with_keypress)
373       with_keypress();
374   }
375
376   free_snapshot(&last);
377   free(doing);
378   debugf("PAGING  wait_for_stability done.\n");
379   va_end(al);
380 }
381
382 static void raise_and_get_details(void) {
383   int evbase,errbase,majver,minver;
384   int wxpos, wypos;
385   unsigned bd,depth;
386
387   progress("raising and checking YPP client window...");
388
389   debugf("PAGING raise_and_get_details\n");
390
391   int xtest= XTestQueryExtension(disp, &evbase,&errbase,&majver,&minver);
392   if (!xtest) fatal("X server does not support the XTEST extension.");
393
394   xassert( XRaiseWindow(disp, id) );
395   /* in case VisibilityNotify triggers right away before we have had a
396    * change to raise; to avoid falsely detecting lowering in that case */
397   
398   xassert( XSelectInput(disp, id,
399                         StructureNotifyMask|
400                         VisibilityChangeMask
401                         ) );
402
403   xassert( XRaiseWindow(disp, id) );
404   /* in case the window was lowered between our Raise and our SelectInput;
405    * to avoid failing to detect that lowering */
406
407   xassert( XGetWindowAttributes(disp, id, &attr) );
408   xassert( XGetGeometry(disp,id, &attr.root,
409                         &wxpos,&wypos, &wwidth,&wheight,
410                         &bd,&depth) );
411
412   if (!(wwidth >= 320 && wheight >= 320))
413     fatal("YPP client window is implausibly small?");
414
415   check_client_window_all_on_screen();
416
417   Bool shmpixmaps=0;
418   int major=0,minor=0;
419   int shm= XShmQueryVersion(disp, &major,&minor,&shmpixmaps);
420   debugf("PAGING shm=%d %d.%d pixmaps=%d\n",shm,major,minor,shmpixmaps);
421   if (shm) {
422     xassert( shmim= XShmCreateImage(disp, attr.visual, attr.depth, ZPixmap,
423                                     0,&shminfo, wwidth,wheight) );
424
425     sigset_t oldset, all;
426     sigfillset(&all);
427     sysassert(! sigprocmask(SIG_BLOCK,&all,&oldset) );
428
429     int pfd[2];
430     pid_t cleaner;
431     sysassert(! pipe(pfd) );
432     sysassert( (cleaner= fork()) != -1 );
433     if (!cleaner) {
434       sysassert(! close(pfd[1]) );
435       for (;;) {
436         int r= read(pfd[0], &shminfo.shmid, sizeof(shminfo.shmid));
437         if (!r) exit(0);
438         if (r==sizeof(shminfo.shmid)) break;
439         assert(r==-1 && errno==EINTR);
440       }
441       for (;;) {
442         char bc;
443         int r= read(pfd[0],&bc,1);
444         if (r>=0) break;
445         assert(r==-1 && errno==EINTR);
446       }
447       sysassert(! shmctl(shminfo.shmid,IPC_RMID,0) );
448       exit(0);
449     }
450     sysassert(! close(pfd[0]) );
451
452     sysassert(! sigprocmask(SIG_SETMASK,&oldset,0) );
453
454     assert(shmim->height == wheight);
455     sysassert( (shminfo.shmid=
456                 shmget(IPC_PRIVATE, shmim->bytes_per_line * wheight,
457                        IPC_CREAT|0600)) >= 0 );
458
459     sysassert( write(pfd[1],&shminfo.shmid,sizeof(shminfo.shmid)) ==
460                sizeof(shminfo.shmid) );
461     sysassert( shminfo.shmaddr= shmat(shminfo.shmid,0,0) );
462     shmim->data= shminfo.shmaddr;
463     shminfo.readOnly= False;
464     xassert( XShmAttach(disp,&shminfo) );
465
466     close(pfd[1]); /* causes IPC_RMID */
467   }
468 }
469
470 static void set_focus_commodity(void) {
471   int screen= XScreenNumberOfScreen(attr.screen);
472
473   progress("taking control of YPP client window...");
474
475   debugf("PAGING set_focus\n");
476
477   mouse_1_updown(160,160);
478   sync_after_input();
479
480   delay(0.5);
481   xassert( XSelectInput(disp, id,
482                         StructureNotifyMask|
483                         VisibilityChangeMask|
484                         FocusChangeMask
485                         ) );
486
487   int xpos,ypos;
488   translate_coords_toroot(10,10, &xpos,&ypos);
489   XTestFakeMotionEvent(disp,screen, xpos,ypos, 0);
490
491   sync_after_input();
492
493   debugf("PAGING raise_and_set_focus done.\n");
494 }
495
496 static CanonImage *convert_page(Snapshot *sn) {
497   CanonImage *im;
498
499   fwrite_ppmraw(screenshot_file, sn);
500
501   unsigned char *pixel= sn->data;
502   CANONICALISE_IMAGE(im, sn->w, sn->h, {
503     rgb=
504       (pixel[0] << 16) |
505       (pixel[1] <<  8) |
506       (pixel[2]      );
507     pixel += 3;
508   });
509     
510   sysassert(!ferror(screenshot_file));
511   sysassert(!fflush(screenshot_file));
512
513   return im;
514 }
515
516 static void prepare_ypp_client(void) {
517   CanonImage *test;
518   Snapshot *current=0;
519   
520   /* find the window and check it's on the right kind of screen */
521   raise_and_get_details();
522   wait_for_stability(&current,0,0, "checking current YPP client screen...");
523
524   test= convert_page(current);
525   find_structure(test, &max_relevant_y);
526   check_correct_commodities();
527   Rect sunshine= find_sunshine_widget();
528
529   progress("poking client...");
530   mouse_1_updown((sunshine.tl.x   + sunshine.br.x) / 2,
531                  (sunshine.tl.y*9 + sunshine.br.y) / 10);
532
533   free(test);
534
535   wait_for_stability(&current,0,0, "checking basic YPP client screen...");
536   mouse_1_updown(250, wheight-10);
537   mouse_1_updown_here();
538   mouse_1_updown_here();
539   XSync(disp,False);
540   check_not_disturbed();
541   send_key(XK_slash);
542   send_key(XK_w);
543   send_key(XK_Return);
544   sync_after_input();
545
546   Snapshot *status=0;
547   wait_for_stability(&status,current,0, "awaiting status information...");
548   free_snapshot(&current);
549   free_snapshot(&status);
550 }
551
552 void take_screenshots(void) {
553   Snapshot *current=0, *last=0;
554
555   prepare_ypp_client();
556   
557   /* page to the top - keep pressing page up until the image stops changing */
558   set_focus_commodity();
559   wait_for_stability(&current,0, send_pgup_many,
560                      "paging up to top of commodity list...");
561
562   /* now to actually page down */
563   for (;;) {
564     debugf("paging page %d\n",npages);
565
566     if (!(npages < MAX_PAGES))
567       fatal("Paging down seems to generate too many pages - max is %d.",
568             MAX_PAGES);
569     
570     page_images[npages]= convert_page(current);
571     free_snapshot(&last); last=current; current=0;
572
573     debugf("PAGING page %d converted\n",npages);
574
575     wait_for_stability(&current,last, 0,
576                        "collecting screenshot of page %d...",
577                        npages+1);
578
579     if (npages &&  /* first pagedown doesn't do much */
580         identical(current,last)) {
581       free_snapshot(&current);
582       break;
583     }
584
585     send_pgdown();
586     npages++;
587   }
588   progress("finishing with the YPP client...");
589   send_pgdown_torestore();
590
591   debugf("PAGING all done.\n");
592   progress_log("collected %d screenshots.",npages);
593 }    
594
595 void take_one_screenshot(void) {
596   Snapshot *current=0;
597
598   prepare_ypp_client();
599   wait_for_stability(&current,0,0, "taking screenshot...");
600   page_images[0]= convert_page(current);
601   npages= 1;
602   progress_log("collected single screenshot.");
603 }
604
605 void set_yppclient_window(unsigned long wul) {
606   id= wul;
607 }
608
609 DEBUG_DEFINE_SOME_DEBUGF(findypp,debugfind)
610
611 static int nfound;
612 static Atom wm_name;
613 static int screen;
614
615 static void findypp_recurse(int depth, int targetdepth, Window w) {
616   unsigned int nchildren;
617   int i;
618   Window *children=0;
619   Window gotroot, gotparent;
620
621   static const char prefix[]= "Puzzle Pirates - ";
622   static const char onthe[]= " on the ";
623   static const char suffix[]= " ocean";
624 #define S(x) ((int)sizeof((x))-1)
625
626   debugfind("FINDYPP %d/%d screen %d  %*s %lx",
627             depth,targetdepth,screen,
628             depth,"",(unsigned long)w);
629   
630   if (depth!=targetdepth) {
631     xassert( XQueryTree(disp,w,
632                         &gotroot,&gotparent,
633                         &children,&nchildren) );
634     debugfind(" nchildren=%d\n",nchildren);
635   
636     for (i=0; i<nchildren; i++) {
637       Window child= children[i];
638       findypp_recurse(depth+1, targetdepth, child);
639     }
640     XFree(children);
641     return;
642   }
643     
644
645   int gotfmt;
646   Atom gottype;
647   unsigned long len, gotbytesafter;
648   char *title;
649   unsigned char *gottitle=0;
650   xassert( !XGetWindowProperty(disp,w, wm_name,0,512, False,
651                                AnyPropertyType,&gottype, &gotfmt, &len,
652                                &gotbytesafter, &gottitle) );
653   title= (char*)gottitle;
654
655   if (DEBUGP(findypp)) {
656     debugfind(" gf=%d len=%lu gba=%lu \"", gotfmt,len,gotbytesafter);
657     char *p;
658     for (p=title; p < title+len; p++) {
659       char c= *p;
660       if (c>=' ' && c<=126) fputc(c,debug);
661       else fprintf(debug,"\\x%02x",c & 0xff);
662     }
663     fputs("\": ",debug);
664   }
665
666 #define REQUIRE(pred)                                                   \
667   if (!(pred)) { debugfind(" failed test  %s\n", #pred); return; }      \
668   else
669
670   REQUIRE( gottype!=None );
671   REQUIRE( len );
672   REQUIRE( gotfmt==8 );
673
674   REQUIRE( len >= S(prefix) + 1 + S(onthe) + 1 + S(suffix) );
675
676   char *spc1= strchr(  title        + S(prefix), ' ');  REQUIRE(spc1);
677   char *spc2= strrchr((title + len) - S(suffix), ' ');  REQUIRE(spc2);
678
679   REQUIRE( (title + len) - spc1  >= S(onthe)  + S(suffix) );
680   REQUIRE(  spc2         - title >= S(prefix) + S(onthe) );
681
682   REQUIRE( !memcmp(title,                   prefix, S(prefix)) );
683   REQUIRE( !memcmp(title + len - S(suffix), suffix, S(suffix))  );
684   REQUIRE( !memcmp(spc1,                    onthe,  S(onthe))  );
685
686 #define ASSIGN(what, start, end)                        \
687   what= masprintf("%.*s", (int)((end)-(start)), start); \
688   if (o_##what) REQUIRE( !strcasecmp(o_##what, what) ); \
689   else
690
691   ASSIGN(ocean,  spc1 + S(onthe),   (title + len) - S(suffix));
692   ASSIGN(pirate, title + S(prefix),  spc1);
693
694   debugfind(" YES!\n");
695   id= w;
696   nfound++;
697   progress_log("found YPP client (0x%lx):"
698                " %s ocean - %s.",
699                (unsigned long)id, ocean, pirate);
700 }
701
702 void find_yppclient_window(void) {
703   int targetdepth;
704
705   nfound=0;
706   
707   if (id) return;
708   
709   progress("looking for YPP client window...");
710
711   xassert( (wm_name= XInternAtom(disp,"WM_NAME",True)) != None);
712
713   for (targetdepth=1; targetdepth<4; targetdepth++) {
714     for (screen=0; screen<ScreenCount(disp); screen++) {
715       debugfind("FINDYPP screen %d\n", screen);
716       findypp_recurse(0,targetdepth, RootWindow(disp,screen));
717     }
718     if (nfound) break;
719   }
720
721   if (nfound>1)
722     fatal("Found several possible YPP clients.   Close one,\n"
723           " disambiguate with --pirate or --ocean,"
724           " or specify --window-id.\n");
725   if (nfound<1)
726     fatal("Did not find %sYPP client."
727           " Use --window-id and/or report this as a fault.\n",
728           o_ocean || o_pirate ? "matching ": "");
729 }