Commit 2ada71fb authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Screen.c: simplify nxagentResizeScreen

parent 1af470a2
...@@ -2310,26 +2310,25 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, ...@@ -2310,26 +2310,25 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
pScreen -> height = height; pScreen -> height = height;
/* /*
* Compute screen dimensions if they aren't given. * Compute screen dimensions if they aren't provided.
*/ */
if (mmWidth == 0) if (mmWidth == 0)
{ {
if (monitorResolution < 0) if (monitorResolution < 0)
{ {
mmWidth = width * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) / mmWidth = width * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) /
DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay)); DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay));
} }
else else
{ {
mmWidth = (width * 254 + monitorResolution * 5) / (monitorResolution * 10); mmWidth = (width * 254 + monitorResolution * 5) / (monitorResolution * 10);
} }
if (mmWidth < 1) if (mmWidth < 1)
{ {
mmWidth = 1; mmWidth = 1;
} }
} }
if (mmHeight == 0) if (mmHeight == 0)
...@@ -2348,7 +2347,6 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, ...@@ -2348,7 +2347,6 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
{ {
mmHeight = 1; mmHeight = 1;
} }
} }
pScreen -> mmWidth = mmWidth; pScreen -> mmWidth = mmWidth;
...@@ -2362,14 +2360,9 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, ...@@ -2362,14 +2360,9 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
PixmapPtr pPixmap = fbGetScreenPixmap(pScreen); PixmapPtr pPixmap = fbGetScreenPixmap(pScreen);
char *fbBits = realloc(pPixmap -> devPrivate.ptr, PixmapBytePad(width, pScreen->rootDepth) * char *fbBits = realloc(pPixmap -> devPrivate.ptr, PixmapBytePad(width, pScreen->rootDepth) *
height * BitsPerPixel(pScreen->rootDepth) / 8); height * BitsPerPixel(pScreen->rootDepth) / 8);
if (fbBits == NULL) if (fbBits == NULL)
{ {
pScreen -> width = oldWidth;
pScreen -> height = oldHeight;
pScreen -> mmWidth = oldMmWidth;
pScreen -> mmHeight = oldMmHeight;
goto nxagentResizeScreenError; goto nxagentResizeScreenError;
} }
...@@ -2481,6 +2474,14 @@ FIXME: We should try to restore the previously ...@@ -2481,6 +2474,14 @@ FIXME: We should try to restore the previously
return 1; return 1;
nxagentResizeScreenError: nxagentResizeScreenError:
#ifdef DEBUG
fprintf(stderr, "%s: nxagentResizeScreenError\n", __func__);
#endif
pScreen -> width = oldWidth;
pScreen -> height = oldHeight;
pScreen -> mmWidth = oldMmWidth;
pScreen -> mmHeight = oldMmHeight;
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment