Japanese translation of message catalog for Sawfish Window-Manager
Revisão | aa4e4b8a4293adf4d70bde75614cc4443127bf3a (tree) |
---|---|
Hora | 2010-12-19 13:32:18 |
Autor | Michal Maruska <mmaruska@gmai...> |
Commiter | Michal Maruska |
merge of mmc-images,mmc-debug into mmc-images-debug
@@ -28,7 +28,7 @@ VPATH=@srcdir@:@top_srcdir@ | ||
28 | 28 | |
29 | 29 | SRCS := colors.c cursors.c display.c events.c fonts.c frames.c \ |
30 | 30 | functions.c images.c keys.c main.c multihead.c pixmap-cache.c \ |
31 | - property-cache.c server.c session.c stacking-list.c windows.c | |
31 | + property-cache.c server.c session.c stacking-list.c windows.c mmc.c | |
32 | 32 | OBJS := $(SRCS:.c=.o) |
33 | 33 | |
34 | 34 | DL_SRCS := gradient.c flippers.c x.c selection.c |
@@ -0,0 +1,81 @@ | ||
1 | +#ifndef DEBUG_COLORS_H | |
2 | +#define DEBUG_COLORS_H | |
3 | + | |
4 | + | |
5 | +#define color_green "\x1b[43;30m" /* i have */ | |
6 | + | |
7 | +/*was printf*/ | |
8 | +#define color_reset "\x1b[0m" | |
9 | +/* requests: */ | |
10 | +#define unmap_request_color "\x1b[48;5;209;38;5;232m" | |
11 | +#define map_request_color "\x1b[48;5;203;38;5;232m" | |
12 | + | |
13 | +#define flow_color "\x1b[31m" | |
14 | +#define event_color "\x1b[01;36m" | |
15 | +#define serial_color "\x1b[01;33m" | |
16 | +#define events_color "\x1b[01;32;45m" /* how many events */ | |
17 | +/* #define event_color "\x1b[46;30m" */ | |
18 | +#define event_name_color "\x1b[01;45;37m" | |
19 | + | |
20 | +#define frame_color "\x1b[48;5;177;38;5;232m" | |
21 | +/* #define frame_color "\x1b[38;5;119m" */ | |
22 | + | |
23 | +#define move_color "\x1b[38;5;119m" | |
24 | + | |
25 | +#define reparent_color "\x1b[38;5;119m" | |
26 | + | |
27 | +/* for stacking! */ | |
28 | +#define functions_color "\x1b[30;43m" | |
29 | +#define message_color "\x1b[33;1m" | |
30 | + | |
31 | + | |
32 | +#define property_color "\x1b[33;1m" | |
33 | +#define time_color "\x1b[33m" | |
34 | +#define stacking_color "\x1b[38;5;204m" | |
35 | + | |
36 | +#define window_color "\x1b[38;5;123m" | |
37 | +#define frame_window_color "\x1b[38;5;10m" | |
38 | +#define image_color "\x1b[48;5;177;38;5;159m" | |
39 | + | |
40 | + | |
41 | +/* fixme: I could simply output 2 Esc. sequences! */ | |
42 | +static | |
43 | +inline char* | |
44 | +color_fg_string(char* string, int part, char* buffer) | |
45 | +{ | |
46 | +#define BUFFER_SIZE 20 | |
47 | +#if 0 | |
48 | + static char buffer[BUFFER_SIZE]; | |
49 | +#endif | |
50 | + | |
51 | +#if 0 | |
52 | + /* number_2_string ? */ | |
53 | + strncat(buffer, BUFFER_SIZE, string, (toa part), ); | |
54 | +#else | |
55 | + snprintf(buffer, BUFFER_SIZE, "%s%dm", string, part); | |
56 | +#endif | |
57 | + return buffer; | |
58 | +} | |
59 | + | |
60 | +#define focus_mode_color "\x1b[01;37m" | |
61 | + | |
62 | +/* no! */ | |
63 | +#define focus_color "\x1b[38;5;204m" | |
64 | +#define another_focus_color "\x1b[31m" | |
65 | +#define warning_color "\x1b[48;5;46;38;5;22m" | |
66 | +#define error_color "\x1b[01;37;41m" | |
67 | + | |
68 | +#define xkb_color "\x1b[01;42;30m" | |
69 | +#define keys_color "\x1b[01;36m" | |
70 | + | |
71 | +#define configure_color "\x1b[48;5;153m" | |
72 | + | |
73 | +/* events: */ | |
74 | +#define unmap_color "\x1b[38;5;209m" | |
75 | +#define map_color "\x1b[38;5;203m" | |
76 | +/*#define map_color "\x1b[01;46;31m" */ | |
77 | +#define grab_color "\x1b[38;5;46m" | |
78 | +#define xgrab_color "\x1b[01;33;41m" | |
79 | + | |
80 | + | |
81 | +#endif /* DEBUG_COLORS_H */ |
@@ -0,0 +1,156 @@ | ||
1 | +#ifndef DEBUG_H | |
2 | +#define DEBUG_H | |
3 | + | |
4 | +#include "sawfish.h" | |
5 | + | |
6 | +/* format specifier */ | |
7 | +#define FMT_XID "lx" /* XID */ | |
8 | +#define FMT_WIN FMT_XID /* Window is unsigned long */ | |
9 | + | |
10 | + | |
11 | +#define DEBUG 1 | |
12 | + | |
13 | +#define XAllowEvents_string "\x1b[01;33;41mXAllowEvents\x1b[0m" | |
14 | + | |
15 | + | |
16 | +#define DB_EVENTS_FLOW 1 /* 1 */ | |
17 | + | |
18 | +#define DB_EVENTS_MAP (1<<1) /* 2 */ | |
19 | +#define DB_EVENTS_UNMAP (1<<2) /* 4 */ | |
20 | +#define DB_EVENTS_FOCUS (1<<3) /* 8 */ // 188 = 128 + 60 = 32 + 16 + 8 + 4 56 = 32 + 16 + 8 | |
21 | + | |
22 | +/* 4+8 = 14 +16 = 30 */ | |
23 | + | |
24 | +#define DB_EVENTS_TIME (1<<4) /* 16 */ | |
25 | + | |
26 | +#define DB_EVENTS_COLOR (1<<5) /* 32 */ | |
27 | +#define DB_EVENTS_PROPERTY (1<<6) /* 64 */ | |
28 | +#define DB_EVENTS_MISC (1<<7)/* 128 216 = 128 + 64 + 16 8 -64 152 */ | |
29 | +#define DB_EVENTS_QUEUE (1<<8) /* 256 */ | |
30 | + | |
31 | +#define DB_EVENTS_QUEUE (1<<8) /* 256 */ | |
32 | + | |
33 | +#define DB_EVENTS_CONFIGURE (1 << 9) /* 1 */ | |
34 | +/* */ | |
35 | + | |
36 | +#define DB_FUNCTIONS_GRAB (1<<1) | |
37 | +#define DB_FUNCTIONS_REST (1<<7) | |
38 | +#define DB_FUNCTIONS_MOUSE (1<<2) | |
39 | +#define DB_FUNCTIONS_MOVE (1<<3) /* 8*/ | |
40 | + | |
41 | +#define DB_FUNCTIONS_MESSAGE (1<<4) /* 16 */ | |
42 | + | |
43 | +#define DB_FUNCTIONS_PROP (1<<5) /* 32 */ | |
44 | + | |
45 | + | |
46 | + | |
47 | +#define DB_WINDOWS_FOCUS 1 | |
48 | + | |
49 | +#define DB_WINDOWS_PROT (1 << 1) /* protocol */ | |
50 | +#define DB_WINDOWS_ADD (1 << 2) /* 4 */ | |
51 | +#define DB_WINDOWS_FRAME (1 << 3) /* 8 */ | |
52 | + | |
53 | + | |
54 | +#define DB_WINDOWS_PUT (1 << 4) /* ??? */ | |
55 | + | |
56 | +#define DB_WINDOWS_HOOKS (1<<6) /* 64 */ | |
57 | +#define DB_WINDOWS_REST (1<<7) /* 128 */ | |
58 | + | |
59 | +#define DB_WINDOWS_FIND (1<<8) | |
60 | +#define DB_WINDOWS_GC (1<<9) | |
61 | + | |
62 | +#define DB_DISPLAY_ERROR 1 | |
63 | + | |
64 | + | |
65 | +#define DB_KEYS_INTER 4 | |
66 | +#define DB_KEYS_FLOW 128 | |
67 | +#define DB_KEYS_GRAB 2 | |
68 | +#define DB_KEYS_WINDOW 8 | |
69 | +#define DB_KEYS_WINDOW_DETAIL 16 | |
70 | + | |
71 | + | |
72 | +#define DB_FRAMES_FRAME (1 << 0) /* 2 */ | |
73 | + | |
74 | +// ??? | |
75 | +#define DB_FRAMES_PARTS (1 << 1) /* 2 */ | |
76 | + | |
77 | + | |
78 | +#define DB_FRAMES_SHAPE (1 << 2) /* 4 */ | |
79 | +// #define DB_FRAMES_SHAPE (1 << 9) /* 512 */ | |
80 | + | |
81 | +#define DB_FRAMES_PARTS_CONFIGURE (1 << 3) /* configure FPs to change their size/position */ | |
82 | + | |
83 | +#define DB_FRAMES_BUILD (1 << 4) /* 16 */ | |
84 | + | |
85 | + | |
86 | +#define DB_FRAMES_ALLOC (1 << 5) /* 32 */ | |
87 | +#define DB_FRAMES_RE (1 << 6) /* 64 ... */ | |
88 | + | |
89 | +#define DB_FRAMES_PARTS_BUILD (1 << 7) /* 128 */ | |
90 | + | |
91 | +// fixme: should use `DB_FRAMES_RE' | |
92 | +#define DB_FRAMES_PARTS_CHANGE (1 << 8) /* 256 */ | |
93 | + | |
94 | + | |
95 | +#define DB_FRAMES_DRAW (1 <<9) /* 512 */ | |
96 | + | |
97 | + | |
98 | + | |
99 | + | |
100 | +#define DB_IMAGES_CREATE (1 << 1) | |
101 | +#define DB_IMAGES_RENDER (1 << 2) /* 4 */ | |
102 | +#define DB_IMAGES_OPS (1 << 3) | |
103 | +#define DB_IMAGES_GET (1 << 4) | |
104 | +#define DB_IMAGES_GC (1 << 5) | |
105 | + | |
106 | + | |
107 | + | |
108 | +#define DB_CACHE_DELETE (1 << 1) | |
109 | +#define DB_CACHE_REF (1 << 2) | |
110 | +#define DB_CACHE_MISS (1 << 3) /* 8 */ | |
111 | + | |
112 | + | |
113 | +#define DB_STACKING_PROT (1 << 1) /* protocol */ | |
114 | +#define DB_STACKING_ALGO (1 << 2) /* 4 */ | |
115 | +#define DB_STACKING_WINDOWS_FRAME (1 << 3) | |
116 | + | |
117 | + | |
118 | + | |
119 | +/* frame options: | |
120 | + * 1 Frame bg black & pixmamp None! | |
121 | + * 2 atomic | |
122 | + * 4 pixbuf cache works as I want: | |
123 | + * 8 DBE | |
124 | + * 16 ?? | |
125 | + * 32 DO refresh_frame_parts before Expose iff 1 | |
126 | + * | |
127 | + * 43 = 32 + 11 = 8 + 3 = 2+1 | |
128 | + * 64 .... allow XConfigure on the FPs (which need it) | |
129 | + | |
130 | + * 128 do not refresh on expose a traced FP | |
131 | + | |
132 | + * 256 make all gravity static | |
133 | + * 512 ... don't reconfigure FPs .. rely on gravity! | |
134 | + * 1024 ... predict the reposition & maybe change the gravity? | |
135 | + * 2048 ... clearArea on each configure | |
136 | + */ | |
137 | + | |
138 | + | |
139 | +extern int debug_keys; | |
140 | +extern int debug_stacking; | |
141 | +extern int debug_events; | |
142 | +extern int debug_functions; | |
143 | +extern int debug_windows; | |
144 | +extern int debug_frames; | |
145 | +extern int debug_frame_part; | |
146 | +extern int debug_images; | |
147 | +extern int debug_cache; | |
148 | +extern int debug_display; | |
149 | + | |
150 | + | |
151 | +/* options */ | |
152 | +extern int default_grab_owner; | |
153 | +extern int dont_allow_events; | |
154 | + | |
155 | + | |
156 | +#endif /* DEBUG_H */ |
@@ -31,6 +31,7 @@ | ||
31 | 31 | #include <stdarg.h> |
32 | 32 | #include <ctype.h> |
33 | 33 | |
34 | +#include <X11/Xproto.h> | |
34 | 35 | #ifdef HAVE_UNIX |
35 | 36 | # ifdef HAVE_FCNTL_H |
36 | 37 | # include <fcntl.h> |
@@ -50,6 +51,14 @@ int screen_num, screen_width, screen_height; | ||
50 | 51 | Window root_window, no_focus_window; |
51 | 52 | int shape_event_base, shape_error_base; |
52 | 53 | |
54 | +int debug_display; | |
55 | +/* A table of strings, probably in Xlib already? */ | |
56 | +#include "errors.h" | |
57 | +#include "debug.h" | |
58 | +#include "debug-colors.h" | |
59 | +int debug_display = DB_DISPLAY_ERROR; /* a good default! */ | |
60 | + | |
61 | + | |
53 | 62 | Visual *preferred_visual; |
54 | 63 | int preferred_depth; |
55 | 64 |
@@ -63,6 +72,39 @@ DEFSYM(canonical_display_name, "canonical-display-name"); | ||
63 | 72 | |
64 | 73 | /* X error handlers */ |
65 | 74 | |
75 | +static const char* | |
76 | +request_name (int request) | |
77 | +{ | |
78 | + request--; | |
79 | + /* return a string with the name, or NULL */ | |
80 | + if ((request >= 0) && | |
81 | + (request < (sizeof(request_names)/sizeof(request_names[0])))) | |
82 | + return request_names[request]; | |
83 | + else | |
84 | + return NULL; | |
85 | +} | |
86 | + | |
87 | +static void | |
88 | +print_error (XErrorEvent *ev) | |
89 | +{ | |
90 | + char buf[256]; | |
91 | + const char* name = request_name(ev->request_code); | |
92 | + | |
93 | + XGetErrorText(dpy, ev->error_code, buf, sizeof(buf)); | |
94 | + fprintf(stderr, "X Error: %s\n", buf); | |
95 | + | |
96 | + if (name) | |
97 | + fprintf(stderr, "The request was: %s, serial %lu\n", name, ev->serial); | |
98 | + else | |
99 | + fprintf(stderr, "The request was from some extension)!\n"); | |
100 | + | |
101 | + fprintf(stderr, " Request Major code: %d\n", ev->request_code); | |
102 | + fprintf(stderr, " Request Minor code: %d\n", ev->minor_code); | |
103 | + fprintf(stderr, " ResourceId 0x%x (%d)\n", (unsigned int)ev->resourceid, | |
104 | + (unsigned int)ev->resourceid); | |
105 | + /* i prefer to see both decimal and hexadecimal */ | |
106 | +} | |
107 | + | |
66 | 108 | /* General error handler. Probably due to lag between windows being |
67 | 109 | killed and us receiving DestroyNotify events */ |
68 | 110 | static int |
@@ -70,6 +112,12 @@ error_handler (Display *dpy, XErrorEvent *ev) | ||
70 | 112 | { |
71 | 113 | Lisp_Window *w; |
72 | 114 | |
115 | + DB(("%s%s%s serial %u, XID %" FMT_XID ", type %d, %s\n", error_color, __FUNCTION__, | |
116 | + color_reset, | |
117 | + ev->serial, ev->resourceid, ev->type, request_name(ev->request_code))); | |
118 | + if (debug_display & DB_DISPLAY_ERROR) | |
119 | + print_error (ev); | |
120 | + | |
73 | 121 | if (ev->resourceid != 0 |
74 | 122 | && (ev->error_code == BadWindow || ev->error_code == BadDrawable)) |
75 | 123 | { |
@@ -32,6 +32,10 @@ | ||
32 | 32 | #include <glib.h> |
33 | 33 | #include <stdio.h> |
34 | 34 | |
35 | +#include "debug.h" | |
36 | +#include "debug-colors.h" | |
37 | +int debug_events; | |
38 | + | |
35 | 39 | /* Lookup table of event handlers */ |
36 | 40 | void (*event_handlers[LASTEvent])(XEvent *ev); |
37 | 41 |
@@ -125,6 +129,8 @@ DEFSYM(normal, "normal"); | ||
125 | 129 | DEFSYM(grab, "grab"); |
126 | 130 | DEFSYM(ungrab, "ungrab"); |
127 | 131 | |
132 | +extern repv Qeval_key_release_events; | |
133 | + | |
128 | 134 | repv Fsynthetic_configure_mutex (repv); |
129 | 135 | |
130 | 136 | /* `Time' will always be 32-bits, due to underlying wire protocol (?) */ |
@@ -309,6 +315,12 @@ colormap_notify (XEvent *ev) | ||
309 | 315 | static void |
310 | 316 | key_press (XEvent *ev) |
311 | 317 | { |
318 | + Lisp_Window *w = find_window_by_id (ev->xkey.window); | |
319 | + if (debug_keys & DB_KEYS_FLOW) | |
320 | + DB (("E: %s [%s %u @ %lu]-> eval_input_event (%s)\n", __FUNCTION__, | |
321 | + ev->type == KeyPress? "keyPress": "keyRelease", | |
322 | + ev->xkey.keycode, ev->xkey.time, | |
323 | + window_name (w))); | |
312 | 324 | record_mouse_position (ev->xkey.x_root, ev->xkey.y_root, ev->type, 0); |
313 | 325 | |
314 | 326 | /* Don't look for a context map, frame parts are never focused */ |
@@ -1446,6 +1458,133 @@ inner_handle_input (repv arg) | ||
1446 | 1458 | return Qnil; |
1447 | 1459 | } |
1448 | 1460 | |
1461 | + | |
1462 | +static void | |
1463 | +report_event (XEvent *xev) | |
1464 | +{ | |
1465 | +#ifdef USE_XKB | |
1466 | + /* indeed!! */ | |
1467 | + if (debug_events) | |
1468 | + report_xkb_event(xev); | |
1469 | +#endif | |
1470 | + /* debugging + skipping Release */ | |
1471 | + switch (xev->type) | |
1472 | + { | |
1473 | + case KeyRelease: | |
1474 | + case KeyPress: | |
1475 | + { | |
1476 | + char buf[256]; /* static ? */ | |
1477 | + u_long code, mods; | |
1478 | + | |
1479 | + /* mmc: I prefer to see (the key combination pressed/release) here, | |
1480 | + * se I run the lookup here: */ | |
1481 | + if (!translate_event (&code, &mods, &xev)) | |
1482 | + break; /* why ??? */ | |
1483 | + | |
1484 | + lookup_event_name(buf, code, mods); | |
1485 | + | |
1486 | + | |
1487 | + char* name = "unknown window"; | |
1488 | + /* do i need to protect it from GC? */ | |
1489 | + Lisp_Window* kw = find_window_by_id(xev->xkey.window); | |
1490 | + if (kw) | |
1491 | + name = (char *) rep_STR (kw->name); | |
1492 | + else if (xev->xkey.window == no_focus_window) | |
1493 | + name = "no_focus_window"; | |
1494 | + else if (xev->xkey.window == root_window) | |
1495 | + name = (xev->xkey.subwindow == no_focus_window ) ? | |
1496 | + "no_focus_window via root_window" : "root_window"; | |
1497 | + | |
1498 | + // xev->xkey.subwindow | |
1499 | + if (debug_keys) /* & DB_EVENTS_TIME */ | |
1500 | + DB (("** Key: serial:%s%d%s %s %s time: %u %s%s%s/%d %d\n", | |
1501 | + keys_color ,xev->xkey.serial, color_reset, | |
1502 | + xev->type < LASTEvent ?event_names[xev->type]:"unknown event", | |
1503 | + buf, | |
1504 | + xev->xkey.time, /*my_timestamp(xev->xkey.time),*/ | |
1505 | + name, | |
1506 | + | |
1507 | + (kw && (kw->id == xev->xkey.window)) ? "window (grab?)" : | |
1508 | + ((kw && (kw->frame == xev->xkey.window)) ? "frame" : ""), | |
1509 | + | |
1510 | + (xev->xkey.subwindow == xev->xkey.window) ? "" : "->subwindow" | |
1511 | + ,xev->xkey.window, xev->xkey.subwindow | |
1512 | + /*xev->xkey.time*/ | |
1513 | + )); | |
1514 | + if (xev->type==KeyRelease | |
1515 | + && (global_symbol_value (Qeval_key_release_events) == Qnil)); | |
1516 | + /* why ?? ... so assert? */ | |
1517 | + break; | |
1518 | + } | |
1519 | + default: | |
1520 | + if (! ((xev->type == Expose) | |
1521 | + // || (xev->type == PropertyNotify) | |
1522 | + || (xev->type == VisibilityNotify) | |
1523 | + | |
1524 | + /* if i set DB_EVENTS_MISC -> i want to see even those */ | |
1525 | + || (!(debug_events & DB_EVENTS_MISC) | |
1526 | + && | |
1527 | + (((xev->type == UnmapNotify) | |
1528 | + || (xev->type == ConfigureNotify) | |
1529 | + || (xev->type == MapNotify)) | |
1530 | + && (xev->xany.window == root_window))) | |
1531 | + /* 64 root_window ... this means, that the event is reported to the root.*/ | |
1532 | + )) | |
1533 | + { | |
1534 | + /* do */ | |
1535 | + if (debug_events & DB_EVENTS_FLOW) | |
1536 | + { | |
1537 | + /* i'm not interested that the event arrived via root_window !! */ | |
1538 | + Window id = xev->xany.window; | |
1539 | + Window event = xev->xany.window; | |
1540 | + | |
1541 | + switch (xev->type){ | |
1542 | + case UnmapNotify: | |
1543 | + id = xev->xunmap.window; | |
1544 | + break; | |
1545 | + case MapNotify: | |
1546 | + id = xev->xmap.window; | |
1547 | + break; | |
1548 | + case ConfigureNotify: | |
1549 | + id = xev->xconfigure.window; | |
1550 | + break; | |
1551 | + case ConfigureRequest: | |
1552 | + id = xev->xconfigurerequest.window; | |
1553 | + break; | |
1554 | + /* Garbagge collection !!!! am i losing prompt b/c of that? */ | |
1555 | + case CreateNotify: /* */ | |
1556 | + id = xev->xcreatewindow.window; | |
1557 | + break; | |
1558 | + case DestroyNotify: | |
1559 | + id = xev->xdestroywindow.window; | |
1560 | + /* premature here? */ | |
1561 | + break; | |
1562 | + case MapRequest: | |
1563 | + id = xev->xmaprequest.window; | |
1564 | + break; | |
1565 | + default: | |
1566 | + id = xev->xany.window; | |
1567 | + }; | |
1568 | + Lisp_Window *w = find_window_by_id (id)? : find_window_by_frame(id); | |
1569 | + | |
1570 | + DB (("** Event: serial:%s%d%s: %s%s%s (event: %x win %x: %s)\n", | |
1571 | + event_color, xev->xkey.serial, color_reset, | |
1572 | + event_name_color, | |
1573 | + xev->type < LASTEvent ? event_names[xev->type] : "unknown", color_reset, | |
1574 | + event, id, | |
1575 | + (w) ? rep_STR (w->name) : (u_char *)"unknown")); | |
1576 | + } | |
1577 | + } else { | |
1578 | + /* give a small hint at the quantity.*/ | |
1579 | + DB(("%s%s%s", events_color, | |
1580 | + (xev->xany.window == no_focus_window) ? "F": | |
1581 | + (xev->xany.window == root_window) ? "R": "@", color_reset | |
1582 | + )); /* @ */ | |
1583 | + } | |
1584 | + }; | |
1585 | + | |
1586 | +} | |
1587 | + | |
1449 | 1588 | /* Handle all available X events matching event mask MASK. Or any events |
1450 | 1589 | if MASK is zero. */ |
1451 | 1590 | void |
@@ -1488,15 +1627,7 @@ handle_input_mask(long mask) | ||
1488 | 1627 | if (xev.type == NoExpose || xev.type == GraphicsExpose) |
1489 | 1628 | continue; |
1490 | 1629 | |
1491 | -#ifdef DEBUG | |
1492 | - do { | |
1493 | - Lisp_Window *w = x_find_window_by_id (xev.xany.window); | |
1494 | - DB(("** Event: %s (win %lx: %s)\n", | |
1495 | - xev.type < LASTEvent ? event_names[xev.type] : "unknown", | |
1496 | - (long)xev.xany.window, w ? (char *) rep_STR (w->name) : "unknown")); | |
1497 | - } while (0); | |
1498 | -#endif | |
1499 | - | |
1630 | + report_event (&xev); | |
1500 | 1631 | record_event_time (&xev); |
1501 | 1632 | current_x_event = &xev; |
1502 | 1633 | invalidate_cached_mouse_position (); |
@@ -43,6 +43,10 @@ | ||
43 | 43 | #include <X11/Xresource.h> |
44 | 44 | #include <X11/extensions/shape.h> |
45 | 45 | #include <assert.h> |
46 | +#include "debug.h" | |
47 | +#include "debug-colors.h" | |
48 | +int debug_frames; | |
49 | + | |
46 | 50 | |
47 | 51 | static XID window_fp_context; |
48 | 52 |
@@ -1386,6 +1390,7 @@ build_frame_part (struct frame_part *fp) | ||
1386 | 1390 | else |
1387 | 1391 | fp->rendered_image = Qnil; |
1388 | 1392 | |
1393 | + if (debug_frames) | |
1389 | 1394 | DB((" part: x=%d y=%d width=%d height=%d\n", |
1390 | 1395 | fp->x, fp->y, fp->width, fp->height)); |
1391 | 1396 |
@@ -1502,6 +1507,7 @@ list_frame_generator (Lisp_Window *w) | ||
1502 | 1507 | else |
1503 | 1508 | right_x = bottom_y = 0; |
1504 | 1509 | |
1510 | + if (debug_frames) | |
1505 | 1511 | DB(("list_frame_generator(%s)\n", rep_STR(w->name))); |
1506 | 1512 | |
1507 | 1513 | while (gen_list != Qnil && rep_SYMBOLP(gen_list) && !rep_INTERRUPTP) |
@@ -1585,6 +1591,7 @@ list_frame_generator (Lisp_Window *w) | ||
1585 | 1591 | w->frame_x = left_x; |
1586 | 1592 | w->frame_y = top_y; |
1587 | 1593 | |
1594 | + if (debug_frames) | |
1588 | 1595 | DB((" bounding box: x=%d y=%d width=%d height=%d\n", |
1589 | 1596 | left_x, top_y, w->frame_width, w->frame_height)); |
1590 | 1597 |
@@ -1729,6 +1736,7 @@ restack_frame_parts (Lisp_Window *w) | ||
1729 | 1736 | void |
1730 | 1737 | create_window_frame (Lisp_Window *w) |
1731 | 1738 | { |
1739 | + if (debug_frames) | |
1732 | 1740 | DB(("create_window_frame (%s)\n", rep_STR(w->name))); |
1733 | 1741 | if (w->frame_parts == 0) |
1734 | 1742 | { |
@@ -45,6 +45,10 @@ | ||
45 | 45 | #include <X11/Xatom.h> |
46 | 46 | #include <stdint.h> |
47 | 47 | |
48 | +#include "debug.h" | |
49 | +#include "debug-colors.h" | |
50 | +int debug_functions=0; | |
51 | + | |
48 | 52 | /* Number of outstanding server grabs made; only when this is zero is |
49 | 53 | the server ungrabbed. */ |
50 | 54 | static int server_grabs; |
@@ -85,12 +89,14 @@ windows isn't affected. | ||
85 | 89 | repv ptr; |
86 | 90 | Lisp_Window *pred; |
87 | 91 | |
92 | + /* check that it's a list of _windows_ */ | |
88 | 93 | rep_DECLARE1(list, rep_LISTP); |
89 | 94 | for (ptr = list; rep_CONSP (ptr); ptr = rep_CDR (ptr)) |
90 | 95 | { |
91 | 96 | if (!WINDOWP (rep_CAR (ptr))) |
92 | 97 | return rep_signal_arg_error (list, 1); |
93 | 98 | } |
99 | + /* end of the check*/ | |
94 | 100 | |
95 | 101 | if (list == Qnil) |
96 | 102 | return Qt; |
@@ -98,6 +104,8 @@ windows isn't affected. | ||
98 | 104 | ptr = list; |
99 | 105 | pred = 0; |
100 | 106 | |
107 | + if (debug_stacking) | |
108 | + DB (("%s%s%s\n", functions_color, __FUNCTION__, color_reset)); | |
101 | 109 | while (rep_CONSP (ptr)) |
102 | 110 | { |
103 | 111 | Lisp_Window *this = VWIN (rep_CAR (ptr)); |
@@ -50,6 +50,10 @@ static ImlibData *imlib_id; | ||
50 | 50 | GdkInterpType interp_type = GDK_INTERP_BILINEAR; |
51 | 51 | #endif |
52 | 52 | |
53 | +#include "debug.h" | |
54 | +#include "debug-colors.h" | |
55 | +int debug_images = 0; | |
56 | + | |
53 | 57 | Colormap image_cmap; |
54 | 58 | Visual *image_visual; |
55 | 59 | int image_depth; |
@@ -27,6 +27,10 @@ | ||
27 | 27 | #include <X11/keysym.h> |
28 | 28 | #include <X11/Xutil.h> |
29 | 29 | |
30 | +#include "debug.h" | |
31 | +#include "debug-colors.h" | |
32 | +int debug_keys; | |
33 | + | |
30 | 34 | /* max number of milliseconds between successive-clicks */ |
31 | 35 | #define DEFAULT_DOUBLE_CLICK_TIME 250 |
32 | 36 |
@@ -500,6 +500,7 @@ where OPTIONS are any of:\n\ | ||
500 | 500 | Fset (Qfonts_are_fontsets, Qnil); |
501 | 501 | } |
502 | 502 | |
503 | + set_init (); | |
503 | 504 | /* call all init funcs... */ |
504 | 505 | session_init (); |
505 | 506 | events_init (); |
@@ -0,0 +1,608 @@ | ||
1 | +#include "sawfish.h" | |
2 | +#include <sys/resource.h> | |
3 | +#include <time.h> | |
4 | + | |
5 | +/* fixme: this assumes a 255-color xterm! */ | |
6 | + | |
7 | +#ifdef USE_XKB | |
8 | +#include <X11/XKBlib.h> /* extensions/XKB.h */ | |
9 | +#include <X11/extensions/XKBstr.h> | |
10 | +extern int usexkb; | |
11 | +#endif /* USE_XKB */ | |
12 | + | |
13 | +#include <errno.h> | |
14 | +#include <assert.h> | |
15 | + | |
16 | +#include "debug.h" | |
17 | +#include "debug-colors.h" | |
18 | + | |
19 | + | |
20 | +const char* | |
21 | +window_name (Lisp_Window *w) | |
22 | +{ | |
23 | + /* todo: root_window or no_focus_window ? */ | |
24 | + repv name = (w)?(w->net_name != Qnil ? w->net_name : w->name) : NULL; | |
25 | + /* stolen from window-name */ | |
26 | + return (name ? (char *) rep_STR(name) : (w?"unknown":"NULL")); | |
27 | +} | |
28 | + | |
29 | +const char* | |
30 | +window_name_id (Lisp_Window *w, Window id) | |
31 | +{ | |
32 | + if (w) | |
33 | + return window_name(w); | |
34 | + else | |
35 | + return ((id == no_focus_window) ? "no_focus_window" | |
36 | + : ((id == root_window) ? "Root_window" : "unknown")); | |
37 | +} | |
38 | + | |
39 | +/* mmc: make a nice string format from the Time T | |
40 | + * only for debugging | |
41 | + */ | |
42 | + | |
43 | +char* | |
44 | +my_timestamp(Time t) | |
45 | +{ | |
46 | + static char buf[30]; /* like asctime */ | |
47 | + | |
48 | + /* fixme: non standard ?? */ | |
49 | + int sec= (int) t / 1000; | |
50 | + int min= (int) sec / 60; | |
51 | + int rest=(int) min / 60; | |
52 | + | |
53 | + min= min % 60; | |
54 | + sec= sec % 60; | |
55 | + | |
56 | + | |
57 | + | |
58 | + sprintf(buf, "%s%u:%2u:%02u:%02lu%s", | |
59 | + time_color, | |
60 | + rest, | |
61 | + min, | |
62 | + sec, | |
63 | + t % 1000, /* (t /10 ) */ | |
64 | + color_reset); | |
65 | + return buf; | |
66 | +} | |
67 | + | |
68 | +/* a useless confirmation? */ | |
69 | +bool | |
70 | +window_is_frame_part (Window id, Lisp_Window *w) | |
71 | +{ | |
72 | + struct frame_part* p = w->frame_parts; | |
73 | + while (p != NULL) | |
74 | + { | |
75 | + if (p->id == id) | |
76 | + return TRUE; | |
77 | + p = p->next; | |
78 | + } | |
79 | + return FALSE; | |
80 | +} | |
81 | + | |
82 | +Lisp_Window * | |
83 | +find_window_by_frame (Window id) | |
84 | +{ | |
85 | + Lisp_Window *w; | |
86 | + | |
87 | + w = window_list; | |
88 | + while (w != 0 && w->frame != id) | |
89 | + w = w->next; | |
90 | + return w; | |
91 | +} | |
92 | + | |
93 | + | |
94 | +inline char* | |
95 | +window_relation_desc (Lisp_Window *w, Window id) | |
96 | +{ | |
97 | + return ((id == w->id)? "(" window_color "itself" color_reset ")" : | |
98 | + ( (id == w->frame) ? "(" frame_window_color "frame" color_reset")" : | |
99 | + (window_is_frame_part (id, w) ? "frame_part" : "??" ))); | |
100 | +} | |
101 | + | |
102 | + | |
103 | +static char* focus_detail_names[]= | |
104 | +{ | |
105 | + "NotifyAncestor", | |
106 | + "NotifyVirtual", | |
107 | + "NotifyInferior", | |
108 | + "NotifyNonlinear", | |
109 | + "NotifyNonlinearVirtual", | |
110 | + "NotifyPointer", | |
111 | + "NotifyPointerRoot", | |
112 | + "NotifyDetailNone" | |
113 | +}; | |
114 | + | |
115 | + | |
116 | +char* focus_mode_string[] = | |
117 | +{ | |
118 | + /* taken from /usr/include/X11/X.h */ | |
119 | + "NotifyNormal", | |
120 | + "NotifyGrab", | |
121 | + "NotifyUngrab", | |
122 | + "NotifyWhileGrabbed", | |
123 | +}; | |
124 | + | |
125 | +char* buffer; | |
126 | + | |
127 | +#define color_fg(string, fg) (buffer = alloca(BUFFER_SIZE), \ | |
128 | + color_fg_string(string, fg, buffer)) | |
129 | + | |
130 | +void | |
131 | +describe_focus_in(XEvent *ev,Lisp_Window *w) | |
132 | +{ | |
133 | + assert (ev->xfocus.detail < 8); /* what is 8? */ | |
134 | + | |
135 | + int color= ((ev->xfocus.mode) == NotifyGrab)?145: | |
136 | + (((ev->xfocus.mode) == NotifyUngrab)?146:147); | |
137 | + | |
138 | + DB (("%s%s received %lu win = %" FMT_WIN ":%s(%s) mode: %s%s%s detail: %s%s%s\n", | |
139 | + color_fg("\x1b[38;5;",color), | |
140 | + /* "%s received %d win = %s mode: %s detail:\n", */ | |
141 | + //(ev->xfocus.type == FocusIn)? "focus_in": "focus_out", | |
142 | + __FUNCTION__, | |
143 | + | |
144 | + ev->xfocus.serial, | |
145 | + w->id, | |
146 | + window_name_id (w, ev->xfocus.window), | |
147 | + (w) ? window_relation_desc (w,ev->xfocus.window):"", | |
148 | + | |
149 | + color_fg("\x1b[38;5;", 116+ev->xfocus.mode), | |
150 | + (ev->xfocus.mode < sizeof(focus_mode_string)/sizeof(focus_mode_string[0])) ? | |
151 | + focus_mode_string[ev->xfocus.mode]:"<unexpected>!", | |
152 | + color_reset, | |
153 | + | |
154 | + color_fg("\x1b[38;5;", color), | |
155 | + /* focus_mode_color, */ | |
156 | + /* ev->xfocus.detail, */ | |
157 | + focus_detail_names[ev->xfocus.detail], | |
158 | + color_reset)); | |
159 | +} | |
160 | + | |
161 | +/*static */ | |
162 | +void | |
163 | +describe_focus_out(XEvent *ev, Lisp_Window *w) | |
164 | +{ | |
165 | + if (!(ev->xfocus.detail < (sizeof(focus_detail_names) /sizeof(focus_detail_names[0])))) | |
166 | + return; | |
167 | + | |
168 | + if (!w) | |
169 | + w = find_window_by_frame (ev->xfocus.window); | |
170 | + | |
171 | + char* window_name = window_name_id (w,ev->xfocus.window); | |
172 | + int color= ((ev->xfocus.mode) == NotifyGrab)? 36: | |
173 | + (((ev->xfocus.mode) == NotifyUngrab)?34:33); | |
174 | + | |
175 | + DB (("%s%s%s serial %lu win = %" FMT_WIN " %s(%s) mode: %s%s%s detail: %s%s%s\n", /* %d */ | |
176 | + /* "%s received %d win = %s mode: %s detail:\n", */ | |
177 | + color_fg("\x1b[38;5;",color), | |
178 | + __FUNCTION__, // (ev->xfocus.type == FocusIn)? "focus_in": "focus_out", | |
179 | + color_reset, | |
180 | + ev->xfocus.serial, | |
181 | + ev->xfocus.window, | |
182 | + window_name, | |
183 | + (w) ? window_relation_desc (w,ev->xfocus.window):"", | |
184 | + | |
185 | + color_fg("\x1b[38;5;", 116 + ev->xfocus.mode), | |
186 | + ((ev->xfocus.mode < sizeof(focus_mode_string)/sizeof(focus_mode_string[0]))? | |
187 | + focus_mode_string[ev->xfocus.mode]:"<unexpected>!"), | |
188 | + color_reset, | |
189 | + | |
190 | + /* detail: */ | |
191 | + color_fg("\x1b[38;5;", color), | |
192 | + focus_detail_names[ev->xfocus.detail], /* ev->xfocus.detail, */ | |
193 | + color_reset)); | |
194 | +}; | |
195 | + | |
196 | +extern int restack_fast; | |
197 | +int | |
198 | +set_int_variable(int* var, repv value) | |
199 | +{ | |
200 | + rep_DECLARE1 (value, rep_INTP); | |
201 | + | |
202 | + int old=*var; | |
203 | + *var = rep_INT(value); | |
204 | + return rep_MAKE_INT(old); | |
205 | +} | |
206 | + | |
207 | + | |
208 | +/* mmc: i should add incrementing/decrementing & commit-on-zero? */ | |
209 | +DEFUN("set-restack-fast", Fset_restack_fast, Sset_restack_fast, (repv debug), rep_Subr1) /* | |
210 | +::doc:sawfish.wm.events::set-restack-fast | |
211 | +make the following restacking operations immediate if 0, and posponed if 1 | |
212 | +::end:: */ | |
213 | +{ | |
214 | + rep_DECLARE1 (debug, rep_INTP); | |
215 | + return set_int_variable(&restack_fast, debug); | |
216 | +} | |
217 | + | |
218 | +extern bool be_proactive_in_move; | |
219 | + | |
220 | + | |
221 | +#if 0 | |
222 | +DEFUN("set-proactive-move", Fset_proactive_move, Sset_proactive_move, (repv debug), rep_Subr1) /* | |
223 | +::doc:sawfish.wm.events#set-proactive-move:: | |
224 | +set-proactive-move 0/1 | |
225 | +::end:: */ | |
226 | +{ | |
227 | + rep_DECLARE1 (debug, rep_INTP); | |
228 | + return set_int_variable(&be_proactive_in_move, debug); | |
229 | +} | |
230 | +#endif | |
231 | + | |
232 | + | |
233 | +DEFUN("set-debug-events", Fset_debug_events, Sset_debug_events, (repv debug), rep_Subr1) /* | |
234 | +::doc:sawfish.wm.events#set-debug-events:: | |
235 | +set-debug-events 0/1 | |
236 | +::end:: */ | |
237 | +{ | |
238 | + rep_DECLARE1 (debug, rep_INTP); | |
239 | + return set_int_variable(&debug_events, debug); | |
240 | +} | |
241 | + | |
242 | +DEFUN("set-debug-windows", Fset_debug_windows, Sset_debug_windows, (repv debug), rep_Subr1) /* | |
243 | +::doc:sawfish.wm.windows#set-debug-windows:: | |
244 | +set-debug-windows 0/1 | |
245 | +::end:: */ | |
246 | +{ | |
247 | + rep_DECLARE1 (debug, rep_INTP); | |
248 | + return set_int_variable(&debug_windows, debug); | |
249 | +} | |
250 | + | |
251 | + | |
252 | +DEFUN("set-debug-keys", Fset_debug_keys, Sset_debug_keys, (repv debug), rep_Subr1) /* | |
253 | +::doc:sawfish.wm.events::set-debug-keys | |
254 | +set-debug-keys 0/1 | |
255 | +::end:: */ | |
256 | +{ | |
257 | + rep_DECLARE1 (debug, rep_INTP); | |
258 | + return set_int_variable(&debug_keys, debug); | |
259 | +} | |
260 | + | |
261 | +DEFUN("set-debug-stacking", Fset_debug_stacking, Sset_debug_stacking, (repv debug), rep_Subr1) /* | |
262 | +::doc:sawfish.wm.events::set-debug-keys | |
263 | +set-debug-keys 0/1 | |
264 | +::end:: */ | |
265 | +{ | |
266 | + rep_DECLARE1 (debug, rep_INTP); | |
267 | + return set_int_variable(&debug_stacking, debug); | |
268 | +} | |
269 | + | |
270 | + | |
271 | +#ifdef USE_XKB | |
272 | +/* work-in-progress? */ | |
273 | +DEFUN("set-xkb-event-mask", Fset_xkb_event_mask, Sset_xkb_event_mask, (repv mask, repv value), rep_Subr2) /* | |
274 | +::doc:sawfish.wm.events::set-debug-keys | |
275 | +set-debug-keys 0/1 | |
276 | +::end:: */ | |
277 | +{ | |
278 | + rep_DECLARE1 (mask, rep_INTP); | |
279 | + rep_DECLARE2 (value, rep_INTP); | |
280 | + | |
281 | + if (usexkb) | |
282 | + /* i want to report them. */ | |
283 | + XkbSelectEvents(dpy, XkbUseCoreKbd, rep_INT(mask), rep_INT(value)); /* `set' */ | |
284 | +/* XkbSelectEventsDetails(dpy, XkbUseCoreKbd, XkbMapNotifyMask, XkbMapNotifyMask); `set' */ | |
285 | +/* return set_int_variable(&xallowevents_handling, debug); */ | |
286 | + return Qnil; | |
287 | +} | |
288 | + | |
289 | + | |
290 | +#endif | |
291 | + | |
292 | + | |
293 | + | |
294 | +DEFUN("set-debug-functions", Fset_debug_functions, Sset_debug_functions, (repv debug), rep_Subr1) /* | |
295 | +::doc:sawfish.wm.events::set-debug-functions | |
296 | +set-debug-functions 0/1 | |
297 | +::end:: */ | |
298 | +{ | |
299 | + rep_DECLARE1 (debug, rep_INTP); | |
300 | + return set_int_variable(&debug_functions, debug); | |
301 | +} | |
302 | + | |
303 | + | |
304 | +DEFUN("set-debug-display", Fset_debug_display, Sset_debug_display, (repv debug), rep_Subr1) /* | |
305 | +::doc:sawfish.wm.events::set-debug-display | |
306 | +set-debug-display 0/1 | |
307 | +::end:: */ | |
308 | +{ | |
309 | + rep_DECLARE1 (debug, rep_INTP); | |
310 | + return set_int_variable(&debug_display, debug); | |
311 | +} | |
312 | + | |
313 | + | |
314 | +DEFUN("set-debug-images", Fset_debug_images, Sset_debug_images, (repv debug), rep_Subr1) /* | |
315 | +::doc:sawfish.wm.events::set-debug-images | |
316 | +set-debug-images 0/1 | |
317 | +::end:: */ | |
318 | +{ | |
319 | + rep_DECLARE1 (debug, rep_INTP); | |
320 | + return set_int_variable(&debug_images, debug); | |
321 | +} | |
322 | + | |
323 | +DEFUN("set-debug-cache", Fset_debug_cache, Sset_debug_cache, (repv debug), rep_Subr1) /* | |
324 | +::doc:sawfish.wm.events::set-debug-cache | |
325 | +set-debug-cache 0/1 | |
326 | +::end:: */ | |
327 | +{ | |
328 | + rep_DECLARE1 (debug, rep_INTP); | |
329 | + return set_int_variable(&debug_cache, debug); | |
330 | +} | |
331 | + | |
332 | +#if 0 | |
333 | +DEFUN("set-grab-owner", Fset_grab_owner, Sset_grab_owner, (repv owner), rep_Subr1) /* | |
334 | +::doc:sawfish.wm.events::set-debug-display | |
335 | +set-debug-display 0/1 | |
336 | +::end:: */ | |
337 | +{ | |
338 | + rep_DECLARE1 (owner, rep_INTP); /* fixme: should be boolean! */ | |
339 | + return set_int_variable(&default_grab_owner, owner); | |
340 | +} | |
341 | +#endif | |
342 | + | |
343 | +DEFUN("next-request", Fnext_request, Snext_request, (void), rep_Subr0) /* | |
344 | +::doc:sawfish.wm.events::next-request | |
345 | +next-request | |
346 | +::end:: */ | |
347 | +{ | |
348 | + return rep_MAKE_INT(NextRequest(dpy)); | |
349 | +} | |
350 | + | |
351 | +DEFUN("set-debug-frames", Fset_debug_frames, Sset_debug_frames, (repv debug), rep_Subr1) /* | |
352 | +::doc:sawfish.wm.events::set-debug-frames | |
353 | +set-debug-frames 0/1 | |
354 | +::end:: */ | |
355 | +{ | |
356 | + rep_DECLARE1 (debug, rep_INTP); | |
357 | + return set_int_variable(&debug_frames, debug); | |
358 | +} | |
359 | + | |
360 | +#if 0 | |
361 | +DEFUN("set-debug-frame-part", Fset_debug_frame_part, Sset_debug_frame_part, (repv debug), rep_Subr1) /* | |
362 | +::doc:sawfish.wm.events::set-debug-frames | |
363 | +set-debug-frames 0/1 | |
364 | +::end:: */ | |
365 | +{ | |
366 | + rep_DECLARE1 (debug, rep_INTP); | |
367 | + return set_int_variable(&debug_frame_part, debug); | |
368 | +} | |
369 | + | |
370 | + | |
371 | +DEFUN("set-dont-allow-events", Fset_dont_allow_events, Sset_dont_allow_events, (repv debug), rep_Subr1) /* | |
372 | +::doc:sawfish.wm.events::set-dont-allow-event | |
373 | +::set-dont-allow-event 0/1 | |
374 | +::end:: */ | |
375 | +{ | |
376 | + rep_DECLARE1 (debug, rep_INTP); | |
377 | + DB(("set-dont-allow-events %d -> %d (now)\n", dont_allow_events, rep_INT(debug))); | |
378 | + return set_int_variable(&dont_allow_events, debug); | |
379 | +} | |
380 | +#endif | |
381 | + | |
382 | +int frame_options; | |
383 | + | |
384 | +DEFUN("set-frame-options", Fset_frame_options, Sset_frame_options, (repv debug), rep_Subr1) /* | |
385 | +::doc:sawfish.wm.events::set-frame-options | |
386 | +set-frame-options 0/1 | |
387 | +::end:: */ | |
388 | +{ | |
389 | + rep_DECLARE1 (debug, rep_INTP); | |
390 | + return set_int_variable(&frame_options, debug); | |
391 | +} | |
392 | + | |
393 | + | |
394 | + | |
395 | +int window_options; | |
396 | + | |
397 | +DEFUN("set-window-options", Fset_window_options, Sset_window_options, (repv debug), rep_Subr1) /* | |
398 | +::doc:sawfish.wm.events::set-frame-options | |
399 | +set-frame-options 0/1 | |
400 | +::end:: */ | |
401 | +{ | |
402 | + rep_DECLARE1 (debug, rep_INTP); | |
403 | + return set_int_variable(&window_options, debug); | |
404 | +} | |
405 | + | |
406 | + | |
407 | + | |
408 | + | |
409 | +/* Run external program w/ UID (su) | |
410 | + * set & get priority. | |
411 | + * */ | |
412 | + | |
413 | +DEFUN("get-priority", Fget_priority, Sget_priority, (repv which, repv who), rep_Subr2) /* | |
414 | +::doc:sawfish.wm.events::set-debug-display | |
415 | +(get-priority 0 0) to get the sawfish WM process's priority. | |
416 | +::end:: */ | |
417 | +{ | |
418 | + rep_DECLARE1(which, rep_INTP); | |
419 | + rep_DECLARE2(who, rep_INTP); | |
420 | + | |
421 | +#if 0 | |
422 | +enum __priority_which | |
423 | +{ | |
424 | + PRIO_PROCESS = 0, /* WHO is a process ID. */ | |
425 | +#define PRIO_PROCESS PRIO_PROCESS | |
426 | + PRIO_PGRP = 1, /* WHO is a process group ID. */ | |
427 | +#define PRIO_PGRP PRIO_PGRP | |
428 | + PRIO_USER = 2 /* WHO is a user ID. */ | |
429 | +#define PRIO_USER PRIO_USER | |
430 | +}; | |
431 | +#endif | |
432 | + | |
433 | + | |
434 | + | |
435 | + int c_which = rep_INT(which); | |
436 | + if ((c_which == PRIO_PROCESS) | |
437 | + || (c_which == PRIO_PGRP) | |
438 | + || (c_which == PRIO_USER)) | |
439 | + { | |
440 | + /* Since getpriority() can legitimately return the value -1, it is necessary to clear the | |
441 | + external variable errno prior to the call */ | |
442 | + errno = 0; | |
443 | + int res = getpriority(c_which, rep_INT(who)); | |
444 | + | |
445 | + if ((res == -1) && errno) | |
446 | + { | |
447 | + /* throw error! */ | |
448 | + return rep_FALSE; | |
449 | + /* rep_handle_error */ | |
450 | + return rep_signal_arg_error(which, 0); | |
451 | + } | |
452 | + else | |
453 | + { | |
454 | + return rep_MAKE_INT(res); | |
455 | + } | |
456 | + } | |
457 | + else return rep_signal_arg_error(which, 0); | |
458 | +} | |
459 | + | |
460 | + | |
461 | + | |
462 | + | |
463 | +static repv | |
464 | +reopen_stdio_stream(FILE** pointer, char* filename) | |
465 | +{ | |
466 | + /* can access? */ | |
467 | + /* FILE* */ | |
468 | + FILE* result = freopen(filename, "a", *pointer); | |
469 | + if (result){ | |
470 | + | |
471 | + /* setlinebuf(result); */ | |
472 | + setvbuf(result, (char *)NULL, _IONBF, 0); | |
473 | + } else | |
474 | + { | |
475 | + /*disaster!!! */ | |
476 | + XBell(dpy,0); | |
477 | + result = freopen("/dev/null", "a", *pointer); | |
478 | + }; | |
479 | + assert(result); | |
480 | + | |
481 | + *pointer = result; | |
482 | + DB(("%s: %s %d\n", __FUNCTION__, result?"ok":"error!", result?fileno(result):-1)); | |
483 | + return result?rep_TRUE:rep_FALSE; | |
484 | +} | |
485 | + | |
486 | + | |
487 | + | |
488 | + | |
489 | + | |
490 | + | |
491 | +DEFUN("reopen-stderr", Freopen_stderr, Sreopen_stderr, (repv filename), rep_Subr1) /* | |
492 | +::doc:sawfish.wm.events::reopen-stderr | |
493 | +redirect-stderr-to filename | |
494 | +::end:: */ | |
495 | +{ | |
496 | + rep_DECLARE1(filename, rep_STRINGP); | |
497 | + | |
498 | + FILE **stdio_stream = &stderr; | |
499 | + | |
500 | + repv result = reopen_stdio_stream (&stderr, rep_STR(filename)); | |
501 | + | |
502 | + repv stream = Fstderr_file(); | |
503 | + rep_FILE(stream)->file.fh = *stdio_stream; | |
504 | + return result?rep_TRUE:rep_FALSE; | |
505 | +} | |
506 | + | |
507 | + | |
508 | +DEFUN("reopen-stdout", Freopen_stdout, Sreopen_stdout, (repv filename), rep_Subr1) /* | |
509 | +::doc:sawfish.wm.events::reopen-stdout | |
510 | +redirect-stdout-to filename | |
511 | +::end:: */ | |
512 | +{ | |
513 | + rep_DECLARE1(filename, rep_STRINGP); | |
514 | + | |
515 | + FILE **stdio_stream = &stdout; | |
516 | + repv result = reopen_stdio_stream (stdio_stream, rep_STR(filename)); | |
517 | + | |
518 | + repv stream = Fstdout_file(); | |
519 | + rep_FILE(stream)->file.fh = *stdio_stream; | |
520 | + return result?rep_TRUE:rep_FALSE; | |
521 | +} | |
522 | + | |
523 | + | |
524 | + | |
525 | +#if 0 | |
526 | +bool | |
527 | +reopen_lisp_stream(repv stream, char* filename) | |
528 | +{ | |
529 | + /* assert (stream_p()) */ | |
530 | + FILE **stdio_stream = &(rep_FILE(stream)->file.fh); /* ??? */ | |
531 | + /* if (*strio_stream) */ | |
532 | + repv result = reopen_stdio_stream (stdio_stream, rep_STR(filename)); | |
533 | + rep_FILE(stream)->file.fh = *stdio_stream; | |
534 | +} | |
535 | + | |
536 | + | |
537 | + | |
538 | +reopen_lisp_stream(Fstdout_file()); | |
539 | +#endif | |
540 | + | |
541 | +static int | |
542 | +get_int_variable_from_env(char* name, int* variable) | |
543 | +{ | |
544 | + if (getenv(name) != NULL) | |
545 | + { | |
546 | + *variable = atoi(getenv(name)); | |
547 | + DB(("using the ENV VAR $%s = %s -> %d\n", name, getenv(name), *variable)); | |
548 | + return *variable; | |
549 | + } | |
550 | + return 0; | |
551 | +} | |
552 | + | |
553 | + | |
554 | +void | |
555 | +set_init (void) | |
556 | +{ | |
557 | + repv tem; | |
558 | + | |
559 | + tem = rep_push_structure ("sawfish.wm.windows.subrs"); | |
560 | + | |
561 | + | |
562 | + /* rep_ADD_SUBR(Sstart_restacking); */ | |
563 | + rep_ADD_SUBR(Sreopen_stderr); | |
564 | + rep_ADD_SUBR(Sreopen_stdout); | |
565 | + | |
566 | + rep_ADD_SUBR(Sget_priority); | |
567 | + rep_ADD_SUBR(Sset_restack_fast); | |
568 | + | |
569 | + rep_ADD_SUBR(Sset_debug_functions); | |
570 | + rep_ADD_SUBR(Sset_debug_display); | |
571 | + rep_ADD_SUBR(Sset_debug_images); | |
572 | + rep_ADD_SUBR(Sset_debug_cache); | |
573 | + | |
574 | + rep_ADD_SUBR(Snext_request); | |
575 | + rep_pop_structure (tem); | |
576 | + | |
577 | + tem = rep_push_structure ("sawfish.wm.events"); | |
578 | +#if 0 | |
579 | + rep_ADD_SUBR(Sset_grab_owner); | |
580 | + rep_ADD_SUBR(Sset_dont_allow_events); | |
581 | + rep_ADD_SUBR(Sset_debug_frame_part); | |
582 | + rep_ADD_SUBR(Sset_frame_options); | |
583 | + rep_ADD_SUBR(Sset_window_options); | |
584 | + rep_ADD_SUBR(Sset_xkb_event_mask); | |
585 | + rep_ADD_SUBR(Sset_proactive_move); | |
586 | + | |
587 | + rep_INTERN_SPECIAL(debug_events); | |
588 | + Fset (Qdebug_events, rep_MAKE_INT(0)); | |
589 | + rep_ADD_SUBR(Sset_xallowevents_handling); | |
590 | +#endif | |
591 | + rep_ADD_SUBR(Sset_debug_events); | |
592 | + rep_ADD_SUBR(Sset_debug_windows); | |
593 | + rep_ADD_SUBR(Sset_debug_keys); | |
594 | + rep_ADD_SUBR(Sset_debug_stacking); | |
595 | + | |
596 | + rep_ADD_SUBR(Sset_debug_frames); | |
597 | + | |
598 | + rep_pop_structure (tem); | |
599 | + | |
600 | + /* initial debug. */ | |
601 | + get_int_variable_from_env("SAWFISH_DEBUG_STACKING", &debug_stacking); | |
602 | + get_int_variable_from_env("SAWFISH_DEBUG_WINDOWS", &debug_windows); | |
603 | + get_int_variable_from_env("SAWFISH_DEBUG_FUNCTIONS", &debug_functions); | |
604 | + | |
605 | + get_int_variable_from_env("SAWFISH_DEBUG_EVENTS", &debug_events); | |
606 | + get_int_variable_from_env("SAWFISH_DEBUG_KEYS", &debug_keys); | |
607 | + get_int_variable_from_env("SAWFISH_DEBUG_FRAMES", &debug_frames); | |
608 | +} |
@@ -42,6 +42,10 @@ | ||
42 | 42 | static unsigned long cached_pixels, max_cached_pixels = 64 * 1024; |
43 | 43 | static unsigned long hits, misses; |
44 | 44 | |
45 | +#include "debug.h" | |
46 | +#include "debug-colors.h" | |
47 | +int debug_cache; | |
48 | + | |
45 | 49 | #ifdef NEED_PIXMAP_CACHE |
46 | 50 | |
47 | 51 | struct pixmap_cache_node_struct { |
@@ -144,12 +148,16 @@ pixmap_cache_ref (Lisp_Image *im, int width, int height, | ||
144 | 148 | remove_from_age_list (n); |
145 | 149 | prepend_to_age_list (n); |
146 | 150 | n->ref_count++; |
151 | + if (debug_cache & DB_CACHE_REF) | |
152 | + DB(("%s now: %d\n", __FUNCTION__, n->ref_count)); | |
147 | 153 | *p1 = n->p1; |
148 | 154 | *p2 = n->p2; |
149 | 155 | hits++; |
150 | 156 | return TRUE; |
151 | 157 | } |
152 | 158 | } |
159 | + if (debug_cache & DB_CACHE_MISS) | |
160 | + DB(("%s missed!\n", __FUNCTION__)); | |
153 | 161 | misses++; |
154 | 162 | return FALSE; |
155 | 163 | } |
@@ -163,6 +171,8 @@ pixmap_cache_unref (Lisp_Image *im, Pixmap p1, Pixmap p2) | ||
163 | 171 | if (n->p1 == p1 && n->p2 == p2) |
164 | 172 | { |
165 | 173 | n->ref_count--; |
174 | + if (debug_cache & DB_CACHE_REF) | |
175 | + DB(("%s remain %d\n", __FUNCTION__, n->ref_count)); | |
166 | 176 | #ifdef DISABLE_CACHE |
167 | 177 | if (n->ref_count == 0) |
168 | 178 | delete_node (n, TRUE); |
@@ -170,6 +180,8 @@ pixmap_cache_unref (Lisp_Image *im, Pixmap p1, Pixmap p2) | ||
170 | 180 | return; |
171 | 181 | } |
172 | 182 | } |
183 | + if (debug_cache) | |
184 | + DB(("%s\n", __FUNCTION__)); | |
173 | 185 | fprintf (stderr, "warning: unref'ing unknown image in pixmap-cache\n"); |
174 | 186 | } |
175 | 187 |
@@ -179,7 +191,9 @@ pixmap_cache_set (Lisp_Image *im, int width, int height, | ||
179 | 191 | { |
180 | 192 | int pixel_count = width * height; |
181 | 193 | pixmap_cache_node *n = 0; |
194 | + int deleted = 0; | |
182 | 195 | |
196 | + /* shring the cache: */ | |
183 | 197 | while (pixel_count + cached_pixels > max_cached_pixels) |
184 | 198 | { |
185 | 199 | /* remove oldest node */ |
@@ -189,9 +203,12 @@ pixmap_cache_set (Lisp_Image *im, int width, int height, | ||
189 | 203 | if (this == 0) |
190 | 204 | break; |
191 | 205 | delete_node (this, n != 0); |
206 | + ++deleted; | |
192 | 207 | if (n == 0) |
193 | 208 | n = this; |
194 | 209 | } |
210 | + if (debug_cache & DB_CACHE_DELETE) | |
211 | + DB(("%s had to delete %d nodes.\n", __FUNCTION__, deleted)); | |
195 | 212 | |
196 | 213 | if (n == 0) |
197 | 214 | n = rep_alloc (sizeof (pixmap_cache_node)); |
@@ -212,6 +229,8 @@ void | ||
212 | 229 | pixmap_cache_flush_image (Lisp_Image *im) |
213 | 230 | { |
214 | 231 | pixmap_cache_node *n, *next; |
232 | + if (debug_cache) | |
233 | + DB(("%s %p\n", __FUNCTION__, im)); | |
215 | 234 | for (n = im->pixmap_first; n != 0; n = next) |
216 | 235 | { |
217 | 236 | next = n->next; |
@@ -50,20 +50,16 @@ property_cache_ref (repv id, repv prop) | ||
50 | 50 | |
51 | 51 | h = CACHE_HASH (id, prop) * CACHE_ASSOC; |
52 | 52 | |
53 | - DB (("prop ref: 0x%x,%s (%d) -> ", id, rep_STR (rep_SYM (prop)->name), h)); | |
54 | - | |
55 | 53 | for (i = h; i < h + CACHE_ASSOC; i++) |
56 | 54 | { |
57 | 55 | if (cache_ids[i] == id && cache_props[i] == prop) |
58 | 56 | { |
59 | 57 | cache_hits++; |
60 | - DB (("hit\n")); | |
61 | 58 | cache_ages[i] = ++cache_clock; |
62 | 59 | return cache_values[i]; |
63 | 60 | } |
64 | 61 | } |
65 | 62 | |
66 | - DB (("miss\n")); | |
67 | 63 | cache_misses++; |
68 | 64 | return rep_NULL; |
69 | 65 | } |
@@ -106,16 +102,11 @@ property_cache_set (repv id, repv prop, repv value, int invals) | ||
106 | 102 | |
107 | 103 | assert (oldest != -1); |
108 | 104 | |
109 | - if (cache_ids[oldest] != 0) | |
110 | - DB (("prop eject: 0x%x (%d)\n", cache_ids[oldest], oldest)); | |
111 | - | |
112 | 105 | cache_ids[oldest] = id; |
113 | 106 | cache_props[oldest] = prop; |
114 | 107 | cache_values[oldest] = value; |
115 | 108 | cache_ages[oldest] = ++cache_clock; |
116 | 109 | cache_updates[oldest] = invals; |
117 | - | |
118 | - DB (("set: 0x%x,%s (%d)\n", id, rep_STR (rep_SYM (prop)->name), oldest)); | |
119 | 110 | } |
120 | 111 | |
121 | 112 | void |
@@ -58,6 +58,7 @@ extern Window root_window, no_focus_window; | ||
58 | 58 | extern Atom xa_wm_state, xa_wm_change_state, xa_wm_protocols, |
59 | 59 | xa_wm_delete_window, xa_wm_colormap_windows, xa_wm_take_focus, |
60 | 60 | xa_compound_text, xa_wm_net_name, xa_wm_net_icon_name, xa_utf8_string; |
61 | +extern Atom ignore_atoms[2]; /* _WIN_AREA _WIN_WORKSPACE */ | |
61 | 62 | extern int shape_event_base, shape_error_base; |
62 | 63 | extern repv Qdisplay_name, Qcanonical_display_name; |
63 | 64 | extern bool sys_init (char *program_name); |
@@ -367,4 +368,14 @@ extern void insert_in_stacking_list_below (Lisp_Window *w, Lisp_Window *x); | ||
367 | 368 | extern void restack_window (Lisp_Window *w); |
368 | 369 | extern repv make_stacking_list (void); |
369 | 370 | |
371 | +/* from mmc.c */ | |
372 | +extern const char* window_name (Lisp_Window *w); | |
373 | +extern const char* window_name_id (Lisp_Window *w, Window id); | |
374 | +extern char* my_timestamp(Time t); | |
375 | +extern void describe_focus_out(XEvent *ev, Lisp_Window *w); | |
376 | +extern void describe_focus_in(XEvent *ev,Lisp_Window *w); | |
377 | + | |
378 | +extern void set_init (void); | |
379 | + | |
380 | + | |
370 | 381 | #endif /* SAWFISH_SUBRS_H */ |
@@ -24,6 +24,10 @@ | ||
24 | 24 | |
25 | 25 | #include "sawfish.h" |
26 | 26 | #include <assert.h> |
27 | +#include "debug.h" | |
28 | +#include "debug-colors.h" | |
29 | +int debug_stacking; | |
30 | + | |
27 | 31 | |
28 | 32 | static Lisp_Window *lowest_window, *highest_window; |
29 | 33 |
@@ -25,6 +25,11 @@ | ||
25 | 25 | #include <X11/extensions/shape.h> |
26 | 26 | #include <glib.h> |
27 | 27 | |
28 | +#include "debug.h" | |
29 | +#include "debug-colors.h" | |
30 | +int debug_windows; | |
31 | + | |
32 | + | |
28 | 33 | Lisp_Window *window_list; |
29 | 34 | int window_type; |
30 | 35 |
@@ -99,6 +104,10 @@ mapped_not_override_p (Window id) | ||
99 | 104 | XWindowAttributes wa; |
100 | 105 | |
101 | 106 | XGetWindowAttributes(dpy, id, &wa); |
107 | + if (debug_windows & DB_WINDOWS_REST) | |
108 | + DB (("%s %" FMT_WIN " %s %s\n", __FUNCTION__, id, | |
109 | + (wa.map_state == IsUnmapped)?"is unmapped!":"", | |
110 | + (wa.override_redirect == True)?"has override!":"")); | |
102 | 111 | return ((wa.map_state != IsUnmapped) && (wa.override_redirect != True)); |
103 | 112 | } |
104 | 113 |
@@ -143,7 +152,7 @@ commit_queued_focus_change (void) | ||
143 | 152 | { |
144 | 153 | if (queued_take_focus) |
145 | 154 | { |
146 | - DB((" sending WM_TAKE_FOCUS %x %ld\n", | |
155 | + DB((" sending WM_TAKE_FOCUS %" FMT_WIN " %ld\n", | |
147 | 156 | (unsigned) queued_focus_id, queued_focus_time)); |
148 | 157 | send_client_message (queued_focus_id, |
149 | 158 | xa_wm_take_focus, |
@@ -151,7 +160,7 @@ commit_queued_focus_change (void) | ||
151 | 160 | } |
152 | 161 | if (queued_set_focus) |
153 | 162 | { |
154 | - DB((" focusing %x %ld\n", | |
163 | + DB((" focusing %" FMT_WIN " %ld\n", | |
155 | 164 | (unsigned) queued_focus_id, queued_focus_time)); |
156 | 165 | XSetInputFocus (dpy, queued_focus_id, |
157 | 166 | queued_focus_revert, queued_focus_time); |
@@ -231,6 +240,8 @@ get_window_protocols (Lisp_Window *w) | ||
231 | 240 | int n; |
232 | 241 | w->does_wm_take_focus = 0; |
233 | 242 | w->does_wm_delete_window = 0; |
243 | + if (debug_windows & DB_WINDOWS_REST) | |
244 | + DB (("W: %s: %s\n",__FUNCTION__,rep_STR(w->name))); | |
234 | 245 | if (XGetWMProtocols (dpy, w->id, &prot, &n) != 0) |
235 | 246 | { |
236 | 247 | int i; |
@@ -239,12 +250,14 @@ get_window_protocols (Lisp_Window *w) | ||
239 | 250 | if (prot[i] == xa_wm_take_focus) |
240 | 251 | { |
241 | 252 | w->does_wm_take_focus = 1; |
242 | - DB((" WM_TAKE_FOCUS is set\n")); | |
253 | + if (debug_windows & DB_WINDOWS_PROT) | |
254 | + DB (("W: WM_TAKE_FOCUS is set\n")); | |
243 | 255 | } |
244 | 256 | if (prot[i] == xa_wm_delete_window) |
245 | 257 | { |
246 | 258 | w->does_wm_delete_window = 1; |
247 | - DB((" WM_DELETE_WINDOW is set\n")); | |
259 | + if (debug_windows & DB_WINDOWS_PROT) | |
260 | + DB (("W: WM_DELETE_WINDOW is set\n")); | |
248 | 261 | } |
249 | 262 | } |
250 | 263 | XFree (prot); |
@@ -279,8 +292,12 @@ find_window_by_id (Window id) | ||
279 | 292 | { |
280 | 293 | Lisp_Window *w; |
281 | 294 | w = window_list; |
295 | + if (debug_windows & DB_WINDOWS_FIND) | |
296 | + DB(("%s searching for %" FMT_WIN "\n", __FUNCTION__, id)); | |
282 | 297 | while (w != 0 && w->id != id && w->frame != id) |
283 | 298 | w = w->next; |
299 | + if (debug_windows & DB_WINDOWS_FIND) | |
300 | + DB(("%s %sfound\n", __FUNCTION__, (w)?"":"not ")); | |
284 | 301 | if (w != 0 && WINDOW_IS_GONE_P (w)) |
285 | 302 | w = 0; |
286 | 303 | return w; |
@@ -301,7 +318,8 @@ x_find_window_by_id (Window id) | ||
301 | 318 | void |
302 | 319 | install_window_frame (Lisp_Window *w) |
303 | 320 | { |
304 | - DB(("install_window_frame (%s)\n", rep_STR(w->name))); | |
321 | + if ((debug_windows & DB_WINDOWS_FRAME) || debug_frames) | |
322 | + DB (("%s%s%s on %s\n", reparent_color,__FUNCTION__, color_reset, rep_STR(w->name))); | |
305 | 323 | if (!w->reparented && w->frame != 0 && !WINDOW_IS_GONE_P (w)) |
306 | 324 | { |
307 | 325 | XSetWindowAttributes wa; |
@@ -309,6 +327,9 @@ install_window_frame (Lisp_Window *w) | ||
309 | 327 | XSelectInput (dpy, w->frame, FRAME_EVENTS); |
310 | 328 | |
311 | 329 | before_local_map (w); |
330 | + if (debug_windows & DB_WINDOWS_FRAME) | |
331 | + DB(("%sXReparentWindow: %" FMT_WIN " %s -> %" FMT_WIN "%s\n", reparent_color, | |
332 | + w->id, rep_STR(w->name), w->frame, color_reset)); | |
312 | 333 | XReparentWindow (dpy, w->id, w->frame, -w->frame_x, -w->frame_y); |
313 | 334 | w->reparented = TRUE; |
314 | 335 | after_local_map (w); |
@@ -324,16 +345,18 @@ install_window_frame (Lisp_Window *w) | ||
324 | 345 | wa.win_gravity = StaticGravity; |
325 | 346 | XChangeWindowAttributes (dpy, w->id, CWWinGravity, &wa); |
326 | 347 | |
327 | - DB((" reparented to %lx [%dx%d%+d%+d]\n", | |
328 | - w->frame, w->frame_width, w->frame_height, | |
329 | - w->frame_x, w->frame_y)); | |
348 | + if (debug_windows & DB_WINDOWS_FRAME) | |
349 | + DB((" reparented to %" FMT_WIN " [%dx%d%+d%+d]\n", | |
350 | + w->frame, w->frame_width, w->frame_height, | |
351 | + w->frame_x, w->frame_y)); | |
330 | 352 | } |
331 | 353 | } |
332 | 354 | |
333 | 355 | void |
334 | 356 | remove_window_frame (Lisp_Window *w) |
335 | 357 | { |
336 | - DB(("remove_window_frame (%s)\n", rep_STR(w->name))); | |
358 | + if (debug_windows & DB_WINDOWS_FRAME) | |
359 | + DB (("%s%s%s %s\n", reparent_color, __FUNCTION__, color_reset, rep_STR(w->name))); | |
337 | 360 | if (w->reparented && !WINDOW_IS_GONE_P (w)) |
338 | 361 | { |
339 | 362 | XSetWindowAttributes wa; |
@@ -343,6 +366,8 @@ remove_window_frame (Lisp_Window *w) | ||
343 | 366 | wa.win_gravity = w->attr.win_gravity; |
344 | 367 | XChangeWindowAttributes (dpy, w->id, CWWinGravity, &wa); |
345 | 368 | |
369 | + DB(("%sXReparentWindow: %" FMT_WIN " %s%s -> root_window at %s%d,%d%s\n", reparent_color, | |
370 | + w->id, rep_STR(w->name), color_reset, reparent_color, w->attr.x, w->attr.y, color_reset)); | |
346 | 371 | before_local_map (w); |
347 | 372 | XReparentWindow (dpy, w->id, root_window, w->attr.x, w->attr.y); |
348 | 373 | w->reparented = FALSE; |
@@ -354,6 +379,9 @@ remove_window_frame (Lisp_Window *w) | ||
354 | 379 | |
355 | 380 | if (!w->mapped) |
356 | 381 | XRemoveFromSaveSet (dpy, w->id); |
382 | + } else { | |
383 | + if (debug_windows & DB_WINDOWS_FRAME) | |
384 | + DB (("%s: window is gone, or reparented outside, doing nothing\n", __FUNCTION__)); | |
357 | 385 | } |
358 | 386 | } |
359 | 387 |
@@ -430,6 +458,13 @@ Lisp_Window * | ||
430 | 458 | add_window (Window id) |
431 | 459 | { |
432 | 460 | Lisp_Window *w = rep_ALLOC_CELL(sizeof (Lisp_Window)); |
461 | + | |
462 | + if (debug_windows & DB_WINDOWS_ADD) { | |
463 | + if (id == root_window) | |
464 | + DB (("W: add_window (ROOT)\n")); | |
465 | + else | |
466 | + DB (("W: add_window (%" FMT_WIN ")\n", id)); | |
467 | + }; | |
433 | 468 | if (w != 0) |
434 | 469 | { |
435 | 470 | rep_GC_root gc_win; |
@@ -438,11 +473,6 @@ add_window (Window id) | ||
438 | 473 | unsigned int xwcm; |
439 | 474 | long supplied; |
440 | 475 | |
441 | - DB(("add_window (%lx)\n", id)); | |
442 | - | |
443 | - if (id == root_window) | |
444 | - DB((" ** adding root window!?\n")); | |
445 | - | |
446 | 476 | rep_data_after_gc += sizeof (Lisp_Window); |
447 | 477 | memset (w, 0, sizeof (Lisp_Window)); |
448 | 478 |
@@ -499,9 +529,10 @@ add_window (Window id) | ||
499 | 529 | w->shaped = bounding ? 1 : 0; |
500 | 530 | } |
501 | 531 | |
502 | - DB((" name=`%s' x=%d y=%d width=%d height=%d\n", | |
503 | - rep_STR(w->name), w->attr.x, w->attr.y, | |
504 | - w->attr.width, w->attr.height)); | |
532 | + if (debug_windows & DB_WINDOWS_ADD) | |
533 | + DB (("W: name=`%s' x=%d y=%d width=%d height=%d\n", | |
534 | + rep_STR(w->name), w->attr.x, w->attr.y, | |
535 | + w->attr.width, w->attr.height)); | |
505 | 536 | |
506 | 537 | xwcm = CWX | CWX | CWWidth | CWHeight | CWBorderWidth; |
507 | 538 | xwc.x = w->attr.x; |
@@ -743,6 +774,11 @@ Note that these are Lisp properties not X properties. | ||
743 | 774 | { |
744 | 775 | repv plist; |
745 | 776 | rep_DECLARE1(win, XWINDOWP); |
777 | + if (debug_windows & DB_WINDOWS_PUT){ | |
778 | + DB(("%s %s prop: %s\n", __FUNCTION__, rep_STR(VWIN(win)->name), | |
779 | + rep_SYMBOLP(prop)? (char*)rep_STR(rep_SYM(prop)->name):"not a symbol")); | |
780 | + /* Fbacktrace(Fstderr_file()); //Fbacktrace(Qnil);*/ | |
781 | + } | |
746 | 782 | plist = VWIN(win)->plist; |
747 | 783 | while (rep_CONSP(plist) && rep_CONSP(rep_CDR(plist))) |
748 | 784 | { |
@@ -891,6 +927,12 @@ new frame constructed as specified by FRAME. | ||
891 | 927 | { |
892 | 928 | rep_DECLARE1(win, WINDOWP); |
893 | 929 | rep_DECLARE2(frame, rep_LISTP); |
930 | + | |
931 | + if (debug_frames && debug_windows) { | |
932 | + DB(("%s:%s\n", __FUNCTION__, rep_STR(VWIN(win)->name))); | |
933 | + Fbacktrace(Fstderr_file()); | |
934 | + } | |
935 | + | |
894 | 936 | Fgrab_server (); |
895 | 937 | |
896 | 938 | if (VWIN(win)->reparented) |
@@ -916,6 +958,11 @@ Reinitialises and recalibrates the window frame of WINDOW. | ||
916 | 958 | rep_DECLARE1(win, WINDOWP); |
917 | 959 | if (VWIN(win)->frame != 0 && VWIN(win)->rebuild_frame != 0) |
918 | 960 | { |
961 | + if (debug_frames || (debug_windows & DB_WINDOWS_FRAME)) | |
962 | + DB(("%s: %s->rebuild_frame %d %d\n", __FUNCTION__, | |
963 | + rep_STR(VWIN(win)->name), | |
964 | + VWIN(win)->attr.width,VWIN(win)->attr.height)); | |
965 | + | |
919 | 966 | VWIN(win)->rebuild_frame (VWIN(win)); |
920 | 967 | refresh_frame_parts (VWIN(win)); |
921 | 968 | Fcall_window_hook (Qafter_framing_hook, win, Qnil, Qnil); |
@@ -1380,6 +1427,8 @@ description of HOOK-TYPE. | ||
1380 | 1427 | tem = Fwindow_get (win, hook, Qnil); |
1381 | 1428 | if (tem && tem != Qnil) |
1382 | 1429 | { |
1430 | + if (debug_windows & DB_WINDOWS_HOOKS) | |
1431 | + DB (("W: call-window-hook: private %s\n", window_name (VWIN(win)))); | |
1383 | 1432 | tem = Fcall_hook (tem, args, type); |
1384 | 1433 | if (!tem || (type == Qand && tem == Qnil) |
1385 | 1434 | || (type == Qor && tem != Qnil)) |
@@ -1387,7 +1436,11 @@ description of HOOK-TYPE. | ||
1387 | 1436 | goto out; |
1388 | 1437 | } |
1389 | 1438 | } |
1439 | + if (debug_windows & DB_WINDOWS_HOOKS) | |
1440 | + DB (("W: call-window-hook: public %s\n", window_name (VWIN(win)))); | |
1390 | 1441 | tem = Fcall_hook (hook, args, type); |
1442 | + if (debug_windows & DB_WINDOWS_HOOKS) | |
1443 | + DB (("W: call-window-hook: end %s\n", window_name (VWIN(win)))); | |
1391 | 1444 | out: |
1392 | 1445 | rep_POPGC; rep_POPGC; rep_POPGC; |
1393 | 1446 | return tem; |
@@ -1540,16 +1593,22 @@ static void | ||
1540 | 1593 | window_prin (repv stream, repv win) |
1541 | 1594 | { |
1542 | 1595 | char buf[128]; |
1543 | - sprintf (buf, "#<window %lx>", VWIN(win)->id); | |
1596 | + snprintf (buf, sizeof(buf), "#<window %" FMT_WIN " %s>", VWIN(win)->id, rep_STR(VWIN(win)->name)); | |
1544 | 1597 | rep_stream_puts (stream, buf, -1, FALSE); |
1545 | 1598 | } |
1546 | 1599 | |
1547 | 1600 | static void |
1548 | 1601 | window_mark (repv win) |
1549 | 1602 | { |
1603 | + if (debug_windows & DB_WINDOWS_GC) | |
1604 | + DB(("%s: %p %s\n", __FUNCTION__, (void*) win, rep_STR(VWIN(win)->name))); | |
1550 | 1605 | rep_MARKVAL(VWIN(win)->plist); |
1551 | 1606 | rep_MARKVAL(VWIN(win)->frame_style); |
1607 | + if (debug_windows & DB_WINDOWS_GC) | |
1608 | + DB(("%s: now frame parts\n", __FUNCTION__)); | |
1552 | 1609 | mark_frame_parts (VWIN(win)); |
1610 | + if (debug_windows & DB_WINDOWS_GC) | |
1611 | + DB(("%s: now strings\n", __FUNCTION__)); | |
1553 | 1612 | rep_MARKVAL(VWIN(win)->name); |
1554 | 1613 | rep_MARKVAL(VWIN(win)->full_name); |
1555 | 1614 | rep_MARKVAL(VWIN(win)->icon_name); |
@@ -1567,6 +1626,10 @@ window_mark_type (void) | ||
1567 | 1626 | { |
1568 | 1627 | if (!WINDOW_IS_GONE_P (w) || !w->destroyed) |
1569 | 1628 | rep_MARKVAL(rep_VAL(w)); |
1629 | + else | |
1630 | + if (debug_windows & DB_WINDOWS_GC) | |
1631 | + DB(("%s: %snot marking%s %p %s\n", __FUNCTION__, warning_color, color_reset, | |
1632 | + w, rep_STR(w->name))); | |
1570 | 1633 | } |
1571 | 1634 | for (ph = prop_handlers; ph != 0; ph = ph->next) |
1572 | 1635 | rep_MARKVAL (ph->prop); |
@@ -1577,12 +1640,17 @@ static void | ||
1577 | 1640 | window_sweep (void) |
1578 | 1641 | { |
1579 | 1642 | Lisp_Window **ptr = &window_list; |
1643 | + | |
1644 | + if (debug_windows & DB_WINDOWS_GC) | |
1645 | + DB(("%s\n", __FUNCTION__)); | |
1580 | 1646 | while (*ptr != 0) |
1581 | 1647 | { |
1582 | 1648 | Lisp_Window *w = *ptr; |
1583 | 1649 | if (!rep_GC_CELL_MARKEDP(rep_VAL(w))) |
1584 | 1650 | { |
1585 | 1651 | assert (!window_in_stacking_list_p (w)); |
1652 | + if (debug_windows & DB_WINDOWS_GC) | |
1653 | + DB(("%s another window gone pointer: %p\n", __FUNCTION__, w)); | |
1586 | 1654 | destroy_window_frame (w, FALSE); |
1587 | 1655 | if (w->wmhints != 0) |
1588 | 1656 | XFree (w->wmhints); |
@@ -1597,6 +1665,8 @@ window_sweep (void) | ||
1597 | 1665 | rep_GC_CLR_CELL(rep_VAL(w)); |
1598 | 1666 | } |
1599 | 1667 | } |
1668 | + if (debug_windows & DB_WINDOWS_GC) | |
1669 | + DB(("%s END\n", __FUNCTION__)); | |
1600 | 1670 | } |
1601 | 1671 | |
1602 | 1672 | /* initialisation */ |
@@ -1608,6 +1678,8 @@ manage_windows (void) | ||
1608 | 1678 | unsigned int nchildren, i; |
1609 | 1679 | int revert_to; |
1610 | 1680 | |
1681 | + if (debug_windows & DB_WINDOWS_REST) | |
1682 | + DB(("%s\n", __FUNCTION__)); | |
1611 | 1683 | Fgrab_server (); |
1612 | 1684 | |
1613 | 1685 | XGetInputFocus (dpy, &focus, &revert_to); |
@@ -1627,8 +1699,13 @@ manage_windows (void) | ||
1627 | 1699 | } |
1628 | 1700 | focus = child; |
1629 | 1701 | } |
1702 | + else if (debug_windows & DB_WINDOWS_REST) | |
1703 | + DB(("%s: (focus != PointerRoot)\n", __FUNCTION__)); | |
1630 | 1704 | |
1631 | 1705 | XQueryTree (dpy, root_window, &root, &parent, &children, &nchildren); |
1706 | + if (debug_windows & DB_WINDOWS_REST) | |
1707 | + DB(("%s: XQueryTree returned %d children\n",__FUNCTION__, nchildren)); | |
1708 | + | |
1632 | 1709 | initialising = TRUE; |
1633 | 1710 | for (i = 0; i < nchildren; i++) |
1634 | 1711 | { |
@@ -50,6 +50,9 @@ | ||
50 | 50 | |
51 | 51 | static int have_dbe; |
52 | 52 | |
53 | +#include "debug.h" | |
54 | +#include "debug-colors.h" | |
55 | + | |
53 | 56 | /* An allocated x-gc */ |
54 | 57 | typedef struct lisp_x_gc { |
55 | 58 | repv car; |
@@ -750,8 +753,11 @@ x-map-window X-WINDOW [UNRAISED] | ||
750 | 753 | rep_DECLARE1 (win, X_WINDOWP); |
751 | 754 | if (unraised == Qnil) |
752 | 755 | XMapRaised (dpy, VX_DRAWABLE (win)->id); |
753 | - else | |
756 | + else { | |
757 | + if (debug_windows & DB_WINDOWS_REST) | |
758 | + DB (("%s%s%s: mapping\n", map_request_color, __FUNCTION__, color_reset)); | |
754 | 759 | XMapWindow (dpy, VX_DRAWABLE (win)->id); |
760 | + } | |
755 | 761 | return Qt; |
756 | 762 | } |
757 | 763 |
@@ -762,6 +768,8 @@ x-unmap-window X-WINDOW | ||
762 | 768 | ::end:: */ |
763 | 769 | { |
764 | 770 | rep_DECLARE1 (win, X_WINDOWP); |
771 | + if (debug_windows & DB_WINDOWS_REST) | |
772 | + DB (("%s%s%s: UN-mapping\n", unmap_request_color, __FUNCTION__, color_reset)); | |
765 | 773 | XUnmapWindow (dpy, VX_DRAWABLE (win)->id); |
766 | 774 | return Qt; |
767 | 775 | } |
@@ -835,6 +843,9 @@ Destroys the X-DRAWABLE. | ||
835 | 843 | if (X_WINDOWP (drawable)) |
836 | 844 | { |
837 | 845 | deregister_event_handler (VX_DRAWABLE (drawable)->id); |
846 | + if (debug_windows & DB_WINDOWS_REST) | |
847 | + DB (("%s%s%s: destroying %x\n", unmap_request_color, __FUNCTION__, color_reset, | |
848 | + VX_DRAWABLE (drawable)->id)); | |
838 | 849 | XDestroyWindow (dpy, VX_DRAWABLE (drawable)->id); |
839 | 850 | } |
840 | 851 | else if (X_PIXMAPP (drawable) || X_BITMAPP (drawable)) |
@@ -957,8 +968,10 @@ DEFUN ("x-window-back-buffer", Fx_window_back_buffer, | ||
957 | 968 | buf = x_back_buffer_from_id (id); |
958 | 969 | if (buf == 0) |
959 | 970 | { |
971 | + DB(("%s XdbeAllocateBackBufferName ...", __FUNCTION__)); | |
960 | 972 | buf = XdbeAllocateBackBufferName (dpy, id, XdbeBackground); |
961 | 973 | XSaveContext (dpy, id, x_dbe_context, (XPointer) buf); |
974 | + DB(("-> %p\n", buf)); | |
962 | 975 | } |
963 | 976 | |
964 | 977 | if (buf == 0) |