Back to index

unity  6.0.0
UnityShowdesktopHandler.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /* Compiz unity plugin
00003  * unity.h
00004  *
00005  * Copyright (c) 2010-11 Canonical Ltd.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 3
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * Your own copyright notice would go above. You are free to choose whatever
00018  * licence you want, just take note that some compiz code is GPL and you will
00019  * not be able to re-use it if you want to use a different licence.
00020  */
00021 #ifndef UNITY_SHOWDESKTOP_HANDLER_H
00022 #define UNITY_SHOWDESKTOP_HANDLER_H
00023 
00024 #include <list>
00025 #include <algorithm>
00026 #include <core/region.h>
00027 
00028 #include <gio/gio.h>
00029 
00030 #include "inputremover.h"
00031 
00032 namespace unity
00033 {
00034 
00035 class ShowdesktopHandlerWindowInterface
00036 {
00037   public:
00038 
00039     enum class PostPaintAction {
00040       Wait = 0,
00041       Damage = 1,
00042       Remove = 2
00043     };
00044 
00045     virtual ~ShowdesktopHandlerWindowInterface ();
00046 
00047     void EnableFocus () { DoEnableFocus (); }
00048     void DisableFocus () { DoDisableFocus (); }
00049 
00050     bool OverrideRedirect () { return IsOverrideRedirect (); }
00051     bool Managed () { return IsManaged (); }
00052     bool Grabbed () { return IsGrabbed (); }
00053     bool DesktopOrDock () { return IsDesktopOrDock (); }
00054     bool SkipTaskbarOrPager () { return IsSkipTaskbarOrPager (); }
00055     bool Hidden () { return IsHidden (); }
00056     bool Shaded () { return IsShaded (); }
00057     bool Minimized () { return IsMinimized (); }
00058     bool ShowDesktopMode () { return IsInShowdesktopMode (); }
00059     void OverrideFrameRegion (CompRegion &r) { return DoOverrideFrameRegion (r); }
00060 
00061     void Hide () { DoHide (); }
00062     void NotifyHidden () { DoNotifyHidden (); }
00063     void Show () { DoShow (); }
00064     void NotifyShown () { DoNotifyShown (); }
00065     void MoveFocusAway () { DoMoveFocusAway (); }
00066 
00067     PostPaintAction HandleAnimations (unsigned int ms) { return DoHandleAnimations (ms); }
00068     void AddDamage () { DoAddDamage (); }
00069 
00070     void DeleteHandler () { DoDeleteHandler (); }
00071 
00072     unsigned int NoCoreInstanceMask () { return GetNoCoreInstanceMask (); }
00073 
00074   private:
00075 
00076     virtual void DoEnableFocus () = 0;
00077     virtual void DoDisableFocus () = 0;
00078 
00079     virtual bool IsOverrideRedirect () = 0;
00080     virtual bool IsManaged () = 0;
00081     virtual bool IsGrabbed () = 0;
00082     virtual bool IsDesktopOrDock () = 0;
00083 
00084     virtual bool IsSkipTaskbarOrPager () = 0;
00085     virtual bool IsHidden () = 0;
00086     virtual bool IsInShowdesktopMode () = 0;
00087     virtual bool IsShaded () = 0;
00088 
00089     virtual bool IsMinimized () = 0;
00090 
00091     virtual void DoOverrideFrameRegion (CompRegion &) = 0;
00092 
00093     virtual void DoHide () = 0;
00094     virtual void DoNotifyHidden () = 0;
00095     virtual void DoShow () = 0;
00096     virtual void DoNotifyShown () = 0;
00097 
00098     virtual void DoMoveFocusAway () = 0;
00099     virtual PostPaintAction DoHandleAnimations (unsigned int ms) = 0;
00100     virtual void DoAddDamage () = 0;
00101 
00102     virtual void DoDeleteHandler () = 0;
00103 
00104     virtual unsigned int GetNoCoreInstanceMask () = 0;
00105 };
00106 
00107 class ShowdesktopHandler
00108 {
00109  public:
00110 
00111   ShowdesktopHandler (ShowdesktopHandlerWindowInterface *uwi, compiz::WindowInputRemoverLockAcquireInterface *lock_acquire_interface);
00112   ~ShowdesktopHandler ();
00113 
00114   typedef enum {
00115     StateVisible = 0,
00116     StateFadeOut = 1,
00117     StateFadeIn = 2,
00118     StateInvisible = 3
00119   } State;
00120 
00121 public:
00122 
00123   void FadeOut ();
00124   void FadeIn ();
00125   ShowdesktopHandlerWindowInterface::PostPaintAction Animate (unsigned int ms);
00126   void PaintOpacity (unsigned short &opacity);
00127   unsigned int GetPaintMask ();
00128   void HandleShapeEvent ();
00129   void WindowFocusChangeNotify ();
00130   void UpdateFrameRegion (CompRegion &r);
00131 
00132   ShowdesktopHandler::State GetState ();
00133 
00134   static const unsigned int fade_time;
00135   static std::list <ShowdesktopHandlerWindowInterface *> animating_windows;
00136   static bool ShouldHide (ShowdesktopHandlerWindowInterface *);
00137   static void InhibitLeaveShowdesktopMode (guint32 xid);
00138   static void AllowLeaveShowdesktopMode (guint32 xid);
00139   static guint32 InhibitingXid ();
00140 
00141 private:
00142 
00143   ShowdesktopHandlerWindowInterface *showdesktop_handler_window_interface_;
00144   compiz::WindowInputRemoverLockAcquireInterface *lock_acquire_interface_;
00145   compiz::WindowInputRemoverLock::Ptr remover_;
00146   ShowdesktopHandler::State         state_;
00147   float                                  progress_;
00148   bool                                   was_hidden_;
00149   static guint32                     inhibiting_xid;
00150 };
00151 
00152 }
00153 
00154 
00155 #endif