From 2bc5bd50a50931972bcffe59835e6d477343f1cf Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Mon, 16 Jul 2012 15:03:01 +0100 Subject: hw/xwin: allow DPI configuration in XWinrc Signed-off-by: Yaakov Selkowitz --- hw/xwin/man/XWinrc.man | 5 +++++ hw/xwin/winconfig.c | 1 + hw/xwin/winconfig.h | 1 + hw/xwin/winprefslex.l | 1 + hw/xwin/winprefsyacc.y | 16 ++++++++++++++++ hw/xwin/winprocarg.c | 8 ++++++++ 6 files changed, 32 insertions(+) diff --git a/hw/xwin/man/XWinrc.man b/hw/xwin/man/XWinrc.man index 71d8dad23..820528730 100644 --- a/hw/xwin/man/XWinrc.man +++ b/hw/xwin/man/XWinrc.man @@ -53,6 +53,11 @@ There are four kinds of instructions: miscellaneous, menu, icon and style. .SH Miscellaneous instruction +.TP 8 +.B DPI \fIresolution\fP +Sets the resolution for all screens, in dots per inch. To be used when +the server cannot determine the screen size(s) from the hardware. + .TP 8 .B DEBUG \fIString\fP The \fIString\fP is printed to the XWin log file. diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c index d26cc9376..afb0cfa27 100644 --- a/hw/xwin/winconfig.c +++ b/hw/xwin/winconfig.c @@ -70,6 +70,7 @@ WinCmdlineRec g_cmdline = { #ifdef XWIN_XF86CONFIG NULL, /* keyboard */ #endif + FALSE, /* customDPI */ NULL, /* xkbRules */ NULL, /* xkbModel */ NULL, /* xkbLayout */ diff --git a/hw/xwin/winconfig.h b/hw/xwin/winconfig.h index f079368c7..3bc25d0bf 100644 --- a/hw/xwin/winconfig.h +++ b/hw/xwin/winconfig.h @@ -159,6 +159,7 @@ typedef struct { #ifdef XWIN_XF86CONFIG char *keyboard; #endif + Bool customDPI; char *xkbRules; char *xkbModel; char *xkbLayout; diff --git a/hw/xwin/winprefslex.l b/hw/xwin/winprefslex.l index 9e6f0d6d4..38401345a 100644 --- a/hw/xwin/winprefslex.l +++ b/hw/xwin/winprefslex.l @@ -90,6 +90,7 @@ RELOAD { return RELOAD; } TRAYICON { return TRAYICON; } FORCEEXIT { return FORCEEXIT; } SILENTEXIT { return SILENTEXIT; } +DPI { return DPI; } "{" { return LB; } "}" { return RB; } "\""[^\"\r\n]+"\"" { yylval.sVal = makestr(yytext+1); \ diff --git a/hw/xwin/winprefsyacc.y b/hw/xwin/winprefsyacc.y index 9bb28ae92..6cc231fdc 100644 --- a/hw/xwin/winprefsyacc.y +++ b/hw/xwin/winprefsyacc.y @@ -39,6 +39,8 @@ #include #define _STDLIB_H 1 /* bison checks this to know if stdlib has been included */ #include +#include "globals.h" +#include "winconfig.h" #include "winprefs.h" /* The following give better error messages in bison at the cost of a few KB */ @@ -57,6 +59,8 @@ static MENUPARSED menu; /* Functions for parsing the tokens into out structure */ /* Defined at the end section of this file */ +static void SetDPI (char *dpi); + static void SetIconDirectory (char *path); static void SetDefaultIcon (char *fname); static void SetRootMenu (char *menu); @@ -121,6 +125,7 @@ extern int yylex(void); %token TRAYICON %token FORCEEXIT %token SILENTEXIT +%token DPI %token STRING %type group1 @@ -155,6 +160,10 @@ command: defaulticon | trayicon | forceexit | silentexit + | dpi + ; + +dpi: DPI STRING NEWLINE { SetDPI($2); free($2); } ; trayicon: TRAYICON STRING NEWLINE { SetTrayIcon($2); free($2); } @@ -259,6 +268,13 @@ yyerror (const char *s) return 1; } +static void +SetDPI (char *dpi) +{ + if (!g_cmdline.customDPI) + monitorResolution = atoi (dpi); +} + /* Miscellaneous functions to store TOKENs into the structure */ static void SetIconDirectory (char *path) diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c index 90a65499c..12dd9c5ba 100644 --- a/hw/xwin/winprocarg.c +++ b/hw/xwin/winprocarg.c @@ -956,6 +956,14 @@ ddxProcessArgument(int argc, char *argv[], int i) return 0; /* Let DIX parse this again */ } + /* + * Look for the '-dpi' argument + */ + if (IS_OPTION("-dpi")) { + g_cmdline.customDPI = TRUE; + return 0; /* Let DIX parse this again */ + } + /* * Look for the '-config' argument */ -- cgit v1.2.3