From 146538a47552d2ecde78196b7d549816a7abda64 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 14 Aug 2024 15:07:22 +0200 Subject: [PATCH] Xnest: collect upstream window geometry in one xRectangle struct Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xnest/Args.c | 14 +++++++------- hw/xnest/Args.h | 5 +---- hw/xnest/Display.c | 8 ++++---- hw/xnest/Screen.c | 35 +++++++++++++++++++---------------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/hw/xnest/Args.c b/hw/xnest/Args.c index 7fb346906..7af0f37d4 100644 --- a/hw/xnest/Args.c +++ b/hw/xnest/Args.c @@ -40,10 +40,7 @@ Bool xnestUserDefaultClass = FALSE; int xnestDefaultDepth; Bool xnestUserDefaultDepth = FALSE; Bool xnestSoftwareScreenSaver = FALSE; -int xnestX; -int xnestY; -unsigned int xnestWidth; -unsigned int xnestHeight; +xRectangle xnestGeometry = { 0 }; int xnestUserGeometry = 0; int xnestBorderWidth; Bool xnestUserBorderWidth = FALSE; @@ -140,9 +137,12 @@ ddxProcessArgument(int argc, char *argv[], int i) } if (!strcmp(argv[i], "-geometry")) { if (++i < argc) { - xnestUserGeometry = XParseGeometry(argv[i], - &xnestX, &xnestY, - &xnestWidth, &xnestHeight); + int x, y; unsigned w, h; + xnestUserGeometry = XParseGeometry(argv[i], &x, &y, &w, &h); + xnestGeometry = (xRectangle) { + .x = x, .y = y, .width = w, .height = h, + }; + if (xnestUserGeometry) return 2; } diff --git a/hw/xnest/Args.h b/hw/xnest/Args.h index 2ae2984b4..fae8fbf2d 100644 --- a/hw/xnest/Args.h +++ b/hw/xnest/Args.h @@ -26,10 +26,7 @@ extern Bool xnestUserDefaultClass; extern int xnestDefaultDepth; extern Bool xnestUserDefaultDepth; extern Bool xnestSoftwareScreenSaver; -extern int xnestX; -extern int xnestY; -extern unsigned int xnestWidth; -extern unsigned int xnestHeight; +extern xRectangle xnestGeometry; extern int xnestUserGeometry; extern int xnestBorderWidth; extern Bool xnestUserBorderWidth; diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index 1d439ac91..924c36ab0 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -161,17 +161,17 @@ xnestOpenDisplay(int argc, char *argv[]) NULL); if (!(xnestUserGeometry & XValue)) - xnestX = 0; + xnestGeometry.x = 0; if (!(xnestUserGeometry & YValue)) - xnestY = 0; + xnestGeometry.y = 0; if (xnestParentWindow == 0) { if (!(xnestUserGeometry & WidthValue)) - xnestWidth = 3 * xnestUpstreamInfo.screenInfo->width_in_pixels / 4; + xnestGeometry.width = 3 * xnestUpstreamInfo.screenInfo->width_in_pixels / 4; if (!(xnestUserGeometry & HeightValue)) - xnestHeight = 3 * xnestUpstreamInfo.screenInfo->height_in_pixels / 4; + xnestGeometry.height = 3 * xnestUpstreamInfo.screenInfo->height_in_pixels / 4; } if (!xnestUserBorderWidth) diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index acd682e43..88111a306 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -264,13 +264,14 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) if (xnestParentWindow != 0) { XGetWindowAttributes(xnestDisplay, xnestParentWindow, &gattributes); - xnestWidth = gattributes.width; - xnestHeight = gattributes.height; + xnestGeometry.width = gattributes.width; + xnestGeometry.height = gattributes.height; } /* myNum */ /* id */ - if (!miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth, rootDepth, numDepths, depths, defaultVisual, /* root visual */ + if (!miScreenInit(pScreen, NULL, xnestGeometry.width, xnestGeometry.height, + 1, 1, xnestGeometry.width, rootDepth, numDepths, depths, defaultVisual, /* root visual */ numVisuals, visuals)) return FALSE; @@ -351,10 +352,10 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) PointPriv->spriteFuncs = &xnestPointerSpriteFuncs; pScreen->mmWidth = - xnestWidth * xnestUpstreamInfo.screenInfo->width_in_millimeters / + xnestGeometry.width * xnestUpstreamInfo.screenInfo->width_in_millimeters / xnestUpstreamInfo.screenInfo->width_in_pixels; pScreen->mmHeight = - xnestHeight * xnestUpstreamInfo.screenInfo->height_in_millimeters / + xnestGeometry.height * xnestUpstreamInfo.screenInfo->height_in_millimeters / xnestUpstreamInfo.screenInfo->height_in_pixels; /* overwrite miCloseScreen with our own */ @@ -365,7 +366,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) /* devPrivates */ -#define POSITION_OFFSET (pScreen->myNum * (xnestWidth + xnestHeight) / 32) +#define POSITION_OFFSET (pScreen->myNum * (xnestGeometry.width + xnestGeometry.height) / 32) if (xnestDoFullGeneration) { @@ -390,10 +391,10 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) pScreen->rootDepth, xnestDefaultWindows[pScreen->myNum], xnestUpstreamInfo.screenInfo->root, - xnestX + POSITION_OFFSET, - xnestY + POSITION_OFFSET, - xnestWidth, - xnestHeight, + xnestGeometry.x + POSITION_OFFSET, + xnestGeometry.y + POSITION_OFFSET, + xnestGeometry.width, + xnestGeometry.height, xnestBorderWidth, XCB_WINDOW_CLASS_INPUT_OUTPUT, xnestDefaultVisual(pScreen)->visualid, @@ -406,10 +407,12 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) xcb_size_hints_t sizeHints = { .flags = XCB_ICCCM_SIZE_HINT_P_POSITION | XCB_ICCCM_SIZE_HINT_P_SIZE | XCB_ICCCM_SIZE_HINT_P_MAX_SIZE, - .x = xnestX + POSITION_OFFSET, - .y = xnestY + POSITION_OFFSET, - .width = sizeHints.max_width = xnestWidth, - .height = sizeHints.max_height = xnestHeight, + .x = xnestGeometry.x + POSITION_OFFSET, + .y = xnestGeometry.y + POSITION_OFFSET, + .width = xnestGeometry.width, + .height = xnestGeometry.height, + .max_width = xnestGeometry.width, + .max_height = xnestGeometry.height, }; if (xnestUserGeometry & XValue || xnestUserGeometry & YValue) @@ -459,8 +462,8 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) xnestDefaultWindows[pScreen->myNum], 0, 0, - xnestWidth, - xnestHeight, + xnestGeometry.width, + xnestGeometry.height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, xnestUpstreamInfo.screenInfo->root_visual,