diff options
author | Jeremy Huddleston <jeremyhu@apple.com> | 2011-09-16 17:58:21 -0500 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2011-09-19 19:32:02 -0700 |
commit | 311488bc0ace95f1c4b6df73a59417109ba68b5f (patch) | |
tree | 1a0782181b7149b2b02125307d524e87ed885e18 /src | |
parent | 7e909e6df065f7c507fb897f3882782f463e7905 (diff) |
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 <jeremyhu@apple.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/xlibclient.c | 42 |
1 files 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; } } } |