diff options
| author | Tim Penhey <tim.penhey@canonical.com> | 2011-10-05 10:39:39 +1300 |
|---|---|---|
| committer | Tim Penhey <tim.penhey@canonical.com> | 2011-10-05 10:39:39 +1300 |
| commit | 5dcf1627b4ca655c6aa371025a19ac15452bedf0 (patch) | |
| tree | 39eb01f28499e09a903b2d825ddf759335d7dacb /plugins | |
| parent | 59daa5d8eac55232d8d171a6858f72838271b853 (diff) | |
| parent | 1adc81898ac0a79419978395dcba8de1af2fd090 (diff) | |
Merged panel-style-refactor into panel-style-namespace.
(bzr r1635.3.4)
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/unityshell/src/FilterRatingsButton.cpp | 6 | ||||
| -rw-r--r-- | plugins/unityshell/src/PanelMenuView.cpp | 47 | ||||
| -rw-r--r-- | plugins/unityshell/src/PanelMenuView.h | 3 | ||||
| -rw-r--r-- | plugins/unityshell/src/PluginAdapter.cpp | 72 | ||||
| -rw-r--r-- | plugins/unityshell/src/PluginAdapter.h | 3 | ||||
| -rw-r--r-- | plugins/unityshell/src/ResultViewGrid.cpp | 21 | ||||
| -rw-r--r-- | plugins/unityshell/src/WindowManager.h | 2 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 44 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 2 |
9 files changed, 150 insertions, 50 deletions
diff --git a/plugins/unityshell/src/FilterRatingsButton.cpp b/plugins/unityshell/src/FilterRatingsButton.cpp index 4acc5bb9c..38653588d 100644 --- a/plugins/unityshell/src/FilterRatingsButton.cpp +++ b/plugins/unityshell/src/FilterRatingsButton.cpp @@ -190,7 +190,7 @@ namespace unity { nux::BaseTexture *texture = normal_empty_->GetTexture(); if (index < total_full_stars) { - if (state = nux::State::NUX_STATE_NORMAL) + if (state == nux::State::NUX_STATE_NORMAL) texture = normal_full_->GetTexture(); else if (state == nux::State::NUX_STATE_PRELIGHT) texture = prelight_full_->GetTexture(); @@ -198,7 +198,7 @@ namespace unity { texture = active_full_->GetTexture(); } else if (index < total_full_stars + total_half_stars) { - if (state = nux::State::NUX_STATE_NORMAL) + if (state == nux::State::NUX_STATE_NORMAL) texture = normal_half_->GetTexture(); else if (state == nux::State::NUX_STATE_PRELIGHT) texture = prelight_half_->GetTexture(); @@ -206,7 +206,7 @@ namespace unity { texture = active_half_->GetTexture(); } else { - if (state = nux::State::NUX_STATE_NORMAL) + if (state == nux::State::NUX_STATE_NORMAL) texture = normal_empty_->GetTexture(); else if (state == nux::State::NUX_STATE_PRELIGHT) texture = prelight_empty_->GetTexture(); diff --git a/plugins/unityshell/src/PanelMenuView.cpp b/plugins/unityshell/src/PanelMenuView.cpp index 553f7e920..2883bcd3e 100644 --- a/plugins/unityshell/src/PanelMenuView.cpp +++ b/plugins/unityshell/src/PanelMenuView.cpp @@ -135,8 +135,11 @@ PanelMenuView::PanelMenuView(int padding) win_manager->window_maximized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMaximized)); win_manager->window_restored.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowRestored)); win_manager->window_unmapped.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnmapped)); + win_manager->window_mapped.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMapped)); win_manager->window_moved.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMoved)); win_manager->window_resized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMoved)); + win_manager->window_decorated.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowDecorated)); + win_manager->window_undecorated.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUndecorated)); panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelMenuView::Refresh)); @@ -871,14 +874,6 @@ PanelMenuView::Refresh() x = _padding; y = 0; - BamfWindow* window = bamf_matcher_get_active_window(_matcher); - if (BAMF_IS_WINDOW(window) && - bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) - { - DrawText(cr, x, y, width, height, "Ubuntu", "", 6); - x += _padding; - } - if (label) DrawText(cr, x, y, width, height, NULL, label); @@ -983,7 +978,7 @@ PanelMenuView::OnActiveWindowChanged(BamfView* old_view, // if we've just started tracking this window and it is maximized, let's // make sure it's undecorated just in case it slipped by us earlier // (I'm looking at you, Chromium!) - if (_is_maximized) + if (_is_maximized && WindowManager::Default ()->IsWindowDecorated(xid)) { WindowManager::Default()->Undecorate(xid); _maximized_set.insert(xid); @@ -1050,8 +1045,38 @@ PanelMenuView::OnWindowUnminimized(guint32 xid) void PanelMenuView::OnWindowUnmapped(guint32 xid) { - _decor_map.erase(xid); - _maximized_set.erase(xid); + if (WindowManager::Default()->IsWindowMaximized(xid)) + { + WindowManager::Default()->Decorate(xid); + _maximized_set.erase(xid); + } +} + +void +PanelMenuView::OnWindowMapped(guint32 xid) +{ + if (WindowManager::Default()->IsWindowMaximized(xid)) + { + WindowManager::Default()->Undecorate(xid); + _maximized_set.insert(xid); + } +} + +void +PanelMenuView::OnWindowDecorated(guint32 xid) +{ + _decor_map[xid] = true; + + if (_maximized_set.find(xid) != _maximized_set.end ()) + { + WindowManager::Default ()->Undecorate(xid); + } +} + +void +PanelMenuView::OnWindowUndecorated(guint32 xid) +{ + _decor_map[xid] = false; } void diff --git a/plugins/unityshell/src/PanelMenuView.h b/plugins/unityshell/src/PanelMenuView.h index 93cb0073d..004a9b842 100644 --- a/plugins/unityshell/src/PanelMenuView.h +++ b/plugins/unityshell/src/PanelMenuView.h @@ -71,9 +71,12 @@ public: void OnWindowMinimized(guint32 xid); void OnWindowUnminimized(guint32 xid); void OnWindowUnmapped(guint32 xid); + void OnWindowMapped(guint32 xid); void OnWindowMaximized(guint32 xid); void OnWindowRestored(guint32 xid); void OnWindowMoved(guint32 xid); + void OnWindowDecorated(guint32 xid); + void OnWindowUndecorated(guint32 xid); guint32 GetMaximizedWindow(); diff --git a/plugins/unityshell/src/PluginAdapter.cpp b/plugins/unityshell/src/PluginAdapter.cpp index c5ea2a671..addf4c7c9 100644 --- a/plugins/unityshell/src/PluginAdapter.cpp +++ b/plugins/unityshell/src/PluginAdapter.cpp @@ -36,6 +36,7 @@ PluginAdapter* PluginAdapter::_default = 0; #define MWM_HINTS_FUNCTIONS (1L << 0) #define MWM_HINTS_DECORATIONS (1L << 1) +#define MWM_HINTS_UNDECORATED_UNITY 0x80 #define _XA_MOTIF_WM_HINTS "_MOTIF_WM_HINTS" /* static */ @@ -141,6 +142,26 @@ PluginAdapter::NotifyStateChange(CompWindow* window, unsigned int state, unsigne } void +PluginAdapter::NotifyNewDecorationState(guint32 xid) +{ + bool wasTracked = (_window_decoration_state.find (xid) != _window_decoration_state.end ()); + bool wasDecorated = false; + + if (wasTracked) + wasDecorated = _window_decoration_state[xid]; + + bool decorated = IsWindowDecorated (xid); + + if (decorated == wasDecorated) + return; + + if (decorated && (!wasDecorated || !wasTracked)) + WindowManager::window_decorated.emit(xid); + else if (wasDecorated || !wasTracked) + WindowManager::window_undecorated.emit(xid); +} + +void PluginAdapter::Notify(CompWindow* window, CompWindowNotify notify) { switch (notify) @@ -402,27 +423,20 @@ PluginAdapter::IsWindowDecorated(guint32 xid) if (!hints) return ret; - if (type == hints_atom && format != 0 && hints->flags & MWM_HINTS_DECORATIONS) + /* Check for the presence of the high bit + * if present, it means that we undecorated + * this window, so don't mark it as undecorated */ + if (type == hints_atom && format != 0 && + hints->flags & MWM_HINTS_DECORATIONS) { - ret = hints->decorations & (MwmDecorAll | MwmDecorTitle); + /* Must have both bits set */ + _window_decoration_state[xid] = ret = + (hints->decorations & (MwmDecorAll | MwmDecorTitle)) || + (hints->decorations & MWM_HINTS_UNDECORATED_UNITY); } XFree(hints); return ret; - -/* FIXME compiz is too slow to update this value, and this could lead to - * issues like the bug #838923, since the read value isn't valid anymore - CompWindow* window; - - window = m_Screen->findWindow(win); - if (window) - { - unsigned int decor = window->mwmDecor(); - - return decor & (MwmDecorAll | MwmDecorTitle); - } - return true; -*/ } bool @@ -797,7 +811,7 @@ PluginAdapter::Decorate(guint32 xid) MotifWmHints hints = { 0 }; hints.flags = MWM_HINTS_DECORATIONS; - hints.decorations = GDK_DECOR_ALL; + hints.decorations = GDK_DECOR_ALL & ~(MWM_HINTS_UNDECORATED_UNITY); SetMwmWindowHints(xid, &hints); } @@ -807,8 +821,11 @@ PluginAdapter::Undecorate(guint32 xid) { MotifWmHints hints = { 0 }; + /* Set the high bit to indicate that we undecorated this + * window, when an application attempts to "undecorate" + * the window again, this bit will be cleared */ hints.flags = MWM_HINTS_DECORATIONS; - hints.decorations = 0; + hints.decorations = MWM_HINTS_UNDECORATED_UNITY; SetMwmWindowHints(xid, &hints); } @@ -831,7 +848,7 @@ void PluginAdapter::MaximizeIfBigEnough(CompWindow* window) Status status; std::string win_wmclass; int num_monitor; - CompOutput screen; + int screen_width; int screen_height; float covering_part; @@ -839,6 +856,9 @@ void PluginAdapter::MaximizeIfBigEnough(CompWindow* window) if (!window) return; + if ((window->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE) + return; + if (window->type() != CompWindowTypeNormalMask || (window->actions() & MAXIMIZABLE) != MAXIMIZABLE) return; @@ -856,17 +876,10 @@ void PluginAdapter::MaximizeIfBigEnough(CompWindow* window) return; num_monitor = window->outputDevice(); - screen = m_Screen->outputDevs().at(num_monitor); - - screen_height = screen.workArea().height(); - screen_width = screen.workArea().width(); + CompOutput &o = m_Screen->outputDevs().at(num_monitor); - if ((window->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE) - { - LOG_DEBUG(logger) << "window mapped and already maximized, just undecorate"; - Undecorate(window->id()); - return; - } + screen_height = o.workArea().height(); + screen_width = o.workArea().width(); // use server<parameter> because the window won't show the real parameter as // not mapped yet @@ -879,7 +892,6 @@ void PluginAdapter::MaximizeIfBigEnough(CompWindow* window) return; } - Undecorate(window->id()); window->maximize(MAXIMIZE_STATE); } diff --git a/plugins/unityshell/src/PluginAdapter.h b/plugins/unityshell/src/PluginAdapter.h index e5eb0502f..ee38ad176 100644 --- a/plugins/unityshell/src/PluginAdapter.h +++ b/plugins/unityshell/src/PluginAdapter.h @@ -106,6 +106,7 @@ public: void NotifyResized(CompWindow* window, int x, int y, int w, int h); void NotifyStateChange(CompWindow* window, unsigned int state, unsigned int last_state); void NotifyCompizEvent(const char* plugin, const char* event, CompOption::Vector& option); + void NotifyNewDecorationState(guint32 xid); void Decorate(guint32 xid); void Undecorate(guint32 xid); @@ -175,6 +176,8 @@ private: bool _in_show_desktop; CompWindow* _last_focused_window; + std::map<guint32, unsigned int> _window_decoration_state; + static PluginAdapter* _default; }; diff --git a/plugins/unityshell/src/ResultViewGrid.cpp b/plugins/unityshell/src/ResultViewGrid.cpp index bdca4f3d3..e1932e412 100644 --- a/plugins/unityshell/src/ResultViewGrid.cpp +++ b/plugins/unityshell/src/ResultViewGrid.cpp @@ -485,11 +485,24 @@ nux::Area* ResultViewGrid::KeyNavIteration(nux::KeyNavDirection direction) // crappy name. void ResultViewGrid::OnOnKeyNavFocusChange(nux::Area *area) { - if (HasKeyFocus()) { - focused_uri_ = results_.front().uri; - selected_index_ = 0; + if (selected_index_ < 0) + { + if (mouse_over_index_ >= 0) + { + // to hack around nux, nux sends the keynavfocuschange event before + // mouse clicks, so when mouse click happens we have already scrolled away + // because the keynav focus changed + focused_uri_ = results_[mouse_over_index_].uri; + selected_index_ = mouse_over_index_; + } + else + { + focused_uri_ = results_.front().uri; + selected_index_ = 0; + } + } NeedRedraw(); int items_per_row = GetItemsPerRow(); @@ -668,6 +681,8 @@ void ResultViewGrid::MouseClick(int x, int y, unsigned long button_flags, unsign { // we got a click on a button so activate it Result result = results_[index]; + selected_index_ = index; + focused_uri_ = result.uri; UriActivated.emit(result.uri); } } diff --git a/plugins/unityshell/src/WindowManager.h b/plugins/unityshell/src/WindowManager.h index 81849d576..932ea5253 100644 --- a/plugins/unityshell/src/WindowManager.h +++ b/plugins/unityshell/src/WindowManager.h @@ -107,6 +107,8 @@ public: sigc::signal<void, guint32> window_resized; sigc::signal<void, guint32> window_moved; sigc::signal<void, guint32> window_focus_changed; + sigc::signal<void, guint32> window_decorated; + sigc::signal<void, guint32> window_undecorated; sigc::signal<void> initiate_spread; sigc::signal<void> terminate_spread; diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 3a376310d..baa2cf2a4 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -773,8 +773,15 @@ void UnityShowdesktopHandler::fadeOut () mState = UnityShowdesktopHandler::FadeOut; mProgress = 1.0f; - mRemover->save (); - mRemover->remove (); + mWasHidden = mWindow->state () & CompWindowStateHiddenMask; + + if (!mWasHidden) + { + mWindow->changeState (mWindow->state () | CompWindowStateHiddenMask); + mWindow->windowNotify (CompWindowNotifyHide); + mRemover->save (); + mRemover->remove (); + } CompositeWindow::get (mWindow)->addDamage (); @@ -788,7 +795,12 @@ void UnityShowdesktopHandler::fadeIn () { mState = UnityShowdesktopHandler::FadeIn; - mRemover->restore (); + if (!mWasHidden) + { + mWindow->changeState (mWindow->state () & ~CompWindowStateHiddenMask); + mWindow->windowNotify (CompWindowNotifyShow); + mRemover->restore (); + } CompositeWindow::get (mWindow)->addDamage (); } @@ -850,6 +862,20 @@ void UnityShowdesktopHandler::handleEvent (XEvent *event) } } +void UnityShowdesktopHandler::windowNotify (CompWindowNotify n) +{ + if (n == CompWindowNotifyFocusChange && mWindow->minimized ()) + { + for (CompWindow *w : animating_windows) + w->focusSetEnabled (UnityWindow::get (w), false); + + mWindow->moveInputFocusToOtherWindow (); + + for (CompWindow *w : animating_windows) + w->focusSetEnabled (UnityWindow::get (w), true); + } +} + void UnityShowdesktopHandler::updateFrameRegion (CompRegion &r) { unsigned int oldUpdateFrameRegionIndex; @@ -1021,6 +1047,14 @@ void UnityScreen::handleEvent(XEvent* event) if (!skip_other_plugins) screen->handleEvent(event); + if (event->type == PropertyNotify) + { + if (event->xproperty.atom == Atoms::mwmHints) + { + PluginAdapter::Default ()->NotifyNewDecorationState(event->xproperty.window); + } + } + if (!skip_other_plugins && screen->otherGrabExist("deco", "move", "switcher", "resize", NULL) && !switcherController->Visible()) @@ -1711,6 +1745,10 @@ void UnityWindow::windowNotify(CompWindowNotify n) boost::dynamic_pointer_cast <minimized_window_handler_unity> (mMinimizeHandler); compizMinimizeHandler->windowNotify (n); } + else if (mShowdesktopHandler) + { + mShowdesktopHandler->windowNotify (n); + } // We do this after the notify to ensure input focus has actually been moved. if (n == CompWindowNotifyFocusChange) diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 630bd1f7a..9aa20a4e6 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -106,6 +106,7 @@ public: void paintAttrib (GLWindowPaintAttrib &attrib); unsigned int getPaintMask (); void handleEvent (XEvent *); + void windowNotify (CompWindowNotify n); void updateFrameRegion (CompRegion &r); UnityShowdesktopHandler::State state (); @@ -120,6 +121,7 @@ private: compiz::WindowInputRemover *mRemover; UnityShowdesktopHandler::State mState; float mProgress; + bool mWasHidden; }; |
