]>
Dogcows Code - chaz/openbox/blob - util/epist/process.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // process.cc for Epistory - a key handler for NETWM/EWMH window managers.
3 // Copyright (c) 2002 - 2002 Ben Jansens <ben at orodu.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.
28 # include "../../config.h"
29 #endif // HAVE_CONFIG_H
36 #include "../../src/XAtom.hh"
39 WindowList::iterator _active
= _clients
.end();
41 void processEvent(const XEvent
&e
) {
44 if (e
.xproperty
.atom
== _xatom
->getAtom(XAtom::net_active_window
))
46 if (e
.xproperty
.atom
== _xatom
->getAtom(XAtom::net_client_list
))
53 void updateClientList() {
54 WindowList::iterator insert_point
= _active
;
55 if (insert_point
!= _clients
.end())
56 ++insert_point
; // get to the item client the focused client
58 // get the client list from the root window
59 Window
*rootclients
= 0;
60 unsigned long num
= (unsigned) -1;
61 if (! _xatom
->getValue(_root
, XAtom::net_client_list
, XAtom::window
, num
,
63 _clients
.clear(); // no clients left
64 if (rootclients
) delete [] rootclients
;
68 WindowList::iterator it
, end
= _clients
.end();
71 // insert new clients after the active window
72 for (i
= 0; i
< num
; ++i
) {
73 for (it
= _clients
.begin(); it
!= end
; ++it
)
74 if (*it
== rootclients
[i
])
76 if (it
== end
) { // didn't already exist
77 _clients
.insert(insert_point
, rootclients
[i
]);
78 cout
<< "Added window: " << rootclients
[i
] << endl
;
82 // remove clients that no longer exist
83 for (it
= _clients
.begin(); it
!= end
;) {
84 WindowList::iterator it2
= it
++;
85 for (i
= 0; i
< num
; ++i
)
86 if (*it2
== rootclients
[i
])
88 if (i
== num
) { // no longer exists
90 cout
<< "Removed window: " << it2
->window() << endl
;
94 if (rootclients
) delete [] rootclients
;
98 void updateActiveWindow() {
100 _xatom
->getValue(_root
, XAtom::net_active_window
, XAtom::window
, a
);
102 WindowList::iterator it
, end
= _clients
.end();
103 for (it
= _clients
.begin(); it
!= end
; ++it
) {
109 cout
<< "Active window is now: ";
110 if (_active
== _clients
.end()) cout
<< "None\n";
111 else cout
<< _active
->window() << endl
;
This page took 0.040666 seconds and 4 git commands to generate.