tmore files - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 0b1c1f414ddda722072bb7c84783db0279d3f7f9
 (DIR) parent 9c8fc12873460c9b8d390fe1c5aed9f03feb6029
 (HTM) Author: rsc <devnull@localhost>
       Date:   Wed, 13 Jul 2005 03:59:24 +0000
       
       more files
       
       Diffstat:
         A src/cmd/rio/key.c                   |      66 +++++++++++++++++++++++++++++++
         A src/cmd/rio/xevents.c               |      45 +++++++++++++++++++++++++++++++
       
       2 files changed, 111 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/rio/key.c b/src/cmd/rio/key.c
       t@@ -0,0 +1,66 @@
       +/* Copyright (c) 2005 Russ Cox, see README for licence details */
       +#include <stdio.h>
       +#include <stdlib.h>
       +#include <X11/X.h>
       +#include <X11/Xos.h>
       +#include <X11/Xlib.h>
       +#include <X11/Xutil.h>
       +#include <X11/Xatom.h>
       +#include <X11/extensions/shape.h>
       +#include "dat.h"
       +#include "fns.h"
       +#include "patchlevel.h"
       +
       +enum
       +{
       +        GrabAltTab,
       +        GrabAltAny,
       +};
       +
       +static int tabcode = 0x17;
       +static int altcode = 0x40;
       +static int pgupcode = 0x63;
       +static int pgdowncode = 0x69;
       +
       +static void altpress(void);
       +static void altrelease(void);
       +static void alttab(int shift);
       +
       +void
       +keysetup(void)
       +{
       +        int i;
       +
       +        for(i=0; i<num_screens; i++){
       +                XGrabKey(dpy, tabcode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
       +                XGrabKey(dpy, tabcode, Mod1Mask|ShiftMask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
       +        //        XGrabKey(dpy, pgupcode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
       +        //        XGrabKey(dpy, pgdowncode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
       +        //        XGrabKey(dpy, altcode, 0, screens[i].root, 0, GrabModeSync, GrabModeAsync);
       +        }
       +}
       +
       +void
       +keypress(XKeyEvent *e)
       +{
       +        /*
       +         * process key press here
       +         */
       +        if(e->keycode == tabcode)
       +                alttab(e->state&ShiftMask);
       +        XAllowEvents(dpy, SyncKeyboard, e->time);
       +}
       +
       +void
       +keyrelease(XKeyEvent *e)
       +{
       +        XAllowEvents(dpy, SyncKeyboard, e->time);
       +}
       +
       +static void
       +alttab(int shift)
       +{
       +        shuffle(shift);
       +//        fprintf(stderr, "%sTab\n", shift ? "Back" : "");
       +}
       +
 (DIR) diff --git a/src/cmd/rio/xevents.c b/src/cmd/rio/xevents.c
       t@@ -0,0 +1,45 @@
       +/*
       + * Original code posted to comp.sources.x (see printevent.c).
       + * Modifications by Russ Cox <rsc@swtch.com>.
       + */
       +
       +#include <stdio.h>
       +#include <stdlib.h>
       +#include <X11/Intrinsic.h>
       +#include "printevent.h"
       +
       +int
       +main(int argc, char **argv)
       +{
       +        int screen;
       +        Display *dpy;
       +        Window window;
       +        XEvent event;
       +        
       +        if (!(dpy = XOpenDisplay(""))) {
       +                printf("Failed to open display...\n");
       +                exit(1);
       +        }
       +        
       +        screen = DefaultScreen(dpy);
       +
       +        window = XCreateSimpleWindow(dpy, RootWindow(dpy, screen), 100, 100,
       +                300, 200, 2, BlackPixel(dpy, screen), WhitePixel(dpy, screen));
       +
       +        XSelectInput(dpy, window, KeyPressMask | KeyReleaseMask | ButtonPressMask |
       +                ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
       +                PointerMotionMask | PointerMotionHintMask | Button1MotionMask |
       +                Button2MotionMask | Button3MotionMask | Button4MotionMask |
       +                Button5MotionMask | ButtonMotionMask | KeymapStateMask |
       +                ExposureMask | VisibilityChangeMask | StructureNotifyMask |
       +                SubstructureNotifyMask | SubstructureRedirectMask | FocusChangeMask |
       +                PropertyChangeMask | ColormapChangeMask | OwnerGrabButtonMask);
       +
       +        XMapWindow(dpy, window);
       +
       +        for(;;){
       +                XNextEvent(dpy, &event);
       +                printevent(&event);
       +        }
       +}
       +