On Tue, Jan 14, 2014 at 06:13:58PM -0800, Parke wrote:
> Hi,
>
> I use the Openbox window manager with xterm. I just tried replacing
> xterm with st.
>
> Compared to xterm, st will stutter/freeze when I resize a window by
> dragging a window edge with the mouse. I have Openbox set to refresh
> the window contents during the resize.
>
This will make OpenBox send a ConfigureNotify event whenever the mouse
moves more than one character.
> Xterm pretty much stays in sync with my resizing. In comparison, the
> stutter/lag with st is annoying. If I aggressively resize the window
> (say 10 seconds of continuous up/down resizing), xterm will stay in
> sync. st will stutter, then freeze. CPU usage will max out at 100%
> (mostly in the X server). Even after I stop resizing the window, st
> will still be frozen (sometimes for over 10 seconds) with CPU usage at
> 100%.
>
> I am running X with the VESA video driver on a 1.2ghz Celeron, on Ubuntu
> 13.04.
>
> I thought the performance delta between xterm and st might be of interest.
>
Here's a premature optimization (attached). Please let us know if that helped.
> st also uses slightly more memory than xterm.
>
Could that be because we use Xft? In that case xterm is hiding an
equivalent amount of memory by offloading it onto the X server.
> -Parke
>
HTH,
Markus
diff --git a/st.c b/st.c
index 4d543d1..60c5658 100644
--- a/st.c
+++ b/st.c
@@ -410,6 +410,7 @@ static void xunloadfont(Font *f);
static void xunloadfonts(void);
static void xresize(int, int);
+static void ffw(XEvent *);
static void expose(XEvent *);
static void visibility(XEvent *);
static void unmap(XEvent *);
@@ -1136,6 +1137,7 @@ brelease(XEvent *e) {
void
bmotion(XEvent *e) {
int oldey, oldex, oldsby, oldsey;
+ ffw(e);
if(IS_SET(MODE_MOUSE)) {
mousereport(e);
@@ -3456,6 +3458,11 @@ drawregion(int x1, int y1, int x2, int y2) {
}
void
+ffw(XEvent *ev) {
+ while (XCheckTypedEvent(xw.dpy, ev->type, ev)) ;
+}
+
+void
expose(XEvent *ev) {
XExposeEvent *e = &ev->xexpose;
@@ -3468,6 +3475,7 @@ expose(XEvent *ev) {
void
visibility(XEvent *ev) {
+ ffw(ev);
XVisibilityEvent *e = &ev->xvisibility;
if(e->state == VisibilityFullyObscured) {
@@ -3500,6 +3508,7 @@ xseturgency(int add) {
void
focus(XEvent *ev) {
+ ffw(ev);
XFocusChangeEvent *e = &ev->xfocus;
if(e->mode == NotifyGrab)
@@ -3654,6 +3663,7 @@ cresize(int width, int height) {
void
resize(XEvent *e) {
+ ffw(e);
if(e->xconfigure.width == xw.w && e->xconfigure.height == xw.h)
return;