~unity-team/unity/trunk

« back to all changes in this revision

Viewing changes to unity-shared/PluginAdapter.cpp

  • Committer: Tarmac
  • Author(s): Brandon Schaefer
  • Date: 2013-07-12 16:06:39 UTC
  • mfrom: (3377.2.4 show-desktop-fix)
  • Revision ID: tarmac-20130712160639-ozeg4qp20dp97ms3
Show desktop now only works for individual workspaces. Also if any new windows are opened, or one is restored on that workspace then the next Show desktop will minimize those. The only time windows are restored are when no new windows have been mapped, and no windows have been restored for that workspace only. Fixes: https://bugs.launchpad.net/bugs/966030.

Approved by PS Jenkins bot, Christopher Townsend, Marco Trevisan (Treviño).

Show diffs side-by-side

added added

removed removed

Lines of Context:
217
217
  }
218
218
  else if (g_strcmp0(event, "end_viewport_switch") == 0)
219
219
  {
 
220
    UpdateShowDesktopState();
 
221
 
220
222
    _vp_switch_started = false;
221
223
    screen_viewport_switch_ended.emit();
222
224
  }
610
612
  return 0;
611
613
}
612
614
 
 
615
bool PluginAdapter::IsCurrentViewportEmpty() const
 
616
{
 
617
  Window win = GetTopMostValidWindowInViewport();
 
618
 
 
619
  if (win)
 
620
  {
 
621
    CompWindow* cwin = m_Screen->findWindow(win);
 
622
    if (!(cwin->type() & NO_FOCUS_MASK))
 
623
      return false;
 
624
  }
 
625
 
 
626
  return true;
 
627
}
 
628
 
613
629
Window PluginAdapter::GetTopWindowAbove(Window xid) const
614
630
{
615
631
  CompWindow* window;
920
936
 
921
937
void PluginAdapter::OnShowDesktop()
922
938
{
923
 
  LOG_DEBUG(logger) << "Now in show desktop mode.";
924
939
  _in_show_desktop = true;
925
940
}
926
941
 
927
942
void PluginAdapter::OnLeaveDesktop()
928
943
{
929
 
  LOG_DEBUG(logger) << "No longer in show desktop mode.";
930
944
  _in_show_desktop = false;
931
945
}
932
946
 
 
947
void PluginAdapter::UpdateShowDesktopState()
 
948
{
 
949
  if (!IsCurrentViewportEmpty())
 
950
  {
 
951
    OnLeaveDesktop();
 
952
  }
 
953
  else
 
954
  {
 
955
    CompWindow* window;
 
956
    CompPoint screen_vp = m_Screen->vp();
 
957
 
 
958
    auto const& windows = m_Screen->windows();
 
959
    for (auto it = windows.rbegin(); it != windows.rend(); ++it)
 
960
    {
 
961
      window = *it;
 
962
      if (window->defaultViewport() == screen_vp &&
 
963
          window->inShowDesktopMode())
 
964
      {
 
965
        OnShowDesktop();
 
966
        break;
 
967
      }
 
968
    }
 
969
  }
 
970
}
 
971
 
933
972
int PluginAdapter::GetWindowMonitor(Window window_id) const
934
973
{
935
974
  // FIXME, we should use window->outputDevice() but this is not UScreen friendly