1 // Netizen.cc for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
23 // stupid macros needed to access some functions in version 2 of the GNU C
30 #include "../config.h"
31 #endif // HAVE_CONFIG_H
36 Netizen::Netizen(BScreen &scr, Window win) : screen(scr),
37 basedisplay(scr.getBaseDisplay()), window(win)
39 event.type = ClientMessage;
40 event.xclient.message_type = basedisplay.getOpenboxStructureMessagesAtom();
41 event.xclient.display = basedisplay.getXDisplay();
42 event.xclient.window = window;
43 event.xclient.format = 32;
44 event.xclient.data.l[0] = basedisplay.getOpenboxNotifyStartupAtom();
45 event.xclient.data.l[1] = event.xclient.data.l[2] =
46 event.xclient.data.l[3] = event.xclient.data.l[4] = 0l;
48 XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
52 void Netizen::sendWorkspaceCount(void) {
53 event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWorkspaceCountAtom();
54 event.xclient.data.l[1] = screen.getWorkspaceCount();
56 XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
60 void Netizen::sendCurrentWorkspace(void) {
61 event.xclient.data.l[0] = basedisplay.getOpenboxNotifyCurrentWorkspaceAtom();
62 event.xclient.data.l[1] = screen.getCurrentWorkspaceID();
64 XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
68 void Netizen::sendWindowFocus(Window w) {
69 event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowFocusAtom();
70 event.xclient.data.l[1] = w;
72 XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
76 void Netizen::sendWindowAdd(Window w, unsigned long p) {
77 event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowAddAtom();
78 event.xclient.data.l[1] = w;
79 event.xclient.data.l[2] = p;
81 XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
83 event.xclient.data.l[2] = 0l;
87 void Netizen::sendWindowDel(Window w) {
88 event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowDelAtom();
89 event.xclient.data.l[1] = w;
91 XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
95 void Netizen::sendWindowRaise(Window w) {
96 event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowRaiseAtom();
97 event.xclient.data.l[1] = w;
99 XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
103 void Netizen::sendWindowLower(Window w) {
104 event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowLowerAtom();
105 event.xclient.data.l[1] = w;
107 XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
111 void Netizen::sendConfigNotify(XEvent *e) {
112 XSendEvent(basedisplay.getXDisplay(), window, False,
113 StructureNotifyMask, e);