[PATCH 1/2] kdrive: add support to +X+Y syntax in -screen option parsing
Laércio de Sousa
lbsousajr at gmail.com
Fri Feb 14 04:05:34 PST 2014
This patch enhances current -screen option parsing for kdrive-based
applications. It can parse strings like
<WIDTH>x<HEIGHT>+<XOFFSET>+<YOFFSET>, storing X and Y offsets
in KdScreenInfo instances.
It will allow e.g. proper Xephyr window placement for multiseat
purposes.
---
hw/kdrive/src/kdrive.c | 33 ++++++++++++++++++++++++++++-----
hw/kdrive/src/kdrive.h | 2 ++
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 8eb8cd0..8a3d119 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -284,7 +284,7 @@ KdSubRotation(Rotation a, Rotation b)
void
KdParseScreen(KdScreenInfo * screen, const char *arg)
{
- char delim;
+ char delim, saved_delim;
char save[1024];
int i;
int pixels, mm;
@@ -293,6 +293,8 @@ KdParseScreen(KdScreenInfo * screen, const char *arg)
screen->softCursor = kdSoftCursor;
screen->origin = kdOrigin;
screen->randr = RR_Rotate_0;
+ screen->x = 0;
+ screen->y = 0;
screen->width = 0;
screen->height = 0;
screen->width_mm = 0;
@@ -306,7 +308,7 @@ KdParseScreen(KdScreenInfo * screen, const char *arg)
return;
for (i = 0; i < 2; i++) {
- arg = KdParseFindNext(arg, "x/@XY", save, &delim);
+ arg = KdParseFindNext(arg, "x/+- at XY", save, &delim);
if (!save[0])
return;
@@ -314,7 +316,7 @@ KdParseScreen(KdScreenInfo * screen, const char *arg)
mm = 0;
if (delim == '/') {
- arg = KdParseFindNext(arg, "x at XY", save, &delim);
+ arg = KdParseFindNext(arg, "x+- at XY", save, &delim);
if (!save[0])
return;
mm = atoi(save);
@@ -328,7 +330,8 @@ KdParseScreen(KdScreenInfo * screen, const char *arg)
screen->height = pixels;
screen->height_mm = mm;
}
- if (delim != 'x' && delim != '@' && delim != 'X' && delim != 'Y' &&
+ if (delim != 'x' && delim != '+' && delim != '-' &&
+ delim != '@' && delim != 'X' && delim != 'Y' &&
(delim != '\0' || i == 0))
return;
}
@@ -339,6 +342,26 @@ KdParseScreen(KdScreenInfo * screen, const char *arg)
kdSoftCursor = FALSE;
kdSubpixelOrder = SubPixelUnknown;
+ if (delim == '+' || delim == '-') {
+ saved_delim = delim;
+ arg = KdParseFindNext(arg, "+- at xXY", save, &delim);
+ if (save[0]) {
+ if (saved_delim == '-')
+ screen->x = -atoi(save);
+ else
+ screen->x = atoi(save);
+ }
+ }
+ if (delim == '+' || delim == '-') {
+ saved_delim = delim;
+ arg = KdParseFindNext(arg, "@xXY", save, &delim);
+ if (save[0]) {
+ if (saved_delim == '-')
+ screen->y = -atoi(save);
+ else
+ screen->y = atoi(save);
+ }
+ }
if (delim == '@') {
arg = KdParseFindNext(arg, "xXY", save, &delim);
if (save[0]) {
@@ -418,7 +441,7 @@ KdUseMsg(void)
{
ErrorF("\nTinyX Device Dependent Usage:\n");
ErrorF
- ("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][@ROTATION][X][Y][xDEPTH/BPP[xFREQ]] Specify screen characteristics\n");
+ ("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][+-XOFFSET][+-YOFFSET][@ROTATION][X][Y][xDEPTH/BPP[xFREQ]] Specify screen characteristics\n");
ErrorF
("-rgba rgb/bgr/vrgb/vbgr/none Specify subpixel ordering for LCD panels\n");
ErrorF
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index bec75cb..89b29fe 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -89,6 +89,8 @@ typedef struct _KdScreenInfo {
ScreenPtr pScreen;
void *driver;
Rotation randr; /* rotation and reflection */
+ int x;
+ int y;
int width;
int height;
int rate;
--
1.8.4.5
More information about the xorg-devel
mailing list