]>
Dogcows Code - chaz/openbox/blob - util/epist/epist.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // epist.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.
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
56 #include "../../src/XAtom.hh"
59 epist::epist(char **argv
, char *dpy_name
, char *rc_file
)
60 : BaseDisplay(argv
[0], dpy_name
) {
67 _rc_file
= expandTilde("~/.openbox/epistrc");
69 _xatom
= new XAtom(getXDisplay());
71 screen
*s
= new screen(this, DefaultScreen(getXDisplay()));
73 _screens
.push_back(s
);
74 if (_screens
.empty()) {
75 cout
<< "No compatible window manager found on any screens. Aborting.\n";
79 _actions
.push_back(Action(Action::nextDesktop
,
80 XKeysymToKeycode(getXDisplay(),
81 XStringToKeysym("Tab")),
83 _actions
.push_back(Action(Action::prevDesktop
,
84 XKeysymToKeycode(getXDisplay(),
85 XStringToKeysym("Tab")),
95 // XGrabKey(_epist->getXDisplay(), XKeysymToKeycode(_epist->getXDisplay(),
96 // XStringToKeysym("F5")),
97 // Mod1Mask, _root, True, GrabModeAsync, GrabModeAsync);
99 void epist::activateGrabs() {
101 ScreenList::const_iterator scrit
, scrend
= _screens
.end();
103 for (scrit
= _screens
.begin(); scrit
!= scrend
; ++scrit
) {
104 ActionList::const_iterator end
= _actions
.end();
106 for(ActionList::const_iterator ait
= _actions
.begin();
108 XGrabKey(getXDisplay(), ait
->keycode(), ait
->modifierMask(),
109 (*scrit
)->rootWindow(), True
, GrabModeAsync
, GrabModeAsync
);
113 bool epist::handleSignal(int sig
) {
116 cout
<< "epist: Restarting on request.\n";
117 execvp(_argv
[0], _argv
);
118 execvp(basename(_argv
[0]), _argv
);
119 return false; // this should be unreachable
132 void epist::process_event(XEvent
*e
) {
135 if (e
->xany
.type
== KeyPress
)
138 root
= e
->xany
.window
;
140 ScreenList::const_iterator it
, end
= _screens
.end();
141 for (it
= _screens
.begin(); it
!= end
; ++it
) {
142 if ((*it
)->rootWindow() == root
) {
143 (*it
)->processEvent(*e
);
148 // wasnt a root window, try for client windows
149 XWindow
*w
= findWindow(e
->xany
.window
);
150 if (w
) w
->processEvent(*e
);
154 void epist::addWindow(XWindow
*window
) {
155 _windows
.insert(WindowLookupPair(window
->window(), window
));
159 void epist::removeWindow(XWindow
*window
) {
160 _windows
.erase(window
->window());
164 XWindow
*epist::findWindow(Window window
) const {
165 WindowLookup::const_iterator it
= _windows
.find(window
);
166 if (it
!= _windows
.end())
This page took 0.039183 seconds and 4 git commands to generate.