Skip to content

Commit

Permalink
MythUIWebBrowser: Automatically set the active state when on the top …
Browse files Browse the repository at this point in the history
…screen.

This fixes a problem were some popups like the music mini player would appear
behind the browser widget. Now if any screen is above it the browser will set
itself in the inactive state allowing any screen to appear above it.
  • Loading branch information
Paul Harrison committed Feb 21, 2011
1 parent df4306a commit d588328
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
55 changes: 54 additions & 1 deletion mythtv/libs/libmythui/mythuiwebbrowser.cpp
Expand Up @@ -30,7 +30,7 @@
#include "mythdirs.h"
#include "mythuihelper.h"
#include "mythcorecontext.h"

#include "mythscreentype.h"

/**
* @class BrowserApi
Expand Down Expand Up @@ -428,6 +428,30 @@ void MythUIWebBrowser::Init(void)
connect(this, SIGNAL(LosingFocus()),
this, SLOT(slotLosingFocus(void)));

// find what screen we are on
m_parentScreen = NULL;
QObject *parentObject = parent();
while(parentObject)
{
m_parentScreen = dynamic_cast<MythScreenType *>(parentObject);
if (m_parentScreen)
break;

parentObject = parentObject->parent();
}

if (!m_parentScreen)
VERBOSE(VB_IMPORTANT, "MythUIWebBrowser: failed to find our parent screen");

// connect to the topScreenChanged signals on each screen stack
for (int x = 0; x < GetMythMainWindow()->GetStackCount(); x++)
{
MythScreenStack *stack = GetMythMainWindow()->GetStackAt(x);
if (stack)
connect(stack, SIGNAL(topScreenChanged(MythScreenType *)),
this, SLOT(slotTopScreenChanged(MythScreenType *)));
}

// set up the icon cache directory
QString path = GetConfDir();
QDir dir(path);
Expand Down Expand Up @@ -768,6 +792,35 @@ void MythUIWebBrowser::slotLosingFocus(void)
UpdateBuffer();
}

void MythUIWebBrowser::slotTopScreenChanged(MythScreenType* screen)
{
(void) screen;

if (!m_parentScreen)
return;

// is our containing screen the top screen?
for (int x = GetMythMainWindow()->GetStackCount() - 1; x >= 0; x--)
{
MythScreenStack *stack = GetMythMainWindow()->GetStackAt(x);

// ignore stacks with no screens on them
if (!stack->GetTopScreen())
continue;

if (stack->GetTopScreen() == m_parentScreen)
{
SetActive(true);
break;
}
else
{
SetActive(false);
break;
}
}
}

void MythUIWebBrowser::UpdateBuffer(void)
{
if (!m_active || (m_active && !m_browser->hasFocus()))
Expand Down
4 changes: 4 additions & 0 deletions mythtv/libs/libmythui/mythuiwebbrowser.h
Expand Up @@ -16,6 +16,7 @@


class MythUIWebBrowser;
class MythScreenType;

class BrowserApi : public QObject
{
Expand Down Expand Up @@ -135,6 +136,7 @@ class MUI_PUBLIC MythUIWebBrowser : public MythUIType
void slotStatusBarMessage(const QString &text);
void slotIconChanged(void);
void slotLinkClicked(const QUrl &url);
void slotTopScreenChanged(MythScreenType *screen);

protected:
void Finalize(void);
Expand All @@ -150,6 +152,8 @@ class MUI_PUBLIC MythUIWebBrowser : public MythUIType
virtual void CopyFrom(MythUIType *base);
virtual void CreateCopy(MythUIType *parent);

MythScreenType *m_parentScreen;

MythWebView *m_browser;

MythImage *m_image;
Expand Down

0 comments on commit d588328

Please sign in to comment.