xorg-server:

- remove unneeded patches
This commit is contained in:
Stephan Raue 2009-11-16 02:27:59 +01:00
parent 511382577a
commit 8b01fafaf5
17 changed files with 0 additions and 586 deletions

View File

@ -1,30 +0,0 @@
--- xorg-server.orig/exa/exa.c 2008-10-14 23:24:44.000000000 +0200
+++ xorg-server/exa/exa.c 2008-10-14 23:25:52.000000000 +0200
@@ -882,6 +882,11 @@
dixSetPrivate(&pScreen->devPrivates, exaScreenPrivateKey, pExaScr);
pExaScr->migration = ExaMigrationAlways;
+ if (pScreenInfo->flags & EXA_MIGRATION_GREEDY) {
+ pExaScr->migration = ExaMigrationGreedy;
+ LogMessage(X_INFO, "EXA(%d): Forcing greedy migration option\n",
+ pScreen->myNum);
+ }
exaDDXDriverInit(pScreen);
--- xorg-server.orig/exa/exa.h 2008-10-14 23:24:44.000000000 +0200
+++ xorg-server/exa/exa.h 2008-10-14 23:25:52.000000000 +0200
@@ -737,6 +737,13 @@
#define EXA_TWO_BITBLT_DIRECTIONS (1 << 2)
/**
+ * EXA_MIGRATION_GREEDY indicates to EXA that the driver prefers to
+ * use the "greedy" migration heuristic. This is to work around
+ * issues with EXA on the Intel 965 chipset. (LP: #177492)
+ */
+#define EXA_MIGRATION_GREEDY (1 << 3)
+
+/**
* EXA_HANDLES_PIXMAPS indicates to EXA that the driver can handle
* all pixmap addressing and migration.
*/

View File

@ -1,35 +0,0 @@
Disable damage notifications on move for manually redirected windows.
The automatic compositor needs damage notification on move, but a
compositing manager doesn't.
Index: xorg-server/composite/compwindow.c
===================================================================
--- xorg-server.orig/composite/compwindow.c 2008-06-18 10:28:16.000000000 +0300
+++ xorg-server/composite/compwindow.c 2008-06-18 12:06:20.000000000 +0300
@@ -580,12 +580,15 @@
}
else
{
+ CompWindowPtr cw = GetCompWindow (pWin);
+
ptOldOrg.x -= dx;
ptOldOrg.y -= dy;
REGION_TRANSLATE (prgnSrc, prgnSrc,
pWin->drawable.x - ptOldOrg.x,
pWin->drawable.y - ptOldOrg.y);
- DamageRegionAppend(&pWin->drawable, prgnSrc);
+ if (pWin->redirectDraw && cw->update == CompositeRedirectAutomatic)
+ DamageRegionAppend(&pWin->drawable, prgnSrc);
}
cs->CopyWindow = pScreen->CopyWindow;
pScreen->CopyWindow = compCopyWindow;
@@ -664,7 +667,8 @@
/*
* Report that as damaged so it will be redrawn
*/
- DamageRegionAppend(&pWin->drawable, &damage);
+ if (cw->update == CompositeRedirectAutomatic)
+ DamageRegionAppend(&pWin->drawable, &damage);
REGION_UNINIT (pScreen, &damage);
/*
* Save the new border clip region

View File

@ -1,22 +0,0 @@
diff -Naur xorg-server-1.6.99.902.orig/Xi/exevents.c xorg-server-1.6.99.902/Xi/exevents.c
--- xorg-server-1.6.99.902.orig/Xi/exevents.c 2009-09-26 14:12:03.000000000 +0200
+++ xorg-server-1.6.99.902/Xi/exevents.c 2009-09-26 18:55:30.000000000 +0200
@@ -195,11 +195,15 @@
static void
CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
{
- KeyClassPtr mk = master->key;
- KeyClassPtr dk = device->key;
+ KeyClassPtr mk, dk;
int i;
- if (device == master)
+ if (device == master || device == NULL || master == NULL)
+ return;
+
+ mk = master->key;
+ dk = device->key;
+ if (dk == NULL || mk == NULL)
return;
mk->sourceid = device->id;

View File

@ -1,14 +0,0 @@
diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c
index d855bd1..2af8c00 100644
--- a/hw/xfree86/common/xf86VidMode.c
+++ b/hw/xfree86/common/xf86VidMode.c
@@ -226,6 +226,9 @@ VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock)
pScrn = xf86Screens[scrnIndex];
pVidMode = VMPTR(pScrn->pScreen);
+ if (pScrn->modes == NULL)
+ return FALSE;
+
pVidMode->First = pScrn->modes;
pVidMode->Next = pVidMode->First->next;

View File

@ -1,12 +0,0 @@
diff -Nurp patched/include/misc.h working/include/misc.h
--- patched/include/misc.h 2009-02-05 01:09:03.000000000 -0800
+++ working/include/misc.h 2009-02-05 02:12:57.000000000 -0800
@@ -86,7 +86,7 @@ extern unsigned long serverGeneration;
#ifndef MAXSCREENS
#define MAXSCREENS 16
#endif
-#define MAXCLIENTS 256
+#define MAXCLIENTS 512
#define MAXEXTENSIONS 128
#define MAXFORMATS 8
#define MAXDEVICES 20 /* input devices */

