Index: libs/libmythtv/videoout_xv.cpp
===================================================================
--- libs/libmythtv/videoout_xv.cpp	(revision 10239)
+++ libs/libmythtv/videoout_xv.cpp	(working copy)
@@ -982,8 +982,7 @@
     (void)stream_type, (void)xvmc_chroma, (void)test_surface;
 
 #ifdef USING_XVMC
-    Display *disp;
-    X11S(disp = XOpenDisplay(NULL));
+    Display *disp = MythXOpenDisplay();
 
     // Disable features based on environment and DB values.
     bool use_xvmc_vld = false, use_xvmc_idct = false, use_xvmc = false;
@@ -1185,7 +1184,7 @@
 
     XV_INIT_FATAL_ERROR_TEST(winid <= 0, "Invalid Window ID.");
 
-    X11S(XJ_disp = XOpenDisplay(NULL));
+    XJ_disp = MythXOpenDisplay();
     XV_INIT_FATAL_ERROR_TEST(!XJ_disp, "Failed to open display.");
 
     // Initialize X stuff
Index: libs/libmythtv/XvMCSurfaceTypes.cpp
===================================================================
--- libs/libmythtv/XvMCSurfaceTypes.cpp	(revision 10239)
+++ libs/libmythtv/XvMCSurfaceTypes.cpp	(working copy)
@@ -5,13 +5,9 @@
 
 static inline Display* createXvMCDisplay() 
 {
-    Display *disp = NULL;
-    X11S(disp = XOpenDisplay(NULL));
+    Display *disp = MythXOpenDisplay();
     if (!disp) 
-    {
-        VERBOSE(VB_IMPORTANT, "XOpenDisplay failed");
-        return 0;
-    }
+        return NULL;
 
     unsigned int p_version, p_release, p_request_base, p_event_base, 
                  p_error_base;
Index: libs/libmyth/mythcontext.h
===================================================================
--- libs/libmyth/mythcontext.h	(revision 10239)
+++ libs/libmyth/mythcontext.h	(working copy)
@@ -222,7 +222,7 @@
 
 /// Update this whenever the plug-in API changes.
 /// Including changes in the libmythtv class methods used by plug-ins.
-#define MYTH_BINARY_VERSION "0.19.20060614-1"
+#define MYTH_BINARY_VERSION "0.19.20060619-1"
 
 /** \brief Increment this whenever the MythTV network protocol changes.
  *
@@ -412,6 +412,9 @@
     QString removeCurrentLocation(void);
     QString getCurrentLocation(void);
 
+    void SetX11Display(const QString &display);
+    QString GetX11Display(void) const;
+
     static QMutex verbose_mutex;
 
   private:
Index: libs/libmyth/util-x11.cpp
===================================================================
--- libs/libmyth/util-x11.cpp	(revision 10239)
+++ libs/libmyth/util-x11.cpp	(working copy)
@@ -34,8 +34,8 @@
     int nr_xinerama_screens = 0;
 
 #ifdef Q_WS_X11
+    Display *d = MythXOpenDisplay();
     X11L;
-    Display *d = XOpenDisplay(NULL);
     int event_base = 0, error_base = 0;
     if (XineramaQueryExtension(d, &event_base, &error_base) &&
         XineramaIsActive(d))
@@ -51,6 +51,27 @@
     return nr_xinerama_screens;
 }
 
+Display *MythXOpenDisplay(void)
+{
+#ifdef Q_WS_X11
+    QString dispStr = gContext->GetX11Display();
+    const char *dispCStr = NULL;
+    if (!dispStr.isEmpty())
+        dispCStr = dispStr.ascii();
+
+    X11L;
+    Display *disp = XOpenDisplay(dispCStr);
+    X11U;
+
+    if (!disp)
+        VERBOSE(VB_IMPORTANT, "MythXOpenDisplay() failed");
+
+    return disp;
+#else
+    return NULL;
+#endif
+}
+
 // Everything below this line is only compiled if using X11
 
 #ifdef Q_WS_X11
Index: libs/libmyth/util-x11.h
===================================================================
--- libs/libmyth/util-x11.h	(revision 10239)
+++ libs/libmyth/util-x11.h	(working copy)
@@ -10,6 +10,7 @@
 #include <X11/Xlib.h>
 #include <vector>
 
+Display *MythXOpenDisplay(void);
 int XJ_error_catcher(Display * d, XErrorEvent * xeev);
 void InstallXErrorHandler(Display *d);
 void PrintXErrors(Display *d, const std::vector<XErrorEvent>& events);
Index: libs/libmyth/DisplayResX.cpp
===================================================================
--- libs/libmyth/DisplayResX.cpp	(revision 10239)
+++ libs/libmyth/DisplayResX.cpp	(working copy)
@@ -12,11 +12,11 @@
 #include <X11/extensions/Xrandr.h>
 }
 
-
 #include "util-x11.h"
 
 using namespace X11;
 
+Display *MythXOpenDisplay(void);
 static XRRScreenConfiguration *GetScreenConfig(Display*& display);
 
 DisplayResX::DisplayResX(void)
@@ -30,8 +30,7 @@
 
 bool DisplayResX::GetDisplaySize(int &width_mm, int &height_mm) const
 {
-    Display *display = NULL;
-    X11S(display = XOpenDisplay(NULL));
+    Display *display = MythXOpenDisplay();
     if (display == NULL)
         return false;
 
@@ -113,10 +112,10 @@
 
 static XRRScreenConfiguration *GetScreenConfig(Display*& display)
 {
-    X11S(display = XOpenDisplay(NULL));
+    display = MythXOpenDisplay();
     if (!display)
     {
-        cerr<<"DisplaResX: Unable to XOpenDisplay"<<endl;
+        cerr<<"DisplaResX: MythXOpenDisplay call failed"<<endl;
         return NULL;
     }
 
Index: libs/libmyth/mythcontext.cpp
===================================================================
--- libs/libmyth/mythcontext.cpp	(revision 10239)
+++ libs/libmyth/mythcontext.cpp	(working copy)
@@ -218,6 +218,8 @@
 
     MythMainWindow *mainWindow;
 
+    QString m_x11_display;
+
     float m_wmult, m_hmult;
 
     // The part of the screen(s) allocated for the GUI. Unless
@@ -276,6 +278,7 @@
       attemptingToConnect(false),
       language(""),
       mainWindow(NULL),
+      m_x11_display(QString::null),
       m_wmult(1.0), m_hmult(1.0),
       m_screenxbase(0), m_screenybase(0), m_screenwidth(0), m_screenheight(0),
       m_geometry_x(0), m_geometry_y(0), m_geometry_w(0), m_geometry_h(0),
@@ -2881,4 +2884,14 @@
     return d->screensaver->Asleep();
 }
 
+void MythContext::SetX11Display(const QString &display)
+{
+    d->m_x11_display = QDeepCopy<QString>(display);
+}
+
+QString MythContext::GetX11Display(void) const
+{
+    return QDeepCopy<QString>(d->m_x11_display);
+}
+
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
Index: programs/mythfrontend/main.cpp
===================================================================
--- programs/mythfrontend/main.cpp	(revision 10239)
+++ programs/mythfrontend/main.cpp	(working copy)
@@ -746,11 +746,17 @@
 int main(int argc, char **argv)
 {
     QString geometry = "";
+    QString display  = QString::null;
 #ifdef Q_WS_X11
-    // Remember any -geometry argument which QApplication init will remove
+    // Remember any -display or -geometry argument
+    // which QApplication init will remove.
     for(int argpos = 1; argpos + 1 < argc; ++argpos)
+    {
         if (!strcmp(argv[argpos],"-geometry"))
             geometry = argv[argpos+1];
+        else if (!strcmp(argv[argpos],"-display"))
+            display = argv[argpos+1];
+    }
 #endif
 
 #ifdef Q_WS_MACX
@@ -870,6 +876,26 @@
 
             ++argpos;
         }
+        else if (!strcmp(a.argv()[argpos],"-display") ||
+                 !strcmp(a.argv()[argpos],"--display"))
+        {
+            if (a.argc()-1 > argpos)
+            {
+                display = a.argv()[argpos+1];
+                if (display.startsWith("-"))
+                {
+                    cerr << "Invalid or missing argument to -display option\n";
+                    return FRONTEND_EXIT_INVALID_CMDLINE;
+                }
+                else
+                    ++argpos;
+            }
+            else
+            {
+                cerr << "Missing argument to -display option\n";
+                return FRONTEND_EXIT_INVALID_CMDLINE;
+            }
+        }
         else if (!strcmp(a.argv()[argpos],"-geometry") ||
                  !strcmp(a.argv()[argpos],"--geometry"))
         {
@@ -980,6 +1006,11 @@
        return FRONTEND_EXIT_OK;
     }
 
+    if (!display.isEmpty())
+    {
+        gContext->SetX11Display(display);
+    }
+
     if (geometry != "" && !gContext->ParseGeometryOverride(geometry))
     {
         VERBOSE(VB_IMPORTANT,
