~ubuntu-branches/ubuntu/wily/fvwm1/wily-proposed

« back to all changes in this revision

Viewing changes to modules/FvwmDebug/FvwmDebug.c

  • Committer: Bazaar Package Importer
  • Author(s): Phil Brooke
  • Date: 2002-02-04 09:00:00 UTC
  • Revision ID: james.westby@ubuntu.com-20020204090000-g9v6alewbk85apqe
Tags: upstream-1.24r
ImportĀ upstreamĀ versionĀ 1.24r

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This module, and the entire FvwmDebug program, and the concept for
 
2
 * interfacing this module to the Window Manager, are all original work
 
3
 * by Robert Nation
 
4
 *
 
5
 * Copyright 1994, Robert Nation. No guarantees or warantees or anything
 
6
 * are provided or implied in any way whatsoever. Use this program at your
 
7
 * own risk. Permission to use this program for any purpose is given,
 
8
 * as long as the copyright is kept intact. */
 
9
 
 
10
#define TRUE 1
 
11
#define FALSE 
 
12
 
 
13
#include "../../configure.h"
 
14
 
 
15
#include <stdio.h>
 
16
#include <signal.h>
 
17
#include <fcntl.h>
 
18
#include <string.h>
 
19
#include <sys/wait.h>
 
20
#include <sys/time.h>
 
21
#include <unistd.h>
 
22
#include <ctype.h>
 
23
#include <stdlib.h>
 
24
#include "../../fvwm/module.h"
 
25
 
 
26
#include "FvwmDebug.h"
 
27
#include "../../version.h"
 
28
 
 
29
char *MyName;
 
30
int fd_width;
 
31
int fd[2];
 
32
 
 
33
/***********************************************************************
 
34
 *
 
35
 *  Procedure:
 
36
 *      main - start of module
 
37
 *
 
38
 ***********************************************************************/
 
39
void main(int argc, char **argv)
 
40
{
 
41
  char *temp, *s;
 
42
 
 
43
  /* Save our program  name - for error messages */
 
44
  temp = argv[0];
 
45
  s=strrchr(argv[0], '/');
 
46
  if (s != NULL)
 
47
    temp = s + 1;
 
48
 
 
49
  MyName = safemalloc(strlen(temp)+2);
 
50
  strcpy(MyName,"*");
 
51
  strcat(MyName, temp);
 
52
 
 
53
  if((argc != 6)&&(argc != 7))
 
54
    {
 
55
      fprintf(stderr,"%s Version %s should only be executed by fvwm!\n",MyName,
 
56
              VERSION);
 
57
      exit(1);
 
58
    }
 
59
 
 
60
  /* Dead pipe == Fvwm died */
 
61
  signal (SIGPIPE, DeadPipe);  
 
62
  
 
63
  fd[0] = atoi(argv[1]);
 
64
  fd[1] = atoi(argv[2]);
 
65
 
 
66
  /* Data passed in command line */
 
67
  fprintf(stderr,"Application Window 0x%s\n",argv[4]);
 
68
  fprintf(stderr,"Application Context %s\n",argv[5]);
 
69
 
 
70
  fd_width = GetFdWidth();
 
71
 
 
72
  /* Create a list of all windows */
 
73
  /* Request a list of all windows,
 
74
   * wait for ConfigureWindow packets */
 
75
  SendInfo(fd,"Send_WindowList",0);
 
76
 
 
77
  Loop(fd);
 
78
}
 
79
 
 
80
/***********************************************************************
 
81
 *
 
82
 *  Procedure:
 
83
 *      Loop - wait for data to process
 
84
 *
 
85
 ***********************************************************************/
 
86
void Loop(int *fd)
 
87
{
 
88
  unsigned long header[3], *body;
 
89
  char *cbody;
 
90
  int body_length,count,count2=0, total;
 
91
 
 
92
  while(1)
 
93
    {
 
94
      if(count = ReadFvwmPacket(fd[1],header,&body) > 0)
 
95
        {
 
96
          process_message(header[1],body);
 
97
          free(body);
 
98
        }
 
99
    }
 
100
}
 
101
 
 
102
 
 
103
/***********************************************************************
 
104
 *
 
105
 *  Procedure:
 
106
 *      Process message - examines packet types, and takes appropriate action
 
107
 *
 
108
 ***********************************************************************/
 
109
void process_message(unsigned long type,unsigned long *body)
 
