xzoom

A simple screen magnifier for X11.
git clone git://r-36.net/xzoom
Log | Files | Refs

commit 02455f8f2c282c809f8bea1a00a00b8cda11de57
parent 2efc3a678f4a4694acb57bc368771c5be11c02f3
Author: Phil Carmody <pc+xzoom@asdf.org>
Date:   Thu, 21 Nov 2013 17:38:46 +0200

xzoom: don't redraw the screen when the window's not visible

Most of the CPU usage was in the read/scale/write part, so skip it
if we can.

Signed-off-by: Phil Carmody <pc+xzoom@asdf.org>
Signed-off-by: Christoph Lohmann <20h@r-36.net>

Diffstat:
xzoom.c | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/xzoom.c b/xzoom.c @@ -385,6 +385,7 @@ main(int argc, char **argv) { XSizeHints *sizeh = NULL; XClassHint *ch; int buttonpressed = False; + int visible = False; int scroll = 1; char title[80]; XGCValues gcv; @@ -576,6 +577,8 @@ main(int argc, char **argv) { xswa.event_mask = ButtonPressMask|ButtonReleaseMask|ButtonMotionMask; xswa.event_mask |= StructureNotifyMask; /* resize etc.. */ xswa.event_mask |= KeyPressMask|KeyReleaseMask; /* commands */ + xswa.event_mask |= VisibilityChangeMask; + xswa.background_pixel = BlackPixelOfScreen(scr); win = XCreateWindow(dpy, RootWindowOfScreen(scr), @@ -699,6 +702,11 @@ main(int argc, char **argv) { case ReparentNotify: break; /* what do we do with it? */ + case VisibilityNotify: + /* VisibilityUnobscured, VisibilityPartiallyObscured, or VisibilityFullyObscured */ + visible = (event.xvisibility.state!=VisibilityFullyObscured); + break; + case KeyRelease: switch(XKeycodeToKeysym(dpy, event.xkey.keycode, 0)) { case XK_Control_L: @@ -901,7 +909,8 @@ main(int argc, char **argv) { } - xzoom(buttonpressed); + if(visible) + xzoom(buttonpressed); #ifdef NO_USLEEP #define usleep(_t) \