From 311488bc0ace95f1c4b6df73a59417109ba68b5f Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Fri, 16 Sep 2011 17:58:21 -0500 Subject: Cleanup NestedClientCheckEvents to use switch rather than if-else-foo This makes the code more readable and makes the following patch cleaner. Signed-off-by: Jeremy Huddleston --- src/xlibclient.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/src/xlibclient.c b/src/xlibclient.c index d8027eb..c1e21ad 100644 --- a/src/xlibclient.c +++ b/src/xlibclient.c @@ -285,7 +285,8 @@ NestedClientCheckEvents(NestedClientPrivatePtr pPriv) { XEvent ev; while(XCheckMaskEvent(pPriv->display, ~0, &ev)) { - if (ev.type == Expose) { + switch (ev.type) { + case Expose: NestedClientUpdateScreen(pPriv, ((XExposeEvent*)&ev)->x, ((XExposeEvent*)&ev)->y, @@ -293,34 +294,23 @@ NestedClientCheckEvents(NestedClientPrivatePtr pPriv) { ((XExposeEvent*)&ev)->width, ((XExposeEvent*)&ev)->y + ((XExposeEvent*)&ev)->height); - } - - // Post mouse motion events to input driver. - if (ev.type == MotionNotify) { - int x = ((XMotionEvent*)&ev)->x; - int y = ((XMotionEvent*)&ev)->y; - - NestedInputPostMouseMotionEvent(pPriv->dev, x, y); - } + break; - // Post mouse button press events to input driver. - if (ev.type == ButtonPress) { - NestedInputPostButtonEvent(pPriv->dev, ev.xbutton.button, TRUE); - } - - // Post mouse button release events to input driver. - if (ev.type == ButtonRelease) { - NestedInputPostButtonEvent(pPriv->dev, ev.xbutton.button, FALSE); - } + case MotionNotify: + NestedInputPostMouseMotionEvent(pPriv->dev, + ((XMotionEvent*)&ev)->x, + ((XMotionEvent*)&ev)->y); + break; - // Post keyboard press events to input driver. - if (ev.type == KeyPress) { - NestedInputPostKeyboardEvent(pPriv->dev, ev.xkey.keycode, TRUE); - } + case ButtonPress: + case ButtonRelease: + NestedInputPostButtonEvent(pPriv->dev, ev.xbutton.button, ev.type == ButtonPress); + break; - // Post keyboard release events to input driver. - if (ev.type == KeyRelease) { - NestedInputPostKeyboardEvent(pPriv->dev, ev.xkey.keycode, FALSE); + case KeyPress: + case KeyRelease: + NestedInputPostKeyboardEvent(pPriv->dev, ev.xkey.keycode, ev.type == KeyPress); + break; } } } -- cgit v1.2.3