Index: libs/libmyth/mythcontext.cpp =================================================================== RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcontext.cpp,v retrieving revision 1.160 diff -u -r1.160 mythcontext.cpp --- libs/libmyth/mythcontext.cpp 14 Mar 2005 12:11:27 -0000 1.160 +++ libs/libmyth/mythcontext.cpp 15 Mar 2005 23:55:29 -0000 @@ -116,6 +116,10 @@ int m_screenxbase, m_screenybase; int m_screenwidth, m_screenheight; + // Command-line GUI size, which overrides both the above sets of sizes + int m_geometry_x, m_geometry_y; + int m_geometry_w, m_geometry_h; + QString themecachedir; int bigfontsize, mediumfontsize, smallfontsize; @@ -190,6 +194,8 @@ m_height = m_width = 0; m_screenxbase = m_screenybase = 0; m_screenheight = m_screenwidth = 0; + m_geometry_x = m_geometry_y = 0; + m_geometry_w = m_geometry_h = 0; } // Get screen size from Qt. If the windowing system environment @@ -199,6 +205,16 @@ void MythContextPrivate::GetScreenBounds() { + if (m_geometry_w) + { + // Geometry on the command-line overrides everything + m_xbase = m_geometry_x; + m_ybase = m_geometry_y; + m_width = m_geometry_w; + m_height = m_geometry_h; + return; + } + QDesktopWidget * desktop = QApplication::desktop(); int screen = parent->GetNumSetting("XineramaScreen", 0); @@ -317,10 +333,21 @@ void MythContextPrivate::StoreGUIsettings() { - m_screenxbase = parent->GetNumSetting("GuiOffsetX"); - m_screenybase = parent->GetNumSetting("GuiOffsetY"); - m_screenwidth = parent->GetNumSetting("GuiWidth"); - m_screenheight = parent->GetNumSetting("GuiHeight"); + if (m_geometry_w) + { + // Geometry on the command-line overrides everything + m_screenxbase = m_geometry_x; + m_screenybase = m_geometry_y; + m_screenwidth = m_geometry_w; + m_screenheight = m_geometry_h; + } + else + { + m_screenxbase = parent->GetNumSetting("GuiOffsetX"); + m_screenybase = parent->GetNumSetting("GuiOffsetY"); + m_screenwidth = parent->GetNumSetting("GuiWidth"); + m_screenheight = parent->GetNumSetting("GuiHeight"); + } // If any of these was _not_ set by the user, // (i.e. they are 0) use the whole-screen defaults @@ -1204,6 +1231,63 @@ hmult = d->m_hmult; } +// Parse an X11 style command line geometry string, like +// -geometry 800x600+112+22 +// and override the fullscreen and user default screen dimensions + +bool MythContext::ParseGeometryOverride(const QString geometry) +{ + QRegExp re("^(\\d+)x(\\d+)([+-]\\d+)([+-]\\d+)$"); + + if (!re.exactMatch(geometry)) + { + VERBOSE(VB_IMPORTANT, + "Geometry does not match form WIDTHxHEIGHT+XOFF+YOFF"); + return false; + } + + re.search(geometry); + + QStringList geo = re.capturedTexts(); + bool parsed; + + d->m_geometry_w = geo[1].toInt(&parsed); + if (!parsed) + { + VERBOSE(VB_IMPORTANT, "Could not parse width of geometry override"); + return false; + } + + d->m_geometry_h = geo[2].toInt(&parsed); + if (!parsed) + { + VERBOSE(VB_IMPORTANT, "Could not parse height of geometry override"); + return false; + } + + d->m_geometry_x = geo[3].toInt(&parsed); + if (!parsed) + { + VERBOSE(VB_IMPORTANT, + "Could not parse horizontal offset of geometry override"); + return false; + } + + d->m_geometry_y = geo[4].toInt(&parsed); + if (!parsed) + { + VERBOSE(VB_IMPORTANT, + "Could not parse vertical offset of geometry override"); + return false; + } + + VERBOSE(VB_IMPORTANT, QString("Overriding GUI, width=%1," + " height=%2 at %3,%4") + .arg(d->m_geometry_w).arg(d->m_geometry_h) + .arg(d->m_geometry_x).arg(d->m_geometry_y)); + return true; +} + QString MythContext::FindThemeDir(const QString &themename) { QString testdir = MythContext::GetConfDir() + "/themes/" + themename; Index: libs/libmyth/mythcontext.h =================================================================== RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcontext.h,v retrieving revision 1.184 diff -u -r1.184 mythcontext.h --- libs/libmyth/mythcontext.h 9 Mar 2005 22:45:07 -0000 1.184 +++ libs/libmyth/mythcontext.h 15 Mar 2005 23:55:29 -0000 @@ -179,6 +179,9 @@ // This returns the raw (drawable) screen size void GetScreenBounds(int &xbase, int &ybase, int &width, int &height); + // Parse an X11 style command line (-geometry) string + bool ParseGeometryOverride(const QString geometry); + QString FindThemeDir(const QString &themename); QString GetThemeDir(void); Index: programs/mythfrontend/main.cpp =================================================================== RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/main.cpp,v retrieving revision 1.187 diff -u -r1.187 main.cpp --- programs/mythfrontend/main.cpp 5 Mar 2005 00:00:39 -0000 1.187 +++ programs/mythfrontend/main.cpp 15 Mar 2005 23:55:29 -0000 @@ -725,6 +725,7 @@ QString verboseString = QString(" important general"); QString pluginname = ""; + QString geometry = ""; QFileInfo finfo(a.argv()[0]); @@ -738,7 +739,7 @@ if (!strcmp(a.argv()[argpos],"-l") || !strcmp(a.argv()[argpos],"--logfile")) { - if (a.argc() > argpos) + if (a.argc()-1 > argpos) { logfile = a.argv()[argpos+1]; if (logfile.startsWith("-")) @@ -751,10 +752,15 @@ ++argpos; } } + else + { + cerr << "Missing argument to -l/--logfile option\n"; + return -1; + } } else if (!strcmp(a.argv()[argpos],"-v") || !strcmp(a.argv()[argpos],"--verbose")) { - if (a.argc() > argpos) + if (a.argc()-1 > argpos) { QString temp = a.argv()[argpos+1]; if (temp.startsWith("-")) @@ -764,7 +770,7 @@ } else { QStringList verboseOpts; - verboseOpts = QStringList::split(',',a.argv()[argpos+1]); + verboseOpts = QStringList::split(',', temp); ++argpos; for (QStringList::Iterator it = verboseOpts.begin(); it != verboseOpts.end(); ++it ) @@ -852,6 +858,26 @@ cout << MYTH_BINARY_VERSION << endl; exit(0); } + else if (!strcmp(a.argv()[argpos],"-geometry") || + !strcmp(a.argv()[argpos],"--geometry")) + { + if (a.argc()-1 > argpos) + { + geometry = a.argv()[argpos+1]; + if (geometry.startsWith("-")) + { + cerr << "Invalid or missing argument to -geometry option\n"; + return -1; + } + else + ++argpos; + } + else + { + cerr << "Missing argument to -geometry option\n"; + return -1; + } + } else if ((argpos + 1 == a.argc()) && !QString(a.argv()[argpos]).startsWith("-")) { @@ -863,6 +889,7 @@ !strcmp(a.argv()[argpos],"--help"))) cerr << "Invalid argument: " << a.argv()[argpos] << endl; cerr << "Valid options are: " << endl << + "-geometry WxH+X+Y Override window size settings\n" << "-l or --logfile filename Writes STDERR and STDOUT messages to filename" << endl << "-v or --verbose debug-level Prints more information" << endl << " Accepts any combination (separated by comma)" << endl << @@ -914,6 +941,11 @@ gContext = NULL; gContext = new MythContext(MYTH_BINARY_VERSION); + if (geometry != "") + if (!gContext->ParseGeometryOverride(geometry)) + cerr << "Illegal -geometry argument '" + << geometry <<"' (ignored)\n"; + if(!gContext->Init()) { VERBOSE(VB_IMPORTANT, "Failed to init MythContext, exiting.");