]>
Dogcows Code - chaz/openbox/blob - util/epist/epist.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // epist.cc for Epistrophy - 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.
24 # include "../../config.h"
25 #endif // HAVE_CONFIG_H
29 # include <sys/types.h>
31 #endif // HAVE_UNISTD_H
35 #endif // HAVE_STDLIB_H
39 #endif // HAVE_SIGNAL_H
43 #endif // HAVE_LIBGEN_H
58 #include "../../src/XAtom.hh"
61 epist::epist(char **argv
, char *dpy_name
, char *rc_file
)
62 : BaseDisplay(argv
[0], dpy_name
) {
69 _rc_file
= expandTilde("~/.epistrc");
71 _xatom
= new XAtom(getXDisplay());
73 _active
= _clients
.end();
75 for (unsigned int i
= 0; i
< getNumberOfScreens(); ++i
) {
76 screen
*s
= new screen(this, i
);
78 _screens
.push_back(s
);
79 s
->updateEverything();
82 if (_screens
.empty()) {
83 cout
<< "No compatible window manager found on any screens. Aborting.\n";
87 _ktree
= new keytree(getXDisplay());
89 // set up the key tree
101 void epist::activateGrabs() {
103 ScreenList::const_iterator scrit
, scrend
= _screens
.end();
105 for (scrit
= _screens
.begin(); scrit
!= scrend
; ++scrit
)
106 _ktree
->grabDefaults(*scrit
);
110 bool epist::handleSignal(int sig
) {
113 cout
<< "epist: Restarting on request.\n";
114 execvp(_argv
[0], _argv
);
115 execvp(basename(_argv
[0]), _argv
);
116 return false; // this should be unreachable
129 void epist::process_event(XEvent
*e
) {
130 ScreenList::const_iterator it
, end
= _screens
.end();
131 for (it
= _screens
.begin(); it
!= end
; ++it
) {
132 if ((*it
)->rootWindow() == e
->xany
.window
) {
133 (*it
)->processEvent(*e
);
138 // wasnt a root window, try for client windows
139 XWindow
*w
= findWindow(e
->xany
.window
);
140 if (w
) w
->processEvent(*e
);
144 void epist::addWindow(XWindow
*window
) {
145 _windows
.insert(WindowLookupPair(window
->window(), window
));
149 void epist::removeWindow(XWindow
*window
) {
150 _windows
.erase(window
->window());
154 XWindow
*epist::findWindow(Window window
) const {
155 WindowLookup::const_iterator it
= _windows
.find(window
);
156 if (it
!= _windows
.end())
163 void epist::cycleScreen(int current
, bool forward
) const {
165 for (i
= 0; i
< _screens
.size(); ++i
)
166 if (_screens
[i
]->number() == current
) {
170 assert(i
< _screens
.size()); // current is for an unmanaged screen
172 int dest
= current
+ (forward
? 1 : -1);
174 if (dest
< 0) dest
= (signed)_screens
.size() - 1;
175 else if (dest
>= (signed)_screens
.size()) dest
= 0;
177 const XWindow
*target
= _screens
[dest
]->lastActiveWindow();
178 if (target
) target
->focus();
This page took 0.047056 seconds and 4 git commands to generate.