110
{
 
111
  switch(type)
 
112
    {
 
113
    case M_ADD_WINDOW:
 
114
      list_add(body);
 
115
    case M_CONFIGURE_WINDOW:
 
116
      list_configure(body);
 
117
      break;
 
118
    case M_DESTROY_WINDOW:
 
119
      list_destroy(body);
 
120
      break;
 
121
    case M_FOCUS_CHANGE:
 
122
      list_focus(body);
 
123
      break;
 
124
    case M_TOGGLE_PAGING:
 
125
      list_toggle(body);
 
126
      break;
 
127
    case M_NEW_PAGE:
 
128
      list_new_page(body);
 
129
      break;
 
130
    case M_NEW_DESK:
 
131
      list_new_desk(body);
 
132
      break;
 
133
    case M_RAISE_WINDOW:
 
134
      list_raise(body);
 
135
      break;
 
136
    case M_LOWER_WINDOW:
 
137
      list_lower(body);
 
138
      break;
 
139
    case M_ICONIFY:
 
140
      list_iconify(body);
 
141
      break;
 
142
    case M_MAP:
 
143
      list_map(body);
 
144
      break;
 
145
    case M_ICON_LOCATION:
 
146
      list_icon_loc(body);
 
147
      break;
 
148
    case M_DEICONIFY:
 
149
      list_deiconify(body);
 
150
      break;
 
151
    case M_WINDOW_NAME:
 
152
      list_window_name(body);
 
153
      break;
 
154
    case M_ICON_NAME:
 
155
      list_icon_name(body);
 
156
      break;
 
157
    case M_RES_CLASS:
 
158
      list_class(body);
 
159
      break;
 
160
    case M_RES_NAME:
 
161
      list_res_name(body);
 
162
      break;
 
163
    case M_END_WINDOWLIST:
 
164
      list_end();
 
165
      break;
 
166
    default:
 
167
      list_unknown(body);
 
168
      break;
 
169
    }
 
170
}
 
171
 
 
172
 
 
173
 
 
174
/***********************************************************************
 
175
 *
 
176
 *  Procedure:
 
177
 *      SIGPIPE handler - SIGPIPE means fvwm is dying
 
178
 *
 
179
 ***********************************************************************/
 
180
void DeadPipe(int nonsense)
 
181
{
 
182
  exit(0);
 
183
}
 
184
 
 
185
/***********************************************************************
 
186
 *
 
187
 *  Procedure:
 
188
 *      list_add - displays packet contents to stderr
 
189
 *
 
190
 ***********************************************************************/
 
191
void list_add(unsigned long *body)
 
192
{
 
193
  fprintf(stderr,"Add Window\n");
 
194
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
195
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
196
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
197
  fprintf(stderr,"\t frame x %ld\n",(long)body[3]);
 
198
  fprintf(stderr,"\t frame y %ld\n",(long)body[4]);
 
199
  fprintf(stderr,"\t frame w %ld\n",(long)body[5]);
 
200
  fprintf(stderr,"\t frame h %ld\n",(long)body[6]);
 
201
  fprintf(stderr,"\t desk %ld\n",(long)body[7]);
 
202
  fprintf(stderr,"\t flags %lx\n",body[8]);
 
203
  fprintf(stderr,"\t title height %ld\n",(long)body[9]);
 
204
  fprintf(stderr,"\t border width %ld\n",(long)body[10]);
 
205
  fprintf(stderr,"\t window base width %ld\n",(long)body[11]);
 
206
  fprintf(stderr,"\t window base height %ld\n",(long)body[12]);
 
207
  fprintf(stderr,"\t window resize width increment %ld\n",(long)body[13]);
 
208
  fprintf(stderr,"\t window resize height increment %ld\n",(long)body[14]);
 
209
  fprintf(stderr,"\t window min width %ld\n",(long)body[15]);
 
210
  fprintf(stderr,"\t window min height %ld\n",(long)body[16]);
 
211
  fprintf(stderr,"\t window max %ld\n",(long)body[17]);
 
212
  fprintf(stderr,"\t window max %ld\n",(long)body[18]);
 
213
  fprintf(stderr,"\t icon label window %lx\n",body[19]);
 
214
  fprintf(stderr,"\t icon pixmap window %lx\n",body[20]);  
 
215
  fprintf(stderr,"\t window gravity %lx\n",body[21]);  
 
216
}
 
217
 
 
218
/***********************************************************************
 
219
 *
 
220
 *  Procedure:
 
221
 *      list_configure - displays packet contents to stderr
 
222
 *
 
223
 ***********************************************************************/
 
224
void list_configure(unsigned long *body)
 
