Helloo again list from Bristol's Central Library!, and thanks very much Mark, if you remember your last comment for my questions:
I'll just chime in with a note about performance.
The correct way to do an event loop is something like.
The correct way to do an event loop is something like.
while(1) {
expose = FALSE;
while(XPending(display)) {
XNextEvent(display, &event);
switch(event.type) {
case Expose: expose = TRUE;
break;
[...]
}
}
XNextEvent(display, &event);
switch(event.type) {
case Expose: expose = TRUE;
break;
[...]
}
}
if(expose) {
HandleExpose();
}
HandleExpose();
}
}
You will get many expose, move, etc... events in a row. If there are
several pending, you do not want to redraw many times, but only once.
Also, note that you get an expose event for each rectangle exposed.
If you're not optimizing on an individual rect by rect basis (most
people don't) you want to throw away all XExposeEvent with non-zero
counts. eg:
several pending, you do not want to redraw many times, but only once.
Also, note that you get an expose event for each rectangle exposed.
If you're not optimizing on an individual rect by rect basis (most
people don't) you want to throw away all XExposeEvent with non-zero
counts. eg:
case Expose: if(!event.xexpose.count)
expose = TRUE;
break;
expose = TRUE;
break;
As for determining if the mouse is over the widget, tracking
motion events is usually not a good idea. Since a widget is a
window (or at least it should be), you just want to get XCrossingEvent
events (ie, EnterNotify and LeaveNotify).
motion events is usually not a good idea. Since a widget is a
window (or at least it should be), you just want to get XCrossingEvent
events (ie, EnterNotify and LeaveNotify).
Also, if you have static artwork (stuff that doesn't change) you
might want to consider setting it as the window background rather
than getting expose events and having to redraw it. If a pixmap
is set as a window background, the server will automatically expose
the area with the contents of the pixmap.
might want to consider setting it as the window background rather
than getting expose events and having to redraw it. If a pixmap
is set as a window background, the server will automatically expose
the area with the contents of the pixmap.
Mark.
Ok. They helped my prettty well in order to understand xlib development in a new way, so thank you very much.
The only thing about your comment is, I find the use of Xpending make my proccessor to work at the highest level (because the while I supossed). However, I think rembember to have tested it without the while statement, the result was still the same, and the thing is, why gimp, or anyother application doesn't make the processor to run in such level when waiting for any user response.
Actually, I'm doing in it the traditional way, but within a little bit more accurated code, at the same time I learn programming as well. I hope to bring some source code very soon for you, or anyother one who wants to do it make a comment about that.
But my question today is a different one. I've been testing override-redirect flag, and I can achieve the mapping of a top level window, but as a far as I've been reading xlib manual, and trying it over different ways, I can't achieve the mapping of a window with no decorations of anykind by the window-manager, but with a visible icon in the taskbar, this is, I would like to test something like a *window-manager independent* window with it's own decorations done by me.
Or what is the same, something like a top level window (override-redirect=true) with an icon visible on the task bar, so I can test things such my own close-window button and send client message event to the server, among other things. I don't want this window to be controlled by any window manager. Any comment about this?
Thanks very much again.
BT Yahoo! Broadband - Free modem offer, sign up online today and save �80
