From 5652cec1841d3d89778735f240fe622fd1d92ecf Mon Sep 17 00:00:00 2001
From: Oliver Mangold <o.mangold@gmail.com>
Date: Sun, 20 Jan 2013 12:06:27 +0100
Subject: [PATCH] - quick'n dirty fix for OpenGL window resize problem

---
 mythtv/libs/libmythtv/videoout_opengl.cpp   | 18 ++++++++++++++++++
 mythtv/libs/libmythui/mythrender_opengl.cpp | 11 +++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/mythtv/libs/libmythtv/videoout_opengl.cpp b/mythtv/libs/libmythtv/videoout_opengl.cpp
index b2b79fd..f6f2c3f 100644
--- a/mythtv/libs/libmythtv/videoout_opengl.cpp
+++ b/mythtv/libs/libmythtv/videoout_opengl.cpp
@@ -70,6 +70,24 @@ VideoOutputOpenGL::VideoOutputOpenGL(const QString &profile)
 
 VideoOutputOpenGL::~VideoOutputOpenGL()
 {
+    ResizeForGui();
+
+    // if width && height are zero users expect fullscreen playback
+    int gui_width = 0, gui_height = 0;
+    gCoreContext->GetResolutionSetting("Gui", gui_width, gui_height);
+    bool fullscreen = (0 == gui_width && 0 == gui_height);
+
+    if (fullscreen)
+    {
+        QSize sz(display_res->GetWidth(), display_res->GetHeight());
+        const QRect display_visible_rect =
+                    QRect(GetMythMainWindow()->geometry().topLeft(), sz);
+        window.SetDisplayVisibleRect(display_visible_rect);
+        MoveResize();
+        // Resize X window to fill new resolution
+        MoveResizeWindow(display_visible_rect);
+    }
+
     gl_context_lock.lock();
     TearDown();
 
diff --git a/mythtv/libs/libmythui/mythrender_opengl.cpp b/mythtv/libs/libmythui/mythrender_opengl.cpp
index 85ee086..39a7651 100644
--- a/mythtv/libs/libmythui/mythrender_opengl.cpp
+++ b/mythtv/libs/libmythui/mythrender_opengl.cpp
@@ -19,6 +19,9 @@ using namespace std;
 #include "util-nvctrl.h"
 #endif
 
+#include <QX11Info>
+#include <X11/Xlib.h>
+
 static const GLuint kTextureOffset = 8 * sizeof(GLfloat);
 
 static inline int __glCheck__(const QString &loc, const char* fileName, int n)
@@ -184,8 +187,12 @@ void MythRenderOpenGL::Release(void)
 void MythRenderOpenGL::MoveResizeWindow(const QRect &rect)
 {
     QWidget *parent = (QWidget*)this->device();
-    if (parent)
-        parent->setGeometry(rect);
+    if (parent) {
+        Window xw = parent->winId();
+        ::Display* display = parent->x11Info().display();
+        XMoveResizeWindow(display, xw, rect.left(), rect.top(),
+                          rect.width(), rect.height());
+    }
 }
 
 void MythRenderOpenGL::SetViewPort(const QRect &rect, bool viewportonly)
-- 
1.8.1.1

