DIRECTORY Commander, IO, Xl, XTkWidgets; X11Tests0: CEDAR PROGRAM IMPORTS Commander, IO, Xl, XTkWidgets ~ BEGIN Widget: TYPE = XTkWidgets.Widget; gLabel: Widget ¬ NIL; gStream: IO.STREAM ¬ NIL; XTCreateWindow: Commander.CommandProc ~ { label: XTkWidgets.Widget ¬ XTkWidgets.CreateField[text: "edit me"]; activate: Widget ¬ XTkWidgets.CreateButton[text: "Activate", hitProc: Activate, registerData: label]; graber: Widget ¬ XTkWidgets.CreateButton[text: "Grab keyboard", hitProc: BPGrabKeyboard]; ungraber: Widget ¬ XTkWidgets.CreateButton[text: "Ungrab keyboard", hitProc: BPUngrabKeyboard]; setfocus: Widget ¬ XTkWidgets.CreateButton[text: "Set focus", hitProc: BPSetFocus]; getfocus: Widget ¬ XTkWidgets.CreateButton[text: "Get focus", hitProc: BPGetFocus]; contents: Widget ¬ XTkWidgets.CreateYStack[[], LIST[<>label, activate, graber, ungraber, setfocus, getfocus]]; shell: XTkWidgets.Widget ¬ XTkWidgets.CreateShell[child: contents, windowHeader: "XT... tests"]; XTkWidgets.RealizeShell[shell]; gLabel ¬ label; gStream ¬ cmd.out; IO.PutRope[cmd.out, "widget created\n"]; }; GrabKeyboard: PROC ~ { status: Xl.GrabStatus; IO.PutRope[gStream, "grabbing focus for: %g\n", IO.card[Xl.WindowId[gLabel.window]]]; status ¬ Xl.GrabKeyboard[gLabel.connection, gLabel.window, TRUE, asynchronous, synchronous, Xl.currentTime]; SELECT status FROM success => IO.PutRope[gStream, "success"]; alreadyGrabbed => IO.PutRope[gStream, "alreadyGrabbed"]; invalidTime => IO.PutRope[gStream, "invalidTime"]; notViewable => IO.PutRope[gStream, "notViewable"]; frozen => IO.PutRope[gStream, "frozen"]; ENDCASE => IO.PutRope[gStream, "endcase"]; IO.PutRope[gStream, "...\n"]; }; UngrabKeyboard: PROC = { Xl.UngrabKeyboard[gLabel.connection, Xl.currentTime]; Xl.Flush[gLabel.connection]; IO.PutRope[gStream, "keyboard ungrabbed\n"]; }; SetFocus: PROC = { Xl.SetInputFocus[gLabel.connection, gLabel.window, parent, Xl.currentTime]; Xl.Flush[gLabel.connection]; IO.PutF1[gStream, "Set input focus to %g\n", IO.card[Xl.WindowId[gLabel.window]]]; }; GetFocus: PROC = { window: Xl.Window; revertTo: Xl.FocusReversion; [window, revertTo] ¬ Xl.GetInputFocus[gLabel.connection]; IO.PutF1[gStream, "Input focus at: %g; revert to: " , IO.card[Xl.WindowId[window]]]; SELECT revertTo FROM none => IO.PutRope[gStream, "none\n"]; pointerRoot => IO.PutRope[gStream, "pointerRoot\n"]; parent => IO.PutRope[gStream, "parent\n"]; ENDCASE => IO.PutRope[gStream, "bad\n"]; }; Activate: XTkWidgets.ButtonHitProcType = { gLabel ¬ NARROW[registerData]; IO.PutF1[gStream, "Activated %g\n", IO.card[Xl.WindowId[gLabel.window]]]; }; BPGrabKeyboard: XTkWidgets.ButtonHitProcType = { GrabKeyboard[] }; BPUngrabKeyboard: XTkWidgets.ButtonHitProcType = { UngrabKeyboard[] }; BPSetFocus: XTkWidgets.ButtonHitProcType = { SetFocus[] }; BPGetFocus: XTkWidgets.ButtonHitProcType = { GetFocus[] }; XTGrabKeyboard: Commander.CommandProc ~ { GrabKeyboard[]; }; XTUngrabKeyboard: Commander.CommandProc ~ { UngrabKeyboard[]; }; XTSetFocus: Commander.CommandProc ~ { SetFocus[]; }; XTGetFocus: Commander.CommandProc ~ { GetFocus[]; }; Commander.Register["XTCreateWindow", XTCreateWindow, "Create a base widget for further tests"]; Commander.Register["XTGrabKeyboard", XTGrabKeyboard, "Grab keyboard"]; Commander.Register["XTUngrabKeyboard", XTUngrabKeyboard, "Ungrab keyboard"]; Commander.Register["XTSetFocus", XTSetFocus, "Set input focus"]; Commander.Register["XTGetFocus", XTGetFocus, "Get input focus"]; END. *X11Tests0.mesa Copyright Σ 1992 by Xerox Corporation. All rights reserved. Christian Jacobi, November 17, 1992 12:15 pm PST Routines to debug input focus related things Not really polished, this is a debugging aid id: XTkWidgets.Widget ¬ XTkWidgets.CreateLabel[text: "X11Tests identity"]; Κ%–(cedarcode) style•NewlineDelimiter ˜code™Kšœ Οeœ1™