View File

@ -1,13 +0,0 @@
diff -Nurp patched/hw/xfree86/modes/xf86RandR12.c working/hw/xfree86/modes/xf86RandR12.c
--- patched/hw/xfree86/modes/xf86RandR12.c 2009-03-02 22:57:18.000000000 -0800
+++ working/hw/xfree86/modes/xf86RandR12.c 2009-03-02 22:57:24.000000000 -0800
@@ -944,7 +944,8 @@ xf86RandR12SetRotations (ScreenPtr pScre
for (c = 0; c < config->num_crtc; c++) {
xf86CrtcPtr crtc = config->crtc[c];
- RRCrtcSetRotations (crtc->randr_crtc, rotations);
+ if (crtc != NULL)
+ RRCrtcSetRotations (crtc->randr_crtc, rotations);
}
#endif
randrp->supported_rotations = rotations;

View File

@ -1,61 +0,0 @@
diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c
index c0e3df9..32288f7 100644
--- a/hw/xfree86/ddc/interpret_edid.c
+++ b/hw/xfree86/ddc/interpret_edid.c
@@ -51,6 +51,15 @@ static void get_whitepoint_section(Uchar *, struct whitePoints *);
static void get_detailed_timing_section(Uchar*, struct detailed_timings *);
static Bool validate_version(int scrnIndex, struct edid_version *);
+static Bool
+is_standard_aspect_ratio(int x, int y)
+{
+ return ((x == 16 && y == 9) ||
+ (x == 16 && y == 10) ||
+ (x == 4 && y == 3) ||
+ (x == 5 && y == 4));
+}
+
static void
handle_edid_quirks(xf86MonPtr m)
{
@@ -91,10 +100,7 @@ handle_edid_quirks(xf86MonPtr m)
* try to find the largest detailed timing that matches that aspect
* ratio and use that to fill in the feature section.
*/
- if ((m->features.hsize == 16 && m->features.vsize == 9) ||
- (m->features.hsize == 16 && m->features.vsize == 10) ||
- (m->features.hsize == 4 && m->features.vsize == 3) ||
- (m->features.hsize == 5 && m->features.vsize == 4)) {
+ if (is_standard_aspect_ratio(m->features.hsize, m->features.vsize)) {
int real_hsize = 0, real_vsize = 0;
float target_aspect, timing_aspect;
@@ -130,6 +136,28 @@ handle_edid_quirks(xf86MonPtr m)
xf86Msg(X_INFO, "Quirked EDID physical size to %dx%d cm\n",
m->features.hsize, m->features.vsize);
}
+
+ /*
+ * Some monitors do the reverse, putting real size in the global block
+ * and aspect ratios in the detailed timings. Check, but only if we
+ * think we've got a real physical size.
+ */
+ if (m->features.hsize && m->features.vsize) {
+ for (i = 0; i < 4; i++) {
+ if (m->det_mon[i].type == DT) {
+ struct detailed_timings *timing;
+ timing = &m->det_mon[i].section.d_timings;
+
+ if (is_standard_aspect_ratio(timing->h_size, timing->v_size)) {
+ timing->h_size = m->features.hsize * 10;
+ timing->v_size = m->features.vsize * 10;
+ xf86Msg(X_INFO, "Quirked timing size to %dx%d mm\n",
+ timing->h_size, timing->v_size);
+
+ }
+ }
+ }
+ }
}
xf86MonPtr

View File

@ -1,30 +0,0 @@
From f0ef98d8d54f5dfa3081b62ff672e0fe992b0a01 Mon Sep 17 00:00:00 2001
From: Bryce Harrington <bryce@bryceharrington.org>
Date: Wed, 18 Mar 2009 23:28:51 -0700
Subject: [PATCH] Check for null pointer dereference to prevent crash
on non-primary Xinerama screens when key repeating.
(LP: #324465)
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
---
mi/mipointer.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/mi/mipointer.c b/mi/mipointer.c
index e37316e..fe5947f 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -306,6 +306,10 @@ miPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
pPointer = MIPOINTER(pDev);
SetupScreen (pScreen);
+ /* Null pointer causes crash on keyrepeat with Xinerama LP: (#324465) */
+ if (pPointer == NULL)
+ return;
+
if (pPointer->pScreen != pScreen)
{
(*pScreenPriv->screenFuncs->NewEventScreen) (pDev, pScreen, TRUE);
--
1.6.0.4

View File

@ -1,13 +0,0 @@
diff -Nurp patched/hw/xfree86/common/xisb.c working/hw/xfree86/common/xisb.c
--- patched/hw/xfree86/common/xisb.c 2009-02-02 21:53:58.000000000 +0100
+++ working/hw/xfree86/common/xisb.c 2009-02-02 21:55:09.000000000 +0100
@@ -98,6 +98,9 @@ XisbRead (XISBuffer *b)
{
int ret;
+ if (b == NULL)
+ return -2;
+
if (b->current >= b->end)
{
if (b->block_duration >= 0)

View File

@ -1,18 +0,0 @@
Index: xorg-server-1.6.0/hw/xfree86/common/xf86Init.c
===================================================================
--- xorg-server-1.6.0.orig/hw/xfree86/common/xf86Init.c 2009-03-19 23:19:45.000000000 -0700
+++ xorg-server-1.6.0/hw/xfree86/common/xf86Init.c 2009-03-19 23:23:22.000000000 -0700
@@ -1345,8 +1345,12 @@
signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
#endif
- if (!beenHere)
+ if (!beenHere) {
+ /* have glibc report internal abort traces to stderr instead of
+ the controlling terminal */
+ setenv("LIBC_FATAL_STDERR_","1",0);
xf86LogInit();
+ }
/* Set stderr to non-blocking. */
#ifndef O_NONBLOCK

View File

@ -1,107 +0,0 @@
From 179cec1d2f919d8d8096d6030b0ad9b6285dfd4d Mon Sep 17 00:00:00 2001
From: Bryce Harrington <bryce@bryceharrington.org>
Date: Mon, 23 Mar 2009 14:25:18 -0700
Subject: [PATCH] Check null pointers to not crash on keyrepeat with Xinerama LP: (#324465)
With -nvidia, when using Xinerama, holding down a key in a text field
on a non-primary screen can cause an X crash. This is caused because
the MIPOINTER(pDev) can return a NULL pointer for a non-null pDev in
some cases, and the mipointer.c code lacks checks for this condition.
MIPOINTER() is a macro #defined locally to mipointer.c, which calls into
dixLookupPrivate(), a routine which returns NULL in at least some
circumstances - such as if the memory could not be xcalloc'd for
whatever reason. Hopefully upstream can provide a better fix for this,
but for now it seems reasonable to check the return values of this macro
for NULL before usage, as a minimum.
diff -Naur xorg-server-1.6.99.902.orig/mi/mipointer.c xorg-server-1.6.99.902/mi/mipointer.c
--- xorg-server-1.6.99.902.orig/mi/mipointer.c 2009-09-26 14:12:02.000000000 +0200
+++ xorg-server-1.6.99.902/mi/mipointer.c 2009-09-26 19:02:00.000000000 +0200
@@ -139,6 +139,10 @@
if (DevHasCursor(pDev))
{
pPointer = MIPOINTER(pDev);
+ if (pPointer == NULL) {
+ ErrorF("miPointerCloseScreen: Invalid input device pointer\n");
+ return FALSE;
+ }
if (pScreen == pPointer->pScreen)
pPointer->pScreen = 0;
@@ -191,6 +195,10 @@
return FALSE;
pPointer = MIPOINTER(pDev);
+ if (pPointer == NULL) {
+ ErrorF("miPointerDisplayCursor: Invalid input device pointer\n");
+ return FALSE;
+ }
pPointer->pCursor = pCursor;
pPointer->pScreen = pScreen;
@@ -204,6 +212,10 @@
miPointerPtr pPointer;
pPointer = MIPOINTER(pDev);
+ if (pPointer == NULL) {
+ ErrorF("miPointerConstrainCursor: Invalid input device pointer\n");
+ return FALSE;
+ }
pPointer->limits = *pBox;
pPointer->confined = PointerConfinedToScreen(pDev);
@@ -305,6 +317,10 @@
SetupScreen (pScreen);
pPointer = MIPOINTER(pDev);
+ if (pPointer == NULL) {
+ ErrorF("miPointerWarpCursor: Invalid input device pointer\n");
+ return;
+ }
if (pPointer->pScreen != pScreen)
{
@@ -436,13 +452,17 @@
ScreenPtr pScreen;
miPointerPtr pPointer;
- pPointer = MIPOINTER(pDev);
-
pScreen = screenInfo.screens[screen_no];
pScreenPriv = GetScreenPrivate (pScreen);
(*pScreenPriv->screenFuncs->NewEventScreen) (pDev, pScreen, FALSE);
NewCurrentScreen (pDev, pScreen, x, y);
+ pPointer = MIPOINTER(pDev);
+ if (pPointer == NULL) {
+ ErrorF("miPointerSetScreen: Invalid input device pointer\n");
+ return;
+ }
+
pPointer->limits.x2 = pScreen->width;
pPointer->limits.y2 = pScreen->height;
}
@@ -469,6 +489,10 @@
SetupScreen(pScreen);
pPointer = MIPOINTER(pDev);
+ if (pPointer == NULL) {
+ ErrorF("miPointerMoved: Invalid input device pointer\n");
+ return;
+ }
/* Hack: We mustn't call into ->MoveCursor for anything but the
* VCP, as this may cause a non-HW rendered cursor to be rendered during
@@ -498,6 +522,11 @@
miPointerPtr pPointer;
pPointer = MIPOINTER(pDev);
+ if (pPointer == NULL) {
+ ErrorF("miPointerSetPosition: Invalid input device pointer\n");
+ return;
+ }
+
pScreen = pPointer->pScreen;
if (!pScreen)
return; /* called before ready */

View File

@ -1,39 +0,0 @@
From 7813adf66be31d8b0e8df21821e786e688f7fe78 Mon Sep 17 00:00:00 2001
From: Bryce Harrington <bryce@bryceharrington.org>
Date: Fri, 27 Mar 2009 19:01:32 -0700
Subject: [PATCH] cwGetBackingPicture can segfault when minimizing/maximizing firefox with
a flash video playing. This appears to be a race condition in which the
backing picture's data is not always fully defined.
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
---
miext/cw/cw_render.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/miext/cw/cw_render.c b/miext/cw/cw_render.c
index 6e0c727..fe8cba7 100644
--- a/miext/cw/cw_render.c
+++ b/miext/cw/cw_render.c
@@ -125,10 +125,15 @@ cwGetBackingPicture (PicturePtr pPicture, int *x_off, int *y_off)
WindowPtr pWindow = (WindowPtr) pDrawable;
PixmapPtr pPixmap = getCwPixmap (pWindow);
- *x_off = pDrawable->x - pPixmap->screen_x;
- *y_off = pDrawable->y - pPixmap->screen_y;
-
- return pPicturePrivate->pBackingPicture;
+ if (pDrawable && pPixmap) {
+ *x_off = pDrawable->x - pPixmap->screen_x;
+ *y_off = pDrawable->y - pPixmap->screen_y;
+
+ return pPicturePrivate->pBackingPicture;
+ } else {
+ *x_off = *y_off = 0;
+ return pPicture;
+ }
}
else
{
--
1.6.0.4

View File

@ -1,21 +0,0 @@
#
# Ubuntu: https://bugs.launchpad.net/bugs/353074
# Upstream: http://bugs.freedesktop.org/show_bug.cgi?id=21000
#
Index: xorg-server-1.6.0/hw/xfree86/modes/xf86EdidModes.c
===================================================================
--- xorg-server-1.6.0.orig/hw/xfree86/modes/xf86EdidModes.c 2009-04-01 19:45:23.000000000 +0200
+++ xorg-server-1.6.0/hw/xfree86/modes/xf86EdidModes.c 2009-04-01 19:45:32.000000000 +0200
@@ -155,6 +155,11 @@
DDC->vendor.prod_id == 13600)
return TRUE;
+ /* Bug #21000: LGPhilipsLCD LP154W01-TLAJ */
+ if (memcmp (DDC->vendor.name, "LPL", 4) == 0 &&
+ DDC->vendor.prod_id == 47360)
+ return TRUE;
+
return FALSE;
}

View File

@ -1,16 +0,0 @@
From 8663524ce398b56af596ab1e7e96b62ca45b79e9 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon, 13 Apr 2009 17:49:00 +1000
Subject: [PATCH] xfree86: don't synthesise a mouse section if synaptics devices are found.
diff -Naur xorg-server-1.6.99.902.orig/hw/xfree86/common/xf86Config.c xorg-server-1.6.99.902/hw/xfree86/common/xf86Config.c
--- xorg-server-1.6.99.902.orig/hw/xfree86/common/xf86Config.c 2009-09-26 14:12:03.000000000 +0200
+++ xorg-server-1.6.99.902/hw/xfree86/common/xf86Config.c 2009-09-26 19:05:52.000000000 +0200
@@ -2406,6 +2406,7 @@
{
if (strcmp((*dev)->driver, "kbd") == 0 ||
strcmp((*dev)->driver, "mouse") == 0 ||
+ strcmp((*dev)->driver, "synaptics") == 0 ||
strcmp((*dev)->driver, "vmmouse") == 0)
{
IDevPtr *current;

View File

@ -1,91 +0,0 @@
diff -Naur xorg-server-1.6.99.902.orig/hw/xfree86/common/xf86pciBus.c xorg-server-1.6.99.902/hw/xfree86/common/xf86pciBus.c
--- xorg-server-1.6.99.902.orig/hw/xfree86/common/xf86pciBus.c 2009-09-26 14:12:03.000000000 +0200
+++ xorg-server-1.6.99.902/hw/xfree86/common/xf86pciBus.c 2009-09-26 19:11:42.000000000 +0200
@@ -52,13 +52,7 @@
/* Bus-specific globals */
Bool pciSlotClaimed = FALSE;
-#define PCIINFOCLASSES(c) \
- ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \
- || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
- || ((((c) & 0x00ffff00) \
- == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \
- || ((((c) & 0x00ffff00) \
- == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) )
+#define PCIINFOCLASSES(c) (((c) & 0x00ffff00) == (PCI_CLASS_DISPLAY << 16))
/*
* PCI classes that have messages printed always. The others are only
@@ -85,6 +79,40 @@
sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8);
}
+/* oh god what have i done */
+static Bool
+looks_like_bios_primary(struct pci_device *info)
+{
+ unsigned char *bios;
+ unsigned short vendor, device;
+ int offset;
+ Bool ret = FALSE;
+
+ bios = xf86MapVidMem(-1, VIDMEM_MMIO, 0xc0000, 0x10000);
+ if (!bios)
+ return FALSE;
+
+ if (bios[0] != 0x55 || bios[1] != 0xAA)
+ goto out;
+
+ offset = (bios[0x19] << 8) + bios[0x18];
+
+ if (bios[offset] != 'P' ||
+ bios[offset+1] != 'C' ||
+ bios[offset+2] != 'I' ||
+ bios[offset+3] != 'R')
+ goto out;
+
+ vendor = (bios[offset+5] << 8) + bios[offset+4];
+ device = (bios[offset+7] << 8) + bios[offset+6];
+
+ ret = (info->vendor_id == vendor) && (info->device_id == device);
+
+out:
+ xf86UnMapVidMem(-1, bios, 0x10000);
+ return ret;
+}
+
/*
* xf86Bus.c interface
*/
@@ -132,17 +160,25 @@
uint16_t command;
info = xf86PciVideoInfo[i];
+ if (!IS_VGA(info->device_class))
+ continue;
+
pci_device_cfg_read_u16(info, & command, 4);
- if ((command & PCI_CMD_MEM_ENABLE)
- && ((num == 1) || IS_VGA(info->device_class))) {
- if (primaryBus.type == BUS_NONE) {
+ if ((command & PCI_CMD_MEM_ENABLE)) {
+ if (num == 1) {
primaryBus.type = BUS_PCI;
primaryBus.id.pci = info;
- } else {
- xf86Msg(X_NOTICE,
+ break;
+ } else if (looks_like_bios_primary(info)) {
+ if (primaryBus.type == BUS_NONE) {
+ primaryBus.type = BUS_PCI;
+ primaryBus.id.pci = info;
+ } else {
+ xf86Msg(X_NOTICE,
"More than one possible primary device found\n");
- primaryBus.type ^= (BusType)(-1);
+ primaryBus.type ^= (BusType)(-1);
+ }
}
}
}

View File

@ -1,32 +0,0 @@
/* Upstream commit 56f21bda1ce95741c88c423b60bd709eef26eb12 was supposed to
* only avoid multiple scans of the PCI devices, but it actually also added
* an "optimization" based on using sysfs files instead of /proc. However,
* this code is broken, for instance because there are no ioctl handler on
* /sys/bus/pci/devices/*/config files while there some on /proc/bus/pci/*
*
* It breaks the Xserver on architectures that require such ioctls to scan
* the PCI devices and/or deal with PCI domains:
* #422077: xserver-xorg: Fatal server error on sparc: xf86MapPciMem failed
* #422095: xserver-xorg-core: fails to start on powerpc, no devices detected
*
* The following patch forces the server to behave as if we were running on
* a 2.4 kernel while scanning PCI devices, so that the sysfs code is disabled.
*
* Upstream doesn't apply this patch since they want to fix the sysfs-code.
* See https://bugs.freedesktop.org/show_bug.cgi?id=7248
*
* Thanks to Jim Watson for testing!
*/
diff -Naur xorg-server-1.5.1.orig/hw/xfree86/os-support/bus/linuxPci.c xorg-server-1.5.1/hw/xfree86/os-support/bus/linuxPci.c
--- xorg-server-1.5.1.orig/hw/xfree86/os-support/bus/linuxPci.c 2008-10-04 18:50:24.000000000 +0200
+++ xorg-server-1.5.1/hw/xfree86/os-support/bus/linuxPci.c 2008-10-04 18:52:08.000000000 +0200
@@ -131,7 +131,7 @@
static int fd = -1,is_write = 0;
char file[64];
struct stat ignored;
- static int is26 = -1;
+ static int is26 = 0;
if (dev == NULL) {
return -1;

View File

@ -1,32 +0,0 @@
Index: xorg-server/hw/xfree86/os-support/linux/lnx_init.c
===================================================================
--- xorg-server.orig/hw/xfree86/os-support/linux/lnx_init.c 2008-06-18 12:06:06.000000000 +0300
+++ xorg-server/hw/xfree86/os-support/linux/lnx_init.c 2008-06-18 12:06:25.000000000 +0300
@@ -344,10 +344,25 @@
if (VTSwitch)
{
+ struct vt_stat vts;
+
/*
- * Perform a switch back to the active VT when we were started
+ * Perform a switch back to the active VT when we were started.
+ * We cannot rely on vtSema to determine if the server was the
+ * active VT at the time of shutdown since it has already been
+ * released. Instead, we manually check the current VT and
+ * compare it with the VT we were running on.
*/
- if (activeVT >= 0) {
+ if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
+ {
+ /* If this failed, fall back to old behaviour
+ * of always switching. */
+ xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
+ strerror(errno));
+ vts.v_active = xf86Info.vtno;
+ }
+
+ if (activeVT >= 0 && vts.v_active == xf86Info.vtno) {
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0)
xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n",
strerror(errno));