aboutsummaryrefslogtreecommitdiff
path: root/xorg-server
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server')
-rw-r--r--xorg-server/Xi/exevents.c20
-rw-r--r--xorg-server/Xi/xiquerydevice.c7
-rw-r--r--xorg-server/composite/compalloc.c11
-rw-r--r--xorg-server/configure.ac6
-rw-r--r--xorg-server/dix/devices.c2
-rw-r--r--xorg-server/dix/eventconvert.c67
-rw-r--r--xorg-server/dix/getevents.c42
-rw-r--r--xorg-server/dix/inpututils.c70
-rw-r--r--xorg-server/dix/ptrveloc.c4
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c139
-rw-r--r--xorg-server/hw/vfb/InitOutput.c2
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c16
-rw-r--r--xorg-server/hw/xfree86/common/xf86Events.c9
-rw-r--r--xorg-server/hw/xfree86/common/xf86Helper.c6
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c29
-rw-r--r--xorg-server/hw/xfree86/common/xf86Option.c3
-rw-r--r--xorg-server/hw/xfree86/common/xf86Optionstr.h13
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c5
-rw-r--r--xorg-server/hw/xfree86/doc/ddxDesign.xml4
-rw-r--r--xorg-server/hw/xfree86/loader/loadmod.c41
-rw-r--r--xorg-server/hw/xfree86/man/xorg.conf.man4
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.c66
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_init.c14
-rw-r--r--xorg-server/hw/xfree86/parser/Flags.c1009
-rw-r--r--xorg-server/hw/xfree86/parser/Layout.c1116
-rw-r--r--xorg-server/hw/xnest/Events.c2
-rw-r--r--xorg-server/hw/xnest/Keyboard.c519
-rw-r--r--xorg-server/hw/xquartz/darwin.c2
-rw-r--r--xorg-server/hw/xquartz/xpr/appledri.c137
-rw-r--r--xorg-server/hw/xquartz/xpr/appledristr.h298
-rw-r--r--xorg-server/hw/xwin/man/XWinrc.man10
-rw-r--r--xorg-server/include/eventstr.h1
-rw-r--r--xorg-server/include/exevents.h3
-rw-r--r--xorg-server/include/input.h7
-rw-r--r--xorg-server/include/inputstr.h7
-rw-r--r--xorg-server/include/list.h12
-rw-r--r--xorg-server/include/optionstr.h14
-rw-r--r--xorg-server/man/Xserver.man6
-rw-r--r--xorg-server/mi/mieq.c188
-rw-r--r--xorg-server/randr/rrproperty.c19
-rw-r--r--xorg-server/render/mipict.c61
-rw-r--r--xorg-server/render/mipict.h350
-rw-r--r--xorg-server/render/picture.c44
-rw-r--r--xorg-server/render/picturestr.h21
-rw-r--r--xorg-server/test/input.c99
-rw-r--r--xorg-server/test/xi2/protocol-eventconvert.c27
-rw-r--r--xorg-server/xkb/xkbActions.c7
47 files changed, 2573 insertions, 1966 deletions
diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c
index ea393d224..1fe284dfc 100644
--- a/xorg-server/Xi/exevents.c
+++ b/xorg-server/Xi/exevents.c
@@ -653,7 +653,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;
@@ -667,7 +667,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);
}
@@ -701,7 +701,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);
}
/**
@@ -1106,6 +1107,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;
@@ -1142,7 +1145,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/xorg-server/Xi/xiquerydevice.c b/xorg-server/Xi/xiquerydevice.c
index 9961d1b6f..5f543f620 100644
--- a/xorg-server/Xi/xiquerydevice.c
+++ b/xorg-server/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/xorg-server/composite/compalloc.c b/xorg-server/composite/compalloc.c
index c4430af43..5b53e6931 100644
--- a/xorg-server/composite/compalloc.c
+++ b/xorg-server/composite/compalloc.c
@@ -196,11 +196,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
anyMarked = compMarkWindows (pWin, &pLayerWin);
- /* Make sure our borderClip is correct for ValidateTree */
RegionNull(&cw->borderClip);
- RegionCopy(&cw->borderClip, &pWin->borderClip);
- cw->borderClipX = pWin->drawable.x;
- cw->borderClipY = pWin->drawable.y;
cw->update = CompositeRedirectAutomatic;
cw->clients = 0;
cw->oldx = COMP_ORIGIN_INVALID;
@@ -658,6 +654,13 @@ compAllocPixmap (WindowPtr pWin)
DamageRegister (&pWin->drawable, cw->damage);
cw->damageRegistered = TRUE;
}
+
+ /* Make sure our borderClip is up to date */
+ RegionUninit(&cw->borderClip);
+ RegionCopy(&cw->borderClip, &pWin->borderClip);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+
return TRUE;
}
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index 4bfa82c24..63d59f92d 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -87,6 +87,12 @@ XORG_PROG_RAWCPP
# easier overrides at build time.
XSERVER_CFLAGS='$(CWARNFLAGS)'
+dnl Explicitly add -fno-strict-aliasing since this option should disappear
+dnl from util-macros CWARNFLAGS
+if test "x$GCC" = xyes ; then
+ XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
+fi
+
dnl Check for dtrace program (needed to build Xserver dtrace probes)
dnl Also checks for <sys/sdt.h>, since some Linux distros have an
dnl ISDN trace program named dtrace
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;
}
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
index 3d87996be..27e33043f 100644
--- a/xorg-server/hw/kdrive/src/kinput.c
+++ b/xorg-server/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)
@@ -364,7 +365,7 @@ KdEnableInput (void)
}
static KdKeyboardDriver *
-KdFindKeyboardDriver (char *name)
+KdFindKeyboardDriver (const char *name)
{
KdKeyboardDriver *ret;
@@ -381,7 +382,7 @@ KdFindKeyboardDriver (char *name)
}
static KdPointerDriver *
-KdFindPointerDriver (char *name)
+KdFindPointerDriver (const char *name)
{
KdPointerDriver *ret;
@@ -1063,33 +1064,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
@@ -1097,23 +1104,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);
}
}
@@ -1194,23 +1204,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);
}
}
@@ -2241,14 +2254,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;
@@ -2259,16 +2275,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;
@@ -2283,16 +2299,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);
@@ -2301,7 +2320,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/xorg-server/hw/vfb/InitOutput.c b/xorg-server/hw/vfb/InitOutput.c
index 0e701e518..121854781 100644
--- a/xorg-server/hw/vfb/InitOutput.c
+++ b/xorg-server/hw/vfb/InitOutput.c
@@ -863,6 +863,8 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
(1 << DirectColor)),
10, TrueColor, 0x3ff00000, 0x000ffc00, 0x000003ff);
break;
+ default:
+ return FALSE;
}
miSetPixmapDepths ();
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index 5c46152b2..cb4be4210 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c
index c4a4db9be..41ffabde3 100644
--- a/xorg-server/hw/xfree86/common/xf86Events.c
+++ b/xorg-server/hw/xfree86/common/xf86Events.c
@@ -601,16 +601,15 @@ xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
InputHandlerProc
xf86SetConsoleHandler(InputHandlerProc proc, pointer data)
{
- static InputHandlerProc handler = NULL;
- InputHandlerProc old_handler = handler;
+ static IHPtr handler = NULL;
+ IHPtr old_handler = handler;
if (old_handler)
xf86RemoveGeneralHandler(old_handler);
- xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
- handler = proc;
+ handler = xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
- return old_handler;
+ return (old_handler) ? old_handler->ihproc : NULL;
}
static void
diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c
index cf577522a..d99522cf6 100644
--- a/xorg-server/hw/xfree86/common/xf86Helper.c
+++ b/xorg-server/hw/xfree86/common/xf86Helper.c
@@ -1553,13 +1553,7 @@ xf86LoadOneModule(char *name, pointer opt)
void
xf86UnloadSubModule(pointer mod)
{
- /*
- * This is disabled for now. The loader isn't smart enough yet to undo
- * relocations.
- */
-#if 0
UnloadSubModule(mod);
-#endif
}
Bool
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index 74e0bc220..a0fdf29ad 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c
index 73b6573f1..9c528782f 100644
--- a/xorg-server/hw/xfree86/common/xf86Option.c
+++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86Optionstr.h b/xorg-server/hw/xfree86/common/xf86Optionstr.h
index 8cc82d34c..fc9385617 100644
--- a/xorg-server/hw/xfree86/common/xf86Optionstr.h
+++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index ea1f92761..425b35957 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/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/xorg-server/hw/xfree86/doc/ddxDesign.xml b/xorg-server/hw/xfree86/doc/ddxDesign.xml
index a4baad557..0d5e952a2 100644
--- a/xorg-server/hw/xfree86/doc/ddxDesign.xml
+++ b/xorg-server/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/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c
index 9f820993a..a21f43d63 100644
--- a/xorg-server/hw/xfree86/loader/loadmod.c
+++ b/xorg-server/hw/xfree86/loader/loadmod.c
@@ -94,6 +94,8 @@ const ModuleVersions LoaderVersionInfo = {
ABI_FONT_VERSION
};
+static int ModuleDuplicated[] = {};
+
static void
FreeStringList(char **paths)
{
@@ -785,7 +787,6 @@ ModuleDescPtr
DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
{
ModuleDescPtr ret;
- int errmaj, errmin;
if (!mod)
return NULL;
@@ -794,14 +795,11 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
if (ret == NULL)
return NULL;
- if (!(ret->handle = LoaderOpen(mod->path, &errmaj, &errmin))) {
- free(ret);
- return NULL;
- }
+ ret->handle = mod->handle;
ret->SetupProc = mod->SetupProc;
ret->TearDownProc = mod->TearDownProc;
- ret->TearDownData = NULL;
+ ret->TearDownData = ModuleDuplicated;
ret->child = DuplicateModule(mod->child, ret);
ret->sib = DuplicateModule(mod->sib, parent);
ret->parent = parent;
@@ -1072,11 +1070,16 @@ UnloadModuleOrDriver(ModuleDescPtr mod)
if (mod == NULL || mod->name == NULL)
return;
- xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name);
+ if (mod->parent)
+ xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name);
+ else
+ xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name);
- if ((mod->TearDownProc) && (mod->TearDownData))
- mod->TearDownProc(mod->TearDownData);
- LoaderUnload(mod->name, mod->handle);
+ if (mod->TearDownData != ModuleDuplicated) {
+ if ((mod->TearDownProc) && (mod->TearDownData))
+ mod->TearDownProc(mod->TearDownData);
+ LoaderUnload(mod->name, mod->handle);
+ }
if (mod->child)
UnloadModuleOrDriver(mod->child);
@@ -1092,23 +1095,8 @@ UnloadSubModule(pointer _mod)
{
ModuleDescPtr mod = (ModuleDescPtr)_mod;
- if (mod == NULL || mod->name == NULL)
- return;
-
- xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name);
-
- if ((mod->TearDownProc) && (mod->TearDownData))
- mod->TearDownProc(mod->TearDownData);
- LoaderUnload(mod->name, mod->handle);
-
RemoveChild(mod);
-
- if (mod->child)
- UnloadModuleOrDriver(mod->child);
-
- free(mod->path);
- free(mod->name);
- free(mod);
+ UnloadModuleOrDriver(mod);
}
static void
@@ -1135,6 +1123,7 @@ RemoveChild(ModuleDescPtr child)
}
if (mdp == child)
prevsib->sib = child->sib;
+ child->sib = NULL;
return;
}
diff --git a/xorg-server/hw/xfree86/man/xorg.conf.man b/xorg-server/hw/xfree86/man/xorg.conf.man
index 7f98851b6..996798f1c 100644
--- a/xorg-server/hw/xfree86/man/xorg.conf.man
+++ b/xorg-server/hw/xfree86/man/xorg.conf.man
@@ -379,7 +379,9 @@ is a number used to order the fontfile FPEs. Examples:
.I misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc
.fi
.PP
-.RE .RE .RE
+.RE
+.RE
+.RE
.PP
.RS 7
Font server identifiers:
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c
index cbe0b5cf6..aac33d32f 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.c
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c
@@ -1915,19 +1915,25 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
break;
}
- if (scrn->modes != NULL) {
- /* For some reason, scrn->modes is circular, unlike the other mode
- * lists. How great is that?
- */
- for (last = scrn->modes; last && last->next; last = last->next)
- ;
- last->next = scrn->modes;
- scrn->modes->prev = last;
- if (mode) {
- while (scrn->modes != mode)
- scrn->modes = scrn->modes->next;
- }
+ if (!scrn->modes) {
+ scrn->modes = xf86ModesAdd(scrn->modes,
+ xf86CVTMode(scrn->display->virtualX,
+ scrn->display->virtualY,
+ 60, 0, 0));
+ }
+
+ /* For some reason, scrn->modes is circular, unlike the other mode
+ * lists. How great is that?
+ */
+ for (last = scrn->modes; last && last->next; last = last->next)
+ ;
+ last->next = scrn->modes;
+ scrn->modes->prev = last;
+ if (mode) {
+ while (scrn->modes != mode)
+ scrn->modes = scrn->modes->next;
}
+
scrn->currentMode = scrn->modes;
#ifdef XFreeXDGA
if (scrn->pScreen)
@@ -2060,13 +2066,28 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
if (o == p)
continue;
- for (mode = output->probed_modes; mode; mode = mode->next) {
- Rotation r = output->initial_rotation;
- if (xf86ModeWidth(mode, r) == pref_width &&
- xf86ModeHeight(mode, r) == pref_height) {
+ /*
+ * First see if the preferred mode matches on the next
+ * output as well. This catches the common case of identical
+ * monitors and makes sure they all have the same timings
+ * and refresh. If that fails, we fall back to trying to
+ * match just width & height.
+ */
+ mode = xf86OutputHasPreferredMode(output, pref_width,
+ pref_height);
+ if (mode && xf86ModesEqual(mode, preferred[p])) {
preferred[o] = mode;
match = TRUE;
- }
+ } else {
+ for (mode = output->probed_modes; mode;
+ mode = mode->next) {
+ Rotation r = output->initial_rotation;
+ if (xf86ModeWidth(mode, r) == pref_width &&
+ xf86ModeHeight(mode, r) == pref_height) {
+ preferred[o] = mode;
+ match = TRUE;
+ }
+ }
}
all_match &= match;
@@ -2514,16 +2535,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
width, height);
}
- if (have_outputs) {
- /* Mirror output modes to scrn mode list */
- xf86SetScrnInfoModes (scrn);
- } else {
- /* Clear any existing modes from scrn->modes */
- while (scrn->modes != NULL)
- xf86DeleteMode(&scrn->modes, scrn->modes);
- scrn->modes = xf86ModesAdd(scrn->modes,
- xf86CVTMode(width, height, 60, 0, 0));
- }
+ xf86SetScrnInfoModes (scrn);
success = TRUE;
bailout:
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
index 9c9174034..f18271f38 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
@@ -45,15 +45,12 @@ static char vtname[11];
static struct termios tty_attr; /* tty state to restore */
static int tty_mode; /* kbd mode to restore */
-static void *console_handler;
-
static void
drain_console(int fd, void *closure)
{
errno = 0;
if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) {
- xf86RemoveGeneralHandler(console_handler);
- console_handler = NULL;
+ xf86SetConsoleHandler(NULL, NULL);
}
}
@@ -257,10 +254,11 @@ xf86CloseConsole(void)
return;
}
- if (console_handler) {
- xf86RemoveGeneralHandler(console_handler);
- console_handler = NULL;
- };
+ /*
+ * unregister the drain_console handler
+ * - what to do if someone else changed it in the meantime?
+ */
+ xf86SetConsoleHandler(NULL, NULL);
/* Back to text mode ... */
SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT));
diff --git a/xorg-server/hw/xfree86/parser/Flags.c b/xorg-server/hw/xfree86/parser/Flags.c
index 17e079a8c..f0a61707b 100644
--- a/xorg-server/hw/xfree86/parser/Flags.c
+++ b/xorg-server/hw/xfree86/parser/Flags.c
@@ -1,504 +1,505 @@
-/*
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-#include <X11/Xfuncproto.h>
-#include "Xprintf.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec ServerFlagsTab[] =
-{
- {ENDSECTION, "endsection"},
- {NOTRAPSIGNALS, "notrapsignals"},
- {DONTZAP, "dontzap"},
- {DONTZOOM, "dontzoom"},
- {DISABLEVIDMODE, "disablevidmodeextension"},
- {ALLOWNONLOCAL, "allownonlocalxvidtune"},
- {DISABLEMODINDEV, "disablemodindev"},
- {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"},
- {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"},
- {OPTION, "option"},
- {BLANKTIME, "blanktime"},
- {STANDBYTIME, "standbytime"},
- {SUSPENDTIME, "suspendtime"},
- {OFFTIME, "offtime"},
- {DEFAULTLAYOUT, "defaultserverlayout"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeFlags
-
-XF86ConfFlagsPtr
-xf86parseFlagsSection (void)
-{
- int token;
- parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
-
- while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION)
- {
- int hasvalue = FALSE;
- int strvalue = FALSE;
- int tokentype;
- switch (token)
- {
- case COMMENT:
- ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
- break;
- /*
- * these old keywords are turned into standard generic options.
- * we fall through here on purpose
- */
- case DEFAULTLAYOUT:
- strvalue = TRUE;
- case BLANKTIME:
- case STANDBYTIME:
- case SUSPENDTIME:
- case OFFTIME:
- hasvalue = TRUE;
- case NOTRAPSIGNALS:
- case DONTZAP:
- case DONTZOOM:
- case DISABLEVIDMODE:
- case ALLOWNONLOCAL:
- case DISABLEMODINDEV:
- case MODINDEVALLOWNONLOCAL:
- case ALLOWMOUSEOPENFAIL:
- {
- int i = 0;
- while (ServerFlagsTab[i].token != -1)
- {
- char *tmp;
-
- if (ServerFlagsTab[i].token == token)
- {
- char *valstr = NULL;
- tmp = strdup (ServerFlagsTab[i].name);
- if (hasvalue)
- {
- tokentype = xf86getSubToken(&(ptr->flg_comment));
- if (strvalue) {
- if (tokentype != STRING)
- Error (QUOTE_MSG, tmp);
- valstr = val.str;
- } else {
- if (tokentype != NUMBER)
- Error (NUMBER_MSG, tmp);
- if (asprintf(&valstr, "%d", val.num) == -1)
- valstr = NULL;
- }
- }
- ptr->flg_option_lst = xf86addNewOption
- (ptr->flg_option_lst, tmp, valstr);
- }
- i++;
- }
- }
- break;
- case OPTION:
- ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst);
- break;
-
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
-#ifdef DEBUG
- printf ("Flags section parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags)
-{
- XF86OptionPtr p;
-
- if ((!flags) || (!flags->flg_option_lst))
- return;
- p = flags->flg_option_lst;
- fprintf (f, "Section \"ServerFlags\"\n");
- if (flags->flg_comment)
- fprintf (f, "%s", flags->flg_comment);
- xf86printOptionList(f, p, 1);
- fprintf (f, "EndSection\n\n");
-}
-
-static XF86OptionPtr
-addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
-{
- XF86OptionPtr new, old = NULL;
-
- /* Don't allow duplicates, free old strings */
- if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
- new = old;
- free(new->opt_name);
- free(new->opt_val);
- }
- else
- new = calloc (1, sizeof (XF86OptionRec));
- new->opt_name = name;
- new->opt_val = val;
- new->opt_used = used;
-
- if (old)
- return head;
- return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
-}
-
-XF86OptionPtr
-xf86addNewOption (XF86OptionPtr head, char *name, char *val)
-{
- return addNewOption2(head, name, val, 0);
-}
-
-void
-xf86freeFlags (XF86ConfFlagsPtr flags)
-{
- if (flags == NULL)
- return;
- xf86optionListFree (flags->flg_option_lst);
- TestFree(flags->flg_comment);
- free (flags);
-}
-
-XF86OptionPtr
-xf86optionListDup (XF86OptionPtr opt)
-{
- XF86OptionPtr newopt = NULL;
- char *val;
-
- while (opt)
- {
- val = opt->opt_val ? strdup(opt->opt_val) : NULL;
- newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val);
- newopt->opt_used = opt->opt_used;
- if (opt->opt_comment)
- newopt->opt_comment = strdup(opt->opt_comment);
- opt = opt->list.next;
- }
- return newopt;
-}
-
-void
-xf86optionListFree (XF86OptionPtr opt)
-{
- XF86OptionPtr prev;
-
- while (opt)
- {
- TestFree (opt->opt_name);
- TestFree (opt->opt_val);
- TestFree (opt->opt_comment);
- prev = opt;
- opt = opt->list.next;
- free (prev);
- }
-}
-
-char *
-xf86optionName(XF86OptionPtr opt)
-{
- if (opt)
- return opt->opt_name;
- return 0;
-}
-
-char *
-xf86optionValue(XF86OptionPtr opt)
-{
- if (opt)
- return opt->opt_val;
- return 0;
-}
-
-XF86OptionPtr
-xf86newOption(char *name, char *value)
-{
- XF86OptionPtr opt;
-
- opt = calloc(1, sizeof (XF86OptionRec));
- if (!opt)
- return NULL;
-
- opt->opt_used = 0;
- opt->list.next = 0;
- opt->opt_name = name;
- opt->opt_val = value;
-
- return opt;
-}
-
-XF86OptionPtr
-xf86nextOption(XF86OptionPtr list)
-{
- if (!list)
- return NULL;
- return list->list.next;
-}
-
-/*
- * this function searches the given option list for the named option and
- * returns a pointer to the option rec if found. If not found, it returns
- * NULL
- */
-
-XF86OptionPtr
-xf86findOption (XF86OptionPtr list, const char *name)
-{
- while (list)
- {
- if (xf86nameCompare (list->opt_name, name) == 0)
- return list;
- list = list->list.next;
- }
- return NULL;
-}
-
-/*
- * this function searches the given option list for the named option. If
- * found and the option has a parameter, a pointer to the parameter is
- * returned. If the option does not have a parameter an empty string is
- * returned. If the option is not found, a NULL is returned.
- */
-
-char *
-xf86findOptionValue (XF86OptionPtr list, const char *name)
-{
- XF86OptionPtr p = xf86findOption (list, name);
-
- if (p)
- {
- if (p->opt_val)
- return p->opt_val;
- else
- return "";
- }
- return NULL;
-}
-
-XF86OptionPtr
-xf86optionListCreate( const char **options, int count, int used )
-{
- XF86OptionPtr p = NULL;
- char *t1, *t2;
- int i;
-
- if (count == -1)
- {
- for (count = 0; options[count]; count++)
- ;
- }
- if( (count % 2) != 0 )
- {
- fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" );
- return NULL;
- }
- for (i = 0; i < count; i += 2)
- {
- t1 = strdup(options[i]);
- t2 = strdup(options[i + 1]);
- p = addNewOption2 (p, t1, t2, used);
- }
-
- return p;
-}
-
-/* the 2 given lists are merged. If an option with the same name is present in
- * both, the option from the user list - specified in the second argument -
- * is used. The end result is a single valid list of options. Duplicates
- * are freed, and the original lists are no longer guaranteed to be complete.
- */
-XF86OptionPtr
-xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail)
-{
- XF86OptionPtr a, b, ap = NULL, bp = NULL;
-
- a = tail;
- b = head;
- while (tail && b) {
- if (xf86nameCompare (a->opt_name, b->opt_name) == 0) {
- if (b == head)
- head = a;
- else
- bp->list.next = a;
- if (a == tail)
- tail = a->list.next;
- else
- ap->list.next = a->list.next;
- a->list.next = b->list.next;
- b->list.next = NULL;
- xf86optionListFree (b);
- b = a->list.next;
- bp = a;
- a = tail;
- ap = NULL;
- } else {
- ap = a;
- if (!(a = a->list.next)) {
- a = tail;
- bp = b;
- b = b->list.next;
- ap = NULL;
- }
- }
- }
-
- if (head) {
- for (a = head; a->list.next; a = a->list.next)
- ;
- a->list.next = tail;
- } else
- head = tail;
-
- return head;
-}
-
-char *
-xf86uLongToString(unsigned long i)
-{
- char *s;
-
- if (asprintf(&s, "%lu", i) == -1)
- return NULL;
- return s;
-}
-
-XF86OptionPtr
-xf86parseOption(XF86OptionPtr head)
-{
- XF86OptionPtr option, cnew, old;
- char *name, *comment = NULL;
- int token;
-
- if ((token = xf86getSubToken(&comment)) != STRING) {
- xf86parseError(BAD_OPTION_MSG, NULL);
- free(comment);
- return head;
- }
-
- name = val.str;
- if ((token = xf86getSubToken(&comment)) == STRING) {
- option = xf86newOption(name, val.str);
- option->opt_comment = comment;
- if ((token = xf86getToken(NULL)) == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
- else
- xf86unGetToken(token);
- }
- else {
- option = xf86newOption(name, NULL);
- option->opt_comment = comment;
- if (token == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
- else
- xf86unGetToken(token);
- }
-
- old = NULL;
-
- /* Don't allow duplicates */
- if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
- cnew = old;
- free(option->opt_name);
- TestFree(option->opt_val);
- TestFree(option->opt_comment);
- free(option);
- }
- else
- cnew = option;
-
- if (old == NULL)
- return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew));
-
- return head;
-}
-
-void
-xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs)
-{
- int i;
-
- if (!list)
- return;
- while (list) {
- for (i = 0; i < tabs; i++)
- fputc('\t', fp);
- if (list->opt_val)
- fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val);
- else
- fprintf(fp, "Option \"%s\"", list->opt_name);
- if (list->opt_comment)
- fprintf(fp, "%s", list->opt_comment);
- else
- fputc('\n', fp);
- list = list->list.next;
- }
-}
+/*
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include <X11/Xfuncproto.h>
+#include "Xprintf.h"
+#include "optionstr.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec ServerFlagsTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {NOTRAPSIGNALS, "notrapsignals"},
+ {DONTZAP, "dontzap"},
+ {DONTZOOM, "dontzoom"},
+ {DISABLEVIDMODE, "disablevidmodeextension"},
+ {ALLOWNONLOCAL, "allownonlocalxvidtune"},
+ {DISABLEMODINDEV, "disablemodindev"},
+ {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"},
+ {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"},
+ {OPTION, "option"},
+ {BLANKTIME, "blanktime"},
+ {STANDBYTIME, "standbytime"},
+ {SUSPENDTIME, "suspendtime"},
+ {OFFTIME, "offtime"},
+ {DEFAULTLAYOUT, "defaultserverlayout"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeFlags
+
+XF86ConfFlagsPtr
+xf86parseFlagsSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
+
+ while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION)
+ {
+ int hasvalue = FALSE;
+ int strvalue = FALSE;
+ int tokentype;
+ switch (token)
+ {
+ case COMMENT:
+ ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
+ break;
+ /*
+ * these old keywords are turned into standard generic options.
+ * we fall through here on purpose
+ */
+ case DEFAULTLAYOUT:
+ strvalue = TRUE;
+ case BLANKTIME:
+ case STANDBYTIME:
+ case SUSPENDTIME:
+ case OFFTIME:
+ hasvalue = TRUE;
+ case NOTRAPSIGNALS:
+ case DONTZAP:
+ case DONTZOOM:
+ case DISABLEVIDMODE:
+ case ALLOWNONLOCAL:
+ case DISABLEMODINDEV:
+ case MODINDEVALLOWNONLOCAL:
+ case ALLOWMOUSEOPENFAIL:
+ {
+ int i = 0;
+ while (ServerFlagsTab[i].token != -1)
+ {
+ char *tmp;
+
+ if (ServerFlagsTab[i].token == token)
+ {
+ char *valstr = NULL;
+ tmp = strdup (ServerFlagsTab[i].name);
+ if (hasvalue)
+ {
+ tokentype = xf86getSubToken(&(ptr->flg_comment));
+ if (strvalue) {
+ if (tokentype != STRING)
+ Error (QUOTE_MSG, tmp);
+ valstr = val.str;
+ } else {
+ if (tokentype != NUMBER)
+ Error (NUMBER_MSG, tmp);
+ if (asprintf(&valstr, "%d", val.num) == -1)
+ valstr = NULL;
+ }
+ }
+ ptr->flg_option_lst = xf86addNewOption
+ (ptr->flg_option_lst, tmp, valstr);
+ }
+ i++;
+ }
+ }
+ break;
+ case OPTION:
+ ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("Flags section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags)
+{
+ XF86OptionPtr p;
+
+ if ((!flags) || (!flags->flg_option_lst))
+ return;
+ p = flags->flg_option_lst;
+ fprintf (f, "Section \"ServerFlags\"\n");
+ if (flags->flg_comment)
+ fprintf (f, "%s", flags->flg_comment);
+ xf86printOptionList(f, p, 1);
+ fprintf (f, "EndSection\n\n");
+}
+
+static XF86OptionPtr
+addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
+{
+ XF86OptionPtr new, old = NULL;
+
+ /* Don't allow duplicates, free old strings */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+ new = old;
+ free(new->opt_name);
+ free(new->opt_val);
+ }
+ else
+ new = calloc (1, sizeof (*new));
+ new->opt_name = name;
+ new->opt_val = val;
+ new->opt_used = used;
+
+ if (old)
+ return head;
+ return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
+}
+
+XF86OptionPtr
+xf86addNewOption (XF86OptionPtr head, char *name, char *val)
+{
+ return addNewOption2(head, name, val, 0);
+}
+
+void
+xf86freeFlags (XF86ConfFlagsPtr flags)
+{
+ if (flags == NULL)
+ return;
+ xf86optionListFree (flags->flg_option_lst);
+ TestFree(flags->flg_comment);
+ free (flags);
+}
+
+XF86OptionPtr
+xf86optionListDup (XF86OptionPtr opt)
+{
+ XF86OptionPtr newopt = NULL;
+ char *val;
+
+ while (opt)
+ {
+ val = opt->opt_val ? strdup(opt->opt_val) : NULL;
+ newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val);
+ newopt->opt_used = opt->opt_used;
+ if (opt->opt_comment)
+ newopt->opt_comment = strdup(opt->opt_comment);
+ opt = opt->list.next;
+ }
+ return newopt;
+}
+
+void
+xf86optionListFree (XF86OptionPtr opt)
+{
+ XF86OptionPtr prev;
+
+ while (opt)
+ {
+ TestFree (opt->opt_name);
+ TestFree (opt->opt_val);
+ TestFree (opt->opt_comment);
+ prev = opt;
+ opt = opt->list.next;
+ free (prev);
+ }
+}
+
+char *
+xf86optionName(XF86OptionPtr opt)
+{
+ if (opt)
+ return opt->opt_name;
+ return 0;
+}
+
+char *
+xf86optionValue(XF86OptionPtr opt)
+{
+ if (opt)
+ return opt->opt_val;
+ return 0;
+}
+
+XF86OptionPtr
+xf86newOption(char *name, char *value)
+{
+ XF86OptionPtr opt;
+
+ opt = calloc(1, sizeof (*opt));
+ if (!opt)
+ return NULL;
+
+ opt->opt_used = 0;
+ opt->list.next = 0;
+ opt->opt_name = name;
+ opt->opt_val = value;
+
+ return opt;
+}
+
+XF86OptionPtr
+xf86nextOption(XF86OptionPtr list)
+{
+ if (!list)
+ return NULL;
+ return list->list.next;
+}
+
+/*
+ * this function searches the given option list for the named option and
+ * returns a pointer to the option rec if found. If not found, it returns
+ * NULL
+ */
+
+XF86OptionPtr
+xf86findOption (XF86OptionPtr list, const char *name)
+{
+ while (list)
+ {
+ if (xf86nameCompare (list->opt_name, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
+}
+
+/*
+ * this function searches the given option list for the named option. If
+ * found and the option has a parameter, a pointer to the parameter is
+ * returned. If the option does not have a parameter an empty string is
+ * returned. If the option is not found, a NULL is returned.
+ */
+
+char *
+xf86findOptionValue (XF86OptionPtr list, const char *name)
+{
+ XF86OptionPtr p = xf86findOption (list, name);
+
+ if (p)
+ {
+ if (p->opt_val)
+ return p->opt_val;
+ else
+ return "";
+ }
+ return NULL;
+}
+
+XF86OptionPtr
+xf86optionListCreate( const char **options, int count, int used )
+{
+ XF86OptionPtr p = NULL;
+ char *t1, *t2;
+ int i;
+
+ if (count == -1)
+ {
+ for (count = 0; options[count]; count++)
+ ;
+ }
+ if( (count % 2) != 0 )
+ {
+ fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" );
+ return NULL;
+ }
+ for (i = 0; i < count; i += 2)
+ {
+ t1 = strdup(options[i]);
+ t2 = strdup(options[i + 1]);
+ p = addNewOption2 (p, t1, t2, used);
+ }
+
+ return p;
+}
+
+/* the 2 given lists are merged. If an option with the same name is present in
+ * both, the option from the user list - specified in the second argument -
+ * is used. The end result is a single valid list of options. Duplicates
+ * are freed, and the original lists are no longer guaranteed to be complete.
+ */
+XF86OptionPtr
+xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail)
+{
+ XF86OptionPtr a, b, ap = NULL, bp = NULL;
+
+ a = tail;
+ b = head;
+ while (tail && b) {
+ if (xf86nameCompare (a->opt_name, b->opt_name) == 0) {
+ if (b == head)
+ head = a;
+ else
+ bp->list.next = a;
+ if (a == tail)
+ tail = a->list.next;
+ else
+ ap->list.next = a->list.next;
+ a->list.next = b->list.next;
+ b->list.next = NULL;
+ xf86optionListFree (b);
+ b = a->list.next;
+ bp = a;
+ a = tail;
+ ap = NULL;
+ } else {
+ ap = a;
+ if (!(a = a->list.next)) {
+ a = tail;
+ bp = b;
+ b = b->list.next;
+ ap = NULL;
+ }
+ }
+ }
+
+ if (head) {
+ for (a = head; a->list.next; a = a->list.next)
+ ;
+ a->list.next = tail;
+ } else
+ head = tail;
+
+ return head;
+}
+
+char *
+xf86uLongToString(unsigned long i)
+{
+ char *s;
+
+ if (asprintf(&s, "%lu", i) == -1)
+ return NULL;
+ return s;
+}
+
+XF86OptionPtr
+xf86parseOption(XF86OptionPtr head)
+{
+ XF86OptionPtr option, cnew, old;
+ char *name, *comment = NULL;
+ int token;
+
+ if ((token = xf86getSubToken(&comment)) != STRING) {
+ xf86parseError(BAD_OPTION_MSG, NULL);
+ free(comment);
+ return head;
+ }
+
+ name = val.str;
+ if ((token = xf86getSubToken(&comment)) == STRING) {
+ option = xf86newOption(name, val.str);
+ option->opt_comment = comment;
+ if ((token = xf86getToken(NULL)) == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+ else {
+ option = xf86newOption(name, NULL);
+ option->opt_comment = comment;
+ if (token == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+
+ old = NULL;
+
+ /* Don't allow duplicates */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+ cnew = old;
+ free(option->opt_name);
+ TestFree(option->opt_val);
+ TestFree(option->opt_comment);
+ free(option);
+ }
+ else
+ cnew = option;
+
+ if (old == NULL)
+ return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew));
+
+ return head;
+}
+
+void
+xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs)
+{
+ int i;
+
+ if (!list)
+ return;
+ while (list) {
+ for (i = 0; i < tabs; i++)
+ fputc('\t', fp);
+ if (list->opt_val)
+ fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val);
+ else
+ fprintf(fp, "Option \"%s\"", list->opt_name);
+ if (list->opt_comment)
+ fprintf(fp, "%s", list->opt_comment);
+ else
+ fputc('\n', fp);
+ list = list->list.next;
+ }
+}
diff --git a/xorg-server/hw/xfree86/parser/Layout.c b/xorg-server/hw/xfree86/parser/Layout.c
index 60e83390f..4487b0df6 100644
--- a/xorg-server/hw/xfree86/parser/Layout.c
+++ b/xorg-server/hw/xfree86/parser/Layout.c
@@ -1,558 +1,558 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-#include <string.h>
-
-
-/* Needed for auto server layout */
-extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec LayoutTab[] =
-{
- {ENDSECTION, "endsection"},
- {SCREEN, "screen"},
- {IDENTIFIER, "identifier"},
- {INACTIVE, "inactive"},
- {INPUTDEVICE, "inputdevice"},
- {OPTION, "option"},
- {-1, ""},
-};
-
-static xf86ConfigSymTabRec AdjTab[] =
-{
- {RIGHTOF, "rightof"},
- {LEFTOF, "leftof"},
- {ABOVE, "above"},
- {BELOW, "below"},
- {RELATIVE, "relative"},
- {ABSOLUTE, "absolute"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeLayoutList
-
-XF86ConfLayoutPtr
-xf86parseLayoutSection (void)
-{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
-
- while ((token = xf86getToken (LayoutTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->lay_identifier = val.str;
- has_ident = TRUE;
- break;
- case INACTIVE:
- {
- XF86ConfInactivePtr iptr;
-
- iptr = calloc (1, sizeof (XF86ConfInactiveRec));
- iptr->list.next = NULL;
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free (iptr);
- Error (INACTIVE_MSG, NULL);
- }
- iptr->inactive_device_str = val.str;
- ptr->lay_inactive_lst = (XF86ConfInactivePtr)
- xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr);
- }
- break;
- case SCREEN:
- {
- XF86ConfAdjacencyPtr aptr;
- int absKeyword = 0;
-
- aptr = calloc (1, sizeof (XF86ConfAdjacencyRec));
- aptr->list.next = NULL;
- aptr->adj_scrnum = -1;
- aptr->adj_where = CONF_ADJ_OBSOLETE;
- aptr->adj_x = 0;
- aptr->adj_y = 0;
- aptr->adj_refscreen = NULL;
- if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER)
- aptr->adj_scrnum = val.num;
- else
- xf86unGetToken (token);
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_screen_str = val.str;
-
- token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
- switch (token)
- {
- case RIGHTOF:
- aptr->adj_where = CONF_ADJ_RIGHTOF;
- break;
- case LEFTOF:
- aptr->adj_where = CONF_ADJ_LEFTOF;
- break;
- case ABOVE:
- aptr->adj_where = CONF_ADJ_ABOVE;
- break;
- case BELOW:
- aptr->adj_where = CONF_ADJ_BELOW;
- break;
- case RELATIVE:
- aptr->adj_where = CONF_ADJ_RELATIVE;
- break;
- case ABSOLUTE:
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- absKeyword = 1;
- break;
- case EOF_TOKEN:
- free(aptr);
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- xf86unGetToken (token);
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token == STRING)
- aptr->adj_where = CONF_ADJ_OBSOLETE;
- else
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- }
- switch (aptr->adj_where)
- {
- case CONF_ADJ_ABSOLUTE:
- if (absKeyword)
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token == NUMBER)
- {
- aptr->adj_x = val.num;
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_y = val.num;
- } else {
- if (absKeyword) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- } else
- xf86unGetToken (token);
- }
- break;
- case CONF_ADJ_RIGHTOF:
- case CONF_ADJ_LEFTOF:
- case CONF_ADJ_ABOVE:
- case CONF_ADJ_BELOW:
- case CONF_ADJ_RELATIVE:
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != STRING) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_refscreen = val.str;
- if (aptr->adj_where == CONF_ADJ_RELATIVE)
- {
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_x = val.num;
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_y = val.num;
- }
- break;
- case CONF_ADJ_OBSOLETE:
- /* top */
- aptr->adj_top_str = val.str;
-
- /* bottom */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_bottom_str = val.str;
-
- /* left */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_left_str = val.str;
-
- /* right */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_right_str = val.str;
-
- }
- ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
- xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr);
- }
- break;
- case INPUTDEVICE:
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = calloc (1, sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(iptr);
- Error (INPUTDEV_MSG, NULL);
- }
- iptr->iref_inputdev_str = val.str;
- while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING)
- {
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, val.str, NULL);
- }
- xf86unGetToken (token);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
- break;
- case OPTION:
- ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf ("Layout section parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr)
-{
- XF86ConfAdjacencyPtr aptr;
- XF86ConfInactivePtr iptr;
- XF86ConfInputrefPtr inptr;
- XF86OptionPtr optr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"ServerLayout\"\n");
- if (ptr->lay_comment)
- fprintf (cf, "%s", ptr->lay_comment);
- if (ptr->lay_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier);
-
- for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next)
- {
- fprintf (cf, "\tScreen ");
- if (aptr->adj_scrnum >= 0)
- fprintf (cf, "%2d", aptr->adj_scrnum);
- else
- fprintf (cf, " ");
- fprintf (cf, " \"%s\"", aptr->adj_screen_str);
- switch(aptr->adj_where)
- {
- case CONF_ADJ_OBSOLETE:
- fprintf (cf, " \"%s\"", aptr->adj_top_str);
- fprintf (cf, " \"%s\"", aptr->adj_bottom_str);
- fprintf (cf, " \"%s\"", aptr->adj_right_str);
- fprintf (cf, " \"%s\"\n", aptr->adj_left_str);
- break;
- case CONF_ADJ_ABSOLUTE:
- if (aptr->adj_x != -1)
- fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y);
- else
- fprintf (cf, "\n");
- break;
- case CONF_ADJ_RIGHTOF:
- fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_LEFTOF:
- fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_ABOVE:
- fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_BELOW:
- fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_RELATIVE:
- fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen,
- aptr->adj_x, aptr->adj_y);
- break;
- }
- }
- for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next)
- fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str);
- for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next)
- {
- fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str);
- for (optr = inptr->iref_option_lst; optr; optr = optr->list.next)
- {
- fprintf(cf, " \"%s\"", optr->opt_name);
- }
- fprintf(cf, "\n");
- }
- xf86printOptionList(cf, ptr->lay_option_lst, 1);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-}
-
-static void
-xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr)
-{
- XF86ConfAdjacencyPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->adj_screen_str);
- TestFree (ptr->adj_top_str);
- TestFree (ptr->adj_bottom_str);
- TestFree (ptr->adj_left_str);
- TestFree (ptr->adj_right_str);
-
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-
-}
-
-static void
-xf86freeInputrefList (XF86ConfInputrefPtr ptr)
-{
- XF86ConfInputrefPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->iref_inputdev_str);
- xf86optionListFree (ptr->iref_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-
-}
-
-void
-xf86freeLayoutList (XF86ConfLayoutPtr ptr)
-{
- XF86ConfLayoutPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->lay_identifier);
- TestFree (ptr->lay_comment);
- xf86freeAdjacencyList (ptr->lay_adjacency_lst);
- xf86freeInputrefList (ptr->lay_input_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-int
-xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
-{
- int count = 0;
- XF86ConfInputPtr input = config->conf_input_lst;
- XF86ConfInputrefPtr inptr;
-
- /* add all AutoServerLayout devices to the server layout */
- while (input)
- {
- if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE))
- {
- XF86ConfInputrefPtr iref = layout->lay_input_lst;
-
- /* avoid duplicates if referenced but lists AutoServerLayout too */
- while (iref)
- {
- if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
- break;
- iref = iref->list.next;
- }
-
- if (!iref)
- {
- XF86ConfInputrefPtr iptr;
- iptr = calloc(1, sizeof(XF86ConfInputrefRec));
- iptr->iref_inputdev_str = input->inp_identifier;
- layout->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem((glp)layout->lay_input_lst, (glp)iptr);
- count++;
- }
- }
- input = input->list.next;
- }
-
- inptr = layout->lay_input_lst;
- while (inptr)
- {
- input = xf86findInput (inptr->iref_inputdev_str,
- config->conf_input_lst);
- if (!input)
- {
- xf86validationError (UNDEFINED_INPUT_MSG,
- inptr->iref_inputdev_str, layout->lay_identifier);
- return -1;
- }
- else
- inptr->iref_inputdev = input;
- inptr = inptr->list.next;
- }
-
- return count;
-}
-
-int
-xf86validateLayout (XF86ConfigPtr p)
-{
- XF86ConfLayoutPtr layout = p->conf_layout_lst;
- XF86ConfAdjacencyPtr adj;
- XF86ConfInactivePtr iptr;
- XF86ConfScreenPtr screen;
- XF86ConfDevicePtr device;
-
- while (layout)
- {
- adj = layout->lay_adjacency_lst;
- while (adj)
- {
- /* the first one can't be "" but all others can */
- screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst);
- if (!screen)
- {
- xf86validationError (UNDEFINED_SCREEN_MSG,
- adj->adj_screen_str, layout->lay_identifier);
- return FALSE;
- }
- else
- adj->adj_screen = screen;
-
- adj = adj->list.next;
- }
- iptr = layout->lay_inactive_lst;
- while (iptr)
- {
- device = xf86findDevice (iptr->inactive_device_str,
- p->conf_device_lst);
- if (!device)
- {
- xf86validationError (UNDEFINED_DEVICE_LAY_MSG,
- iptr->inactive_device_str, layout->lay_identifier);
- return FALSE;
- }
- else
- iptr->inactive_device = device;
- iptr = iptr->list.next;
- }
-
- if (xf86layoutAddInputDevices(p, layout) == -1)
- return FALSE;
-
- layout = layout->list.next;
- }
- return TRUE;
-}
-
-XF86ConfLayoutPtr
-xf86findLayout (const char *name, XF86ConfLayoutPtr list)
-{
- while (list)
- {
- if (xf86nameCompare (list->lay_identifier, name) == 0)
- return list;
- list = list->list.next;
- }
- return NULL;
-}
-
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#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);
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec LayoutTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {SCREEN, "screen"},
+ {IDENTIFIER, "identifier"},
+ {INACTIVE, "inactive"},
+ {INPUTDEVICE, "inputdevice"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec AdjTab[] =
+{
+ {RIGHTOF, "rightof"},
+ {LEFTOF, "leftof"},
+ {ABOVE, "above"},
+ {BELOW, "below"},
+ {RELATIVE, "relative"},
+ {ABSOLUTE, "absolute"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeLayoutList
+
+XF86ConfLayoutPtr
+xf86parseLayoutSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
+
+ while ((token = xf86getToken (LayoutTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->lay_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case INACTIVE:
+ {
+ XF86ConfInactivePtr iptr;
+
+ iptr = calloc (1, sizeof (XF86ConfInactiveRec));
+ iptr->list.next = NULL;
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free (iptr);
+ Error (INACTIVE_MSG, NULL);
+ }
+ iptr->inactive_device_str = val.str;
+ ptr->lay_inactive_lst = (XF86ConfInactivePtr)
+ xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr);
+ }
+ break;
+ case SCREEN:
+ {
+ XF86ConfAdjacencyPtr aptr;
+ int absKeyword = 0;
+
+ aptr = calloc (1, sizeof (XF86ConfAdjacencyRec));
+ aptr->list.next = NULL;
+ aptr->adj_scrnum = -1;
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ aptr->adj_x = 0;
+ aptr->adj_y = 0;
+ aptr->adj_refscreen = NULL;
+ if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER)
+ aptr->adj_scrnum = val.num;
+ else
+ xf86unGetToken (token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_screen_str = val.str;
+
+ token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
+ switch (token)
+ {
+ case RIGHTOF:
+ aptr->adj_where = CONF_ADJ_RIGHTOF;
+ break;
+ case LEFTOF:
+ aptr->adj_where = CONF_ADJ_LEFTOF;
+ break;
+ case ABOVE:
+ aptr->adj_where = CONF_ADJ_ABOVE;
+ break;
+ case BELOW:
+ aptr->adj_where = CONF_ADJ_BELOW;
+ break;
+ case RELATIVE:
+ aptr->adj_where = CONF_ADJ_RELATIVE;
+ break;
+ case ABSOLUTE:
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ absKeyword = 1;
+ break;
+ case EOF_TOKEN:
+ free(aptr);
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ xf86unGetToken (token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == STRING)
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ else
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ }
+ switch (aptr->adj_where)
+ {
+ case CONF_ADJ_ABSOLUTE:
+ if (absKeyword)
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == NUMBER)
+ {
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_y = val.num;
+ } else {
+ if (absKeyword) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ } else
+ xf86unGetToken (token);
+ }
+ break;
+ case CONF_ADJ_RIGHTOF:
+ case CONF_ADJ_LEFTOF:
+ case CONF_ADJ_ABOVE:
+ case CONF_ADJ_BELOW:
+ case CONF_ADJ_RELATIVE:
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_refscreen = val.str;
+ if (aptr->adj_where == CONF_ADJ_RELATIVE)
+ {
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_y = val.num;
+ }
+ break;
+ case CONF_ADJ_OBSOLETE:
+ /* top */
+ aptr->adj_top_str = val.str;
+
+ /* bottom */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_bottom_str = val.str;
+
+ /* left */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_left_str = val.str;
+
+ /* right */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_right_str = val.str;
+
+ }
+ ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
+ xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr);
+ }
+ break;
+ case INPUTDEVICE:
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = calloc (1, sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(iptr);
+ Error (INPUTDEV_MSG, NULL);
+ }
+ iptr->iref_inputdev_str = val.str;
+ while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING)
+ {
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, val.str, NULL);
+ }
+ xf86unGetToken (token);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+ break;
+ case OPTION:
+ ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Layout section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr)
+{
+ XF86ConfAdjacencyPtr aptr;
+ XF86ConfInactivePtr iptr;
+ XF86ConfInputrefPtr inptr;
+ XF86OptionPtr optr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"ServerLayout\"\n");
+ if (ptr->lay_comment)
+ fprintf (cf, "%s", ptr->lay_comment);
+ if (ptr->lay_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier);
+
+ for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next)
+ {
+ fprintf (cf, "\tScreen ");
+ if (aptr->adj_scrnum >= 0)
+ fprintf (cf, "%2d", aptr->adj_scrnum);
+ else
+ fprintf (cf, " ");
+ fprintf (cf, " \"%s\"", aptr->adj_screen_str);
+ switch(aptr->adj_where)
+ {
+ case CONF_ADJ_OBSOLETE:
+ fprintf (cf, " \"%s\"", aptr->adj_top_str);
+ fprintf (cf, " \"%s\"", aptr->adj_bottom_str);
+ fprintf (cf, " \"%s\"", aptr->adj_right_str);
+ fprintf (cf, " \"%s\"\n", aptr->adj_left_str);
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ if (aptr->adj_x != -1)
+ fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y);
+ else
+ fprintf (cf, "\n");
+ break;
+ case CONF_ADJ_RIGHTOF:
+ fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_LEFTOF:
+ fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_ABOVE:
+ fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_BELOW:
+ fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_RELATIVE:
+ fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen,
+ aptr->adj_x, aptr->adj_y);
+ break;
+ }
+ }
+ for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next)
+ fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str);
+ for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next)
+ {
+ fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str);
+ for (optr = inptr->iref_option_lst; optr; optr = optr->list.next)
+ {
+ fprintf(cf, " \"%s\"", optr->opt_name);
+ }
+ fprintf(cf, "\n");
+ }
+ xf86printOptionList(cf, ptr->lay_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+static void
+xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr)
+{
+ XF86ConfAdjacencyPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->adj_screen_str);
+ TestFree (ptr->adj_top_str);
+ TestFree (ptr->adj_bottom_str);
+ TestFree (ptr->adj_left_str);
+ TestFree (ptr->adj_right_str);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+
+}
+
+static void
+xf86freeInputrefList (XF86ConfInputrefPtr ptr)
+{
+ XF86ConfInputrefPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->iref_inputdev_str);
+ xf86optionListFree (ptr->iref_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+
+}
+
+void
+xf86freeLayoutList (XF86ConfLayoutPtr ptr)
+{
+ XF86ConfLayoutPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->lay_identifier);
+ TestFree (ptr->lay_comment);
+ xf86freeAdjacencyList (ptr->lay_adjacency_lst);
+ xf86freeInputrefList (ptr->lay_input_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+int
+xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
+{
+ int count = 0;
+ XF86ConfInputPtr input = config->conf_input_lst;
+ XF86ConfInputrefPtr inptr;
+
+ /* add all AutoServerLayout devices to the server layout */
+ while (input)
+ {
+ if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE))
+ {
+ XF86ConfInputrefPtr iref = layout->lay_input_lst;
+
+ /* avoid duplicates if referenced but lists AutoServerLayout too */
+ while (iref)
+ {
+ if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
+ break;
+ iref = iref->list.next;
+ }
+
+ if (!iref)
+ {
+ XF86ConfInputrefPtr iptr;
+ iptr = calloc(1, sizeof(XF86ConfInputrefRec));
+ iptr->iref_inputdev_str = input->inp_identifier;
+ layout->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem((glp)layout->lay_input_lst, (glp)iptr);
+ count++;
+ }
+ }
+ input = input->list.next;
+ }
+
+ inptr = layout->lay_input_lst;
+ while (inptr)
+ {
+ input = xf86findInput (inptr->iref_inputdev_str,
+ config->conf_input_lst);
+ if (!input)
+ {
+ xf86validationError (UNDEFINED_INPUT_MSG,
+ inptr->iref_inputdev_str, layout->lay_identifier);
+ return -1;
+ }
+ else
+ inptr->iref_inputdev = input;
+ inptr = inptr->list.next;
+ }
+
+ return count;
+}
+
+int
+xf86validateLayout (XF86ConfigPtr p)
+{
+ XF86ConfLayoutPtr layout = p->conf_layout_lst;
+ XF86ConfAdjacencyPtr adj;
+ XF86ConfInactivePtr iptr;
+ XF86ConfScreenPtr screen;
+ XF86ConfDevicePtr device;
+
+ while (layout)
+ {
+ adj = layout->lay_adjacency_lst;
+ while (adj)
+ {
+ /* the first one can't be "" but all others can */
+ screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst);
+ if (!screen)
+ {
+ xf86validationError (UNDEFINED_SCREEN_MSG,
+ adj->adj_screen_str, layout->lay_identifier);
+ return FALSE;
+ }
+ else
+ adj->adj_screen = screen;
+
+ adj = adj->list.next;
+ }
+ iptr = layout->lay_inactive_lst;
+ while (iptr)
+ {
+ device = xf86findDevice (iptr->inactive_device_str,
+ p->conf_device_lst);
+ if (!device)
+ {
+ xf86validationError (UNDEFINED_DEVICE_LAY_MSG,
+ iptr->inactive_device_str, layout->lay_identifier);
+ return FALSE;
+ }
+ else
+ iptr->inactive_device = device;
+ iptr = iptr->list.next;
+ }
+
+ if (xf86layoutAddInputDevices(p, layout) == -1)
+ return FALSE;
+
+ layout = layout->list.next;
+ }
+ return TRUE;
+}
+
+XF86ConfLayoutPtr
+xf86findLayout (const char *name, XF86ConfLayoutPtr list)
+{
+ while (list)
+ {
+ if (xf86nameCompare (list->lay_identifier, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
+}
+
diff --git a/xorg-server/hw/xnest/Events.c b/xorg-server/hw/xnest/Events.c
index 2399313c6..619427ded 100644
--- a/xorg-server/hw/xnest/Events.c
+++ b/xorg-server/hw/xnest/Events.c
@@ -198,8 +198,6 @@ xnestCollectEvents(void)
case DestroyNotify:
if (xnestParentWindow != (Window) 0 &&
X.xdestroywindow.window == xnestParentWindow)
- CloseWellKnownConnections();
- OsCleanup(1);
exit (0);
break;
diff --git a/xorg-server/hw/xnest/Keyboard.c b/xorg-server/hw/xnest/Keyboard.c
index 9dba46ccd..5ef376b91 100644
--- a/xorg-server/hw/xnest/Keyboard.c
+++ b/xorg-server/hw/xnest/Keyboard.c
@@ -1,251 +1,268 @@
-/*
-
-Copyright 1993 by Davor Matic
-
-Permission to use, copy, modify, distribute, and sell this software
-and its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation. Davor Matic makes no representations about
-the suitability of this software for any purpose. It is provided "as
-is" without express or implied warranty.
-
-*/
-
-#ifdef HAVE_XNEST_CONFIG_H
-#include <xnest-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/keysym.h>
-#include "screenint.h"
-#include "inputstr.h"
-#include "misc.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-
-#include "Xnest.h"
-
-#include "Display.h"
-#include "Screen.h"
-#include "Keyboard.h"
-#include "Args.h"
-#include "Events.h"
-
-#include <X11/extensions/XKB.h>
-#include "xkbsrv.h"
-#include <X11/extensions/XKBconfig.h>
-
-extern Bool
-XkbQueryExtension(
- Display * /* dpy */,
- int * /* opcodeReturn */,
- int * /* eventBaseReturn */,
- int * /* errorBaseReturn */,
- int * /* majorRtrn */,
- int * /* minorRtrn */
-);
-
-extern XkbDescPtr XkbGetKeyboard(
- Display * /* dpy */,
- unsigned int /* which */,
- unsigned int /* deviceSpec */
-);
-
-extern Status XkbGetControls(
- Display * /* dpy */,
- unsigned long /* which */,
- XkbDescPtr /* desc */
-);
-
-DeviceIntPtr xnestKeyboardDevice = NULL;
-
-void
-xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls)
-{
- XBell(xnestDisplay, volume);
-}
-
-void
-DDXRingBell(int volume, int pitch, int duration)
-{
- XBell(xnestDisplay, volume);
-}
-
-void
-xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
-{
-#if 0
- unsigned long value_mask;
- XKeyboardControl values;
- int i;
-
- value_mask = KBKeyClickPercent |
- KBBellPercent |
- KBBellPitch |
- KBBellDuration |
- KBAutoRepeatMode;
-
- values.key_click_percent = ctrl->click;
- values.bell_percent = ctrl->bell;
- values.bell_pitch = ctrl->bell_pitch;
- values.bell_duration = ctrl->bell_duration;
- values.auto_repeat_mode = ctrl->autoRepeat ?
- AutoRepeatModeOn : AutoRepeatModeOff;
-
- XChangeKeyboardControl(xnestDisplay, value_mask, &values);
-
- /*
- value_mask = KBKey | KBAutoRepeatMode;
- At this point, we need to walk through the vector and compare it
- to the current server vector. If there are differences, report them.
- */
-
- value_mask = KBLed | KBLedMode;
- for (i = 1; i <= 32; i++) {
- values.led = i;
- values.led_mode = (ctrl->leds & (1 << (i - 1))) ? LedModeOn : LedModeOff;
- XChangeKeyboardControl(xnestDisplay, value_mask, &values);
- }
-#endif
-}
-
-int
-xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
-{
- KeySym *keymap;
- int mapWidth;
- int min_keycode, max_keycode;
- KeySymsRec keySyms;
- int i;
- XKeyboardState values;
- XkbDescPtr xkb;
- int op, event, error, major, minor;
-
- switch (onoff)
- {
- case DEVICE_INIT:
- XDisplayKeycodes(xnestDisplay, &min_keycode, &max_keycode);
-#ifdef _XSERVER64
- {
- KeySym64 *keymap64;
- int i, len;
- keymap64 = XGetKeyboardMapping(xnestDisplay,
- min_keycode,
- max_keycode - min_keycode + 1,
- &mapWidth);
- len = (max_keycode - min_keycode + 1) * mapWidth;
- keymap = (KeySym *)malloc(len * sizeof(KeySym));
- for(i = 0; i < len; ++i)
- keymap[i] = keymap64[i];
- XFree(keymap64);
- }
-#else
- keymap = XGetKeyboardMapping(xnestDisplay,
- min_keycode,
- max_keycode - min_keycode + 1,
- &mapWidth);
-#endif
-
- keySyms.minKeyCode = min_keycode;
- keySyms.maxKeyCode = max_keycode;
- keySyms.mapWidth = mapWidth;
- keySyms.map = keymap;
-
- if (XkbQueryExtension(xnestDisplay, &op, &event, &error, &major, &minor) == 0) {
- ErrorF("Unable to initialize XKEYBOARD extension.\n");
- goto XkbError;
- }
- xkb = XkbGetKeyboard(xnestDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
- if (xkb == NULL || xkb->geom == NULL) {
- ErrorF("Couldn't get keyboard.\n");
- goto XkbError;
- }
- XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb);
-
- InitKeyboardDeviceStruct(pDev, NULL,
- xnestBell, xnestChangeKeyboardControl);
- XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls);
- XkbFreeKeyboard(xkb, 0, False);
- free(keymap);
- break;
- case DEVICE_ON:
- xnestEventMask |= XNEST_KEYBOARD_EVENT_MASK;
- for (i = 0; i < xnestNumScreens; i++)
- XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
- break;
- case DEVICE_OFF:
- xnestEventMask &= ~XNEST_KEYBOARD_EVENT_MASK;
- for (i = 0; i < xnestNumScreens; i++)
- XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
- break;
- case DEVICE_CLOSE:
- break;
- }
- return Success;
-
-XkbError:
- XGetKeyboardControl(xnestDisplay, &values);
- memmove((char *)defaultKeyboardControl.autoRepeats,
- (char *)values.auto_repeats,
- sizeof(values.auto_repeats));
-
- InitKeyboardDeviceStruct(pDev, NULL,
- xnestBell, xnestChangeKeyboardControl);
- free(keymap);
- return Success;
-}
-
-Bool
-LegalModifier(unsigned int key, DeviceIntPtr pDev)
-{
- return TRUE;
-}
-
-void
-xnestUpdateModifierState(unsigned int state)
-{
- DeviceIntPtr pDev = xnestKeyboardDevice;
- KeyClassPtr keyc = pDev->key;
- int i;
- CARD8 mask;
- int xkb_state;
-
- if (!pDev)
- return;
-
- xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state);
- state = state & 0xff;
-
- if (xkb_state == state)
- return;
-
- for (i = 0, mask = 1; i < 8; i++, mask <<= 1) {
- int key;
-
- /* Modifier is down, but shouldn't be
- */
- if ((xkb_state & mask) && !(state & mask)) {
- int count = keyc->modifierKeyCount[i];
-
- for (key = 0; key < MAP_LENGTH; key++)
- if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
- if (key_is_down(pDev, key, KEY_PROCESSED))
- xnestQueueKeyEvent(KeyRelease, key);
-
- if (--count == 0)
- break;
- }
- }
-
- /* Modifier shoud be down, but isn't
- */
- if (!(xkb_state & mask) && (state & mask))
- for (key = 0; key < MAP_LENGTH; key++)
- if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
- xnestQueueKeyEvent(KeyPress, key);
- break;
- }
- }
-}
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "screenint.h"
+#include "inputstr.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "Keyboard.h"
+#include "Args.h"
+#include "Events.h"
+
+#include <X11/extensions/XKB.h>
+#include "xkbsrv.h"
+#include <X11/extensions/XKBconfig.h>
+
+extern Bool
+XkbQueryExtension(
+ Display * /* dpy */,
+ int * /* opcodeReturn */,
+ int * /* eventBaseReturn */,
+ int * /* errorBaseReturn */,
+ int * /* majorRtrn */,
+ int * /* minorRtrn */
+);
+
+extern XkbDescPtr XkbGetKeyboard(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* deviceSpec */
+);
+
+extern Status XkbGetControls(
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+);
+
+DeviceIntPtr xnestKeyboardDevice = NULL;
+
+void
+xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls)
+{
+ XBell(xnestDisplay, volume);
+}
+
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+ XBell(xnestDisplay, volume);
+}
+
+void
+xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
+{
+#if 0
+ unsigned long value_mask;
+ XKeyboardControl values;
+ int i;
+
+ value_mask = KBKeyClickPercent |
+ KBBellPercent |
+ KBBellPitch |
+ KBBellDuration |
+ KBAutoRepeatMode;
+
+ values.key_click_percent = ctrl->click;
+ values.bell_percent = ctrl->bell;
+ values.bell_pitch = ctrl->bell_pitch;
+ values.bell_duration = ctrl->bell_duration;
+ values.auto_repeat_mode = ctrl->autoRepeat ?
+ AutoRepeatModeOn : AutoRepeatModeOff;
+
+ XChangeKeyboardControl(xnestDisplay, value_mask, &values);
+
+ /*
+ value_mask = KBKey | KBAutoRepeatMode;
+ At this point, we need to walk through the vector and compare it
+ to the current server vector. If there are differences, report them.
+ */
+
+ value_mask = KBLed | KBLedMode;
+ for (i = 1; i <= 32; i++) {
+ values.led = i;
+ values.led_mode = (ctrl->leds & (1 << (i - 1))) ? LedModeOn : LedModeOff;
+ XChangeKeyboardControl(xnestDisplay, value_mask, &values);
+ }
+#endif
+}
+
+int
+xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
+{
+ XModifierKeymap *modifier_keymap;
+ KeySym *keymap;
+ int mapWidth;
+ int min_keycode, max_keycode;
+ KeySymsRec keySyms;
+ CARD8 modmap[MAP_LENGTH];
+ int i, j;
+ XKeyboardState values;
+ XkbDescPtr xkb;
+ int op, event, error, major, minor;
+
+ switch (onoff)
+ {
+ case DEVICE_INIT:
+ XDisplayKeycodes(xnestDisplay, &min_keycode, &max_keycode);
+#ifdef _XSERVER64
+ {
+ KeySym64 *keymap64;
+ int len;
+ keymap64 = XGetKeyboardMapping(xnestDisplay,
+ min_keycode,
+ max_keycode - min_keycode + 1,
+ &mapWidth);
+ len = (max_keycode - min_keycode + 1) * mapWidth;
+ keymap = (KeySym *)malloc(len * sizeof(KeySym));
+ for(i = 0; i < len; ++i)
+ keymap[i] = keymap64[i];
+ XFree(keymap64);
+ }
+#else
+ keymap = XGetKeyboardMapping(xnestDisplay,
+ min_keycode,
+ max_keycode - min_keycode + 1,
+ &mapWidth);
+#endif
+
+ memset(modmap, 0, sizeof(modmap));
+ modifier_keymap = XGetModifierMapping(xnestDisplay);
+ for (j = 0; j < 8; j++)
+ for(i = 0; i < modifier_keymap->max_keypermod; i++) {
+ CARD8 keycode;
+ if ((keycode = modifier_keymap->modifiermap[j * modifier_keymap->max_keypermod + i]))
+ modmap[keycode] |= 1<<j;
+ }
+ XFreeModifiermap(modifier_keymap);
+
+ keySyms.minKeyCode = min_keycode;
+ keySyms.maxKeyCode = max_keycode;
+ keySyms.mapWidth = mapWidth;
+ keySyms.map = keymap;
+
+ if (XkbQueryExtension(xnestDisplay, &op, &event, &error, &major, &minor) == 0) {
+ ErrorF("Unable to initialize XKEYBOARD extension.\n");
+ goto XkbError;
+ }
+ xkb = XkbGetKeyboard(xnestDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
+ if (xkb == NULL || xkb->geom == NULL) {
+ ErrorF("Couldn't get keyboard.\n");
+ goto XkbError;
+ }
+ XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb);
+
+ InitKeyboardDeviceStruct(pDev, NULL,
+ xnestBell, xnestChangeKeyboardControl);
+
+ XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode,
+ keySyms.maxKeyCode - keySyms.minKeyCode + 1,
+ modmap, serverClient);
+
+ XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls);
+ XkbFreeKeyboard(xkb, 0, False);
+ free(keymap);
+ break;
+ case DEVICE_ON:
+ xnestEventMask |= XNEST_KEYBOARD_EVENT_MASK;
+ for (i = 0; i < xnestNumScreens; i++)
+ XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
+ break;
+ case DEVICE_OFF:
+ xnestEventMask &= ~XNEST_KEYBOARD_EVENT_MASK;
+ for (i = 0; i < xnestNumScreens; i++)
+ XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
+ break;
+ case DEVICE_CLOSE:
+ break;
+ }
+ return Success;
+
+XkbError:
+ XGetKeyboardControl(xnestDisplay, &values);
+ memmove((char *)defaultKeyboardControl.autoRepeats,
+ (char *)values.auto_repeats,
+ sizeof(values.auto_repeats));
+
+ InitKeyboardDeviceStruct(pDev, NULL,
+ xnestBell, xnestChangeKeyboardControl);
+ free(keymap);
+ return Success;
+}
+
+Bool
+LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+ return TRUE;
+}
+
+void
+xnestUpdateModifierState(unsigned int state)
+{
+ DeviceIntPtr pDev = xnestKeyboardDevice;
+ KeyClassPtr keyc = pDev->key;
+ int i;
+ CARD8 mask;
+ int xkb_state;
+
+ if (!pDev)
+ return;
+
+ xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state);
+ state = state & 0xff;
+
+ if (xkb_state == state)
+ return;
+
+ for (i = 0, mask = 1; i < 8; i++, mask <<= 1) {
+ int key;
+
+ /* Modifier is down, but shouldn't be
+ */
+ if ((xkb_state & mask) && !(state & mask)) {
+ int count = keyc->modifierKeyCount[i];
+
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
+ if (key_is_down(pDev, key, KEY_PROCESSED))
+ xnestQueueKeyEvent(KeyRelease, key);
+
+ if (--count == 0)
+ break;
+ }
+ }
+
+ /* Modifier shoud be down, but isn't
+ */
+ if (!(xkb_state & mask) && (state & mask))
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
+ xnestQueueKeyEvent(KeyPress, key);
+ break;
+ }
+ }
+}
diff --git a/xorg-server/hw/xquartz/darwin.c b/xorg-server/hw/xquartz/darwin.c
index b483000f8..465a96d12 100644
--- a/xorg-server/hw/xquartz/darwin.c
+++ b/xorg-server/hw/xquartz/darwin.c
@@ -621,7 +621,7 @@ void OsVendorInit(void)
char *lf;
char *home = getenv("HOME");
assert(home);
- assert(0 < asprintf(&lf, "%s/Library/Logs/X11.%s.log", home, bundle_id_prefix));
+ assert(0 < asprintf(&lf, "%s/Library/Logs/%s.X11.log", home, bundle_id_prefix));
LogInit(lf, ".old");
free(lf);
diff --git a/xorg-server/hw/xquartz/xpr/appledri.c b/xorg-server/hw/xquartz/xpr/appledri.c
index 1304d5a43..6b4a8a383 100644
--- a/xorg-server/hw/xquartz/xpr/appledri.c
+++ b/xorg-server/hw/xquartz/xpr/appledri.c
@@ -2,7 +2,7 @@
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002, 2009 Apple Computer, Inc.
+Copyright (c) 2002, 2009-2011 Apple Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -102,6 +102,9 @@ ProcAppleDRIQueryVersion(
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
+ swaps(&rep.majorVersion);
+ swaps(&rep.minorVersion);
+ swapl(&rep.patchVersion);
}
WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep);
return Success;
@@ -133,6 +136,11 @@ ProcAppleDRIQueryDirectRenderingCapable(
if (!LocalClient(client))
rep.isCapable = 0;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ }
+
WriteToClient(client,
sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep);
return Success;
@@ -157,6 +165,13 @@ ProcAppleDRIAuthConnection(
ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic);
rep.authenticated = 0;
}
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.authenticated); /* Yes, this is a CARD32 ... sigh */
+ }
+
WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
return Success;
}
@@ -216,6 +231,14 @@ ProcAppleDRICreateSurface(
rep.key_1 = key[1];
rep.uid = sid;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.key_0);
+ swapl(&rep.key_1);
+ swapl(&rep.uid);
+ }
+
WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep);
return Success;
}
@@ -277,9 +300,8 @@ ProcAppleDRICreatePixmap(ClientPtr client)
rep.stringLength = strlen(path) + 1;
- /* No need for swapping, because this only runs if LocalClient is true. */
rep.type = X_Reply;
- rep.length = sizeof(rep) + rep.stringLength;
+ rep.length = bytes_to_int32(rep.stringLength);
rep.sequenceNumber = client->sequence;
rep.width = width;
rep.height = height;
@@ -290,8 +312,19 @@ ProcAppleDRICreatePixmap(ClientPtr client)
if(sizeof(rep) != sz_xAppleDRICreatePixmapReply)
ErrorF("error sizeof(rep) is %zu\n", sizeof(rep));
- WriteReplyToClient(client, sizeof(rep), &rep);
- (void)WriteToClient(client, rep.stringLength, path);
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.stringLength);
+ swapl(&rep.width);
+ swapl(&rep.height);
+ swapl(&rep.pitch);
+ swapl(&rep.bpp);
+ swapl(&rep.size);
+ }
+
+ WriteToClient(client, sizeof(rep), &rep);
+ WriteToClient(client, rep.stringLength, path);
return Success;
}
@@ -377,21 +410,107 @@ SProcAppleDRIQueryVersion(
}
static int
+SProcAppleDRIQueryDirectRenderingCapable(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleDRIQueryDirectRenderingCapableReq);
+ swaps(&stuff->length);
+ swapl(&stuff->screen);
+ return ProcAppleDRIQueryDirectRenderingCapable(client);
+}
+
+static int
+SProcAppleDRIAuthConnection(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleDRIAuthConnectionReq);
+ swaps(&stuff->length);
+ swapl(&stuff->screen);
+ swapl(&stuff->magic);
+ return ProcAppleDRIAuthConnection(client);
+}
+
+static int
+SProcAppleDRICreateSurface(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleDRICreateSurfaceReq);
+ swaps(&stuff->length);
+ swapl(&stuff->screen);
+ swapl(&stuff->drawable);
+ swapl(&stuff->client_id);
+ return ProcAppleDRICreateSurface(client);
+}
+
+static int
+SProcAppleDRIDestroySurface(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleDRIDestroySurfaceReq);
+ swaps(&stuff->length);
+ swapl(&stuff->screen);
+ swapl(&stuff->drawable);
+ return ProcAppleDRIDestroySurface(client);
+}
+
+static int
+SProcAppleDRICreatePixmap(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleDRICreatePixmapReq);
+ swaps(&stuff->length);
+ swapl(&stuff->screen);
+ swapl(&stuff->drawable);
+ return ProcAppleDRICreatePixmap(client);
+}
+
+static int
+SProcAppleDRIDestroyPixmap(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleDRIDestroyPixmapReq);
+ swaps(&stuff->length);
+ swapl(&stuff->drawable);
+ return ProcAppleDRIDestroyPixmap(client);
+}
+
+static int
SProcAppleDRIDispatch (
register ClientPtr client
)
{
REQUEST(xReq);
- /* It is bound to be non-local when there is byte swapping */
+ switch (stuff->data)
+ {
+ case X_AppleDRIQueryVersion:
+ return SProcAppleDRIQueryVersion(client);
+ case X_AppleDRIQueryDirectRenderingCapable:
+ return SProcAppleDRIQueryDirectRenderingCapable(client);
+ }
+
if (!LocalClient(client))
return DRIErrorBase + AppleDRIClientNotLocal;
- /* only local clients are allowed DRI access */
switch (stuff->data)
{
- case X_AppleDRIQueryVersion:
- return SProcAppleDRIQueryVersion(client);
+ case X_AppleDRIAuthConnection:
+ return SProcAppleDRIAuthConnection(client);
+ case X_AppleDRICreateSurface:
+ return SProcAppleDRICreateSurface(client);
+ case X_AppleDRIDestroySurface:
+ return SProcAppleDRIDestroySurface(client);
+ case X_AppleDRICreatePixmap:
+ return SProcAppleDRICreatePixmap(client);
+ case X_AppleDRIDestroyPixmap:
+ return SProcAppleDRIDestroyPixmap(client);
+
default:
return BadRequest;
}
diff --git a/xorg-server/hw/xquartz/xpr/appledristr.h b/xorg-server/hw/xquartz/xpr/appledristr.h
index c569719b7..b5ffe5b46 100644
--- a/xorg-server/hw/xquartz/xpr/appledristr.h
+++ b/xorg-server/hw/xquartz/xpr/appledristr.h
@@ -42,209 +42,225 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define APPLEDRINAME "Apple-DRI"
-#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */
+#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */
#define APPLE_DRI_MINOR_VERSION 0
#define APPLE_DRI_PATCH_VERSION 0
-typedef struct _AppleDRIQueryVersion {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIQueryVersion */
- CARD16 length B16;
+typedef struct _AppleDRIQueryVersion
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIQueryVersion */
+ CARD16 length B16;
} xAppleDRIQueryVersionReq;
#define sz_xAppleDRIQueryVersionReq 4
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD16 majorVersion B16; /* major version of DRI protocol */
- CARD16 minorVersion B16; /* minor version of DRI protocol */
- CARD32 patchVersion B32; /* patch version of DRI protocol */
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 majorVersion B16; /* major version of DRI protocol */
+ CARD16 minorVersion B16; /* minor version of DRI protocol */
+ CARD32 patchVersion B32; /* patch version of DRI protocol */
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xAppleDRIQueryVersionReply;
#define sz_xAppleDRIQueryVersionReply 32
-typedef struct _AppleDRIQueryDirectRenderingCapable {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
- CARD16 length B16;
- CARD32 screen B32;
+typedef struct _AppleDRIQueryDirectRenderingCapable
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
+ CARD16 length B16;
+ CARD32 screen B32;
} xAppleDRIQueryDirectRenderingCapableReq;
#define sz_xAppleDRIQueryDirectRenderingCapableReq 8
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- BOOL isCapable;
- BOOL pad2;
- BOOL pad3;
- BOOL pad4;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
- CARD32 pad7 B32;
- CARD32 pad8 B32;
- CARD32 pad9 B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ BOOL isCapable;
+ BOOL pad2;
+ BOOL pad3;
+ BOOL pad4;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+ CARD32 pad9 B32;
} xAppleDRIQueryDirectRenderingCapableReply;
#define sz_xAppleDRIQueryDirectRenderingCapableReply 32
-typedef struct _AppleDRIAuthConnection {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICloseConnection */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 magic B32;
+typedef struct _AppleDRIAuthConnection
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 magic B32;
} xAppleDRIAuthConnectionReq;
#define sz_xAppleDRIAuthConnectionReq 12
-typedef struct {
- BYTE type;
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 authenticated B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct
+{
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 authenticated B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xAppleDRIAuthConnectionReply;
#define zx_xAppleDRIAuthConnectionReply 32
-typedef struct _AppleDRICreateSurface {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICreateSurface */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
- CARD32 client_id B32;
+typedef struct _AppleDRICreateSurface
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateSurface */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+ CARD32 client_id B32;
} xAppleDRICreateSurfaceReq;
#define sz_xAppleDRICreateSurfaceReq 16
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 key_0 B32;
- CARD32 key_1 B32;
- CARD32 uid B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 key_0 B32;
+ CARD32 key_1 B32;
+ CARD32 uid B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xAppleDRICreateSurfaceReply;
#define sz_xAppleDRICreateSurfaceReply 32
-typedef struct _AppleDRIDestroySurface {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIDestroySurface */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
+typedef struct _AppleDRIDestroySurface
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroySurface */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
} xAppleDRIDestroySurfaceReq;
#define sz_xAppleDRIDestroySurfaceReq 12
-typedef struct _AppleDRINotify {
- BYTE type; /* always eventBase + event type */
- BYTE kind;
- CARD16 sequenceNumber B16;
- CARD32 time B32; /* time of change */
- CARD32 pad1 B32;
- CARD32 arg B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct _AppleDRINotify
+{
+ BYTE type; /* always eventBase + event type */
+ BYTE kind;
+ CARD16 sequenceNumber B16;
+ CARD32 time B32; /* time of change */
+ CARD32 pad1 B32;
+ CARD32 arg B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xAppleDRINotifyEvent;
#define sz_xAppleDRINotifyEvent 32
-typedef struct {
- CARD8 reqType;
- CARD8 driReqType;
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
- BOOL doubleSwap;
- CARD8 pad1, pad2, pad3;
+typedef struct
+{
+ CARD8 reqType;
+ CARD8 driReqType;
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+ BOOL doubleSwap;
+ CARD8 pad1, pad2, pad3;
} xAppleDRICreateSharedBufferReq;
#define sz_xAppleDRICreateSharedBufferReq 16
-typedef struct {
- BYTE type;
- BYTE data1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 stringLength B32; /* 0 on error */
- CARD32 width B32;
- CARD32 height B32;
- CARD32 pad1 B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
+typedef struct
+{
+ BYTE type;
+ BYTE data1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 stringLength B32; /* 0 on error */
+ CARD32 width B32;
+ CARD32 height B32;
+ CARD32 pad1 B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
} xAppleDRICreateSharedBufferReply;
#define sz_xAppleDRICreateSharedBufferReply 32
-typedef struct {
- CARD8 reqType;
- CARD8 driReqType;
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
+typedef struct
+{
+ CARD8 reqType;
+ CARD8 driReqType;
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
} xAppleDRISwapBuffersReq;
#define sz_xAppleDRISwapBuffersReq 12
-typedef struct {
- CARD8 reqType; /*1*/
- CARD8 driReqType; /*2*/
- CARD16 length B16; /*4*/
- CARD32 screen B32; /*8*/
- CARD32 drawable B32; /*12*/
+typedef struct
+{
+ CARD8 reqType; /*1 */
+ CARD8 driReqType; /*2 */
+ CARD16 length B16; /*4 */
+ CARD32 screen B32; /*8 */
+ CARD32 drawable B32; /*12 */
} xAppleDRICreatePixmapReq;
#define sz_xAppleDRICreatePixmapReq 12
-typedef struct {
- BYTE type; /*1*/
- BOOL pad1; /*2*/
- CARD16 sequenceNumber B16; /*4*/
- CARD32 length B32; /*8*/
- CARD32 width B32; /*12*/
- CARD32 height B32; /*16*/
- CARD32 pitch B32; /*20*/
- CARD32 bpp B32; /*24*/
- CARD32 size B32; /*28*/
- CARD32 stringLength B32; /*32*/
+typedef struct
+{
+ BYTE type; /*1 */
+ BOOL pad1; /*2 */
+ CARD16 sequenceNumber B16; /*4 */
+ CARD32 length B32; /*8 */
+ CARD32 width B32; /*12 */
+ CARD32 height B32; /*16 */
+ CARD32 pitch B32; /*20 */
+ CARD32 bpp B32; /*24 */
+ CARD32 size B32; /*28 */
+ CARD32 stringLength B32; /*32 */
} xAppleDRICreatePixmapReply;
#define sz_xAppleDRICreatePixmapReply 32
-typedef struct {
- CARD8 reqType; /*1*/
- CARD8 driReqType; /*2*/
- CARD16 length B16; /*4*/
- CARD32 drawable B32; /*8*/
+typedef struct
+{
+ CARD8 reqType; /*1 */
+ CARD8 driReqType; /*2 */
+ CARD16 length B16; /*4 */
+ CARD32 drawable B32; /*8 */
} xAppleDRIDestroyPixmapReq;
#define sz_xAppleDRIDestroyPixmapReq 8
#ifdef _APPLEDRI_SERVER_
-void AppleDRISendEvent (
+void AppleDRISendEvent(
#if NeedFunctionPrototypes
- int /* type */,
- unsigned int /* mask */,
- int /* which */,
- int /* arg */
+ int /* type */ ,
+ unsigned int /* mask */ ,
+ int /* which */ ,
+ int /* arg */
#endif
-);
+ );
#endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRISTR_H_ */
diff --git a/xorg-server/hw/xwin/man/XWinrc.man b/xorg-server/hw/xwin/man/XWinrc.man
index e4c454fba..71d8dad23 100644
--- a/xorg-server/hw/xwin/man/XWinrc.man
+++ b/xorg-server/hw/xwin/man/XWinrc.man
@@ -88,15 +88,15 @@ this may be useful if you want no dialogs.
This instruction defines a menu and asigns a \fIMenu_Name\fP to it.
\fIMenu_Item_Line\fP are lines of any of the following types:
.TP 8
-.B \t SEPARATOR
+.B SEPARATOR
.TP 8
-.B \t \fIItem_Label\fP EXEC \fICommand\fP
+.B \fIItem_Label\fP EXEC \fICommand\fP
.TP 8
-.B \t \fIItem_Label\fP MENU \fIpreviously-defined-menu-name\fP
+.B \fIItem_Label\fP MENU \fIpreviously-defined-menu-name\fP
.TP 8
-.B \t \fIItem_Label\fP ALWAYSONTOP
+.B \fIItem_Label\fP ALWAYSONTOP
.TP 8
-.B \t \fIItem_Label\fP RELOAD
+.B \fIItem_Label\fP RELOAD
.br
The \fIItem_Label\fP is the string that is written in the menu item.
.br
diff --git a/xorg-server/include/eventstr.h b/xorg-server/include/eventstr.h
index 2de077fd2..4d836fb14 100644
--- a/xorg-server/include/eventstr.h
+++ b/xorg-server/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/xorg-server/include/exevents.h b/xorg-server/include/exevents.h
index 4fe6c61a9..720fb2e5a 100644
--- a/xorg-server/include/exevents.h
+++ b/xorg-server/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/xorg-server/include/input.h b/xorg-server/include/input.h
index b7de5ca3d..4eee47ce4 100644
--- a/xorg-server/include/input.h
+++ b/xorg-server/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,
@@ -597,6 +598,10 @@ extern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest,
extern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum);
extern _X_EXPORT double valuator_mask_get_double(const ValuatorMask *mask,
int valnum);
+extern _X_EXPORT Bool valuator_mask_fetch(const ValuatorMask *mask,
+ int valnum, int *val);
+extern _X_EXPORT Bool valuator_mask_fetch_double(const ValuatorMask *mask,
+ int valnum, double *val);
/* InputOption handling interface */
extern _X_EXPORT InputOption* input_option_new(InputOption *list, const char *key, const char *value);
diff --git a/xorg-server/include/inputstr.h b/xorg-server/include/inputstr.h
index 9d4108ef5..7a1554075 100644
--- a/xorg-server/include/inputstr.h
+++ b/xorg-server/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/xorg-server/include/list.h b/xorg-server/include/list.h
index 7825dce52..4706e178b 100644
--- a/xorg-server/include/list.h
+++ b/xorg-server/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/xorg-server/include/optionstr.h b/xorg-server/include/optionstr.h
new file mode 100644
index 000000000..a71d245fa
--- /dev/null
+++ b/xorg-server/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/xorg-server/man/Xserver.man b/xorg-server/man/Xserver.man
index 02cca5263..0cd9b941c 100644
--- a/xorg-server/man/Xserver.man
+++ b/xorg-server/man/Xserver.man
@@ -100,6 +100,12 @@ specifies a file which contains a collection of authorization records used
to authenticate access. See also the \fIxdm\fP(1) and
\fIXsecurity\fP(__miscmansuffix__) manual pages.
.TP 8
+.BI \-background\ none
+Asks the driver not to clear the background on startup, if the driver supports that.
+May be useful for smooth transition with eg. fbdev driver.
+For security reasons this is not the default as the screen contents might
+show a previous user session.
+.TP 8
.B \-br
sets the default root window to solid black instead of the standard root weave
pattern. This is the default unless -retro or -wr is specified.
diff --git a/xorg-server/mi/mieq.c b/xorg-server/mi/mieq.c
index 7cc0e7c51..3d51a567b 100644
--- a/xorg-server/mi/mieq.c
+++ b/xorg-server/mi/mieq.c
@@ -59,7 +59,12 @@ in this Software without prior written authorization from The Open Group.
# include <X11/extensions/dpmsconst.h>
#endif
-#define QUEUE_SIZE 512
+/* Maximum size should be initial size multiplied by a power of 2 */
+#define QUEUE_INITIAL_SIZE 256
+#define QUEUE_RESERVED_SIZE 64
+#define QUEUE_MAXIMUM_SIZE 4096
+#define QUEUE_DROP_BACKTRACE_FREQUENCY 100
+#define QUEUE_DROP_BACKTRACE_MAX 10
#define EnqueueScreen(dev) dev->spriteInfo->sprite->pEnqueueScreen
#define DequeueScreen(dev) dev->spriteInfo->sprite->pDequeueScreen
@@ -74,7 +79,9 @@ typedef struct _EventQueue {
HWEventQueueType head, tail; /* long for SetInputCheck */
CARD32 lastEventTime; /* to avoid time running backwards */
int lastMotion; /* device ID if last event motion? */
- EventRec events[QUEUE_SIZE]; /* static allocation for signals */
+ EventRec *events; /* our queue as an array */
+ size_t nevents; /* the number of buckets in our queue */
+ size_t dropped; /* counter for number of consecutive dropped events */
mieqHandler handlers[128]; /* custom event handler */
} EventQueueRec, *EventQueuePtr;
@@ -99,25 +106,87 @@ static inline void wait_for_server_init(void) {
}
#endif
+static size_t
+mieqNumEnqueued(EventQueuePtr eventQueue) {
+ size_t n_enqueued = 0;
+ if (eventQueue->nevents) {
+ /* % is not well-defined with negative numbers... sigh */
+ n_enqueued = eventQueue->tail - eventQueue->head + eventQueue->nevents;
+ if (n_enqueued >= eventQueue->nevents)
+ n_enqueued -= eventQueue->nevents;
+ }
+ return n_enqueued;
+}
+
+/* Pre-condition: Called with miEventQueueMutex held */
+static Bool
+mieqGrowQueue(EventQueuePtr eventQueue, size_t new_nevents) {
+ size_t i, n_enqueued, first_hunk;
+ EventRec *new_events;
+
+ if (!eventQueue) {
+ ErrorF("[mi] mieqGrowQueue called with a NULL eventQueue\n");
+ return FALSE;
+ }
+
+ if (new_nevents <= eventQueue->nevents)
+ return FALSE;
+
+ new_events = calloc(new_nevents, sizeof(EventRec));
+ if (new_events == NULL) {
+ ErrorF("[mi] mieqGrowQueue memory allocation error.\n");
+ return FALSE;
+ }
+
+ n_enqueued = mieqNumEnqueued(eventQueue);
+
+ /* We block signals, so an mieqEnqueue triggered by SIGIO does not
+ * write to our queue as we are modifying it.
+ */
+ OsBlockSignals();
+
+ /* First copy the existing events */
+ first_hunk = eventQueue->nevents - eventQueue->head;
+ memcpy(new_events,
+ &eventQueue->events[eventQueue->head],
+ first_hunk * sizeof(EventRec));
+ memcpy(&new_events[first_hunk],
+ eventQueue->events,
+ eventQueue->head * sizeof(EventRec));
+
+ /* Initialize the new portion */
+ for (i = eventQueue->nevents; i < new_nevents; i++) {
+ InternalEvent* evlist = InitEventList(1);
+ if (!evlist) {
+ size_t j;
+ for (j = 0; j < i; j++)
+ FreeEventList(new_events[j].events, 1);
+ free(new_events);
+ OsReleaseSignals();
+ return FALSE;
+ }
+ new_events[i].events = evlist;
+ }
+
+ /* And update our record */
+ eventQueue->tail = n_enqueued;
+ eventQueue->head = 0;
+ eventQueue->nevents = new_nevents;
+ free(eventQueue->events);
+ eventQueue->events = new_events;
+
+ OsReleaseSignals();
+ return TRUE;
+}
+
Bool
mieqInit(void)
{
- int i;
-
- miEventQueue.head = miEventQueue.tail = 0;
+ memset(&miEventQueue, 0, sizeof(miEventQueue));
miEventQueue.lastEventTime = GetTimeInMillis ();
- miEventQueue.lastMotion = FALSE;
- for (i = 0; i < 128; i++)
- miEventQueue.handlers[i] = NULL;
- for (i = 0; i < QUEUE_SIZE; i++)
- {
- if (miEventQueue.events[i].events == NULL) {
- InternalEvent* evlist = InitEventList(1);
- if (!evlist)
- FatalError("Could not allocate event queue.\n");
- miEventQueue.events[i].events = evlist;
- }
- }
+
+ if(!mieqGrowQueue(&miEventQueue, QUEUE_INITIAL_SIZE))
+ FatalError("Could not allocate event queue.\n");
SetInputCheck(&miEventQueue.head, &miEventQueue.tail);
return TRUE;
@@ -127,13 +196,34 @@ void
mieqFini(void)
{
int i;
- for (i = 0; i < QUEUE_SIZE; i++)
+ for (i = 0; i < miEventQueue.nevents; i++)
{
if (miEventQueue.events[i].events != NULL) {
FreeEventList(miEventQueue.events[i].events, 1);
miEventQueue.events[i].events = NULL;
}
}
+ free(miEventQueue.events);
+}
+
+/* This function will determine if the given event is allowed to used the reserved
+ * queue space.
+ */
+static Bool
+mieqReservedCandidate(InternalEvent *e) {
+ switch(e->any.type) {
+ case ET_KeyRelease:
+ case ET_ButtonRelease:
+#if XFreeXDGA
+ case ET_DGAEvent:
+#endif
+ case ET_RawKeyRelease:
+ case ET_RawButtonRelease:
+ case ET_XQuartz:
+ return TRUE;
+ default:
+ return FALSE;
+ }
}
/*
@@ -151,6 +241,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
int isMotion = 0;
int evlen;
Time time;
+ size_t n_enqueued;
#ifdef XQUARTZ
wait_for_server_init();
@@ -159,32 +250,40 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
verify_internal_event(e);
+ n_enqueued = mieqNumEnqueued(&miEventQueue);
+
/* avoid merging events from different devices */
if (e->any.type == ET_Motion)
isMotion = pDev->id;
if (isMotion && isMotion == miEventQueue.lastMotion &&
oldtail != miEventQueue.head) {
- oldtail = (oldtail - 1) % QUEUE_SIZE;
- }
- else {
- static int stuck = 0;
+ oldtail = (oldtail - 1) % miEventQueue.nevents;
+ } else if ((n_enqueued + 1 == miEventQueue.nevents) ||
+ ((n_enqueued + 1 >= miEventQueue.nevents - QUEUE_RESERVED_SIZE) && !mieqReservedCandidate(e))) {
/* Toss events which come in late. Usually this means your server's
* stuck in an infinite loop somewhere, but SIGIO is still getting
- * handled. */
- if (((oldtail + 1) % QUEUE_SIZE) == miEventQueue.head) {
- if (!stuck) {
- ErrorF("[mi] EQ overflowing. The server is probably stuck "
- "in an infinite loop.\n");
- xorg_backtrace();
- stuck = 1;
+ * handled.
+ */
+ miEventQueue.dropped++;
+ if (miEventQueue.dropped == 1) {
+ ErrorF("[mi] EQ overflowing. Additional events will be discarded until existing events are processed.\n");
+ xorg_backtrace();
+ ErrorF("[mi] These backtraces from mieqEnqueue may point to a culprit higher up the stack.\n");
+ ErrorF("[mi] mieq is *NOT* the cause. It is a victim.\n");
+ } else if (miEventQueue.dropped % QUEUE_DROP_BACKTRACE_FREQUENCY == 0 &&
+ miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY <= QUEUE_DROP_BACKTRACE_MAX) {
+ ErrorF("[mi] EQ overflow continuing. %lu events have been dropped.\n", miEventQueue.dropped);
+ if (miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY == QUEUE_DROP_BACKTRACE_MAX) {
+ ErrorF("[mi] No further overflow reports will be reported until the clog is cleared.\n");
}
+ xorg_backtrace();
+ }
+
#ifdef XQUARTZ
- pthread_mutex_unlock(&miEventQueueMutex);
+ pthread_mutex_unlock(&miEventQueueMutex);
#endif
- return;
- }
- stuck = 0;
+ return;
}
evlen = e->any.length;
@@ -203,7 +302,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
miEventQueue.events[oldtail].pDev = pDev;
miEventQueue.lastMotion = isMotion;
- miEventQueue.tail = (oldtail + 1) % QUEUE_SIZE;
+ miEventQueue.tail = (oldtail + 1) % miEventQueue.nevents;
#ifdef XQUARTZ
pthread_mutex_unlock(&miEventQueueMutex);
#endif
@@ -437,11 +536,28 @@ mieqProcessInputEvents(void)
static InternalEvent event;
DeviceIntPtr dev = NULL,
master = NULL;
+ size_t n_enqueued;
#ifdef XQUARTZ
pthread_mutex_lock(&miEventQueueMutex);
#endif
-
+
+ /* Grow our queue if we are reaching capacity: < 2 * QUEUE_RESERVED_SIZE remaining */
+ n_enqueued = mieqNumEnqueued(&miEventQueue);
+ if (n_enqueued >= (miEventQueue.nevents - (2 * QUEUE_RESERVED_SIZE)) &&
+ miEventQueue.nevents < QUEUE_MAXIMUM_SIZE) {
+ ErrorF("[mi] Increasing EQ size to %lu to prevent dropped events.\n", miEventQueue.nevents << 1);
+ if (!mieqGrowQueue(&miEventQueue, miEventQueue.nevents << 1)) {
+ ErrorF("[mi] Increasing the size of EQ failed.\n");
+ }
+ }
+
+ if (miEventQueue.dropped) {
+ ErrorF("[mi] EQ processing has resumed after %lu dropped events.\n", miEventQueue.dropped);
+ ErrorF("[mi] This may be caused my a misbehaving driver monopolizing the server's resources.\n");
+ miEventQueue.dropped = 0;
+ }
+
while (miEventQueue.head != miEventQueue.tail) {
e = &miEventQueue.events[miEventQueue.head];
@@ -449,7 +565,7 @@ mieqProcessInputEvents(void)
dev = e->pDev;
screen = e->pScreen;
- miEventQueue.head = (miEventQueue.head + 1) % QUEUE_SIZE;
+ miEventQueue.head = (miEventQueue.head + 1) % miEventQueue.nevents;
#ifdef XQUARTZ
pthread_mutex_unlock(&miEventQueueMutex);
diff --git a/xorg-server/randr/rrproperty.c b/xorg-server/randr/rrproperty.c
index 6ed24d3aa..d0a90203b 100644
--- a/xorg-server/randr/rrproperty.c
+++ b/xorg-server/randr/rrproperty.c
@@ -549,18 +549,31 @@ int
ProcRRDeleteOutputProperty (ClientPtr client)
{
REQUEST(xRRDeleteOutputPropertyReq);
- RROutputPtr output;
-
+ RROutputPtr output;
+ RRPropertyPtr prop;
+
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
UpdateCurrentTime();
VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
-
+
if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
return BadAtom;
}
+ prop = RRQueryOutputProperty(output, stuff->property);
+ if (!prop)
+ {
+ client->errorValue = stuff->property;
+ return BadName;
+ }
+
+ if (prop->immutable)
+ {
+ client->errorValue = stuff->property;
+ return BadAccess;
+ }
RRDeleteOutputProperty(output, stuff->property);
return Success;
diff --git a/xorg-server/render/mipict.c b/xorg-server/render/mipict.c
index 61b368472..caa76e396 100644
--- a/xorg-server/render/mipict.c
+++ b/xorg-server/render/mipict.c
@@ -569,6 +569,64 @@ miRenderPixelToColor (PictFormatPtr format,
}
}
+void
+miTriStrip (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoints,
+ xPointFixed *points)
+{
+ xTriangle *tris, *tri;
+ int ntri;
+
+ ntri = npoints - 2;
+ tris = malloc(ntri * sizeof (xTriangle));
+ if (!tris)
+ return;
+
+ for (tri = tris; npoints >= 3; npoints--, points++, tri++)
+ {
+ tri->p1 = points[0];
+ tri->p2 = points[1];
+ tri->p3 = points[2];
+ }
+ CompositeTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
+ free(tris);
+}
+
+void
+miTriFan (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoints,
+ xPointFixed *points)
+{
+ xTriangle *tris, *tri;
+ xPointFixed *first;
+ int ntri;
+
+ ntri = npoints - 2;
+ tris = malloc(ntri * sizeof (xTriangle));
+ if (!tris)
+ return;
+
+ first = points++;
+ for (tri = tris; npoints >= 3; npoints--, points++, tri++)
+ {
+ tri->p1 = *first;
+ tri->p2 = points[0];
+ tri->p3 = points[1];
+ }
+ CompositeTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
+ free(tris);
+}
+
Bool
miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
{
@@ -602,5 +660,8 @@ miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
ps->AddTraps = 0; /* requires DDX support */
ps->AddTriangles = 0; /* requires DDX support */
+ ps->TriStrip = miTriStrip; /* converts call to CompositeTriangles */
+ ps->TriFan = miTriFan;
+
return TRUE;
}
diff --git a/xorg-server/render/mipict.h b/xorg-server/render/mipict.h
index f2df601e4..4399a6fad 100644
--- a/xorg-server/render/mipict.h
+++ b/xorg-server/render/mipict.h
@@ -1,165 +1,185 @@
-/*
- *
- * Copyright © 2000 SuSE, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. SuSE makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Keith Packard, SuSE, Inc.
- */
-
-#ifndef _MIPICT_H_
-#define _MIPICT_H_
-
-#include "picturestr.h"
-
-#define MI_MAX_INDEXED 256 /* XXX depth must be <= 8 */
-
-#if MI_MAX_INDEXED <= 256
-typedef CARD8 miIndexType;
-#endif
-
-typedef struct _miIndexed {
- Bool color;
- CARD32 rgba[MI_MAX_INDEXED];
- miIndexType ent[32768];
-} miIndexedRec, *miIndexedPtr;
-
-#define miCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
- (((s) >> 6) & 0x03e0) | \
- (((s) >> 9) & 0x7c00))
-#define miIndexToEnt15(mif,rgb15) ((mif)->ent[rgb15])
-#define miIndexToEnt24(mif,rgb24) miIndexToEnt15(mif,miCvtR8G8B8to15(rgb24))
-
-#define miIndexToEntY24(mif,rgb24) ((mif)->ent[CvtR8G8B8toY15(rgb24)])
-
-extern _X_EXPORT int
-miCreatePicture (PicturePtr pPicture);
-
-extern _X_EXPORT void
-miDestroyPicture (PicturePtr pPicture);
-
-extern _X_EXPORT void
-miDestroyPictureClip (PicturePtr pPicture);
-
-extern _X_EXPORT int
-miChangePictureClip (PicturePtr pPicture,
- int type,
- pointer value,
- int n);
-
-extern _X_EXPORT void
-miChangePicture (PicturePtr pPicture,
- Mask mask);
-
-extern _X_EXPORT void
-miValidatePicture (PicturePtr pPicture,
- Mask mask);
-
-extern _X_EXPORT int
-miChangePictureTransform (PicturePtr pPicture,
- PictTransform *transform);
-
-extern _X_EXPORT int
-miChangePictureFilter (PicturePtr pPicture,
- int filter,
- xFixed *params,
- int nparams);
-
-extern _X_EXPORT void
-miCompositeSourceValidate (PicturePtr pPicture);
-
-extern _X_EXPORT Bool
-miComputeCompositeRegion (RegionPtr pRegion,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height);
-
-extern _X_EXPORT Bool
-miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
-
-extern _X_EXPORT Bool
-miRealizeGlyph (ScreenPtr pScreen,
- GlyphPtr glyph);
-
-extern _X_EXPORT void
-miUnrealizeGlyph (ScreenPtr pScreen,
- GlyphPtr glyph);
-
-extern _X_EXPORT void
-miGlyphs (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs);
-
-extern _X_EXPORT void
-miRenderColorToPixel (PictFormatPtr pPict,
- xRenderColor *color,
- CARD32 *pixel);
-
-extern _X_EXPORT void
-miRenderPixelToColor (PictFormatPtr pPict,
- CARD32 pixel,
- xRenderColor *color);
-
-extern _X_EXPORT Bool
-miIsSolidAlpha (PicturePtr pSrc);
-
-extern _X_EXPORT void
-miCompositeRects (CARD8 op,
- PicturePtr pDst,
- xRenderColor *color,
- int nRect,
- xRectangle *rects);
-
-extern _X_EXPORT void
-miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box);
-
-extern _X_EXPORT void
-miPointFixedBounds (int npoint, xPointFixed *points, BoxPtr bounds);
-
-extern _X_EXPORT void
-miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds);
-
-extern _X_EXPORT Bool
-miInitIndexed (ScreenPtr pScreen,
- PictFormatPtr pFormat);
-
-extern _X_EXPORT void
-miCloseIndexed (ScreenPtr pScreen,
- PictFormatPtr pFormat);
-
-extern _X_EXPORT void
-miUpdateIndexed (ScreenPtr pScreen,
- PictFormatPtr pFormat,
- int ndef,
- xColorItem *pdef);
-
-#endif /* _MIPICT_H_ */
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _MIPICT_H_
+#define _MIPICT_H_
+
+#include "picturestr.h"
+
+#define MI_MAX_INDEXED 256 /* XXX depth must be <= 8 */
+
+#if MI_MAX_INDEXED <= 256
+typedef CARD8 miIndexType;
+#endif
+
+typedef struct _miIndexed {
+ Bool color;
+ CARD32 rgba[MI_MAX_INDEXED];
+ miIndexType ent[32768];
+} miIndexedRec, *miIndexedPtr;
+
+#define miCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
+ (((s) >> 6) & 0x03e0) | \
+ (((s) >> 9) & 0x7c00))
+#define miIndexToEnt15(mif,rgb15) ((mif)->ent[rgb15])
+#define miIndexToEnt24(mif,rgb24) miIndexToEnt15(mif,miCvtR8G8B8to15(rgb24))
+
+#define miIndexToEntY24(mif,rgb24) ((mif)->ent[CvtR8G8B8toY15(rgb24)])
+
+extern _X_EXPORT int
+miCreatePicture (PicturePtr pPicture);
+
+extern _X_EXPORT void
+miDestroyPicture (PicturePtr pPicture);
+
+extern _X_EXPORT void
+miDestroyPictureClip (PicturePtr pPicture);
+
+extern _X_EXPORT int
+miChangePictureClip (PicturePtr pPicture,
+ int type,
+ pointer value,
+ int n);
+
+extern _X_EXPORT void
+miChangePicture (PicturePtr pPicture,
+ Mask mask);
+
+extern _X_EXPORT void
+miValidatePicture (PicturePtr pPicture,
+ Mask mask);
+
+extern _X_EXPORT int
+miChangePictureTransform (PicturePtr pPicture,
+ PictTransform *transform);
+
+extern _X_EXPORT int
+miChangePictureFilter (PicturePtr pPicture,
+ int filter,
+ xFixed *params,
+ int nparams);
+
+extern _X_EXPORT void
+miCompositeSourceValidate (PicturePtr pPicture);
+
+extern _X_EXPORT Bool
+miComputeCompositeRegion (RegionPtr pRegion,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+extern _X_EXPORT Bool
+miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+
+extern _X_EXPORT Bool
+miRealizeGlyph (ScreenPtr pScreen,
+ GlyphPtr glyph);
+
+extern _X_EXPORT void
+miUnrealizeGlyph (ScreenPtr pScreen,
+ GlyphPtr glyph);
+
+extern _X_EXPORT void
+miGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs);
+
+extern _X_EXPORT void
+miRenderColorToPixel (PictFormatPtr pPict,
+ xRenderColor *color,
+ CARD32 *pixel);
+
+extern _X_EXPORT void
+miRenderPixelToColor (PictFormatPtr pPict,
+ CARD32 pixel,
+ xRenderColor *color);
+
+extern _X_EXPORT Bool
+miIsSolidAlpha (PicturePtr pSrc);
+
+extern _X_EXPORT void
+miCompositeRects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects);
+
+extern _X_EXPORT void
+miTriStrip (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoints,
+ xPointFixed *points);
+
+extern _X_EXPORT void
+miTriFan (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoints,
+ xPointFixed *points);
+
+extern _X_EXPORT void
+miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box);
+
+extern _X_EXPORT void
+miPointFixedBounds (int npoint, xPointFixed *points, BoxPtr bounds);
+
+extern _X_EXPORT void
+miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds);
+
+extern _X_EXPORT Bool
+miInitIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat);
+
+extern _X_EXPORT void
+miCloseIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat);
+
+extern _X_EXPORT void
+miUpdateIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat,
+ int ndef,
+ xColorItem *pdef);
+
+#endif /* _MIPICT_H_ */
diff --git a/xorg-server/render/picture.c b/xorg-server/render/picture.c
index 5640c4d96..f13459665 100644
--- a/xorg-server/render/picture.c
+++ b/xorg-server/render/picture.c
@@ -1715,23 +1715,14 @@ CompositeTriStrip (CARD8 op,
int npoints,
xPointFixed *points)
{
- xTriangle *tris, *tri;
- int ntri;
-
+ PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
+
if (npoints < 3)
return;
- ntri = npoints - 2;
- tris = malloc(ntri * sizeof (xTriangle));
- if (!tris)
- return;
- for (tri = tris; npoints >= 3; npoints--, points++, tri++)
- {
- tri->p1 = points[0];
- tri->p2 = points[1];
- tri->p3 = points[2];
- }
- CompositeTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
- free(tris);
+
+ ValidatePicture (pSrc);
+ ValidatePicture (pDst);
+ (*ps->TriStrip) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points);
}
void
@@ -1744,25 +1735,14 @@ CompositeTriFan (CARD8 op,
int npoints,
xPointFixed *points)
{
- xTriangle *tris, *tri;
- xPointFixed *first;
- int ntri;
-
+ PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
+
if (npoints < 3)
return;
- ntri = npoints - 2;
- tris = malloc(ntri * sizeof (xTriangle));
- if (!tris)
- return;
- first = points++;
- for (tri = tris; npoints >= 3; npoints--, points++, tri++)
- {
- tri->p1 = *first;
- tri->p2 = points[0];
- tri->p3 = points[1];
- }
- CompositeTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
- free(tris);
+
+ ValidatePicture (pSrc);
+ ValidatePicture (pDst);
+ (*ps->TriFan) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points);
}
void
diff --git a/xorg-server/render/picturestr.h b/xorg-server/render/picturestr.h
index 7b7f9112d..1f3f5a433 100644
--- a/xorg-server/render/picturestr.h
+++ b/xorg-server/render/picturestr.h
@@ -260,6 +260,24 @@ typedef void (*TrianglesProcPtr) (CARD8 op,
int ntri,
xTriangle *tris);
+typedef void (*TriStripProcPtr) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points);
+
+typedef void (*TriFanProcPtr) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points);
+
typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen,
PictFormatPtr pFormat);
@@ -348,6 +366,9 @@ typedef struct _PictureScreen {
RealizeGlyphProcPtr RealizeGlyph;
UnrealizeGlyphProcPtr UnrealizeGlyph;
+#define PICTURE_SCREEN_VERSION 2
+ TriStripProcPtr TriStrip;
+ TriFanProcPtr TriFan;
} PictureScreenRec, *PictureScreenPtr;
extern _X_EXPORT DevPrivateKeyRec PictureScreenPrivateKeyRec;
diff --git a/xorg-server/test/input.c b/xorg-server/test/input.c
index bc41c226d..5b4c8c193 100644
--- a/xorg-server/test/input.c
+++ b/xorg-server/test/input.c
@@ -40,6 +40,7 @@
#include "dixgrabs.h"
#include "eventstr.h"
#include "inpututils.h"
+#include "mi.h"
#include "assert.h"
/**
@@ -1199,14 +1200,19 @@ static void dix_input_valuator_masks(void)
assert(valuator_mask_num_valuators(mask) == num_vals);
for (i = 0; i < nvaluators; i++)
{
+ double val;
if (i < first_val || i >= first_val + num_vals)
+ {
assert(!valuator_mask_isset(mask, i));
- else
+ assert(!valuator_mask_fetch_double(mask, i, &val));
+ } else
{
assert(valuator_mask_isset(mask, i));
assert(valuator_mask_get(mask, i) == val_ranged[i - first_val]);
assert(valuator_mask_get_double(mask, i) ==
val_ranged[i - first_val]);
+ assert(valuator_mask_fetch_double(mask, i, &val));
+ assert(val_ranged[i - first_val] == val);
}
}
@@ -1218,10 +1224,18 @@ static void dix_input_valuator_masks(void)
for (i = 0; i < nvaluators; i++)
{
+ double a, b;
assert(valuator_mask_isset(mask, i) == valuator_mask_isset(copy, i));
+
+ if (!valuator_mask_isset(mask, i))
+ continue;
+
assert(valuator_mask_get(mask, i) == valuator_mask_get(copy, i));
assert(valuator_mask_get_double(mask, i) ==
valuator_mask_get_double(copy, i));
+ assert(valuator_mask_fetch_double(mask, i, &a));
+ assert(valuator_mask_fetch_double(copy, i, &b));
+ assert(a == b);
}
valuator_mask_free(&mask);
@@ -1467,8 +1481,6 @@ _test_double_fp16_values(double orig_d)
{
FP1616 first_fp16, final_fp16;
double final_d;
- char first_fp16_s[64];
- char final_fp16_s[64];
if (orig_d > 0x7FFF) {
printf("Test out of range\n");
@@ -1479,10 +1491,15 @@ _test_double_fp16_values(double orig_d)
final_d = fp1616_to_double(first_fp16);
final_fp16 = double_to_fp1616(final_d);
- snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff);
- snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff);
-
- printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s);
+ /* {
+ * char first_fp16_s[64];
+ * char final_fp16_s[64];
+ * snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff);
+ * snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff);
+ *
+ * printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s);
+ * }
+ */
/* since we lose precision, we only do rough range testing */
assert(final_d > orig_d - 0.1);
@@ -1590,6 +1607,73 @@ dix_double_fp_conversion(void)
}
}
+/* The mieq test verifies that events added to the queue come out in the same
+ * order that they went in.
+ */
+static uint32_t mieq_test_event_last_processed;
+
+static void
+mieq_test_event_handler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) {
+ RawDeviceEvent *e = (RawDeviceEvent *)ie;
+
+ assert(e->type == ET_RawMotion);
+ assert(e->flags > mieq_test_event_last_processed);
+ mieq_test_event_last_processed = e->flags;
+}
+
+static void _mieq_test_generate_events(uint32_t start, uint32_t count) {
+ count += start;
+ while (start < count) {
+ RawDeviceEvent e = {0};
+ e.header = ET_Internal;
+ e.type = ET_RawMotion;
+ e.length = sizeof(e);
+ e.time = GetTimeInMillis();
+ e.flags = start;
+
+ mieqEnqueue(NULL, (InternalEvent*)&e);
+
+ start++;
+ }
+}
+
+#define mieq_test_generate_events(c) { _mieq_test_generate_events(next, c); next += c; }
+
+static void
+mieq_test(void) {
+ uint32_t next = 1;
+
+ mieq_test_event_last_processed = 0;
+ mieqInit();
+ mieqSetHandler(ET_RawMotion, mieq_test_event_handler);
+
+ /* Enough to fit the buffer but trigger a grow */
+ mieq_test_generate_events(180);
+
+ /* We should resize to 512 now */
+ mieqProcessInputEvents();
+
+ /* Some should now get dropped */
+ mieq_test_generate_events(500);
+
+ /* Tell us how many got dropped, 1024 now */
+ mieqProcessInputEvents();
+
+ /* Now make it 2048 */
+ mieq_test_generate_events(900);
+ mieqProcessInputEvents();
+
+ /* Now make it 4096 (max) */
+ mieq_test_generate_events(1950);
+ mieqProcessInputEvents();
+
+ /* Now overflow one last time with the maximal queue and reach the verbosity limit */
+ mieq_test_generate_events(10000);
+ mieqProcessInputEvents();
+
+ mieqFini();
+}
+
int main(int argc, char** argv)
{
dix_double_fp_conversion();
@@ -1608,6 +1692,7 @@ int main(int argc, char** argv)
dix_valuator_alloc();
dix_get_master();
input_option_test();
+ mieq_test();
return 0;
}
diff --git a/xorg-server/test/xi2/protocol-eventconvert.c b/xorg-server/test/xi2/protocol-eventconvert.c
index bfa23b51f..ba2d96ad1 100644
--- a/xorg-server/test/xi2/protocol-eventconvert.c
+++ b/xorg-server/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/xorg-server/xkb/xkbActions.c b/xorg-server/xkb/xkbActions.c
index 529b53c37..78a3319b8 100644
--- a/xorg-server/xkb/xkbActions.c
+++ b/xorg-server/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;
}