1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
5
* Copyright (c) 2010-11 Canonical Ltd.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* Your own copyright notice would go above. You are free to choose whatever
18
* licence you want, just take note that some compiz code is GPL and you will
19
* not be able to re-use it if you want to use a different licence.
23
#include "UnityShowdesktopHandler.h"
28
ShowdesktopHandlerWindowInterface::~ShowdesktopHandlerWindowInterface()
33
const unsigned int ShowdesktopHandler::fade_time = 300;
34
std::list <ShowdesktopHandlerWindowInterface *> ShowdesktopHandler::animating_windows (0);
36
bool ShowdesktopHandler::ShouldHide (ShowdesktopHandlerWindowInterface *wi)
38
if (wi->OverrideRedirect())
47
if (wi->DesktopOrDock())
50
if (wi->SkipTaskbarOrPager())
54
if ((wi->ShowDesktopMode() || wi->Shaded()))
60
guint32 ShowdesktopHandler::inhibiting_xid = 0;
63
ShowdesktopHandler::InhibitLeaveShowdesktopMode (guint32 xid)
70
ShowdesktopHandler::AllowLeaveShowdesktopMode (guint32 xid)
72
if (inhibiting_xid == xid)
77
ShowdesktopHandler::InhibitingXid()
79
return inhibiting_xid;
82
ShowdesktopHandler::ShowdesktopHandler (ShowdesktopHandlerWindowInterface *wi) :
83
showdesktop_handler_window_interface_ (wi),
84
remover_ (wi->InputRemover()),
85
state_ (StateVisible),
90
ShowdesktopHandler::~ShowdesktopHandler()
94
void ShowdesktopHandler::FadeOut()
96
if (state_ != StateVisible && state_ != StateFadeIn)
99
state_ = ShowdesktopHandler::StateFadeOut;
102
was_hidden_ = showdesktop_handler_window_interface_->Hidden();
106
showdesktop_handler_window_interface_->Hide();
107
showdesktop_handler_window_interface_->NotifyHidden();
111
if (std::find (animating_windows.begin(),
112
animating_windows.end(),
113
showdesktop_handler_window_interface_) == animating_windows.end())
114
animating_windows.push_back (showdesktop_handler_window_interface_);
119
void ShowdesktopHandler::FadeIn()
121
if (state_ != StateInvisible && state_ != StateFadeOut)
124
state_ = ShowdesktopHandler::StateFadeIn;
128
showdesktop_handler_window_interface_->Show();
129
showdesktop_handler_window_interface_->NotifyShown();
132
if (std::find (animating_windows.begin(),
133
animating_windows.end(),
134
showdesktop_handler_window_interface_) == animating_windows.end())
135
animating_windows.push_back(showdesktop_handler_window_interface_);
139
ShowdesktopHandlerWindowInterface::PostPaintAction ShowdesktopHandler::Animate (unsigned int ms)
141
float inc = ms / static_cast <float> (fade_time);
143
if (state_ == ShowdesktopHandler::StateFadeOut)
146
if (progress_ >= 1.0f)
149
state_ = StateInvisible;
152
else if (state_ == StateFadeIn)
155
if (progress_ <= 0.0f)
158
state_ = StateVisible;
161
else if (state_ == StateVisible)
162
return ShowdesktopHandlerWindowInterface::PostPaintAction::Remove;
163
else if (state_ == StateInvisible)
164
return ShowdesktopHandlerWindowInterface::PostPaintAction::Wait;
166
return ShowdesktopHandlerWindowInterface::PostPaintAction::Damage;
169
void ShowdesktopHandler::PaintOpacity (unsigned short &opacity)
171
if (progress_ == 1.0f || progress_ == 0.0f)
172
opacity = std::numeric_limits <unsigned short>::max();
174
opacity *= (1.0f - progress_);
177
unsigned int ShowdesktopHandler::GetPaintMask()
179
return (progress_ == 1.0f) ? showdesktop_handler_window_interface_->NoCoreInstanceMask() : 0;
182
void ShowdesktopHandler::HandleShapeEvent()
184
/* Ignore sent events from the InputRemover */
192
void ShowdesktopHandler::WindowFocusChangeNotify()
194
if (showdesktop_handler_window_interface_->Minimized())
196
for (ShowdesktopHandlerWindowInterface *w : animating_windows)
199
showdesktop_handler_window_interface_->MoveFocusAway();
201
for (ShowdesktopHandlerWindowInterface *w : animating_windows)
206
void ShowdesktopHandler::UpdateFrameRegion (CompRegion &r)
210
/* Ensure no other plugins can touch this frame region */
211
showdesktop_handler_window_interface_->OverrideFrameRegion (r);