diff options
Diffstat (limited to 'xorg-server/dix')
-rw-r--r-- | xorg-server/dix/devices.c | 2 | ||||
-rw-r--r-- | xorg-server/dix/eventconvert.c | 67 | ||||
-rw-r--r-- | xorg-server/dix/getevents.c | 42 | ||||
-rw-r--r-- | xorg-server/dix/inpututils.c | 70 | ||||
-rw-r--r-- | xorg-server/dix/ptrveloc.c | 4 |
5 files changed, 142 insertions, 43 deletions
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c index 73c4d1460..c8ae230cd 100644 --- a/xorg-server/dix/devices.c +++ b/xorg-server/dix/devices.c @@ -2368,7 +2368,7 @@ RecalculateMasterButtons(DeviceIntPtr slave) event.keys.max_keycode = master->key->xkbInfo->desc->max_key_code; } - XISendDeviceChangedEvent(master, master, &event); + XISendDeviceChangedEvent(master, &event); } } diff --git a/xorg-server/dix/eventconvert.c b/xorg-server/dix/eventconvert.c index 5269e53bc..d7b161e02 100644 --- a/xorg-server/dix/eventconvert.c +++ b/xorg-server/dix/eventconvert.c @@ -43,10 +43,13 @@ #include "inputstr.h" #include "misc.h" #include "eventstr.h" +#include "exevents.h" #include "exglobals.h" #include "eventconvert.h" +#include "inpututils.h" #include "xiquerydevice.h" #include "xkbsrv.h" +#include "inpututils.h" static int countValuators(DeviceEvent *ev, int *first); @@ -482,6 +485,40 @@ appendValuatorInfo(DeviceChangedEvent *dce, xXIValuatorInfo *info, int axisnumbe } static int +appendScrollInfo(DeviceChangedEvent *dce, xXIScrollInfo *info, int axisnumber) +{ + if (dce->valuators[axisnumber].scroll.type == SCROLL_TYPE_NONE) + return 0; + + info->type = XIScrollClass; + info->length = sizeof(xXIScrollInfo)/4; + info->number = axisnumber; + switch(dce->valuators[axisnumber].scroll.type) + { + case SCROLL_TYPE_VERTICAL: + info->scroll_type = XIScrollTypeVertical; + break; + case SCROLL_TYPE_HORIZONTAL: + info->scroll_type = XIScrollTypeHorizontal; + break; + default: + ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", dce->valuators[axisnumber].scroll.type); + break; + } + info->increment = double_to_fp3232(dce->valuators[axisnumber].scroll.increment); + info->sourceid = dce->sourceid; + + info->flags = 0; + + if (dce->valuators[axisnumber].scroll.flags & SCROLL_FLAG_DONT_EMULATE) + info->flags |= XIScrollFlagNoEmulation; + if (dce->valuators[axisnumber].scroll.flags & SCROLL_FLAG_PREFERRED) + info->flags |= XIScrollFlagPreferred; + + return info->length * 4; +} + +static int eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi) { xXIDeviceChangedEvent *dcce; @@ -496,8 +533,16 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi) len += pad_to_int32(bits_to_bytes(dce->buttons.num_buttons)); } if (dce->num_valuators) + { + int i; + len += sizeof(xXIValuatorInfo) * dce->num_valuators; + for (i = 0; i < dce->num_valuators; i++) + if (dce->valuators[i].scroll.type != SCROLL_TYPE_NONE) + len += sizeof(xXIScrollInfo); + } + nkeys = (dce->keys.max_keycode > 0) ? dce->keys.max_keycode - dce->keys.min_keycode + 1 : 0; if (nkeys > 0) @@ -543,6 +588,15 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi) dcce->num_classes += dce->num_valuators; for (i = 0; i < dce->num_valuators; i++) ptr += appendValuatorInfo(dce, (xXIValuatorInfo*)ptr, i); + + for (i = 0; i < dce->num_valuators; i++) + { + if (dce->valuators[i].scroll.type != SCROLL_TYPE_NONE) + { + dcce->num_classes++; + ptr += appendScrollInfo(dce, (xXIScrollInfo*)ptr, i); + } + } } *xi = (xEvent*)dcce; @@ -633,9 +687,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) if (BitIsOn(ev->valuators.mask, i)) { SetBit(ptr, i); - axisval->integral = trunc(ev->valuators.data[i]); - axisval->frac = (ev->valuators.data[i] - axisval->integral) * - (1 << 16) * (1 << 16); + *axisval = double_to_fp3232(ev->valuators.data[i]); axisval++; } } @@ -679,13 +731,8 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) if (BitIsOn(ev->valuators.mask, i)) { SetBit(ptr, i); - axisval->integral = trunc(ev->valuators.data[i]); - axisval->frac = (ev->valuators.data[i] - axisval->integral) * - (1 << 16) * (1 << 16); - axisval_raw->integral = trunc(ev->valuators.data_raw[i]); - axisval_raw->frac = - (ev->valuators.data_raw[i] - axisval_raw->integral) * - (1 << 16) * (1 << 16); + *axisval = double_to_fp3232(ev->valuators.data[i]); + *axisval_raw = double_to_fp3232(ev->valuators.data_raw[i]); axisval++; axisval_raw++; } diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c index f000620e3..226d5cd43 100644 --- a/xorg-server/dix/getevents.c +++ b/xorg-server/dix/getevents.c @@ -224,7 +224,7 @@ void CreateClassesChangedEvent(InternalEvent* event, DeviceIntPtr master, DeviceIntPtr slave, - int type) + int flags) { int i; DeviceChangedEvent *dce; @@ -233,13 +233,12 @@ CreateClassesChangedEvent(InternalEvent* event, dce = &event->changed_event; memset(dce, 0, sizeof(DeviceChangedEvent)); dce->deviceid = slave->id; - dce->masterid = master->id; + dce->masterid = master ? master->id : 0; dce->header = ET_Internal; dce->length = sizeof(DeviceChangedEvent); dce->type = ET_DeviceChanged; dce->time = ms; - dce->flags = type; - dce->flags |= DEVCHANGE_SLAVE_SWITCH; + dce->flags = flags; dce->sourceid = slave->id; if (slave->button) @@ -258,6 +257,7 @@ CreateClassesChangedEvent(InternalEvent* event, dce->valuators[i].resolution = slave->valuator->axes[i].resolution; dce->valuators[i].mode = slave->valuator->axes[i].mode; dce->valuators[i].name = slave->valuator->axes[i].label; + dce->valuators[i].scroll = slave->valuator->axes[i].scroll; } } if (slave->key) @@ -688,7 +688,7 @@ UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_eve if (master && master->last.slave != dev) { - CreateClassesChangedEvent(events, master, dev, type); + CreateClassesChangedEvent(events, master, dev, type | DEVCHANGE_SLAVE_SWITCH); if (IsPointerDevice(master)) { updateSlaveDeviceCoords(master, dev); @@ -1249,6 +1249,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, * * @param events The pointer to the event list to fill the events * @param dev The device to generate the events for + * @param type The real type of the event * @param axis The axis number to generate events for * @param mask State before this event in absolute coords * @param[in,out] last Last scroll state posted in absolute coords (modified @@ -1260,6 +1261,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, static int emulate_scroll_button_events(InternalEvent *events, DeviceIntPtr dev, + int type, int axis, const ValuatorMask *mask, ValuatorMask *last, @@ -1272,6 +1274,7 @@ emulate_scroll_button_events(InternalEvent *events, int num_events = 0; double total; int b; + int flags = 0; if (dev->valuator->axes[axis].scroll.type == SCROLL_TYPE_NONE) return 0; @@ -1282,6 +1285,9 @@ emulate_scroll_button_events(InternalEvent *events, ax = &dev->valuator->axes[axis]; incr = ax->scroll.increment; + if (type != ButtonPress && type != ButtonRelease) + flags |= POINTER_EMULATED; + if (!valuator_mask_isset(last, axis)) valuator_mask_set_double(last, axis, 0); @@ -1309,14 +1315,20 @@ emulate_scroll_button_events(InternalEvent *events, */ if (num_events + 4 < max_events) { - nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms, - POINTER_EMULATED, NULL); - events += nev_tmp; - num_events += nev_tmp; - nev_tmp = fill_pointer_events(events, dev, ButtonRelease, b, ms, - POINTER_EMULATED, NULL); - events += nev_tmp; - num_events += nev_tmp; + if (type != ButtonRelease) + { + nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms, + flags, NULL); + events += nev_tmp; + num_events += nev_tmp; + } + if (type != ButtonPress) + { + nev_tmp = fill_pointer_events(events, dev, ButtonRelease, b, ms, + flags, NULL); + events += nev_tmp; + num_events += nev_tmp; + } } } @@ -1361,6 +1373,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, ValuatorMask mask; ValuatorMask scroll; int i; + int realtype = type; /* refuse events from disabled devices */ if (!pDev->enabled) @@ -1413,6 +1426,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, valuator_mask_set_double(&mask, axis, val); type = MotionNotify; buttons = 0; + flags |= POINTER_EMULATED; } } @@ -1432,7 +1446,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, valuator_mask_set_double(&scroll, i, pDev->last.valuators[i]); - nev_tmp = emulate_scroll_button_events(events, pDev, i, &scroll, + nev_tmp = emulate_scroll_button_events(events, pDev, realtype, i, &scroll, pDev->last.scroll, ms, GetMaximumEventsNum() - num_events); events += nev_tmp; diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c index 5c76361b3..5797f9256 100644 --- a/xorg-server/dix/inpututils.c +++ b/xorg-server/dix/inpututils.c @@ -38,6 +38,7 @@ #include "inpututils.h" #include "eventstr.h" #include "scrnintstr.h" +#include "optionstr.h" /* Check if a button map change is okay with the device. * Returns -1 for BadValue, as it collides with MappingBusy. */ @@ -539,6 +540,42 @@ valuator_mask_get(const ValuatorMask *mask, int valuator) } /** + * Set value to the requested valuator. If the mask bit is set for this + * valuator, value contains the requested valuator value and TRUE is + * returned. + * If the mask bit is not set for this valuator, value is unchanged and + * FALSE is returned. + */ +Bool +valuator_mask_fetch_double(const ValuatorMask *mask, int valuator, double *value) +{ + if (valuator_mask_isset(mask, valuator)) + { + *value = valuator_mask_get_double(mask, valuator); + return TRUE; + } else + return FALSE; +} + +/** + * Set value to the requested valuator. If the mask bit is set for this + * valuator, value contains the requested valuator value and TRUE is + * returned. + * If the mask bit is not set for this valuator, value is unchanged and + * FALSE is returned. + */ +Bool +valuator_mask_fetch(const ValuatorMask *mask, int valuator, int *value) +{ + if (valuator_mask_isset(mask, valuator)) + { + *value = valuator_mask_get(mask, valuator); + return TRUE; + } else + return FALSE; +} + +/** * Remove the valuator from the mask. */ void @@ -634,8 +671,9 @@ point_on_screen(ScreenPtr pScreen, int x, int y) static void input_option_free(InputOption *o) { - free(o->key); - free(o->value); + free(o->opt_name); + free(o->opt_val); + free(o->opt_comment); free(o); } @@ -665,7 +703,7 @@ input_option_new(InputOption* list, const char *key, const char *value) if (list) { - nt_list_for_each_entry(opt, list, next) + nt_list_for_each_entry(opt, list, list.next) { if (strcmp(input_option_get_key(opt), key) == 0) { @@ -679,13 +717,13 @@ input_option_new(InputOption* list, const char *key, const char *value) if (!opt) return NULL; - nt_list_init(opt, next); + nt_list_init(opt, list.next); input_option_set_key(opt, key); input_option_set_value(opt, value); if (list) { - nt_list_append(opt, list, InputOption, next); + nt_list_append(opt, list, InputOption, list.next); return list; } else return opt; @@ -696,9 +734,9 @@ input_option_free_element(InputOption *list, const char *key) { InputOption *element; - nt_list_for_each_entry(element, list, next) { + nt_list_for_each_entry(element, list, list.next) { if (strcmp(input_option_get_key(element), key) == 0) { - nt_list_del(element, list, InputOption, next); + nt_list_del(element, list, InputOption, list.next); input_option_free(element); break; } @@ -714,8 +752,8 @@ input_option_free_list(InputOption **opt) { InputOption *element, *tmp; - nt_list_for_each_entry_safe(element, tmp, *opt, next) { - nt_list_del(element, *opt, InputOption, next); + nt_list_for_each_entry_safe(element, tmp, *opt, list.next) { + nt_list_del(element, *opt, InputOption, list.next); input_option_free(element); } *opt = NULL; @@ -732,7 +770,7 @@ input_option_find(InputOption *list, const char *key) { InputOption *element; - nt_list_for_each_entry(element, list, next) { + nt_list_for_each_entry(element, list, list.next) { if (strcmp(input_option_get_key(element), key) == 0) return element; } @@ -743,29 +781,29 @@ input_option_find(InputOption *list, const char *key) const char* input_option_get_key(const InputOption *opt) { - return opt->key; + return opt->opt_name; } const char* input_option_get_value(const InputOption *opt) { - return opt->value; + return opt->opt_val; } void input_option_set_key(InputOption *opt, const char *key) { - free(opt->key); + free(opt->opt_name); if (key) - opt->key = strdup(key); + opt->opt_name = strdup(key); } void input_option_set_value(InputOption *opt, const char *value) { - free(opt->value); + free(opt->opt_val); if (value) - opt->value = strdup(value); + opt->opt_val = strdup(value); } diff --git a/xorg-server/dix/ptrveloc.c b/xorg-server/dix/ptrveloc.c index fc5cf49b8..1ba531c96 100644 --- a/xorg-server/dix/ptrveloc.c +++ b/xorg-server/dix/ptrveloc.c @@ -658,13 +658,13 @@ QueryTrackers(DeviceVelocityPtr vel, int cur_t){ DebugAccelF("(dix prtacc) query: last tracker in effect\n"); used_offset = vel->num_tracker-1; } -#ifdef PTRACCEL_DEBUGGING if(used_offset >= 0){ +#ifdef PTRACCEL_DEBUGGING MotionTracker *tracker = TRACKER(vel, used_offset); DebugAccelF("(dix prtacc) result: offset %i [dx: %i dy: %i diff: %i]\n", used_offset, tracker->dx, tracker->dy, cur_t - tracker->time); - } #endif + } return result; } |