Back to index

unity  6.0.0
x11-window-read-transients.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 "x11-window-read-transients.h"
00023 
00024 #ifndef _GNU_SOURCE
00025 #define _GNU_SOURCE
00026 #endif
00027 
00028 X11WindowReadTransients::X11WindowReadTransients (Display *d, Window w) :
00029     X11Window::X11Window (d, w)
00030 {
00031 }
00032 
00033 X11WindowReadTransients::~X11WindowReadTransients ()
00034 {
00035 }
00036 
00037 void
00038 X11WindowReadTransients::makeTransientFor (X11WindowReadTransients *w)
00039 {
00040   XSetTransientForHint (mDpy, mXid, w->id ());
00041   XSync (mDpy, false);
00042 }
00043 
00044 void
00045 X11WindowReadTransients::setClientLeader (X11WindowReadTransients *w)
00046 {
00047   Atom wmClientLeader = XInternAtom (mDpy, "WM_CLIENT_LEADER", 0);
00048   Atom netWmWindowType = XInternAtom (mDpy, "_NET_WM_WINDOW_TYPE", 0);
00049   Atom netWmWindowTypeDialog = XInternAtom (mDpy, "_NET_WM_WINDOW_TYPE_DIALOG", 0);
00050 
00051   Window cl = w->id ();
00052 
00053   XChangeProperty (mDpy, mXid, wmClientLeader, XA_WINDOW, 32,
00054                    PropModeReplace, (unsigned char *) &cl, 1);
00055   XChangeProperty (mDpy, mXid, netWmWindowType, XA_ATOM, 32,
00056                    PropModeAppend, (const unsigned char *) &netWmWindowTypeDialog, 1);
00057 
00058   XSync (mDpy, false);
00059 }
00060 
00061 std::vector<unsigned int>
00062 X11WindowReadTransients::transients ()
00063 {
00064   compiz::X11TransientForReader *reader = new compiz::X11TransientForReader (mDpy, mXid);
00065   std::vector<unsigned int> transients = reader->getTransients ();
00066 
00067   delete reader;
00068   return transients;
00069 }
00070 
00071 void
00072 X11WindowReadTransients::printTransients ()
00073 {
00074   for (unsigned int &w : transients ())
00075     printf ("window id 0x%x\n", w);
00076 }