ScreenSaver: Stop saver on General tab.

Unfortunately OpenGL screen saver previews draw on top of the tabview,
so, when you switch to the General tab we now stop the screen saver
and then restart it when you come back to the Screensavers tab.
This commit is contained in:
John Scipione
2014-02-28 16:45:26 -05:00
parent c08eb212ef
commit 00d9a29e2e
2 changed files with 47 additions and 3 deletions
@@ -98,6 +98,14 @@ private:
}; };
class TabView : public BTabView {
public:
TabView();
virtual void MouseDown(BPoint where);
};
class FadeView : public BView { class FadeView : public BView {
public: public:
FadeView(const char* name, FadeView(const char* name,
@@ -148,6 +156,8 @@ public:
BScreenSaver* ScreenSaver(); BScreenSaver* ScreenSaver();
private: private:
friend class TabView;
static int _CompareScreenSaverItems(const void* left, static int _CompareScreenSaverItems(const void* left,
const void* right); const void* right);
@@ -836,6 +846,40 @@ ModulesView::_OpenSaver()
} }
// #pragma mark - TabView
TabView::TabView()
:
BTabView("tab_view", B_WIDTH_FROM_LABEL)
{
}
void
TabView::MouseDown(BPoint where)
{
BTab* fadeTab = TabAt(0);
BRect fadeTabFrame(TabFrame(0));
BTab* modulesTab = TabAt(1);
BRect modulesTabFrame(TabFrame(1));
ModulesView* modulesView = dynamic_cast<ModulesView*>(modulesTab->View());
if (fadeTab != NULL && Selection() != 0 && fadeTabFrame.Contains(where)
&& modulesView != NULL) {
// clicked on the fade tab
modulesView->SaveState();
modulesView->_CloseSaver();
} else if (modulesTab != NULL && Selection() != 1
&& modulesTabFrame.Contains(where) && modulesView != NULL) {
// clicked on the modules tab
modulesView->MessageReceived(new BMessage(kMsgSaverSelected));
}
BTabView::MouseDown(where);
}
// #pragma mark - ScreenSaverWindow // #pragma mark - ScreenSaverWindow
@@ -861,7 +905,7 @@ ScreenSaverWindow::ScreenSaverWindow()
fPasswordWindow->Run(); fPasswordWindow->Run();
// Create the tab view // Create the tab view
fTabView = new BTabView("tab_view", B_WIDTH_FROM_LABEL); fTabView = new TabView();
fTabView->SetBorder(B_NO_BORDER); fTabView->SetBorder(B_NO_BORDER);
// Create the controls inside the tabs // Create the controls inside the tabs
@@ -20,10 +20,10 @@
class BMessage; class BMessage;
class BRect; class BRect;
class BTabView;
class FadeView; class FadeView;
class ModulesView; class ModulesView;
class TabView;
class ScreenSaverWindow : public BDirectWindow { class ScreenSaverWindow : public BDirectWindow {
@@ -47,7 +47,7 @@ private:
FadeView* fFadeView; FadeView* fFadeView;
ModulesView* fModulesView; ModulesView* fModulesView;
BTabView* fTabView; TabView* fTabView;
}; };