diff options
author | Keith Packard <keithp@keithp.com> | 2011-10-24 22:09:00 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-10-24 22:09:00 -0700 |
commit | 5701ab4a441eb113abd0851b0d71b82d12112854 (patch) | |
tree | 33bb486d975fe46781283c9f8495b21d25d422e2 | |
parent | 7d50211ab57a35910d79fc3f67ae89aff91fa995 (diff) | |
parent | a41214bc9a0f326c6dc129e4a6382efb8b826862 (diff) |
Merge remote-tracking branch 'whot/for-keith'
-rw-r--r-- | Xi/exevents.c | 20 | ||||
-rw-r--r-- | Xi/xiquerydevice.c | 7 | ||||
-rw-r--r-- | dix/devices.c | 2 | ||||
-rw-r--r-- | dix/eventconvert.c | 67 | ||||
-rw-r--r-- | dix/getevents.c | 10 | ||||
-rw-r--r-- | dix/inpututils.c | 34 | ||||
-rw-r--r-- | dix/ptrveloc.c | 4 | ||||
-rw-r--r-- | hw/kdrive/src/kinput.c | 139 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Config.c | 16 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Init.c | 29 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Option.c | 3 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Optionstr.h | 13 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Xinput.c | 5 | ||||
-rw-r--r-- | hw/xfree86/doc/ddxDesign.xml | 4 | ||||
-rw-r--r-- | hw/xfree86/parser/Flags.c | 5 | ||||
-rw-r--r-- | hw/xfree86/parser/Layout.c | 2 | ||||
-rw-r--r-- | include/eventstr.h | 1 | ||||
-rw-r--r-- | include/exevents.h | 3 | ||||
-rw-r--r-- | include/input.h | 3 | ||||
-rw-r--r-- | include/inputstr.h | 7 | ||||
-rw-r--r-- | include/list.h | 12 | ||||
-rw-r--r-- | include/optionstr.h | 14 | ||||
-rw-r--r-- | test/xi2/protocol-eventconvert.c | 27 | ||||
-rw-r--r-- | xkb/xkbActions.c | 7 |
24 files changed, 265 insertions, 169 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 74a78ecf2..053c76f22 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -651,7 +651,7 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to, DeviceChangedEvent *dc * Send an XI2 DeviceChangedEvent to all interested clients. */ void -XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChangedEvent *dce) +XISendDeviceChangedEvent(DeviceIntPtr device, DeviceChangedEvent *dce) { xXIDeviceChangedEvent *dcce; int rc; @@ -665,7 +665,7 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged /* we don't actually swap if there's a NullClient, swapping is done * later when event is delivered. */ - SendEventToAllWindows(master, XI_DeviceChangedMask, (xEvent*)dcce, 1); + SendEventToAllWindows(device, XI_DeviceChangedMask, (xEvent*)dcce, 1); free(dcce); } @@ -699,7 +699,8 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce) /* FIXME: the classes may have changed since we generated the event. */ DeepCopyDeviceClasses(slave, device, dce); - XISendDeviceChangedEvent(slave, device, dce); + dce->deviceid = device->id; + XISendDeviceChangedEvent(device, dce); } /** @@ -1102,6 +1103,8 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr { AxisInfoPtr ax; int *current_ax; + InternalEvent dce; + DeviceIntPtr master; if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes) return FALSE; @@ -1138,7 +1141,16 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr ax->scroll.type = type; ax->scroll.increment = increment; ax->scroll.flags = flags; - /* FIXME: generate DeviceChanged Events */ + + master = GetMaster(dev, MASTER_ATTACHED); + CreateClassesChangedEvent(&dce, master, dev, DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE); + XISendDeviceChangedEvent(dev, &dce.changed_event); + + /* if the current slave is us, update the master. If not, we'll update + * whenever the next slave switch happens anyway. CMDC sends the event + * for us */ + if (master && master->lastSlave == dev) + ChangeMasterDeviceClasses(master, &dce.changed_event); return TRUE; } diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index 9961d1b6f..5f543f620 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -41,6 +41,7 @@ #include "xserver-properties.h" #include "exevents.h" #include "xace.h" +#include "inpututils.h" #include "xiquerydevice.h" @@ -351,8 +352,7 @@ ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber, info->min.frac = 0; info->max.integral = v->axes[axisnumber].max_value; info->max.frac = 0; - info->value.integral = (int)v->axisVal[axisnumber]; - info->value.frac = (int)(v->axisVal[axisnumber] * (1 << 16) * (1 << 16)); + info->value = double_to_fp3232(v->axisVal[axisnumber]); info->resolution = v->axes[axisnumber].resolution; info->number = axisnumber; info->mode = valuator_get_mode(dev, axisnumber); @@ -402,8 +402,7 @@ ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo *info, int axisnumber) ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", axis->scroll.type); break; } - info->increment.integral = (int)axis->scroll.increment; - info->increment.frac = (unsigned int)(axis->scroll.increment * (1UL << 16) * (1UL << 16)); + info->increment = double_to_fp3232(axis->scroll.increment); info->sourceid = v->sourceid; info->flags = 0; diff --git a/dix/devices.c b/dix/devices.c index 64557aaf1..7c196e077 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2360,7 +2360,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/dix/eventconvert.c b/dix/eventconvert.c index 189cb85d0..c9da39685 100644 --- a/dix/eventconvert.c +++ b/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/dix/getevents.c b/dix/getevents.c index 7be39dc33..4845a106c 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -209,7 +209,7 @@ void CreateClassesChangedEvent(InternalEvent* event, DeviceIntPtr master, DeviceIntPtr slave, - int type) + int flags) { int i; DeviceChangedEvent *dce; @@ -218,13 +218,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) @@ -243,6 +242,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) @@ -673,7 +673,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); diff --git a/dix/inpututils.c b/dix/inpututils.c index 2915e6766..5797f9256 100644 --- a/dix/inpututils.c +++ b/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. */ @@ -670,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); } @@ -701,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) { @@ -715,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; @@ -732,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; } @@ -750,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; @@ -768,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; } @@ -779,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/dix/ptrveloc.c b/dix/ptrveloc.c index 53a0d0397..7b6f56049 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -649,13 +649,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; } diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index c14dd8241..6a1ce49e0 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -49,6 +49,7 @@ #include "eventstr.h" #include "xserver-properties.h" #include "inpututils.h" +#include "optionstr.h" #define AtomFromName(x) MakeAtom(x, strlen(x), 1) @@ -344,7 +345,7 @@ KdEnableInput (void) } static KdKeyboardDriver * -KdFindKeyboardDriver (char *name) +KdFindKeyboardDriver (const char *name) { KdKeyboardDriver *ret; @@ -361,7 +362,7 @@ KdFindKeyboardDriver (char *name) } static KdPointerDriver * -KdFindPointerDriver (char *name) +KdFindPointerDriver (const char *name) { KdPointerDriver *ret; @@ -1040,33 +1041,39 @@ KdRemovePointer (KdPointerInfo *pi) static Bool KdGetOptions (InputOption **options, char *string) { - InputOption *newopt = NULL, **tmpo = NULL; + InputOption *newopt = NULL; + char *key = NULL, + *value = NULL; int tam_key = 0; - newopt = calloc(1, sizeof (InputOption)); - if (!newopt) - return FALSE; - - for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next) - ; /* Hello, I'm here */ - *tmpo = newopt; - if (strchr(string, '=')) { tam_key = (strchr(string, '=') - string); - newopt->key = (char *)malloc(tam_key); - strncpy(newopt->key, string, tam_key); - newopt->key[tam_key] = '\0'; - newopt->value = strdup(strchr(string, '=') + 1); + key = malloc(tam_key + 1); + if (!key) + goto out; + + strncpy(key, string, tam_key); + key[tam_key] = '\0'; + value = strdup(strchr(string, '=') + 1); + if (!value) + goto out; } else { - newopt->key = strdup(string); - newopt->value = NULL; + key = strdup(string); + value = NULL; } - newopt->next = NULL; - return TRUE; + newopt = input_option_new(*options, key, value); + if (newopt) + *options = newopt; + +out: + free(key); + free(value); + + return (newopt != NULL); } static void @@ -1074,23 +1081,26 @@ KdParseKbdOptions (KdKeyboardInfo *ki) { InputOption *option = NULL; - for (option = ki->options; option; option = option->next) + nt_list_for_each_entry(option, ki->options, list.next) { - if (strcasecmp(option->key, "XkbRules") == 0) - ki->xkbRules = option->value; - else if (strcasecmp(option->key, "XkbModel") == 0) - ki->xkbModel = option->value; - else if (strcasecmp(option->key, "XkbLayout") == 0) - ki->xkbLayout = option->value; - else if (strcasecmp(option->key, "XkbVariant") == 0) - ki->xkbVariant = option->value; - else if (strcasecmp(option->key, "XkbOptions") == 0) - ki->xkbOptions = option->value; - else if (!strcasecmp (option->key, "device")) - ki->path = strdup(option->value); + const char *key = input_option_get_key(option); + const char *value = input_option_get_value(option); + + if (strcasecmp(key, "XkbRules") == 0) + ki->xkbRules = strdup(value); + else if (strcasecmp(key, "XkbModel") == 0) + ki->xkbModel = strdup(value); + else if (strcasecmp(key, "XkbLayout") == 0) + ki->xkbLayout = strdup(value); + else if (strcasecmp(key, "XkbVariant") == 0) + ki->xkbVariant = strdup(value); + else if (strcasecmp(key, "XkbOptions") == 0) + ki->xkbOptions = strdup(value); + else if (!strcasecmp (key, "device")) + ki->path = strdup(value); else ErrorF("Kbd option key (%s) of value (%s) not assigned!\n", - option->key, option->value); + key, value); } } @@ -1171,23 +1181,26 @@ KdParsePointerOptions (KdPointerInfo *pi) { InputOption *option = NULL; - for (option = pi->options; option; option = option->next) + nt_list_for_each_entry(option, pi->options, list.next) { - if (!strcmp (option->key, "emulatemiddle")) + const char *key = input_option_get_key(option); + const char *value = input_option_get_value(option); + + if (!strcmp (key, "emulatemiddle")) pi->emulateMiddleButton = TRUE; - else if (!strcmp (option->key, "noemulatemiddle")) + else if (!strcmp (key, "noemulatemiddle")) pi->emulateMiddleButton = FALSE; - else if (!strcmp (option->key, "transformcoord")) + else if (!strcmp (key, "transformcoord")) pi->transformCoordinates = TRUE; - else if (!strcmp (option->key, "rawcoord")) + else if (!strcmp (key, "rawcoord")) pi->transformCoordinates = FALSE; - else if (!strcasecmp (option->key, "device")) - pi->path = strdup(option->value); - else if (!strcasecmp (option->key, "protocol")) - pi->protocol = strdup(option->value); + else if (!strcasecmp (key, "device")) + pi->path = strdup(value); + else if (!strcasecmp (key, "protocol")) + pi->protocol = strdup(value); else ErrorF("Pointer option key (%s) of value (%s) not assigned!\n", - option->key, option->value); + key, value); } } @@ -2216,14 +2229,17 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, KdPointerInfo *pi = NULL; KdKeyboardInfo *ki = NULL; - for (option = options; option; option = option->next) { - if (strcmp(option->key, "type") == 0) { - if (strcmp(option->value, "pointer") == 0) { + nt_list_for_each_entry(option, options, list.next) { + const char *key = input_option_get_key(option); + const char *value = input_option_get_value(option); + + if (strcmp(key, "type") == 0) { + if (strcmp(value, "pointer") == 0) { pi = KdNewPointer(); if (!pi) return BadAlloc; } - else if (strcmp(option->value, "keyboard") == 0) { + else if (strcmp(value, "keyboard") == 0) { ki = KdNewKeyboard(); if (!ki) return BadAlloc; @@ -2234,16 +2250,16 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, } } #ifdef CONFIG_HAL - else if (strcmp(option->key, "_source") == 0 && - strcmp(option->value, "server/hal") == 0) + else if (strcmp(key, "_source") == 0 && + strcmp(value, "server/hal") == 0) { ErrorF("Ignoring device from HAL.\n"); return BadValue; } #endif #ifdef CONFIG_UDEV - else if (strcmp(option->key, "_source") == 0 && - strcmp(option->value, "server/udev") == 0) + else if (strcmp(key, "_source") == 0 && + strcmp(value, "server/udev") == 0) { ErrorF("Ignoring device from udev.\n"); return BadValue; @@ -2258,16 +2274,19 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, /* FIXME: change this code below to use KdParseKbdOptions and * KdParsePointerOptions */ - for (option = options; option; option = option->next) { - if (strcmp(option->key, "device") == 0) { - if (pi && option->value) - pi->path = strdup(option->value); - else if (ki && option->value) - ki->path = strdup(option->value); + nt_list_for_each_entry(option, options, list.next) { + const char *key = input_option_get_key(option); + const char *value = input_option_get_value(option); + + if (strcmp(key, "device") == 0) { + if (pi && value) + pi->path = strdup(value); + else if (ki && value) + ki->path = strdup(value); } - else if (strcmp(option->key, "driver") == 0) { + else if (strcmp(key, "driver") == 0) { if (pi) { - pi->driver = KdFindPointerDriver(option->value); + pi->driver = KdFindPointerDriver(value); if (!pi->driver) { ErrorF("couldn't find driver!\n"); KdFreePointer(pi); @@ -2276,7 +2295,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, pi->options = options; } else if (ki) { - ki->driver = KdFindKeyboardDriver(option->value); + ki->driver = KdFindKeyboardDriver(value); if (!ki->driver) { ErrorF("couldn't find driver!\n"); KdFreeKeyboard(ki); diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 5c46152b2..cb4be4210 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1194,8 +1194,12 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) if (Pointer) foundPointer = configInput(Pointer, confInput, from); if (foundPointer) { - Pointer->options = xf86addNewOption(Pointer->options, - xnfstrdup("CorePointer"), "on"); + Pointer->options = xf86AddNewOption(Pointer->options, + "CorePointer", "on"); + Pointer->options = xf86AddNewOption(Pointer->options, + "driver", confInput->inp_driver); + Pointer->options = xf86AddNewOption(Pointer->options, + "identifier", confInput->inp_identifier); servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer); } } @@ -1284,8 +1288,12 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) if (Keyboard) foundKeyboard = configInput(Keyboard, confInput, from); if (foundKeyboard) { - Keyboard->options = xf86addNewOption(Keyboard->options, - xnfstrdup("CoreKeyboard"), "on"); + Keyboard->options = xf86AddNewOption(Keyboard->options, + "CoreKeyboard", "on"); + Keyboard->options = xf86AddNewOption(Keyboard->options, + "driver", confInput->inp_driver); + Keyboard->options = xf86AddNewOption(Keyboard->options, + "identifier", confInput->inp_identifier); servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard); } } diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 74e0bc220..a0fdf29ad 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -811,21 +811,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) NULL); } -static InputInfoPtr -duplicateDevice(InputInfoPtr pInfo) -{ - InputInfoPtr dup = calloc(1, sizeof(InputInfoRec)); - if (dup) { - dup->name = strdup(pInfo->name); - dup->driver = strdup(pInfo->driver); - dup->options = xf86OptionListDuplicate(pInfo->options); - /* type_name is a const string */ - dup->type_name = pInfo->type_name; - dup->fd = -1; - } - return dup; -} - /** * Initialize all supported input devices present and referenced in the * xorg.conf. @@ -842,20 +827,8 @@ InitInput(int argc, char **argv) /* Initialize all configured input devices */ for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) { - InputInfoPtr dup; - /* Replace obsolete keyboard driver with kbd */ - if (!xf86NameCmp((*pInfo)->driver, "keyboard")) { - strcpy((*pInfo)->driver, "kbd"); - } - - /* Data passed into xf86NewInputDevice will be freed on shutdown. - * Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any - * xorg.conf input devices in the second generation - */ - dup = duplicateDevice(*pInfo); - /* If one fails, the others will too */ - if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc) + if (NewInputDeviceRequest((*pInfo)->options, NULL, &dev) == BadAlloc) break; } diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c index 73b6573f1..9c528782f 100644 --- a/hw/xfree86/common/xf86Option.c +++ b/hw/xfree86/common/xf86Option.c @@ -44,6 +44,7 @@ #include "xf86Xinput.h" #include "xf86Optrec.h" #include "xf86Parser.h" +#include "optionstr.h" static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p, Bool markUsed); @@ -298,7 +299,7 @@ xf86CheckPercentOption(XF86OptionPtr optlist, const char *name, double deflt) return LookupPercentOption(optlist, name, deflt, FALSE); } /* - * addNewOption() has the required property of replacing the option value + * xf86AddNewOption() has the required property of replacing the option value * if the option is already present. */ XF86OptionPtr diff --git a/hw/xfree86/common/xf86Optionstr.h b/hw/xfree86/common/xf86Optionstr.h index 8cc82d34c..fc9385617 100644 --- a/hw/xfree86/common/xf86Optionstr.h +++ b/hw/xfree86/common/xf86Optionstr.h @@ -24,16 +24,7 @@ #ifndef XF86OPTIONSTR_H #define XF86OPTIONSTR_H - -/* - * all records that need to be linked lists should contain a GenericList as - * their first field. - */ -typedef struct generic_list_rec -{ - void *next; -} -GenericListRec, *GenericListPtr, *glp; +#include "list.h" /* * All options are stored using this data type. @@ -48,6 +39,6 @@ typedef struct _XF86OptionRec } XF86OptionRec; -typedef struct _XF86OptionRec *XF86OptionPtr; +typedef struct _InputOption *XF86OptionPtr; #endif diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index ea1f92761..425b35957 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -68,6 +68,7 @@ #include "exglobals.h" #include "eventstr.h" #include "inpututils.h" +#include "optionstr.h" #include <string.h> /* InputClassMatches */ #ifdef HAVE_FNMATCH_H @@ -908,7 +909,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, if (!pInfo) return BadAlloc; - nt_list_for_each_entry(option, options, next) { + nt_list_for_each_entry(option, options, list.next) { if (strcasecmp(input_option_get_key(option), "driver") == 0) { if (pInfo->driver) { rval = BadRequest; @@ -946,7 +947,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, } } - nt_list_for_each_entry(option, options, next) { + nt_list_for_each_entry(option, options, list.next) { /* Copy option key/value strings from the provided list */ pInfo->options = xf86AddNewOption(pInfo->options, input_option_get_key(option), diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml index a4baad557..0d5e952a2 100644 --- a/hw/xfree86/doc/ddxDesign.xml +++ b/hw/xfree86/doc/ddxDesign.xml @@ -189,7 +189,7 @@ following changes: <varlistentry><term><emphasis>Keyboard</emphasis></term> <listitem><literallayout> &k.identifier; "Implicit Core Keyboard" - &k.driver; "keyboard" + &k.driver; "kbd" </literallayout></listitem></varlistentry> <varlistentry><term><emphasis>Pointer</emphasis></term> <listitem><literallayout> @@ -206,7 +206,7 @@ following changes: is no &k.serverlayout; section, if the <option>-screen</option> command line options is used, or if the &k.serverlayout; section doesn't reference any &k.inputdevice; sections. In this case, the first - sections with drivers "keyboard" and "mouse" are used as the core + sections with drivers "kbd" and "mouse" are used as the core keyboard and pointer respectively. </para> </sect2> diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c index 7a0794bb0..f0a61707b 100644 --- a/hw/xfree86/parser/Flags.c +++ b/hw/xfree86/parser/Flags.c @@ -63,6 +63,7 @@ #include "Configint.h" #include <X11/Xfuncproto.h> #include "Xprintf.h" +#include "optionstr.h" extern LexRec val; @@ -203,7 +204,7 @@ addNewOption2 (XF86OptionPtr head, char *name, char *val, int used) free(new->opt_val); } else - new = calloc (1, sizeof (XF86OptionRec)); + new = calloc (1, sizeof (*new)); new->opt_name = name; new->opt_val = val; new->opt_used = used; @@ -284,7 +285,7 @@ xf86newOption(char *name, char *value) { XF86OptionPtr opt; - opt = calloc(1, sizeof (XF86OptionRec)); + opt = calloc(1, sizeof (*opt)); if (!opt) return NULL; diff --git a/hw/xfree86/parser/Layout.c b/hw/xfree86/parser/Layout.c index e1f770bc3..4487b0df6 100644 --- a/hw/xfree86/parser/Layout.c +++ b/hw/xfree86/parser/Layout.c @@ -63,7 +63,7 @@ #include "xf86tokens.h" #include "Configint.h" #include <string.h> - +#include "optionstr.h" /* Needed for auto server layout */ extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt); diff --git a/include/eventstr.h b/include/eventstr.h index 2de077fd2..4d836fb14 100644 --- a/include/eventstr.h +++ b/include/eventstr.h @@ -153,6 +153,7 @@ struct _DeviceChangedEvent uint32_t resolution; /**< Resolution counts/m */ uint8_t mode; /**< Relative or Absolute */ Atom name; /**< Axis name */ + ScrollInfo scroll; /**< Smooth scrolling info */ } valuators[MAX_VALUATORS]; struct { diff --git a/include/exevents.h b/include/exevents.h index 4fe6c61a9..720fb2e5a 100644 --- a/include/exevents.h +++ b/include/exevents.h @@ -322,8 +322,7 @@ extern int XIShouldNotify(ClientPtr client, DeviceIntPtr dev); extern void -XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, - DeviceChangedEvent *dce); +XISendDeviceChangedEvent(DeviceIntPtr device, DeviceChangedEvent *dce); extern int XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client, diff --git a/include/input.h b/include/input.h index a1930bb66..4eee47ce4 100644 --- a/include/input.h +++ b/include/input.h @@ -427,7 +427,8 @@ extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events); extern void CreateClassesChangedEvent(InternalEvent *event, DeviceIntPtr master, DeviceIntPtr slave, - int type); + int flags); + extern InternalEvent * UpdateFromMaster( InternalEvent *events, DeviceIntPtr pDev, diff --git a/include/inputstr.h b/include/inputstr.h index 9d4108ef5..7a1554075 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -621,11 +621,4 @@ static inline WindowPtr DeepestSpriteWin(SpritePtr sprite) return sprite->spriteTrace[sprite->spriteTraceGood - 1]; } -struct _InputOption { - char *key; - char *value; - struct _InputOption *next; -}; - - #endif /* INPUTSTRUCT_H */ diff --git a/include/list.h b/include/list.h index 7825dce52..4706e178b 100644 --- a/include/list.h +++ b/include/list.h @@ -438,4 +438,16 @@ list_is_empty(struct list *head) nt_list_init(__e, _member); \ } while(0) +/** + * DO NOT USE THIS. + * This is a remainder of the xfree86 DDX attempt of having a set of generic + * list functions. Unfortunately, the xf86OptionRec uses it and we can't + * easily get rid of it. Do not use for new code. + */ +typedef struct generic_list_rec +{ + void *next; +} +GenericListRec, *GenericListPtr, *glp; + #endif diff --git a/include/optionstr.h b/include/optionstr.h new file mode 100644 index 000000000..a71d245fa --- /dev/null +++ b/include/optionstr.h @@ -0,0 +1,14 @@ +#ifndef OPTIONSTR_H_ +#define OPTIONSTR_H_ +#include "list.h" + + +struct _InputOption { + GenericListRec list; + char *opt_name; + char *opt_val; + int opt_used; + char *opt_comment; +}; + +#endif /* INPUTSTRUCT_H */ diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index bfa23b51f..ba2d96ad1 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -30,6 +30,7 @@ #include "eventstr.h" #include "eventconvert.h" #include "exevents.h" +#include "inpututils.h" #include <X11/extensions/XI2proto.h> static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, @@ -104,8 +105,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, value = (FP3232*)(((unsigned char*)&out[1]) + out->valuators_len * 4); value += nvals; - vi.integral = trunc(in->valuators.data[i]); - vi.frac = in->valuators.data[i] - vi.integral; + vi = double_to_fp3232(in->valuators.data[i]); vo.integral = value->integral; vo.frac = value->frac; @@ -120,8 +120,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, raw_value = value + bits_set; - vi.integral = trunc(in->valuators.data_raw[i]); - vi.frac = in->valuators.data_raw[i] - vi.integral; + vi = double_to_fp3232(in->valuators.data_raw[i]); vo.integral = raw_value->integral; vo.frac = raw_value->frac; @@ -748,6 +747,26 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, } break; + case XIScrollClass: + { + xXIScrollInfo *s = (xXIScrollInfo*)any; + assert(s->length == + bytes_to_int32(sizeof(xXIScrollInfo))); + + assert(s->sourceid == in->sourceid); + assert(s->number < in->num_valuators); + switch(s->type) + { + case XIScrollTypeVertical: + assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_VERTICAL); + break; + case XIScrollTypeHorizontal: + assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_HORIZONTAL); + break; + } + if (s->flags & XIScrollFlagPreferred) + assert(in->valuators[s->number].scroll.flags & SCROLL_FLAG_PREFERRED); + } default: printf("Invalid class type.\n\n"); assert(1); diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 4b5405ab0..000002a45 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -344,15 +344,18 @@ _XkbFilterLockState( XkbSrvInfoPtr xkbi, filter->keycode = keycode; filter->active = 1; filter->filterOthers = 0; - filter->priv = 0; + filter->priv = xkbi->state.locked_mods&pAction->mods.mask; filter->filter = _XkbFilterLockState; filter->upAction = *pAction; - xkbi->state.locked_mods^= pAction->mods.mask; + if (!(filter->upAction.mods.flags&XkbSA_LockNoLock)) + xkbi->state.locked_mods|= pAction->mods.mask; xkbi->setMods = pAction->mods.mask; } else if (filter->keycode==keycode) { filter->active = 0; xkbi->clearMods = filter->upAction.mods.mask; + if (!(filter->upAction.mods.flags&XkbSA_LockNoUnlock)) + xkbi->state.locked_mods&= ~filter->priv; } return 1; } |