225
{
 
226
  fprintf(stderr,"Configure Window\n");
 
227
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
228
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
229
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
230
  fprintf(stderr,"\t frame x %ld\n",(long)body[3]);
 
231
  fprintf(stderr,"\t frame y %ld\n",(long)body[4]);
 
232
  fprintf(stderr,"\t frame w %ld\n",(long)body[5]);
 
233
  fprintf(stderr,"\t frame h %ld\n",(long)body[6]);
 
234
  fprintf(stderr,"\t desk %ld\n",(long)body[7]);
 
235
  fprintf(stderr,"\t flags %lx\n",body[8]);
 
236
  fprintf(stderr,"\t title height %ld\n",(long)body[9]);
 
237
  fprintf(stderr,"\t border width %ld\n",(long)body[10]);
 
238
  fprintf(stderr,"\t window base width %ld\n",(long)body[11]);
 
239
  fprintf(stderr,"\t window base height %ld\n",(long)body[12]);
 
240
  fprintf(stderr,"\t window resize width increment %ld\n",(long)body[13]);
 
241
  fprintf(stderr,"\t window resize height increment %ld\n",(long)body[14]);
 
242
  fprintf(stderr,"\t window min width %ld\n",(long)body[15]);
 
243
  fprintf(stderr,"\t window min height %ld\n",(long)body[16]);
 
244
  fprintf(stderr,"\t window max %ld\n",(long)body[17]);
 
245
  fprintf(stderr,"\t window max %ld\n",(long)body[18]);
 
246
  fprintf(stderr,"\t icon label window %lx\n",body[19]);
 
247
  fprintf(stderr,"\t icon pixmap window %lx\n",body[20]);
 
248
  fprintf(stderr,"\t window gravity %lx\n",body[21]);  
 
249
}
 
250
 
 
251
/***********************************************************************
 
252
 *
 
253
 *  Procedure:
 
254
 *      list_destroy - displays packet contents to stderr
 
255
 *
 
256
 ***********************************************************************/
 
257
void list_destroy(unsigned long *body)
 
258
{
 
259
  fprintf(stderr,"destroy\n");
 
260
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
261
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
262
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
263
}
 
264
 
 
265
/***********************************************************************
 
266
 *
 
267
 *  Procedure:
 
268
 *      list_focus - displays packet contents to stderr
 
269
 *
 
270
 ***********************************************************************/
 
271
void list_focus(unsigned long *body)
 
272
{
 
273
  fprintf(stderr,"focus\n");
 
274
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
275
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
276
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
277
 
 
278
}
 
279
 
 
280
/***********************************************************************
 
281
 *
 
282
 *  Procedure:
 
283
 *      list_toggle - displays packet contents to stderr
 
284
 *
 
285
 ***********************************************************************/
 
286
void list_toggle(unsigned long *body)
 
287
{
 
288
  fprintf(stderr,"toggle\n");
 
289
  fprintf(stderr,"\t value %ld\n",body[0]);
 
290
 
 
291
}
 
292
 
 
293
/***********************************************************************
 
294
 *
 
295
 *  Procedure:
 
296
 *      list_new_page - displays packet contents to stderr
 
297
 *
 
298
 ***********************************************************************/
 
299
void list_new_page(unsigned long *body)
 
300
{
 
301
  fprintf(stderr,"new page\n");
 
302
  fprintf(stderr,"\t x %ld\n",(long)body[0]);
 
303
  fprintf(stderr,"\t y %ld\n",(long)body[1]);
 
304
  fprintf(stderr,"\t desk %ld\n",(long)body[2]);
 
305
}
 
306
 
 
307
/***********************************************************************
 
308
 *
 
309
 *  Procedure:
 
310
 *      list_new_desk - displays packet contents to stderr
 
311
 *
 
312
 ***********************************************************************/
 
313
void list_new_desk(unsigned long *body)
 
314
{
 
315
  fprintf(stderr,"new desk\n");
 
316
  fprintf(stderr,"\t desk %ld\n",(long)body[0]);
 
317
}
 
318
 
 
319
/***********************************************************************
 
320
 *
 
321
 *  Procedure:
 
322
 *      list_raise - displays packet contents to stderr
 
323
 *
 
324
 ***********************************************************************/
 
325
void list_raise(unsigned long *body)
 
326
{
 
327
  fprintf(stderr,"raise\n");
 
328
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
329
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
330
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
331
}
 
332
 
 
333
 
 
334
/***********************************************************************
 
335
 *
 
336
 *  Procedure:
 
337
 *      list_lower - displays packet contents to stderr
 
338
 *
 
339
 ***********************************************************************/
 
340
void list_lower(unsigned long *body)
 
341
{
 
342
  fprintf(stderr,"lower\n");
 
343
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
344
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
345
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
346
}
 
347
 
 
348
 
 
349
/***********************************************************************
 
350
 *
 
351
 *  Procedure:
 
352
 *      list_unknow - handles an unrecognized packet.
 
353
 *
 
354
 ***********************************************************************/
 
355
void list_unknown(unsigned long *body)
 
356
{
 
357
  fprintf(stderr,"Unknown packet type\n");
 
358
}
 
