From 7fe298a3f7bec0ac97921bb31372b316a64c9668 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 1 Jun 2010 01:26:40 -0700 Subject: [PATCH] Cleanup on encapsulation. Addition of initial widescreen detection. --- src/ui/uxmanager.cpp | 70 ++++++++++++++++++++++++++++++++++++-------- src/ui/uxmanager.h | 17 ++++++----- 2 files changed, 67 insertions(+), 20 deletions(-) diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp index 3c6f85b91..ae4de62e3 100644 --- a/src/ui/uxmanager.cpp +++ b/src/ui/uxmanager.cpp @@ -20,6 +20,7 @@ #include "widgets/toolbox.h" #include "widgets/desktop-widget.h" #include "preferences.h" +#include "gdkmm/screen.h" #ifdef GDK_WINDOWING_X11 #include @@ -44,17 +45,45 @@ namespace UI { UXManager* instance = 0; +class UXManagerImpl : public UXManager +{ +public: + UXManagerImpl(); + virtual ~UXManagerImpl(); + + virtual void setTask(SPDesktop* dt, gint val); + virtual void addTrack( SPDesktopWidget* dtw ); + virtual void delTrack( SPDesktopWidget* dtw ); + virtual void connectToDesktop( vector const & toolboxes, SPDesktop *desktop ); + + virtual bool isFloatWindowProblem() const; + virtual bool isWidescreen() const; + +private: + bool _floatwindowIssues; + bool _widescreen; +}; + UXManager* UXManager::getInstance() { if (!instance) { - instance = new UXManager(); + instance = new UXManagerImpl(); } return instance; } -UXManager::UXManager() : - floatwindowIssues(false) +UXManager::UXManager() +{ +} + +UXManager::~UXManager() +{ +} + +UXManagerImpl::UXManagerImpl() : + _floatwindowIssues(false), + _widescreen(false) { ege::TagSet tags; tags.setLang("en"); @@ -68,24 +97,39 @@ UXManager::UXManager() : //if (g_ascii_strcasecmp( wmName, UNKOWN_WINDOW_MANAGER_NAME ) == 0) { if (g_ascii_strcasecmp( wmName, KDE_WINDOW_MANAGER_NAME ) == 0) { - floatwindowIssues = true; + _floatwindowIssues = true; } #elif defined(GDK_WINDOWING_WIN32) - floatwindowIssues = true; + _floatwindowIssues = true; #endif // GDK_WINDOWING_WIN32 + + + Glib::RefPtr defaultScreen = Gdk::Screen::get_default(); + if (defaultScreen) { + int width = defaultScreen->get_width(); + int height = defaultScreen->get_height(); + gdouble aspect = static_cast(width) / static_cast(height); + if (aspect > 1.4) { + _widescreen = true; + } + } } -UXManager::~UXManager() +UXManagerImpl::~UXManagerImpl() { } +bool UXManagerImpl::isFloatWindowProblem() const +{ + return _floatwindowIssues; +} -bool UXManager::isFloatWindowProblem() const +bool UXManagerImpl::isWidescreen() const { - return floatwindowIssues; + return _widescreen; } -void UXManager::setTask(SPDesktop* dt, gint val) +void UXManagerImpl::setTask(SPDesktop* dt, gint val) { for (vector::iterator it = dtws.begin(); it != dtws.end(); ++it) { SPDesktopWidget* dtw = *it; @@ -124,14 +168,14 @@ void UXManager::setTask(SPDesktop* dt, gint val) } -void UXManager::addTrack( SPDesktopWidget* dtw ) +void UXManagerImpl::addTrack( SPDesktopWidget* dtw ) { if (std::find(dtws.begin(), dtws.end(), dtw) == dtws.end()) { dtws.push_back(dtw); } } -void UXManager::delTrack( SPDesktopWidget* dtw ) +void UXManagerImpl::delTrack( SPDesktopWidget* dtw ) { vector::iterator iter = std::find(dtws.begin(), dtws.end(), dtw); if (iter != dtws.end()) { @@ -139,9 +183,9 @@ void UXManager::delTrack( SPDesktopWidget* dtw ) } } -void UXManager::connectToDesktop( vector const & toolboxes, SPDesktop *desktop ) +void UXManagerImpl::connectToDesktop( vector const & toolboxes, SPDesktop *desktop ) { -//static map > trackedBoxes; + //static map > trackedBoxes; for (vector::const_iterator it = toolboxes.begin(); it != toolboxes.end(); ++it ) { GtkWidget* toolbox = *it; diff --git a/src/ui/uxmanager.h b/src/ui/uxmanager.h index aecda2b5e..7f7cc6ecb 100644 --- a/src/ui/uxmanager.h +++ b/src/ui/uxmanager.h @@ -34,19 +34,22 @@ public: static UXManager* getInstance(); virtual ~UXManager(); - void addTrack( SPDesktopWidget* dtw ); - void delTrack( SPDesktopWidget* dtw ); + virtual void addTrack( SPDesktopWidget* dtw ) = 0; + virtual void delTrack( SPDesktopWidget* dtw ) = 0; - void connectToDesktop( std::vector const & toolboxes, SPDesktop *desktop ); + virtual void connectToDesktop( std::vector const & toolboxes, SPDesktop *desktop ) = 0; - void setTask(SPDesktop* dt, gint val); + virtual void setTask(SPDesktop* dt, gint val) = 0; - bool isFloatWindowProblem() const; + virtual bool isFloatWindowProblem() const = 0; + virtual bool isWidescreen() const = 0; -private: +protected: UXManager(); - bool floatwindowIssues; +private: + UXManager( UXManager const & ); + UXManager & operator=( UXManager const & ); }; } // namespace UI -- 2.30.2