-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrace.c
140 lines (122 loc) · 3.16 KB
/
trace.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include "extern.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
const char *
str_event(XEvent *event)
{
static const struct event_str {
int type;
char *name;
} es[] = {
{ KeyPress, "KeyPress" },
{ KeyRelease, "KeyRelease" },
{ ButtonPress, "ButtonPress" },
{ ButtonRelease, "ButtonRelease" },
{ MotionNotify, "MotionNotify" },
{ EnterNotify, "EnterNotify" },
{ LeaveNotify, "LeaveNotify" },
{ FocusIn, "FocusIn" },
{ FocusOut, "FocusOut" },
{ KeymapNotify, "KeymapNotify" },
{ Expose, "Expose" },
{ GraphicsExpose, "GraphicsExpose" },
{ NoExpose, "NoExpose" },
{ VisibilityNotify, "VisibilityNotify" },
{ CreateNotify, "CreateNotify" },
{ DestroyNotify, "DestroyNotify" },
{ UnmapNotify, "UnmapNotify" },
{ MapNotify, "MapNotify" },
{ MapRequest, "MapRequest" },
{ ReparentNotify, "ReparentNotify" },
{ ConfigureNotify, "ConfigureNotify" },
{ ConfigureRequest, "ConfigureRequest" },
{ GravityNotify, "GravityNotify" },
{ ResizeRequest, "ResizeRequest" },
{ CirculateNotify, "CirculateNotify" },
{ CirculateRequest, "CirculateRequest" },
{ PropertyNotify, "PropertyNotify" },
{ SelectionClear, "SelectionClear" },
{ SelectionRequest, "SelectionRequest" },
{ SelectionNotify, "SelectionNotify" },
{ ColormapNotify, "ColormapNotify" },
{ ClientMessage, "ClientMessage" },
{ MappingNotify, "MappingNotify" },
{ -1 }
};
int i;
char *s;
for (i = 0; es[i].type != -1; i++)
if (es[i].type == event->type)
break;
if (es[i].type != -1)
s = es[i].name;
else
s = "<unknown event>";
return s;
}
const char *
str_op(int op)
{
static const char *s[] = {
"NoAction", "FocusPane", "MovePane", "FocusColumn",
"MoveColumn", "KillPane", "RestartManager",
"ToggleTagMode", "Maximize", "QuitManager", "Minimize",
"Fullscreen", "PrevFocus", "EditCommand", "NewCommand",
"RestartCommand", "ToggleMode",
NULL
};
return s[op];
}
const char *
str_pane(struct pane *pane)
{
static char buf[256];
if (pane == NULL)
snprintf(buf, sizeof(buf), "null pane");
else
snprintf(buf, sizeof(buf), "pane %ld (%s)", PANE_NUMBER(pane),
pane->name);
return buf;
}
const char *
str_target(int target)
{
static const char *s[] = {
"NoTarget", "Forward", "Backward", NULL
};
return s[target];
}
const char *
dump_flags(int flags)
{
static const char *s[] = {
"FOCUSED", "MAXIMIZED", "MINIMIZED", "MAPPED", "DIRTY",
"ACTIVE ", "MOVE", "RESIZE", "FOCUS", "UNFOCUS"
};
static char buf[256];
int i;
buf[0] = '\0';
for (i = 0; i <= 9; i++) {
if (flags & (1 << i)) {
strlcat(buf, s[i], sizeof(buf));
strlcat(buf, " ", sizeof(buf));
}
}
return buf;
}
void
dump_column(struct column *column)
{
struct pane *pane;
TRACE_BEGIN("column at x=%d (n=%d first=%ld last=%ld):",
column->x, column->n, PANE_NUMBER(column->first),
PANE_NUMBER(column->last));
for (pane = column->first; pane != NULL; pane = pane->next) {
TRACE("...%s:", PANE_STR(pane));
TRACE("......frame=%lx window=%lx prev=%ld next=%ld height=%d ",
pane->frame, pane->window,
PANE_NUMBER(pane->prev), PANE_NUMBER(pane->next), pane->height);
TRACE("......flags=%s", dump_flags(pane->flags));
}
}