Re: CLX/CMUCL: Event processing speed



David Trudgett wrote:
Hm, it's been a while since I did any X window.  Wasn't there an event
count associated with each sort of event.  I remember reading
something about that if some count > 0, you simply discard the event,
so that you only redraw after the last resize/expose/... was received.

I thought I was doing that, but I looked at the code and realised I must have accidentally deleted it somewhere along the line. In any case, I put it back in, but the behaviour is just the same. I assume it must be generating lots of exposure events with count equal to zero.

Hm, maybe you should stick a FORMAT or a counter somewhere in there, or something that measures the time between subsequent events of a kind.


I just looked through the Xlib code I wrote (in C), and noticed that you don't have any ConfigureNotify-events in there. They are the ones that contain resizing information about your window.

(from Xlib.h)
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window event;
Window window;
int x, y;
int width, height;
int border_width;
Window above;
Bool override_redirect;
} XConfigureEvent;


I only used width and height for a simple example, but window might be interesting too if you have more than one. Unfortunately I'm not exactly familiar with CLX, so I can't tell what exactly is going on in your code.

I'm not sure what modern window-managers do; if they really send lots of expose-events, or mostly configure-notifies. In any case it shouldn't be *that* many.

Anyway, here is the corrected bit:

(defmacro with-drawing-window (&body body)
(flet ((do-stuff () `(progn ,@body (display-finish-output *display*))))
`(unwind-protect (progn
(show-drawing-window)
(event-case
(*display* :force-output-p t :discard-p t)

What do force-output-p and discard-p do? Maybe this is some kind of Sync option that slows down the server connection?


                       (DRAW-LINE *DRAWING-WINDOW*
                                  *GRAPHICS-CONTEXT*
                                  100
                                  300
                                  X
                                  Y2)
                       (WHEN (>= X 590) (SETQ X-INC (- X-INC))))

(DISPLAY-FINISH-OUTPUT *DISPLAY*)))

XSync()?

At least in the C version, all the X-commands you do are placed in a buffer, and only XNextEvent() flushes the buffer to the server, goes fetch new events, and gives you the first one. Subsequent XNextEvents probably don't even make new round-trips (at least when you don't create new commands for the server; and probably your resize-handlers, and the expose-handler with count > 0 won't do that), but just fetch the next event in the client's buffer.

(so in C you almost never need to call anything like XSync(). Not sure what your DISPLAY-FINISH-OUTPUT does.)

Not sure what takes so long here...

--
If you have to ask what jazz is, you'll never know.
	Louis Armstrong
.



Relevant Pages

  • Re: In window mode, pD3DDevice->SetViewport?
    ... the back buffer is always stretchblit to ... // Holds Our Window Handle ... HINSTANCE hInstance; // Holds The Instance Of The Application ... void ReSizeD3DScene(int width, int height) // Resize And Initialize The ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: How add buton onto title bar of any external active window?
    ... I want to add buttons ontoany active window. ... int sm_CXSIZE; ... static int WindowsFeaturesWidth(HWND hwnd, DWORD style) ... LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM ...
    (microsoft.public.win32.programmer.gdi)
  • TextOut and WM_PAINT
    ... I update the window A from other one, ... This window A receives that message and should check the lparam and wparam.. ... What I need is to display that int value. ... same value is shown all the time, in spite of the int and buffer values are ...
    (microsoft.public.vc.mfc)
  • Re: CreateProcess() its extermely slow
    ... I notice that if my application has no Window, ... int APIENTRY _tWinMain(HINSTANCE hInstance, ... LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, ... LPARAM lParam) ...
    (microsoft.public.vc.mfc)
  • JFrame Resize Issues (Redux)
    ... However, when the LookAndFeel is set, Java's Window Manager ... public int OffSetX = 0; ... private Rectangle positRectangle; ... public void componentHidden{ ...
    (comp.lang.java.programmer)