add OPACITY, TRANSPARENTLIST config macros; add clang-format back to build script; update docs

This commit is contained in:
Iris Lightshard 2021-11-16 15:16:28 -07:00
parent b23f229ca5
commit 496da4fe6e
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
15 changed files with 414 additions and 262 deletions

View file

@ -39,6 +39,7 @@ The primary additions I've made are:
- Other new features customizable by `config.h`:
+ Show/hide 'Stick' Button3 menuitem
+ `AUTOSTICK` list of windows to spawn sticky by default and not focus (pseudo-panel/dock windows)
+ `TRANSPARENTLIST` of window classes to be rendered with partial transparency (and corresponding OPACITY setting)
+ Optionally notify with `notify-send` which desktop is switched to (I use it with `dunst`)
+ Gaps for pseudo-tiling
+ Option to swap the keyboard shortcuts between "Snap Big Center" and "Snap Floating Center" (and the preferred behavior for terminals launched by keyboard)
@ -61,7 +62,9 @@ to point to the proper location of your plan9port's `mkwsysrules.sh`.
### Bugs and Caveats
Of the bugs and caveats not already mentioned in Rio's readme:
- Rendering of windows with RGBA surfaces is bound to RGB space (xshove and transset can be leveraged to get transparent terminals if you want it)
- Rendering of windows with RGBA surfaces is bound to RGB space (ie, transparency cannot be set on a per-pixel level beyond a binary resolution)
- Switching back and forth between virtual desktops very quickly can cause some windows to glitch out, lose their parent, and become unfocusable (doesn't happen if switching just in one direction).
- Multimonitor setups are treated like one giant monitor. This is on the short list.
- Some applications that render fullscreen or dedicated OSD windows (Virtualbox, Zoom, etc) will need to be manually maximized to fix their alignment (in the former case) or otherwise misbehave.
- Probably more!

View file

@ -4,6 +4,8 @@ if [ ! -e config.h ]; then
cp config.def.h config.h
fi
clang-format -i ./*.c ./*.h ./*/*.c ./*/*.h
mk clean
mk o.rio

View file

@ -337,6 +337,47 @@ int isautostick(Client* c) {
}
#endif
#ifdef ALWAYSDRAW
int shouldalwaysdraw(Client* c) {
static char* alwaysdraw[] = ALWAYSDRAW;
char** a = alwaysdraw;
while (*a) {
if (c && c->class && strstr(c->class, *a)) {
return 1;
}
++a;
}
return 0;
}
#endif
int isterminalwindow(Client* c) {
static char* termnames[] = TERMINALS;
char** t = termnames;
while (*t) {
if (c && c->class && strstr(c->class, *t)) {
return 1;
}
++t;
}
return 0;
}
int istransparent(Client* c) {
static char* transnames[] = TRANSPARENTLIST;
char** t = transnames;
while (*t) {
if (c && c->class && strstr(c->class, *t)) {
return 1;
}
++t;
}
return 0;
}
void ensureactive() {
if (!current)
shuffle(0);

View file

@ -37,8 +37,26 @@
#define SMENUFGCOL 0x000000
#define SMENUBGCOL 0x1F9B92
/* You must use a compositor (eg xcompmgr, picom) for the next 2 settings
* to have any effect!
*/
/* From 0 - 255, the opacity of windows marked 'transparent' */
#define OPACITY 217
// clang-format off
/* Window classes marked 'transparent' */
#define TRANSPARENTLIST { \
"Alacritty", \
"kate", \
"acme", \
0 \
}
/* List of fonts to try, in order, for rendering the menus.
* Remember the backslash at the end of non-terminating lines!
*/

4
dat.h
View file

@ -6,9 +6,9 @@
#define CORNER _corner
#define INSET _inset
#define MAXHIDDEN 128
#if defined (SHOWMAX) && defined (SHOWSTICK)
#if defined(SHOWMAX) && defined(SHOWSTICK)
#define B3FIXED 7
#elif defined (SHOWMAX) || defined (SHOWSTICK)
#elif defined(SHOWMAX) || defined(SHOWSTICK)
#define B3FIXED 6
#else
#define B3FIXED 5

26
event.c
View file

@ -283,6 +283,30 @@ void newwindow(XCreateWindowEvent* e) {
if (c->parent == None)
c->parent = c->screen->root;
}
if (istransparent(c)) {
/* We need to set the atom on both the window and its parent */
const Atom alpha_atom = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", 0);
unsigned long opacity = (unsigned long)OPACITY * 0x1010101;
XChangeProperty(
dpy,
c->window,
alpha_atom,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char*)&opacity,
1);
XChangeProperty(
dpy,
c->parent,
alpha_atom,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char*)&opacity,
1);
}
if (kbLaunch) {
usleep(100000);
#ifdef CENTERVMAX
@ -529,7 +553,7 @@ void focusin(XFocusChangeEvent* e) {
c = getclient(e->window, 0);
if (c != 0 && c->window == e->window && c != current) {
#ifdef AUTOSTICK
if (isautostick(c)) {
if (!isautostick(c)) {
#endif
/* someone grabbed keyboard or seized focus; make them current */
XMapRaised(dpy, c->parent);

9
fns.h
View file

@ -9,8 +9,8 @@
#define setstate setstaterio
/* color.c */
unsigned long
colorpixel(Display*, ScreenInfo*, int, unsigned long, unsigned long);
unsigned long colorpixel(
Display*, ScreenInfo*, int, unsigned long, unsigned long);
/* main.c */
void usage();
@ -60,8 +60,6 @@ void setstate();
void setlabel();
void getproto();
void gettrans();
int shouldalwaysdraw(Client* c);
int isterminalwindow(Client* c);
/* key.c */
void keypress();
@ -99,6 +97,9 @@ void dump_revert();
void dump_clients();
void shuffle(int);
int isautostick(Client* c);
int istransparent(Client* c);
int shouldalwaysdraw(Client* c);
int isterminalwindow(Client* c);
void ensureactive();
/* grab.c */

View file

@ -22,7 +22,7 @@ else
chmod a+x ${PLAN9}/bin/ryudo
echo "ryudo has been installed to '${PLAN9}/bin/';"
echo "xsession has been installed to '/usr/share/xsessions';"
echo "xsession has been installed to '/usr/share/xsessions/';"
echo "startryudo script has been installed to '/usr/bin/';"
echo "The manual pages have been installed to '${PLAN9}/man/'"
fi

8
main.c
View file

@ -224,14 +224,14 @@ int main(int argc, char* argv[]) {
for (i = 0; i < num_screens; i++)
scanwins(&screens[i]);
#ifdef VIRTNOTIFY
#ifdef VIRTNOTIFY
notify_init("ryudo");
#endif
#endif
keysetup();
mainloop(shape_event);
#ifdef VIRTNOTIFY
#ifdef VIRTNOTIFY
notify_uninit();
#endif
#endif
return 0;
}

View file

@ -546,31 +546,3 @@ void getproto(Client* c) {
XFree((char*)p);
}
#ifdef ALWAYSDRAW
int shouldalwaysdraw(Client* c) {
static char* alwaysdraw[] = ALWAYSDRAW;
char** a = alwaysdraw;
while (*a) {
if (c && c->class && strstr(c->class, *a)) {
return 1;
}
++a;
}
return 0;
}
#endif
int isterminalwindow(Client* c) {
static char* termnames[] = TERMINALS;
char** t = termnames;
while (*t) {
if (c && c->class && strstr(c->class, *t)) {
return 1;
}
++t;
}
return 0;
}

33
menu.c
View file

@ -156,8 +156,7 @@ void button(XButtonEvent* e) {
break;
case Button4:
/* scroll up changes to previous virtual screen, wraps around */
if (!c && e->type == ButtonPress)
{
if (!c && e->type == ButtonPress) {
if (numvirtuals > 1) {
if (virt > 0) {
switch_to(virt - 1);
@ -470,10 +469,8 @@ void switch_to_c(int n, Client* c) {
void switch_to(int n) {
#ifdef VIRTNOTIFY
static char virtmsg[32];
NotifyNotification* notification = notify_notification_new(
VIRTHEADER,
NULL,
NULL);
NotifyNotification* notification =
notify_notification_new(VIRTHEADER, NULL, NULL);
#endif
if (n == virt)
return;
@ -491,32 +488,10 @@ void switch_to(int n) {
top(current);
#ifdef VIRTNOTIFY
sprintf(virtmsg, VIRTMSG, b2items[virt]);
notify_notification_update(notification,
VIRTHEADER,
virtmsg,
NULL);
notify_notification_update(notification, VIRTHEADER, virtmsg, NULL);
notify_notification_set_category(notification, "virtual");
notify_notification_show(notification, NULL);
notify_notification_close(notification, NULL);
/* if (fork() == 0) {
if (fork() == 0) {
close(ConnectionNumber(dpy));
if (dpy != '\0')
putenv(dpy);
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
sprintf(virtmsg, VIRTMSG, b2items[virt]);
execlp(
"notify-send",
"notify-send",
"-c",
"virtual",
VIRTHEADER,
virtmsg,
(char*)0);
}
}*/
#endif
}

View file

@ -149,7 +149,7 @@ Multimonitor output is not currently supported \-\- the whole "screen" (collecti
Click events don\'t pass through when clicking to activate a window\.
.
.P
Clicking mouse button 3 on an inactive window brings up the Button 3 Menu instead of focusing the window\. I personally sometimes find this behavior useful\.
Clicking mouse button 2/3 on an inactive window brings up the Button 2/3 Menu instead of focusing the window\. I personally sometimes find this behavior useful\.
.
.P
Programs that expect to run fullscreen will probably just open in a window the size of whatever resolution they expect to run at\. Depending on the implementation, they may respond well to being maximized or you may have to change your screen resolution manually before doing so\.
@ -158,7 +158,7 @@ Programs that expect to run fullscreen will probably just open in a window the s
Fullscreen Virtualbox VM windows are a strange outlier and start with their graphics offset\. Maximize the window after opening and it should be good\.
.
.P
There is no native support for compositing, but included is a shell script (\fBtranssetter\.sh\fR) which I use for translucent terminal and editor windows\. It works well and is decently lightweight\.
While there is naitive support for per\-window opacity via the \fBOPACITY\fR and \fBTRANSPARENTLIST\fR configuration macros, there is no support for per\-pixel opacity\. Programs that expect this behavior will render all pixels at the same opacity (unless using the \fBXSHAPE\fR extension for boolean opacity per\-pixel (eg, \fBxeyes\fR), which works\.)
.
.SH "AUTHORS"
.

View file

@ -162,19 +162,19 @@
<p>Click events don't pass through when clicking to activate a window.</p>
<p>Clicking mouse button 3 on an inactive window brings up the Button 3 Menu instead of focusing the window. I personally sometimes find this behavior useful.</p>
<p>Clicking mouse button 2/3 on an inactive window brings up the Button 2/3 Menu instead of focusing the window. I personally sometimes find this behavior useful.</p>
<p>Programs that expect to run fullscreen will probably just open in a window the size of whatever resolution they expect to run at. Depending on the implementation, they may respond well to being maximized or you may have to change your screen resolution manually before doing so.</p>
<p>Fullscreen Virtualbox VM windows are a strange outlier and start with their graphics offset. Maximize the window after opening and it should be good.</p>
<p>There is no native support for compositing, but included is a shell script (<code>transsetter.sh</code>) which I use for translucent terminal and editor windows. It works well and is decently lightweight.</p>
<p>While there is naitive support for per-window opacity via the <code>OPACITY</code> and <code>TRANSPARENTLIST</code> configuration macros, there is no support for per-pixel opacity. Programs that expect this behavior will render all pixels at the same opacity (unless using the <code>XSHAPE</code> extension for boolean opacity per-pixel (eg, <code>xeyes</code>), which works.)</p>
<h2 id="AUTHORS">AUTHORS</h2>
<ul>
<li>Derek Stevens <a href="&#109;&#97;&#105;&#108;&#x74;&#111;&#x3a;&#x6e;&#x69;&#x6c;&#x69;&#120;&#64;&#x6e;&#x69;&#108;&#x66;&#109;&#x2e;&#99;&#x63;" data-bare-link="true">&#110;&#105;&#108;&#105;&#120;&#x40;&#x6e;&#x69;&#x6c;&#102;&#x6d;&#x2e;&#99;&#99;</a></li>
<li>Russ Cox <a href="&#109;&#x61;&#x69;&#x6c;&#116;&#111;&#58;&#114;&#115;&#99;&#x40;&#115;&#x77;&#x74;&#99;&#104;&#x2e;&#99;&#111;&#x6d;" data-bare-link="true">&#114;&#x73;&#99;&#x40;&#115;&#119;&#116;&#x63;&#x68;&#46;&#x63;&#111;&#x6d;</a></li>
<li>Derek Stevens <a href="&#x6d;&#x61;&#105;&#108;&#116;&#x6f;&#x3a;&#x6e;&#x69;&#x6c;&#105;&#x78;&#x40;&#110;&#105;&#108;&#x66;&#x6d;&#x2e;&#99;&#99;" data-bare-link="true">&#110;&#x69;&#x6c;&#x69;&#120;&#64;&#110;&#105;&#108;&#102;&#x6d;&#x2e;&#x63;&#x63;</a></li>
<li>Russ Cox <a href="&#109;&#97;&#105;&#x6c;&#x74;&#111;&#58;&#x72;&#x73;&#99;&#x40;&#x73;&#x77;&#x74;&#99;&#104;&#x2e;&#99;&#x6f;&#109;" data-bare-link="true">&#x72;&#x73;&#99;&#x40;&#x73;&#119;&#116;&#99;&#104;&#x2e;&#99;&#111;&#x6d;</a></li>
<li>David Hogan, RIP</li>
</ul>

View file

@ -83,13 +83,13 @@ Multimonitor output is not currently supported -- the whole "screen" (collection
Click events don't pass through when clicking to activate a window.
Clicking mouse button 3 on an inactive window brings up the Button 3 Menu instead of focusing the window. I personally sometimes find this behavior useful.
Clicking mouse button 2/3 on an inactive window brings up the Button 2/3 Menu instead of focusing the window. I personally sometimes find this behavior useful.
Programs that expect to run fullscreen will probably just open in a window the size of whatever resolution they expect to run at. Depending on the implementation, they may respond well to being maximized or you may have to change your screen resolution manually before doing so.
Fullscreen Virtualbox VM windows are a strange outlier and start with their graphics offset. Maximize the window after opening and it should be good.
There is no native support for compositing, but included is a shell script (`transsetter.sh`) which I use for translucent terminal and editor windows. It works well and is decently lightweight.
While there is naitive support for per-window opacity via the `OPACITY` and `TRANSPARENTLIST` configuration macros, there is no support for per-pixel opacity. Programs that expect this behavior will render all pixels at the same opacity (unless using the `XSHAPE` extension for boolean opacity per-pixel (eg, `xeyes`), which works.)
## AUTHORS

View file

@ -12,11 +12,14 @@ static char* sep;
static char* TorF(bool) int bool;
{
switch (bool) {
case True: return ("True");
case True:
return ("True");
case False: return ("False");
case False:
return ("False");
default: return ("?");
default:
return ("?");
}
}
@ -24,11 +27,14 @@ static char* TorF(bool) int bool;
static char* PropertyState(state) int state;
{
switch (state) {
case PropertyNewValue: return ("PropertyNewValue");
case PropertyNewValue:
return ("PropertyNewValue");
case PropertyDelete: return ("PropertyDelete");
case PropertyDelete:
return ("PropertyDelete");
default: return ("?");
default:
return ("?");
}
}
@ -36,13 +42,17 @@ static char* PropertyState(state) int state;
static char* VisibilityState(state) int state;
{
switch (state) {
case VisibilityUnobscured: return ("VisibilityUnobscured");
case VisibilityUnobscured:
return ("VisibilityUnobscured");
case VisibilityPartiallyObscured: return ("VisibilityPartiallyObscured");
case VisibilityPartiallyObscured:
return ("VisibilityPartiallyObscured");
case VisibilityFullyObscured: return ("VisibilityFullyObscured");
case VisibilityFullyObscured:
return ("VisibilityFullyObscured");
default: return ("?");
default:
return ("?");
}
}
@ -157,11 +167,14 @@ static char* ConfigureValueMask(valuemask) unsigned int valuemask;
static char* IsHint(is_hint) char is_hint;
{
switch (is_hint) {
case NotifyNormal: return ("NotifyNormal");
case NotifyNormal:
return ("NotifyNormal");
case NotifyHint: return ("NotifyHint");
case NotifyHint:
return ("NotifyHint");
default: return ("?");
default:
return ("?");
}
}
@ -182,11 +195,14 @@ static char* MaybeNone(value) int value;
static char* ColormapState(state) int state;
{
switch (state) {
case ColormapInstalled: return ("ColormapInstalled");
case ColormapInstalled:
return ("ColormapInstalled");
case ColormapUninstalled: return ("ColormapUninstalled");
case ColormapUninstalled:
return ("ColormapUninstalled");
default: return ("?");
default:
return ("?");
}
}
@ -194,17 +210,23 @@ static char* ColormapState(state) int state;
static char* CrossingDetail(detail) int detail;
{
switch (detail) {
case NotifyAncestor: return ("NotifyAncestor");
case NotifyAncestor:
return ("NotifyAncestor");
case NotifyInferior: return ("NotifyInferior");
case NotifyInferior:
return ("NotifyInferior");
case NotifyVirtual: return ("NotifyVirtual");
case NotifyVirtual:
return ("NotifyVirtual");
case NotifyNonlinear: return ("NotifyNonlinear");
case NotifyNonlinear:
return ("NotifyNonlinear");
case NotifyNonlinearVirtual: return ("NotifyNonlinearVirtual");
case NotifyNonlinearVirtual:
return ("NotifyNonlinearVirtual");
default: return ("?");
default:
return ("?");
}
}
@ -212,23 +234,32 @@ static char* CrossingDetail(detail) int detail;
static char* FocusChangeDetail(detail) int detail;
{
switch (detail) {
case NotifyAncestor: return ("NotifyAncestor");
case NotifyAncestor:
return ("NotifyAncestor");
case NotifyInferior: return ("NotifyInferior");
case NotifyInferior:
return ("NotifyInferior");
case NotifyVirtual: return ("NotifyVirtual");
case NotifyVirtual:
return ("NotifyVirtual");
case NotifyNonlinear: return ("NotifyNonlinear");
case NotifyNonlinear:
return ("NotifyNonlinear");
case NotifyNonlinearVirtual: return ("NotifyNonlinearVirtual");
case NotifyNonlinearVirtual:
return ("NotifyNonlinearVirtual");
case NotifyPointer: return ("NotifyPointer");
case NotifyPointer:
return ("NotifyPointer");
case NotifyPointerRoot: return ("NotifyPointerRoot");
case NotifyPointerRoot:
return ("NotifyPointerRoot");
case NotifyDetailNone: return ("NotifyDetailNone");
case NotifyDetailNone:
return ("NotifyDetailNone");
default: return ("?");
default:
return ("?");
}
}
@ -236,17 +267,23 @@ static char* FocusChangeDetail(detail) int detail;
static char* ConfigureDetail(detail) int detail;
{
switch (detail) {
case Above: return ("Above");
case Above:
return ("Above");
case Below: return ("Below");
case Below:
return ("Below");
case TopIf: return ("TopIf");
case TopIf:
return ("TopIf");
case BottomIf: return ("BottomIf");
case BottomIf:
return ("BottomIf");
case Opposite: return ("Opposite");
case Opposite:
return ("Opposite");
default: return ("?");
default:
return ("?");
}
}
@ -254,15 +291,20 @@ static char* ConfigureDetail(detail) int detail;
static char* GrabMode(mode) int mode;
{
switch (mode) {
case NotifyNormal: return ("NotifyNormal");
case NotifyNormal:
return ("NotifyNormal");
case NotifyGrab: return ("NotifyGrab");
case NotifyGrab:
return ("NotifyGrab");
case NotifyUngrab: return ("NotifyUngrab");
case NotifyUngrab:
return ("NotifyUngrab");
case NotifyWhileGrabbed: return ("NotifyWhileGrabbed");
case NotifyWhileGrabbed:
return ("NotifyWhileGrabbed");
default: return ("?");
default:
return ("?");
}
}
@ -270,13 +312,17 @@ static char* GrabMode(mode) int mode;
static char* MappingRequest(request) int request;
{
switch (request) {
case MappingModifier: return ("MappingModifier");
case MappingModifier:
return ("MappingModifier");
case MappingKeyboard: return ("MappingKeyboard");
case MappingKeyboard:
return ("MappingKeyboard");
case MappingPointer: return ("MappingPointer");
case MappingPointer:
return ("MappingPointer");
default: return ("?");
default:
return ("?");
}
}
@ -284,11 +330,14 @@ static char* MappingRequest(request) int request;
static char* Place(place) int place;
{
switch (place) {
case PlaceOnTop: return ("PlaceOnTop");
case PlaceOnTop:
return ("PlaceOnTop");
case PlaceOnBottom: return ("PlaceOnBottom");
case PlaceOnBottom:
return ("PlaceOnBottom");
default: return ("?");
default:
return ("?");
}
}
@ -298,11 +347,15 @@ static char* MajorCode(code) int code;
static char buffer[32];
switch (code) {
case X_CopyArea: return ("X_CopyArea");
case X_CopyArea:
return ("X_CopyArea");
case X_CopyPlane: return ("X_CopyPlane");
case X_CopyPlane:
return ("X_CopyPlane");
default: sprintf(buffer, "0x%x", code); return (buffer);
default:
sprintf(buffer, "0x%x", code);
return (buffer);
}
}
@ -330,12 +383,12 @@ static char* Keycode(ev) XKeyEvent* ev;
}
/* Returns the string equivalent of an atom or "None"*/
static char*
AtomName(Display* dpy, Atom atom) {
static char* AtomName(Display* dpy, Atom atom) {
static char buffer[256];
char* atom_name;
if (atom == None) return ("None");
if (atom == None)
return ("None");
atom_name = XGetAtomName(dpy, atom);
strncpy(buffer, atom_name, 256);
@ -347,8 +400,7 @@ AtomName(Display* dpy, Atom atom) {
/**** Routines to print out readable values for the field of various events ***/
/******************************************************************************/
static void
VerbMotion(XMotionEvent* ev) {
static void VerbMotion(XMotionEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("root=0x%x%s", (unsigned)ev->root, sep);
printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
@ -360,8 +412,7 @@ VerbMotion(XMotionEvent* ev) {
printf("same_screen=%s\n", TorF(ev->same_screen));
}
static void
VerbButton(XButtonEvent* ev) {
static void VerbButton(XButtonEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("root=0x%x%s", (unsigned)ev->root, sep);
printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
@ -373,16 +424,14 @@ VerbButton(XButtonEvent* ev) {
printf("same_screen=%s\n", TorF(ev->same_screen));
}
static void
VerbColormap(XColormapEvent* ev) {
static void VerbColormap(XColormapEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("colormap=%s%s", MaybeNone(ev->colormap), sep);
printf("new=%s%s", TorF(ev->new), sep);
printf("state=%s\n", ColormapState(ev->state));
}
static void
VerbCrossing(XCrossingEvent* ev) {
static void VerbCrossing(XCrossingEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("root=0x%x%s", (unsigned)ev->root, sep);
printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
@ -396,16 +445,14 @@ VerbCrossing(XCrossingEvent* ev) {
printf("state=%s\n", ButtonAndOrModifierState(ev->state));
}
static void
VerbExpose(XExposeEvent* ev) {
static void VerbExpose(XExposeEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("x=%d y=%d%s", ev->x, ev->y, sep);
printf("width=%d height=%d%s", ev->width, ev->height, sep);
printf("count=%d\n", ev->count);
}
static void
VerbGraphicsExpose(XGraphicsExposeEvent* ev) {
static void VerbGraphicsExpose(XGraphicsExposeEvent* ev) {
printf("drawable=0x%x%s", (unsigned)ev->drawable, sep);
printf("x=%d y=%d%s", ev->x, ev->y, sep);
printf("width=%d height=%d%s", ev->width, ev->height, sep);
@ -413,32 +460,29 @@ VerbGraphicsExpose(XGraphicsExposeEvent* ev) {
printf("minor_code=%d\n", ev->minor_code);
}
static void
VerbNoExpose(XNoExposeEvent* ev) {
static void VerbNoExpose(XNoExposeEvent* ev) {
printf("drawable=0x%x%s", (unsigned)ev->drawable, sep);
printf("major_code=%s%s", MajorCode(ev->major_code), sep);
printf("minor_code=%d\n", ev->minor_code);
}
static void
VerbFocus(XFocusChangeEvent* ev) {
static void VerbFocus(XFocusChangeEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("mode=%s%s", GrabMode(ev->mode), sep);
printf("detail=%s\n", FocusChangeDetail(ev->detail));
}
static void
VerbKeymap(XKeymapEvent* ev) {
static void VerbKeymap(XKeymapEvent* ev) {
int i;
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("key_vector=");
for (i = 0; i < 32; i++) printf("%02x", ev->key_vector[i]);
for (i = 0; i < 32; i++)
printf("%02x", ev->key_vector[i]);
printf("\n");
}
static void
VerbKey(XKeyEvent* ev) {
static void VerbKey(XKeyEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("root=0x%x%s", (unsigned)ev->root, sep);
printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
@ -450,29 +494,25 @@ VerbKey(XKeyEvent* ev) {
printf("same_screen=%s\n", TorF(ev->same_screen));
}
static void
VerbProperty(XPropertyEvent* ev) {
static void VerbProperty(XPropertyEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("atom=%s%s", AtomName(ev->display, ev->atom), sep);
printf("time=%s%s", ServerTime(ev->time), sep);
printf("state=%s\n", PropertyState(ev->state));
}
static void
VerbResizeRequest(XResizeRequestEvent* ev) {
static void VerbResizeRequest(XResizeRequestEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("width=%d height=%d\n", ev->width, ev->height);
}
static void
VerbCirculate(XCirculateEvent* ev) {
static void VerbCirculate(XCirculateEvent* ev) {
printf("event=0x%x%s", (unsigned)ev->event, sep);
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("place=%s\n", Place(ev->place));
}
static void
VerbConfigure(XConfigureEvent* ev) {
static void VerbConfigure(XConfigureEvent* ev) {
printf("event=0x%x%s", (unsigned)ev->event, sep);
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("x=%d y=%d%s", ev->x, ev->y, sep);
@ -482,8 +522,7 @@ VerbConfigure(XConfigureEvent* ev) {
printf("override_redirect=%s\n", TorF(ev->override_redirect));
}
static void
VerbCreateWindow(XCreateWindowEvent* ev) {
static void VerbCreateWindow(XCreateWindowEvent* ev) {
printf("parent=0x%x%s", (unsigned)ev->parent, sep);
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("x=%d y=%d%s", ev->x, ev->y, sep);
@ -492,28 +531,24 @@ VerbCreateWindow(XCreateWindowEvent* ev) {
printf("override_redirect=%s\n", TorF(ev->override_redirect));
}
static void
VerbDestroyWindow(XDestroyWindowEvent* ev) {
static void VerbDestroyWindow(XDestroyWindowEvent* ev) {
printf("event=0x%x%s", (unsigned)ev->event, sep);
printf("window=0x%x\n", (unsigned)ev->window);
}
static void
VerbGravity(XGravityEvent* ev) {
static void VerbGravity(XGravityEvent* ev) {
printf("event=0x%x%s", (unsigned)ev->event, sep);
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("x=%d y=%d\n", ev->x, ev->y);
}
static void
VerbMap(XMapEvent* ev) {
static void VerbMap(XMapEvent* ev) {
printf("event=0x%x%s", (unsigned)ev->event, sep);
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("override_redirect=%s\n", TorF(ev->override_redirect));
}
static void
VerbReparent(XReparentEvent* ev) {
static void VerbReparent(XReparentEvent* ev) {
printf("event=0x%x%s", (unsigned)ev->event, sep);
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("parent=0x%x%s", (unsigned)ev->parent, sep);
@ -521,22 +556,19 @@ VerbReparent(XReparentEvent* ev) {
printf("override_redirect=%s\n", TorF(ev->override_redirect));
}
static void
VerbUnmap(XUnmapEvent* ev) {
static void VerbUnmap(XUnmapEvent* ev) {
printf("event=0x%x%s", (unsigned)ev->event, sep);
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("from_configure=%s\n", TorF(ev->from_configure));
}
static void
VerbCirculateRequest(XCirculateRequestEvent* ev) {
static void VerbCirculateRequest(XCirculateRequestEvent* ev) {
printf("parent=0x%x%s", (unsigned)ev->parent, sep);
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("place=%s\n", Place(ev->place));
}
static void
VerbConfigureRequest(XConfigureRequestEvent* ev) {
static void VerbConfigureRequest(XConfigureRequestEvent* ev) {
printf("parent=0x%x%s", (unsigned)ev->parent, sep);
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("x=%d y=%d%s", ev->x, ev->y, sep);
@ -547,41 +579,37 @@ VerbConfigureRequest(XConfigureRequestEvent* ev) {
printf("value_mask=%s\n", ConfigureValueMask(ev->value_mask));
}
static void
VerbMapRequest(XMapRequestEvent* ev) {
static void VerbMapRequest(XMapRequestEvent* ev) {
printf("parent=0x%x%s", (unsigned)ev->parent, sep);
printf("window=0x%x\n", (unsigned)ev->window);
}
static void
VerbClient(XClientMessageEvent* ev) {
static void VerbClient(XClientMessageEvent* ev) {
int i;
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("message_type=%s%s", AtomName(ev->display, ev->message_type), sep);
printf("format=%d\n", ev->format);
printf("data (shown as longs)=");
for (i = 0; i < 5; i++) printf(" 0x%08lx", ev->data.l[i]);
for (i = 0; i < 5; i++)
printf(" 0x%08lx", ev->data.l[i]);
printf("\n");
}
static void
VerbMapping(XMappingEvent* ev) {
static void VerbMapping(XMappingEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("request=%s%s", MappingRequest(ev->request), sep);
printf("first_keycode=0x%x%s", ev->first_keycode, sep);
printf("count=0x%x\n", ev->count);
}
static void
VerbSelectionClear(XSelectionClearEvent* ev) {
static void VerbSelectionClear(XSelectionClearEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
printf("time=%s\n", ServerTime(ev->time));
}
static void
VerbSelection(XSelectionEvent* ev) {
static void VerbSelection(XSelectionEvent* ev) {
printf("requestor=0x%x%s", (unsigned)ev->requestor, sep);
printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
printf("target=%s%s", AtomName(ev->display, ev->target), sep);
@ -589,8 +617,7 @@ VerbSelection(XSelectionEvent* ev) {
printf("time=%s\n", ServerTime(ev->time));
}
static void
VerbSelectionRequest(XSelectionRequestEvent* ev) {
static void VerbSelectionRequest(XSelectionRequestEvent* ev) {
printf("owner=0x%x%s", (unsigned)ev->owner, sep);
printf("requestor=0x%x%s", (unsigned)ev->requestor, sep);
printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
@ -599,8 +626,7 @@ VerbSelectionRequest(XSelectionRequestEvent* ev) {
printf("time=%s\n", ServerTime(ev->time));
}
static void
VerbVisibility(XVisibilityEvent* ev) {
static void VerbVisibility(XVisibilityEvent* ev) {
printf("window=0x%x%s", (unsigned)ev->window, sep);
printf("state=%s\n", VisibilityState(ev->state));
}
@ -612,39 +638,72 @@ VerbVisibility(XVisibilityEvent* ev) {
char* GetType(ev) XEvent* ev;
{
switch (ev->type) {
case KeyPress: return ("KeyPress");
case KeyRelease: return ("KeyRelease");
case ButtonPress: return ("ButtonPress");
case ButtonRelease: return ("ButtonRelease");
case MotionNotify: return ("MotionNotify");
case EnterNotify: return ("EnterNotify");
case LeaveNotify: return ("LeaveNotify");
case FocusIn: return ("FocusIn");
case FocusOut: return ("FocusOut");
case KeymapNotify: return ("KeymapNotify");
case Expose: return ("Expose");
case GraphicsExpose: return ("GraphicsExpose");
case NoExpose: return ("NoExpose");
case VisibilityNotify: return ("VisibilityNotify");
case CreateNotify: return ("CreateNotify");
case DestroyNotify: return ("DestroyNotify");
case UnmapNotify: return ("UnmapNotify");
case MapNotify: return ("MapNotify");
case MapRequest: return ("MapRequest");
case ReparentNotify: return ("ReparentNotify");
case ConfigureNotify: return ("ConfigureNotify");
case ConfigureRequest: return ("ConfigureRequest");
case GravityNotify: return ("GravityNotify");
case ResizeRequest: return ("ResizeRequest");
case CirculateNotify: return ("CirculateNotify");
case CirculateRequest: return ("CirculateRequest");
case PropertyNotify: return ("PropertyNotify");
case SelectionClear: return ("SelectionClear");
case SelectionRequest: return ("SelectionRequest");
case SelectionNotify: return ("SelectionNotify");
case ColormapNotify: return ("ColormapNotify");
case ClientMessage: return ("ClientMessage");
case MappingNotify: return ("MappingNotify");
case KeyPress:
return ("KeyPress");
case KeyRelease:
return ("KeyRelease");
case ButtonPress:
return ("ButtonPress");
case ButtonRelease:
return ("ButtonRelease");
case MotionNotify:
return ("MotionNotify");
case EnterNotify:
return ("EnterNotify");
case LeaveNotify:
return ("LeaveNotify");
case FocusIn:
return ("FocusIn");
case FocusOut:
return ("FocusOut");
case KeymapNotify:
return ("KeymapNotify");
case Expose:
return ("Expose");
case GraphicsExpose:
return ("GraphicsExpose");
case NoExpose:
return ("NoExpose");
case VisibilityNotify:
return ("VisibilityNotify");
case CreateNotify:
return ("CreateNotify");
case DestroyNotify:
return ("DestroyNotify");
case UnmapNotify:
return ("UnmapNotify");
case MapNotify:
return ("MapNotify");
case MapRequest:
return ("MapRequest");
case ReparentNotify:
return ("ReparentNotify");
case ConfigureNotify:
return ("ConfigureNotify");
case ConfigureRequest:
return ("ConfigureRequest");
case GravityNotify:
return ("GravityNotify");
case ResizeRequest:
return ("ResizeRequest");
case CirculateNotify:
return ("CirculateNotify");
case CirculateRequest:
return ("CirculateRequest");
case PropertyNotify:
return ("PropertyNotify");
case SelectionClear:
return ("SelectionClear");
case SelectionRequest:
return ("SelectionRequest");
case SelectionNotify:
return ("SelectionNotify");
case ColormapNotify:
return ("ColormapNotify");
case ClientMessage:
return ("ClientMessage");
case MappingNotify:
return ("MappingNotify");
}
return "???";
}
@ -653,8 +712,7 @@ char* GetType(ev) XEvent* ev;
/**************** Print the values of all fields for any event ****************/
/******************************************************************************/
void
ShowEvent(XEvent* eev) {
void ShowEvent(XEvent* eev) {
XAnyEvent* ev = (XAnyEvent*)eev;
/* determine which field separator to use */
if (use_separate_lines)
@ -668,66 +726,124 @@ ShowEvent(XEvent* eev) {
printf("display=0x%p%s", ev->display, sep);
switch (ev->type) {
case MotionNotify: VerbMotion((void*)ev); break;
case MotionNotify:
VerbMotion((void*)ev);
break;
case ButtonPress:
case ButtonRelease: VerbButton((void*)ev); break;
case ButtonRelease:
VerbButton((void*)ev);
break;
case ColormapNotify: VerbColormap((void*)ev); break;
case ColormapNotify:
VerbColormap((void*)ev);
break;
case EnterNotify:
case LeaveNotify: VerbCrossing((void*)ev); break;
case LeaveNotify:
VerbCrossing((void*)ev);
break;
case Expose: VerbExpose((void*)ev); break;
case Expose:
VerbExpose((void*)ev);
break;
case GraphicsExpose: VerbGraphicsExpose((void*)ev); break;
case GraphicsExpose:
VerbGraphicsExpose((void*)ev);
break;
case NoExpose: VerbNoExpose((void*)ev); break;
case NoExpose:
VerbNoExpose((void*)ev);
break;
case FocusIn:
case FocusOut: VerbFocus((void*)ev); break;
case FocusOut:
VerbFocus((void*)ev);
break;
case KeymapNotify: VerbKeymap((void*)ev); break;
case KeymapNotify:
VerbKeymap((void*)ev);
break;
case KeyPress:
case KeyRelease: VerbKey((void*)ev); break;
case KeyRelease:
VerbKey((void*)ev);
break;
case PropertyNotify: VerbProperty((void*)ev); break;
case PropertyNotify:
VerbProperty((void*)ev);
break;
case ResizeRequest: VerbResizeRequest((void*)ev); break;
case ResizeRequest:
VerbResizeRequest((void*)ev);
break;
case CirculateNotify: VerbCirculate((void*)ev); break;
case CirculateNotify:
VerbCirculate((void*)ev);
break;
case ConfigureNotify: VerbConfigure((void*)ev); break;
case ConfigureNotify:
VerbConfigure((void*)ev);
break;
case CreateNotify: VerbCreateWindow((void*)ev); break;
case CreateNotify:
VerbCreateWindow((void*)ev);
break;
case DestroyNotify: VerbDestroyWindow((void*)ev); break;
case DestroyNotify:
VerbDestroyWindow((void*)ev);
break;
case GravityNotify: VerbGravity((void*)ev); break;
case GravityNotify:
VerbGravity((void*)ev);
break;
case MapNotify: VerbMap((void*)ev); break;
case MapNotify:
VerbMap((void*)ev);
break;
case ReparentNotify: VerbReparent((void*)ev); break;
case ReparentNotify:
VerbReparent((void*)ev);
break;
case UnmapNotify: VerbUnmap((void*)ev); break;
case UnmapNotify:
VerbUnmap((void*)ev);
break;
case CirculateRequest: VerbCirculateRequest((void*)ev); break;
case CirculateRequest:
VerbCirculateRequest((void*)ev);
break;
case ConfigureRequest: VerbConfigureRequest((void*)ev); break;
case ConfigureRequest:
VerbConfigureRequest((void*)ev);
break;
case MapRequest: VerbMapRequest((void*)ev); break;
case MapRequest:
VerbMapRequest((void*)ev);
break;
case ClientMessage: VerbClient((void*)ev); break;
case ClientMessage:
VerbClient((void*)ev);
break;
case MappingNotify: VerbMapping((void*)ev); break;
case MappingNotify:
VerbMapping((void*)ev);
break;
case SelectionClear: VerbSelectionClear((void*)ev); break;
case SelectionClear:
VerbSelectionClear((void*)ev);
break;
case SelectionNotify: VerbSelection((void*)ev); break;
case SelectionNotify:
VerbSelection((void*)ev);
break;
case SelectionRequest: VerbSelectionRequest((void*)ev); break;
case SelectionRequest:
VerbSelectionRequest((void*)ev);
break;
case VisibilityNotify: VerbVisibility((void*)ev); break;
case VisibilityNotify:
VerbVisibility((void*)ev);
break;
}
}