Skip to content

Commit

Permalink
Create the native window in the root widget
Browse files Browse the repository at this point in the history
 - refs #13376
  • Loading branch information
mark-kendall committed Jan 13, 2019
1 parent 2b783da commit f738ae1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
10 changes: 8 additions & 2 deletions mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -326,10 +326,16 @@ MythNotificationCenter *GetNotificationCenter(void)
MythPainterWindowGL::MythPainterWindowGL(MythMainWindow *win,
MythMainWindowPrivate *priv,
MythRenderOpenGL *rend)
: QWidget(win), parent(win), d(priv), render(rend)
: QWidget(win),
parent(win),
d(priv),
render(rend)
{
rend->setWidget(this);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_NativeWindow);
setAttribute(Qt::WA_DontCreateNativeAncestors);
winId();
render->setWidget(this);
}

QPaintEngine *MythPainterWindowGL::paintEngine() const
Expand Down
17 changes: 8 additions & 9 deletions mythtv/libs/libmythui/mythrender_opengl.cpp
Expand Up @@ -160,18 +160,17 @@ void MythRenderOpenGL::swapBuffers()
QOpenGLContext::swapBuffers(m_window);
}

void MythRenderOpenGL::setWidget(QWidget *w)
void MythRenderOpenGL::setWidget(QWidget *Widget)
{
if (!w)
if (!Widget)
return;

w->winId(); // Ensure native window
m_window = w->windowHandle();
m_window = Widget->windowHandle();
if (!m_window)
{
w = w->nativeParentWidget();
if (w)
m_window = w->windowHandle();
Widget = Widget->nativeParentWidget();
if (Widget)
m_window = Widget->windowHandle();
}

#ifdef ANDROID
Expand All @@ -185,8 +184,8 @@ void MythRenderOpenGL::setWidget(QWidget *w)

if (!create())
LOG(VB_GENERAL, LOG_WARNING, LOC + "setWidget create failed");
else if (w)
w->setAttribute(Qt::WA_PaintOnScreen);
else if (Widget)
Widget->setAttribute(Qt::WA_PaintOnScreen);
}

void MythRenderOpenGL::makeCurrent()
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythrender_opengl.h
Expand Up @@ -103,7 +103,7 @@ class MUI_PUBLIC MythRenderOpenGL : protected QOpenGLContext, public MythRender
virtual void doneCurrent();

virtual void swapBuffers();
void setWidget(QWidget *w);
void setWidget(QWidget *Widget);
bool IsDirectRendering() const;

void Init(void);
Expand Down

0 comments on commit f738ae1

Please sign in to comment.