Make Xephyr work without shadow fb

This commit is contained in:
Matthew Allum 2005-08-05 09:08:32 +00:00
parent fedbce2186
commit 4220a0c4cc
2 changed files with 412 additions and 314 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Xephyr - A kdrive X server thats runs in a host X window. * Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@o-hand.com> * Authored by Matthew Allum <mallum@openedhand.com>
* *
* Copyright © 2004 Nokia * Copyright © 2004 Nokia
* *
@ -25,12 +25,7 @@
/* TODO: /* TODO:
* *
* POSSIBLES * o Support multiple screens, shouldn't be hard just alot of rejigging.
* - much improve keyboard handling *kind of done*
* - '-fullscreen' switch ?
* - full keyboard grab option somehow ? - use for testing WM key shortcuts
* with out host WM getting them instead.
* - Make cursor 'accel' better.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -49,7 +44,7 @@ Bool
ephyrInitialize (KdCardInfo *card, EphyrPriv *priv) ephyrInitialize (KdCardInfo *card, EphyrPriv *priv)
{ {
OsSignal(SIGUSR1, hostx_handle_signal); OsSignal(SIGUSR1, hostx_handle_signal);
priv->base = 0; priv->base = 0;
priv->bytes_per_line = 0; priv->bytes_per_line = 0;
return TRUE; return TRUE;
@ -58,26 +53,26 @@ ephyrInitialize (KdCardInfo *card, EphyrPriv *priv)
Bool Bool
ephyrCardInit (KdCardInfo *card) ephyrCardInit (KdCardInfo *card)
{ {
EphyrPriv *priv; EphyrPriv *priv;
priv = (EphyrPriv *) xalloc (sizeof (EphyrPriv)); priv = (EphyrPriv *) xalloc (sizeof (EphyrPriv));
if (!priv) if (!priv)
return FALSE; return FALSE;
if (!ephyrInitialize (card, priv)) if (!ephyrInitialize (card, priv))
{ {
xfree (priv); xfree (priv);
return FALSE; return FALSE;
} }
card->driver = priv; card->driver = priv;
return TRUE; return TRUE;
} }
Bool Bool
ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv) ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
{ {
int width = 640, height = 480; int width = 640, height = 480;
if (hostx_want_screen_size(&width, &height) if (hostx_want_screen_size(&width, &height)
|| !screen->width || !screen->height) || !screen->width || !screen->height)
@ -85,22 +80,22 @@ ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
screen->width = width; screen->width = width;
screen->height = height; screen->height = height;
} }
if (screen->fb[0].depth && screen->fb[0].depth != hostx_get_depth()) if (screen->fb[0].depth && screen->fb[0].depth != hostx_get_depth())
{ {
if (screen->fb[0].depth < hostx_get_depth() if (screen->fb[0].depth < hostx_get_depth()
&& (screen->fb[0].depth == 24 || screen->fb[0].depth == 16 && (screen->fb[0].depth == 24 || screen->fb[0].depth == 16
|| screen->fb[0].depth == 8)) || screen->fb[0].depth == 8))
{ {
hostx_set_server_depth(screen->fb[0].depth); hostx_set_server_depth(screen->fb[0].depth);
} }
else else
ErrorF("\nXephyr: requested screen depth not supported, setting to match hosts.\n"); ErrorF("\nXephyr: requested screen depth not supported, setting to match hosts.\n");
} }
screen->fb[0].depth = hostx_get_server_depth(); screen->fb[0].depth = hostx_get_server_depth();
screen->rate = 72; screen->rate = 72;
if (screen->fb[0].depth <= 8) if (screen->fb[0].depth <= 8)
{ {
screen->fb[0].visuals = ((1 << StaticGray) | screen->fb[0].visuals = ((1 << StaticGray) |
@ -109,18 +104,17 @@ ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
(1 << PseudoColor) | (1 << PseudoColor) |
(1 << TrueColor) | (1 << TrueColor) |
(1 << DirectColor)); (1 << DirectColor));
screen->fb[0].redMask = 0x00; screen->fb[0].redMask = 0x00;
screen->fb[0].greenMask = 0x00; screen->fb[0].greenMask = 0x00;
screen->fb[0].blueMask = 0x00; screen->fb[0].blueMask = 0x00;
screen->fb[0].depth = 8; screen->fb[0].depth = 8;
screen->fb[0].bitsPerPixel = 8; screen->fb[0].bitsPerPixel = 8;
} }
else else
{ {
screen->fb[0].visuals = (1 << TrueColor); screen->fb[0].visuals = (1 << TrueColor);
if (screen->fb[0].depth <= 15) if (screen->fb[0].depth <= 15)
{ {
screen->fb[0].depth = 15; screen->fb[0].depth = 15;
@ -131,48 +125,52 @@ ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
&screen->fb[0].blueMask); &screen->fb[0].blueMask);
} }
else if (screen->fb[0].depth <= 16) else if (screen->fb[0].depth <= 16)
{ {
screen->fb[0].depth = 16; screen->fb[0].depth = 16;
screen->fb[0].bitsPerPixel = 16; screen->fb[0].bitsPerPixel = 16;
hostx_get_visual_masks (&screen->fb[0].redMask, hostx_get_visual_masks (&screen->fb[0].redMask,
&screen->fb[0].greenMask, &screen->fb[0].greenMask,
&screen->fb[0].blueMask); &screen->fb[0].blueMask);
} }
else else
{ {
screen->fb[0].depth = 24; screen->fb[0].depth = 24;
screen->fb[0].bitsPerPixel = 32; screen->fb[0].bitsPerPixel = 32;
hostx_get_visual_masks (&screen->fb[0].redMask, hostx_get_visual_masks (&screen->fb[0].redMask,
&screen->fb[0].greenMask, &screen->fb[0].greenMask,
&screen->fb[0].blueMask); &screen->fb[0].blueMask);
} }
} }
scrpriv->randr = screen->randr;
scrpriv->randr = screen->randr; return ephyrMapFramebuffer (screen);
return ephyrMapFramebuffer (screen);
} }
Bool Bool
ephyrScreenInit (KdScreenInfo *screen) ephyrScreenInit (KdScreenInfo *screen)
{ {
EphyrScrPriv *scrpriv; EphyrScrPriv *scrpriv;
scrpriv = xalloc (sizeof (EphyrScrPriv));
scrpriv = xalloc (sizeof (EphyrScrPriv)); if (!scrpriv)
if (!scrpriv) return FALSE;
return FALSE;
memset (scrpriv, 0, sizeof (EphyrScrPriv)); memset (scrpriv, 0, sizeof (EphyrScrPriv));
screen->driver = scrpriv; screen->driver = scrpriv;
if (!ephyrScreenInitialize (screen, scrpriv))
if (!ephyrScreenInitialize (screen, scrpriv))
{ {
screen->driver = 0; screen->driver = 0;
xfree (scrpriv); xfree (scrpriv);
return FALSE; return FALSE;
} }
return TRUE;
return TRUE;
} }
void* void*
@ -183,80 +181,98 @@ ephyrWindowLinear (ScreenPtr pScreen,
CARD32 *size, CARD32 *size,
void *closure) void *closure)
{ {
KdScreenPriv(pScreen); KdScreenPriv(pScreen);
EphyrPriv *priv = pScreenPriv->card->driver; EphyrPriv *priv = pScreenPriv->card->driver;
if (!pScreenPriv->enabled)
{
return 0;
}
if (!pScreenPriv->enabled) *size = priv->bytes_per_line;
{ return priv->base + row * priv->bytes_per_line + offset;
return 0;
}
*size = priv->bytes_per_line;
return priv->base + row * priv->bytes_per_line + offset;
} }
Bool Bool
ephyrMapFramebuffer (KdScreenInfo *screen) ephyrMapFramebuffer (KdScreenInfo *screen)
{ {
EphyrScrPriv *scrpriv = screen->driver; EphyrScrPriv *scrpriv = screen->driver;
EphyrPriv *priv = screen->card->driver; EphyrPriv *priv = screen->card->driver;
KdMouseMatrix m; KdMouseMatrix m;
EPHYR_DBG(" screen->width: %d, screen->height: %d", EPHYR_DBG(" screen->width: %d, screen->height: %d",
screen->width, screen->height); screen->width, screen->height);
/* Always use shadow so we get damage notifications */ KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
scrpriv->shadow = TRUE;
KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height); KdSetMouseMatrix (&m);
KdSetMouseMatrix (&m); priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2; /* point the framebuffer to the data in an XImage */
priv->base = hostx_screen_init (screen->width, screen->height);
/* point the framebuffer to the data in an XImage */
priv->base = hostx_screen_init (screen->width, screen->height); screen->memory_base = (CARD8 *) (priv->base);
screen->memory_size = 0;
screen->memory_base = (CARD8 *) (priv->base); screen->off_screen_base = 0;
screen->memory_size = 0;
screen->off_screen_base = 0; if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All))
{
KdShadowFbAlloc (screen, 0, scrpriv->shadow = FALSE;
scrpriv->randr & (RR_Rotate_90|RR_Rotate_270));
return TRUE; screen->fb[0].byteStride = priv->bytes_per_line;
screen->fb[0].pixelStride = screen->width;
screen->fb[0].frameBuffer = (CARD8 *) (priv->base);
screen->off_screen_base = priv->bytes_per_line * screen->height;
}
else
{
/* Rotated/Reflected so we need to use shadow fb */
scrpriv->shadow = TRUE;
EPHYR_DBG("allocing shadow");
KdShadowFbAlloc (screen, 0,
scrpriv->randr & (RR_Rotate_90|RR_Rotate_270));
}
return TRUE;
} }
void void
ephyrSetScreenSizes (ScreenPtr pScreen) ephyrSetScreenSizes (ScreenPtr pScreen)
{ {
KdScreenPriv(pScreen); KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen; KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver; EphyrScrPriv *scrpriv = screen->driver;
if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180)) if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
{ {
pScreen->width = screen->width; pScreen->width = screen->width;
pScreen->height = screen->height; pScreen->height = screen->height;
pScreen->mmWidth = screen->width_mm; pScreen->mmWidth = screen->width_mm;
pScreen->mmHeight = screen->height_mm; pScreen->mmHeight = screen->height_mm;
} }
else else
{ {
pScreen->width = screen->height; pScreen->width = screen->height;
pScreen->height = screen->width; pScreen->height = screen->width;
pScreen->mmWidth = screen->height_mm; pScreen->mmWidth = screen->height_mm;
pScreen->mmHeight = screen->width_mm; pScreen->mmHeight = screen->width_mm;
} }
} }
Bool Bool
ephyrUnmapFramebuffer (KdScreenInfo *screen) ephyrUnmapFramebuffer (KdScreenInfo *screen)
{ {
EphyrScrPriv *scrpriv = screen->driver;
if (scrpriv->shadow)
KdShadowFbFree (screen, 0); KdShadowFbFree (screen, 0);
/* Note, priv->base will get freed when XImage recreated */ /* Note, priv->base will get freed when XImage recreated */
return TRUE; return TRUE;
} }
void void
@ -264,126 +280,171 @@ ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf)
{ {
KdScreenPriv(pScreen); KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen; KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
int nbox; EPHYR_DBG("slow paint");
BoxPtr pbox;
/* FIXME: Slow Rotated/Reflected updates could be much
* much faster efficiently updating via tranforming
* pBuf->pDamage regions
*/
shadowUpdateRotatePacked(pScreen, pBuf);
hostx_paint_rect(0,0,0,0, screen->width, screen->height);
}
RegionPtr damage; static void
ephyrInternalDamageRedisplay (ScreenPtr pScreen)
if (!(scrpriv->randr & RR_Rotate_0) || (scrpriv->randr & RR_Reflect_All)) {
{ KdScreenPriv(pScreen);
/* Rotated. KdScreenInfo *screen = pScreenPriv->screen;
* TODO: Fix this to use damage as well so much faster. EphyrScrPriv *scrpriv = screen->driver;
* Sledgehammer approach atm. RegionPtr pRegion;
*
* Catch reflects here too - though thats wrong ... if (!scrpriv || !scrpriv->pDamage)
*/
EPHYR_DBG("slow paint");
shadowUpdateRotatePacked(pScreen, pBuf);
hostx_paint_rect(0,0,0,0, screen->width, screen->height);
return;
}
else shadowUpdatePacked(pScreen, pBuf);
/* Figure out what rects have changed and update em. */
if (!pBuf || !pBuf->pDamage)
return; return;
damage = DamageRegion (pBuf->pDamage); pRegion = DamageRegion (scrpriv->pDamage);
if (!REGION_NOTEMPTY (pScreen, damage)) if (REGION_NOTEMPTY (pScreen, pRegion))
return;
nbox = REGION_NUM_RECTS (damage);
pbox = REGION_RECTS (damage);
while (nbox--)
{ {
hostx_paint_rect(pbox->x1, pbox->y1, int nbox;
pbox->x1, pbox->y1, BoxPtr pbox;
pbox->x2 - pbox->x1,
pbox->y2 - pbox->y1); nbox = REGION_NUM_RECTS (pRegion);
pbox++; pbox = REGION_RECTS (pRegion);
while (nbox--)
{
hostx_paint_rect(pbox->x1, pbox->y1,
pbox->x1, pbox->y1,
pbox->x2 - pbox->x1,
pbox->y2 - pbox->y1);
pbox++;
}
DamageEmpty (scrpriv->pDamage);
} }
} }
Bool static void
ephyrSetShadow (ScreenPtr pScreen) ephyrInternalDamageBlockHandler (pointer data,
OSTimePtr pTimeout,
pointer pRead)
{ {
KdScreenPriv(pScreen); ScreenPtr pScreen = (ScreenPtr) data;
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver; ephyrInternalDamageRedisplay (pScreen);
ShadowUpdateProc update; }
ShadowWindowProc window;
window = ephyrWindowLinear; static void
update = ephyrShadowUpdate; ephyrInternalDamageWakeupHandler (pointer data, int i, pointer LastSelectMask)
{
/* FIXME: Not needed ? */
}
return KdShadowSet (pScreen, scrpriv->randr, update, window); Bool
ephyrSetInternalDamage (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
PixmapPtr pPixmap = NULL;
scrpriv->pDamage = DamageCreate ((DamageReportFunc) 0,
(DamageDestroyFunc) 0,
DamageReportNone,
TRUE,
pScreen,
pScreen);
if (!RegisterBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
ephyrInternalDamageWakeupHandler,
(pointer) pScreen))
return FALSE;
pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
DamageRegister (&pPixmap->drawable, scrpriv->pDamage);
return TRUE;
}
void
ephyrUnsetInternalDamage (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
PixmapPtr pPixmap = NULL;
pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
DamageUnregister (&pPixmap->drawable, scrpriv->pDamage);
RemoveBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
ephyrInternalDamageWakeupHandler,
(pointer) pScreen);
} }
#ifdef RANDR #ifdef RANDR
Bool Bool
ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
{ {
KdScreenPriv(pScreen); KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen; KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver; EphyrScrPriv *scrpriv = screen->driver;
RRScreenSizePtr pSize; RRScreenSizePtr pSize;
Rotation randr; Rotation randr;
int n = 0; int n = 0;
EPHYR_DBG("mark"); EPHYR_DBG("mark");
struct { int width, height; } sizes[] = struct { int width, height; } sizes[] =
{ {
{ 1600, 1200 }, { 1600, 1200 },
{ 1400, 1050 }, { 1400, 1050 },
{ 1280, 960 }, { 1280, 960 },
{ 1280, 1024 }, { 1280, 1024 },
{ 1152, 864 }, { 1152, 864 },
{ 1024, 768 }, { 1024, 768 },
{ 832, 624 }, { 832, 624 },
{ 800, 600 }, { 800, 600 },
{ 720, 400 }, { 720, 400 },
{ 480, 640 }, { 480, 640 },
{ 640, 480 }, { 640, 480 },
{ 640, 400 }, { 640, 400 },
{ 320, 240 }, { 320, 240 },
{ 240, 320 }, { 240, 320 },
{ 160, 160 }, { 160, 160 },
{ 0, 0 } { 0, 0 }
}; };
*rotations = RR_Rotate_All|RR_Reflect_All;
if (!hostx_want_preexisting_window()
&& !hostx_want_fullscreen()) /* only if no -parent switch */
{
while (sizes[n].width != 0 && sizes[n].height != 0)
{
RRRegisterSize (pScreen,
sizes[n].width,
sizes[n].height,
(sizes[n].width * screen->width_mm)/screen->width,
(sizes[n].height *screen->height_mm)/screen->height
);
n++;
}
}
pSize = RRRegisterSize (pScreen,
screen->width,
screen->height,
screen->width_mm,
screen->height_mm);
*rotations = RR_Rotate_All|RR_Reflect_All; randr = KdSubRotation (scrpriv->randr, screen->randr);
RRSetCurrentConfig (pScreen, randr, 0, pSize);
if (!hostx_want_preexisting_window() return TRUE;
&& !hostx_want_fullscreen()) /* only if no -parent switch */
{
while (sizes[n].width != 0 && sizes[n].height != 0)
{
RRRegisterSize (pScreen,
sizes[n].width,
sizes[n].height,
(sizes[n].width * screen->width_mm)/screen->width,
(sizes[n].height *screen->height_mm)/screen->height
);
n++;
}
}
pSize = RRRegisterSize (pScreen,
screen->width,
screen->height,
screen->width_mm,
screen->height_mm);
randr = KdSubRotation (scrpriv->randr, screen->randr);
RRSetCurrentConfig (pScreen, randr, 0, pSize);
return TRUE;
} }
Bool Bool
@ -392,120 +453,138 @@ ephyrRandRSetConfig (ScreenPtr pScreen,
int rate, int rate,
RRScreenSizePtr pSize) RRScreenSizePtr pSize)
{ {
KdScreenPriv(pScreen); KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen; KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver; EphyrScrPriv *scrpriv = screen->driver;
Bool wasEnabled = pScreenPriv->enabled; Bool wasEnabled = pScreenPriv->enabled;
EphyrScrPriv oldscr; EphyrScrPriv oldscr;
int oldwidth; int oldwidth, oldheight, oldmmwidth, oldmmheight;
int oldheight; Bool oldshadow;
int oldmmwidth; int newwidth, newheight;
int oldmmheight;
int newwidth, newheight; if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
{ {
newwidth = pSize->width; newwidth = pSize->width;
newheight = pSize->height; newheight = pSize->height;
} }
else else
{ {
newwidth = pSize->height; newwidth = pSize->height;
newheight = pSize->width; newheight = pSize->width;
} }
if (wasEnabled)
KdDisableScreen (pScreen);
if (wasEnabled) oldscr = *scrpriv;
KdDisableScreen (pScreen);
oldscr = *scrpriv;
oldwidth = screen->width; oldwidth = screen->width;
oldheight = screen->height; oldheight = screen->height;
oldmmwidth = pScreen->mmWidth; oldmmwidth = pScreen->mmWidth;
oldmmheight = pScreen->mmHeight; oldmmheight = pScreen->mmHeight;
oldshadow = scrpriv->shadow;
/*
* Set new configuration /*
*/ * Set new configuration
*/
scrpriv->randr = KdAddRotation (screen->randr, randr);
scrpriv->randr = KdAddRotation (screen->randr, randr);
KdOffscreenSwapOut (screen->pScreen);
KdOffscreenSwapOut (screen->pScreen);
ephyrUnmapFramebuffer (screen);
ephyrUnmapFramebuffer (screen);
screen->width = newwidth;
screen->height = newheight; screen->width = newwidth;
screen->height = newheight;
if (!ephyrMapFramebuffer (screen))
goto bail4; if (!ephyrMapFramebuffer (screen))
goto bail4;
/* FIXME below should go in own call */
if (oldshadow)
KdShadowUnset (screen->pScreen); KdShadowUnset (screen->pScreen);
else
if (!ephyrSetShadow (screen->pScreen)) ephyrUnsetInternalDamage(screen->pScreen);
if (scrpriv->shadow)
{
if (!KdShadowSet (screen->pScreen,
scrpriv->randr,
ephyrShadowUpdate,
ephyrWindowLinear))
goto bail4; goto bail4;
}
ephyrSetScreenSizes (screen->pScreen); else
{
/* /* Without shadow fb ( non rotated ) we need
* Set frame buffer mapping * to use damage to efficiently update display
*/ * via signal regions what to copy from 'fb'.
(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), */
pScreen->width, if (!ephyrSetInternalDamage(screen->pScreen))
pScreen->height, goto bail4;
screen->fb[0].depth, }
screen->fb[0].bitsPerPixel,
screen->fb[0].byteStride, ephyrSetScreenSizes (screen->pScreen);
screen->fb[0].frameBuffer);
/*
/* set the subpixel order */ * Set frame buffer mapping
*/
KdSetSubpixelOrder (pScreen, scrpriv->randr); (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
pScreen->width,
pScreen->height,
if (wasEnabled) screen->fb[0].depth,
KdEnableScreen (pScreen); screen->fb[0].bitsPerPixel,
screen->fb[0].byteStride,
return TRUE; screen->fb[0].frameBuffer);
bail4: /* set the subpixel order */
EPHYR_DBG("bailed");
KdSetSubpixelOrder (pScreen, scrpriv->randr);
ephyrUnmapFramebuffer (screen);
*scrpriv = oldscr; if (wasEnabled)
(void) ephyrMapFramebuffer (screen); KdEnableScreen (pScreen);
pScreen->width = oldwidth; return TRUE;
pScreen->height = oldheight;
pScreen->mmWidth = oldmmwidth; bail4:
pScreen->mmHeight = oldmmheight; EPHYR_DBG("bailed");
if (wasEnabled) ephyrUnmapFramebuffer (screen);
KdEnableScreen (pScreen); *scrpriv = oldscr;
return FALSE; (void) ephyrMapFramebuffer (screen);
pScreen->width = oldwidth;
pScreen->height = oldheight;
pScreen->mmWidth = oldmmwidth;
pScreen->mmHeight = oldmmheight;
if (wasEnabled)
KdEnableScreen (pScreen);
return FALSE;
} }
Bool Bool
ephyrRandRInit (ScreenPtr pScreen) ephyrRandRInit (ScreenPtr pScreen)
{ {
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
if (!RRScreenInit (pScreen)) if (!RRScreenInit (pScreen))
{ {
return FALSE; return FALSE;
} }
pScrPriv = rrGetScrPriv(pScreen); pScrPriv = rrGetScrPriv(pScreen);
pScrPriv->rrGetInfo = ephyrRandRGetInfo; pScrPriv->rrGetInfo = ephyrRandRGetInfo;
pScrPriv->rrSetConfig = ephyrRandRSetConfig; pScrPriv->rrSetConfig = ephyrRandRSetConfig;
return TRUE; return TRUE;
} }
#endif #endif
Bool Bool
ephyrCreateColormap (ColormapPtr pmap) ephyrCreateColormap (ColormapPtr pmap)
{ {
return fbInitializeColormap (pmap); return fbInitializeColormap (pmap);
} }
Bool Bool
@ -518,6 +597,9 @@ ephyrInitScreen (ScreenPtr pScreen)
Bool Bool
ephyrFinishInitScreen (ScreenPtr pScreen) ephyrFinishInitScreen (ScreenPtr pScreen)
{ {
/* FIXME: Calling this even if not using shadow.
* Seems harmless enough. But may be safer elsewhere.
*/
if (!shadowSetup (pScreen)) if (!shadowSetup (pScreen))
return FALSE; return FALSE;
@ -532,7 +614,19 @@ ephyrFinishInitScreen (ScreenPtr pScreen)
Bool Bool
ephyrCreateResources (ScreenPtr pScreen) ephyrCreateResources (ScreenPtr pScreen)
{ {
return ephyrSetShadow (pScreen); KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
EPHYR_DBG("mark");
if (scrpriv->shadow)
return KdShadowSet (pScreen,
scrpriv->randr,
ephyrShadowUpdate,
ephyrWindowLinear);
else
return ephyrSetInternalDamage(pScreen);
} }
void void
@ -543,13 +637,13 @@ ephyrPreserve (KdCardInfo *card)
Bool Bool
ephyrEnable (ScreenPtr pScreen) ephyrEnable (ScreenPtr pScreen)
{ {
return TRUE; return TRUE;
} }
Bool Bool
ephyrDPMS (ScreenPtr pScreen, int mode) ephyrDPMS (ScreenPtr pScreen, int mode)
{ {
return TRUE; return TRUE;
} }
void void
@ -582,15 +676,15 @@ ephyrUpdateModifierState(unsigned int state)
pkeydev = (DeviceIntPtr)LookupKeyboardDevice(); pkeydev = (DeviceIntPtr)LookupKeyboardDevice();
if (!pkeydev) if (!pkeydev)
return; return;
keyc = pkeydev->key; keyc = pkeydev->key;
state = state & 0xff; state = state & 0xff;
if (keyc->state == state) if (keyc->state == state)
return; return;
for (i = 0, mask = 1; i < 8; i++, mask <<= 1) for (i = 0, mask = 1; i < 8; i++, mask <<= 1)
{ {
int key; int key;
@ -642,7 +736,7 @@ ephyrPoll(void)
ev.data.mouse_motion.x, ev.data.mouse_motion.x,
ev.data.mouse_motion.y); ev.data.mouse_motion.y);
break; break;
case EPHYR_EV_MOUSE_PRESS: case EPHYR_EV_MOUSE_PRESS:
ephyrUpdateModifierState(ev.key_state); ephyrUpdateModifierState(ev.key_state);
mouseState |= ev.data.mouse_down.button_num; mouseState |= ev.data.mouse_down.button_num;
@ -674,17 +768,17 @@ ephyrPoll(void)
void void
ephyrCardFini (KdCardInfo *card) ephyrCardFini (KdCardInfo *card)
{ {
EphyrPriv *priv = card->driver; EphyrPriv *priv = card->driver;
xfree (priv); xfree (priv);
} }
void void
ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
{ {
/* XXX Not sure if this is right */ /* XXX Not sure if this is right */
EPHYR_DBG("mark"); EPHYR_DBG("mark");
while (n--) while (n--)
{ {
pdefs->red = 0; pdefs->red = 0;

View File

@ -47,6 +47,7 @@ typedef struct _ephyrScrPriv {
Rotation randr; Rotation randr;
Bool shadow; Bool shadow;
PixmapPtr pShadow; PixmapPtr pShadow;
DamagePtr pDamage;
} EphyrScrPriv; } EphyrScrPriv;
extern KdCardFuncs ephyrFuncs; extern KdCardFuncs ephyrFuncs;
@ -116,8 +117,11 @@ ephyrSetScreenSizes (ScreenPtr pScreen);
Bool Bool
ephyrUnmapFramebuffer (KdScreenInfo *screen); ephyrUnmapFramebuffer (KdScreenInfo *screen);
void
ephyrUnsetInternalDamage (ScreenPtr pScreen);
Bool Bool
ephyrSetShadow (ScreenPtr pScreen); ephyrSetInternalDamage (ScreenPtr pScreen);
Bool Bool
ephyrCreateColormap (ColormapPtr pmap); ephyrCreateColormap (ColormapPtr pmap);