Back to index

unity  6.0.0
inputremover.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Canonical Ltd.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Authored By:
00019  * Sam Spilsbury <sam.spilsbury@canonical.com>
00020  */
00021 
00022 #ifndef _COMPIZ_INPUTREMOVER_H
00023 #define _COMPIZ_INPUTREMOVER_H
00024 
00025 #include <memory>
00026 #include <X11/Xlib.h>
00027 #include <X11/Xatom.h>
00028 #include <X11/extensions/shape.h>
00029 
00030 // Will be merged back into compiz
00031 namespace compiz {
00032 
00033 class WindowInputRemoverInterface
00034 {
00035   public:
00036 
00037     typedef std::shared_ptr <WindowInputRemoverInterface> Ptr;
00038 
00039     bool save () { return saveInput (); }
00040     bool remove () { return removeInput (); }
00041     bool restore () { return restoreInput (); }
00042 
00043     virtual ~WindowInputRemoverInterface ();
00044 
00045   protected:
00046 
00047     virtual bool saveInput () = 0;
00048     virtual bool removeInput () = 0;
00049     virtual bool restoreInput () = 0;
00050 };
00051 
00052 class WindowInputRemover :
00053   public WindowInputRemoverInterface
00054 {
00055 public:
00056 
00057   WindowInputRemover (Display *, Window xid);
00058   ~WindowInputRemover ();
00059 
00060 private:
00061 
00062   bool saveInput ();
00063   bool removeInput ();
00064   bool restoreInput ();
00065 
00066   void sendShapeNotify ();
00067 
00068   Display       *mDpy;
00069   Window        mShapeWindow;
00070   unsigned long mShapeMask;
00071 
00072   XRectangle    *mInputRects;
00073   int           mNInputRects;
00074   int           mInputRectOrdering;
00075 
00076   XRectangle    *mBoundingRects;
00077   int           mNBoundingRects;
00078   int           mBoundingRectOrdering;
00079   bool          mRemoved;
00080 
00081   int           mShapeEvent;
00082   int           mShapeError;
00083 
00084 };
00085 
00086 class WindowInputRemoverLock
00087 {
00088   public:
00089 
00090     typedef std::shared_ptr <WindowInputRemoverLock> Ptr;
00091     typedef std::weak_ptr <WindowInputRemoverLock> Weak;
00092 
00093     WindowInputRemoverLock (WindowInputRemoverInterface *remover) :
00094         remover_ (remover)
00095     {
00096       remover->save();
00097       remover->remove();
00098     }
00099 
00100     ~WindowInputRemoverLock ()
00101     {
00102       remover_->restore();
00103       delete remover_;
00104     }
00105 
00106     void refresh ()
00107     {
00108       remover_->save();
00109       remover_->remove();
00110     }
00111 
00112   private:
00113     WindowInputRemoverInterface *remover_;
00114 };
00115 
00116 class WindowInputRemoverLockAcquireInterface
00117 {
00118 public:
00119 
00120   virtual ~WindowInputRemoverLockAcquireInterface () {}
00121 
00122   WindowInputRemoverLock::Ptr InputRemover () { return GetInputRemover (); }
00123 
00124 private:
00125 
00126   virtual WindowInputRemoverLock::Ptr GetInputRemover () = 0;
00127 };
00128 
00129 }
00130 
00131 #endif