• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

kipc.cpp

00001 /* This file is part of the KDE libraries
00002 
00003    Copyright (C) 1999 Mattias Ettrich (ettrich@kde.org)
00004    Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020 */
00021 
00022 
00023 /*
00024  * kipc.cpp: Send a message to one/all KDE apps.
00025  *
00026  * $Id$
00027  */
00028 #include "config.h"
00029 
00030 #include <tqevent.h>
00031 #include <tqwindowdefs.h>
00032 
00033 #if defined Q_WS_X11
00034 #include <X11/X.h>
00035 #include <X11/Xlib.h>
00036 #include <kxerrorhandler.h>
00037 #endif
00038 
00039 #include <kipc.h>
00040 
00041 
00042 #if defined Q_WS_X11
00043 static long getSimpleProperty(Window w, Atom a)
00044 {
00045     Atom real_type;
00046     int format;
00047     unsigned long n, extra, res = 0;
00048     int status;
00049     unsigned char *p = 0;
00050 
00051     status = XGetWindowProperty(tqt_xdisplay(), w, a, 0L, 1L, False, a,
00052             &real_type, &format, &n, &extra, &p);
00053     if ((status == Success) && (n == 1) && (format == 32))
00054     res = *(unsigned long*)p;
00055     if (p) XFree(p);
00056     return res;
00057 }
00058 #endif
00059 
00060 void KIPC::sendMessage(Message msg, WId w, int data)
00061 {
00062 #if defined Q_WS_X11
00063     static Atom a = 0;
00064     if (a == 0)
00065     a = XInternAtom(tqt_xdisplay(), "KIPC_COMM_ATOM", False);
00066     XEvent ev;
00067     ev.xclient.type = ClientMessage;
00068     ev.xclient.display = tqt_xdisplay();
00069     ev.xclient.window = (Window) w;
00070     ev.xclient.message_type = a;
00071     ev.xclient.format = 32;
00072     ev.xclient.data.l[0] = msg;
00073     ev.xclient.data.l[1] = data;
00074     XSendEvent(tqt_xdisplay(), (Window) w, False, 0L, &ev);
00075 
00076     // KDE 1 support
00077     static Atom kde1 = 0;
00078     if ( msg == PaletteChanged || msg == FontChanged ) {
00079     if ( kde1 == 0 )
00080         kde1 = XInternAtom(tqt_xdisplay(), "KDEChangeGeneral", False );
00081     ev.xclient.message_type = kde1;
00082     XSendEvent(tqt_xdisplay(), (Window) w, False, 0L, &ev);
00083     }
00084 
00085 #endif
00086 }
00087 
00088 
00089 void KIPC::sendMessageAll(Message msg, int data)
00090 {
00091 #if defined Q_WS_X11
00092     unsigned int i, nrootwins;
00093     Window dw1, dw2, *rootwins = 0;
00094     Display *dpy = tqt_xdisplay();
00095     int screen_count = ScreenCount(dpy);
00096 
00097     KXErrorHandler handler;
00098     for (int s = 0; s < screen_count; s++) {
00099     Window root = RootWindow(dpy, s);
00100 
00101     XQueryTree(dpy, root, &dw1, &dw2, &rootwins, &nrootwins);
00102     Atom a = XInternAtom(tqt_xdisplay(), "KDE_DESKTOP_WINDOW", False);
00103     for (i = 0; i < nrootwins; i++)
00104         {
00105         if (getSimpleProperty(rootwins[i], a) != 0L)
00106             sendMessage(msg, rootwins[i], data);
00107         }
00108         XFree((char *) rootwins);
00109     }
00110     XSync(dpy,False);
00111 #endif
00112 }
00113 

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.7.1
This website is maintained by Timothy Pearson.