• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDECore

kipc.cpp

Go to the documentation of this file.
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: kipc.cpp 482239 2005-11-22 08:32:28Z coolo $
00027  */
00028 #include "config.h"
00029 
00030 #include <qwindowdefs.h>
00031 
00032 #if defined Q_WS_X11
00033 #include <X11/X.h> 
00034 #include <X11/Xlib.h> 
00035 #include <kxerrorhandler.h> 
00036 #endif
00037 
00038 #include <kipc.h>
00039 
00040 
00041 #if defined Q_WS_X11
00042 static long getSimpleProperty(Window w, Atom a)
00043 {
00044     Atom real_type;
00045     int format;
00046     unsigned long n, extra, res = 0;
00047     int status;
00048     unsigned char *p = 0;
00049 
00050     status = XGetWindowProperty(qt_xdisplay(), w, a, 0L, 1L, False, a,
00051             &real_type, &format, &n, &extra, &p);
00052     if ((status == Success) && (n == 1) && (format == 32))
00053     res = *(unsigned long*)p;
00054     if (p) XFree(p);
00055     return res;
00056 }
00057 #endif
00058 
00059 void KIPC::sendMessage(Message msg, WId w, int data)
00060 {
00061 #if defined Q_WS_X11
00062     static Atom a = 0;
00063     if (a == 0)
00064     a = XInternAtom(qt_xdisplay(), "KIPC_COMM_ATOM", False);
00065     XEvent ev;
00066     ev.xclient.type = ClientMessage;
00067     ev.xclient.display = qt_xdisplay();
00068     ev.xclient.window = (Window) w;
00069     ev.xclient.message_type = a;
00070     ev.xclient.format = 32;
00071     ev.xclient.data.l[0] = msg;
00072     ev.xclient.data.l[1] = data;
00073     XSendEvent(qt_xdisplay(), (Window) w, False, 0L, &ev);
00074 
00075     // KDE 1 support
00076     static Atom kde1 = 0;
00077     if ( msg == PaletteChanged || msg == FontChanged ) {
00078     if ( kde1 == 0 )
00079         kde1 = XInternAtom(qt_xdisplay(), "KDEChangeGeneral", False );
00080     ev.xclient.message_type = kde1;
00081     XSendEvent(qt_xdisplay(), (Window) w, False, 0L, &ev);
00082     }
00083 
00084 #endif
00085 }
00086 
00087 
00088 void KIPC::sendMessageAll(Message msg, int data)
00089 {
00090 #if defined Q_WS_X11
00091     unsigned int i, nrootwins;
00092     Window dw1, dw2, *rootwins = 0;
00093     Display *dpy = qt_xdisplay();
00094     int screen_count = ScreenCount(dpy);
00095 
00096     KXErrorHandler handler;
00097     for (int s = 0; s < screen_count; s++) {
00098     Window root = RootWindow(dpy, s);
00099 
00100     XQueryTree(dpy, root, &dw1, &dw2, &rootwins, &nrootwins);
00101     Atom a = XInternAtom(qt_xdisplay(), "KDE_DESKTOP_WINDOW", False);
00102     for (i = 0; i < nrootwins; i++)
00103         {
00104         if (getSimpleProperty(rootwins[i], a) != 0L)
00105             sendMessage(msg, rootwins[i], data);
00106         }
00107         XFree((char *) rootwins);
00108     }
00109     XSync(dpy,False);
00110 #endif
00111 }
00112 

KDECore

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal