aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-10-02 16:26:05 (GMT)
committerfluxgen <fluxgen>2002-10-02 16:26:05 (GMT)
commit93ae8f2d2f6bf69832f01f4952ac194c88a0849a (patch)
tree533b68409c65d9934a8533ba7b6447f94a0fdeca /src
parent086ee7d26617da471434971aa26a584996900824 (diff)
downloadfluxbox-93ae8f2d2f6bf69832f01f4952ac194c88a0849a.zip
fluxbox-93ae8f2d2f6bf69832f01f4952ac194c88a0849a.tar.bz2
initial import
Diffstat (limited to 'src')
-rw-r--r--src/Ewmh.cc228
-rw-r--r--src/Ewmh.hh75
2 files changed, 303 insertions, 0 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
new file mode 100644
index 0000000..0d5885b
--- /dev/null
+++ b/src/Ewmh.cc
@@ -0,0 +1,228 @@
1// Ewmh.cc for fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@fluxbox.org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: Ewmh.cc,v 1.1 2002/10/02 16:26:05 fluxgen Exp $
23
24#include "Ewmh.hh"
25
26#include "Screen.hh"
27#include "Window.hh"
28
29#include <iostream>
30using namespace std;
31
32Ewmh::Ewmh() {
33 createAtoms();
34}
35
36Ewmh::~Ewmh() {
37 while (!m_windows.empty()) {
38 XDestroyWindow(BaseDisplay::getXDisplay(), m_windows.back());
39 m_windows.pop_back();
40 }
41}
42
43void Ewmh::initForScreen(const BScreen &screen) {
44 Display *disp = BaseDisplay::getXDisplay();
45
46 XSetWindowAttributes attr;
47 attr.override_redirect = True;
48 Window wincheck = XCreateWindow(disp, screen.getRootWindow(),
49 0, 0, 1, 1, 0,
50 CopyFromParent, InputOnly, CopyFromParent,
51 CWOverrideRedirect, &attr);
52
53 if (wincheck != None) {
54 m_windows.push_back(wincheck);
55
56 XChangeProperty(disp, screen.getRootWindow(), m_net_supporting_wm_check, XA_WINDOW, 32,
57 PropModeReplace, (unsigned char *) &wincheck, 1);
58
59 XChangeProperty(disp, wincheck, m_net_wm_name, XA_STRING, 8,
60 PropModeReplace, (unsigned char *) "Fluxbox", strlen("Fluxbox"));
61 }
62
63 //set supported atoms
64 Atom atomsupported[] = {
65 m_net_wm_state,
66 m_net_wm_state_sticky,
67 m_net_wm_state_shaded,
68
69 m_net_client_list,
70 m_net_number_of_desktops,
71 m_net_current_desktop,
72 m_net_desktop_names,
73 m_net_supporting_wm_check
74 };
75
76 XChangeProperty(disp, screen.getRootWindow(),
77 m_net_supported, XA_ATOM, 32,
78 PropModeReplace, (unsigned char *) &atomsupported, (sizeof atomsupported)/sizeof atomsupported[0]);
79
80
81}
82void Ewmh::setupWindow(FluxboxWindow &win) {
83/*
84 Display *disp = BaseDisplay::getXDisplay();
85 Atom ret_type;
86 int fmt;
87 unsigned long nitems, bytes_after;
88 long flags, *data = 0;
89
90 if (XGetWindowProperty(disp, win.getClientWindow(),
91 m_net_wm_state, 0, 1, False, XA_CARDINAL,
92 &ret_type, &fmt, &nitems, &bytes_after,
93 (unsigned char **) &data) == Success && data) {
94 flags = *data;
95 setState(win, flags);
96 XFree (data);
97 }
98*/
99}
100
101void Ewmh::updateClientList(const BScreen &screen) {
102 size_t num=0;
103
104 BScreen::Workspaces::const_iterator workspace_it = screen.getWorkspacesList().begin();
105 BScreen::Workspaces::const_iterator workspace_it_end = screen.getWorkspacesList().end();
106 for (; workspace_it != workspace_it_end; ++workspace_it) {
107 num += (*workspace_it)->getWindowList().size();
108 }
109 //int num = getCurrentWorkspace()->getWindowList().size();
110
111 Window *wl = new (nothrow) Window[num];
112 if (wl == 0) {
113 cerr<<"Fatal: Out of memory, can't allocate for Ewmh client list"<<endl;
114 return;
115 }
116 //start the iterator from begining
117 workspace_it = screen.getWorkspacesList().begin();
118 int win=0;
119 for (; workspace_it != workspace_it_end; ++workspace_it) {
120
121 // Fill in array of window ID's
122 Workspace::Windows::const_iterator it = (*workspace_it)->getWindowList().begin();
123 Workspace::Windows::const_iterator it_end = (*workspace_it)->getWindowList().end();
124 for (; it != it_end; ++it) {
125 wl[win++] = (*it)->getClientWindow();
126 }
127 }
128 //number of windows to show in client list
129 num = win;
130 XChangeProperty(BaseDisplay::getXDisplay(),
131 screen.getRootWindow(),
132 m_net_client_list,
133 XA_CARDINAL, 32,
134 PropModeReplace, (unsigned char *)wl, num);
135
136 delete wl;
137}
138
139void Ewmh::updateWorkspaceNames(const BScreen &screen) {
140 XTextProperty text;
141 const size_t number_of_desks = screen.getWorkspaceNames().size();
142
143 char *names[number_of_desks];
144
145 for (size_t i = 0; i < number_of_desks; i++) {
146 names[i] = new char[screen.getWorkspaceNames()[i].size()];
147 strcpy(names[i], screen.getWorkspaceNames()[i].c_str());
148 }
149
150 if (XStringListToTextProperty(names, number_of_desks, &text)) {
151 XSetTextProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(),
152 &text, m_net_desktop_names);
153 XFree(text.value);
154 }
155
156 for (size_t i = 0; i < number_of_desks; i++)
157 delete [] names[i];
158}
159
160void Ewmh::updateCurrentWorkspace(const BScreen &screen) {
161 size_t workspace = screen.getCurrentWorkspaceID();
162 XChangeProperty(BaseDisplay::getXDisplay(),
163 screen.getRootWindow(),
164 m_net_current_desktop, XA_CARDINAL, 32, PropModeReplace,
165 (unsigned char *)&workspace, 1);
166
167}
168
169void Ewmh::updateWorkspaceCount(const BScreen &screen) {
170 size_t numworkspaces = screen.getCount();
171 XChangeProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(),
172 m_net_number_of_desktops, XA_CARDINAL, 32, PropModeReplace,
173 (unsigned char *)&numworkspaces, 1);
174}
175
176void Ewmh::updateState(FluxboxWindow &win) {
177
178}
179
180void Ewmh::updateHints(FluxboxWindow &win) {
181
182}
183
184void Ewmh::updateWorkspace(FluxboxWindow &win) {
185
186}
187
188bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, BScreen *screen, FluxboxWindow *win) {
189
190}
191
192
193void Ewmh::createAtoms() {
194 Display *disp = BaseDisplay::getXDisplay();
195 m_net_supported = XInternAtom(disp, "_NET_SUPPORTED", False);
196 m_net_client_list = XInternAtom(disp, "_NET_CLIENT_LIST", False);
197 m_net_client_list_stacking = XInternAtom(disp, "_NET_CLIENT_LIST_STACKING", False);
198 m_net_number_of_desktops = XInternAtom(disp, "_NET_NUMBER_OF_DESKTOPS", False);
199 m_net_desktop_geometry = XInternAtom(disp, "_NET_DESKTOP_GEOMETRY", False);
200 m_net_desktop_viewport = XInternAtom(disp, "_NET_DESKTOP_VIEWPORT", False);
201 m_net_current_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False);
202 m_net_desktop_names = XInternAtom(disp, "_NET_DESKTOP_NAMES", False);
203 m_net_active_window = XInternAtom(disp, "_NET_ACTIVE_WINDOW", False);
204 m_net_workarea = XInternAtom(disp, "_NET_WORKAREA", False);
205 m_net_supporting_wm_check = XInternAtom(disp, "_NET_SUPPORTING_WM_CHECK", False);
206 m_net_virtual_roots = XInternAtom(disp, "_NET_VIRTUAL_ROOTS", False);
207
208 m_net_close_window = XInternAtom(disp, "_NET_CLOSE_WINDOW", False);
209 m_net_wm_moveresize = XInternAtom(disp, "_NET_WM_MOVERESIZE", False);
210
211 m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False);
212 m_net_wm_name = XInternAtom(disp, "_NET_WM_NAME", False);
213 m_net_wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False);
214 m_net_wm_window_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False);
215
216 m_net_wm_state = XInternAtom(disp, "_NET_WM_STATE", False);
217 m_net_wm_state_sticky = XInternAtom(disp, "_NET_WM_STATE_STICKY", False);
218 m_net_wm_state_shaded = XInternAtom(disp, "_NET_WM_STATE_SHADED", False);
219
220 m_net_wm_strut = XInternAtom(disp, "_NET_WM_STRUT", False);
221 m_net_wm_icon_geometry = XInternAtom(disp, "_NET_WM_ICON_GEOMETRY", False);
222 m_net_wm_icon = XInternAtom(disp, "_NET_WM_ICON", False);
223 m_net_wm_pid = XInternAtom(disp, "_NET_WM_PID", False);
224 m_net_wm_handled_icons = XInternAtom(disp, "_NET_WM_HANDLED_ICONS", False);
225
226 m_net_wm_ping = XInternAtom(disp, "_NET_WM_PING", False);
227}
228
diff --git a/src/Ewmh.hh b/src/Ewmh.hh
new file mode 100644
index 0000000..2344045
--- /dev/null
+++ b/src/Ewmh.hh
@@ -0,0 +1,75 @@
1// Ewmh.hh for fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@fluxbox.org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: Ewmh.hh,v 1.1 2002/10/02 16:26:05 fluxgen Exp $
23
24#include "AtomHandler.hh"
25
26#include <X11/Xatom.h>
27#include <vector>
28
29class Ewmh:public AtomHandler {
30public:
31
32 Ewmh();
33 ~Ewmh();
34 void initForScreen(const BScreen &screen);
35 void setupWindow(FluxboxWindow &win);
36
37 void updateClientList(const BScreen &screen);
38 void updateWorkspaceNames(const BScreen &screen);
39 void updateCurrentWorkspace(const BScreen &screen);
40 void updateWorkspaceCount(const BScreen &screen);
41
42 void updateState(FluxboxWindow &win);
43 void updateHints(FluxboxWindow &win);
44 void updateWorkspace(FluxboxWindow &win);
45
46
47 bool checkClientMessage(const XClientMessageEvent &ce,
48 BScreen *screen, FluxboxWindow *win);
49private:
50
51 enum { STATE_REMOVE = 0, STATE_ADD = 1, STATE_TOGGLE = 2};
52
53 void setState(FluxboxWindow &win, Atom flags) const;
54 void createAtoms();
55
56 // root window properties
57 Atom m_net_supported, m_net_client_list, m_net_client_list_stacking,
58 m_net_number_of_desktops, m_net_desktop_geometry, m_net_desktop_viewport,
59 m_net_current_desktop, m_net_desktop_names, m_net_active_window, m_net_workarea,
60 m_net_supporting_wm_check, m_net_virtual_roots;
61
62 // root window messages
63 Atom m_net_close_window, m_net_wm_moveresize;
64
65 // application window properties
66 Atom m_net_properties, m_net_wm_name, m_net_wm_desktop, m_net_wm_window_type,
67 m_net_wm_state, m_net_wm_state_sticky, m_net_wm_state_shaded,
68 m_net_wm_strut, m_net_wm_icon_geometry, m_net_wm_icon, m_net_wm_pid,
69 m_net_wm_handled_icons;
70
71 // application protocols
72 Atom m_net_wm_ping;
73
74 std::vector<Window> m_windows;
75};