359
 
 
360
/***********************************************************************
 
361
 *
 
362
 *  Procedure:
 
363
 *      list_iconify - displays packet contents to stderr
 
364
 *
 
365
 ***********************************************************************/
 
366
void list_iconify(unsigned long *body)
 
367
{
 
368
  fprintf(stderr,"iconify\n");
 
369
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
370
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
371
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
372
  fprintf(stderr,"\t icon x %ld\n",(long)body[3]);
 
373
  fprintf(stderr,"\t icon y %ld\n",(long)body[4]);
 
374
  fprintf(stderr,"\t icon w %ld\n",(long)body[5]);
 
375
  fprintf(stderr,"\t icon h %ld\n",(long)body[6]);
 
376
}
 
377
 
 
378
 
 
379
/***********************************************************************
 
380
 *
 
381
 *  Procedure:
 
382
 *      list_map - displays packet contents to stderr
 
383
 *
 
384
 ***********************************************************************/
 
385
void list_map(unsigned long *body)
 
386
{
 
387
  fprintf(stderr,"map\n");
 
388
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
389
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
390
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
391
}
 
392
 
 
393
 
 
394
/***********************************************************************
 
395
 *
 
396
 *  Procedure:
 
397
 *      list_icon_loc - displays packet contents to stderr
 
398
 *
 
399
 ***********************************************************************/
 
400
void list_icon_loc(unsigned long *body)
 
401
{
 
402
  fprintf(stderr,"icon location\n");
 
403
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
404
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
405
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
406
  fprintf(stderr,"\t icon x %ld\n",(long)body[3]);
 
407
  fprintf(stderr,"\t icon y %ld\n",(long)body[4]);
 
408
  fprintf(stderr,"\t icon w %ld\n",(long)body[5]);
 
409
  fprintf(stderr,"\t icon h %ld\n",(long)body[6]);
 
410
}
 
411
 
 
412
 
 
413
 
 
414
/***********************************************************************
 
415
 *
 
416
 *  Procedure:
 
417
 *      list_deiconify - displays packet contents to stderr
 
418
 *
 
419
 ***********************************************************************/
 
420
 
 
421
void list_deiconify(unsigned long *body)
 
422
{
 
423
  fprintf(stderr,"de-iconify\n");
 
424
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
425
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
426
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
427
}
 
428
 
 
429
/***********************************************************************
 
430
 *
 
431
 *  Procedure:
 
432
 *      list_window_name - displays packet contents to stderr
 
433
 *
 
434
 ***********************************************************************/
 
435
 
 
436
void list_window_name(unsigned long *body)
 
437
{
 
438
  fprintf(stderr,"window name\n");
 
439
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
440
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
441
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
442
  fprintf(stderr,"\t window name %s\n",(char *)(&body[3]));
 
443
 
 
444
}
 
445
 
 
446
 
 
447
/***********************************************************************
 
448
 *
 
449
 *  Procedure:
 
450
 *      list_icon_name - displays packet contents to stderr
 
451
 *
 
452
 ***********************************************************************/
 
453
void list_icon_name(unsigned long *body)
 
454
{
 
455
  fprintf(stderr,"icon name\n");
 
456
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
457
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
458
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
459
  fprintf(stderr,"\t icon name %s\n",(char *)(&body[3]));
 
460
}
 
461
 
 
462
 
 
463
 
 
464
/***********************************************************************
 
465
 *
 
466
 *  Procedure:
 
467
 *      list_class - displays packet contents to stderr
 
468
 *
 
469
 ***********************************************************************/
 
470
void list_class(unsigned long *body)
 
471
{
 
472
  fprintf(stderr,"window class\n");
 
473
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
474
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
475
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
476
  fprintf(stderr,"\t window class %s\n",(char *)(&body[3]));
 
477
}
 
478
 
 
479
 
 
480
/***********************************************************************
 
481
 *
 
482
 *  Procedure:
 
483
 *      list_res_name - displays packet contents to stderr
 
484
 *
 
485
 ***********************************************************************/
 
486
void list_res_name(unsigned long *body)
 
487
{
 
488
  fprintf(stderr,"class resource name\n");
 
489
  fprintf(stderr,"\t ID %lx\n",body[0]);
 
490
  fprintf(stderr,"\t frame ID %lx\n",body[1]);
 
491
  fprintf(stderr,"\t fvwm ptr %lx\n",body[2]);
 
492
  fprintf(stderr,"\t resource name %s\n",(char *)(&body[3]));
 
493
}
 
494
 
 
495
/***********************************************************************
 
496
 *
 
497
 *  Procedure:
 
498
 *      list_end - displays packet contents to stderr
 
499
 *
 
500
 ***********************************************************************/
 
501
void list_end(void)
 
502
{
 
503
  fprintf(stderr,"Send_WindowList End\n");
 
504
}
 
505