3 /* This module, and the entire FvwmDebug program, and the concept for
4 * interfacing this module to the Window Manager, are all original work
7 * Copyright 1994, Robert Nation. No guarantees or warantees or anything
8 * are provided or implied in any way whatsoever. Use this program at your
9 * own risk. Permission to use this program for any purpose is given,
10 * as long as the copyright is kept intact. */
12 /* This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include "libs/ftime.h"
37 #include "FvwmOldDebug.h"
39 #include "fvwm/fvwm.h"
40 #include "libs/Module.h"
41 #include "libs/vpacket.h"
42 #include "libs/System.h"
51 ** spawn_xtee - code to execute xtee from a running executable &
52 ** redirect stdout & stderr to it. Currently sends both to same xtee,
53 ** but you rewrite this to spawn off 2 xtee's - one for each stream.
56 pid_t
spawn_xtee(void)
62 setvbuf(stdout
,NULL
,_IOLBF
,0); /* line buffered */
67 fprintf(stderr
, "ERROR ERRATA -- Failed to create pipe for xtee.\n");
72 argarray
[1] = "-nostdout";
75 if (!(pid
= fork())) /* child */
77 dup2(PIPE
[0], STDIN_FILENO
);
80 execvp("xtee",argarray
);
81 exit(1); /* shouldn't get here... */
85 if (ReapChildrenPid(pid
) != pid
)
87 dup2(PIPE
[1], STDOUT_FILENO
);
88 dup2(PIPE
[1], STDERR_FILENO
);
100 * main - start of module
103 int main(int argc
, char **argv
)
105 const char *temp
, *s
;
107 /* Save our program name - for error messages */
109 s
=strrchr(argv
[0], '/');
113 MyName
= safemalloc(strlen(temp
)+2);
115 strcat(MyName
, temp
);
117 if((argc
< 6)||(argc
> 8)) {
118 fprintf(stderr
,"%s Version %s should only be executed by fvwm!\n",MyName
,
125 if (!(strcmp(argv
[6], "-v")))
129 output
= fopen( argv
[6], "w" );
132 fprintf(stderr
,"%s Version %s: Failed to open %s\n",
133 MyName
,VERSION
,argv
[6]);
142 output
= fopen( argv
[7], "w" );
145 fprintf(stderr
,"%s Version %s: Failed to open %s\n",
146 MyName
,VERSION
,argv
[7]);
152 if (!(strcmp(argv
[7], "-v")))
156 fprintf(stderr
,"%s Version %s received two filename args!\n",
166 /* Dead pipe == Fvwm died */
167 signal(SIGPIPE
, DeadPipe
);
169 fd
[0] = atoi(argv
[1]);
170 fd
[1] = atoi(argv
[2]);
176 /* Data passed in command line */
177 fprintf(output
,"Application Window 0x%s\n",argv
[4]);
178 fprintf(output
,"Application Context %s\n",argv
[5]);
180 fd_width
= GetFdWidth();
182 /* select all extended messages */
183 SetMessageMask(fd
, M_EXTENDED_MSG
| MAX_XMSG_MASK
);
185 /* Create a list of all windows */
186 /* Request a list of all windows,
187 * wait for ConfigureWindow packets */
188 SendInfo(fd
,"Send_WindowList",0);
190 /* tell fvwm we're running */
191 SendFinishedStartupNotification(fd
);
201 * Loop - wait for data to process
204 void Loop(const int *fd
)
207 FvwmPacket
* packet
= ReadFvwmPacket(fd
[1]);
208 if ( packet
== NULL
)
210 process_message( packet
->type
, packet
->body
);
218 * Process message - examines packet types, and takes appropriate action
221 void process_message(unsigned long type
, const unsigned long *body
)
226 fprintf(output
,"new page\n");
230 fprintf(output
,"new desk\n");
233 case M_OLD_ADD_WINDOW
:
234 fprintf(output
,"Old Add Window\n");
235 list_old_configure(body
);
236 case M_OLD_CONFIGURE_WINDOW
:
237 fprintf(output
,"Old Configure Window\n");
238 list_old_configure(body
);
241 fprintf(output
,"Raise\n");
245 fprintf(output
,"Lower\n");
249 fprintf(output
,"Focus\n");
252 case M_DESTROY_WINDOW
:
253 fprintf(output
,"Destroy\n");
257 fprintf(output
,"iconify\n");
261 fprintf(output
,"Deiconify\n");
265 fprintf(output
,"window name\n");
266 list_window_name(body
);
269 fprintf(output
,"visible window name\n");
270 list_window_name(body
);
273 fprintf(output
,"icon name\n");
274 list_window_name(body
);
276 case MX_VISIBLE_ICON_NAME
:
277 fprintf(output
,"visible icon name\n");
278 list_window_name(body
);
281 fprintf(output
,"window class\n");
282 list_window_name(body
);
285 fprintf(output
,"class resource name\n");
286 list_window_name(body
);
288 case M_END_WINDOWLIST
:
289 fprintf(output
,"Send_WindowList End\n");
291 case M_ICON_LOCATION
:
292 fprintf(output
,"icon location\n");
296 fprintf(output
,"icon file\n");
297 list_window_name(body
);
300 fprintf(output
,"map\n");
304 fprintf(output
,"Error\n");
308 fprintf(output
,"Mini icon\n");
312 fprintf(output
,"Windowshade\n");
315 case M_DEWINDOWSHADE
:
316 fprintf(output
,"Dewindowshade\n");
320 fprintf(output
,"Restack\n");
324 fprintf(output
,"Add Window\n");
325 list_configure(body
);
327 case M_CONFIGURE_WINDOW
:
328 fprintf(output
,"Configure Window\n");
329 list_configure(body
);
333 fprintf(output
, " 0x%x\n", (int)type
);
343 * SIGPIPE handler - SIGPIPE means fvwm is dying
346 RETSIGTYPE
DeadPipe(int nonsense
)
349 fprintf(stderr
,"FvwmDebug: DeadPipe\n");
357 * list_old_configure - displays packet contents to output
360 void list_old_configure(const unsigned long *body
)
362 fprintf(output
,"\t ID %lx\n",body
[0]);
363 fprintf(output
,"\t frame ID %lx\n",body
[1]);
364 fprintf(output
,"\t fvwm ptr %lx\n",body
[2]);
365 fprintf(output
,"\t frame x %ld\n",(long)body
[3]);
366 fprintf(output
,"\t frame y %ld\n",(long)body
[4]);
367 fprintf(output
,"\t frame w %ld\n",(long)body
[5]);
368 fprintf(output
,"\t frame h %ld\n",(long)body
[6]);
369 fprintf(output
,"\t desk %ld\n",(long)body
[7]);
370 fprintf(output
,"\t flags %lx\n",body
[8]);
371 fprintf(output
,"\t title height %ld\n",(long)body
[9]);
372 fprintf(output
,"\t border width %ld\n",(long)body
[10]);
373 fprintf(output
,"\t window base width %ld\n",(long)body
[11]);
374 fprintf(output
,"\t window base height %ld\n",(long)body
[12]);
375 fprintf(output
,"\t window resize width increment %ld\n",(long)body
[13]);
376 fprintf(output
,"\t window resize height increment %ld\n",(long)body
[14]);
377 fprintf(output
,"\t window min width %ld\n",(long)body
[15]);
378 fprintf(output
,"\t window min height %ld\n",(long)body
[16]);
379 fprintf(output
,"\t window max %ld\n",(long)body
[17]);
380 fprintf(output
,"\t window max %ld\n",(long)body
[18]);
381 fprintf(output
,"\t icon label window %lx\n",body
[19]);
382 fprintf(output
,"\t icon pixmap window %lx\n",body
[20]);
383 fprintf(output
,"\t window gravity %lx\n",body
[21]);
390 * list_new_page - displays packet contents to output
393 void list_new_page(const unsigned long *body
)
395 fprintf(output
,"\t x %ld\n",(long)body
[0]);
396 fprintf(output
,"\t y %ld\n",(long)body
[1]);
397 fprintf(output
,"\t desk %ld\n",(long)body
[2]);
404 * list_new_desk - displays packet contents to output
407 void list_new_desk(const unsigned long *body
)
409 fprintf(output
,"\t desk %ld\n",(long)body
[0]);
416 * list_focus - displays packet contents to output
419 void list_focus(const unsigned long *body
)
421 fprintf(output
,"\t ID %lx\n",body
[0]);
422 fprintf(output
,"\t frame ID %lx\n",body
[1]);
423 fprintf(output
,"\t focus not by builtin %lx\n",body
[2]);
430 * list_winid - displays packet contents to for three-field
431 * window ID-bearing packets
434 void list_winid(const unsigned long *body
)
436 fprintf(output
,"\t ID %lx\n",body
[0]);
437 fprintf(output
,"\t frame ID %lx\n",body
[1]);
438 fprintf(output
,"\t fvwm ptr %lx\n",body
[2]);
446 * list_unknown - handles an unrecognized packet.
449 void list_unknown(const unsigned long *body
)
452 fprintf(output
,"Unknown packet type");
459 * list_iconify - displays packet contents to output
462 void list_icon(const unsigned long *body
)
464 fprintf(output
,"\t ID %lx\n",body
[0]);
465 fprintf(output
,"\t frame ID %lx\n",body
[1]);
466 fprintf(output
,"\t fvwm ptr %lx\n",body
[2]);
467 fprintf(output
,"\t icon x %ld\n",(long)body
[3]);
468 fprintf(output
,"\t icon y %ld\n",(long)body
[4]);
469 fprintf(output
,"\t icon w %ld\n",(long)body
[5]);
470 fprintf(output
,"\t icon h %ld\n",(long)body
[6]);
477 * list_window_name - displays packet contents to output
481 void list_window_name(const unsigned long *body
)
483 fprintf(output
,"\t ID %lx\n",body
[0]);
484 fprintf(output
,"\t frame ID %lx\n",body
[1]);
485 fprintf(output
,"\t fvwm ptr %lx\n",body
[2]);
486 fprintf(output
,"\t name %s\n",(const char *)(&body
[3]));
493 * list_restack - displays packet contents to output
497 void list_restack(const unsigned long *body
)
501 fprintf(output
,"\t Restack beginning with:\n");
502 fprintf(output
,"\t\tID %lx\n",body
[0]);
503 fprintf(output
,"\t\tframe ID %lx\n",body
[1]);
504 fprintf(output
,"\t\tfvwm ptr %lx\n",body
[2]);
506 while (body
[i
] != 0 && i
<FvwmPacketBodyMaxSize
)
508 fprintf(output
,"\t Next window:\n");
509 fprintf(output
,"\t\tID %lx\n",body
[i
]);
510 fprintf(output
,"\t\tframe ID %lx\n",body
[i
+1]);
511 fprintf(output
,"\t\tfvwm ptr %lx\n",body
[i
+2]);
520 * list_error - displays packet contents to output
524 void list_error(const unsigned long *body
)
526 fprintf(output
,"\t %s\n",(const char *)(&body
[3]));
533 * list_configure - displays packet contents to output
536 void list_configure(const unsigned long *body
)
538 struct ConfigWinPacket
*p
= (void *)body
;
540 fprintf(output
,"\t ID %lx\n",p
->w
);
541 fprintf(output
,"\t frame ID %lx\n",p
->frame
);
542 fprintf(output
,"\t fvwm ptr %lx\n",(unsigned long)p
->fvwmwin
);
543 fprintf(output
,"\t frame x %ld\n",p
->frame_x
);
544 fprintf(output
,"\t frame y %ld\n",p
->frame_y
);
545 fprintf(output
,"\t frame w %ld\n",p
->frame_width
);
546 fprintf(output
,"\t frame h %ld\n",p
->frame_height
);
547 fprintf(output
,"\t desk %ld\n",p
->desk
);
548 fprintf(output
,"\t layer %ld\n",p
->layer
);
549 fprintf(output
,"\t title height %hd\n",p
->title_height
);
550 fprintf(output
,"\t border width %hd\n",p
->border_width
);
551 fprintf(output
,"\t window base width %ld\n",p
->hints_base_width
);
552 fprintf(output
,"\t window base height %ld\n",p
->hints_base_height
);
553 fprintf(output
,"\t window resize width increment %ld\n",p
->hints_width_inc
);
554 fprintf(output
,"\t window resize height increment %ld\n",p
->hints_height_inc
);
555 fprintf(output
,"\t window min width %ld\n",p
->hints_min_width
);
556 fprintf(output
,"\t window min height %ld\n",p
->hints_min_height
);
557 fprintf(output
,"\t window max width %ld\n",p
->hints_max_width
);
558 fprintf(output
,"\t window max height %ld\n",p
->hints_max_height
);
559 fprintf(output
,"\t icon label window %lx\n",p
->icon_w
);
560 fprintf(output
,"\t icon pixmap window %lx\n",p
->icon_pixmap_w
);
561 fprintf(output
,"\t window gravity %lx\n",p
->hints_win_gravity
);
562 fprintf(output
,"\t forecolor %lx\n",p
->TextPixel
);
563 fprintf(output
,"\t backcolor %lx\n",p
->BackPixel
);
566 fprintf(output
,"\t Packet flags\n");
567 fprintf(output
,"\t\tis_sticky: %d\n",IS_STICKY(p
));
568 fprintf(output
,"\t\thas_icon_font: %d\n",HAS_ICON_FONT(p
));
569 fprintf(output
,"\t\thas_window_font: %d\n",HAS_WINDOW_FONT(p
));
570 fprintf(output
,"\t\tdo_circulate_skip: %d\n",DO_SKIP_CIRCULATE(p
));
571 fprintf(output
,"\t\tdo_circulate_skip_icon: %d\n",
572 DO_SKIP_ICON_CIRCULATE(p
));
573 fprintf(output
,"\t\tdo_circulate_skip_shaded: %d\n",
574 DO_SKIP_SHADED_CIRCULATE(p
));
575 fprintf(output
,"\t\tdo_grab_focus_when_created: %d\n",
576 FP_DO_GRAB_FOCUS(FW_FOCUS_POLICY(p
)));
577 fprintf(output
,"\t\tdo_grab_focus_when_transient_created: %d\n",
578 FP_DO_GRAB_FOCUS_TRANSIENT(FW_FOCUS_POLICY(p
)));
579 fprintf(output
,"\t\tdo_ignore_restack: %d\n", DO_IGNORE_RESTACK(p
));
580 fprintf(output
,"\t\tdo_lower_transient: %d\n", DO_LOWER_TRANSIENT(p
));
581 fprintf(output
,"\t\tdo_not_show_on_map: %d\n", DO_NOT_SHOW_ON_MAP(p
));
582 fprintf(output
,"\t\tdo_not_pass_click_focus_click: %d\n",
583 FP_DO_PASS_FOCUS_CLICK( FW_FOCUS_POLICY(p
) ) );
584 fprintf(output
,"\t\tdo_raise_transient: %d\n", DO_RAISE_TRANSIENT(p
));
585 fprintf(output
,"\t\tdo_resize_opaque: %d\n", DO_RESIZE_OPAQUE(p
));
586 fprintf(output
,"\t\tdo_shrink_windowshade: %d\n", DO_SHRINK_WINDOWSHADE(p
));
587 fprintf(output
,"\t\tdo_stack_transient_parent: %d\n",
588 DO_STACK_TRANSIENT_PARENT(p
));
589 fprintf(output
,"\t\tdo_window_list_skip: %d\n", DO_SKIP_WINDOW_LIST(p
));
590 fprintf(output
,"\t\thas_depressable_border: %d\n",
591 HAS_DEPRESSABLE_BORDER(p
));
592 fprintf(output
,"\t\thas_mwm_border: %d\n", HAS_MWM_BORDER(p
));
593 fprintf(output
,"\t\thas_mwm_buttons: %d\n", HAS_MWM_BUTTONS(p
));
594 fprintf(output
,"\t\thas_mwm_override: %d\n", HAS_MWM_OVERRIDE_HINTS(p
));
595 fprintf(output
,"\t\thas_no_icon_title: %d\n", HAS_NO_ICON_TITLE(p
));
596 fprintf(output
,"\t\thas_override_size: %d\n", HAS_OVERRIDE_SIZE_HINTS(p
));
597 fprintf(output
,"\t\thas_stippled_title: %d\n", HAS_STIPPLED_TITLE(p
));
598 fprintf(output
,"\t\tis_fixed: %d\n", IS_FIXED(p
));
599 fprintf(output
,"\t\tis_sticky_icon: %d\n", IS_ICON_STICKY(p
));
600 fprintf(output
,"\t\tis_icon_suppressed: %d\n", IS_ICON_SUPPRESSED(p
));
601 fprintf(output
,"\t\tis_lenient: %d\n",
602 FP_IS_LENIENT( FW_FOCUS_POLICY(p
) ));
603 fprintf(output
,"\t\tdoes_wm_delete_window: %d\n", WM_DELETES_WINDOW(p
));
604 fprintf(output
,"\t\tdoes_wm_take_focus: %d\n", WM_TAKES_FOCUS(p
));
605 fprintf(output
,"\t\tdo_iconify_after_map: %d\n", DO_ICONIFY_AFTER_MAP(p
));
606 fprintf(output
,"\t\tdo_reuse_destroyed: %d\n", DO_REUSE_DESTROYED(p
));
607 fprintf(output
,"\t\thas_border: %d\n", !HAS_NO_BORDER(p
));
608 fprintf(output
,"\t\thas_title: %d\n", HAS_TITLE(p
));
609 fprintf(output
,"\t\tis_iconify_pending: %d\n", IS_ICONIFY_PENDING(p
));
610 fprintf(output
,"\t\tis_fully_visible: %d\n", IS_FULLY_VISIBLE(p
));
611 fprintf(output
,"\t\tis_iconified: %d\n", IS_ICONIFIED(p
));
612 fprintf(output
,"\t\tis_iconfied_by_parent: %d\n",
613 IS_ICONIFIED_BY_PARENT(p
));
614 fprintf(output
,"\t\tis_icon_entered: %d\n", IS_ICON_ENTERED(p
));
615 fprintf(output
,"\t\tis_icon_font_loaded: %d\n", IS_ICON_FONT_LOADED(p
));
616 fprintf(output
,"\t\tis_icon_moved: %d\n", IS_ICON_MOVED(p
));
617 fprintf(output
,"\t\tis_icon_ours: %d\n", IS_ICON_OURS(p
));
618 fprintf(output
,"\t\tis_icon_shaped: %d\n", IS_ICON_SHAPED(p
));
619 fprintf(output
,"\t\tis_icon_unmapped: %d\n", IS_ICON_UNMAPPED(p
));
620 fprintf(output
,"\t\tis_mapped: %d\n", IS_MAPPED(p
));
621 fprintf(output
,"\t\tis_map_pending: %d\n", IS_MAP_PENDING(p
));
622 fprintf(output
,"\t\tis_maximized: %d\n", IS_MAXIMIZED(p
));
623 fprintf(output
,"\t\tis_name_changed: %d\n", IS_NAME_CHANGED(p
));
624 fprintf(output
,"\t\tis_partially_visible: %d\n", IS_PARTIALLY_VISIBLE(p
));
625 fprintf(output
,"\t\tis_pixmap_ours: %d\n", IS_PIXMAP_OURS(p
));
626 fprintf(output
,"\t\tis_placed_wb3: %d\n", IS_PLACED_WB3(p
));
627 fprintf(output
,"\t\tis_placed_by_fvwm: %d\n", IS_PLACED_BY_FVWM(p
));
628 fprintf(output
,"\t\tis_size_inc_set: %d\n", IS_SIZE_INC_SET(p
));
629 fprintf(output
,"\t\tis_transient: %d\n", IS_TRANSIENT(p
));
630 fprintf(output
,"\t\tis_window_drawn_once: %d\n", IS_WINDOW_DRAWN_ONCE(p
));
631 fprintf(output
,"\t\tis_viewport_moved: %d\n", IS_VIEWPORT_MOVED(p
));
632 fprintf(output
,"\t\tis_window_being_moved_opaque: %d\n",
633 IS_WINDOW_BEING_MOVED_OPAQUE(p
));
634 fprintf(output
,"\t\tis_window_font_loaded: %d\n", IS_WINDOW_FONT_LOADED(p
));
635 fprintf(output
,"\t\tis_window_shaded %d\n", IS_SHADED(p
));
636 fprintf(output
,"\t\ttitle_dir: %d\n", GET_TITLE_DIR(p
));