add more spacing
[personal-kdebase.git] / workspace / kcontrol / kfontinst / apps / CreateParent.h
blob26445e70ba11a96ccb29ca18a469e7c312d7c5c5
1 #ifndef __CREATE_PARENT_H__
2 #define __CREATE_PARENT_H__
4 /*
5 * KFontInst - KDE Font Installer
7 * Copyright 2003-2007 Craig Drummond <craig@kde.org>
9 * ----
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
27 #include <QtGui/QX11Info>
28 #include <X11/Xlib.h>
29 #include <fixx11h.h>
32 // *Very* hacky way to get some KDE dialogs to appear to be transient
33 // for 'xid'
35 // Create's a QWidget with size 0/0 and no border, makes this transient
36 // for xid, and all other widgets can use this as their parent...
37 static QWidget * createParent(int xid)
39 if(!xid)
40 return NULL;
42 QWidget *parent=new QWidget(NULL, Qt::FramelessWindowHint);
44 parent->resize(1, 1);
45 parent->show();
47 XWindowAttributes attr;
48 int rx, ry;
49 Window junkwin;
51 XSetTransientForHint(QX11Info::display(), parent->winId(), xid);
52 if(XGetWindowAttributes(QX11Info::display(), xid, &attr))
54 XTranslateCoordinates(QX11Info::display(), xid, attr.root,
55 -attr.border_width, -16,
56 &rx, &ry, &junkwin);
58 rx=(rx+(attr.width/2));
59 if(rx<0)
60 rx=0;
61 ry=(ry+(attr.height/2));
62 if(ry<0)
63 ry=0;
64 parent->move(rx, ry);
66 parent->setWindowOpacity(0);
68 return parent;
71 #endif