hi,

I eventually got over my previous AddInputHandler puzzling and kept on
reading code until I finished the included rough outline of "useful"
code paths in the XServer.

I am planning to turn this into a real documentation but real life
matters make it unreasonable for me to finish this before the end of
august. As such, I thought some people might find it useful as-is.

Mathieu
-- 
Mathieu Lacage <[EMAIL PROTECTED]>

main:
-----

xc/programs/Xserver/dix/main.c:main
  hw/xfree86/common/xf86Init.c:InitOutput
  hw/xfree86/common/xf86Init.c:InitInput
  Xserver/dix/dispatch.c:Dispatch
    hw/xfree86/common/xf86Events.c:ProcessInputEvents
    Xserver/os/WaitFor.c:WaitForSomething
    ReadRequestFromClient
    result = (* client->requestVector[MAJOROP])(client) which ends in one of the 
functions stored in dix/tables.c
     dix/dispatch.c:ProcPolyPoint
        include/dix.h:VALIDATE_DRAWABLE_AND_GC
          ValidateGC
            pGC->funcs->ValidateGC
              XAAValidateGC
        (*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint,(xPoint *) 
&stuff[1]);
      


InitOutput:
-----------

  hw/xfree86/common/xf86config.c:xf86HandleConfig
    hw/xfree86/common/xf86Config.c:configLayout
      hw/xfree86/common/xf86Config.c:configInput
        hw/xfree86/common/xf86Config.c:configInputKbd
          set xf86Info.kbdEvents to one of xf86KbdEvents, xf86XqueEvents or 
xf86WSKbdEvents.
  driver->PreInit
    driver/neomagic/neo_driver.c:NEOPreInit
      driver/neomagic/neo_2070.c:Neo2070AccelInit
        xaa/xaaInit.c:XAAInit
          xaa/xaaInitAccel.c:XAAInitAccel (finish intialization of gc->ops)
  Xserver/dix/dixutils.c:RegisterBlockAndWakeupHandlers (NoopDDA, xf86Wakeup)


InitInput:
----------

    foreach input driver specified in config file
      driver->PreInit which ends in
        hw/xfree86/input/mouse.c:MousePreInit
        hw/xfree86/common/xf86helper.c:xf86AllocateInput
          pInfo->read_input = MouseReadInput
          pMse->PostEvent = MousePostEvent
    foreach input driver registered with xf86AllocateInput
      xf86Xinput.c:xf86ActivateDevice
        dix/device.c:AddInputDevice
          _AddInputDevice
             dev->deviceProc = deviceProc;
        xf86XinputFinalizeInit
        one of RegisterPointerDevice or RegisterKeyboardDevice
           device->public.processInputProc = ProcessKeyboardEvent;
           device->public.realInputProc = ProcessKeyboardEvent;
           device->ActivateGrab = ActivateKeyboardGrab;
           device->DeactivateGrab = DeactivateKeyboardGrab;
    if (no XInput support)
      :mieqInit (register core keyboard and pointer)
    else
      hw/xfree86/common/xf86XInput.c:xf86eqInit (register core keyboard and pointer)
        xf86EventQueue.pKbd = pKbd;
        xf86EventQueue.pPtr = pPtr;


ProcessInputEvents:
-------------------

      if (no XInput support)
        Xserver/mi/mieq.c:mieqProcessInputEvents
      else
        Xserver/hw/xfree86/common/xf86Xinput.c:xf86eqProcessInputEvents
          if (key pressed)
            (*xf86EventQueue.pKbd->processInputProc)
               Xserver/dix/events.c:ProcessKeyboardEvent
                 DeliverGrabbedEvent or DeliverDeviceEvent
          else if (mouse event)
            (*(inputInfo.pointer->public.processInputProc)) 
               Xserver/dix/events.c:ProcessPointerEvent 
                 DeliverGrabbedEvent or DeliverDeviceEvent
                   DeliverEventsToWindow
                     TryClientEvents
                       WriteEventsToClient
                         Xserver/os/io.c:WriteToClient
                           ReplyCallback --> used by other pieces of code interested 
in the reply going out
                           if (not enough data)
                             bufferize
                           else
                             FlushClient
                               xc/lib/xtrans/Xtrans.h:_XSERVTransWritev
                                  xc/lib/xtrans/Xtrans.c:ciptr->transptr->Writev which 
ends in
                                    xc/lib/xtrans/Xtranslcl.c:TRANS(LocalWritev) 
(local case)
                                    xc/lib/xtrans/Xtranssock.c:TRANS(SocketWritev) 
(networked case)
        

WaitForSomething:
-----------------

      while (1) {
        Xserver/dix/dixutils.c:ProcessWorkQueue
        Xserver/dix/dixutils.c:BlockHandler (invoke each function in the BlockHandler 
list with the waittime as param)
           hw/xfree86/common/xf86Events.c:xf86Wakeup
           if (events) {
             xf86Info.kbdEvents which ends in
               hw/xfree86/common/xf86Events.c:xf86PostKbdEvent (convert hardware 
keycode into X keycode)
                 ENQUEUE
                   EqEnqueue
                   __EqEnqueue
                     xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c:xf86eqEnqueue 
(insert event in 
                       xf86EventQueue.events)
             foreach fd which is an input dev, pInfo->read_input which ends in
               hw/xfree86/input/mouse.c::MouseReadInput (read data from device, parse 
it)
                  MousePostEvent
                    MouseDoPostEvent
                      hw/xfree86/common/xf86Xinput.c:xf86PostButtonEvent or 
xf86PostMotionEvent
                        hw/xfree86/common/xf86Events.c:ENQUEUE
             foreach input handler which generated an event, 
               ih->ihproc
           }
        Xserver/os/io.c:FlushAllOutput (flush all clients which have no input pending)
          Xserver/os/io.c:FlushClient
        xc/include/Xpoll.h:Select (maps to select on linux)
        Xserver/dix/dixutils.c:WakeupHandler (invoke each function in the BlockHandler 
list with the number 
                                      of fds which changed of state during Select and 
read changed mask)
        if (error_during_select) {
          CheckConnections
          break;
        } else {
          dix/dixutils.c:QueueWorkProc (EstablishNewConnections)
        }
      }


EstablishNewConnections:
------------------------

os/connection.c:EstablishNewConnections
  os/connection.c:AllocNewConnection
    dix/dispatch.c:NextAvailableClient
      InitClient
        client->requestVector = InitialVector (see dix/tables.c)

Reply via email to