Back to index

unity  6.0.0
comptransientfor.cpp
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 #include "comptransientfor.h"
00023 
00024 namespace compiz
00025 {
00026 class PrivateCompTransientForReader
00027 {
00028 public:
00029 
00030   PrivateCompTransientForReader () {};
00031 
00032   CompWindow *mWindow;
00033 };
00034 }
00035 
00036 compiz::CompTransientForReader::CompTransientForReader (CompWindow *w) :
00037   X11TransientForReader (screen->dpy (), w->id ())
00038 {
00039   priv = new PrivateCompTransientForReader ();
00040 
00041   priv->mWindow = w;
00042 }
00043 
00044 compiz::CompTransientForReader::~CompTransientForReader ()
00045 {
00046   delete priv;
00047 }
00048 
00049 unsigned int
00050 compiz::CompTransientForReader::getAncestor ()
00051 {
00052   return priv->mWindow->transientFor ();
00053 }
00054 
00055 bool
00056 compiz::CompTransientForReader::isTransientFor (unsigned int ancestor)
00057 {
00058   if (!ancestor ||
00059       !priv->mWindow->id ())
00060       return false;
00061 
00062   return priv->mWindow->transientFor () == ancestor;
00063 }
00064 
00065 bool
00066 compiz::CompTransientForReader::isGroupTransientFor (unsigned int clientLeader)
00067 {
00068   if (!clientLeader ||
00069       !priv->mWindow->id ())
00070     return false;
00071 
00072   if (priv->mWindow->transientFor () == None || priv->mWindow->transientFor () == screen->root ())
00073   {
00074     if (priv->mWindow->type () & (CompWindowTypeUtilMask    |
00075                                   CompWindowTypeToolbarMask |
00076                                   CompWindowTypeMenuMask    |
00077                                   CompWindowTypeDialogMask  |
00078                                   CompWindowTypeModalDialogMask))
00079     {
00080            if (priv->mWindow->clientLeader () == clientLeader)
00081         return true;
00082     }
00083   }
00084 
00085   return false;
00086 }