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

tdecore

  • tdecore
kipc.cpp
1/* This file is part of the KDE libraries
2
3 Copyright (C) 1999 Mattias Ettrich (ettrich@kde.org)
4 Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22
23/*
24 * kipc.cpp: Send a message to one/all KDE apps.
25 *
26 * $Id$
27 */
28#include "config.h"
29
30#include <tqevent.h>
31#include <tqwindowdefs.h>
32
33#if defined TQ_WS_X11
34#include <X11/X.h>
35#include <X11/Xlib.h>
36#include <kxerrorhandler.h>
37#endif
38
39#include <kipc.h>
40
41
42#if defined TQ_WS_X11
43static long getSimpleProperty(Window w, Atom a)
44{
45 Atom real_type;
46 int format;
47 unsigned long n, extra, res = 0;
48 int status;
49 unsigned char *p = 0;
50
51 status = XGetWindowProperty(tqt_xdisplay(), w, a, 0L, 1L, False, a,
52 &real_type, &format, &n, &extra, &p);
53 if ((status == Success) && (n == 1) && (format == 32))
54 res = *(unsigned long*)p;
55 if (p) XFree(p);
56 return res;
57}
58#endif
59
60void KIPC::sendMessage(Message msg, WId w, int data)
61{
62#if defined TQ_WS_X11
63 static Atom a = 0;
64 if (a == 0)
65 a = XInternAtom(tqt_xdisplay(), "KIPC_COMM_ATOM", False);
66 XEvent ev;
67 ev.xclient.type = ClientMessage;
68 ev.xclient.display = tqt_xdisplay();
69 ev.xclient.window = (Window) w;
70 ev.xclient.message_type = a;
71 ev.xclient.format = 32;
72 ev.xclient.data.l[0] = msg;
73 ev.xclient.data.l[1] = data;
74 XSendEvent(tqt_xdisplay(), (Window) w, False, 0L, &ev);
75
76 // KDE 1 support
77 static Atom kde1 = 0;
78 if ( msg == PaletteChanged || msg == FontChanged ) {
79 if ( kde1 == 0 )
80 kde1 = XInternAtom(tqt_xdisplay(), "KDEChangeGeneral", False );
81 ev.xclient.message_type = kde1;
82 XSendEvent(tqt_xdisplay(), (Window) w, False, 0L, &ev);
83 }
84
85#endif
86}
87
88
89void KIPC::sendMessageAll(Message msg, int data)
90{
91#if defined TQ_WS_X11
92 unsigned int i, nrootwins;
93 Window dw1, dw2, *rootwins = 0;
94 Display *dpy = tqt_xdisplay();
95 int screen_count = ScreenCount(dpy);
96
97 KXErrorHandler handler;
98 for (int s = 0; s < screen_count; s++) {
99 Window root = RootWindow(dpy, s);
100
101 XQueryTree(dpy, root, &dw1, &dw2, &rootwins, &nrootwins);
102 Atom a = XInternAtom(tqt_xdisplay(), "KDE_DESKTOP_WINDOW", False);
103 for (i = 0; i < nrootwins; i++)
104 {
105 if (getSimpleProperty(rootwins[i], a) != 0L)
106 sendMessage(msg, rootwins[i], data);
107 }
108 XFree((char *) rootwins);
109 }
110 XSync(dpy,False);
111#endif
112}
113
KIPC::sendMessage
static void sendMessage(Message msg, WId w, int data=0)
Send a message to a specific application.
Definition: kipc.cpp:60
KIPC::sendMessageAll
static void sendMessageAll(Message msg, int data=0)
Send a message to all KDE application on the current display.
Definition: kipc.cpp:89
KIPC::Message
Message
A identifier for messages.
Definition: kipc.h:56
KXErrorHandler
This class simplifies handling of X errors.
Definition: kxerrorhandler.h:58

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.9.4
This website is maintained by Timothy Pearson.