From 496da4fe6e8652064de54cfda6282a795427bbe6 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Tue, 16 Nov 2021 15:16:28 -0700 Subject: [PATCH] add OPACITY, TRANSPARENTLIST config macros; add clang-format back to build script; update docs --- README.md | 5 +- build.sh | 2 + client.c | 41 ++++ config.def.h | 26 ++- dat.h | 6 +- event.c | 26 ++- fns.h | 9 +- install.sh | 2 +- main.c | 8 +- manage.c | 28 --- menu.c | 33 +-- ryudo.1 | 4 +- ryudo.1.html | 8 +- ryudo.1.md | 4 +- showevent/ShowEvent.c | 474 ++++++++++++++++++++++++++---------------- 15 files changed, 414 insertions(+), 262 deletions(-) diff --git a/README.md b/README.md index 9ab2fc6..f0b82c1 100755 --- a/README.md +++ b/README.md @@ -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! diff --git a/build.sh b/build.sh index 7053ea1..81d6abd 100755 --- a/build.sh +++ b/build.sh @@ -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 diff --git a/client.c b/client.c index b7e8d55..2ee2da3 100644 --- a/client.c +++ b/client.c @@ -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); diff --git a/config.def.h b/config.def.h index f207159..2ce4caa 100644 --- a/config.def.h +++ b/config.def.h @@ -5,7 +5,7 @@ /*************** * LOOK & FEEL * [All of these are required options] **************/ - + /* Border colors */ #define SBORDERCOL 0x17736C #define BORDERCOL 0x000000 @@ -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! */ @@ -77,7 +95,7 @@ } // clang-format on - + /************ * BEHAVIOR * [Everything in this section is optional unless otherwise noted] ***********/ @@ -163,12 +181,12 @@ * Mod4 = (1<<6) * Mod5 = (1<<7) */ - + #define SHORTCUTMOD Mod4Mask #define MODBITS (1 << 6) /* Shortcut keys */ - + #define MAX_KEY XK_m #define ICON_KEY XK_i #define UNHIDE_KEY XK_u diff --git a/dat.h b/dat.h index d22be33..8e74b22 100644 --- a/dat.h +++ b/dat.h @@ -6,16 +6,16 @@ #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 #endif #define NUMVIRTUALS 12 -#define AllButtonMask \ +#define AllButtonMask \ (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask) #define ButtonMask (ButtonPressMask | ButtonReleaseMask) #define MenuMask (ButtonMask | ButtonMotionMask | ExposureMask) diff --git a/event.c b/event.c index 717519a..cbd54fd 100644 --- a/event.c +++ b/event.c @@ -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); diff --git a/fns.h b/fns.h index ab65645..3c9b36e 100644 --- a/fns.h +++ b/fns.h @@ -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 */ diff --git a/install.sh b/install.sh index f451473..e4e3539 100755 --- a/install.sh +++ b/install.sh @@ -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 diff --git a/main.c b/main.c index 6775436..20aa0a0 100644 --- a/main.c +++ b/main.c @@ -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; } diff --git a/manage.c b/manage.c index 550d18f..2191a84 100644 --- a/manage.c +++ b/manage.c @@ -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; -} diff --git a/menu.c b/menu.c index 75f99e9..cefa878 100644 --- a/menu.c +++ b/menu.c @@ -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 } diff --git a/ryudo.1 b/ryudo.1 index b776ecc..f1f61e7 100644 --- a/ryudo.1 +++ b/ryudo.1 @@ -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" . diff --git a/ryudo.1.html b/ryudo.1.html index 3a91b8f..63c8f34 100644 --- a/ryudo.1.html +++ b/ryudo.1.html @@ -162,19 +162,19 @@

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

diff --git a/ryudo.1.md b/ryudo.1.md index 5a4efcd..70310e1 100644 --- a/ryudo.1.md +++ b/ryudo.1.md @@ -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 diff --git a/showevent/ShowEvent.c b/showevent/ShowEvent.c index 39a4e5c..22484b9 100644 --- a/showevent/ShowEvent.c +++ b/showevent/ShowEvent.c @@ -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; } }