diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-08 10:22:26 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-13 13:24:08 +1000 |
commit | 1d01e861b69d7ca8fe2335270b8286bc115fb6e9 (patch) | |
tree | a1fba70e6d868ef95100800f3ed2df63e0296834 | |
parent | fb010c543696b781a83b945f72865b7d7b75bf95 (diff) |
dix: split out core state and event state setting into helper functions
no functional changes.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | Xi/exevents.c | 31 | ||||
-rw-r--r-- | dix/inpututils.c | 39 | ||||
-rw-r--r-- | include/inpututils.h | 2 |
3 files changed, 44 insertions, 28 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 798377670..874759959 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -915,7 +915,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) int key = 0, rootX, rootY; ButtonClassPtr b; int ret = 0; - int corestate, i; + int corestate; DeviceIntPtr mouse = NULL, kbd = NULL; DeviceEvent *event = &ev->device_event; @@ -945,33 +945,8 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) mouse = NULL; } - /* core state needs to be assembled BEFORE the device is updated. */ - corestate = (kbd && kbd->key) ? XkbStateFieldFromRec(&kbd->key->xkbInfo->state) : 0; - corestate |= (mouse && mouse->button) ? (mouse->button->state) : 0; - - for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++) - if (BitIsOn(mouse->button->down, i)) - SetBit(event->buttons, i); - - if (kbd && kbd->key) - { - XkbStatePtr state; - /* we need the state before the event happens */ - if (event->type == ET_KeyPress || event->type == ET_KeyRelease) - state = &kbd->key->xkbInfo->prev_state; - else - state = &kbd->key->xkbInfo->state; - - event->mods.base = state->base_mods; - event->mods.latched = state->latched_mods; - event->mods.locked = state->locked_mods; - event->mods.effective = state->mods; - - event->group.base = state->base_group; - event->group.latched = state->latched_group; - event->group.locked = state->locked_group; - event->group.effective = state->group; - } + corestate = event_get_corestate(mouse, kbd); + event_set_state(mouse, kbd, event); ret = UpdateDeviceState(device, event); if (ret == DONT_PROCESS) diff --git a/dix/inpututils.c b/dix/inpututils.c index 60f9fa0a8..5844daf9c 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -657,6 +657,45 @@ void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms) event->sourceid = dev->id; } +int event_get_corestate(DeviceIntPtr mouse, DeviceIntPtr kbd) +{ + int corestate; + /* core state needs to be assembled BEFORE the device is updated. */ + corestate = (kbd && kbd->key) ? XkbStateFieldFromRec(&kbd->key->xkbInfo->state) : 0; + corestate |= (mouse && mouse->button) ? (mouse->button->state) : 0; + return corestate; +} + +void event_set_state(DeviceIntPtr mouse, DeviceIntPtr kbd, DeviceEvent *event) +{ + int i; + + for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++) + if (BitIsOn(mouse->button->down, i)) + SetBit(event->buttons, i); + + if (kbd && kbd->key) + { + XkbStatePtr state; + /* we need the state before the event happens */ + if (event->type == ET_KeyPress || event->type == ET_KeyRelease) + state = &kbd->key->xkbInfo->prev_state; + else + state = &kbd->key->xkbInfo->state; + + event->mods.base = state->base_mods; + event->mods.latched = state->latched_mods; + event->mods.locked = state->locked_mods; + event->mods.effective = state->mods; + + event->group.base = state->base_group; + event->group.latched = state->latched_group; + event->group.locked = state->locked_group; + event->group.effective = state->group; + } +} + + Bool point_on_screen(ScreenPtr pScreen, int x, int y) { diff --git a/include/inpututils.h b/include/inpututils.h index 5f9dfecc3..96ad6df4d 100644 --- a/include/inpututils.h +++ b/include/inpututils.h @@ -40,6 +40,8 @@ struct _ValuatorMask { extern void verify_internal_event(const InternalEvent *ev); extern void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms); +extern int event_get_corestate(DeviceIntPtr mouse, DeviceIntPtr kbd); +extern void event_set_state(DeviceIntPtr mouse, DeviceIntPtr kbd, DeviceEvent *event); FP3232 double_to_fp3232(double in); FP1616 double_to_fp1616(double in); |