diff options
| author | Jason Smith <jason.smith@canonical.com> | 2010-12-14 22:10:15 -0500 |
|---|---|---|
| committer | Jason Smith <jason.smith@canonical.com> | 2010-12-14 22:10:15 -0500 |
| commit | 979fffdadfb88acbdef9f34eccae78a40da53e9e (patch) | |
| tree | 7a1e472a8f27022ef80a76026098fda630a90b47 /src | |
| parent | f7c5941bf0726cf999588dfc894708c450add15b (diff) | |
Random autohide fixes
Utilize plugin adapter rather than passing events to launcher (bzr r711.1.1)
Diffstat (limited to 'src')
| -rw-r--r-- | src/BamfLauncherIcon.cpp | 16 | ||||
| -rw-r--r-- | src/BamfLauncherIcon.h | 4 | ||||
| -rw-r--r-- | src/Launcher.cpp | 51 | ||||
| -rw-r--r-- | src/Launcher.h | 70 | ||||
| -rw-r--r-- | src/LauncherController.cpp | 22 | ||||
| -rw-r--r-- | src/LauncherController.h | 2 | ||||
| -rw-r--r-- | src/LauncherIcon.h | 1 | ||||
| -rw-r--r-- | src/PluginAdapter.cpp | 25 | ||||
| -rw-r--r-- | src/PluginAdapter.h | 7 | ||||
| -rw-r--r-- | src/unity.cpp | 38 |
10 files changed, 99 insertions, 137 deletions
diff --git a/src/BamfLauncherIcon.cpp b/src/BamfLauncherIcon.cpp index d376061dd..b406f7d29 100644 --- a/src/BamfLauncherIcon.cpp +++ b/src/BamfLauncherIcon.cpp @@ -78,11 +78,13 @@ BamfLauncherIcon::BamfLauncherIcon (Launcher* IconManager, BamfApplication *app, g_signal_connect (app, "active-changed", (GCallback) &BamfLauncherIcon::OnActiveChanged, this); g_signal_connect (app, "user-visible-changed", (GCallback) &BamfLauncherIcon::OnUserVisibleChanged, this); g_signal_connect (app, "closed", (GCallback) &BamfLauncherIcon::OnClosed, this); - + g_object_ref (m_App); EnsureWindowState (); UpdateMenus (); + + PluginAdapter::Default ()->window_minimized.connect (sigc::mem_fun (this, &BamfLauncherIcon::OnWindowMinimized)); } BamfLauncherIcon::~BamfLauncherIcon() @@ -98,6 +100,16 @@ BamfLauncherIcon::~BamfLauncherIcon() g_object_unref (m_App); } +void +BamfLauncherIcon::OnWindowMinimized (CompWindow *window) +{ + if (!OwnsWindow (window->id ())) + return; + + Present (0.5f, 600); + UpdateQuirkTimeDelayed (300, LAUNCHER_ICON_QUIRK_SHIMMER); +} + bool BamfLauncherIcon::IsSticky () { @@ -138,7 +150,7 @@ BamfLauncherIcon::AddProperties (GVariantBuilder *builder) } bool -BamfLauncherIcon::IconOwnsWindow (Window w) +BamfLauncherIcon::OwnsWindow (Window w) { GList *children, *l; BamfView *view; diff --git a/src/BamfLauncherIcon.h b/src/BamfLauncherIcon.h index 0550e9257..488ab4740 100644 --- a/src/BamfLauncherIcon.h +++ b/src/BamfLauncherIcon.h @@ -48,7 +48,6 @@ protected: void UpdateIconGeometries (nux::Point3 center); void OnCenterStabilized (nux::Point3 center); - bool IconOwnsWindow (Window w); void AddProperties (GVariantBuilder *builder); @@ -68,6 +67,9 @@ private: void Spread (); void EnsureMenuItemsReady (); + + void OnWindowMinimized (CompWindow *window); + bool OwnsWindow (Window w); static void OnClosed (BamfView *view, gpointer data); static void OnUserVisibleChanged (BamfView *view, gboolean visible, gpointer data); diff --git a/src/Launcher.cpp b/src/Launcher.cpp index a732f9c7b..216835a5e 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -183,16 +183,26 @@ Launcher::Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_DE m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION); - OnMouseDown.connect(sigc::mem_fun(this, &Launcher::RecvMouseDown)); - OnMouseUp.connect(sigc::mem_fun(this, &Launcher::RecvMouseUp)); - OnMouseDrag.connect(sigc::mem_fun(this, &Launcher::RecvMouseDrag)); - OnMouseEnter.connect(sigc::mem_fun(this, &Launcher::RecvMouseEnter)); - OnMouseLeave.connect(sigc::mem_fun(this, &Launcher::RecvMouseLeave)); - OnMouseMove.connect(sigc::mem_fun(this, &Launcher::RecvMouseMove)); - OnMouseWheel.connect(sigc::mem_fun(this, &Launcher::RecvMouseWheel)); + OnMouseDown.connect (sigc::mem_fun (this, &Launcher::RecvMouseDown)); + OnMouseUp.connect (sigc::mem_fun (this, &Launcher::RecvMouseUp)); + OnMouseDrag.connect (sigc::mem_fun (this, &Launcher::RecvMouseDrag)); + OnMouseEnter.connect (sigc::mem_fun (this, &Launcher::RecvMouseEnter)); + OnMouseLeave.connect (sigc::mem_fun (this, &Launcher::RecvMouseLeave)); + OnMouseMove.connect (sigc::mem_fun (this, &Launcher::RecvMouseMove)); + OnMouseWheel.connect (sigc::mem_fun (this, &Launcher::RecvMouseWheel)); QuicklistManager::Default ()->quicklist_opened.connect (sigc::mem_fun(this, &Launcher::RecvQuicklistOpened)); QuicklistManager::Default ()->quicklist_closed.connect (sigc::mem_fun(this, &Launcher::RecvQuicklistClosed)); + + PluginAdapter::Default ()->window_maximized.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide)); + PluginAdapter::Default ()->window_restored.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide)); + PluginAdapter::Default ()->window_unminimized.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide)); + PluginAdapter::Default ()->window_mapped.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide)); + PluginAdapter::Default ()->window_unmapped.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide)); + PluginAdapter::Default ()->window_shown.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide)); + PluginAdapter::Default ()->window_hidden.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide)); + PluginAdapter::Default ()->window_resized.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide)); + PluginAdapter::Default ()->window_moved.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide)); m_ActiveTooltipIcon = NULL; m_ActiveMenuIcon = NULL; @@ -882,7 +892,7 @@ Launcher::CheckWindowOverLauncher () { CompWindow *window = *it; - if (window->type () != CompWindowTypeNormalMask || window->invisible ()) + if (window->type () != CompWindowTypeNormalMask || !window->isMapped ()) continue; if (CompRegion (window->inputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height))) @@ -898,28 +908,11 @@ Launcher::CheckWindowOverLauncher () } void -Launcher::OnWindowMoved (CompWindow *window) -{ - if (_autohide) - CheckWindowOverLauncher (); -} - -void -Launcher::OnWindowResized (CompWindow *window) -{ - if (_autohide) - CheckWindowOverLauncher (); -} - -void -Launcher::OnWindowAppear (CompWindow *window) -{ - if (_autohide) - CheckWindowOverLauncher (); -} -void -Launcher::OnWindowDisappear (CompWindow *window) +Launcher::OnWindowMaybeIntellihide (CompWindow *window) { + if (window->type () != CompWindowTypeNormalMask || !window->isMapped ()) + return; + if (_autohide) CheckWindowOverLauncher (); } diff --git a/src/Launcher.h b/src/Launcher.h index 9c53e0b76..4176231a1 100644 --- a/src/Launcher.h +++ b/src/Launcher.h @@ -30,6 +30,7 @@ #include "LauncherDragWindow.h" #include "NuxGraphics/IOpenGLAsmShader.h" #include "Nux/TimerProc.h" +#include "PluginAdapter.h" class LauncherModel; class QuicklistView; @@ -37,53 +38,48 @@ class QuicklistView; class Launcher : public Introspectable, public nux::View { public: - Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_PROTO); - ~Launcher(); + Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_PROTO); + ~Launcher(); - virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo); - virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); - virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); - virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw); + virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo); + virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); + virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); + virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw); - LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;} - LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;} + LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;} + LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;} - bool TooltipNotify(LauncherIcon* Icon); - bool MenuNotify(LauncherIcon* Icon); + bool TooltipNotify(LauncherIcon* Icon); + bool MenuNotify(LauncherIcon* Icon); - void SetIconSize(int tile_size, int icon_size); - void NotifyMenuTermination(LauncherIcon* Icon); + void SetIconSize(int tile_size, int icon_size); + void NotifyMenuTermination(LauncherIcon* Icon); - void SetModel (LauncherModel *model); + void SetModel (LauncherModel *model); - void SetFloating (bool floating); + void SetFloating (bool floating); - void SetAutohide (bool autohide, nux::View *show_trigger); - bool AutohideEnabled (); - - nux::BaseWindow* GetParent () { return _parent; }; - - void OnWindowMoved (CompWindow *window); - void OnWindowResized (CompWindow *window); - void OnWindowAppear (CompWindow *window); - void OnWindowDisappear (CompWindow *window); + void SetAutohide (bool autohide, nux::View *show_trigger); + bool AutohideEnabled (); + + nux::BaseWindow* GetParent () { return _parent; }; - virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags); - virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags); - virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); - virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags); - virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags); - virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); - virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags); + virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags); + virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags); + virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); + virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags); + virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags); + virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); + virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags); - virtual void RecvQuicklistOpened (QuicklistView *quicklist); - virtual void RecvQuicklistClosed (QuicklistView *quicklist); + virtual void RecvQuicklistOpened (QuicklistView *quicklist); + virtual void RecvQuicklistClosed (QuicklistView *quicklist); - sigc::signal<void, LauncherIcon *, LauncherIcon *> request_reorder; + sigc::signal<void, LauncherIcon *, LauncherIcon *> request_reorder; protected: - // Introspectable methods - const gchar* GetName (); - void AddProperties (GVariantBuilder *builder); + // Introspectable methods + const gchar* GetName (); + void AddProperties (GVariantBuilder *builder); private: typedef enum @@ -119,6 +115,8 @@ private: int window_indicators; } RenderArg; + void OnWindowMaybeIntellihide (CompWindow *window); + static gboolean AnimationTimeout (gpointer data); static gboolean OnAutohideTimeout (gpointer data); static gboolean StrutHack (gpointer data); diff --git a/src/LauncherController.cpp b/src/LauncherController.cpp index 242c5d184..1c9aaa355 100644 --- a/src/LauncherController.cpp +++ b/src/LauncherController.cpp @@ -122,28 +122,6 @@ LauncherController::OnLauncherRequestReorder (LauncherIcon *icon, LauncherIcon * _favorite_store->SetFavorites (desktop_paths); } -void -LauncherController::PresentIconOwningWindow (Window window) -{ - LauncherModel::iterator it; - LauncherIcon *owner = 0; - - for (it = _model->begin (); it != _model->end (); it++) - { - if ((*it)->IconOwnsWindow (window)) - { - owner = *it; - break; - } - } - - if (owner) - { - owner->Present (0.5f, 600); - owner->UpdateQuirkTimeDelayed (300, LAUNCHER_ICON_QUIRK_SHIMMER); - } -} - void LauncherController::OnExpoClicked (int button) { diff --git a/src/LauncherController.h b/src/LauncherController.h index 98278866b..61155f28e 100644 --- a/src/LauncherController.h +++ b/src/LauncherController.h @@ -43,8 +43,6 @@ public: LauncherController(Launcher* launcher, CompScreen *screen, nux::BaseWindow* window); ~LauncherController(); - void PresentIconOwningWindow (Window window); - private: BamfMatcher* _matcher; CompAction* _expo_action; diff --git a/src/LauncherIcon.h b/src/LauncherIcon.h index 43f172235..6e9b6a299 100644 --- a/src/LauncherIcon.h +++ b/src/LauncherIcon.h @@ -139,7 +139,6 @@ protected: virtual nux::BaseTexture * GetTextureForSize (int size) = 0; virtual void OnCenterStabilized (nux::Point3 center) {}; - virtual bool IconOwnsWindow (Window w) { return false; } nux::BaseTexture * TextureFromGtkTheme (const char *name, int size); nux::BaseTexture * TextureFromPath (const char *name, int size); diff --git a/src/PluginAdapter.cpp b/src/PluginAdapter.cpp index 8ccbc4c2d..0a5355dcb 100644 --- a/src/PluginAdapter.cpp +++ b/src/PluginAdapter.cpp @@ -25,28 +25,39 @@ PluginAdapter * PluginAdapter::_default = 0; PluginAdapter * PluginAdapter::Default () { - if (!_default) - return 0; - return _default; + if (!_default) + return 0; + return _default; } /* static */ void PluginAdapter::Initialize (CompScreen *screen) { - _default = new PluginAdapter (screen); + _default = new PluginAdapter (screen); } PluginAdapter::PluginAdapter(CompScreen *screen) { - m_Screen = screen; - m_ExpoAction = 0; - m_ScaleAction = 0; + m_Screen = screen; + m_ExpoAction = 0; + m_ScaleAction = 0; } PluginAdapter::~PluginAdapter() { +} +void +PluginAdapter::NotifyResized (CompWindow *window, int x, int y, int w, int h) +{ + window_resized.emit (window); +} + +void +PluginAdapter::NotifyMoved (CompWindow *window, int x, int y) +{ + window_moved.emit (window); } void diff --git a/src/PluginAdapter.h b/src/PluginAdapter.h index 6f9d3c287..0e259e1db 100644 --- a/src/PluginAdapter.h +++ b/src/PluginAdapter.h @@ -43,9 +43,10 @@ public: void InitiateExpo (); - void NotifyStateChange (CompWindow *window, unsigned int state, unsigned int last_state); - void Notify (CompWindow *window, CompWindowNotify notify); + void NotifyMoved (CompWindow *window, int x, int y); + void NotifyResized (CompWindow *window, int x, int y, int w, int h); + void NotifyStateChange (CompWindow *window, unsigned int state, unsigned int last_state); sigc::signal<void, CompWindow *> window_maximized; sigc::signal<void, CompWindow *> window_restored; @@ -57,6 +58,8 @@ public: sigc::signal<void, CompWindow *> window_unmapped; sigc::signal<void, CompWindow *> window_shown; sigc::signal<void, CompWindow *> window_hidden; + sigc::signal<void, CompWindow *> window_resized; + sigc::signal<void, CompWindow *> window_moved; protected: PluginAdapter(CompScreen *screen); diff --git a/src/unity.cpp b/src/unity.cpp index 7e6e38064..0e28d5e46 100644 --- a/src/unity.cpp +++ b/src/unity.cpp @@ -289,38 +289,6 @@ void UnityWindow::windowNotify (CompWindowNotify n) { PluginAdapter::Default ()->Notify (window, n); - - switch (n) - { - case CompWindowNotifyMinimize: - uScreen->controller->PresentIconOwningWindow (window->id ()); - uScreen->launcher->OnWindowDisappear (window); - break; - case CompWindowNotifyUnminimize: - uScreen->launcher->OnWindowAppear (window); - break; - case CompWindowNotifyShade: - uScreen->launcher->OnWindowDisappear (window); - break; - case CompWindowNotifyUnshade: - uScreen->launcher->OnWindowAppear (window); - break; - case CompWindowNotifyHide: - uScreen->launcher->OnWindowDisappear (window); - break; - case CompWindowNotifyShow: - uScreen->launcher->OnWindowAppear (window); - break; - case CompWindowNotifyMap: - uScreen->launcher->OnWindowAppear (window); - break; - case CompWindowNotifyUnmap: - uScreen->launcher->OnWindowDisappear (window); - break; - default: - break; - } - window->windowNotify (n); } @@ -334,14 +302,14 @@ UnityWindow::stateChangeNotify (unsigned int lastState) void UnityWindow::moveNotify (int x, int y, bool immediate) { - uScreen->launcher->OnWindowMoved (window); + PluginAdapter::Default ()->NotifyMoved (window, x, y); window->moveNotify (x, y, immediate); } void UnityWindow::resizeNotify (int x, int y, int w, int h) { - uScreen->launcher->OnWindowResized (window); + PluginAdapter::Default ()->NotifyResized (window, x, y, w, h); window->resizeNotify (x, y, w, h); } @@ -426,6 +394,7 @@ UnityScreen::UnityScreen (CompScreen *screen) : CompositeScreenInterface::setHandler (cScreen); GLScreenInterface::setHandler (gScreen); + PluginAdapter::Initialize (screen); StartupNotifyService::Default ()->SetSnDisplay (screen->snDisplay (), screen->screenNum ()); nux::NuxInitialize (0); @@ -441,7 +410,6 @@ UnityScreen::UnityScreen (CompScreen *screen) : debugger = new IntrospectionDBusInterface (this); - PluginAdapter::Initialize (screen); optionSetLauncherAutohideNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2)); optionSetLauncherFloatNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2)); |
