From 5bf463ea955bd7e27b1f04a1eefb28ec52309cb8 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 20 Jul 2002 09:17:23 +0000 Subject: [PATCH] add the ability to close a window --- util/epist/actions.hh | 12 ++++++------ util/epist/epist.cc | 4 ++++ util/epist/screen.cc | 4 ++++ util/epist/window.cc | 6 ++++++ util/epist/window.hh | 1 + 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/util/epist/actions.hh b/util/epist/actions.hh index 11c262e0..1c70fc63 100644 --- a/util/epist/actions.hh +++ b/util/epist/actions.hh @@ -36,17 +36,17 @@ public: noaction = 0, execute, iconify, - raiseWindow, - lowerWindow, - closeWindow, - toggleshade, + raise, + lower, + close, //done + toggleshade, //done moveWindowUp, moveWindowDown, moveWindowLeft, moveWindowRight, - nextWindow, - prevWindow, + nextWindow, //done for now + prevWindow, //done for now nextWindowOnAllWorkspaces, prevWindowOnAllWorkspaces, diff --git a/util/epist/epist.cc b/util/epist/epist.cc index 3fb06463..feb6cd4c 100644 --- a/util/epist/epist.cc +++ b/util/epist/epist.cc @@ -88,6 +88,10 @@ epist::epist(char **argv, char *dpy_name, char *rc_file) XKeysymToKeycode(getXDisplay(), XStringToKeysym("F5")), Mod1Mask)); + _actions.push_back(Action(Action::close, + XKeysymToKeycode(getXDisplay(), + XStringToKeysym("F4")), + Mod1Mask)); _actions.push_back(Action(Action::nextWindow, XKeysymToKeycode(getXDisplay(), XStringToKeysym("Tab")), diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 0d97b614..7c4294a0 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -175,6 +175,10 @@ void screen::handleKeypress(const XEvent &e) { XWindow *window = *_active; switch (it->type()) { + case Action::close: + window->close(); + return; + case Action::toggleshade: window->shade(! window->shaded()); return; diff --git a/util/epist/window.cc b/util/epist/window.cc index e650f415..c956bdfa 100644 --- a/util/epist/window.cc +++ b/util/epist/window.cc @@ -148,3 +148,9 @@ void XWindow::shade(const bool sh) const { _window, (sh ? 1 : 0), _xatom->getAtom(XAtom::net_wm_state_shaded)); } + + +void XWindow::close() const { + _xatom->sendClientMessage(_screen->rootWindow(), XAtom::net_close_window, + _window); +} diff --git a/util/epist/window.hh b/util/epist/window.hh index edd126b0..5c275d74 100644 --- a/util/epist/window.hh +++ b/util/epist/window.hh @@ -81,6 +81,7 @@ public: void processEvent(const XEvent &e); void shade(const bool sh) const; + void close() const; bool operator == (const XWindow &w) const { return w._window == _window; } bool operator == (const Window &w) const { return w == _window; } -- 2.45.2